Skip to main content
Starts a long-running background process in the sandbox. Use this for servers, services, and any command that should continue running after the initial call returns.

Method Signature

await sandbox.startProcess(
  command: string,
  options?: ProcessOptions,
  sessionId?: string
): Promise<Process>

Parameters

command
string
required
The command to execute as a background process
"python -m http.server 8080"
options
ProcessOptions
Configuration options for the process
sessionId
string
Optional session ID. If not provided, the default session is used.

Returns

Process
Process
A Process object with methods for interacting with the running process

Examples

Start a web server

const process = await sandbox.startProcess('python -m http.server 8080');
console.log('Server started:', process.id);

Start with custom process ID

const process = await sandbox.startProcess(
  'npm run dev',
  { processId: 'dev-server' }
);

Monitor process output

const process = await sandbox.startProcess(
  'python train.py',
  {
    onOutput: (stream, data) => {
      console.log(`[${stream}]:`, data);
    },
    onExit: (code) => {
      console.log('Process exited with code:', code);
    }
  }
);

Start with environment variables

const process = await sandbox.startProcess(
  'node server.js',
  {
    env: {
      PORT: '3000',
      NODE_ENV: 'production'
    }
  }
);

Build docs developers (and LLMs) love