forked from wrenn/wrenn
fix: resolve bugs and DRY violations in sandbox manager and API handlers
- Fix createFromSnapshot discarding memoryMB param (balloon optimization was dead) - Fix double dm-snapshot removal in Pause() cleanupPauseFailure path - Fix DestroySandbox RPC mapping all errors to CodeNotFound - Fix handleFailed event consumer missing pausing/resuming → error transitions - Fix stream resource leak in StreamUpload on early-return paths - Add envs/cwd fields to ExecRequest proto for foreground exec parity - Extract createResources rollback helper to eliminate 4x duplicated teardown - Remove unused chClient.ping method - Add .mcp.json to gitignore Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -78,15 +78,30 @@ type ExecResult struct {
|
||||
ExitCode int32
|
||||
}
|
||||
|
||||
// ExecOpts holds optional parameters for Exec.
|
||||
type ExecOpts struct {
|
||||
Envs map[string]string
|
||||
Cwd string
|
||||
}
|
||||
|
||||
// Exec runs a command inside the sandbox and collects all stdout/stderr output.
|
||||
// It blocks until the command completes.
|
||||
func (c *Client) Exec(ctx context.Context, cmd string, args ...string) (*ExecResult, error) {
|
||||
func (c *Client) Exec(ctx context.Context, cmd string, args []string, opts *ExecOpts) (*ExecResult, error) {
|
||||
stdin := false
|
||||
proc := &envdpb.ProcessConfig{
|
||||
Cmd: cmd,
|
||||
Args: args,
|
||||
}
|
||||
if opts != nil {
|
||||
if len(opts.Envs) > 0 {
|
||||
proc.Envs = opts.Envs
|
||||
}
|
||||
if opts.Cwd != "" {
|
||||
proc.Cwd = &opts.Cwd
|
||||
}
|
||||
}
|
||||
req := connect.NewRequest(&envdpb.StartRequest{
|
||||
Process: &envdpb.ProcessConfig{
|
||||
Cmd: cmd,
|
||||
Args: args,
|
||||
},
|
||||
Process: proc,
|
||||
Stdin: &stdin,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user