Orblealpha

TypeScript SDK

Install

Requires Node.js 20 or later, or Bun.

$ npm install @orble/sdk
main.ts
import { Orble } from "@orble/sdk";

const orble = new Orble();
const box = await orble.create({ size: "s" });
const { code, stdout } = await box.exec("npm test", { cwd: "app", env: { CI: "1" } });
console.log(code, stdout);
await box.delete();

Authentication

Authenticate with an API key or with credentials saved by the Orble CLI. The SDK loads credentials automatically unless you provide a key when configuring a client.

Use an API key

Create an API key in Settings, then set ORBLE_API_KEY in the environment where your application runs.

$ export ORBLE_API_KEY=orble_...

Use CLI credentials

For local development, run orble login to save credentials. If no key is provided explicitly or through ORBLE_API_KEY, the SDK uses the saved CLI token.

The default configuration file is ~/.config/orble/config.json on Linux, ~/Library/Application Support/orble/config.json on macOS, or %APPDATA%/orble/config.json on Windows. On Linux, XDG_CONFIG_HOME overrides the ~/.config directory.

$ orble login

Configure a client

Pass credentials directly when you need an explicitly configured client. The client key takes precedence over ORBLE_API_KEY and CLI credentials. Use this client for subsequent SDK calls.

client.ts
import { Orble } from "@orble/sdk";

const orble = new Orble({
  key: process.env.ORBLE_API_KEY,
  url: "https://orble.tech",
});
const box = orble.box("my-box");

Choose an API URL

Set ORBLE_API_URL to use another Orble deployment, such as staging. Use credentials created for that deployment.

The SDK selects the URL in this order: the client's explicit url argument, ORBLE_API_URL, the API URL saved by the CLI, then https://orble.tech.

$ export ORBLE_API_URL=https://staging.orble.tech

Calls

new Orble({ key, url })

Create an API client. key and url are optional; see Authentication

orble.create({ size, name, fromSnapshot, })

Create a box and return a Box instance. Set size to "s" (default), "m" or "l", and fromSnapshot to a snapshot name

orble.box(name)

Get a client-side reference to an existing box by name

orble.boxes()

Return the account's boxes as Box[]

orble.snapshots()

Return available snapshots as Snapshot[]

box.exec( command, { cwd, env, timeout, user }, )

Execute a shell command and wait for completion. Set user: "root" to run it as root. Return { code, stdout, stderr, timedOut }

box.write(path, content, { user })

Write a string, Uint8Array or ReadableStream to a file, replacing existing contents and creating missing parent directories

box.read(path, { user })

Read a whole file as a string

box.readBytes(path, { user })

Read a whole file as a Uint8Array

box.readStream(path, { user })

Read a file as it arrives. Return a Response whose body is a ReadableStream

box.port(port, { public })

Expose a port and return its HTTPS URL. Access is restricted to the account unless public access is requested

box.tokenPort(port)

Expose a port to anyone with its token. Return { url, token }

box.newPortToken(port)

Replace a token port's token and return the new { url, token }

box.fork(count = 1)

Create 1–10 copies of the box with disk contents, memory and process state preserved. Return the copies as Box[]

box.snapshot(name?)

Create a snapshot of the box and return a Snapshot instance

box.suspend()

Suspend the box with guest memory and process state preserved

box.resume()

Resume the box from its saved memory and process state

box.start()

Start a stopped box (its own software powered it off) from its disk. Nothing else wakes a stopped box

box.keepAwake(on = true)

Disable automatic suspension when on is true; restore suspension when idle when on is false

box.delete()

Permanently delete the box and its disk

box.refresh()

Retrieve the current API representation and update box.info

snapshot.delete()

Permanently delete the snapshot

Commands, files and ports

Commands

Commands are executed with /bin/sh -c as the agent user in /home/agent, with passwordless sudo available, or as root in /root with the user option. Maximum timeout: 600 seconds; exit code on timeout: 124. Output is limited to the last 64 KiB of each stream

Files

Relative file paths are resolved from /home/agent. Files are streamed in both directions. Maximum file size: 4 GiB

Suspended boxes

Suspended boxes are resumed automatically for command execution and file reads or writes

Ports

Private ports require account authentication. Public ports are accessible without authentication. Token ports require the port's token in the X-Orble-Preview-Token header, or ?orble_preview_token=<token> on a browser link. Public and token ports require account credit. Limit: 20 shared ports per box

Errors

SDK exceptions: orble.Error in Python and OrbleError in TypeScript, with the HTTP status and error message