Skip to content

An open-source, faster Devin alternative

TypeScript

support per-org configurable workspace disk size (up to 256GB) (#127)

Mohamed Habib1750baa36087
diff --git a/docs/sandboxes/overview.mdx b/docs/sandboxes/overview.mdx
index aa5fb778..ebf34c41 100644
--- a/docs/sandboxes/overview.mdx
+++ b/docs/sandboxes/overview.mdx
@@ -37,6 +37,7 @@ const sandbox = await Sandbox.create({
timeout: 600,
cpuCount: 2,
memoryMB: 1024,
+ diskMB: 20480, // 20GB workspace (default; larger sizes in closed beta)
envs: { NODE_ENV: "production" },
metadata: { project: "my-app" },
});
@@ -46,6 +47,7 @@ const sandbox = await Sandbox.create({
sandbox = await Sandbox.create(
template="my-custom-template",
timeout=600,
+ disk_mb=20480, # 20GB workspace (default; larger sizes in closed beta)
envs={"NODE_ENV": "production"},
metadata={"project": "my-app"},
)
@@ -60,6 +62,7 @@ curl -X POST https://app.opencomputer.dev/api/sandboxes \
"timeout": 600,
"cpuCount": 2,
"memoryMB": 1024,
+ "diskMB": 20480,
"envs": {"NODE_ENV": "production"},
"metadata": {"project": "my-app"}
}'
@@ -77,6 +80,7 @@ curl -X POST https://app.opencomputer.dev/api/sandboxes \
| `metadata` | object | — | Arbitrary key-value pairs stored with the sandbox |
| `cpuCount` | number | — | CPU cores. TypeScript and HTTP API only |
| `memoryMB` | number | — | Memory in MB. TypeScript and HTTP API only |
+| `diskMB` | number | `20480` | Workspace disk size in MB (20GB–256GB). See disk sizing note below. |
| `secretStore` | string | — | Secret store name — resolves encrypted secrets and egress allowlist |
| `image` | Image | — | Declarative image definition (see [Templates](/sandboxes/templates)) |
| `snapshot` | string | — | Name of a pre-built snapshot for instant boot |
@@ -87,6 +91,15 @@ curl -X POST https://app.opencomputer.dev/api/sandboxes \
`cpuCount`, `memoryMB`, and `secretStore` are not available in the Python SDK. Use the [HTTP API](/reference/api#sandbox-lifecycle) directly for custom resources from Python.
</Note>
+<Info>
+ **Disk sizing (closed beta).** Every sandbox ships with a 20GB workspace on
+ `/home/sandbox`. You can request up to 256GB via `diskMB`; any GB above the
+ 20GB baseline is metered per-second at a rate comparable to AWS EBS gp3.
+ Larger disk limits are gated per-organization during the beta — [book a
+ call](https://cal.com/team/digger/opencomputer-founder-chat) to have your
+ org's ceiling raised.
+</Info>
+
## Connecting to an Existing Sandbox
<CodeGroup>
diff --git a/internal/api/sandbox.go b/internal/api/sandbox.go
index 85690e64..84acd559 100644
--- a/internal/api/sandbox.go
+++ b/internal/api/sandbox.go
@@ -38,8 +38,10 @@ func (s *Server) createSandbox(c echo.Context) error {
// Check org quota and plan enforcement
orgID, hasOrg := auth.GetOrgID(c)
+ var org *db.Org
if hasOrg && s.store != nil {
- org, err := s.store.GetOrg(ctx, orgID)
+ var err error
+ org, err = s.store.GetOrg(ctx, orgID)
if err == nil {
// Concurrent sandbox limit
count, err := s.store.CountActiveSandboxes(ctx, orgID)
@@ -65,6 +67,37 @@ func (s *Server) createSandbox(c echo.Context) error {
}
}
+ // Disk size validation
+ if cfg.DiskMB == 0 {
+ cfg.DiskMB = 20480 // default 20GB
+ }
+ if cfg.DiskMB < 20480 {
+ return c.JSON(http.StatusBadRequest, map[string]string{
+ "error": "diskMB must be at least 20480 (20GB)",
+ })
+ }
+ if cfg.DiskMB > 262144 {
+ return c.JSON(http.StatusBadRequest, map[string]string{
+ "error": "diskMB cannot exceed 262144 (256GB)",
+ })
+ }
+ if org != nil {
+ if org.Plan == "free" && cfg.DiskMB > 20480 {
+ return c.JSON(http.StatusPaymentRequired, map[string]string{
+ "error": "upgrade to pro for larger disk sizes",
+ })
+ }
+ maxDisk := org.MaxDiskMB
+ if maxDisk == 0 {
+ maxDisk = 20480
+ }
+ if cfg.DiskMB > maxDisk {
+ return c.JSON(http.StatusForbidden, map[string]string{
+ "error": fmt.Sprintf("disk size %dMB exceeds org limit of %dMB", cfg.DiskMB, maxDisk),
+ })
+ }
+ }
+
// Declarative image or named snapshot → resolve to checkpoint and use createFromCheckpoint flow
if len(cfg.ImageManifest) > 0 || cfg.Snapshot != "" {
if !hasOrg {
@@ -410,6 +443,7 @@ func (s *Server) createSandboxRemote(c echo.Context, ctx context.Context, cfg ty
EgressAllowlist: cfg.EgressAllowlist,
SecretAllowedHosts: flattenSecretAllowedHosts(cfg.SecretAllowedHosts),
SecretEnvs: cfg.SecretEnvs,
+ DiskMb: int32(cfg.DiskMB),
})
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]string{
diff --git a/internal/db/migrations/019_org_max_disk_mb.down.sql b/internal/db/migrations/019_org_max_disk_mb.down.sql
new file mode 100644
index 00000000..b28fe538
--- /dev/null
+++ b/internal/db/migrations/019_org_max_disk_mb.down.sql
@@ -0,0 +1 @@
+ALTER TABLE orgs DROP COLUMN IF EXISTS max_disk_mb;
diff --git a/internal/db/migrations/019_org_max_disk_mb.up.sql b/internal/db/migrations/019_org_max_disk_mb.up.sql
new file mode 100644
index 00000000..97abc160
--- /dev/null
+++ b/internal/db/migrations/019_org_max_disk_mb.up.sql
@@ -0,0 +1 @@
+ALTER TABLE orgs ADD COLUMN max_disk_mb INTEGER NOT NULL DEFAULT 20480;
diff --git a/internal/db/store.go b/internal/db/store.go
index d08c879a..bf9ad948 100644
--- a/internal/db/store.go
+++ b/internal/db/store.go
@@ -139,6 +139,7 @@ type Org struct {
Plan string `json:"plan"`
MaxConcurrentSandboxes int `json:"maxConcurrentSandboxes"`
MaxSandboxTimeoutSec int `json:"maxSandboxTimeoutSec"`
+ MaxDiskMB int `json:"maxDiskMB"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
@@ -165,7 +166,7 @@ type Org struct {
}
// orgColumns is the list of columns returned by all Org queries.
-const orgColumns = `id, name, slug, plan, max_concurrent_sandboxes, max_sandbox_timeout_sec, created_at, updated_at,
+const orgColumns = `id, name, slug, plan, max_concurrent_sandboxes, max_sandbox_timeout_sec, max_disk_mb, created_at, updated_at,
custom_domain, cf_hostname_id, domain_verification_status, domain_ssl_status,
verification_txt_name, verification_txt_value, ssl_txt_name, ssl_txt_value,
workos_org_id, is_personal, owner_user_id, credit_balance_cents,
@@ -176,7 +177,7 @@ func scanOrg(row pgx.Row) (*Org, error) {
org := &Org{}
err := row.Scan(
&org.ID, &org.Name, &org.Slug, &org.Plan, &org.MaxConcurrentSandboxes,
- &org.MaxSandboxTimeoutSec, &org.CreatedAt, &org.UpdatedAt,
+ &org.MaxSandboxTimeoutSec, &org.MaxDiskMB, &org.CreatedAt, &org.UpdatedAt,
&org.CustomDomain, &org.CFHostnameID, &org.DomainVerificationStatus, &org.DomainSSLStatus,
&org.VerificationTxtName, &org.VerificationTxtValue, &org.SSLTxtName, &org.SSLTxtValue,
&org.WorkOSOrgID, &org.IsPersonal, &org.OwnerUserID, &org.CreditBalanceCents,
diff --git a/internal/qemu/manager.go b/internal/qemu/manager.go
index 5a96673b..f8b114fa 100644
--- a/internal/qemu/manager.go
+++ b/internal/qemu/manager.go
@@ -547,6 +547,19 @@ func (m *Manager) createFromGolden(ctx context.Context, cfg types.SandboxConfig,
os.RemoveAll(sandboxDir)
return nil, fmt.Errorf("create workspace: %w", err)
}
+
+ // Resize workspace if requested size exceeds default (golden geometry)
+ requestedDiskMB := cfg.DiskMB
+ if requestedDiskMB <= 0 {
+ requestedDiskMB = m.cfg.DefaultDiskMB
+ }
+ if requestedDiskMB > diskMB {
+ if err := ResizeWorkspace(workspacePath, requestedDiskMB); err != nil {
+ os.RemoveAll(sandboxDir)
+ return nil, fmt.Errorf("resize workspace: %w", err)
+ }
+ }
+
log.Printf("qemu: golden-create %s: rootfs+workspace ready (%dms)", id, time.Since(t0).Milliseconds())
// Allocate network
@@ -721,6 +734,33 @@ func (m *Manager) createFromGolden(ctx context.Context, cfg types.SandboxConfig,
vm.agent = agentClient
log.Printf("qemu: golden-create %s: agent connected (%dms)", id, time.Since(t0).Milliseconds())
+ // If we resized the workspace qcow2 before launch, notify QEMU via QMP
+ // block_resize so virtio-blk fires a capacity-change event to the guest.
+ // Without this, the guest kernel still sees the golden-snapshot-captured
+ // 20GB geometry even though the backing file is larger.
+ if requestedDiskMB > diskMB {
+ newSizeBytes := int64(requestedDiskMB) * 1024 * 1024
+ devs, qbErr := qmpClient.QueryBlock()
+ if qbErr != nil {
+ log.Printf("qemu: golden-create %s: query-block failed: %v", id, qbErr)
+ } else {
+ var devID string
+ for _, d := range devs {
+ if d.Inserted.File == workspacePath {
+ devID = d.Device
+ break
+ }
+ }
+ if devID == "" {
+ log.Printf("qemu: golden-create %s: workspace device not found in query-block", id)
+ } else if err := qmpClient.BlockResize(devID, newSizeBytes); err != nil {
+ log.Printf("qemu: golden-create %s: block_resize failed: %v", id, err)
+ } else {
+ log.Printf("qemu: golden-create %s: block_resize %s → %dMB", id, devID, requestedDiskMB)
+ }
+ }
+ }
+
// Patch network inside the guest — the snapshot had the golden VM's IP
if err := patchGuestNetwork(context.Background(), agentClient, netCfg); err != nil {
log.Printf("qemu: golden-create %s: network patch failed: %v", id, err)
@@ -744,6 +784,7 @@ func (m *Manager) createFromGolden(ctx context.Context, cfg types.SandboxConfig,
"echo 3 > /proc/sys/vm/drop_caches",
"echo 3 > /proc/sys/vm/drop_caches",
"mount /dev/vdb /home/sandbox 2>/dev/null || true",
+ "resize2fs /dev/vdb 2>/dev/null || true",
"chown 1000:1000 /home/sandbox",
}, " && ")},
RunAsRoot: true,
@@ -994,7 +1035,10 @@ func (m *Manager) Create(ctx context.Context, cfg types.SandboxConfig) (*types.S
return nil, fmt.Errorf("prepare rootfs: %w", err)
}
- diskMB := m.cfg.DefaultDiskMB
+ diskMB := cfg.DiskMB
+ if diskMB <= 0 {
+ diskMB = m.cfg.DefaultDiskMB
+ }
if err := CreateWorkspace(workspacePath, diskMB); err != nil {
os.RemoveAll(sandboxDir)
return nil, fmt.Errorf("create workspace: %w", err)
diff --git a/internal/qemu/qmp.go b/internal/qemu/qmp.go
index ab9760cf..ad710fd8 100644
--- a/internal/qemu/qmp.go
+++ b/internal/qemu/qmp.go
@@ -140,6 +140,41 @@ func (q *QMPClient) execute(cmd qmpCommand, timeout time.Duration) (*qmpResponse
}
}
+// QMPBlockDevice represents an entry in the query-block response.
+type QMPBlockDevice struct {
+ Device string `json:"device"`
+ Inserted struct {
+ File string `json:"file"`
+ } `json:"inserted"`
+}
+
+// QueryBlock returns the list of block devices attached to the VM.
+func (q *QMPClient) QueryBlock() ([]QMPBlockDevice, error) {
+ resp, err := q.execute(qmpCommand{Execute: "query-block"}, 10*time.Second)
+ if err != nil {
+ return nil, err
+ }
+ var devs []QMPBlockDevice
+ if err := json.Unmarshal(resp.Return, &devs); err != nil {
+ return nil, fmt.Errorf("parse query-block: %w", err)
+ }
+ return devs, nil
+}
+
+// BlockResize notifies QEMU that the backing image for `device` has been
+// resized to `sizeBytes`. QEMU fires a virtio-blk capacity change event;
+// the guest kernel picks up the new size on /dev/vdX.
+func (q *QMPClient) BlockResize(device string, sizeBytes int64) error {
+ _, err := q.execute(qmpCommand{
+ Execute: "block_resize",
+ Arguments: map[string]interface{}{
+ "device": device,
+ "size": sizeBytes,
+ },
+ }, 30*time.Second)
+ return err
+}
+
// Stop pauses the VM (equivalent to pressing the pause button).
func (q *QMPClient) Stop() error {
_, err := q.execute(qmpCommand{Execute: "stop"}, 10*time.Second)
diff --git a/internal/qemu/rootfs.go b/internal/qemu/rootfs.go
index 809c946d..e9e131a7 100644
--- a/internal/qemu/rootfs.go
+++ b/internal/qemu/rootfs.go
@@ -121,6 +121,16 @@ func CreateWorkspace(path string, sizeMB int, uuid ...string) error {
return nil
}
+// ResizeWorkspace expands a qcow2 workspace image to the target size.
+// Must be called BEFORE QEMU attaches the disk.
+func ResizeWorkspace(path string, targetMB int) error {
+ cmd := exec.Command("qemu-img", "resize", path, fmt.Sprintf("%dM", targetMB))
+ if out, err := cmd.CombinedOutput(); err != nil {
+ return fmt.Errorf("qemu-img resize: %w (%s)", err, strings.TrimSpace(string(out)))
+ }
+ return nil
+}
+
// getWorkspaceUUID extracts the ext4 filesystem UUID from a qcow2 workspace image.
// Converts to raw, runs tune2fs, and parses the UUID line.
func getWorkspaceUUID(qcow2Path string) (string, error) {
diff --git a/internal/worker/grpc_server.go b/internal/worker/grpc_server.go
index e7332645..b8b4963a 100644
--- a/internal/worker/grpc_server.go
+++ b/internal/worker/grpc_server.go
@@ -136,6 +136,7 @@ func (s *GRPCServer) CreateSandbox(ctx context.Context, req *pb.CreateSandboxReq
EgressAllowlist: req.EgressAllowlist,
SecretAllowedHosts: parseSecretAllowedHosts(req.SecretAllowedHosts),
SecretEnvs: req.SecretEnvs,
+ DiskMB: int(req.DiskMb),
}
// Warm fork: if checkpoint_id is set, fork from the local checkpoint cache.
diff --git a/pkg/types/sandbox.go b/pkg/types/sandbox.go
index 62c64a93..f72d77bd 100644
--- a/pkg/types/sandbox.go
+++ b/pkg/types/sandbox.go
@@ -45,6 +45,7 @@ type SandboxConfig struct {
Timeout int `json:"timeout,omitempty"` // seconds, default 300
CpuCount int `json:"cpuCount,omitempty"` // default 1
MemoryMB int `json:"memoryMB,omitempty"` // default 256
+ DiskMB int `json:"diskMB,omitempty"` // workspace disk in MB (default 20480)
Envs map[string]string `json:"envs,omitempty"`
Port int `json:"port,omitempty"` // container port to expose via subdomain (default 80)
NetworkEnabled bool `json:"networkEnabled,omitempty"`
diff --git a/proto/worker/worker.pb.go b/proto/worker/worker.pb.go
index 86bc6fa4..17c757be 100644
--- a/proto/worker/worker.pb.go
+++ b/proto/worker/worker.pb.go
@@ -91,6 +91,7 @@ type CreateSandboxRequest struct {
// Env vars resolved from a SecretStore. Sealed by the worker's secrets proxy
// before injection into the VM. Disjoint from `envs` (which is plaintext).
SecretEnvs map[string]string `protobuf:"bytes,15,rep,name=secret_envs,json=secretEnvs,proto3" json:"secret_envs,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
+ DiskMb int32 `protobuf:"varint,16,opt,name=disk_mb,json=diskMb,proto3" json:"disk_mb,omitempty"` // workspace disk size in MB (0 = default 20GB)
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -230,6 +231,13 @@ func (x *CreateSandboxRequest) GetSecretEnvs() map[string]string {
return nil
}
+func (x *CreateSandboxRequest) GetDiskMb() int32 {
+ if x != nil {
+ return x.DiskMb
+ }
+ return 0
+}
+
type CreateSandboxResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
SandboxId string `protobuf:"bytes,1,opt,name=sandbox_id,json=sandboxId,proto3" json:"sandbox_id,omitempty"`
@@ -3037,7 +3045,7 @@ var File_proto_worker_worker_proto protoreflect.FileDescriptor
const file_proto_worker_worker_proto_rawDesc = "" +
"\n" +
- "\x19proto/worker/worker.proto\x12\x06worker\"\xe7\x06\n" +
+ "\x19proto/worker/worker.proto\x12\x06worker\"\x80\a\n" +
"\x14CreateSandboxRequest\x12\x1a\n" +
"\btemplate\x18\x01 \x01(\tR\btemplate\x12\x18\n" +
"\atimeout\x18\x02 \x01(\x05R\atimeout\x12:\n" +
@@ -3056,7 +3064,8 @@ const file_proto_worker_worker_proto_rawDesc = "" +
"\x10egress_allowlist\x18\r \x03(\tR\x0fegressAllowlist\x12f\n" +
"\x14secret_allowed_hosts\x18\x0e \x03(\v24.worker.CreateSandboxRequest.SecretAllowedHostsEntryR\x12secretAllowedHosts\x12M\n" +
"\vsecret_envs\x18\x0f \x03(\v2,.worker.CreateSandboxRequest.SecretEnvsEntryR\n" +
- "secretEnvs\x1a7\n" +
+ "secretEnvs\x12\x17\n" +
+ "\adisk_mb\x18\x10 \x01(\x05R\x06diskMb\x1a7\n" +
"\tEnvsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\x1aE\n" +
diff --git a/proto/worker/worker.proto b/proto/worker/worker.proto
index 1254347d..f680201c 100644
--- a/proto/worker/worker.proto
+++ b/proto/worker/worker.proto
@@ -67,6 +67,7 @@ message CreateSandboxRequest {
// Env vars resolved from a SecretStore. Sealed by the worker's secrets proxy
// before injection into the VM. Disjoint from `envs` (which is plaintext).
map<string, string> secret_envs = 15;
+ int32 disk_mb = 16; // workspace disk size in MB (0 = default 20GB)
}
message CreateSandboxResponse {
diff --git a/sdks/python/examples/test_disk_size.py b/sdks/python/examples/test_disk_size.py
new file mode 100644
index 00000000..c4bf0ff2
--- /dev/null
+++ b/sdks/python/examples/test_disk_size.py
@@ -0,0 +1,102 @@
+#!/usr/bin/env python3
+"""
+Disk Size Test
+
+Verifies the `disk_mb` sandbox creation parameter:
+ 1. Default (no arg) → 20GB workspace
+ 2. Explicit 20GB → 20GB workspace
+ 3. Explicit 30GB → 30GB workspace (requires org `max_disk_mb` >= 30720)
+ 4. Below minimum → rejected with 400
+
+Larger disk sizes are in closed beta — contact us to raise your org's
+max_disk_mb ceiling: https://cal.com/team/digger/opencomputer-founder-chat
+
+Usage:
+ python examples/test_disk_size.py
+
+Environment:
+ OPENCOMPUTER_API_URL (default: http://localhost:8080)
+ OPENCOMPUTER_API_KEY (default: test-key)
+"""
+
+import asyncio
+import os
+import sys
+
+sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
+from opencomputer import Sandbox
+
+API_URL = os.environ.get("OPENCOMPUTER_API_URL", "http://localhost:8080")
+API_KEY = os.environ.get("OPENCOMPUTER_API_KEY", "test-key")
+
+GREEN = "\033[32m"
+RED = "\033[31m"
+BOLD = "\033[1m"
+DIM = "\033[2m"
+RESET = "\033[0m"
+
+passed = 0
+failed = 0
+
+
+def green(msg: str) -> None:
+ print(f"{GREEN}✓ {msg}{RESET}")
+
+
+def red(msg: str) -> None:
+ print(f"{RED}✗ {msg}{RESET}")
+
+
+def bold(msg: str) -> None:
+ print(f"{BOLD}{msg}{RESET}")
+
+
+def dim(msg: str) -> None:
+ print(f"{DIM} {msg}{RESET}")
+
+
+async def run_case(label: str, disk_mb: int | None, expect_size: str | None, expect_reject: bool = False) -> None:
+ global passed, failed
+ bold(f"\n{label}")
+ kwargs = dict(api_url=API_URL, api_key=API_KEY, timeout=120)
+ if disk_mb is not None:
+ kwargs["disk_mb"] = disk_mb
+ try:
+ async with await Sandbox.create(**kwargs) as sb:
+ dim(f"created {sb.sandbox_id}")
+ r = await sb.exec.run("df -h /home/sandbox | tail -1")
+ dim(f"df: {r.stdout.strip()}")
+ if expect_reject:
+ red("expected rejection but sandbox was created")
+ failed += 1
+ elif expect_size and expect_size in r.stdout:
+ green(f"workspace reports {expect_size}")
+ passed += 1
+ else:
+ red(f"expected {expect_size} in df output")
+ failed += 1
+ except Exception as e:
+ if expect_reject:
+ green(f"rejected as expected ({str(e).splitlines()[0]})")
+ passed += 1
+ else:
+ red(f"unexpected error: {e}")
+ failed += 1
+
+
+async def main() -> None:
+ bold("OpenComputer SDK — disk size test")
+ dim(f"API: {API_URL}")
+
+ await run_case("default (no disk_mb)", None, "20G")
+ await run_case("explicit 20GB", 20480, "20G")
+ await run_case("30GB", 30720, "30G")
+ await run_case("below minimum (8GB)", 8192, None, expect_reject=True)
+
+ print()
+ bold(f"Results: {passed} passed, {failed} failed")
+ sys.exit(1 if failed > 0 else 0)
+
+
+if __name__ == "__main__":
+ asyncio.run(main())
diff --git a/sdks/python/opencomputer/sandbox.py b/sdks/python/opencomputer/sandbox.py
index 5444e130..6983f05a 100644
--- a/sdks/python/opencomputer/sandbox.py
+++ b/sdks/python/opencomputer/sandbox.py
@@ -39,6 +39,7 @@ class Sandbox:
api_url: str | None = None,
envs: dict[str, str] | None = None,
metadata: dict[str, str] | None = None,
+ disk_mb: int | None = None,
secret_store: str | None = None,
image: Image | None = None,
snapshot: str | None = None,
@@ -53,6 +54,11 @@ class Sandbox:
api_url: API URL (or OPENCOMPUTER_API_URL env var).
envs: Environment variables to inject. Overrides store secrets.
metadata: Custom metadata key-value pairs.
+ disk_mb: Workspace disk size in MB (default 20480 = 20GB). Any
+ additional GB above 20GB is metered at a per-second rate
+ comparable to EBS gp3. Closed beta: requests above 20GB
+ require the org's ``max_disk_mb`` to be raised. Contact us:
+ https://cal.com/team/digger/opencomputer-founder-chat
secret_store: Secret store name — resolves encrypted secrets
and egress allowlist.
image: Declarative Image definition. The server builds and caches it as a checkpoint.
@@ -88,6 +94,8 @@ class Sandbox:
body["envs"] = envs
if metadata:
body["metadata"] = metadata
+ if disk_mb is not None:
+ body["diskMB"] = disk_mb
if secret_store:
body["secretStore"] = secret_store
if image is not None:
diff --git a/sdks/python/pyproject.toml b/sdks/python/pyproject.toml
index ca417555..e4cc8f41 100644
--- a/sdks/python/pyproject.toml
+++ b/sdks/python/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "opencomputer-sdk"
-version = "0.5.2"
+version = "0.5.3"
description = "Python SDK for OpenComputer - cloud sandbox platform"
readme = "README.md"
requires-python = ">=3.10"
diff --git a/sdks/typescript/examples/test-disk-size.ts b/sdks/typescript/examples/test-disk-size.ts
new file mode 100644
index 00000000..26053bb6
--- /dev/null
+++ b/sdks/typescript/examples/test-disk-size.ts
@@ -0,0 +1,87 @@
+/**
+ * Disk Size Test
+ *
+ * Verifies the `diskMB` sandbox creation parameter:
+ * 1. Default (no arg) → 20GB workspace
+ * 2. Explicit 20GB → 20GB workspace
+ * 3. Explicit 30GB → 30GB workspace (requires org `max_disk_mb` ≥ 30720)
+ * 4. Below minimum → rejected with 400
+ *
+ * Larger disk sizes are in closed beta — contact us to raise your org's
+ * max_disk_mb ceiling: https://cal.com/team/digger/opencomputer-founder-chat
+ *
+ * Usage:
+ * npx tsx examples/test-disk-size.ts
+ *
+ * Environment:
+ * OPENCOMPUTER_API_URL (default: http://localhost:8080)
+ * OPENCOMPUTER_API_KEY (default: test-key)
+ */
+
+import { Sandbox } from "../src/index";
+
+const API_URL = process.env.OPENCOMPUTER_API_URL ?? "http://localhost:8080";
+const API_KEY = process.env.OPENCOMPUTER_API_KEY ?? "test-key";
+
+function green(msg: string) { console.log(`\x1b[32m✓ ${msg}\x1b[0m`); }
+function red(msg: string) { console.log(`\x1b[31m✗ ${msg}\x1b[0m`); }
+function bold(msg: string) { console.log(`\x1b[1m${msg}\x1b[0m`); }
+function dim(msg: string) { console.log(`\x1b[2m ${msg}\x1b[0m`); }
+
+let passed = 0;
+let failed = 0;
+
+async function runCase(
+ label: string,
+ diskMB: number | undefined,
+ expect: { size?: string; reject?: boolean },
+) {
+ bold(`\n${label}`);
+ try {
+ const sb = await Sandbox.create({
+ apiUrl: API_URL,
+ apiKey: API_KEY,
+ timeout: 120,
+ ...(diskMB !== undefined ? { diskMB } : {}),
+ });
+ dim(`created ${sb.sandboxId}`);
+ try {
+ const r = await sb.exec.run("df -h /home/sandbox | tail -1");
+ dim(`df: ${r.stdout.trim()}`);
+ if (expect.reject) {
+ red(`expected rejection but sandbox was created`);
+ failed++;
+ } else if (expect.size && r.stdout.includes(expect.size)) {
+ green(`workspace reports ${expect.size}`);
+ passed++;
+ } else {
+ red(`expected ${expect.size} in df output`);
+ failed++;
+ }
+ } finally {
+ await sb.kill();
+ }
+ } catch (e: any) {
+ if (expect.reject) {
+ green(`rejected as expected (${e.message.split("\n")[0]})`);
+ passed++;
+ } else {
+ red(`unexpected error: ${e.message}`);
+ failed++;
+ }
+ }
+}
+
+(async () => {
+ bold("OpenComputer SDK — disk size test");
+ dim(`API: ${API_URL}`);
+
+ await runCase("default (no diskMB)", undefined, { size: "20G" });
+ await runCase("explicit 20GB", 20480, { size: "20G" });
+ await runCase("30GB", 30720, { size: "30G" });
+ await runCase("below minimum (8GB)", 8192, { reject: true });
+
+ console.log();
+ bold(`Results: ${passed} passed, ${failed} failed`);
+ process.exit(failed > 0 ? 1 : 0);
+})();
diff --git a/sdks/typescript/package.json b/sdks/typescript/package.json
index 91c00cc9..a5116e25 100644
--- a/sdks/typescript/package.json
+++ b/sdks/typescript/package.json
@@ -1,6 +1,6 @@
{
"name": "@opencomputer/sdk",
- "version": "0.5.14",
+ "version": "0.5.15",
"description": "TypeScript SDK for OpenComputer - cloud sandbox platform",
"type": "module",
"main": "dist/index.js",
diff --git a/sdks/typescript/src/sandbox.ts b/sdks/typescript/src/sandbox.ts
index 00eec816..d9c49838 100644
--- a/sdks/typescript/src/sandbox.ts
+++ b/sdks/typescript/src/sandbox.ts
@@ -20,6 +20,14 @@ export interface SandboxOpts {
metadata?: Record<string, string>;
cpuCount?: number;
memoryMB?: number;
+ /**
+ * Workspace disk size in MB (default 20480 = 20GB). Any additional GB above
+ * 20GB is metered at a per-second rate comparable to EBS gp3.
+ *
+ * Closed beta: requests above 20GB require the org's `max_disk_mb` to be
+ * raised. Contact us: https://cal.com/team/digger/opencomputer-founder-chat
+ */
+ diskMB?: number;
/** Secret store name — resolves encrypted secrets and egress allowlist. */
secretStore?: string;
/** Declarative image definition. The server builds and caches it as a checkpoint. */
@@ -140,6 +148,7 @@ export class Sandbox {
if (opts.metadata) body.metadata = opts.metadata;
if (opts.cpuCount != null) body.cpuCount = opts.cpuCount;
if (opts.memoryMB != null) body.memoryMB = opts.memoryMB;
+ if (opts.diskMB != null) body.diskMB = opts.diskMB;
if (opts.secretStore) body.secretStore = opts.secretStore;
if (opts.image) body.image = opts.image.toJSON();
if (opts.snapshot) body.snapshot = opts.snapshot;