TypeScript SDK
Preview the programmatic sandbox lifecycle planned for the carton SDK.
The public SDK is not released yet. There is no supported package install command today. Use the CLI while the SDK is in development.
The planned SDK will let you create a sandbox, run commands, and clean up from application code. Your provider setup will stay separate from the code that uses a sandbox.
Planned usage
This is a proposed API example, consistent with the landing page. It is not executable against a released Carton package. Client initialization and authentication options are not final.
// Proposed SDK API. No public package is available yet.
import { Carton } from "carton";
const carton = new Carton();
const sandbox = await carton.sandboxes.create({
source: { type: "image", image: "IMAGE" },
});
try {
const result = await sandbox.exec(["echo", "Hello from carton"]);
console.log(result.stdout);
} finally {
await sandbox.destroy();
}
As with the CLI, IMAGE stands for an image configured for your provider.
The generated types in packages/contracts/ support Carton’s implementation
and tests. They are not the public SDK and should not be presented as its
installation path.