Skip to main content
Version: 0.1.22
Last Verified: 2025-01-27
Package: @hopx-ai/sdk on npm

Overview

The Commands resource provides shell command execution capabilities for sandboxes. Access it via the commands property on a Sandbox instance.

Methods

run

Run a shell command.
async commands.run(
    command: string,
    options?: CommandOptions
): Promise<CommandResponse>
Parameters:
  • command (string): Shell command to execute
  • options.timeout (number, optional): Command timeout in seconds (default: 30)
  • options.background (boolean, optional): Run in background (default: false)
  • options.workingDir (string, optional): Working directory (default: '/workspace')
  • options.env (Record<string, string>, optional): Environment variables
Returns: Promise<CommandResponse> - Command execution result Example:
const result = await sandbox.commands.run('ls -la /workspace');
console.log(result.stdout);
console.log(`Exit code: ${result.exitCode}`);

runBackground

Run command in background.
async commands.runBackground(
    command: string,
    options?: Omit<CommandOptions, 'background'>
): Promise<{ processId: string }>
Returns: Promise<{ processId: string }> - Process ID
  • Sandbox - Main sandbox class
  • Files - File operations resource

See Also

Next Steps