@cmdop/sdk 3.1.0 → 3.3.0

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
@@ -23,6 +23,10 @@ its group (`box.fs.read({ path })`, `box.task.start({ command })`); `box.screens
23
23
  `cmdop.call(tool, args, { machine })` reaches any of them by name. A refused call throws `CmdopError` with its
24
24
  `code`; `deadline` and `signal` bound and cancel any call.
25
25
 
26
+ The tools the server answers itself are methods of the client, with no machine: `cmdop.machines_list()`,
27
+ `cmdop.tasks_list()`, `cmdop.history_search({ text })`, `cmdop.docs_read({ path })` (the docs, contents first) and
28
+ `cmdop.showtime_guide({ language })`, the guide for a short live demo of what your machines can do.
29
+
26
30
  ## The same tools over MCP
27
31
 
28
32
  CMDOP is an MCP server too: an agent reaches these tools at `$CMDOP_URL/mcp` (streamable HTTP) with an agent token
package/dist/client.d.ts CHANGED
@@ -17,6 +17,7 @@
17
17
  * End-to-end calls come through a `Sealer` (`connect({ e2e })`): this file holds no key and reads no sealed text.
18
18
  */
19
19
  import type { Answer, CallRequest, ErrorCode, OutputChunk } from "./generated/call.gen.ts";
20
+ import { type ServerMethods } from "./generated/server.gen.ts";
20
21
  import { type Forms, type Groups } from "./generated/surface.gen.ts";
21
22
  import { type ExecRunOut, type ToolMap, type ToolName } from "./generated/tools.gen.ts";
22
23
  import { type Carrier, type MachineRow } from "./carriers/carrier.ts";
@@ -88,7 +89,12 @@ type ToolMethods = {
88
89
  * short forms (`run`, `stream`, `screenshot`), all generated (`generated/surface.gen.ts`).
89
90
  */
90
91
  export type Machine = ToolMethods & Groups<Omit<CallOpts, "machine">> & Forms<Omit<CallOpts, "machine">>;
91
- export interface Client {
92
+ /**
93
+ * The client: the contour's machines, and the tools the server answers itself as methods (`cmdop.showtime_guide()`,
94
+ * `cmdop.tasks_list()`), generated (`generated/server.gen.ts`). Those take no machine and are never sealed: the server
95
+ * answers them from its own records.
96
+ */
97
+ export interface Client extends ServerMethods<Omit<CallOpts, "machine">> {
92
98
  /** Which carrier is in use (`"http"`, …): what `auto` picked. */
93
99
  readonly carrier: string;
94
100
  /** The machines of the contour: name, id, online, os, tools. */
package/dist/client.js CHANGED
@@ -16,6 +16,7 @@
16
16
  *
17
17
  * End-to-end calls come through a `Sealer` (`connect({ e2e })`): this file holds no key and reads no sealed text.
18
18
  */
19
+ import { SERVER_TOOL_NAMES } from "./generated/server.gen.js";
19
20
  import { FORMS, GROUPS } from "./generated/surface.gen.js";
20
21
  import { TOOL_NAMES } from "./generated/tools.gen.js";
21
22
  import { CarrierError } from "./carriers/carrier.js";
@@ -223,10 +224,24 @@ export function connect(opts = {}) {
223
224
  }
224
225
  return out;
225
226
  }
227
+ /** A server tool: no machine, and never sealed, since the server reads its arguments and answers it itself. */
228
+ async function server(tool, args, o = {}) {
229
+ const deadline = o.deadline === undefined ? {} : { deadline_ms: Math.max(0, Math.round(o.deadline)) };
230
+ const req = { tool, args: args ?? {}, ...deadline };
231
+ let a;
232
+ try {
233
+ a = await carrier.call(req, o.signal ? { signal: o.signal } : {});
234
+ }
235
+ catch (e) {
236
+ throw cancelledOr(e, o.signal);
237
+ }
238
+ return settle(a);
239
+ }
240
+ const serverMethods = Object.fromEntries(SERVER_TOOL_NAMES.map((t) => [t, (args, o) => server(t, args, o)]));
226
241
  async function publicKey() {
227
242
  if (!opts.e2e)
228
243
  throw new CmdopError("bad_args", "this client was made without e2e");
229
244
  return opts.e2e.publicKey();
230
245
  }
231
- return { carrier: carrier.name, machines, machine, call, stream, publicKey, close: () => carrier.close() };
246
+ return { ...serverMethods, carrier: carrier.name, machines, machine, call, stream, publicKey, close: () => carrier.close() };
232
247
  }
@@ -1,4 +1,4 @@
1
- // Generated from cmdop/crates/tools/tools.schema.json (sha256 72ba780fabadfafb, cmdop 0.1.10) by exports/sdk/gen/gen.ts. Do not edit.
1
+ // Generated from cmdop/crates/tools/tools.schema.json (sha256 53ac9daa3bb73c83, cmdop 0.1.11) by exports/sdk/gen/gen.ts. Do not edit.
2
2
  /** Every error code, in the order Rust declares them. */
3
3
  export const ERROR_CODES = ["other", "denied", "unknown_tool", "bad_args", "not_found", "busy", "permission_missing", "screen_locked", "stale_capture", "element_gone", "app_not_allowed", "lease_paused", "paused", "offline", "rate_limited", "quota_exceeded", "not_dispatched", "display_gone", "timed_out", "cancelled", "too_large", "hash_required", "failed", "needs_presence", "unauthorized"];
4
4
  /** The size limits every carrier keeps. */
@@ -0,0 +1,323 @@
1
+ /** Arguments of `docs_read`. */
2
+ export type DocsReadArgs = {
3
+ /**
4
+ * The page: `guides/connect`, `/guides/connect`, its docs.cmdop.ai address or the `.md`
5
+ * link a page carries. Absent: the contents, every page with its path and title.
6
+ */
7
+ path?: string | null;
8
+ };
9
+ /** What `docs_read` returns. */
10
+ export type DocsReadOut = string;
11
+ /** Arguments of `history_search`. */
12
+ export type HistorySearchArgs = {
13
+ /** Author or its start: `owner`, `agent:` (every agent), `agent:<name>`. */
14
+ author?: string | null;
15
+ /** What to return. Default: tasks, sessions and calls. */
16
+ kind?: HistoryKind[] | null;
17
+ /** At most this many of each kind, newest first (default 50, at most 200). */
18
+ limit?: number | null;
19
+ /** Only this machine (name or id). */
20
+ machine?: string | null;
21
+ /** Started (sessions: last changed) at or after this time, unix seconds. */
22
+ since?: number | null;
23
+ /** Only this task (its row and the calls that started or named it; no sessions). */
24
+ task?: number | null;
25
+ /**
26
+ * Text, any case. Tasks: the command, the folder or the error (another author's only for an
27
+ * agent granted exec). Sessions: path, id, folder. Calls: the tool name.
28
+ */
29
+ text?: string | null;
30
+ /** Started (sessions: last changed) before this time, unix seconds. */
31
+ until?: number | null;
32
+ };
33
+ /** What `history_search` returns. */
34
+ export type HistorySearchOut = {
35
+ /**
36
+ * Only calls the server could read: calls from a paired client, encrypted end to end, are
37
+ * left out.
38
+ */
39
+ calls?: CallView[] | null;
40
+ /** Absent when `task` was given: a task has no sessions. */
41
+ sessions?: SessionView[] | null;
42
+ tasks?: ShownTask[] | null;
43
+ };
44
+ /** Arguments of `machines_list`. No arguments. */
45
+ export type MachinesListArgs = Record<string, never>;
46
+ /** What `machines_list` returns. */
47
+ export type MachinesListOut = MachineRow[];
48
+ /** Arguments of `showtime_guide`. */
49
+ export type ShowtimeGuideArgs = {
50
+ /** The language to speak to the user in, e.g. "Russian" or "de". Default: the user's. */
51
+ language?: string | null;
52
+ /** The stage machine's OS (`sys_info` `os`). Default: the notes for every OS. */
53
+ os?: Os | null;
54
+ };
55
+ /** What `showtime_guide` returns. */
56
+ export type ShowtimeGuideOut = string;
57
+ /** Arguments of `tasks_list`. */
58
+ export type TasksListArgs = {
59
+ /** Only this machine (name or id). Default: all machines. */
60
+ machine?: string | null;
61
+ };
62
+ /** What `tasks_list` returns. */
63
+ export type TasksListOut = {
64
+ /** Other processes on each online machine (`proc_list` there), by who started them. */
65
+ outside: Picture[];
66
+ /** Tasks started through cmdop that still run. */
67
+ tasks: ShownTask[];
68
+ };
69
+ export type CallView = {
70
+ author: string;
71
+ id: number;
72
+ machine: string;
73
+ machine_name: string;
74
+ ms?: number | null;
75
+ /**
76
+ * `ok`, an error code, `cancelled` (the caller went away first) or `interrupted` (the
77
+ * server stopped first); none while it runs.
78
+ */
79
+ outcome?: string | null;
80
+ /**
81
+ * The caller was refused (the grant, an OS permission or the app list said no), as opposed
82
+ * to the tool failing.
83
+ */
84
+ refused: boolean;
85
+ /**
86
+ * Sealed end to end: the server never saw its arguments or answer. False for MCP
87
+ * and the page, whose calls pass through the server in clear.
88
+ */
89
+ sealed: boolean;
90
+ started: number;
91
+ /**
92
+ * The task the call started (`task_start`) or named (a plain `task_output` / `task_stop`);
93
+ * none for other tools and for a sealed call that names a task.
94
+ */
95
+ task?: number | null;
96
+ /** The token that made the call: an agent's id on `/api/agents`, or the owner's token. */
97
+ token: number;
98
+ tool: string;
99
+ };
100
+ /** What `history_search` returns. */
101
+ export type HistoryKind = "tasks" | "sessions" | "calls";
102
+ /** One row of `machines_list`: the machine as `/api/v1/machines` shows it, and its activity. */
103
+ export type MachineRow = {
104
+ /** The last 7 days' counts; absent when the server's store could not count them. */
105
+ activity?: Activity | null;
106
+ arch: string;
107
+ /**
108
+ * Whether a newer CMDOP release than `program` is published. Null when this server cannot
109
+ * say (it does not follow releases, as a self-hosted server may not) or `program` is not a
110
+ * release version.
111
+ */
112
+ behind?: boolean | null;
113
+ /**
114
+ * The machine's key for sealed calls. A client trusts it only with `box_sig`, checked
115
+ * against the machine id it pinned.
116
+ */
117
+ box_key?: string | null;
118
+ box_sig?: string | null;
119
+ /**
120
+ * The commit its program was built from (12 hex digits), as it said on its current or last
121
+ * link since the server started; null from an older program or before it dialled in.
122
+ */
123
+ commit?: string | null;
124
+ /**
125
+ * Its program had changes not in `commit` (a developer's build). Not required in the
126
+ * document, so a client also reads a row from an older server, which sends none.
127
+ */
128
+ dirty: boolean;
129
+ epoch: number;
130
+ id: string;
131
+ /** The name its owner gave it on the page; null when none, and `name` is `own_name`. */
132
+ label?: string | null;
133
+ /** Unix seconds of the last message from the machine. */
134
+ last_seen: number;
135
+ /** What to call it: the name its owner gave it on the page, else the machine's own. */
136
+ name: string;
137
+ /**
138
+ * The newest published CMDOP release this server knows, `0.1.10`; null when it knows none.
139
+ * The same on every row.
140
+ */
141
+ newest_release?: string | null;
142
+ /**
143
+ * It has a live link (it may still be `stale` or `paused`; `state` says whether it can
144
+ * take a call).
145
+ */
146
+ online: boolean;
147
+ os: string;
148
+ /** The name the machine gives itself (`machine.json` `name`), from its last `Hello`. */
149
+ own_name: string;
150
+ /**
151
+ * Whether its owner paused it (no tool runs there), as the machine reported on its live
152
+ * link; null while it is offline, or when its program is too old to report.
153
+ */
154
+ paused?: boolean | null;
155
+ program: string;
156
+ /** Unix seconds: when the current link came up, or when the machine was last seen. */
157
+ since: number;
158
+ /**
159
+ * Whether it can take a call now: `online`, `stale`, `offline` or `paused`. Only `online`
160
+ * takes calls; for any other, tell the user instead of retrying.
161
+ */
162
+ state: Presence;
163
+ /** Tools the machine runs, as it announced them on its current or last link. */
164
+ tools: string[];
165
+ /**
166
+ * Risk classes a call from the page or MCP may use on this machine: what its own ceiling
167
+ * allows, which no agent's grant can exceed. As the machine reported on its live link; null
168
+ * while it is offline, or when its program is too old to report.
169
+ */
170
+ unpaired_risks?: string[] | null;
171
+ };
172
+ /** The operating systems with notes. Windows has none until it has a machine program (V4). */
173
+ export type Os = "macos" | "linux";
174
+ /** One machine's picture, or why there is none. */
175
+ export type Picture = {
176
+ error?: string | null;
177
+ machine: string;
178
+ machine_name: string;
179
+ /** Processes of "the machine itself" (apps, daemons), only counted. */
180
+ others: number;
181
+ procs: ProcView[];
182
+ };
183
+ /** A kept vendor session file, or a run of the agent dock (`dock` set), as history shows it. */
184
+ export type SessionView = {
185
+ author: string;
186
+ cwd?: string | null;
187
+ /** Set when this row is a dock run, not a vendor file. */
188
+ dock?: DockRunView | null;
189
+ gone: boolean;
190
+ kept: boolean;
191
+ machine: string;
192
+ machine_name: string;
193
+ modified: number;
194
+ path: string;
195
+ session: string;
196
+ size: number;
197
+ vendor: string;
198
+ };
199
+ /** A task as the caller may see it. */
200
+ export type ShownTask = {
201
+ argv?: string[];
202
+ author: string;
203
+ code?: number | null;
204
+ created: number;
205
+ cwd?: string | null;
206
+ ended?: number | null;
207
+ error?: string | null;
208
+ hidden?: string | null;
209
+ id: number;
210
+ machine: string;
211
+ machine_name: string;
212
+ pid?: number | null;
213
+ /**
214
+ * Started by a call from a paired client, encrypted end to end: the server never saw the
215
+ * command, so `argv` is empty.
216
+ */
217
+ sealed: boolean;
218
+ signal?: number | null;
219
+ state: TaskState;
220
+ };
221
+ export type Activity = {
222
+ /**
223
+ * Tool calls the server could read made to it since `since`; calls from a paired client,
224
+ * encrypted end to end, are not counted.
225
+ */
226
+ calls: number;
227
+ /** Unix seconds. */
228
+ since: number;
229
+ /** Tasks started on the machine since `since`. */
230
+ tasks: number;
231
+ };
232
+ /**
233
+ * A run of the owner's agent dock on that machine (persistent context S4), from the app's
234
+ * `dock.log`: start, stop and exit only, never keystrokes or output.
235
+ */
236
+ export type DockRunView = {
237
+ /** Unix milliseconds; absent while it runs, or when the app quit first (`exit` is `lost`). */
238
+ ended?: number | null;
239
+ /** The exit code, `signal`, or `lost`. */
240
+ exit?: string | null;
241
+ /** Unix milliseconds. */
242
+ started: number;
243
+ };
244
+ /**
245
+ * Whether a machine can take a call now, the one answer the page, the app, MCP, the SDK and the
246
+ * refusals give (machine-presence V1). It is derived from the time of the machine's last
247
+ * envelope, never from WebSocket control frames, so a proxy that pings cannot keep a gone
248
+ * machine looking alive.
249
+ */
250
+ export type Presence = "online" | "stale" | "offline" | "paused";
251
+ /** A process cmdop did not start, with who did. */
252
+ export type ProcView = {
253
+ argv: string[];
254
+ author: string;
255
+ cwd?: string | null;
256
+ machine: string;
257
+ machine_name: string;
258
+ pid: number;
259
+ started: number;
260
+ };
261
+ /** Where a task is in its life. The store keeps it as text (`cmdop-store` writes only these five). */
262
+ export type TaskState = "running" | "starting" | "ended" | "failed" | "lost";
263
+ /** Every tool the server answers itself: its arguments and its result. */
264
+ export interface ServerToolMap {
265
+ docs_read: {
266
+ args: DocsReadArgs;
267
+ out: DocsReadOut;
268
+ };
269
+ history_search: {
270
+ args: HistorySearchArgs;
271
+ out: HistorySearchOut;
272
+ };
273
+ machines_list: {
274
+ args: MachinesListArgs;
275
+ out: MachinesListOut;
276
+ };
277
+ showtime_guide: {
278
+ args: ShowtimeGuideArgs;
279
+ out: ShowtimeGuideOut;
280
+ };
281
+ tasks_list: {
282
+ args: TasksListArgs;
283
+ out: TasksListOut;
284
+ };
285
+ }
286
+ export type ServerToolName = keyof ServerToolMap;
287
+ /** Title and description of every server tool, as the server lists them. */
288
+ export declare const SERVER_TOOLS: {
289
+ readonly docs_read: {
290
+ readonly title: "Read the docs";
291
+ readonly description: "Call before answering how CMDOP works, is set up or is priced: no `path` lists every page of docs.cmdop.ai (path and title); a `path` returns that page as Markdown.";
292
+ };
293
+ readonly history_search: {
294
+ readonly title: "Search history";
295
+ readonly description: "Past tasks, tool calls and agent sessions by machine, author, task, time and text, newest first. Calls carry no arguments; journal_search on the machine has them.";
296
+ };
297
+ readonly machines_list: {
298
+ readonly title: "List machines";
299
+ readonly description: "The owner's machines: name, id, `state` (online; stale = not answering; paused; offline), `last_seen`, `activity`, `tools` (screen and control are here), build, `behind`. Only online ones take calls.";
300
+ };
301
+ readonly showtime_guide: {
302
+ readonly title: "Showtime guide";
303
+ readonly description: "Call when the user asks to see what CMDOP can do (a demo or a show), or offer it to a user new to CMDOP: returns a guide for a short live demonstration on their machines.";
304
+ };
305
+ readonly tasks_list: {
306
+ readonly title: "List running work";
307
+ readonly description: "Everything running now, by author. `tasks`: started through cmdop. `outside`: other processes per machine, by agent:claude-code, agent:codex or user. Ended ones: history_search.";
308
+ };
309
+ };
310
+ export declare const SERVER_TOOL_NAMES: readonly ["docs_read", "history_search", "machines_list", "showtime_guide", "tasks_list"];
311
+ /** The server tools as client methods (`cmdop.showtime_guide()`): no machine, never sealed. */
312
+ export interface ServerMethods<O> {
313
+ /** Call before answering how CMDOP works, is set up or is priced: no `path` lists every page of docs.cmdop.ai (path and title); a `path` returns that page as Markdown. */
314
+ docs_read(args?: DocsReadArgs, opts?: O): Promise<DocsReadOut>;
315
+ /** Past tasks, tool calls and agent sessions by machine, author, task, time and text, newest first. Calls carry no arguments; journal_search on the machine has them. */
316
+ history_search(args?: HistorySearchArgs, opts?: O): Promise<HistorySearchOut>;
317
+ /** The owner's machines: name, id, `state` (online; stale = not answering; paused; offline), `last_seen`, `activity`, `tools` (screen and control are here), build, `behind`. Only online ones take calls. */
318
+ machines_list(args?: MachinesListArgs, opts?: O): Promise<MachinesListOut>;
319
+ /** Call when the user asks to see what CMDOP can do (a demo or a show), or offer it to a user new to CMDOP: returns a guide for a short live demonstration on their machines. */
320
+ showtime_guide(args?: ShowtimeGuideArgs, opts?: O): Promise<ShowtimeGuideOut>;
321
+ /** Everything running now, by author. `tasks`: started through cmdop. `outside`: other processes per machine, by agent:claude-code, agent:codex or user. Ended ones: history_search. */
322
+ tasks_list(args?: TasksListArgs, opts?: O): Promise<TasksListOut>;
323
+ }
@@ -0,0 +1,10 @@
1
+ // Generated from cmdop/crates/tools/tools.schema.json (sha256 53ac9daa3bb73c83, cmdop 0.1.11) by exports/sdk/gen/gen.ts. Do not edit.
2
+ /** Title and description of every server tool, as the server lists them. */
3
+ export const SERVER_TOOLS = {
4
+ docs_read: { title: "Read the docs", description: "Call before answering how CMDOP works, is set up or is priced: no `path` lists every page of docs.cmdop.ai (path and title); a `path` returns that page as Markdown." },
5
+ history_search: { title: "Search history", description: "Past tasks, tool calls and agent sessions by machine, author, task, time and text, newest first. Calls carry no arguments; journal_search on the machine has them." },
6
+ machines_list: { title: "List machines", description: "The owner's machines: name, id, `state` (online; stale = not answering; paused; offline), `last_seen`, `activity`, `tools` (screen and control are here), build, `behind`. Only online ones take calls." },
7
+ showtime_guide: { title: "Showtime guide", description: "Call when the user asks to see what CMDOP can do (a demo or a show), or offer it to a user new to CMDOP: returns a guide for a short live demonstration on their machines." },
8
+ tasks_list: { title: "List running work", description: "Everything running now, by author. `tasks`: started through cmdop. `outside`: other processes per machine, by agent:claude-code, agent:codex or user. Ended ones: history_search." },
9
+ };
10
+ export const SERVER_TOOL_NAMES = ["docs_read", "history_search", "machines_list", "showtime_guide", "tasks_list"];
@@ -1,4 +1,4 @@
1
- // Generated from cmdop/crates/tools/tools.schema.json (sha256 72ba780fabadfafb, cmdop 0.1.10) by exports/sdk/gen/gen.ts. Do not edit.
1
+ // Generated from cmdop/crates/tools/tools.schema.json (sha256 53ac9daa3bb73c83, cmdop 0.1.11) by exports/sdk/gen/gen.ts. Do not edit.
2
2
  /** Group, then method, then the tool it calls. */
3
3
  export const GROUPS = {
4
4
  app: { open: "app_open" },
@@ -1,4 +1,4 @@
1
- // Generated from cmdop/crates/tools/tools.schema.json (sha256 72ba780fabadfafb, cmdop 0.1.10) by exports/sdk/gen/gen.ts. Do not edit.
1
+ // Generated from cmdop/crates/tools/tools.schema.json (sha256 53ac9daa3bb73c83, cmdop 0.1.11) by exports/sdk/gen/gen.ts. Do not edit.
2
2
  /** Risk class, version and description of every tool, as the server lists them. */
3
3
  export const TOOLS = {
4
4
  app_open: { risk: "control", added: "0.0.2", timeoutSecs: 30, description: "Launch or focus an app, or open a file in it. The app has to be allowed for `control` on this machine. Opens in the background unless `background` is false." },
package/dist/index.d.ts CHANGED
@@ -5,5 +5,6 @@ export { memoryCarrier, type MemoryDoor } from "./carriers/memory.ts";
5
5
  export * from "./generated/tools.gen.ts";
6
6
  export * from "./generated/call.gen.ts";
7
7
  export { GROUPS, type GroupName } from "./generated/surface.gen.ts";
8
+ export { SERVER_TOOLS, SERVER_TOOL_NAMES, type ServerToolMap, type ServerToolName } from "./generated/server.gen.ts";
8
9
  export { decodeImage, toScreenshot, type DecodedImage, type Screenshot } from "./screen.ts";
9
10
  export { anthropicToCalls, openaiToCalls, performCalls, UnsupportedAction, type Step, type VendorOptions } from "./vendor.ts";
package/dist/index.js CHANGED
@@ -5,5 +5,6 @@ export { memoryCarrier } from "./carriers/memory.js";
5
5
  export * from "./generated/tools.gen.js";
6
6
  export * from "./generated/call.gen.js";
7
7
  export { GROUPS } from "./generated/surface.gen.js";
8
+ export { SERVER_TOOLS, SERVER_TOOL_NAMES } from "./generated/server.gen.js";
8
9
  export { decodeImage, toScreenshot } from "./screen.js";
9
10
  export { anthropicToCalls, openaiToCalls, performCalls, UnsupportedAction } from "./vendor.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmdop/sdk",
3
- "version": "3.1.0",
3
+ "version": "3.3.0",
4
4
  "description": "Your machines' tools from a program: the same tools agents use through MCP, typed from Rust.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://cmdop.ai",