Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
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.14.4] - 2026-11-30

`bxc sandbox expose` reports unsupported platforms before loading credentials.

### CLI users

- The help and error message list the supported platforms. Run `bxc sandbox
expose` on Linux or macOS with an x64 or arm64 runtime.
- Update with `bxc update` or `npm install --global @boxcompute/cli@latest`.

### Security

- Unsupported clients exit before loading credentials or requesting a service grant.

## [0.14.3] - 2026-11-29

The CLI can use saved credentials on native Windows.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ analytics, costs and processes running inside the VM do not count as activity.
### Expose VM services

To reach a TCP service running inside a network-enabled VM, keep a foreground
tunnel open locally:
tunnel open on Linux or macOS (x64 or arm64):

```sh
# 127.0.0.1:3000 -> VM port 3000
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@boxcompute/cli",
"version": "0.14.3",
"version": "0.14.4",
"description": "Connect local AI agents to BoxCompute sandboxes",
"keywords": [
"boxcompute",
Expand Down
3 changes: 2 additions & 1 deletion skills/boxcompute-sandbox/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ and delete with `bxc sandbox delete SANDBOX_ID --yes`, including on test failure
or expiry. Ordinary Sandbox persistence guidance below does not apply to VMs.

To let the user reach a TCP service in a running VM, start the server as a
durable remote process, then have the user run this foreground command locally:
durable remote process. The user can run this foreground command on Linux or
macOS (x64 or arm64):

```sh
bxc sandbox expose SANDBOX_ID --port 3000
Expand Down
6 changes: 5 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
type AgentTarget,
type HarnessDetection,
} from "./skill.js";
import { openServices, type ServiceMapping } from "./services.js";
import { openServices, requireServicePlatform, SERVICE_PLATFORMS, type ServiceHost, type ServiceMapping } from "./services.js";
import { runProxy } from "./proxy.js";
import { runSsh } from "./ssh.js";
import { OrcaUsageError, runLocal, runOrca } from "./orca.js";
Expand Down Expand Up @@ -90,6 +90,7 @@ Commands:
logs Read current or retained sandbox logs
exec Execute a program inside a sandbox
expose Forward selected TCP ports to local loopback
Requires ${SERVICE_PLATFORMS}
preview Open or close a one-hour browser preview URL
ssh Open experimental lease-limited SSH
upload Upload a local file (up to 8 MiB)
Expand Down Expand Up @@ -159,6 +160,7 @@ Commands:
Execute a program inside a sandbox
expose SANDBOX_ID --port [LOCAL:]REMOTE
Forward up to 8 TCP ports to 127.0.0.1
Requires ${SERVICE_PLATFORMS}
preview SANDBOX_ID --port PORT Open a one-hour HTTP/WebSocket preview URL for a VM port
preview SANDBOX_ID --close PREVIEW_ID
Close a preview before it expires
Expand Down Expand Up @@ -472,6 +474,7 @@ export type CliDependencies = {
readSkill?: typeof readSkill;
syncManagedSkills?: typeof syncManagedSkills;
openServices?: typeof openServices;
serviceHost?: ServiceHost;
proxy?: typeof runProxy;
ssh?: typeof runSsh;
runner?: typeof runRunner;
Expand Down Expand Up @@ -1270,6 +1273,7 @@ export async function runCli(argv: string[], supplied: CliDependencies = {}): Pr
write(io.stdout, sandboxHelp);
return 0;
}
if (command === "sandbox" && args[0] === "expose") requireServicePlatform(supplied.serviceHost);
if (command === "deleted" && !args.length) args.push("list");

const connection = await load(env);
Expand Down
13 changes: 11 additions & 2 deletions src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ import { fileURLToPath } from "node:url";
import type { ServiceAccessApi, ServiceAccessRequest, ServiceAccessResponse, ServiceCleanup } from "./service-access.js";

export type ServiceMapping = { local: number; remote: number };
export type ServiceHost = Pick<NodeJS.Process, "platform" | "arch">;

export const SERVICE_PLATFORMS = "Linux or macOS (x64 or arm64)";

export function requireServicePlatform({ platform, arch }: ServiceHost = process): void {
if (["linux", "darwin"].includes(platform) && ["x64", "arm64"].includes(arch)) return;
const target = platform === "win32" ? `native Windows (${arch})` : `${platform}/${arch}`;
throw new Error(`bxc sandbox expose is unsupported on ${target}. Run it on ${SERVICE_PLATFORMS}.`);
}

const unavailable = () => new Error(
"Service access unavailable; no mutation retry was attempted. Any unconfirmed access expires at its original deadline.",
Expand Down Expand Up @@ -97,8 +106,8 @@ export async function openServices(
mappings: readonly ServiceMapping[],
signal?: AbortSignal,
) {
if (signal?.aborted || !["linux", "darwin"].includes(process.platform) || !["x64", "arm64"].includes(process.arch)
|| mappings.length < 1 || mappings.length > 8
requireServicePlatform();
if (signal?.aborted || mappings.length < 1 || mappings.length > 8
|| mappings.some((mapping) => Object.keys(mapping).sort().join() !== "local,remote"
|| !Number.isInteger(mapping.local) || mapping.local < 1 || mapping.local > 65_535
|| !Number.isInteger(mapping.remote) || mapping.remote < 1 || mapping.remote > 65_535)
Expand Down
35 changes: 34 additions & 1 deletion test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,33 @@ function output(stream: PassThrough): string {
}

describe("bxc CLI", () => {
it("documents the expose platforms in CLI and sandbox help", async () => {
for (const args of [["--help"], ["sandbox", "expose", "--help"]]) {
const io = streams();
expect(await runCli(args, { io, env: {} })).toBe(0);
const exposeHelp = /^ +expose\b[^\n]*(?:\n {10,}[^\n]+)*/m.exec(output(io.stdout))?.[0];
expect(exposeHelp).toContain("Linux or macOS (x64 or arm64)");
}
});

it.each([
["win32", "x64", "native Windows (x64)"],
["win32", "arm64", "native Windows (arm64)"],
["linux", "ia32", "linux/ia32"],
["freebsd", "x64", "freebsd/x64"],
] as const)("rejects expose on %s/%s before loading credentials or making requests",
async (platform, arch, target) => {
await expect(runCli(["sandbox", "expose", "sbx_one", "--port", "3000"], {
io: streams(),
env: {},
serviceHost: { platform, arch },
loadConnection: async () => { throw new Error("should not load credentials"); },
fetch: Object.assign(async () => { throw new Error("should not make a request"); }, { preconnect: fetch.preconnect }),
openServices: async () => { throw new Error("should not start forwarding"); },
})).rejects.toThrow(`bxc sandbox expose is unsupported on ${target}. Run it on Linux or macOS (x64 or arm64).`);
},
);

it("parses selected service ports without permitting duplicate listeners or targets", () => {
const values = ["--port", "3000", "--port", "8080:80"];
expect(serviceMappings(values)).toEqual([{ local: 3000, remote: 3000 }, { local: 8080, remote: 80 }]);
Expand All @@ -23,12 +50,18 @@ describe("bxc CLI", () => {
expect(() => serviceMappings(["--port", "0"])).toThrow("1 to 65535");
});

it("keeps expose in the foreground and reports loopback mappings", async () => {
it.each([
["linux", "x64"],
["linux", "arm64"],
["darwin", "x64"],
["darwin", "arm64"],
] as const)("keeps expose in the foreground and reports loopback mappings on %s/%s", async (platform, arch) => {
const io = streams();
const observed: unknown[] = [];
expect(await runCli(["sandbox", "expose", "sbx_one", "--port", "3000", "--port", "8080:80"], {
io,
env: {},
serviceHost: { platform, arch },
loadConnection: async () => ({ url: "https://app.boxcompute.ai", token: "bc_live_test", tokenFile: "/credential" }),
syncManagedSkills: async () => [],
openServices: async (_client, id, mappings, signal) => {
Expand Down
14 changes: 13 additions & 1 deletion test/services.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@ import {
hkdfSync,
randomBytes,
} from "node:crypto";
import { unsealServices } from "../src/services.js";
import { openServices, unsealServices } from "../src/services.js";
import type { ServiceAccessRequest } from "../src/service-access.js";

const generation = "11234567-89ab-4cde-8fab-0123456789ab";

it.skipIf(process.platform !== "win32")("refuses to launch Windows forwarding before requesting service access", async () => {
const unexpectedRequest = async () => { throw new Error("should not request service access"); };
const api = {
createServiceAccess: unexpectedRequest,
lookupServiceAccess: unexpectedRequest,
revokeServiceAccess: unexpectedRequest,
};
await expect(openServices(api, "sbx_one", [{ local: 3000, remote: 3000 }])).rejects.toThrow(
`bxc sandbox expose is unsupported on native Windows (${process.arch}). Run it on Linux or macOS (x64 or arm64).`,
);
});

function seal(request: ServiceAccessRequest, change: Record<string, unknown> = {}) {
const sender = generateKeyPairSync("x25519");
const recipient = createPublicKey({
Expand Down