Device and agent SDK
Pair devices with short-lived setup tokens, connect agents separately, configure agent access and follow correlated action results.
The openlaunch SDK has separate credentials for device setup and agent access. A short-lived ol_sdk_ token pairs a device; it cannot call agent or MCP APIs. An ol_agent_ API connection authenticates an agent; it cannot pair devices. The setup token cannot operate anything, but a newly paired device becomes available to agents with an all-functions access policy; connections in selected-functions mode need the owner’s per-device approval.
Create an agent API connection
In the console, open Connections and create a named agent API connection. Choose read or action access and set a finite expiry or choose until revoked. The ol_agent_ credential is shown once. Save it in a secret manager or environment variable. Do not put it in source code, prompts, shell history, or logs.
Revoke an agent connection in Connections to stop agent requests and remove its grants. Per-device function grants are separate and can also expire or remain active until revoked.
Connect an agent
Install the SDK from the hosted archive:
npm install 'https://www.openlaunch.dev/downloads/openlaunch-sdk.tgz?commit=c15ef9686751bc86f28b6fdd3a40119f9b7eb951'
Read the token from a private environment variable and create a client:
import { createClient } from "@openlaunch/sdk";
const openlaunch = createClient({
url: "https://www.openlaunch.dev",
token: process.env.OPENLAUNCH_AGENT_TOKEN!,
});
const devices = await openlaunch.listDevices();
const functions = await openlaunch.listFunctions(); // Custom functions this connection may use.
const device = devices[0];
if (!device) throw new Error("No devices are granted to this agent");
const action = await openlaunch.requestAction(device.id, {
capability: "device.health",
idempotencyKey: crypto.randomUUID(),
});
let result = action;
while (["queued", "received"].includes(result.status)) {
await new Promise((resolve) => setTimeout(resolve, 1_000));
result = await openlaunch.getAction(action.id);
}
console.log(result.status, result.result);
Choose action access for this example; a read-only agent connection can list devices and inspect actions but cannot request them. Access policies decide which functions the agent can use; selected-function policies also require device grants. A queued action is not a completed action; check the final result. See Connect an agent for MCP clients and other connection options.
Use cancelAction(id) before a device receives an action. broadcast({ deviceIds, capability, arguments, idempotencyKey }) requests the same function from several devices and returns a result per device. Retry a request with the same idempotency key only when its arguments are identical. Agents written in other languages can use the same HTTP endpoints with Authorization: Bearer <agent API credential>; see the API reference.
Attach a device with one command
For a Linux machine, gateway or Node adapter, open Devices → Add device and create a device setup token. It uses the ol_sdk_ prefix, expires after 10 minutes by default, and attaches one device by default. The console shows the one-time token and a setup command. Copy the command and run it on the machine beside your hardware:
curl -fsSL https://www.openlaunch.dev/setup.sh | bash -s -- adapter
With curl, Python 3 and Node 24+ installed, the launcher reads the deployed download manifest and verifies the SDK checksum before running it. The command asks only for the device setup token, with the input hidden. It gets the workspace from the token, creates a starter adapter, saves a private per-device credential, and starts the Node runner. It never saves the setup token. If setup loses its connection, rerun the same command with the same token within 10 minutes to resume the saved request. Once paired, the private child credential survives setup-token expiry or revocation; removing the device revokes that child credential.
After the device appears, the console opens its Access view. Choose which functions the agent connection may use. A grant can have an expiry or remain active until you revoke it. The starter reports the adapter process health; connect your hardware library and implement its functions in adapter.mjs to control real hardware.
Change and publish the function list with:
curl -fsSL https://www.openlaunch.dev/setup.sh | bash -s -- adapter publish
Review exclusions in the console; selected-function connections need grants for the published functions. Then restart the adapter:
curl -fsSL https://www.openlaunch.dev/setup.sh | bash -s -- adapter run
Publishing a changed manifest clears earlier grants and cancels queued actions. It cannot undo a command already delivered to a device.
Recover an interrupted action
The adapter keeps a private result journal. It retries a saved result without running its handler again, and verifies the server receipt before acknowledging it. If a restart leaves an action’s outcome unknown, it reports that uncertainty and stops accepting new commands, including on later restarts.
Inspect the physical device first. If you retire the interrupted adapter, revoke its device identity in the console and start a replacement in a new directory with a fresh device setup token:
curl -fsSL https://www.openlaunch.dev/setup.sh | bash -s -- adapter setup --directory ./recovered-adapter
The old private identity and journal remain available for inspection. Do not clear a journal merely to bypass an unknown outcome.
Use the SDK directly
The setup token can attach a device from JavaScript or TypeScript. Use a stable UUID request ID for retries of the same attachment and manifest:
import { createDevice } from "@openlaunch/sdk";
const device = createDevice({
url: "https://www.openlaunch.dev",
token: process.env.OPENLAUNCH_SDK_TOKEN!,
});
const identity = await device.attach(manifest, crypto.randomUUID());
// Store identity.deviceId and identity.token in protected device storage.
createDevice() uses the device setup token only to attach; the device polls with the private child credential. The child credential remains valid after setup-token expiry or revocation. The SDK keeps credentials in memory, so store the returned device identity securely if the process must restart. nextAction() retrieves one action and submitResult() reports its outcome. Node adapters can call openEvents(onWake) to receive a wake hint and immediately check nextAction() over HTTPS.
Bring another board
The Node runner uses an authenticated WebSocket for payload-free wake hints. It fetches the actual action over HTTPS and keeps its 10-second HTTP poll as a fallback. The hint connection uses a short-lived ticket in the WebSocket handshake; it never carries action arguments or results. Other runtimes, including Go, Uno and ESP32, continue to poll over HTTPS every 10 seconds. A custom device kind such as custom.rp2040 does not need a built-in board profile. Declare only the functions your adapter implements, using bounded input fields. A manifest is a description and input schema; it does not install firmware or create hardware support.
The maintained integrations are Uno R4 WiFi and Raspberry Pi. Their real board behavior is still subject to the hardware checks in the verification guide. See Build your own functions for input and permission rules, and the API reference for request routes.
The former one-use enrollment flow and older combined connection records remain available for existing integrations. New integrations should use a device setup token for pairing and a separate agent API connection or OAuth for agent access.
Standalone ESP32
The ESP32 Arduino library includes a health example and portable C++ SDK. After uploading firmware, choose Standalone ESP32 in the setup menu. Enter its confirmed USB port when prompted:
curl -fsSL https://www.openlaunch.dev/setup.sh | bash
The helper prompts for Wi-Fi details and a device setup token with hidden input, then asks before sending settings. The ol_sdk_ token is only used to pair this device; it cannot authenticate an agent. The helper does not ask you to edit a secrets.h file or flash firmware. The hosted origin uses a bundled, fingerprint-checked public CA. For another origin, supply its trusted public root certificate with --ca-file. The archive is compile-verified; physical ESP32 operation remains unverified. See downloads and resources.