import { Novita, SandboxState } from 'novita-sandbox'
const novita = new Novita()
// --- Get the sandbox ID ---
// Get all running sandboxes
const runningSandboxesPaginator = await novita.sandbox.list({
query: {
state: [SandboxState.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 novita.sandbox.connect(runningSandboxId)
console.log('connected to sandbox: ', sandbox.sandboxId)
// Now you can use the sandbox as usual
// ...