Installation
TL;DR
Install @cmdop/node with npm, yarn, or pnpm. Requires Node.js 18 or later. TypeScript support is built-in with full type definitions β no separate @types package needed. Configure via environment variables (CMDOP_API_KEY, CMDOP_MACHINE) or programmatically using configure() or per-client options. Supports remote (cloud relay), local (direct), and auto-discover (mDNS) connection types.
What are the requirements?
- Node.js 18 or later
- TypeScript 5.0+ (recommended)
How do I install with my package manager?
# Install with npm
npm install @cmdop/node
# Install with pnpm
pnpm add @cmdop/node
# Install with yarn
yarn add @cmdop/nodeWhat environment variables are needed?
# Required for remote connections β your CMDOP API key
export CMDOP_API_KEY="cmdop_xxx"
# Optional β set a default target machine name
export CMDOP_MACHINE="my-server"
# Optional β override the default cloud relay URL
export CMDOP_RELAY_URL="relay.cmdop.com"How do I configure the SDK?
Using configure()
import { configure } from '@cmdop/node';
// Set global defaults for all clients created after this call
configure({
apiKey: process.env.CMDOP_API_KEY,
defaultMachine: 'prod-server',
timeout: 30000, // 30-second default timeout
retries: 3, // Retry failed requests up to 3 times
});Per-client Configuration
import { CMDOPClient } from '@cmdop/node';
// Override global defaults for this specific client instance
const client = await CMDOPClient.remote({
apiKey: 'cmdop_xxx',
timeout: 60000, // 60-second timeout for this client only
retries: 5, // More retries for this client
});What connection types are available?
| Method | Use Case |
|---|---|
CMDOPClient.remote() | Cloud relay β works through NAT/firewalls |
CMDOPClient.local() | Direct connection to local agent |
CMDOPClient.discover() | Auto-discover agent via mDNS |
How do I use TypeScript types?
The SDK is written in TypeScript and provides full type definitions. No @types package needed.
// Import type definitions directly from the package
import type { ExecuteResult, AgentResult, FileInfo } from '@cmdop/node';Last updated on