import { Sandbox } from "novita-sandbox/code-interpreter"
// Get all running sandboxes
const runningSandboxesPaginator = await Sandbox.list({
query: {
state: ["running"],
},
})
const runningSandboxes = await runningSandboxesPaginator.nextItems()
if (runningSandboxes.length === 0) {
throw new Error("No running sandboxes found")
}
const runningSandboxId = runningSandboxes[0].sandboxId
// connect to the sandbox.
const sandbox = await Sandbox.connect(runningSandboxId)
console.log("connected to sandbox: ", sandbox.sandboxId)
// Now you can use the sandbox as usual
// ...