@runloop/api-client - v1.4.0
    Preparing search index...

    Object-oriented interface for working with Devboxes.

    The Devbox class provides a high-level, object-oriented API for managing devboxes. Devboxes are containers that run your code in a consistent environment. They have the the following categories of operations:

    • net - Network operations
    • cmd - Command execution operations
    • file - File operations
    import { RunloopSDK } from '@runloop/api-client-ts';

    const runloop = new RunloopSDK();
    const devbox = await runloop.devbox.create({ name: 'my-devbox' });
    devbox.cmd.exec('echo "Hello, World!"');
    ...
    Index

    Properties

    Network operations on the devbox.

    Command execution operations on the devbox.

    File operations on the devbox.

    Accessors

    Methods

    • Create a named shell instance for stateful command execution.

      Named shells are stateful and maintain environment variables and the current working directory (CWD) across commands, just like a real shell on your local computer. Commands executed through the same named shell instance will execute sequentially - the shell can only run one command at a time with automatic queuing. This ensures that environment changes and directory changes from one command are preserved for the next command.

      Parameters

      • OptionalshellName: string = ...

        The name of the persistent shell session. If not provided, a UUID will be generated automatically.

      Returns DevboxNamedShell

      A DevboxNamedShell instance for executing commands in the named shell

      // Create a named shell with a custom name
      const shell = devbox.shell('my-session');

      // Create a named shell with an auto-generated UUID name
      const shell2 = devbox.shell();

      // Commands execute sequentially and share state
      await shell.exec('cd /app');
      await shell.exec('export MY_VAR=value');
      await shell.exec('echo $MY_VAR'); // Will output 'value' because env is preserved
      await shell.exec('pwd'); // Will output '/app' because CWD is preserved
    • Get the complete devbox data from the API.

      Parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<DevboxView>

      The devbox data

      const info = await devbox.getInfo();
      console.log(`Devbox name: ${info.name}, status: ${info.status}`);
    • Wait for the devbox to reach the running state. Uses optimized server-side polling for better performance.

      Parameters

      • Optionaloptions: RequestOptions<unknown> & { polling?: Partial<PollingOptions<DevboxView>> }

        Request options with optional polling configuration

      Returns Promise<DevboxView>

      The devbox data when running state is reached

      const devbox = Devbox.fromId(runloop, 'devbox-123');
      await devbox.awaitRunning();
      console.log('Devbox is now running');
    • Wait for the devbox to reach the suspended state. Uses optimized server-side polling for better performance.

      Parameters

      • Optionaloptions: RequestOptions<unknown> & { polling?: Partial<PollingOptions<DevboxView>> }

        Request options with optional polling configuration

      Returns Promise<DevboxView>

      The devbox data when suspended state is reached

      await devbox.suspend();
      await devbox.awaitSuspended();
      console.log('Devbox is now suspended');
    • Create a disk snapshot of the devbox. Returns a snapshot that is completed. If you don't want to block on completion, use snapshotDiskAsync().

      Parameters

      • Optionalparams: DevboxSnapshotDiskParams

        Snapshot creation parameters

      • Optionaloptions: RequestOptions<unknown> & {
            polling?: Partial<PollingOptions<DevboxSnapshotView>>;
        }

        Request options with optional polling configuration

      Returns Promise<RunloopSDK.Snapshot>

      A completed Snapshot instance

      const snapshot = await devbox.snapshotDisk({ name: 'pre-deployment' });
      console.log(`Snapshot ${snapshot.id} created successfully`);
    • Create a disk snapshot of the devbox asynchronously. Returns a snapshot that is not yet completed but has started. You can await completion using snapshot.awaitCompleted().

      Parameters

      • Optionalparams: DevboxSnapshotDiskParams

        Snapshot creation parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<RunloopSDK.Snapshot>

      A Snapshot instance that has started but may not be completed

      const snapshot = await devbox.snapshotDiskAsync({ name: 'backup' });
      // Do other work...
      await snapshot.awaitCompleted();
    • Shutdown the devbox.

      Parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<DevboxView>

      Shutdown result

      await devbox.shutdown();
      
    • Suspend the devbox and create a disk snapshot.

      Parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<DevboxView>

      Suspend result

      await devbox.suspend();
      // Optionally, wait for the devbox to reach the suspended state
      await devbox.awaitSuspended();
    • Resume a suspended devbox and wait for it to reach the running state.

      Parameters

      • Optionaloptions: RequestOptions<unknown> & { polling?: Partial<PollingOptions<DevboxView>> }

        Request options with optional polling configuration

      Returns Promise<DevboxView>

      The devbox data when running state is reached

      await devbox.resume();
      // Devbox is now running
    • Resume a suspended devbox without waiting for it to reach the running state.

      Parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<DevboxView>

      Resume result

      await devbox.resumeAsync();
      // Optionally wait for running state
      await devbox.awaitRunning();
    • Send a keep-alive signal to prevent idle shutdown.

      Parameters

      • Optionaloptions: RequestOptions<unknown>

        Request options

      Returns Promise<unknown>

      Keep-alive result

      // Send keep-alive periodically
      setInterval(() => devbox.keepAlive(), 60000);