Skip to content

An open-source, faster Devin alternative

TypeScript

Make exec/run, snapshots, and the /files cold path async to eliminate Cloudflare 524s (+ fix reaper exit-code -1 and CP synchronous wake)

Brian Reardonf377e9b76c83
diff --git a/cmd/worker/main.go b/cmd/worker/main.go
index 6fb4ec6e..9d9e9824 100644
--- a/cmd/worker/main.go
+++ b/cmd/worker/main.go
@@ -1123,8 +1123,13 @@ func consumeExecOutput(stream agentpb.SandboxAgent_ExecSessionAttachClient, scro
scrollback.Write(2, msg.Data)
case agentpb.ExecSessionOutput_EXIT:
exitCode := int(msg.ExitCode)
+ handle.ExitedAt = time.Now()
handle.ExitCode = &exitCode
handle.Running = false
+ slog.Info("exec_session_exit",
+ "sandbox", handle.SandboxID, "session", handle.ID,
+ "exit_code", exitCode,
+ "command_ms", time.Since(handle.StartedAt).Milliseconds())
return
case agentpb.ExecSessionOutput_SCROLLBACK_END:
// Transition from scrollback replay to live
diff --git a/internal/agent/exec_session.go b/internal/agent/exec_session.go
index f08f4baa..5d44129c 100644
--- a/internal/agent/exec_session.go
+++ b/internal/agent/exec_session.go
@@ -2,6 +2,7 @@ package agent
import (
"context"
+ "errors"
"fmt"
"io"
"log"
@@ -116,7 +117,15 @@ func (s *Server) ExecSessionCreate(ctx context.Context, req *pb.ExecSessionCreat
log.Printf("exec-session: start failed: %v (cmd=%s)", err, req.Command)
return nil, fmt.Errorf("start command: %w", err)
}
- moveToCgroup(cmd.Process.Pid)
+ pid := cmd.Process.Pid
+ // Register with the SIGCHLD reaper BEFORE the child can exit. For
+ // fast-exiting commands the reaper's Wait4(-1) can reap the child before
+ // our cmd.Wait() runs, making cmd.Wait() return ECHILD and
+ // ProcessState.ExitCode() report -1. We recover the real status from this
+ // channel instead. Same coordination as the one-shot Exec path; see
+ // reap_registry.go.
+ exitCh := RegisterReap(pid)
+ moveToCgroup(pid)
s.execMu.Lock()
s.execSessions[sessionID] = sess
@@ -162,10 +171,30 @@ func (s *Server) ExecSessionCreate(ctx context.Context, req *pb.ExecSessionCreat
// Wait for command exit — ensure all pipe output is collected first
go func() {
- _ = cmd.Wait()
+ waitErr := cmd.Wait()
// Wait for stdout/stderr goroutines to finish reading remaining pipe data
pipeWg.Wait()
- code := int32(cmd.ProcessState.ExitCode())
+
+ // Resolve the exit code, coordinating with the SIGCHLD reaper. If the
+ // reaper won the race, cmd.Wait() returns ECHILD and ProcessState is
+ // unreliable — pull the real status from the registered channel.
+ var code int32
+ switch {
+ case waitErr == nil:
+ code = int32(cmd.ProcessState.ExitCode())
+ UnregisterReap(pid)
+ case isExitError(waitErr):
+ code = int32(waitErr.(*exec.ExitError).ExitCode())
+ UnregisterReap(pid)
+ case errors.Is(waitErr, syscall.ECHILD):
+ ws := <-exitCh
+ code = int32(ws.ExitStatus())
+ default:
+ // Unknown wait error — best effort from ProcessState, drop the reg.
+ code = int32(cmd.ProcessState.ExitCode())
+ UnregisterReap(pid)
+ }
+
sess.mu.Lock()
sess.exitCode = &code
sess.mu.Unlock()
diff --git a/internal/api/exec_session.go b/internal/api/exec_session.go
index 3c834d2d..03585f94 100644
--- a/internal/api/exec_session.go
+++ b/internal/api/exec_session.go
@@ -233,6 +233,14 @@ func (s *Server) execRun(c echo.Context) error {
return s.execRunRemote(c, id, req)
}
+ // Async path (QEMU worker): run the command as a background exec session
+ // and return a handle immediately. The caller polls GET /exec/:execId/result
+ // for completion. Every HTTP request stays sub-second, so the edge proxy
+ // never 524s no matter how long the command runs.
+ if s.execSessionManager != nil {
+ return s.execRunAsync(c, id, req)
+ }
+
if s.manager == nil {
return c.JSON(http.StatusServiceUnavailable, errSandboxNotAvailable)
}
@@ -315,6 +323,85 @@ func (s *Server) execRunRemote(c echo.Context, sandboxID string, req types.Proce
})
}
+// execRunAsync runs a command as a background exec session and returns a handle
+// immediately. Mirrors createExecSession but maps the ProcessConfig shape and
+// returns an ExecRunResponse. The command keeps running independent of this
+// connection; the result persists on the worker (scrollback + exit code, with
+// the agent's 5-min post-exit retention) and is fetched via execResult.
+func (s *Server) execRunAsync(c echo.Context, id string, req types.ProcessConfig) error {
+ sreq := types.ExecSessionCreateRequest{
+ Command: req.Command,
+ Args: req.Args,
+ Env: req.Env,
+ Cwd: req.Cwd,
+ Timeout: req.Timeout,
+ }
+
+ var session *sandbox.ExecSessionHandle
+
+ routeOp := func(_ context.Context) error {
+ var err error
+ session, err = s.execSessionManager.CreateSession(id, sreq)
+ return err
+ }
+
+ if s.router != nil {
+ if err := s.router.Route(c.Request().Context(), id, "execRun", routeOp); err != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
+ }
+ } else {
+ if err := routeOp(c.Request().Context()); err != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
+ }
+ }
+
+ return c.JSON(http.StatusAccepted, types.ExecRunResponse{
+ ExecID: session.ID,
+ Running: true,
+ StartedAt: session.StartedAt.Format(time.RFC3339),
+ })
+}
+
+// execResult returns the current state of an async exec/run session — the
+// load-bearing poll endpoint behind SDK exec.run(). Returns immediately with
+// running/exitCode/stdout/stderr; the result is read straight from the in-VM
+// agent (authoritative), so a dropped worker attach stream can't leave it
+// stuck reporting running:true forever.
+func (s *Server) execResult(c echo.Context) error {
+ if s.execSessionManager == nil {
+ return c.JSON(http.StatusServiceUnavailable, errSandboxNotAvailable)
+ }
+
+ id := c.Param("id")
+ sessionID := c.Param("sessionID")
+
+ var res *types.ExecSessionResult
+
+ routeOp := func(_ context.Context) error {
+ var err error
+ res, err = s.execSessionManager.GetResult(id, sessionID)
+ return err
+ }
+
+ if s.router != nil {
+ if err := s.router.Route(c.Request().Context(), id, "execResult", routeOp); err != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
+ }
+ } else {
+ if err := routeOp(c.Request().Context()); err != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
+ }
+ }
+
+ return c.JSON(http.StatusOK, types.ExecRunResult{
+ Running: res.Running,
+ ExitCode: res.ExitCode,
+ Stdout: string(res.Stdout),
+ Stderr: string(res.Stderr),
+ Truncated: res.Truncated,
+ })
+}
+
func (s *Server) killExecSession(c echo.Context) error {
if s.execSessionManager == nil {
return c.JSON(http.StatusServiceUnavailable, errSandboxNotAvailable)
diff --git a/internal/api/router.go b/internal/api/router.go
index 47dd4aa7..163c2f60 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -504,6 +504,7 @@ func NewServer(mgr sandbox.Manager, ptyMgr *sandbox.PTYManager, apiKey string, o
api.POST("/sandboxes/:id/exec", pxy)
api.GET("/sandboxes/:id/exec", pxy)
api.GET("/sandboxes/:id/exec/:sessionID", wsHandler)
+ api.GET("/sandboxes/:id/exec/:sessionID/result", pxy)
api.POST("/sandboxes/:id/exec/:sessionID/kill", pxy)
api.POST("/sandboxes/:id/exec/run", pxy)
@@ -543,6 +544,7 @@ func NewServer(mgr sandbox.Manager, ptyMgr *sandbox.PTYManager, apiKey string, o
api.POST("/sandboxes/:id/exec", s.createExecSession)
api.GET("/sandboxes/:id/exec", s.listExecSessions)
api.GET("/sandboxes/:id/exec/:sessionID", s.execSessionWebSocket)
+ api.GET("/sandboxes/:id/exec/:sessionID/result", s.execResult)
api.POST("/sandboxes/:id/exec/:sessionID/kill", s.killExecSession)
api.POST("/sandboxes/:id/exec/run", s.execRun)
diff --git a/internal/api/snapshots.go b/internal/api/snapshots.go
index 0ccaacff..bda72b11 100644
--- a/internal/api/snapshots.go
+++ b/internal/api/snapshots.go
@@ -53,15 +53,67 @@ func (s *Server) createSnapshot(c echo.Context) error {
return s.createSnapshotWithSSE(c, ctx, orgID, req.Name, req.Image)
}
- // Non-streaming path
- ic, err := s.createSnapshotCore(ctx, orgID, req.Name, req.Image, nil)
- if err != nil {
- log.Printf("snapshot: build failed for %q: %v", req.Name, err)
- return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
+ // Non-streaming path: build asynchronously. Pre-create the named snapshot
+ // row as "building" and run the (potentially multi-minute) build in the
+ // background, returning immediately. Callers poll GET /snapshots/:name until
+ // status is "ready" or "failed". This keeps the request sub-second so the
+ // edge proxy never 524s on a long build.
+ return s.createSnapshotAsync(c, orgID, req.Name, req.Image)
+}
+
+// createSnapshotAsync pre-creates a named "building" snapshot row, dispatches
+// the image build in a background goroutine, and returns the building row
+// immediately. Mirrors the SSE path's background dispatch but without a
+// streaming connection. The inflightBuilds dedup in resolveImageManifest
+// prevents duplicate concurrent builds of the same underlying image.
+func (s *Server) createSnapshotAsync(c echo.Context, orgID uuid.UUID, name string, imageJSON json.RawMessage) error {
+ var manifest ImageManifest
+ _ = json.Unmarshal(imageJSON, &manifest)
+ contentHash := computeManifestHash(&manifest)
+
+ n := name
+ ic := &db.ImageCache{
+ ID: uuid.New(),
+ OrgID: orgID,
+ // Suffix the hash so the named row never collides with the unnamed
+ // content-hash build row that resolveImageManifest creates/reuses.
+ ContentHash: contentHash + ":named:" + name,
+ Name: &n,
+ Manifest: imageJSON,
+ Status: "building",
+ }
+ if err := s.store.CreateImageCache(c.Request().Context(), ic); err != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{"error": "failed to create snapshot: " + err.Error()})
}
- log.Printf("snapshot: created %q", req.Name)
- return c.JSON(http.StatusCreated, ic)
+ // Background build — context.Background() so it survives the HTTP response.
+ go func() {
+ ctx := context.Background()
+ tBuild := time.Now()
+ checkpointID, err := s.resolveImageManifest(ctx, orgID, imageJSON, nil)
+ buildMs := time.Since(tBuild).Milliseconds()
+ if err != nil {
+ log.Printf("snapshot: async build failed for %q after %dms: %v", name, buildMs, err)
+ _ = s.store.SetImageCacheFailed(ctx, ic.ID)
+ // Mirror the failed status to D1 so GET /snapshots/:name returns
+ // status=failed (not 404), letting SDK waitUntilReady throw instead
+ // of polling to timeout. publishImageCacheReadyFrom mirrors whatever
+ // ic.Status is — here, "failed".
+ ic.Status = "failed"
+ s.publishImageCacheReadyFrom(ctx, ic)
+ return
+ }
+ if err := s.store.SetImageCacheReady(ctx, ic.ID, checkpointID); err != nil {
+ log.Printf("snapshot: failed to mark %q ready: %v", name, err)
+ return
+ }
+ ic.Status = "ready"
+ ic.CheckpointID = &checkpointID
+ s.publishImageCacheReadyFrom(ctx, ic)
+ log.Printf("snapshot: created %q (checkpoint=%s, build_ms=%d)", name, checkpointID, buildMs)
+ }()
+
+ return c.JSON(http.StatusAccepted, ic)
}
// createSnapshotCore contains the shared snapshot creation logic.
diff --git a/internal/proxy/sandbox_api_proxy.go b/internal/proxy/sandbox_api_proxy.go
index 459a171e..49910e13 100644
--- a/internal/proxy/sandbox_api_proxy.go
+++ b/internal/proxy/sandbox_api_proxy.go
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"log"
+ "log/slog"
"net"
"net/http"
"net/http/httputil"
@@ -257,8 +258,40 @@ func (p *SandboxAPIProxy) ProxyHandler(c echo.Context) error {
})
}
- // If hibernated, wake on demand
+ // If hibernated, wake on demand.
if session.Status == "hibernated" {
+ // Async exec path (POST /exec/run, GET …/result): never hold the
+ // connection on the restore — a large cold checkpoint can exceed
+ // Cloudflare's 100s and 524. Claim a worker (atomic CAS) and forward
+ // immediately; the worker's execRun returns a handle right away and
+ // self-restores in the background (router doWake), off the connection.
+ // /result is DB-routed to that worker, so this is correct across
+ // multiple control planes. Other (synchronous) ops keep the inline wake.
+ if isAsyncExecPath(c) {
+ workerURL, workerID, err := p.claimWorkerForAsyncWake(ctx, sandboxID)
+ if err != nil {
+ log.Printf("sandbox-api-proxy: async-wake claim failed for sandbox %s: %v", sandboxID, err)
+ return c.JSON(http.StatusBadGateway, map[string]string{
+ "error": fmt.Sprintf("sandbox %s: failed to wake: %v", sandboxID, err),
+ })
+ }
+ return p.forward(c, sandboxID, workerURL, workerID)
+ }
+ // File ops are synchronous (the caller wants the bytes/result now) so
+ // handle+poll doesn't apply, but a cold restore can exceed Cloudflare's
+ // 100s → 524 (or the 90s WakeSandbox cap → 502). Instead of restoring
+ // on the connection, kick the wake to the background and return 503
+ // "waking" + Retry-After; the SDK retries and the warm retry proxies
+ // normally (the restore flips the DB status to running). Wake is deduped
+ // across control planes via a Redis lock so we never double-restore.
+ if isFilesPath(c) {
+ p.startBackgroundWake(sandboxID)
+ c.Response().Header().Set("Retry-After", "1")
+ return c.JSON(http.StatusServiceUnavailable, map[string]any{
+ "error": fmt.Sprintf("sandbox %s is waking", sandboxID),
+ "waking": true,
+ })
+ }
worker, workerURL, err := p.wakeHibernatedSandbox(ctx, sandboxID)
if err != nil {
log.Printf("sandbox-api-proxy: wake-on-request failed for sandbox %s: %v", sandboxID, err)
@@ -292,6 +325,96 @@ func (p *SandboxAPIProxy) ProxyHandler(c echo.Context) error {
return p.forward(c, sandboxID, worker.HTTPAddr, session.WorkerID)
}
+// isAsyncExecPath reports whether the request is part of the async exec/run
+// flow (the POST that dispatches, or a /result poll). Those tolerate a 503
+// "waking" + retry, so we never hold their connection on a restore. Everything
+// else keeps the inline synchronous wake.
+func isAsyncExecPath(c echo.Context) bool {
+ p := c.Request().URL.Path
+ m := c.Request().Method
+ return (m == http.MethodPost && strings.HasSuffix(p, "/exec/run")) ||
+ (m == http.MethodGet && strings.HasSuffix(p, "/result"))
+}
+
+// isFilesPath reports whether the request targets the filesystem API
+// (read/write/list/mkdir/remove, including the signed download/upload variants
+// that re-enter via the proxy). These are synchronous ops that tolerate a 503
+// "waking" + client retry, so we never restore on their connection.
+func isFilesPath(c echo.Context) bool {
+ return strings.Contains(c.Request().URL.Path, "/files")
+}
+
+// startBackgroundWake restores a hibernated sandbox off the request connection.
+// Deduped across control planes via a Redis SETNX lock (120s TTL) so a burst of
+// 503-driven client retries — which the edge may spread across CP instances —
+// triggers exactly one restore (no split-brain double-restore). The restore
+// flips the DB status to running on success, so subsequent retries proxy
+// normally; on failure the lock is released so a later retry can try again.
+func (p *SandboxAPIProxy) startBackgroundWake(sandboxID string) {
+ key := "sandbox:waking:" + sandboxID
+ rdb := p.registry.RedisClient()
+ if rdb != nil {
+ ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
+ won, err := rdb.SetNX(ctx, key, "1", 120*time.Second).Result()
+ cancel()
+ if err == nil && !won {
+ return // another control plane already owns this wake
+ }
+ // err != nil → Redis hiccup; fall through and wake best-effort.
+ }
+ go func() {
+ t0 := time.Now()
+ _, _, err := p.wakeHibernatedSandbox(context.Background(), sandboxID)
+ slog.Info("files_async_wake", "sandbox", sandboxID,
+ "wake_ms", time.Since(t0).Milliseconds(), "ok", err == nil)
+ if err != nil {
+ log.Printf("sandbox-api-proxy: background wake failed for sandbox %s: %v", sandboxID, err)
+ }
+ if rdb != nil {
+ dctx, dcancel := context.WithTimeout(context.Background(), 2*time.Second)
+ _ = rdb.Del(dctx, key).Err()
+ dcancel()
+ }
+ }()
+}
+
+// claimWorkerForAsyncWake atomically assigns a hibernated sandbox to a worker
+// and returns that worker's address — WITHOUT performing the restore. The
+// restore happens lazily on the worker (its execRun → router doWake) so it
+// stays off the connection.
+//
+// Multi-CP safe: UpdateSandboxSessionForWake is a compare-and-swap
+// (UPDATE … WHERE status='hibernated'), so if several control planes race only
+// the first flips the row. We then RE-READ the session and forward to whatever
+// worker actually won the claim — so every racing CP converges on the same
+// worker and the box restores exactly once (the worker's router + manager.Wake
+// singleflight dedup any remaining concurrency).
+func (p *SandboxAPIProxy) claimWorkerForAsyncWake(ctx context.Context, sandboxID string) (string, string, error) {
+ checkpoint, err := p.store.GetActiveHibernation(ctx, sandboxID)
+ if err != nil {
+ return "", "", fmt.Errorf("no active hibernation: %w", err)
+ }
+ candidate, _, err := p.registry.GetLeastLoadedWorker(checkpoint.Region)
+ if err != nil {
+ return "", "", fmt.Errorf("no workers available in region %s: %w", checkpoint.Region, err)
+ }
+ // CAS claim (no-ops if another CP already flipped the row).
+ if err := p.store.UpdateSandboxSessionForWake(ctx, sandboxID, candidate.ID); err != nil {
+ return "", "", fmt.Errorf("claim worker for wake: %w", err)
+ }
+ // Authoritative re-read: forward to whoever actually won the claim.
+ sess, err := p.store.GetSandboxSession(ctx, sandboxID)
+ if err != nil {
+ return "", "", fmt.Errorf("re-read session after claim: %w", err)
+ }
+ w := p.registry.GetWorker(sess.WorkerID)
+ if w == nil || w.HTTPAddr == "" {
+ return "", "", fmt.Errorf("claimed worker %s unavailable", sess.WorkerID)
+ }
+ log.Printf("sandbox-api-proxy: async-wake claim for sandbox %s → worker %s (%s), worker will restore lazily", sandboxID, sess.WorkerID, w.HTTPAddr)
+ return w.HTTPAddr, sess.WorkerID, nil
+}
+
// forward proxies the request to the worker, mints a JWT, caches the route.
func (p *SandboxAPIProxy) forward(c echo.Context, sandboxID, workerURL, workerID string) error {
token := ""
diff --git a/internal/sandbox/exec_session.go b/internal/sandbox/exec_session.go
index ede19ff0..00c8de79 100644
--- a/internal/sandbox/exec_session.go
+++ b/internal/sandbox/exec_session.go
@@ -29,6 +29,7 @@ type ExecSessionHandle struct {
Running bool
ExitCode *int
StartedAt time.Time
+ ExitedAt time.Time // zero until the command exits; for command_ms timing
Done chan struct{}
Scrollback *ScrollbackBuffer
StdinWriter io.Writer
@@ -124,6 +125,55 @@ func (m *ExecSessionManager) GetSession(sessionID string) (*ExecSessionHandle, e
return session, nil
}
+// GetResult returns the current result of an exec session from its local
+// handle — the scrollback (split by stream) plus the exit code captured by the
+// worker's attach stream. This is the load-bearing call behind the async
+// exec/run poll endpoint. If the local map missed (live migration or worker
+// restart moved the still-alive in-VM session), it rebinds from the agent
+// first, reusing the same recovery path as the WS attach handler.
+//
+// Running is derived from the captured exit code rather than the handle's
+// Running flag: consumeExecOutput sets ExitCode before clearing Running, so
+// gating on ExitCode==nil never reports a finished command without its code.
+func (m *ExecSessionManager) GetResult(sandboxID, sessionID string) (*types.ExecSessionResult, error) {
+ m.mu.RLock()
+ sess, ok := m.sessions[sessionID]
+ m.mu.RUnlock()
+ if !ok {
+ var err error
+ sess, err = m.RebindFromAgent(sandboxID, sessionID)
+ if err != nil {
+ return nil, fmt.Errorf("exec session %s not found", sessionID)
+ }
+ }
+
+ res := &types.ExecSessionResult{Running: sess.ExitCode == nil}
+ if sess.ExitCode != nil {
+ ec := *sess.ExitCode
+ res.ExitCode = &ec
+ }
+ // command_ms: wall-clock of the command itself (start → exit, or → now if
+ // still running). Feeds the 524 attribution (command duration vs wake).
+ if !sess.StartedAt.IsZero() {
+ end := sess.ExitedAt
+ if end.IsZero() {
+ end = time.Now()
+ }
+ res.CommandMs = end.Sub(sess.StartedAt).Milliseconds()
+ }
+ if sess.Scrollback != nil {
+ for _, ch := range sess.Scrollback.Snapshot() {
+ if ch.Stream == 2 {
+ res.Stderr = append(res.Stderr, ch.Data...)
+ } else {
+ res.Stdout = append(res.Stdout, ch.Data...)
+ }
+ }
+ res.Truncated = sess.Scrollback.Truncated()
+ }
+ return res, nil
+}
+
// ListSessions returns info for all sessions belonging to a sandbox.
func (m *ExecSessionManager) ListSessions(sandboxID string) []types.ExecSessionInfo {
m.mu.RLock()
diff --git a/internal/sandbox/scrollback.go b/internal/sandbox/scrollback.go
index f3958683..8e8de6d3 100644
--- a/internal/sandbox/scrollback.go
+++ b/internal/sandbox/scrollback.go
@@ -18,6 +18,7 @@ type ScrollbackBuffer struct {
totalLen int
maxBytes int
nextSeq uint64
+ evicted bool // true once the ring has dropped older output
subs map[chan OutputChunk]struct{}
}
@@ -56,6 +57,7 @@ func (sb *ScrollbackBuffer) Write(stream uint8, data []byte) {
for sb.totalLen > sb.maxBytes && len(sb.chunks) > 0 {
sb.totalLen -= len(sb.chunks[0].Data)
sb.chunks = sb.chunks[1:]
+ sb.evicted = true
}
// Copy subscribers to avoid holding lock during send
@@ -85,6 +87,14 @@ func (sb *ScrollbackBuffer) Snapshot() []OutputChunk {
return result
}
+// Truncated reports whether the ring has evicted older output (i.e. the
+// snapshot is incomplete because total output exceeded the buffer size).
+func (sb *ScrollbackBuffer) Truncated() bool {
+ sb.mu.Lock()
+ defer sb.mu.Unlock()
+ return sb.evicted
+}
+
// Subscribe returns a channel that receives live output chunks.
func (sb *ScrollbackBuffer) Subscribe() chan OutputChunk {
ch := make(chan OutputChunk, 256)
diff --git a/internal/worker/grpc_server.go b/internal/worker/grpc_server.go
index 40110034..460718ad 100644
--- a/internal/worker/grpc_server.go
+++ b/internal/worker/grpc_server.go
@@ -708,6 +708,41 @@ func (s *GRPCServer) ExecSessionKill(ctx context.Context, req *pb.ExecSessionKil
return &pb.ExecSessionKillResponse{}, nil
}
+func (s *GRPCServer) ExecSessionResult(ctx context.Context, req *pb.ExecSessionResultRequest) (*pb.ExecSessionResultResponse, error) {
+ if s.execSessionManager == nil {
+ return nil, fmt.Errorf("exec sessions not configured on this worker")
+ }
+
+ var res *types.ExecSessionResult
+
+ routeOp := func(_ context.Context) error {
+ var err error
+ res, err = s.execSessionManager.GetResult(req.SandboxId, req.SessionId)
+ return err
+ }
+
+ if s.router != nil {
+ if err := s.router.Route(ctx, req.SandboxId, "execSessionResult", routeOp); err != nil {
+ return nil, fmt.Errorf("exec session result failed: %w", err)
+ }
+ } else {
+ if err := routeOp(ctx); err != nil {
+ return nil, fmt.Errorf("exec session result failed: %w", err)
+ }
+ }
+
+ resp := &pb.ExecSessionResultResponse{
+ Running: res.Running,
+ Stdout: res.Stdout,
+ Stderr: res.Stderr,
+ Truncated: res.Truncated,
+ }
+ if res.ExitCode != nil {
+ resp.ExitCode = int32(*res.ExitCode)
+ }
+ return resp, nil
+}
+
func (s *GRPCServer) HibernateSandbox(ctx context.Context, req *pb.HibernateSandboxRequest) (*pb.HibernateSandboxResponse, error) {
if s.checkpointStore == nil {
return nil, fmt.Errorf("hibernation not configured on this worker")
diff --git a/internal/worker/handlers.go b/internal/worker/handlers.go
index 01d8d2e7..eae267af 100644
--- a/internal/worker/handlers.go
+++ b/internal/worker/handlers.go
@@ -7,7 +7,9 @@ import (
"fmt"
"io"
"log"
+ "log/slog"
"net/http"
+ "sync"
"time"
"github.com/google/uuid"
@@ -261,6 +263,28 @@ func (s *HTTPServer) execSessionWebSocket(c echo.Context) error {
}
}
+type asyncExecState int
+
+const (
+ asyncExecStarting asyncExecState = iota // waking / creating the in-VM session
+ asyncExecRunning // session created; command in flight or done
+ asyncExecFailed // wake or session-create failed
+)
+
+// asyncExec tracks a background exec/run by its client-facing execId, so that
+// POST /exec/run can return a handle before the (possibly slow) auto-wake and
+// session-create complete. Once running, sessionID points at the real in-VM
+// exec session that holds the output + exit code.
+type asyncExec struct {
+ mu sync.Mutex
+ state asyncExecState
+ sessionID string
+ err error
+ startedAt time.Time
+ wakeMs int64 // checkpoint-restore latency before the command could start
+ createMs int64 // session create once the box was up
+}
+
func (s *HTTPServer) execRun(c echo.Context) error {
id := c.Param("id")
@@ -272,43 +296,90 @@ func (s *HTTPServer) execRun(c echo.Context) error {
return c.JSON(http.StatusBadRequest, map[string]string{"error": "cmd is required"})
}
- // For long-running commands (timeout > 30s), send response headers
- // immediately and write periodic keepalive whitespace. This prevents
- // Cloudflare (and other reverse proxies) from timing out:
- // - 524 first-byte timeout (~100s): solved by sending headers early
- // - Body idle timeout (~600s): solved by periodic space bytes
- // JSON parsers ignore leading whitespace, so the final JSON body
- // is parsed cleanly regardless of how many spaces precede it.
- earlyFlush := req.Timeout > 30
- var keepaliveDone chan struct{}
- if earlyFlush {
- c.Response().Header().Set("Content-Type", "application/json")
- c.Response().WriteHeader(http.StatusOK)
- flusher, _ := c.Response().Writer.(http.Flusher)
- if flusher != nil {
- flusher.Flush()
- }
-
- keepaliveDone = make(chan struct{})
+ // Async path: register a handle synchronously and return immediately, then
+ // do the wake + session-create + command run in a background goroutine.
+ // Because the connection is never held — not for the command, and crucially
+ // not for a slow auto-wake/restore — the edge never 524s (nor 502s on the
+ // CP's 60s response-header timeout). The caller polls GET /exec/:execId/result.
+ if s.execSessionManager != nil {
+ execID := uuid.NewString()[:8]
+ ae := &asyncExec{state: asyncExecStarting, startedAt: time.Now()}
+ s.asyncExecs.Store(execID, ae)
+
+ sreq := types.ExecSessionCreateRequest{
+ Command: req.Command,
+ Args: req.Args,
+ Env: req.Env,
+ Cwd: req.Cwd,
+ Timeout: req.Timeout,
+ }
+
go func() {
- ticker := time.NewTicker(15 * time.Second)
- defer ticker.Stop()
- for {
- select {
- case <-ticker.C:
- c.Response().Write([]byte(" "))
- if flusher != nil {
- flusher.Flush()
- }
- case <-keepaliveDone:
- return
+ // 524-attribution timing. wake_ms = checkpoint restore latency (the
+ // dominant cause of the old synchronous exec/run 524s); create_ms =
+ // session create once the box is up. The command's own duration is
+ // logged separately on session exit (exec_session_exit). routeOp
+ // stamps when the session create begins, so the time inside Route
+ // before it is the wake (+ any queue wait).
+ wasHibernated := false
+ if s.router != nil {
+ if st, ok := s.router.GetState(id); ok {
+ wasHibernated = st != sandbox.StateRunning
}
}
+ var session *sandbox.ExecSessionHandle
+ var createMs int64
+ routeOp := func(_ context.Context) error {
+ tc := time.Now()
+ var e error
+ session, e = s.execSessionManager.CreateSession(id, sreq)
+ createMs = time.Since(tc).Milliseconds()
+ return e
+ }
+ // context.Background(): detached from the HTTP request (already
+ // returned). ensureRunning (the wake/restore) and the command both
+ // run here, off the connection.
+ t0 := time.Now()
+ var err error
+ if s.router != nil {
+ err = s.router.Route(context.Background(), id, "execRun", routeOp)
+ } else {
+ err = routeOp(context.Background())
+ }
+ wakeMs := time.Since(t0).Milliseconds() - createMs
+ if wakeMs < 0 {
+ wakeMs = 0
+ }
+ slog.Info("exec_run_dispatch",
+ "sandbox", id, "exec_id", execID,
+ "was_hibernated", wasHibernated,
+ "wake_ms", wakeMs, "create_ms", createMs, "ok", err == nil)
+
+ ae.mu.Lock()
+ ae.wakeMs = wakeMs
+ ae.createMs = createMs
+ if err != nil {
+ ae.state = asyncExecFailed
+ ae.err = err
+ } else {
+ ae.state = asyncExecRunning
+ ae.sessionID = session.ID
+ }
+ ae.mu.Unlock()
+ // Reap the handle after the underlying session's own retention
+ // window has comfortably passed.
+ time.AfterFunc(10*time.Minute, func() { s.asyncExecs.Delete(execID) })
}()
+
+ return c.JSON(http.StatusAccepted, types.ExecRunResponse{
+ ExecID: execID,
+ Running: true,
+ StartedAt: ae.startedAt.Format(time.RFC3339),
+ })
}
+ // Fallback (no exec sessions, e.g. Podman): synchronous one-shot.
var result *types.ProcessResult
-
routeOp := func(ctx context.Context) error {
var err error
result, err = s.manager.Exec(ctx, id, req)
@@ -321,22 +392,66 @@ func (s *HTTPServer) execRun(c echo.Context) error {
} else {
execErr = routeOp(c.Request().Context())
}
+ if execErr != nil {
+ return c.JSON(http.StatusInternalServerError, map[string]string{"error": execErr.Error()})
+ }
+ return c.JSON(http.StatusOK, result)
+}
- if keepaliveDone != nil {
- close(keepaliveDone)
+// execResult is the poll target behind async exec/run. It resolves the
+// client-facing execId to its background state: still waking/creating →
+// running:true (with waking:true); the wake/create failed → an error; otherwise
+// it reads the live session result (running/exitCode + buffered output),
+// rebinding from the in-VM agent on a local miss. Always sub-second.
+func (s *HTTPServer) execResult(c echo.Context) error {
+ if s.execSessionManager == nil {
+ return c.JSON(http.StatusServiceUnavailable, map[string]string{"error": "exec sessions not available"})
}
- if execErr != nil {
- if earlyFlush {
- return json.NewEncoder(c.Response()).Encode(map[string]string{"error": execErr.Error()})
- }
- return c.JSON(http.StatusInternalServerError, map[string]string{"error": execErr.Error()})
+ id := c.Param("id")
+ execID := c.Param("sessionID")
+
+ v, ok := s.asyncExecs.Load(execID)
+ if !ok {
+ return c.JSON(http.StatusNotFound, map[string]string{"error": "exec " + execID + " not found"})
}
+ ae := v.(*asyncExec)
+ ae.mu.Lock()
+ state, sessionID, aeErr := ae.state, ae.sessionID, ae.err
+ wakeMs, createMs := ae.wakeMs, ae.createMs
+ ae.mu.Unlock()
- if earlyFlush {
- return json.NewEncoder(c.Response()).Encode(result)
+ if s.router != nil {
+ s.router.Touch(id)
}
- return c.JSON(http.StatusOK, result)
+
+ switch state {
+ case asyncExecStarting:
+ // Box is waking and/or the session is still being created.
+ return c.JSON(http.StatusOK, types.ExecRunResult{Running: true, Waking: true})
+ case asyncExecFailed:
+ ec := -1
+ return c.JSON(http.StatusOK, types.ExecRunResult{
+ Running: false, ExitCode: &ec, Error: aeErr.Error(),
+ WakeMs: wakeMs, CreateMs: createMs,
+ })
+ }
+
+ // Running — read the live session result.
+ res, err := s.execSessionManager.GetResult(id, sessionID)
+ if err != nil {
+ return c.JSON(http.StatusNotFound, map[string]string{"error": err.Error()})
+ }
+ return c.JSON(http.StatusOK, types.ExecRunResult{
+ Running: res.Running,
+ ExitCode: res.ExitCode,
+ Stdout: string(res.Stdout),
+ Stderr: string(res.Stderr),
+ Truncated: res.Truncated,
+ WakeMs: wakeMs,
+ CreateMs: createMs,
+ CommandMs: res.CommandMs,
+ })
}
func (s *HTTPServer) killExecSession(c echo.Context) error {
diff --git a/internal/worker/http_server.go b/internal/worker/http_server.go
index 2d9d0eb2..7d3f2d01 100644
--- a/internal/worker/http_server.go
+++ b/internal/worker/http_server.go
@@ -2,6 +2,7 @@ package worker
import (
"net/http"
+ "sync"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
@@ -25,6 +26,13 @@ type HTTPServer struct {
router *sandbox.SandboxRouter
mountSvc *mounts.Service // nil when store is unavailable
sandboxDomain string
+
+ // asyncExecs tracks background exec/run invocations by client-facing
+ // execId. The handle is registered synchronously so POST /exec/run returns
+ // immediately; the wake + session create + command run happen in a
+ // goroutine, so a slow auto-wake never holds the connection (no 524/502).
+ // Keyed execId -> *asyncExec. Entries self-expire via a TTL timer.
+ asyncExecs sync.Map
}
// NewHTTPServer creates a new worker HTTP server for direct SDK access.
@@ -81,6 +89,7 @@ func NewHTTPServer(mgr sandbox.Manager, ptyMgr *sandbox.PTYManager, execMgr *san
api.POST("/sandboxes/:id/exec", s.createExecSession)
api.GET("/sandboxes/:id/exec", s.listExecSessions)
api.GET("/sandboxes/:id/exec/:sessionID", s.execSessionWebSocket)
+ api.GET("/sandboxes/:id/exec/:sessionID/result", s.execResult)
api.POST("/sandboxes/:id/exec/:sessionID/kill", s.killExecSession)
// Timeout
diff --git a/pkg/types/exec_session.go b/pkg/types/exec_session.go
index 3639feb7..71a1536c 100644
--- a/pkg/types/exec_session.go
+++ b/pkg/types/exec_session.go
@@ -10,6 +10,18 @@ type ExecSessionCreateRequest struct {
MaxRunAfterDisconnect int `json:"maxRunAfterDisconnect,omitempty"`
}
+// ExecSessionResult is the terminal/intermediate result of an exec session,
+// fetched without attaching a live stream. Used by the async exec/run poll
+// path. Stdout/Stderr are the scrollback snapshot split by frame tag.
+type ExecSessionResult struct {
+ Running bool `json:"running"`
+ ExitCode *int `json:"exitCode,omitempty"`
+ Stdout []byte `json:"stdout,omitempty"`
+ Stderr []byte `json:"stderr,omitempty"`
+ Truncated bool `json:"truncated,omitempty"`
+ CommandMs int64 `json:"commandMs,omitempty"` // command wall-clock (start→exit/now)
+}
+
// ExecSessionInfo is the response body for exec session metadata.
type ExecSessionInfo struct {
SessionID string `json:"sessionID"`
diff --git a/pkg/types/process.go b/pkg/types/process.go
index 4422ca26..7e6d9d0e 100644
--- a/pkg/types/process.go
+++ b/pkg/types/process.go
@@ -16,6 +16,39 @@ type ProcessConfig struct {
Timeout int `json:"timeout,omitempty"` // seconds, default 60
}
+// ExecRunResponse is the immediate handle returned by the async exec/run
+// endpoint. The command runs as a background exec session; the caller polls
+// GET /exec/:execId/result for completion.
+type ExecRunResponse struct {
+ ExecID string `json:"execId"`
+ Running bool `json:"running"`
+ StartedAt string `json:"startedAt"`
+}
+
+// ExecRunResult is the polled result of an async exec/run session. ExitCode is
+// nil while Running is true. Truncated indicates the 1MB scrollback ring
+// dropped older output (attach via WS for full live output). Waking is true
+// while the sandbox is still auto-waking / the session is being created (no
+// output yet). Error is set if the wake or session-create failed.
+type ExecRunResult struct {
+ Running bool `json:"running"`
+ Waking bool `json:"waking,omitempty"`
+ ExitCode *int `json:"exitCode,omitempty"`
+ Stdout string `json:"stdout"`
+ Stderr string `json:"stderr"`
+ Truncated bool `json:"truncated,omitempty"`
+ Error string `json:"error,omitempty"`
+
+ // Timing (524 attribution; observable per-request, not just in logs).
+ // WakeMs = checkpoint-restore latency before the command could start;
+ // CreateMs = session create once the box was up; CommandMs = the command's
+ // own wall-clock. wake/command being the two things that used to hold the
+ // synchronous connection past Cloudflare's 100s.
+ WakeMs int64 `json:"wakeMs,omitempty"`
+ CreateMs int64 `json:"createMs,omitempty"`
+ CommandMs int64 `json:"commandMs,omitempty"`
+}
+
// BackgroundProcess represents a background process.
type BackgroundProcess struct {
PID int `json:"pid"`
diff --git a/proto/agent/agent.pb.go b/proto/agent/agent.pb.go
index 9e3d004d..612ced75 100644
--- a/proto/agent/agent.pb.go
+++ b/proto/agent/agent.pb.go
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.11
-// protoc v7.34.0
+// protoc v7.35.0
// source: proto/agent/agent.proto
package agent
diff --git a/proto/agent/agent_grpc.pb.go b/proto/agent/agent_grpc.pb.go
index ae83f1f0..2bd31ba6 100644
--- a/proto/agent/agent_grpc.pb.go
+++ b/proto/agent/agent_grpc.pb.go
@@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
-// - protoc-gen-go-grpc v1.6.1
-// - protoc v7.34.0
+// - protoc-gen-go-grpc v1.6.2
+// - protoc v7.35.0
// source: proto/agent/agent.proto
package agent
diff --git a/proto/worker/worker.pb.go b/proto/worker/worker.pb.go
index 1514e3a6..7e0230f7 100644
--- a/proto/worker/worker.pb.go
+++ b/proto/worker/worker.pb.go
@@ -2465,6 +2465,134 @@ func (*ExecSessionKillResponse) Descriptor() ([]byte, []int) {
return file_proto_worker_worker_proto_rawDescGZIP(), []int{41}
}
+type ExecSessionResultRequest struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ SandboxId string `protobuf:"bytes,1,opt,name=sandbox_id,json=sandboxId,proto3" json:"sandbox_id,omitempty"`
+ SessionId string `protobuf:"bytes,2,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *ExecSessionResultRequest) Reset() {
+ *x = ExecSessionResultRequest{}
+ mi := &file_proto_worker_worker_proto_msgTypes[42]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *ExecSessionResultRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ExecSessionResultRequest) ProtoMessage() {}
+
+func (x *ExecSessionResultRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_proto_worker_worker_proto_msgTypes[42]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use ExecSessionResultRequest.ProtoReflect.Descriptor instead.
+func (*ExecSessionResultRequest) Descriptor() ([]byte, []int) {
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{42}
+}
+
+func (x *ExecSessionResultRequest) GetSandboxId() string {
+ if x != nil {
+ return x.SandboxId
+ }
+ return ""
+}
+
+func (x *ExecSessionResultRequest) GetSessionId() string {
+ if x != nil {
+ return x.SessionId
+ }
+ return ""
+}
+
+type ExecSessionResultResponse struct {
+ state protoimpl.MessageState `protogen:"open.v1"`
+ Running bool `protobuf:"varint,1,opt,name=running,proto3" json:"running,omitempty"`
+ ExitCode int32 `protobuf:"varint,2,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` // valid only when running = false
+ Stdout []byte `protobuf:"bytes,3,opt,name=stdout,proto3" json:"stdout,omitempty"`
+ Stderr []byte `protobuf:"bytes,4,opt,name=stderr,proto3" json:"stderr,omitempty"`
+ Truncated bool `protobuf:"varint,5,opt,name=truncated,proto3" json:"truncated,omitempty"`
+ unknownFields protoimpl.UnknownFields
+ sizeCache protoimpl.SizeCache
+}
+
+func (x *ExecSessionResultResponse) Reset() {
+ *x = ExecSessionResultResponse{}
+ mi := &file_proto_worker_worker_proto_msgTypes[43]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+}
+
+func (x *ExecSessionResultResponse) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*ExecSessionResultResponse) ProtoMessage() {}
+
+func (x *ExecSessionResultResponse) ProtoReflect() protoreflect.Message {
+ mi := &file_proto_worker_worker_proto_msgTypes[43]
+ if x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use ExecSessionResultResponse.ProtoReflect.Descriptor instead.
+func (*ExecSessionResultResponse) Descriptor() ([]byte, []int) {
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{43}
+}
+
+func (x *ExecSessionResultResponse) GetRunning() bool {
+ if x != nil {
+ return x.Running
+ }
+ return false
+}
+
+func (x *ExecSessionResultResponse) GetExitCode() int32 {
+ if x != nil {
+ return x.ExitCode
+ }
+ return 0
+}
+
+func (x *ExecSessionResultResponse) GetStdout() []byte {
+ if x != nil {
+ return x.Stdout
+ }
+ return nil
+}
+
+func (x *ExecSessionResultResponse) GetStderr() []byte {
+ if x != nil {
+ return x.Stderr
+ }
+ return nil
+}
+
+func (x *ExecSessionResultResponse) GetTruncated() bool {
+ if x != nil {
+ return x.Truncated
+ }
+ return false
+}
+
type GetSandboxStatsRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
SandboxId string `protobuf:"bytes,1,opt,name=sandbox_id,json=sandboxId,proto3" json:"sandbox_id,omitempty"`
@@ -2474,7 +2602,7 @@ type GetSandboxStatsRequest struct {
func (x *GetSandboxStatsRequest) Reset() {
*x = GetSandboxStatsRequest{}
- mi := &file_proto_worker_worker_proto_msgTypes[42]
+ mi := &file_proto_worker_worker_proto_msgTypes[44]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2486,7 +2614,7 @@ func (x *GetSandboxStatsRequest) String() string {
func (*GetSandboxStatsRequest) ProtoMessage() {}
func (x *GetSandboxStatsRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[42]
+ mi := &file_proto_worker_worker_proto_msgTypes[44]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2499,7 +2627,7 @@ func (x *GetSandboxStatsRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetSandboxStatsRequest.ProtoReflect.Descriptor instead.
func (*GetSandboxStatsRequest) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{42}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{44}
}
func (x *GetSandboxStatsRequest) GetSandboxId() string {
@@ -2523,7 +2651,7 @@ type GetSandboxStatsResponse struct {
func (x *GetSandboxStatsResponse) Reset() {
*x = GetSandboxStatsResponse{}
- mi := &file_proto_worker_worker_proto_msgTypes[43]
+ mi := &file_proto_worker_worker_proto_msgTypes[45]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2535,7 +2663,7 @@ func (x *GetSandboxStatsResponse) String() string {
func (*GetSandboxStatsResponse) ProtoMessage() {}
func (x *GetSandboxStatsResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[43]
+ mi := &file_proto_worker_worker_proto_msgTypes[45]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2548,7 +2676,7 @@ func (x *GetSandboxStatsResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use GetSandboxStatsResponse.ProtoReflect.Descriptor instead.
func (*GetSandboxStatsResponse) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{43}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{45}
}
func (x *GetSandboxStatsResponse) GetCpuPercent() float64 {
@@ -2609,7 +2737,7 @@ type CreateCheckpointRequest struct {
func (x *CreateCheckpointRequest) Reset() {
*x = CreateCheckpointRequest{}
- mi := &file_proto_worker_worker_proto_msgTypes[44]
+ mi := &file_proto_worker_worker_proto_msgTypes[46]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2621,7 +2749,7 @@ func (x *CreateCheckpointRequest) String() string {
func (*CreateCheckpointRequest) ProtoMessage() {}
func (x *CreateCheckpointRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[44]
+ mi := &file_proto_worker_worker_proto_msgTypes[46]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2634,7 +2762,7 @@ func (x *CreateCheckpointRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use CreateCheckpointRequest.ProtoReflect.Descriptor instead.
func (*CreateCheckpointRequest) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{44}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{46}
}
func (x *CreateCheckpointRequest) GetSandboxId() string {
@@ -2681,7 +2809,7 @@ type CreateCheckpointResponse struct {
func (x *CreateCheckpointResponse) Reset() {
*x = CreateCheckpointResponse{}
- mi := &file_proto_worker_worker_proto_msgTypes[45]
+ mi := &file_proto_worker_worker_proto_msgTypes[47]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2693,7 +2821,7 @@ func (x *CreateCheckpointResponse) String() string {
func (*CreateCheckpointResponse) ProtoMessage() {}
func (x *CreateCheckpointResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[45]
+ mi := &file_proto_worker_worker_proto_msgTypes[47]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2706,7 +2834,7 @@ func (x *CreateCheckpointResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use CreateCheckpointResponse.ProtoReflect.Descriptor instead.
func (*CreateCheckpointResponse) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{45}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{47}
}
func (x *CreateCheckpointResponse) GetRootfsS3Key() string {
@@ -2740,7 +2868,7 @@ type RestoreCheckpointRequest struct {
func (x *RestoreCheckpointRequest) Reset() {
*x = RestoreCheckpointRequest{}
- mi := &file_proto_worker_worker_proto_msgTypes[46]
+ mi := &file_proto_worker_worker_proto_msgTypes[48]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2752,7 +2880,7 @@ func (x *RestoreCheckpointRequest) String() string {
func (*RestoreCheckpointRequest) ProtoMessage() {}
func (x *RestoreCheckpointRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[46]
+ mi := &file_proto_worker_worker_proto_msgTypes[48]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2765,7 +2893,7 @@ func (x *RestoreCheckpointRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use RestoreCheckpointRequest.ProtoReflect.Descriptor instead.
func (*RestoreCheckpointRequest) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{46}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{48}
}
func (x *RestoreCheckpointRequest) GetSandboxId() string {
@@ -2791,7 +2919,7 @@ type RestoreCheckpointResponse struct {
func (x *RestoreCheckpointResponse) Reset() {
*x = RestoreCheckpointResponse{}
- mi := &file_proto_worker_worker_proto_msgTypes[47]
+ mi := &file_proto_worker_worker_proto_msgTypes[49]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2803,7 +2931,7 @@ func (x *RestoreCheckpointResponse) String() string {
func (*RestoreCheckpointResponse) ProtoMessage() {}
func (x *RestoreCheckpointResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[47]
+ mi := &file_proto_worker_worker_proto_msgTypes[49]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2816,7 +2944,7 @@ func (x *RestoreCheckpointResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use RestoreCheckpointResponse.ProtoReflect.Descriptor instead.
func (*RestoreCheckpointResponse) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{47}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{49}
}
func (x *RestoreCheckpointResponse) GetSuccess() bool {
@@ -2839,7 +2967,7 @@ type SetSandboxLimitsRequest struct {
func (x *SetSandboxLimitsRequest) Reset() {
*x = SetSandboxLimitsRequest{}
- mi := &file_proto_worker_worker_proto_msgTypes[48]
+ mi := &file_proto_worker_worker_proto_msgTypes[50]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2851,7 +2979,7 @@ func (x *SetSandboxLimitsRequest) String() string {
func (*SetSandboxLimitsRequest) ProtoMessage() {}
func (x *SetSandboxLimitsRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[48]
+ mi := &file_proto_worker_worker_proto_msgTypes[50]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2864,7 +2992,7 @@ func (x *SetSandboxLimitsRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use SetSandboxLimitsRequest.ProtoReflect.Descriptor instead.
func (*SetSandboxLimitsRequest) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{48}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{50}
}
func (x *SetSandboxLimitsRequest) GetSandboxId() string {
@@ -2910,7 +3038,7 @@ type SetSandboxLimitsResponse struct {
func (x *SetSandboxLimitsResponse) Reset() {
*x = SetSandboxLimitsResponse{}
- mi := &file_proto_worker_worker_proto_msgTypes[49]
+ mi := &file_proto_worker_worker_proto_msgTypes[51]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2922,7 +3050,7 @@ func (x *SetSandboxLimitsResponse) String() string {
func (*SetSandboxLimitsResponse) ProtoMessage() {}
func (x *SetSandboxLimitsResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[49]
+ mi := &file_proto_worker_worker_proto_msgTypes[51]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2935,7 +3063,7 @@ func (x *SetSandboxLimitsResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use SetSandboxLimitsResponse.ProtoReflect.Descriptor instead.
func (*SetSandboxLimitsResponse) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{49}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{51}
}
// Live migration messages
@@ -2948,7 +3076,7 @@ type PreCopyDrivesRequest struct {
func (x *PreCopyDrivesRequest) Reset() {
*x = PreCopyDrivesRequest{}
- mi := &file_proto_worker_worker_proto_msgTypes[50]
+ mi := &file_proto_worker_worker_proto_msgTypes[52]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -2960,7 +3088,7 @@ func (x *PreCopyDrivesRequest) String() string {
func (*PreCopyDrivesRequest) ProtoMessage() {}
func (x *PreCopyDrivesRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[50]
+ mi := &file_proto_worker_worker_proto_msgTypes[52]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -2973,7 +3101,7 @@ func (x *PreCopyDrivesRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use PreCopyDrivesRequest.ProtoReflect.Descriptor instead.
func (*PreCopyDrivesRequest) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{50}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{52}
}
func (x *PreCopyDrivesRequest) GetSandboxId() string {
@@ -3017,7 +3145,7 @@ type PreCopyDrivesResponse struct {
func (x *PreCopyDrivesResponse) Reset() {
*x = PreCopyDrivesResponse{}
- mi := &file_proto_worker_worker_proto_msgTypes[51]
+ mi := &file_proto_worker_worker_proto_msgTypes[53]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3029,7 +3157,7 @@ func (x *PreCopyDrivesResponse) String() string {
func (*PreCopyDrivesResponse) ProtoMessage() {}
func (x *PreCopyDrivesResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[51]
+ mi := &file_proto_worker_worker_proto_msgTypes[53]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3042,7 +3170,7 @@ func (x *PreCopyDrivesResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use PreCopyDrivesResponse.ProtoReflect.Descriptor instead.
func (*PreCopyDrivesResponse) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{51}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{53}
}
func (x *PreCopyDrivesResponse) GetRootfsKey() string {
@@ -3125,7 +3253,7 @@ type HostList struct {
func (x *HostList) Reset() {
*x = HostList{}
- mi := &file_proto_worker_worker_proto_msgTypes[52]
+ mi := &file_proto_worker_worker_proto_msgTypes[54]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3137,7 +3265,7 @@ func (x *HostList) String() string {
func (*HostList) ProtoMessage() {}
func (x *HostList) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[52]
+ mi := &file_proto_worker_worker_proto_msgTypes[54]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3150,7 +3278,7 @@ func (x *HostList) ProtoReflect() protoreflect.Message {
// Deprecated: Use HostList.ProtoReflect.Descriptor instead.
func (*HostList) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{52}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{54}
}
func (x *HostList) GetHosts() []string {
@@ -3188,7 +3316,7 @@ type PrepareMigrationIncomingRequest struct {
func (x *PrepareMigrationIncomingRequest) Reset() {
*x = PrepareMigrationIncomingRequest{}
- mi := &file_proto_worker_worker_proto_msgTypes[53]
+ mi := &file_proto_worker_worker_proto_msgTypes[55]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3200,7 +3328,7 @@ func (x *PrepareMigrationIncomingRequest) String() string {
func (*PrepareMigrationIncomingRequest) ProtoMessage() {}
func (x *PrepareMigrationIncomingRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[53]
+ mi := &file_proto_worker_worker_proto_msgTypes[55]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3213,7 +3341,7 @@ func (x *PrepareMigrationIncomingRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use PrepareMigrationIncomingRequest.ProtoReflect.Descriptor instead.
func (*PrepareMigrationIncomingRequest) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{53}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{55}
}
func (x *PrepareMigrationIncomingRequest) GetSandboxId() string {
@@ -3338,7 +3466,7 @@ type PrepareMigrationIncomingResponse struct {
func (x *PrepareMigrationIncomingResponse) Reset() {
*x = PrepareMigrationIncomingResponse{}
- mi := &file_proto_worker_worker_proto_msgTypes[54]
+ mi := &file_proto_worker_worker_proto_msgTypes[56]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3350,7 +3478,7 @@ func (x *PrepareMigrationIncomingResponse) String() string {
func (*PrepareMigrationIncomingResponse) ProtoMessage() {}
func (x *PrepareMigrationIncomingResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[54]
+ mi := &file_proto_worker_worker_proto_msgTypes[56]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3363,7 +3491,7 @@ func (x *PrepareMigrationIncomingResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use PrepareMigrationIncomingResponse.ProtoReflect.Descriptor instead.
func (*PrepareMigrationIncomingResponse) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{54}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{56}
}
func (x *PrepareMigrationIncomingResponse) GetIncomingAddr() string {
@@ -3391,7 +3519,7 @@ type UpdateSandboxSecretRequest struct {
func (x *UpdateSandboxSecretRequest) Reset() {
*x = UpdateSandboxSecretRequest{}
- mi := &file_proto_worker_worker_proto_msgTypes[55]
+ mi := &file_proto_worker_worker_proto_msgTypes[57]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3403,7 +3531,7 @@ func (x *UpdateSandboxSecretRequest) String() string {
func (*UpdateSandboxSecretRequest) ProtoMessage() {}
func (x *UpdateSandboxSecretRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[55]
+ mi := &file_proto_worker_worker_proto_msgTypes[57]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3416,7 +3544,7 @@ func (x *UpdateSandboxSecretRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use UpdateSandboxSecretRequest.ProtoReflect.Descriptor instead.
func (*UpdateSandboxSecretRequest) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{55}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{57}
}
func (x *UpdateSandboxSecretRequest) GetSandboxId() string {
@@ -3452,7 +3580,7 @@ type UpdateSandboxSecretResponse struct {
func (x *UpdateSandboxSecretResponse) Reset() {
*x = UpdateSandboxSecretResponse{}
- mi := &file_proto_worker_worker_proto_msgTypes[56]
+ mi := &file_proto_worker_worker_proto_msgTypes[58]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3464,7 +3592,7 @@ func (x *UpdateSandboxSecretResponse) String() string {
func (*UpdateSandboxSecretResponse) ProtoMessage() {}
func (x *UpdateSandboxSecretResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[56]
+ mi := &file_proto_worker_worker_proto_msgTypes[58]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3477,7 +3605,7 @@ func (x *UpdateSandboxSecretResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use UpdateSandboxSecretResponse.ProtoReflect.Descriptor instead.
func (*UpdateSandboxSecretResponse) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{56}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{58}
}
func (x *UpdateSandboxSecretResponse) GetUpdated() bool {
@@ -3497,7 +3625,7 @@ type LiveMigrateRequest struct {
func (x *LiveMigrateRequest) Reset() {
*x = LiveMigrateRequest{}
- mi := &file_proto_worker_worker_proto_msgTypes[57]
+ mi := &file_proto_worker_worker_proto_msgTypes[59]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3509,7 +3637,7 @@ func (x *LiveMigrateRequest) String() string {
func (*LiveMigrateRequest) ProtoMessage() {}
func (x *LiveMigrateRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[57]
+ mi := &file_proto_worker_worker_proto_msgTypes[59]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3522,7 +3650,7 @@ func (x *LiveMigrateRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use LiveMigrateRequest.ProtoReflect.Descriptor instead.
func (*LiveMigrateRequest) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{57}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{59}
}
func (x *LiveMigrateRequest) GetSandboxId() string {
@@ -3547,7 +3675,7 @@ type LiveMigrateResponse struct {
func (x *LiveMigrateResponse) Reset() {
*x = LiveMigrateResponse{}
- mi := &file_proto_worker_worker_proto_msgTypes[58]
+ mi := &file_proto_worker_worker_proto_msgTypes[60]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3559,7 +3687,7 @@ func (x *LiveMigrateResponse) String() string {
func (*LiveMigrateResponse) ProtoMessage() {}
func (x *LiveMigrateResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[58]
+ mi := &file_proto_worker_worker_proto_msgTypes[60]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3572,7 +3700,7 @@ func (x *LiveMigrateResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use LiveMigrateResponse.ProtoReflect.Descriptor instead.
func (*LiveMigrateResponse) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{58}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{60}
}
type CompleteMigrationIncomingRequest struct {
@@ -3584,7 +3712,7 @@ type CompleteMigrationIncomingRequest struct {
func (x *CompleteMigrationIncomingRequest) Reset() {
*x = CompleteMigrationIncomingRequest{}
- mi := &file_proto_worker_worker_proto_msgTypes[59]
+ mi := &file_proto_worker_worker_proto_msgTypes[61]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3596,7 +3724,7 @@ func (x *CompleteMigrationIncomingRequest) String() string {
func (*CompleteMigrationIncomingRequest) ProtoMessage() {}
func (x *CompleteMigrationIncomingRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[59]
+ mi := &file_proto_worker_worker_proto_msgTypes[61]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3609,7 +3737,7 @@ func (x *CompleteMigrationIncomingRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use CompleteMigrationIncomingRequest.ProtoReflect.Descriptor instead.
func (*CompleteMigrationIncomingRequest) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{59}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{61}
}
func (x *CompleteMigrationIncomingRequest) GetSandboxId() string {
@@ -3627,7 +3755,7 @@ type CompleteMigrationIncomingResponse struct {
func (x *CompleteMigrationIncomingResponse) Reset() {
*x = CompleteMigrationIncomingResponse{}
- mi := &file_proto_worker_worker_proto_msgTypes[60]
+ mi := &file_proto_worker_worker_proto_msgTypes[62]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3639,7 +3767,7 @@ func (x *CompleteMigrationIncomingResponse) String() string {
func (*CompleteMigrationIncomingResponse) ProtoMessage() {}
func (x *CompleteMigrationIncomingResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[60]
+ mi := &file_proto_worker_worker_proto_msgTypes[62]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3652,7 +3780,7 @@ func (x *CompleteMigrationIncomingResponse) ProtoReflect() protoreflect.Message
// Deprecated: Use CompleteMigrationIncomingResponse.ProtoReflect.Descriptor instead.
func (*CompleteMigrationIncomingResponse) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{60}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{62}
}
// Golden snapshot management
@@ -3664,7 +3792,7 @@ type RebuildGoldenSnapshotRequest struct {
func (x *RebuildGoldenSnapshotRequest) Reset() {
*x = RebuildGoldenSnapshotRequest{}
- mi := &file_proto_worker_worker_proto_msgTypes[61]
+ mi := &file_proto_worker_worker_proto_msgTypes[63]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3676,7 +3804,7 @@ func (x *RebuildGoldenSnapshotRequest) String() string {
func (*RebuildGoldenSnapshotRequest) ProtoMessage() {}
func (x *RebuildGoldenSnapshotRequest) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[61]
+ mi := &file_proto_worker_worker_proto_msgTypes[63]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3689,7 +3817,7 @@ func (x *RebuildGoldenSnapshotRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use RebuildGoldenSnapshotRequest.ProtoReflect.Descriptor instead.
func (*RebuildGoldenSnapshotRequest) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{61}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{63}
}
type RebuildGoldenSnapshotResponse struct {
@@ -3702,7 +3830,7 @@ type RebuildGoldenSnapshotResponse struct {
func (x *RebuildGoldenSnapshotResponse) Reset() {
*x = RebuildGoldenSnapshotResponse{}
- mi := &file_proto_worker_worker_proto_msgTypes[62]
+ mi := &file_proto_worker_worker_proto_msgTypes[64]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -3714,7 +3842,7 @@ func (x *RebuildGoldenSnapshotResponse) String() string {
func (*RebuildGoldenSnapshotResponse) ProtoMessage() {}
func (x *RebuildGoldenSnapshotResponse) ProtoReflect() protoreflect.Message {
- mi := &file_proto_worker_worker_proto_msgTypes[62]
+ mi := &file_proto_worker_worker_proto_msgTypes[64]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -3727,7 +3855,7 @@ func (x *RebuildGoldenSnapshotResponse) ProtoReflect() protoreflect.Message {
// Deprecated: Use RebuildGoldenSnapshotResponse.ProtoReflect.Descriptor instead.
func (*RebuildGoldenSnapshotResponse) Descriptor() ([]byte, []int) {
- return file_proto_worker_worker_proto_rawDescGZIP(), []int{62}
+ return file_proto_worker_worker_proto_rawDescGZIP(), []int{64}
}
func (x *RebuildGoldenSnapshotResponse) GetOldVersion() string {
@@ -3950,7 +4078,18 @@ const file_proto_worker_worker_proto_rawDesc = "" +
"\n" +
"session_id\x18\x02 \x01(\tR\tsessionId\x12\x16\n" +
"\x06signal\x18\x03 \x01(\x05R\x06signal\"\x19\n" +
- "\x17ExecSessionKillResponse\"7\n" +
+ "\x17ExecSessionKillResponse\"X\n" +
+ "\x18ExecSessionResultRequest\x12\x1d\n" +
+ "\n" +
+ "sandbox_id\x18\x01 \x01(\tR\tsandboxId\x12\x1d\n" +
+ "\n" +
+ "session_id\x18\x02 \x01(\tR\tsessionId\"\xa0\x01\n" +
+ "\x19ExecSessionResultResponse\x12\x18\n" +
+ "\arunning\x18\x01 \x01(\bR\arunning\x12\x1b\n" +
+ "\texit_code\x18\x02 \x01(\x05R\bexitCode\x12\x16\n" +
+ "\x06stdout\x18\x03 \x01(\fR\x06stdout\x12\x16\n" +
+ "\x06stderr\x18\x04 \x01(\fR\x06stderr\x12\x1c\n" +
+ "\ttruncated\x18\x05 \x01(\bR\ttruncated\"7\n" +
"\x16GetSandboxStatsRequest\x12\x1d\n" +
"\n" +
"sandbox_id\x18\x01 \x01(\tR\tsandboxId\"\xc4\x01\n" +
@@ -4073,7 +4212,7 @@ const file_proto_worker_worker_proto_rawDesc = "" +
"\vold_version\x18\x01 \x01(\tR\n" +
"oldVersion\x12\x1f\n" +
"\vnew_version\x18\x02 \x01(\tR\n" +
- "newVersion2\x8b\x13\n" +
+ "newVersion2\xe5\x13\n" +
"\rSandboxWorker\x12L\n" +
"\rCreateSandbox\x12\x1c.worker.CreateSandboxRequest\x1a\x1d.worker.CreateSandboxResponse\x12O\n" +
"\x0eDestroySandbox\x12\x1d.worker.DestroySandboxRequest\x1a\x1e.worker.DestroySandboxResponse\x12C\n" +
@@ -4089,7 +4228,8 @@ const file_proto_worker_worker_proto_rawDesc = "" +
"\tPTYStream\x12\x10.worker.PTYInput\x1a\x11.worker.PTYOutput(\x010\x01\x12X\n" +
"\x11ExecSessionCreate\x12 .worker.ExecSessionCreateRequest\x1a!.worker.ExecSessionCreateResponse\x12R\n" +
"\x0fExecSessionList\x12\x1e.worker.ExecSessionListRequest\x1a\x1f.worker.ExecSessionListResponse\x12R\n" +
- "\x0fExecSessionKill\x12\x1e.worker.ExecSessionKillRequest\x1a\x1f.worker.ExecSessionKillResponse\x12U\n" +
+ "\x0fExecSessionKill\x12\x1e.worker.ExecSessionKillRequest\x1a\x1f.worker.ExecSessionKillResponse\x12X\n" +
+ "\x11ExecSessionResult\x12 .worker.ExecSessionResultRequest\x1a!.worker.ExecSessionResultResponse\x12U\n" +
"\x10HibernateSandbox\x12\x1f.worker.HibernateSandboxRequest\x1a .worker.HibernateSandboxResponse\x12F\n" +
"\vWakeSandbox\x12\x1a.worker.WakeSandboxRequest\x1a\x1b.worker.WakeSandboxResponse\x12L\n" +
"\rRebootSandbox\x12\x1c.worker.RebootSandboxRequest\x1a\x1d.worker.RebootSandboxResponse\x12X\n" +
@@ -4120,7 +4260,7 @@ func file_proto_worker_worker_proto_rawDescGZIP() []byte {
}
var file_proto_worker_worker_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_proto_worker_worker_proto_msgTypes = make([]protoimpl.MessageInfo, 74)
+var file_proto_worker_worker_proto_msgTypes = make([]protoimpl.MessageInfo, 76)
var file_proto_worker_worker_proto_goTypes = []any{
(ExecOutputChunk_Stream)(0), // 0: worker.ExecOutputChunk.Stream
(*CreateSandboxRequest)(nil), // 1: worker.CreateSandboxRequest
@@ -4165,58 +4305,60 @@ var file_proto_worker_worker_proto_goTypes = []any{
(*ExecSessionInfoEntry)(nil), // 40: worker.ExecSessionInfoEntry
(*ExecSessionKillRequest)(nil), // 41: worker.ExecSessionKillRequest
(*ExecSessionKillResponse)(nil), // 42: worker.ExecSessionKillResponse
- (*GetSandboxStatsRequest)(nil), // 43: worker.GetSandboxStatsRequest
- (*GetSandboxStatsResponse)(nil), // 44: worker.GetSandboxStatsResponse
- (*CreateCheckpointRequest)(nil), // 45: worker.CreateCheckpointRequest
- (*CreateCheckpointResponse)(nil), // 46: worker.CreateCheckpointResponse
- (*RestoreCheckpointRequest)(nil), // 47: worker.RestoreCheckpointRequest
- (*RestoreCheckpointResponse)(nil), // 48: worker.RestoreCheckpointResponse
- (*SetSandboxLimitsRequest)(nil), // 49: worker.SetSandboxLimitsRequest
- (*SetSandboxLimitsResponse)(nil), // 50: worker.SetSandboxLimitsResponse
- (*PreCopyDrivesRequest)(nil), // 51: worker.PreCopyDrivesRequest
- (*PreCopyDrivesResponse)(nil), // 52: worker.PreCopyDrivesResponse
- (*HostList)(nil), // 53: worker.HostList
- (*PrepareMigrationIncomingRequest)(nil), // 54: worker.PrepareMigrationIncomingRequest
- (*PrepareMigrationIncomingResponse)(nil), // 55: worker.PrepareMigrationIncomingResponse
- (*UpdateSandboxSecretRequest)(nil), // 56: worker.UpdateSandboxSecretRequest
- (*UpdateSandboxSecretResponse)(nil), // 57: worker.UpdateSandboxSecretResponse
- (*LiveMigrateRequest)(nil), // 58: worker.LiveMigrateRequest
- (*LiveMigrateResponse)(nil), // 59: worker.LiveMigrateResponse
- (*CompleteMigrationIncomingRequest)(nil), // 60: worker.CompleteMigrationIncomingRequest
- (*CompleteMigrationIncomingResponse)(nil), // 61: worker.CompleteMigrationIncomingResponse
- (*RebuildGoldenSnapshotRequest)(nil), // 62: worker.RebuildGoldenSnapshotRequest
- (*RebuildGoldenSnapshotResponse)(nil), // 63: worker.RebuildGoldenSnapshotResponse
- nil, // 64: worker.CreateSandboxRequest.EnvsEntry
- nil, // 65: worker.CreateSandboxRequest.SecretAllowedHostsEntry
- nil, // 66: worker.CreateSandboxRequest.SecretEnvsEntry
- nil, // 67: worker.ExecCommandRequest.EnvsEntry
- nil, // 68: worker.ExecSessionCreateRequest.EnvsEntry
- nil, // 69: worker.PreCopyDrivesResponse.SealedTokensEntry
- nil, // 70: worker.PreCopyDrivesResponse.TokenHostsEntry
- nil, // 71: worker.PreCopyDrivesResponse.SealedNamesEntry
- nil, // 72: worker.PrepareMigrationIncomingRequest.SealedTokensEntry
- nil, // 73: worker.PrepareMigrationIncomingRequest.TokenHostsEntry
- nil, // 74: worker.PrepareMigrationIncomingRequest.SealedNamesEntry
+ (*ExecSessionResultRequest)(nil), // 43: worker.ExecSessionResultRequest
+ (*ExecSessionResultResponse)(nil), // 44: worker.ExecSessionResultResponse
+ (*GetSandboxStatsRequest)(nil), // 45: worker.GetSandboxStatsRequest
+ (*GetSandboxStatsResponse)(nil), // 46: worker.GetSandboxStatsResponse
+ (*CreateCheckpointRequest)(nil), // 47: worker.CreateCheckpointRequest
+ (*CreateCheckpointResponse)(nil), // 48: worker.CreateCheckpointResponse
+ (*RestoreCheckpointRequest)(nil), // 49: worker.RestoreCheckpointRequest
+ (*RestoreCheckpointResponse)(nil), // 50: worker.RestoreCheckpointResponse
+ (*SetSandboxLimitsRequest)(nil), // 51: worker.SetSandboxLimitsRequest
+ (*SetSandboxLimitsResponse)(nil), // 52: worker.SetSandboxLimitsResponse
+ (*PreCopyDrivesRequest)(nil), // 53: worker.PreCopyDrivesRequest
+ (*PreCopyDrivesResponse)(nil), // 54: worker.PreCopyDrivesResponse
+ (*HostList)(nil), // 55: worker.HostList
+ (*PrepareMigrationIncomingRequest)(nil), // 56: worker.PrepareMigrationIncomingRequest
+ (*PrepareMigrationIncomingResponse)(nil), // 57: worker.PrepareMigrationIncomingResponse
+ (*UpdateSandboxSecretRequest)(nil), // 58: worker.UpdateSandboxSecretRequest
+ (*UpdateSandboxSecretResponse)(nil), // 59: worker.UpdateSandboxSecretResponse
+ (*LiveMigrateRequest)(nil), // 60: worker.LiveMigrateRequest
+ (*LiveMigrateResponse)(nil), // 61: worker.LiveMigrateResponse
+ (*CompleteMigrationIncomingRequest)(nil), // 62: worker.CompleteMigrationIncomingRequest
+ (*CompleteMigrationIncomingResponse)(nil), // 63: worker.CompleteMigrationIncomingResponse
+ (*RebuildGoldenSnapshotRequest)(nil), // 64: worker.RebuildGoldenSnapshotRequest
+ (*RebuildGoldenSnapshotResponse)(nil), // 65: worker.RebuildGoldenSnapshotResponse
+ nil, // 66: worker.CreateSandboxRequest.EnvsEntry
+ nil, // 67: worker.CreateSandboxRequest.SecretAllowedHostsEntry
+ nil, // 68: worker.CreateSandboxRequest.SecretEnvsEntry
+ nil, // 69: worker.ExecCommandRequest.EnvsEntry
+ nil, // 70: worker.ExecSessionCreateRequest.EnvsEntry
+ nil, // 71: worker.PreCopyDrivesResponse.SealedTokensEntry
+ nil, // 72: worker.PreCopyDrivesResponse.TokenHostsEntry
+ nil, // 73: worker.PreCopyDrivesResponse.SealedNamesEntry
+ nil, // 74: worker.PrepareMigrationIncomingRequest.SealedTokensEntry
+ nil, // 75: worker.PrepareMigrationIncomingRequest.TokenHostsEntry
+ nil, // 76: worker.PrepareMigrationIncomingRequest.SealedNamesEntry
}
var file_proto_worker_worker_proto_depIdxs = []int32{
- 64, // 0: worker.CreateSandboxRequest.envs:type_name -> worker.CreateSandboxRequest.EnvsEntry
- 65, // 1: worker.CreateSandboxRequest.secret_allowed_hosts:type_name -> worker.CreateSandboxRequest.SecretAllowedHostsEntry
- 66, // 2: worker.CreateSandboxRequest.secret_envs:type_name -> worker.CreateSandboxRequest.SecretEnvsEntry
+ 66, // 0: worker.CreateSandboxRequest.envs:type_name -> worker.CreateSandboxRequest.EnvsEntry
+ 67, // 1: worker.CreateSandboxRequest.secret_allowed_hosts:type_name -> worker.CreateSandboxRequest.SecretAllowedHostsEntry
+ 68, // 2: worker.CreateSandboxRequest.secret_envs:type_name -> worker.CreateSandboxRequest.SecretEnvsEntry
10, // 3: worker.ListSandboxesResponse.sandboxes:type_name -> worker.GetSandboxResponse
- 67, // 4: worker.ExecCommandRequest.envs:type_name -> worker.ExecCommandRequest.EnvsEntry
+ 69, // 4: worker.ExecCommandRequest.envs:type_name -> worker.ExecCommandRequest.EnvsEntry
0, // 5: worker.ExecOutputChunk.stream:type_name -> worker.ExecOutputChunk.Stream
21, // 6: worker.ListDirResponse.entries:type_name -> worker.DirEntry
26, // 7: worker.PTYInput.resize:type_name -> worker.PTYResize
- 68, // 8: worker.ExecSessionCreateRequest.envs:type_name -> worker.ExecSessionCreateRequest.EnvsEntry
+ 70, // 8: worker.ExecSessionCreateRequest.envs:type_name -> worker.ExecSessionCreateRequest.EnvsEntry
40, // 9: worker.ExecSessionListResponse.sessions:type_name -> worker.ExecSessionInfoEntry
- 69, // 10: worker.PreCopyDrivesResponse.sealed_tokens:type_name -> worker.PreCopyDrivesResponse.SealedTokensEntry
- 70, // 11: worker.PreCopyDrivesResponse.token_hosts:type_name -> worker.PreCopyDrivesResponse.TokenHostsEntry
- 71, // 12: worker.PreCopyDrivesResponse.sealed_names:type_name -> worker.PreCopyDrivesResponse.SealedNamesEntry
- 72, // 13: worker.PrepareMigrationIncomingRequest.sealed_tokens:type_name -> worker.PrepareMigrationIncomingRequest.SealedTokensEntry
- 73, // 14: worker.PrepareMigrationIncomingRequest.token_hosts:type_name -> worker.PrepareMigrationIncomingRequest.TokenHostsEntry
- 74, // 15: worker.PrepareMigrationIncomingRequest.sealed_names:type_name -> worker.PrepareMigrationIncomingRequest.SealedNamesEntry
- 53, // 16: worker.PreCopyDrivesResponse.TokenHostsEntry.value:type_name -> worker.HostList
- 53, // 17: worker.PrepareMigrationIncomingRequest.TokenHostsEntry.value:type_name -> worker.HostList
+ 71, // 10: worker.PreCopyDrivesResponse.sealed_tokens:type_name -> worker.PreCopyDrivesResponse.SealedTokensEntry
+ 72, // 11: worker.PreCopyDrivesResponse.token_hosts:type_name -> worker.PreCopyDrivesResponse.TokenHostsEntry
+ 73, // 12: worker.PreCopyDrivesResponse.sealed_names:type_name -> worker.PreCopyDrivesResponse.SealedNamesEntry
+ 74, // 13: worker.PrepareMigrationIncomingRequest.sealed_tokens:type_name -> worker.PrepareMigrationIncomingRequest.SealedTokensEntry
+ 75, // 14: worker.PrepareMigrationIncomingRequest.token_hosts:type_name -> worker.PrepareMigrationIncomingRequest.TokenHostsEntry
+ 76, // 15: worker.PrepareMigrationIncomingRequest.sealed_names:type_name -> worker.PrepareMigrationIncomingRequest.SealedNamesEntry
+ 55, // 16: worker.PreCopyDrivesResponse.TokenHostsEntry.value:type_name -> worker.HostList
+ 55, // 17: worker.PrepareMigrationIncomingRequest.TokenHostsEntry.value:type_name -> worker.HostList
1, // 18: worker.SandboxWorker.CreateSandbox:input_type -> worker.CreateSandboxRequest
3, // 19: worker.SandboxWorker.DestroySandbox:input_type -> worker.DestroySandboxRequest
9, // 20: worker.SandboxWorker.GetSandbox:input_type -> worker.GetSandboxRequest
@@ -4231,54 +4373,56 @@ var file_proto_worker_worker_proto_depIdxs = []int32{
36, // 29: worker.SandboxWorker.ExecSessionCreate:input_type -> worker.ExecSessionCreateRequest
38, // 30: worker.SandboxWorker.ExecSessionList:input_type -> worker.ExecSessionListRequest
41, // 31: worker.SandboxWorker.ExecSessionKill:input_type -> worker.ExecSessionKillRequest
- 28, // 32: worker.SandboxWorker.HibernateSandbox:input_type -> worker.HibernateSandboxRequest
- 30, // 33: worker.SandboxWorker.WakeSandbox:input_type -> worker.WakeSandboxRequest
- 5, // 34: worker.SandboxWorker.RebootSandbox:input_type -> worker.RebootSandboxRequest
- 7, // 35: worker.SandboxWorker.PowerCycleSandbox:input_type -> worker.PowerCycleSandboxRequest
- 32, // 36: worker.SandboxWorker.SaveAsTemplate:input_type -> worker.SaveAsTemplateRequest
- 45, // 37: worker.SandboxWorker.CreateCheckpoint:input_type -> worker.CreateCheckpointRequest
- 47, // 38: worker.SandboxWorker.RestoreCheckpoint:input_type -> worker.RestoreCheckpointRequest
- 34, // 39: worker.SandboxWorker.BuildTemplate:input_type -> worker.BuildTemplateRequest
- 43, // 40: worker.SandboxWorker.GetSandboxStats:input_type -> worker.GetSandboxStatsRequest
- 49, // 41: worker.SandboxWorker.SetSandboxLimits:input_type -> worker.SetSandboxLimitsRequest
- 56, // 42: worker.SandboxWorker.UpdateSandboxSecret:input_type -> worker.UpdateSandboxSecretRequest
- 51, // 43: worker.SandboxWorker.PreCopyDrives:input_type -> worker.PreCopyDrivesRequest
- 54, // 44: worker.SandboxWorker.PrepareMigrationIncoming:input_type -> worker.PrepareMigrationIncomingRequest
- 58, // 45: worker.SandboxWorker.LiveMigrate:input_type -> worker.LiveMigrateRequest
- 60, // 46: worker.SandboxWorker.CompleteMigrationIncoming:input_type -> worker.CompleteMigrationIncomingRequest
- 62, // 47: worker.SandboxWorker.RebuildGoldenSnapshot:input_type -> worker.RebuildGoldenSnapshotRequest
- 2, // 48: worker.SandboxWorker.CreateSandbox:output_type -> worker.CreateSandboxResponse
- 4, // 49: worker.SandboxWorker.DestroySandbox:output_type -> worker.DestroySandboxResponse
- 10, // 50: worker.SandboxWorker.GetSandbox:output_type -> worker.GetSandboxResponse
- 12, // 51: worker.SandboxWorker.ListSandboxes:output_type -> worker.ListSandboxesResponse
- 14, // 52: worker.SandboxWorker.ExecCommand:output_type -> worker.ExecCommandResponse
- 15, // 53: worker.SandboxWorker.ExecCommandStream:output_type -> worker.ExecOutputChunk
- 17, // 54: worker.SandboxWorker.ReadFile:output_type -> worker.ReadFileResponse
- 19, // 55: worker.SandboxWorker.WriteFile:output_type -> worker.WriteFileResponse
- 22, // 56: worker.SandboxWorker.ListDir:output_type -> worker.ListDirResponse
- 24, // 57: worker.SandboxWorker.CreatePTY:output_type -> worker.CreatePTYResponse
- 27, // 58: worker.SandboxWorker.PTYStream:output_type -> worker.PTYOutput
- 37, // 59: worker.SandboxWorker.ExecSessionCreate:output_type -> worker.ExecSessionCreateResponse
- 39, // 60: worker.SandboxWorker.ExecSessionList:output_type -> worker.ExecSessionListResponse
- 42, // 61: worker.SandboxWorker.ExecSessionKill:output_type -> worker.ExecSessionKillResponse
- 29, // 62: worker.SandboxWorker.HibernateSandbox:output_type -> worker.HibernateSandboxResponse
- 31, // 63: worker.SandboxWorker.WakeSandbox:output_type -> worker.WakeSandboxResponse
- 6, // 64: worker.SandboxWorker.RebootSandbox:output_type -> worker.RebootSandboxResponse
- 8, // 65: worker.SandboxWorker.PowerCycleSandbox:output_type -> worker.PowerCycleSandboxResponse
- 33, // 66: worker.SandboxWorker.SaveAsTemplate:output_type -> worker.SaveAsTemplateResponse
- 46, // 67: worker.SandboxWorker.CreateCheckpoint:output_type -> worker.CreateCheckpointResponse
- 48, // 68: worker.SandboxWorker.RestoreCheckpoint:output_type -> worker.RestoreCheckpointResponse
- 35, // 69: worker.SandboxWorker.BuildTemplate:output_type -> worker.BuildTemplateResponse
- 44, // 70: worker.SandboxWorker.GetSandboxStats:output_type -> worker.GetSandboxStatsResponse
- 50, // 71: worker.SandboxWorker.SetSandboxLimits:output_type -> worker.SetSandboxLimitsResponse
- 57, // 72: worker.SandboxWorker.UpdateSandboxSecret:output_type -> worker.UpdateSandboxSecretResponse
- 52, // 73: worker.SandboxWorker.PreCopyDrives:output_type -> worker.PreCopyDrivesResponse
- 55, // 74: worker.SandboxWorker.PrepareMigrationIncoming:output_type -> worker.PrepareMigrationIncomingResponse
- 59, // 75: worker.SandboxWorker.LiveMigrate:output_type -> worker.LiveMigrateResponse
- 61, // 76: worker.SandboxWorker.CompleteMigrationIncoming:output_type -> worker.CompleteMigrationIncomingResponse
- 63, // 77: worker.SandboxWorker.RebuildGoldenSnapshot:output_type -> worker.RebuildGoldenSnapshotResponse
- 48, // [48:78] is the sub-list for method output_type
- 18, // [18:48] is the sub-list for method input_type
+ 43, // 32: worker.SandboxWorker.ExecSessionResult:input_type -> worker.ExecSessionResultRequest
+ 28, // 33: worker.SandboxWorker.HibernateSandbox:input_type -> worker.HibernateSandboxRequest
+ 30, // 34: worker.SandboxWorker.WakeSandbox:input_type -> worker.WakeSandboxRequest
+ 5, // 35: worker.SandboxWorker.RebootSandbox:input_type -> worker.RebootSandboxRequest
+ 7, // 36: worker.SandboxWorker.PowerCycleSandbox:input_type -> worker.PowerCycleSandboxRequest
+ 32, // 37: worker.SandboxWorker.SaveAsTemplate:input_type -> worker.SaveAsTemplateRequest
+ 47, // 38: worker.SandboxWorker.CreateCheckpoint:input_type -> worker.CreateCheckpointRequest
+ 49, // 39: worker.SandboxWorker.RestoreCheckpoint:input_type -> worker.RestoreCheckpointRequest
+ 34, // 40: worker.SandboxWorker.BuildTemplate:input_type -> worker.BuildTemplateRequest
+ 45, // 41: worker.SandboxWorker.GetSandboxStats:input_type -> worker.GetSandboxStatsRequest
+ 51, // 42: worker.SandboxWorker.SetSandboxLimits:input_type -> worker.SetSandboxLimitsRequest
+ 58, // 43: worker.SandboxWorker.UpdateSandboxSecret:input_type -> worker.UpdateSandboxSecretRequest
+ 53, // 44: worker.SandboxWorker.PreCopyDrives:input_type -> worker.PreCopyDrivesRequest
+ 56, // 45: worker.SandboxWorker.PrepareMigrationIncoming:input_type -> worker.PrepareMigrationIncomingRequest
+ 60, // 46: worker.SandboxWorker.LiveMigrate:input_type -> worker.LiveMigrateRequest
+ 62, // 47: worker.SandboxWorker.CompleteMigrationIncoming:input_type -> worker.CompleteMigrationIncomingRequest
+ 64, // 48: worker.SandboxWorker.RebuildGoldenSnapshot:input_type -> worker.RebuildGoldenSnapshotRequest
+ 2, // 49: worker.SandboxWorker.CreateSandbox:output_type -> worker.CreateSandboxResponse
+ 4, // 50: worker.SandboxWorker.DestroySandbox:output_type -> worker.DestroySandboxResponse
+ 10, // 51: worker.SandboxWorker.GetSandbox:output_type -> worker.GetSandboxResponse
+ 12, // 52: worker.SandboxWorker.ListSandboxes:output_type -> worker.ListSandboxesResponse
+ 14, // 53: worker.SandboxWorker.ExecCommand:output_type -> worker.ExecCommandResponse
+ 15, // 54: worker.SandboxWorker.ExecCommandStream:output_type -> worker.ExecOutputChunk
+ 17, // 55: worker.SandboxWorker.ReadFile:output_type -> worker.ReadFileResponse
+ 19, // 56: worker.SandboxWorker.WriteFile:output_type -> worker.WriteFileResponse
+ 22, // 57: worker.SandboxWorker.ListDir:output_type -> worker.ListDirResponse
+ 24, // 58: worker.SandboxWorker.CreatePTY:output_type -> worker.CreatePTYResponse
+ 27, // 59: worker.SandboxWorker.PTYStream:output_type -> worker.PTYOutput
+ 37, // 60: worker.SandboxWorker.ExecSessionCreate:output_type -> worker.ExecSessionCreateResponse
+ 39, // 61: worker.SandboxWorker.ExecSessionList:output_type -> worker.ExecSessionListResponse
+ 42, // 62: worker.SandboxWorker.ExecSessionKill:output_type -> worker.ExecSessionKillResponse
+ 44, // 63: worker.SandboxWorker.ExecSessionResult:output_type -> worker.ExecSessionResultResponse
+ 29, // 64: worker.SandboxWorker.HibernateSandbox:output_type -> worker.HibernateSandboxResponse
+ 31, // 65: worker.SandboxWorker.WakeSandbox:output_type -> worker.WakeSandboxResponse
+ 6, // 66: worker.SandboxWorker.RebootSandbox:output_type -> worker.RebootSandboxResponse
+ 8, // 67: worker.SandboxWorker.PowerCycleSandbox:output_type -> worker.PowerCycleSandboxResponse
+ 33, // 68: worker.SandboxWorker.SaveAsTemplate:output_type -> worker.SaveAsTemplateResponse
+ 48, // 69: worker.SandboxWorker.CreateCheckpoint:output_type -> worker.CreateCheckpointResponse
+ 50, // 70: worker.SandboxWorker.RestoreCheckpoint:output_type -> worker.RestoreCheckpointResponse
+ 35, // 71: worker.SandboxWorker.BuildTemplate:output_type -> worker.BuildTemplateResponse
+ 46, // 72: worker.SandboxWorker.GetSandboxStats:output_type -> worker.GetSandboxStatsResponse
+ 52, // 73: worker.SandboxWorker.SetSandboxLimits:output_type -> worker.SetSandboxLimitsResponse
+ 59, // 74: worker.SandboxWorker.UpdateSandboxSecret:output_type -> worker.UpdateSandboxSecretResponse
+ 54, // 75: worker.SandboxWorker.PreCopyDrives:output_type -> worker.PreCopyDrivesResponse
+ 57, // 76: worker.SandboxWorker.PrepareMigrationIncoming:output_type -> worker.PrepareMigrationIncomingResponse
+ 61, // 77: worker.SandboxWorker.LiveMigrate:output_type -> worker.LiveMigrateResponse
+ 63, // 78: worker.SandboxWorker.CompleteMigrationIncoming:output_type -> worker.CompleteMigrationIncomingResponse
+ 65, // 79: worker.SandboxWorker.RebuildGoldenSnapshot:output_type -> worker.RebuildGoldenSnapshotResponse
+ 49, // [49:80] is the sub-list for method output_type
+ 18, // [18:49] is the sub-list for method input_type
18, // [18:18] is the sub-list for extension type_name
18, // [18:18] is the sub-list for extension extendee
0, // [0:18] is the sub-list for field type_name
@@ -4299,7 +4443,7 @@ func file_proto_worker_worker_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_worker_worker_proto_rawDesc), len(file_proto_worker_worker_proto_rawDesc)),
NumEnums: 1,
- NumMessages: 74,
+ NumMessages: 76,
NumExtensions: 0,
NumServices: 1,
},
diff --git a/proto/worker/worker.proto b/proto/worker/worker.proto
index 18bc58b3..3eff816e 100644
--- a/proto/worker/worker.proto
+++ b/proto/worker/worker.proto
@@ -23,6 +23,7 @@ service SandboxWorker {
rpc ExecSessionCreate(ExecSessionCreateRequest) returns (ExecSessionCreateResponse);
rpc ExecSessionList(ExecSessionListRequest) returns (ExecSessionListResponse);
rpc ExecSessionKill(ExecSessionKillRequest) returns (ExecSessionKillResponse);
+ rpc ExecSessionResult(ExecSessionResultRequest) returns (ExecSessionResultResponse);
rpc HibernateSandbox(HibernateSandboxRequest) returns (HibernateSandboxResponse);
rpc WakeSandbox(WakeSandboxRequest) returns (WakeSandboxResponse);
@@ -319,6 +320,19 @@ message ExecSessionKillRequest {
message ExecSessionKillResponse {}
+message ExecSessionResultRequest {
+ string sandbox_id = 1;
+ string session_id = 2;
+}
+
+message ExecSessionResultResponse {
+ bool running = 1;
+ int32 exit_code = 2; // valid only when running = false
+ bytes stdout = 3;
+ bytes stderr = 4;
+ bool truncated = 5;
+}
+
// --- Stats ---
message GetSandboxStatsRequest {
diff --git a/proto/worker/worker_grpc.pb.go b/proto/worker/worker_grpc.pb.go
index bf3105a3..e5a8356c 100644
--- a/proto/worker/worker_grpc.pb.go
+++ b/proto/worker/worker_grpc.pb.go
@@ -33,6 +33,7 @@ const (
SandboxWorker_ExecSessionCreate_FullMethodName = "/worker.SandboxWorker/ExecSessionCreate"
SandboxWorker_ExecSessionList_FullMethodName = "/worker.SandboxWorker/ExecSessionList"
SandboxWorker_ExecSessionKill_FullMethodName = "/worker.SandboxWorker/ExecSessionKill"
+ SandboxWorker_ExecSessionResult_FullMethodName = "/worker.SandboxWorker/ExecSessionResult"
SandboxWorker_HibernateSandbox_FullMethodName = "/worker.SandboxWorker/HibernateSandbox"
SandboxWorker_WakeSandbox_FullMethodName = "/worker.SandboxWorker/WakeSandbox"
SandboxWorker_RebootSandbox_FullMethodName = "/worker.SandboxWorker/RebootSandbox"
@@ -69,6 +70,7 @@ type SandboxWorkerClient interface {
ExecSessionCreate(ctx context.Context, in *ExecSessionCreateRequest, opts ...grpc.CallOption) (*ExecSessionCreateResponse, error)
ExecSessionList(ctx context.Context, in *ExecSessionListRequest, opts ...grpc.CallOption) (*ExecSessionListResponse, error)
ExecSessionKill(ctx context.Context, in *ExecSessionKillRequest, opts ...grpc.CallOption) (*ExecSessionKillResponse, error)
+ ExecSessionResult(ctx context.Context, in *ExecSessionResultRequest, opts ...grpc.CallOption) (*ExecSessionResultResponse, error)
HibernateSandbox(ctx context.Context, in *HibernateSandboxRequest, opts ...grpc.CallOption) (*HibernateSandboxResponse, error)
WakeSandbox(ctx context.Context, in *WakeSandboxRequest, opts ...grpc.CallOption) (*WakeSandboxResponse, error)
// Reboot performs a soft, in-place guest reset (QMP system_reset). The
@@ -264,6 +266,16 @@ func (c *sandboxWorkerClient) ExecSessionKill(ctx context.Context, in *ExecSessi
return out, nil
}
+func (c *sandboxWorkerClient) ExecSessionResult(ctx context.Context, in *ExecSessionResultRequest, opts ...grpc.CallOption) (*ExecSessionResultResponse, error) {
+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
+ out := new(ExecSessionResultResponse)
+ err := c.cc.Invoke(ctx, SandboxWorker_ExecSessionResult_FullMethodName, in, out, cOpts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
func (c *sandboxWorkerClient) HibernateSandbox(ctx context.Context, in *HibernateSandboxRequest, opts ...grpc.CallOption) (*HibernateSandboxResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(HibernateSandboxResponse)
@@ -442,6 +454,7 @@ type SandboxWorkerServer interface {
ExecSessionCreate(context.Context, *ExecSessionCreateRequest) (*ExecSessionCreateResponse, error)
ExecSessionList(context.Context, *ExecSessionListRequest) (*ExecSessionListResponse, error)
ExecSessionKill(context.Context, *ExecSessionKillRequest) (*ExecSessionKillResponse, error)
+ ExecSessionResult(context.Context, *ExecSessionResultRequest) (*ExecSessionResultResponse, error)
HibernateSandbox(context.Context, *HibernateSandboxRequest) (*HibernateSandboxResponse, error)
WakeSandbox(context.Context, *WakeSandboxRequest) (*WakeSandboxResponse, error)
// Reboot performs a soft, in-place guest reset (QMP system_reset). The
@@ -527,6 +540,9 @@ func (UnimplementedSandboxWorkerServer) ExecSessionList(context.Context, *ExecSe
func (UnimplementedSandboxWorkerServer) ExecSessionKill(context.Context, *ExecSessionKillRequest) (*ExecSessionKillResponse, error) {
return nil, status.Error(codes.Unimplemented, "method ExecSessionKill not implemented")
}
+func (UnimplementedSandboxWorkerServer) ExecSessionResult(context.Context, *ExecSessionResultRequest) (*ExecSessionResultResponse, error) {
+ return nil, status.Error(codes.Unimplemented, "method ExecSessionResult not implemented")
+}
func (UnimplementedSandboxWorkerServer) HibernateSandbox(context.Context, *HibernateSandboxRequest) (*HibernateSandboxResponse, error) {
return nil, status.Error(codes.Unimplemented, "method HibernateSandbox not implemented")
}
@@ -830,6 +846,24 @@ func _SandboxWorker_ExecSessionKill_Handler(srv interface{}, ctx context.Context
return interceptor(ctx, in, info, handler)
}
+func _SandboxWorker_ExecSessionResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(ExecSessionResultRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(SandboxWorkerServer).ExecSessionResult(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: SandboxWorker_ExecSessionResult_FullMethodName,
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(SandboxWorkerServer).ExecSessionResult(ctx, req.(*ExecSessionResultRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
func _SandboxWorker_HibernateSandbox_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HibernateSandboxRequest)
if err := dec(in); err != nil {
@@ -1173,6 +1207,10 @@ var SandboxWorker_ServiceDesc = grpc.ServiceDesc{
MethodName: "ExecSessionKill",
Handler: _SandboxWorker_ExecSessionKill_Handler,
},
+ {
+ MethodName: "ExecSessionResult",
+ Handler: _SandboxWorker_ExecSessionResult_Handler,
+ },
{
MethodName: "HibernateSandbox",
Handler: _SandboxWorker_HibernateSandbox_Handler,
diff --git a/sdks/typescript/src/exec.ts b/sdks/typescript/src/exec.ts
index 50535134..6c86bb4b 100644
--- a/sdks/typescript/src/exec.ts
+++ b/sdks/typescript/src/exec.ts
@@ -7,9 +7,72 @@ export interface ProcessResult {
}
export interface RunOpts {
+ /** Server-side command timeout in seconds (default 60). */
timeout?: number;
env?: Record<string, string>;
cwd?: string;
+ /**
+ * Abort the client-side wait for the result. The command keeps running on the
+ * worker and stays retrievable by execId (exposed on the thrown error).
+ */
+ signal?: AbortSignal;
+ /**
+ * Max time to wait client-side for the command to finish, in milliseconds.
+ * On expiry, run() throws an ExecTimeoutError but the command keeps running.
+ */
+ timeoutMs?: number;
+}
+
+/**
+ * Thrown when run()'s client-side wait is aborted or times out. The command is
+ * still running on the worker; re-poll or attach via execId to recover it.
+ */
+export class ExecTimeoutError extends Error {
+ constructor(public readonly execId: string, message: string) {
+ super(message);
+ this.name = "ExecTimeoutError";
+ }
+}
+
+interface ExecRunHandle {
+ execId?: string;
+ running?: boolean;
+ startedAt?: string;
+ // Back-compat: a pre-async origin returns the full result synchronously.
+ exitCode?: number;
+ stdout?: string;
+ stderr?: string;
+}
+
+interface ExecRunResult {
+ running: boolean;
+ waking?: boolean;
+ exitCode?: number;
+ stdout?: string;
+ stderr?: string;
+ truncated?: boolean;
+ error?: string;
+ // Timing breakdown (524 attribution), observable per-request.
+ wakeMs?: number;
+ createMs?: number;
+ commandMs?: number;
+}
+
+/** Sleep that resolves early (does not reject) when the signal aborts. */
+function sleep(ms: number, signal?: AbortSignal): Promise<void> {
+ return new Promise((resolve) => {
+ if (signal?.aborted) return resolve();
+ const onAbort = () => {
+ clearTimeout(timer);
+ signal?.removeEventListener("abort", onAbort);
+ resolve();
+ };
+ const timer = setTimeout(() => {
+ signal?.removeEventListener("abort", onAbort);
+ resolve();
+ }, ms);
+ signal?.addEventListener("abort", onAbort);
+ });
}
export interface ExecStartOpts {
@@ -281,6 +344,20 @@ export class Exec {
return impl;
}
+ /**
+ * Run a command and wait for it to finish, returning its result.
+ *
+ * Transparently async: POSTs to /exec/run (which returns a handle
+ * immediately) then polls /exec/:execId/result until the command exits. Each
+ * HTTP request is sub-second, so there is no proxy 524 regardless of how long
+ * the command runs, and a dropped poll simply retries — the result persists
+ * on the worker independent of the connection.
+ *
+ * Pass `timeoutMs`/`signal` to bound the client-side wait; on expiry an
+ * {@link ExecTimeoutError} is thrown (carrying execId) while the command
+ * keeps running. For live output instead of wait-for-result, use
+ * {@link start}/{@link background} + {@link attach}.
+ */
async run(command: string, opts: RunOpts = {}): Promise<ProcessResult> {
const body: Record<string, unknown> = {
cmd: "sh",
@@ -288,8 +365,7 @@ export class Exec {
};
if (opts.env) body.envs = opts.env;
if (opts.cwd) body.cwd = opts.cwd;
- if (opts.timeout != null) body.timeout = opts.timeout;
- else body.timeout = 60;
+ body.timeout = opts.timeout != null ? opts.timeout : 60;
const resp = await fetch(`${this.apiUrl}/sandboxes/${this.sandboxId}/exec/run`, {
method: "POST",
@@ -302,6 +378,59 @@ export class Exec {
throw new Error(`Failed to run command: ${resp.status} ${text}`);
}
+ const handle = (await resp.json()) as ExecRunHandle;
+
+ // Back-compat: an older (synchronous) origin returns the full result.
+ if (handle.execId == null && handle.exitCode != null) {
+ return {
+ exitCode: handle.exitCode,
+ stdout: handle.stdout ?? "",
+ stderr: handle.stderr ?? "",
+ };
+ }
+
+ const execId = handle.execId!;
+ const deadline = opts.timeoutMs != null ? Date.now() + opts.timeoutMs : null;
+ let delay = 200;
+ const maxDelay = 2000;
+
+ for (;;) {
+ if (opts.signal?.aborted) {
+ throw new ExecTimeoutError(execId, `exec.run aborted; command still running (execId=${execId})`);
+ }
+ if (deadline != null && Date.now() >= deadline) {
+ throw new ExecTimeoutError(execId, `exec.run timed out after ${opts.timeoutMs}ms; command still running (execId=${execId})`);
+ }
+
+ const result = await this.result(execId);
+ if (!result.running) {
+ if (result.error) {
+ // Wake/restore or session creation failed on the worker.
+ throw new Error(`exec.run failed: ${result.error}`);
+ }
+ return {
+ exitCode: result.exitCode ?? 0,
+ stdout: result.stdout ?? "",
+ stderr: result.stderr ?? "",
+ };
+ }
+
+ await sleep(delay, opts.signal);
+ delay = Math.min(delay * 2, maxDelay);
+ }
+ }
+
+ /** Fetch the current result of an exec session (poll target for run()). */
+ private async result(execId: string): Promise<ExecRunResult> {
+ const resp = await fetch(`${this.apiUrl}/sandboxes/${this.sandboxId}/exec/${execId}/result`, {
+ headers: this.headers,
+ });
+
+ if (!resp.ok) {
+ const text = await resp.text();
+ throw new Error(`Failed to fetch exec result: ${resp.status} ${text}`);
+ }
+
return resp.json();
}
}
diff --git a/sdks/typescript/src/filesystem.ts b/sdks/typescript/src/filesystem.ts
index 0f0ff369..d92541d8 100644
--- a/sdks/typescript/src/filesystem.ts
+++ b/sdks/typescript/src/filesystem.ts
@@ -18,8 +18,27 @@ export class Filesystem {
return this.apiKey ? { "X-API-Key": this.apiKey } : {};
}
+ // wfetch transparently rides out a cold-start wake. If the sandbox is
+ // hibernated, the control plane wakes it in the background and returns
+ // 503 { waking: true } immediately (rather than restoring on the connection
+ // and risking a proxy 524). We retry until the box is up. Bounded so a wake
+ // that can't complete eventually surfaces the 503 instead of hanging forever.
+ private async wfetch(url: string, init?: RequestInit): Promise<Response> {
+ const deadline = Date.now() + 120_000;
+ let delay = 500;
+ for (;;) {
+ const resp = await fetch(url, init);
+ if (resp.status !== 503) return resp;
+ let waking = false;
+ try { waking = (await resp.clone().json())?.waking === true; } catch { /* not JSON */ }
+ if (!waking || Date.now() >= deadline) return resp;
+ await new Promise((r) => setTimeout(r, delay));
+ delay = Math.min(delay * 2, 3000);
+ }
+ }
+
async read(path: string): Promise<string> {
- const resp = await fetch(
+ const resp = await this.wfetch(
`${this.apiUrl}/sandboxes/${this.sandboxId}/files?path=${encodeURIComponent(path)}`,
{ headers: this.headers },
);
@@ -28,7 +47,7 @@ export class Filesystem {
}
async readBytes(path: string): Promise<Uint8Array> {
- const resp = await fetch(
+ const resp = await this.wfetch(
`${this.apiUrl}/sandboxes/${this.sandboxId}/files?path=${encodeURIComponent(path)}`,
{ headers: this.headers },
);
@@ -44,18 +63,18 @@ export class Filesystem {
};
// duplex: "half" is required for ReadableStream bodies in Node.js fetch,
// but must NOT be set for Uint8Array/Buffer/string bodies.
- if (content instanceof ReadableStream) {
+ const isStream = content instanceof ReadableStream;
+ if (isStream) {
opts.duplex = "half";
}
- const resp = await fetch(
- `${this.apiUrl}/sandboxes/${this.sandboxId}/files?path=${encodeURIComponent(path)}`,
- opts,
- );
+ const url = `${this.apiUrl}/sandboxes/${this.sandboxId}/files?path=${encodeURIComponent(path)}`;
+ // A stream body can't be replayed across a wake retry; string/bytes can.
+ const resp = isStream ? await fetch(url, opts) : await this.wfetch(url, opts);
if (!resp.ok) throw new Error(`Failed to write ${path}: ${resp.status}`);
}
async list(path: string = "/"): Promise<EntryInfo[]> {
- const resp = await fetch(
+ const resp = await this.wfetch(
`${this.apiUrl}/sandboxes/${this.sandboxId}/files/list?path=${encodeURIComponent(path)}`,
{ headers: this.headers },
);
@@ -65,7 +84,7 @@ export class Filesystem {
}
async makeDir(path: string): Promise<void> {
- const resp = await fetch(
+ const resp = await this.wfetch(
`${this.apiUrl}/sandboxes/${this.sandboxId}/files/mkdir?path=${encodeURIComponent(path)}`,
{ method: "POST", headers: this.headers },
);
@@ -73,7 +92,7 @@ export class Filesystem {
}
async remove(path: string): Promise<void> {
- const resp = await fetch(
+ const resp = await this.wfetch(
`${this.apiUrl}/sandboxes/${this.sandboxId}/files?path=${encodeURIComponent(path)}`,
{ method: "DELETE", headers: this.headers },
);
@@ -82,7 +101,7 @@ export class Filesystem {
async exists(path: string): Promise<boolean> {
try {
- const resp = await fetch(
+ const resp = await this.wfetch(
`${this.apiUrl}/sandboxes/${this.sandboxId}/files?path=${encodeURIComponent(path)}`,
{ headers: this.headers },
);
diff --git a/sdks/typescript/src/index.ts b/sdks/typescript/src/index.ts
index d34e86f5..399de8f7 100644
--- a/sdks/typescript/src/index.ts
+++ b/sdks/typescript/src/index.ts
@@ -17,7 +17,7 @@ export { SandboxAgent, type SandboxAgentEvent, type SandboxAgentConfig, type San
// Managed Durable Agent Sessions (the OpenComputer client + Session handle).
export * from "./agents/index.js";
export { Filesystem, type EntryInfo } from "./filesystem.js";
-export { Exec, type ProcessResult, type RunOpts, type ExecSession, type ExecSessionInfo, type ExecStartOpts, type ExecAttachOpts } from "./exec.js";
+export { Exec, ExecTimeoutError, type ProcessResult, type RunOpts, type ExecSession, type ExecSessionInfo, type ExecStartOpts, type ExecAttachOpts } from "./exec.js";
export { Mounts, type AddMountOpts, type MountInfo, type MountBackend } from "./mounts.js";
export { type Shell, type ShellOpts, type ShellRunOpts, ShellBusyError, ShellClosedError } from "./shell.js";
export { Pty, type PtySession, type PtyOpts } from "./pty.js";
@@ -59,4 +59,4 @@ export {
} from "./usage.js";
// Node.js-only modules (use crypto, fs, path) — import via "@opencomputer/sdk/node".
export type { ImageManifest, ImageStep } from "./image.js";
-export type { SnapshotInfo, CreateSnapshotOpts } from "./snapshot.js";
+export type { SnapshotInfo, CreateSnapshotOpts, WaitForReadyOpts } from "./snapshot.js";
diff --git a/sdks/typescript/src/snapshot.ts b/sdks/typescript/src/snapshot.ts
index fdea9b53..7678d22a 100644
--- a/sdks/typescript/src/snapshot.ts
+++ b/sdks/typescript/src/snapshot.ts
@@ -29,6 +29,32 @@ export interface SnapshotOpts {
apiUrl?: string;
}
+export interface WaitForReadyOpts {
+ /** Abort the wait. */
+ signal?: AbortSignal;
+ /** Max time to wait before throwing, in milliseconds. */
+ timeoutMs?: number;
+ /** Initial poll interval in ms (default 1000, backs off to 5000). */
+ pollIntervalMs?: number;
+}
+
+/** Sleep that resolves early (does not reject) when the signal aborts. */
+function sleep(ms: number, signal?: AbortSignal): Promise<void> {
+ return new Promise((resolve) => {
+ if (signal?.aborted) return resolve();
+ const onAbort = () => {
+ clearTimeout(timer);
+ signal?.removeEventListener("abort", onAbort);
+ resolve();
+ };
+ const timer = setTimeout(() => {
+ signal?.removeEventListener("abort", onAbort);
+ resolve();
+ }, ms);
+ signal?.addEventListener("abort", onAbort);
+ });
+}
+
/**
* Manage pre-built snapshots (named, persistent image checkpoints).
*/
@@ -111,6 +137,50 @@ export class Snapshots {
return resp.json();
}
+ /**
+ * Poll a snapshot until its build reaches a terminal state, resolving with
+ * the ready SnapshotInfo. Throws if the build fails or the wait times out.
+ *
+ * Useful when a snapshot was created via the async (non-SSE) endpoint, which
+ * returns a `building` row immediately. The SSE `create()` already waits for
+ * completion via the build-log stream, so this is not needed after it.
+ *
+ * Note: a still-building snapshot is not yet mirrored to the read store, so
+ * `get()` 404s until it reaches a terminal state. We treat that 404 as
+ * "still building" and keep polling; `failed` is mirrored, so it surfaces as
+ * a thrown error rather than a poll-to-timeout.
+ */
+ async waitUntilReady(name: string, opts: WaitForReadyOpts = {}): Promise<SnapshotInfo> {
+ const deadline = opts.timeoutMs != null ? Date.now() + opts.timeoutMs : null;
+ let delay = opts.pollIntervalMs ?? 1000;
+ const maxDelay = 5000;
+
+ for (;;) {
+ if (opts.signal?.aborted) {
+ throw new Error(`waitUntilReady aborted for snapshot ${name}`);
+ }
+ if (deadline != null && Date.now() >= deadline) {
+ throw new Error(`Snapshot ${name} not ready after ${opts.timeoutMs}ms`);
+ }
+
+ const resp = await fetch(`${this.apiUrl}/snapshots/${encodeURIComponent(name)}`, {
+ headers: this.headers,
+ });
+ if (resp.ok) {
+ const snap = (await resp.json()) as SnapshotInfo;
+ if (snap.status === "ready") return snap;
+ if (snap.status === "failed") throw new Error(`Snapshot ${name} build failed`);
+ // any other status (e.g. "building") → keep polling
+ } else if (resp.status !== 404) {
+ // 404 = not yet mirrored (still building); anything else is a real error
+ throw new Error(`Failed to get snapshot ${name}: ${resp.status}`);
+ }
+
+ await sleep(delay, opts.signal);
+ delay = Math.min(delay * 2, maxDelay);
+ }
+ }
+
/**
* Delete a named snapshot.
*/