@cmdop/sdk 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,16 +1,22 @@
1
1
  # @cmdop/sdk (Node)
2
2
 
3
- Typed Node SDK for CMDOP. A **thin** client: it spawns the baked-in `cmdop-core`
4
- Go binary and speaks a protobuf-length-delimited `Envelope` protocol over its
5
- stdio. All relay logic (REST, the `/ask` SSE stream, pin/confirm side-channels,
6
- retries, error mapping) lives in the Go core.
7
-
8
- - **No Go toolchain, no `cmdop_go` install** — every platform's `cmdop-core`
9
- binary is baked into the one package; the right one is selected at runtime
10
- (no `optionalDependencies`). `npm i @cmdop/sdk` is everything.
11
- - **Pure stdio** — no local port, no socket. Token via `CMDOP_TOKEN` env at spawn.
12
- - **No macOS notarization** — npm-extracted binaries are unquarantined (ad-hoc
13
- signed only).
3
+ ![@cmdop/sdk — Node SDK for CMDOP](https://raw.githubusercontent.com/commandoperator/cmdop-sdk/main/assets/hero-cmdop-node.webp)
4
+
5
+ Typed Node SDK for CMDOP — manage your machines, fleets, tunnels, and schedules,
6
+ stream a machine's AI agent, and drive the skills marketplace, all from typed
7
+ TypeScript.
8
+
9
+ 📚 **Docs: [docs.cmdop.com](https://docs.cmdop.com)** · [SDK](https://cmdop.com/sdk) ·
10
+ [Bots](https://cmdop.com/bots) · [Connect](https://cmdop.com/connect)
11
+
12
+ ![How the CMDOP SDK connects your app to your machines](https://raw.githubusercontent.com/commandoperator/cmdop-sdk/main/assets/diagram-cmdop-sdk.webp)
13
+
14
+ - **One install, zero dependencies** — `npm i @cmdop/sdk` is everything. No
15
+ native build step, no `optionalDependencies`, nothing fetched on first run.
16
+ - **Works anywhere, offline-ready** — a single self-contained package runs the
17
+ same on macOS, Linux, and Windows, including air-gapped hosts.
18
+ - **Typed end to end** — full TypeScript types for every resource and response,
19
+ with one clean async streaming API for live agent output.
14
20
 
15
21
  ## Install
16
22
 
@@ -33,7 +39,7 @@ for (const m of page.items) console.log(m.hostname, m.presence);
33
39
  const text = await c.machines.ask(machineId, "uptime").collect();
34
40
  console.log(text);
35
41
 
36
- await c.close(); // reap the core subprocess
42
+ await c.close(); // release resources
37
43
  ```
38
44
 
39
45
  `await using c = new Client(...)` works too (`Symbol.asyncDispose`).
@@ -58,9 +64,9 @@ List endpoints also expose `iter(...)` (an async generator over every item,
58
64
  following cursors) and `pages(...)` (an async generator over each page).
59
65
 
60
66
  > **Two planes, one client.** `machines / fleets / tunnels / schedules / keys`
61
- > talk to the relay with `CMDOP_TOKEN`; the **`skills`** marketplace lives on the
62
- > platform (Django) and uses the `UserAPIKey` (`CMDOP_API_KEY`). Both are passed
63
- > to the core at spawn; you only set whichever you use.
67
+ > use your relay token (`CMDOP_TOKEN`); the **`skills`** marketplace uses your
68
+ > platform API key (`CMDOP_API_KEY`). Set whichever you need — the client routes
69
+ > each call to the right plane for you.
64
70
 
65
71
  ## Streaming: `machines.ask()`
66
72
 
@@ -100,44 +106,43 @@ pin_denied`. An `error` outcome throws `AgentStreamError`.
100
106
  | `CMDOP_API_BASE_URL` | platform REST root | `https://api.cmdop.com` |
101
107
  | `CMDOP_FLEET_ID` | default fleet for fleet-scoped ops | none |
102
108
  | `CMDOP_TIMEOUT_MS` | per-call timeout | `30000` |
103
- | `CMDOP_CORE_BINARY` | override the baked binary (dev / offline) | baked binary |
104
109
 
105
110
  Precedence is always explicit option > env var > default. Pass a string to the
106
111
  constructor (`new Client("token")`) as a shorthand for `{ token }`.
107
112
 
108
113
  ## Error handling
109
114
 
110
- The core emits a terminal `ERROR` frame; the client maps its `code` to a typed
111
- error (all extend `CmdopError`):
115
+ Every failure surfaces as a typed error carrying a stable `code` (all extend
116
+ `CmdopError`):
112
117
 
113
118
  ```ts
114
119
  import {
115
120
  AuthError, PermissionError, NotFoundError, ConflictError,
116
121
  ValidationError, RateLimitError, ServerError, ConnectionError,
117
- AgentStreamError, CmdopError,
122
+ TimeoutError, UnavailableError, AgentStreamError, CmdopError,
118
123
  } from "@cmdop/sdk";
119
124
 
120
125
  try {
121
126
  await c.machines.get("missing-id");
122
127
  } catch (e) {
123
128
  if (e instanceof NotFoundError) { /* ... */ }
124
- else if (e instanceof CmdopError) console.log(e.code, e.message);
129
+ else if (e instanceof CmdopError) {
130
+ if (e.retryable) { /* true on TimeoutError — safe to retry */ }
131
+ console.log(e.code, e.message);
132
+ }
125
133
  }
126
134
  ```
127
135
 
128
- `ConnectionError` also covers the core process dying mid-call (pending
129
- promises reject). `AgentStreamError` is the streaming-`ask` error outcome.
136
+ `ConnectionError` covers a lost connection mid-call (pending promises reject);
137
+ `TimeoutError` (a retryable subclass) is a deadline/handshake timeout;
138
+ `UnavailableError` means the relay is up but the target agent/machine is offline.
139
+ `AgentStreamError` is the streaming-`ask` error outcome.
130
140
 
131
- ## Local development
132
-
133
- Released packages bake in every platform's binary. For local work, build the
134
- core and point the client at it with `CMDOP_CORE_BINARY` (also the offline
135
- escape hatch in production):
136
-
137
- ```bash
138
- cd ../../cmdop_go/go && go build -o /tmp/cmdop-core ./cmd/cmdop-core
139
- CMDOP_CORE_BINARY=/tmp/cmdop-core CMDOP_TOKEN=... node ...
140
- ```
141
+ ## Links
141
142
 
142
- Tests: `pnpm exec vitest run`. The cross-language parity gate:
143
- `python ../../core/parity/check.py`.
143
+ - **Docs** → [docs.cmdop.com](https://docs.cmdop.com)
144
+ - **SDK** → [cmdop.com/sdk](https://cmdop.com/sdk) · **Bots** →
145
+ [cmdop.com/bots](https://cmdop.com/bots) · **Connect** →
146
+ [cmdop.com/connect](https://cmdop.com/connect)
147
+ - [`@cmdop/sdk` on npm](https://www.npmjs.com/package/@cmdop/sdk) ·
148
+ [source](https://github.com/commandoperator/cmdop-sdk)
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,8 +1,17 @@
1
1
  {
2
2
  "name": "@cmdop/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Typed Node SDK for CMDOP \u2014 spawns the baked-in cmdop-core Go binary and speaks protobuf over stdio (machines, fleets, tunnels, schedules, keys, and machine AI ask streaming).",
5
5
  "license": "MIT",
6
+ "homepage": "https://docs.cmdop.com",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/commandoperator/cmdop-sdk.git",
10
+ "directory": "node"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/commandoperator/cmdop-sdk/issues"
14
+ },
6
15
  "type": "module",
7
16
  "main": "./dist/index.cjs",
8
17
  "module": "./dist/index.js",