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

    Execution Result object for a completed command execution.

    The ExecutionResult class provides access to the results of a completed command execution. It includes the exit code, stdout/stderr output, and convenient methods for checking success/failure.

    Execution results are typically obtained from devbox.cmd.exec() or asyncExecution.result():

    import { RunloopSDK } from '@runloop/api-client-ts';

    const runloop = new RunloopSDK();
    const devbox = runloop.devbox.fromId('devbox-123');

    // Get result from synchronous execution
    const result = await devbox.cmd.exec('ls -la');

    // Check success
    if (result.success) {
    console.log('Command succeeded!');
    console.log(await result.stdout());
    } else {
    console.error(`Command failed with exit code: ${result.exitCode}`);
    console.error(await result.stderr());
    }
    const stdout = await result.stdout();
    const stderr = await result.stderr();
    // Get last 10 lines of stdout
    const lastLines = await result.stdout(10);

    // Get last 5 lines of stderr
    const errors = await result.stderr(5);
    Index

    Accessors

    • get exitCode(): number | null

      Get the exit code of the execution.

      Returns number | null

      The exit code, or null if not available

    • get executionId(): string

      Get the unique ID identifying this execution.

      Returns string

      string A UUIDv7 execution ID

    • get success(): boolean

      Check if the execution completed successfully (exit code 0).

      Returns boolean

      True if the execution succeeded (exit code 0), false otherwise

    • get failed(): boolean

      Check if the execution failed (non-zero exit code).

      Returns boolean

      True if the execution failed (non-zero exit code), false otherwise

    Methods

    • Get the stdout output from the execution. If numLines is specified, it will return the last N lines. If numLines is not specified, it will return the entire stdout output. Note after the execution is completed, the stdout is not available anymore.

      This method will retreive more logs from the server if necessary, an execution returns a subset of the logs. If you don't require all lines, it will resolve faster if you specify how many lines you need. Defaults to all lines.

      Parameters

      • OptionalnumLines: number

        Optional number of lines to return from the end (most recent logs) Defaults to all lines.

      Returns Promise<string>

      The stdout content

      // Get full stdout
      const fullOutput = await result.stdout();

      // Get last 10 lines
      const lastLines = await result.stdout(10);
    • Get the stderr output from the execution. If numLines is specified, it will return the last N lines. If numLines is not specified, it will return the entire stderr output. Note after the execution is completed, the stderr is not available anymore.

      This method will retreive more logs from the server if necessary, an execution returns a subset of the logs. If you don't require all lines, it will resolve faster if you specify how many lines you need. Defaults to all lines.

      Parameters

      • OptionalnumLines: number

        Optional number of lines to guarantee from the end (most recent logs) Defaults to all lines.

      Returns Promise<string>

      The stderr content

      // Get full stderr
      const fullErrors = await result.stderr();

      // Get last 5 lines
      const recentErrors = await result.stderr(5);