From 599f2dd5651888fa59687d003eb068226422ff61 Mon Sep 17 00:00:00 2001 From: Farhan Helmy <59960562+farhan-helmy@users.noreply.github.com> Date: Mon, 16 Nov 2026 00:20:35 +0800 Subject: [PATCH] fix(cli): retire --gvisor and --cpu, correct the credential path (0.13.0) BoxCompute 0.51.1 retired gVisor container sandboxes and refuses `vmSandbox: false`, so `bxc sandbox start --gvisor` and `--cpu` (which implied it) always failed at the server. Help and the README still showed `--cpu 2` and `--gvisor --cpu 2`, and the bundled boxcompute-sandbox skill told coding agents to use `--gvisor` for a container sandbox. The options now fail before any request with a message naming the change; help, README, docs and the skill no longer offer them. The README also put the credential under ~/.config/boxcompute, but the CLI uses ~/boxcompute, or $XDG_CONFIG_HOME/boxcompute when that is set. 0.12.1 was never published to npm; its preview help fix ships here. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 27 +++++++++++++ README.md | 13 ++----- docs/vm-sandbox-beta.md | 13 +++---- package.json | 2 +- skills/boxcompute-sandbox/SKILL.md | 5 +-- src/cli.ts | 29 ++++---------- src/sdk.ts | 19 ++------- test/cli.test.ts | 62 +++++------------------------- test/sdk.test.ts | 12 +----- test/vm-files.test.ts | 21 ---------- 10 files changed, 61 insertions(+), 142 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af078ba..869cd4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,35 @@ This file records user-visible changes to the BoxCompute CLI. GitHub Releases use the same notes and bind them to the exact source commit. +## [0.13.0] - 2026-11-16 + +The retired gVisor options are gone, and the CLI's own guide says where it +keeps its credential. + +### CLI users + +- `bxc sandbox start` no longer offers `--gvisor` or `--cpu`. BoxCompute + retired gVisor container sandboxes in October and refuses `vmSandbox: + false`, so both options already failed at the server. They now fail before + any request, naming the change; choose a VM size with `--size small|large`. + Help, the README and the bundled `boxcompute-sandbox` skill no longer show + them, so coding agents stop trying them. +- The README said the credential lives under `~/.config/boxcompute`. The CLI + uses `~/boxcompute`, or `$XDG_CONFIG_HOME/boxcompute` when that is set; no + files move. +- Includes 0.12.1, which was never published to npm: help says a VM can have + up to three previews. +- Update with `bxc update` or `npm install --global @boxcompute/cli@latest`. + Scripts that pass `--gvisor` or `--cpu` must drop them. + +### Security + +- No change to authentication or credential storage. + ## [0.12.1] - 2026-11-06 +Not published to npm; its change ships in 0.13.0. + ### CLI users - `bxc sandbox preview` help and the README no longer say a VM has at most one diff --git a/README.md b/README.md index 8604db8..8bea3ba 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ bxc login ``` `bxc login` opens BoxCompute in your browser. After you approve the device, the -CLI stores its credential outside the project under `~/.config/boxcompute` with +CLI stores its credential outside the project under `~/boxcompute` (or +`$XDG_CONFIG_HOME/boxcompute` when that is set) with restrictive file permissions. The credential is never included in the agent skill. @@ -47,8 +48,6 @@ bxc doctor bxc workspaces bxc sandboxes bxc sandbox start WORKSPACE_ID -# Optionally request 0.1–4 scheduler CPUs for this sandbox. -bxc sandbox start WORKSPACE_ID --cpu 2 # Use the returned sandbox instance ID for later commands. bxc sandbox logs SANDBOX_ID --source execute bxc sandbox exec SANDBOX_ID -- python -m pytest @@ -56,9 +55,6 @@ bxc sandbox exec SANDBOX_ID -- python -m pytest bxc sandbox expose SANDBOX_ID --port 3000 ``` -When `--cpu` is omitted, BoxCompute uses the server's default scheduler CPU -allocation. - ### VM sandboxes Any authenticated account can create a VM; VM is the default runtime, so a @@ -76,8 +72,6 @@ bxc --json sandbox status SANDBOX_ID bxc --json sandbox resume SANDBOX_ID # Stop a running VM now; its disk and files stay for the next resume. bxc --json sandbox stop SANDBOX_ID -# Container sandbox instead (supports --cpu); explicit gVisor opt-out. -bxc sandbox start WORKSPACE_ID --gvisor --cpu 2 bxc sandbox upload SANDBOX_ID fixture.txt /workspace/fixture.txt bxc sandbox exec SANDBOX_ID --timeout 10 -- /bin/cat /workspace/fixture.txt bxc sandbox download SANDBOX_ID /workspace/fixture.txt downloaded.txt @@ -88,8 +82,7 @@ See [Test tools in a VM sandbox](docs/vm-sandbox-beta.md) for the CLI and API walkthroughs, retry recovery, and Hermes limitations. VMs default to the `small` profile (0.5 CPU, 1024 MiB memory) and `--size large` selects the 3x profile (1.5 CPU, 3072 MiB memory). Both use a 30 GiB thin-provisioned -workspace. Sizing is VM only: the -gVisor runtime ignores `small` and rejects `large`. VMs have outbound Internet +workspace. VMs have outbound Internet access by default, no automatic lifetime expiry, and no SSH access. A running VM bills until it stops: stop it when done if you will reuse it, or delete it when its files are no longer needed. Uploads are limited to 8 MiB; downloads diff --git a/docs/vm-sandbox-beta.md b/docs/vm-sandbox-beta.md index 7dfa4f2..6a51639 100644 --- a/docs/vm-sandbox-beta.md +++ b/docs/vm-sandbox-beta.md @@ -11,8 +11,8 @@ workloads or always-on services, and running VMs bill until they stop. **CLI support:** CLI 0.4.0 or newer creates VMs by default — `bxc sandbox start` omits the runtime selector and waits up to 180 seconds for `running` — plus `upload` and `download`. Use `--vm --idempotency-key KEY` for an explicit VM -create with your own retry key, `--no-wait` for the receipt only, and -`--gvisor` for a container sandbox instead. CLI 0.5.0 or newer adds `--size +create with your own retry key and `--no-wait` for the receipt only. Every +sandbox is a VM; CLI 0.13.0 removed the retired `--gvisor` and `--cpu` options. CLI 0.5.0 or newer adds `--size small|large` for the VM profile. The [CLI walkthrough](#cli-walkthrough-040-or-newer) uses browser login and the CLI's saved credential. The direct API walkthrough uses a separately loaded account API key; do not extract the CLI's credential. @@ -30,7 +30,7 @@ sizing (`size`) added September 17, 2026. | Capability | Current VM profile | | --- | --- | | Availability | Any authenticated account. No separate VM approval. | -| Selection | Omitted `vmSandbox` selects the VM runtime (the default); `vmSandbox: false` explicitly selects a gVisor container sandbox. Rejected VM requests do not fall back to that path. | +| Selection | Every sandbox is a VM. Omitted `vmSandbox` or `true` creates one; `vmSandbox: false` is refused with `400 INVALID_REQUEST` since gVisor container sandboxes were retired. | | Resources | Sizing is chosen at create with `size`. `small` (default) is 500m CPU (0.5 CPU), 1,024 MiB RAM; `large` is 1,536m CPU (1.5 CPU), 3,072 MiB RAM. Both get a 30 GiB thin-provisioned workspace. | | Lifetime | No automatic expiry. The VM exists until you delete it and bills while it runs. A running VM stops, keeping its files, when you call stop or 30 minutes after its last start, execute, file call or preview request; reads, logs, operation polling and work inside the VM do not count. | | Image | Immutable, server-selected approved minimal Ubuntu image. No arbitrary image override, library profile, or attached volumes. | @@ -245,10 +245,9 @@ generates a new key. Restore any saved sandbox ID from `vm-sandbox-id.txt`. Only `workspaceId`, optional `name` (1–80 trimmed characters), `vmSandbox`, `size` (VM only: `small` or `large`, default `small`), and `blockNetwork` (VM only; omitted means outbound Internet) configure public creation. `small` is -0.5 CPU / 1,024 MiB and `large` is 1.5 CPU / 3,072 MiB. `size` applies to VMs -only: gVisor ignores `small` and rejects `large`. Unknown fields are currently -discarded, not sizing controls. Do not send `image`, `backend`, `cpu` -(container sandboxes only), `memoryMiB`, `workspaceMiB`, `timeoutSeconds`, +0.5 CPU / 1,024 MiB and `large` is 1.5 CPU / 3,072 MiB. Unknown fields are +currently discarded, not sizing controls. Do not send `image`, `backend`, `cpu`, +`memoryMiB`, `workspaceMiB`, `timeoutSeconds`, `libraries`, or `volumes`. An explicit `vmSandbox:true` requires `Idempotency-Key`: 1–255 visible ASCII diff --git a/package.json b/package.json index 10edc1e..f82c1c3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@boxcompute/cli", - "version": "0.12.1", + "version": "0.13.0", "description": "Connect local AI agents to BoxCompute sandboxes", "keywords": [ "boxcompute", diff --git a/skills/boxcompute-sandbox/SKILL.md b/skills/boxcompute-sandbox/SKILL.md index f97ccd0..aca8e9f 100644 --- a/skills/boxcompute-sandbox/SKILL.md +++ b/skills/boxcompute-sandbox/SKILL.md @@ -29,7 +29,7 @@ and waits up to 180 seconds for `state: running`, reporting the sandbox either way. For an explicit VM create with your own retry key, add `--vm --idempotency-key KEY`; reuse the same key, workspace, and optional `--name` on retry, and save the returned ID even when pending. `--no-wait` returns the -creation receipt immediately. Use `--gvisor` for a container sandbox instead. +creation receipt immediately. Every sandbox is a VM: there is no container option. Never change keys to recover a stuck create. With CLI 0.9.0+, use `bxc --json sandbox resume SANDBOX_ID` when the task @@ -49,8 +49,7 @@ logs, analytics, costs and processes running inside the VM do not count. VMs are sized at create with `--size small|large` (default `small`): small is 0.5 CPU / 1024 MiB RAM and large is 1.5 CPU / 3072 MiB RAM, both with a 30 GiB -workspace. Sizing is VM only: gVisor ignores `small` and rejects `large`, and -VM sizing is mutually exclusive with `--cpu`. Use `--size large` only when the +workspace. Use `--size large` only when the task needs more than the default profile; it bills more. VMs have outbound Internet access by default, no SSH, and no automatic lifetime expiry. A running VM bills until it is stopped: stop it when finished if you will reuse it, or diff --git a/src/cli.ts b/src/cli.ts index 0438904..3970b13 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -126,7 +126,6 @@ Examples: $ bxc skill install $ bxc workspaces $ bxc sandbox start WORKSPACE_ID - $ bxc sandbox start WORKSPACE_ID --cpu 2 $ bxc sandbox start WORKSPACE_ID --size large --idempotency-key SAVED_UNIQUE_KEY $ bxc sandbox logs SANDBOX_ID --source execute $ bxc sandbox exec SANDBOX_ID -- python -m pytest @@ -175,16 +174,11 @@ Start options: small = 0.5 CPU / 1024 MiB; large = 1.5 CPU / 3072 MiB --vm Explicitly request a VM sandbox; requires --idempotency-key, reused with the same options on retry - --gvisor Explicitly request a gVisor container sandbox - --cpu CPU gVisor only: scheduler CPU allocation (0.1–4); - implies --gvisor --idempotency-key KEY Required for --vm; reusable for any create --name NAME Optional sandbox name (1–80 trimmed characters) --no-wait Return the creation receipt without waiting - Without --vm or --gvisor, the server's default runtime is selected (VM). - --size is VM only: gVisor ignores small and rejects large. VM sizing is - mutually exclusive with --cpu. + Every sandbox is a VM; --vm only makes that explicit. Start waits up to 180 seconds for a pending sandbox to reach running and reports its state either way. No automatic retries or replacement VMs. Transfers never retry; downloads stop after five minutes and discard partial @@ -625,15 +619,6 @@ export function serviceMappings(tokens: string[]): ServiceMapping[] { return mappings; } -function schedulerCpu(value: string | undefined): number | undefined { - if (value === undefined) return undefined; - const parsed = Number(value); - if (!Number.isFinite(parsed) || parsed < 0.1 || parsed > 4) { - throw new UsageError("--cpu must be a number from 0.1 to 4"); - } - return parsed; -} - function timestamp(value: string | undefined, name: string): string | undefined { if (value === undefined) return undefined; const parsed = new Date(value); @@ -1330,7 +1315,9 @@ export async function runCli(argv: string[], supplied: CliDependencies = {}): Pr return sandbox.state === "running" || (noWait && sandbox.state === "pending") ? 0 : 1; } if (action === "start") { - const cpu = schedulerCpu(option(args, "cpu")); + // Still read, so the refusal names gVisor rather than an unknown option: + // BoxCompute 0.51.1 retired gVisor, and the server refuses `vmSandbox: false`. + const cpu = option(args, "cpu"); const vmSandbox = flag(args, "vm"); const gvisor = flag(args, "gvisor"); const size: SandboxSize = oneOf(option(args, "size"), "--size", ["small", "large"] as const) ?? "small"; @@ -1338,14 +1325,12 @@ export async function runCli(argv: string[], supplied: CliDependencies = {}): Pr const name = option(args, "name"); const noWait = flag(args, "no-wait"); if (args.length) throw new UsageError(`Unknown sandbox start option: ${args[0]}`); - if (vmSandbox && gvisor) throw new UsageError("sandbox start accepts either --vm or --gvisor, not both"); - if (vmSandbox && cpu !== undefined) throw new UsageError("VM sandboxes use a fixed CPU profile; --cpu selects the gVisor runtime"); + if (gvisor || cpu !== undefined) { + throw new UsageError("gVisor sandboxes are retired: every sandbox is a VM. Drop --gvisor and --cpu, and choose a size with --size small|large"); + } if (vmSandbox && !idempotencyKey) throw new UsageError("sandbox start --vm requires --idempotency-key; save and reuse it with the same options on retry"); - if (gvisor && size === "large") throw new UsageError("--size large is VM only; gVisor container sandboxes ignore --size small"); let sandbox = await client.sandboxes.create(buildCreateSandboxRequest(id, { - cpu, vmSandbox, - gvisor: gvisor || cpu !== undefined, size, idempotencyKey, name, diff --git a/src/sdk.ts b/src/sdk.ts index 179b21d..e9488f4 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -18,9 +18,7 @@ export function validateFilePath(path: string): void { } export type SandboxStartInput = { - cpu?: number; vmSandbox?: boolean; - gvisor?: boolean; size?: SandboxSize; idempotencyKey?: string; name?: string; @@ -29,33 +27,24 @@ export type SandboxStartInput = { /** * Validate the create options and build the SDK create request. The runtime * selection rules live here so the CLI never reimplements the v2 contract: - * - `gvisor` selects `vmSandbox: false` (the CLI derives this from `--gvisor` - * or the gVisor-only `--cpu` flag); * - an explicit `vmSandbox` selects `vmSandbox: true` and requires a key; * - otherwise `vmSandbox` is omitted and the server default (VM) applies. - * `cpu` is a gVisor-only scheduler request carried on the create body; the - * public v2 contract keeps `additionalProperties` open for it. + * There is no gVisor opt-out: the server refuses `vmSandbox: false`. */ export function buildCreateSandboxRequest( workspaceId: string, input: SandboxStartInput = {}, ): CreateSandboxRequest & { idempotencyKey?: string } { - if (input.vmSandbox && input.gvisor) throw new Error("VM and gVisor selection are mutually exclusive"); - if (input.vmSandbox && input.cpu !== undefined) throw new Error("VM sandboxes use a fixed CPU profile; --cpu selects the gVisor runtime"); if (input.vmSandbox && !input.idempotencyKey) throw new Error("VM creation requires --idempotency-key; reuse the same key and options on retry"); - if (input.gvisor && input.size === "large") throw new Error("--size large is VM only; gVisor container sandboxes ignore --size small"); if (input.idempotencyKey !== undefined && !/^[\x21-\x7e]{1,255}$/.test(input.idempotencyKey)) { throw new Error("Idempotency key must contain 1–255 visible ASCII characters without spaces"); } const name = input.name?.trim(); if (name !== undefined && (!name || name.length > 80)) throw new Error("Sandbox name must contain 1–80 trimmed characters"); - const body: CreateSandboxRequest & { cpu?: number } = { workspaceId }; - if (input.cpu !== undefined) body.cpu = input.cpu; - if (input.gvisor) body.vmSandbox = false; - else if (input.vmSandbox) body.vmSandbox = true; - // VM sizing only: gVisor uses the default profile and must not receive size. - if (!input.gvisor && input.size !== undefined) body.size = input.size; + const body: CreateSandboxRequest = { workspaceId }; + if (input.vmSandbox) body.vmSandbox = true; + if (input.size !== undefined) body.size = input.size; if (name !== undefined) body.name = name; return { ...body, ...(input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : {}) }; diff --git a/test/cli.test.ts b/test/cli.test.ts index d837642..eb83b03 100644 --- a/test/cli.test.ts +++ b/test/cli.test.ts @@ -193,39 +193,20 @@ describe("bxc CLI", () => { expect(output(io.stdout)).toBe("workspace-one\tDemo\n"); }); - it("sets scheduler CPU when starting a sandbox", async () => { - const connection = { url: "https://app.boxcompute.ai", token: "bc_live_test", tokenFile: "/credential" }; - const bodies: unknown[] = []; + it("refuses the retired gVisor options before calling the server", async () => { const dependencies = { io: streams(), env: {}, - loadConnection: async () => connection, - fetch: (async (_input: string | URL | Request, init?: RequestInit) => { - bodies.push(JSON.parse(String(init?.body))); - return new Response(JSON.stringify({ sandbox: { - id: "sandbox-one", - workspaceId: "workspace-one", - name: "Demo", - state: "running", - runtimeId: "runtime-one", - retainedRuntimeId: null, - image: null, - createdAt: 1, - lastUsedAt: 1, - } }), { status: 201, headers: { "content-type": "application/json" } }); - }) as typeof globalThis.fetch, + loadConnection: async () => ({ url: "https://app.boxcompute.ai", token: "bc_live_test", tokenFile: "/credential" }), + fetch: (async () => { throw new Error("should not fetch"); }) as unknown as typeof globalThis.fetch, }; - - expect(await runCli(["sandbox", "start", "workspace-one", "--cpu", "0.1"], dependencies)).toBe(0); - expect(await runCli(["sandbox", "start", "workspace-one", "--cpu", "4"], dependencies)).toBe(0); - - expect(bodies).toEqual([ - { workspaceId: "workspace-one", cpu: 0.1, vmSandbox: false }, - { workspaceId: "workspace-one", cpu: 4, vmSandbox: false }, - ]); + for (const args of [["--cpu", "2"], ["--gvisor"], ["--gvisor", "--cpu", "0.5"], ["--vm", "--gvisor", "--idempotency-key", "k"]]) { + await expect(runCli(["sandbox", "start", "workspace-one", ...args], dependencies)) + .rejects.toThrow("gVisor sandboxes are retired"); + } }); - it("sends the VM size, defaulting to small, and rejects large on gVisor", async () => { + it("sends the VM size, defaulting to small", async () => { const connection = { url: "https://app.boxcompute.ai", token: "bc_live_test", tokenFile: "/credential" }; const bodies: unknown[] = []; const dependencies = { @@ -269,30 +250,6 @@ describe("bxc CLI", () => { }; await expect(runCli(["sandbox", "start", "workspace-one", "--size", "medium"], rejected)) .rejects.toThrow("--size must be one of: small, large"); - await expect(runCli(["sandbox", "start", "workspace-one", "--gvisor", "--size", "large"], rejected)) - .rejects.toThrow("--size large is VM only"); - await expect(runCli(["sandbox", "start", "workspace-one", "--cpu", "2", "--size", "large"], rejected)) - .rejects.toThrow("--size large is VM only"); - }); - - it("rejects scheduler CPU outside the supported range before calling the server", async () => { - const dependencies = { - io: streams(), - env: {}, - loadConnection: async () => ({ - url: "https://app.boxcompute.ai", - token: "bc_live_test", - tokenFile: "/credential", - }), - fetch: (async () => { throw new Error("should not fetch"); }) as unknown as typeof globalThis.fetch, - }; - - await expect(runCli(["sandbox", "start", "workspace-one", "--cpu", "0.09"], dependencies)) - .rejects.toThrow("--cpu must be a number from 0.1 to 4"); - await expect(runCli(["sandbox", "start", "workspace-one", "--cpu", "4.01"], dependencies)) - .rejects.toThrow("--cpu must be a number from 0.1 to 4"); - await expect(runCli(["sandbox", "start", "workspace-one", "--cpu", "fast"], dependencies)) - .rejects.toThrow("--cpu must be a number from 0.1 to 4"); }); it("reads retained sandbox logs with filters without starting compute", async () => { @@ -479,7 +436,8 @@ describe("bxc CLI", () => { const sandboxIo = streams(); expect(await runCli(["sandbox", "--help"], { io: sandboxIo, env: {} })).toBe(0); const sandboxHelp = output(sandboxIo.stdout); - expect(sandboxHelp).toContain("--cpu CPU"); + expect(sandboxHelp).not.toContain("--cpu"); + expect(sandboxHelp).not.toContain("--gvisor"); expect(sandboxHelp).toContain("--size small|large"); expect(sandboxHelp).toContain("stop SANDBOX_ID"); diff --git a/test/sdk.test.ts b/test/sdk.test.ts index a3cbef1..de11b7d 100644 --- a/test/sdk.test.ts +++ b/test/sdk.test.ts @@ -14,18 +14,11 @@ describe("buildCreateSandboxRequest", () => { expect(buildCreateSandboxRequest("ws_one")).toEqual({ workspaceId: "ws_one" }); }); - it("forwards scheduler CPU and selects gVisor", () => { - expect(buildCreateSandboxRequest("ws_one", { cpu: 0.5, gvisor: true })) - .toEqual({ workspaceId: "ws_one", cpu: 0.5, vmSandbox: false }); - }); - - it("sends VM size and omits it for gVisor", () => { + it("sends VM size", () => { expect(buildCreateSandboxRequest("ws_one", { vmSandbox: true, size: "small", idempotencyKey: "key-one" })) .toEqual({ workspaceId: "ws_one", vmSandbox: true, size: "small", idempotencyKey: "key-one" }); expect(buildCreateSandboxRequest("ws_one", { vmSandbox: true, size: "large", idempotencyKey: "key-two" })) .toEqual({ workspaceId: "ws_one", vmSandbox: true, size: "large", idempotencyKey: "key-two" }); - expect(buildCreateSandboxRequest("ws_one", { gvisor: true, size: "small" })) - .toEqual({ workspaceId: "ws_one", vmSandbox: false }); }); it("rejects invalid keys, names and conflicting runtime options before any request", () => { @@ -33,10 +26,7 @@ describe("buildCreateSandboxRequest", () => { expect(() => buildCreateSandboxRequest("ws_one", { vmSandbox: true, idempotencyKey: key })).toThrow(); } expect(() => buildCreateSandboxRequest("ws_one", { name: " " })).toThrow(); - expect(() => buildCreateSandboxRequest("ws_one", { vmSandbox: true, gvisor: true, idempotencyKey: "k" })).toThrow(); - expect(() => buildCreateSandboxRequest("ws_one", { vmSandbox: true, cpu: 1, idempotencyKey: "k" })).toThrow(); expect(() => buildCreateSandboxRequest("ws_one", { vmSandbox: true })).toThrow(); - expect(() => buildCreateSandboxRequest("ws_one", { gvisor: true, size: "large" })).toThrow(); }); }); diff --git a/test/vm-files.test.ts b/test/vm-files.test.ts index cadf089..e6bbf87 100644 --- a/test/vm-files.test.ts +++ b/test/vm-files.test.ts @@ -111,27 +111,6 @@ describe("VM creation", () => { expect(JSON.parse(io.stdout.read().toString()).sandbox.state).toBe("pending"); expect(io.stderr.read().toString()).toContain("bxc sandbox status sbx_slow"); }); - - it("sends an explicit gVisor opt-out and rejects conflicting runtime flags", async () => { - const io = { stdout: new PassThrough(), stderr: new PassThrough() }; - const bodies: unknown[] = []; - const dependencies = { - io, env: {}, loadConnection: async () => connection, syncManagedSkills: async () => [], - fetch: (async (_: unknown, init?: RequestInit) => { - if (init?.method === "POST") { - bodies.push(JSON.parse(String(init.body))); - return json({ sandbox: { id: "sbx_container", vmSandbox: false, state: "running" } }, 201); - } - throw new Error("should not inspect"); - }) as typeof fetch, - }; - expect(await runCli(["sandbox", "start", "ws_one", "--gvisor"], dependencies)).toBe(0); - expect(bodies).toEqual([{ workspaceId: "ws_one", vmSandbox: false }]); - await expect(runCli(["sandbox", "start", "ws_one", "--vm", "--gvisor", "--idempotency-key", "k"], dependencies)) - .rejects.toThrow("either --vm or --gvisor"); - await expect(runCli(["sandbox", "start", "ws_one", "--vm", "--cpu", "1", "--idempotency-key", "k"], dependencies)) - .rejects.toThrow("fixed CPU profile"); - }); }); describe("file transfers", () => {