Skip to main content

Installation

npm install nen-sdk-js
Requires Node 20+ (uses the native fetch API). Zero runtime dependencies.

Quick Start

import { NenDesktop } from "nen-sdk-js";

const client = new NenDesktop({ apiKey: "sk_nen_..." });

// Create a desktop
const desktop = await client.createDesktop();
const did = desktop.desktopId;

// Take a screenshot
const result = await client.screenshot(did);
// result.base64Image is a PNG, base64-encoded

// Click and type
await client.leftClick(did, 500, 400);
await client.typeText(did, "hello world");

// Clean up
await client.deleteDesktop(did);

Configuration

const client = new NenDesktop({
  apiKey: "sk_nen_...",
  baseUrl: "https://desktop.api.getnen.ai", // default
  timeout: 30_000,                           // default (milliseconds)
});
The execute() method always uses a 120-second timeout, regardless of the client timeout.

Method Reference

Desktop CRUD

MethodReturnsDescription
createDesktop(desktopType?)Promise<Desktop>Create a new desktop ("sandbox" by default)
listDesktops()Promise<Desktop[]>List all active desktops
getDesktop(desktopId)Promise<Desktop>Get a single desktop by ID
updateDesktop(desktopId, { name })Promise<Desktop>Rename a desktop
deleteDesktop(desktopId)Promise<DeleteResponse>Delete a desktop

Computer-Use Helpers

Typed shortcuts — no need to know the wire format:
MethodDescription
screenshot(desktopId)Take a screenshot
leftClick(desktopId, x, y)Left click at coordinate
rightClick(desktopId, x, y)Right click at coordinate
doubleClick(desktopId, x, y)Double click at coordinate
middleClick(desktopId, x, y)Middle click at coordinate
mouseMove(desktopId, x, y)Move cursor to coordinate
typeText(desktopId, text)Type text
keyPress(desktopId, key)Press a key or combo (e.g. "ctrl+a")
scroll(desktopId, x, y, { direction, amount? })Scroll at coordinate
cursorPosition(desktopId)Get current cursor position

Tool Execution

MethodReturnsDescription
execute(desktopId, { tool, action, params? })Promise<ExecuteResult>Execute any tool action (raw)
listTools(desktopId)Promise<ToolSchema[]>List available tools as JSON Schema
getToolLogs(desktopId)Promise<unknown[]>Get tool execution logs

Sessions

MethodReturnsDescription
createSession(desktopId)Promise<SessionInfo>Create or reconnect an RDP session
getSession(desktopId)Promise<SessionInfo>Get current session status
deleteSession(desktopId)Promise<void>Disconnect the session

Error Handling

All API errors throw NenDesktopError, which carries statusCode and responseBody:
import { NenDesktop, NenDesktopError } from "nen-sdk-js";

const client = new NenDesktop({ apiKey: "sk_nen_..." });

try {
  await client.getDesktop("dsk_nonexistent");
} catch (e) {
  if (e instanceof NenDesktopError) {
    console.log(`Error ${e.statusCode}: ${e.responseBody}`);
  }
}
The JS SDK does not subclass by status code — inspect e.statusCode to differentiate (401, 404, 409, 5xx).