Skip to content
NorthstarPlatformPricingLogin

Execute command (streaming)

client.computers.exec.create(stringid, ExecCreateParams { command, cwd, env, timeout_seconds } body, RequestOptionsoptions?): ExecCreateResponse { code, data, message, type } | Stream<ExecCreateResponse { code, data, message, type } >
POST/computers/{id}/exec

Execute a shell command (desktop sessions only) and stream output back as newline-delimited JSON. Each line is a types.ExecOutput object whose type is one of stdout, stderr, exit, or error. The stream terminates with a single {"type":"exit","code":<int>} line; code -1 indicates timeout or abnormal termination.

Error model: this endpoint always returns HTTP 200 and reports failures (invalid JSON body, missing command, stream-setup failure) as a single {"type":"error","code":"<CODE>","message":"..."} NDJSON line followed by connection close. Clients MUST parse the first line rather than relying on HTTP status codes.

Output is filtered server-side by request ID, so concurrent /exec calls on the same computer don't interleave. Defaults: cwd=/workspace, timeout_seconds=120.

ParametersExpand Collapse
id: string
body: ExecCreateParams { command, cwd, env, timeout_seconds }
command?: string
cwd?: string
env?: Record<string, string>
timeout_seconds?: number
ReturnsExpand Collapse
ExecCreateResponse { code, data, message, type }
code?: number

for exit

data?: string

for stdout/stderr

message?: string

for error

type?: string

"stdout", "stderr", "exit", "error"

Execute command (streaming)

import Lightcone from '@tzafon/lightcone';

const client = new Lightcone({
  apiKey: process.env['TZAFON_API_KEY'], // This is the default and can be omitted
});

const exec = await client.computers.exec.create('id');

console.log(exec.code);
Returns Examples