taskmaster-api 0.1.0 → 0.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
@@ -1,27 +1,45 @@
1
1
  # taskmaster-api
2
2
 
3
- Client for a [Taskmaster](https://github.com/narensen/Taskmaster) daemon running on your machine.
3
+ Client for the [Taskmaster](https://github.com/narensen/Taskmaster) Computer agent running on your machine.
4
4
 
5
- `tm serve .` listens on `http://127.0.0.1:8737`. `GET /api/health` and `POST /api/pair` need no token. Every other `/api` route needs `Authorization: Bearer <token>`.
5
+ `tm serve .` listens on `http://127.0.0.1:8737`. Pair first. Computer stays off until `computerEnable(true)`.
6
6
 
7
7
  ```js
8
8
  import { Taskmaster } from "taskmaster-api";
9
9
 
10
10
  const tm = new Taskmaster();
11
11
  tm.setToken(await tm.pair("ABCD", { label: "laptop", kind: "agent" }));
12
+ await tm.computerEnable(true);
12
13
 
13
- const accepted = await tm.start({ prompt: "Add a command palette", yes: true });
14
- const page = await tm.events(accepted.id);
15
- console.log(page.next);
14
+ const session = await tm.computerStart("Open Chrome and search for the weather");
15
+ await tm.computerResume(session.id, "Read the first forecast");
16
+ await tm.computerCancel(session.id);
16
17
  ```
17
18
 
18
- `0.1.0` covers health, pairing, projects, providers, doctor, and the run lifecycle: list, get, start, approve, reject, resume, cancel, undo, and events. `call(method, path, body)` sends any other route and returns the JSON body.
19
+ `computerAct` sends one action on the 0–1000 screen grid. `computerMode("virtual")` aims the agent at the isolated desktop.
19
20
 
20
21
  ```js
21
- const doctor = await tm.doctor();
22
- const dictionary = await tm.call("GET", "/api/dictionary?q=button");
22
+ const acted = await tm.computerAct("click_text", { text: "Search" });
23
+ console.log(acted.result);
23
24
  ```
24
25
 
25
- Requires Node 18 or newer (uses `fetch`). The same client is published for Rust (`cargo add taskmaster-api`) and Python (`pip install taskmaster-api`).
26
+ Connect a provider, save an MCP server, or start a deck. `builtinMcpUrl()` is the daemon's own `/mcp`, which already has Computer and the document tools.
27
+
28
+ ```js
29
+ await tm.connectProvider("grok");
30
+ await tm.connectProvider("openrouter", "sk-...");
31
+ await tm.connectMcp({
32
+ name: "linear",
33
+ command: "npx",
34
+ args: ["-y", "mcp-remote"],
35
+ secret_env: { LINEAR_API_KEY: "..." },
36
+ });
37
+ const deck = await tm.makePptx("Q4 plan", "Three slides: goal, plan, ask");
38
+ console.log(await tm.docs());
39
+ ```
40
+
41
+ Requires Node 18 or newer. Coding-run methods (`start`, `approve`, `events`) remain. `call(method, path, body)` sends any other route.
42
+
43
+ The same client is published for Rust (`cargo add taskmaster-api`) and Python (`pip install taskmaster-api`).
26
44
 
27
45
  MIT © 2026 Naren Sengodan
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  /** Daemon address when `tm serve` is started with no bind flag. */
8
8
  export declare const DEFAULT_BASE_URL = "http://127.0.0.1:8737";
9
9
  /** Package version. Independent of the Taskmaster app version. */
10
- export declare const VERSION = "0.1.0";
10
+ export declare const VERSION = "0.3.0";
11
11
  /** The daemon refused the request, or the response was not usable JSON. `status` is `0` when no HTTP response arrived. */
12
12
  export declare class TaskmasterError extends Error {
13
13
  readonly status: number;
@@ -101,6 +101,102 @@ export interface StartRun {
101
101
  goal_max_turns?: number;
102
102
  computer_use?: boolean;
103
103
  }
104
+ /** `GET /api/computer/status` and the toggle and mode replies. */
105
+ export interface ComputerStatus {
106
+ enabled: boolean;
107
+ /** `host` or `virtual`. */
108
+ mode?: string;
109
+ display?: string | null;
110
+ screenshot_backend?: string | null;
111
+ pointer_backend?: string | null;
112
+ keyboard_backend?: string | null;
113
+ install_hint?: string | null;
114
+ [key: string]: unknown;
115
+ }
116
+ /** A screen frame. `data` is base64 PNG bytes. */
117
+ export interface ComputerScreen {
118
+ mime: string;
119
+ data?: string;
120
+ info?: string;
121
+ hash?: string;
122
+ unchanged?: boolean;
123
+ }
124
+ /** One row from `GET /api/computer/sessions`. */
125
+ export interface ComputerSessionSummary {
126
+ id: string;
127
+ task: string;
128
+ status?: string;
129
+ harness?: string | null;
130
+ model?: string | null;
131
+ step_count?: number;
132
+ agent_count?: number;
133
+ error?: string | null;
134
+ [key: string]: unknown;
135
+ }
136
+ /** A Computer agent session. */
137
+ export interface ComputerSession {
138
+ id: string;
139
+ task: string;
140
+ status?: string;
141
+ harness?: string | null;
142
+ model?: string | null;
143
+ final_reply?: string;
144
+ stream_text?: string | null;
145
+ error?: string | null;
146
+ handoff?: unknown;
147
+ latest_screen?: ComputerScreen | null;
148
+ [key: string]: unknown;
149
+ }
150
+ /** Body of `POST /api/computer/sessions`. */
151
+ export interface ComputerTask {
152
+ task: string;
153
+ bot_id?: string;
154
+ harness?: string;
155
+ model?: string;
156
+ parent_session_id?: string;
157
+ attachments?: string[];
158
+ }
159
+ /** `POST /api/computer/act`. */
160
+ export interface ComputerActResult {
161
+ ok: boolean;
162
+ result: string;
163
+ screen?: ComputerScreen;
164
+ }
165
+ /** One user MCP server from `GET /api/mcp`. Secrets are not returned; only their names are. */
166
+ export interface McpServer {
167
+ name: string;
168
+ command: string;
169
+ args?: string[];
170
+ env?: Record<string, string>;
171
+ secret_env_keys?: string[];
172
+ roles?: string[];
173
+ enabled?: boolean;
174
+ require_approval?: boolean;
175
+ [key: string]: unknown;
176
+ }
177
+ /** Body of `POST /api/mcp`. Adds or replaces a user MCP server. */
178
+ export interface McpConnect {
179
+ name: string;
180
+ command: string;
181
+ args?: string[];
182
+ env?: Record<string, string>;
183
+ /** Secret values. The daemon stores them and does not echo them. */
184
+ secret_env?: Record<string, string>;
185
+ roles?: string[];
186
+ enabled?: boolean;
187
+ require_approval?: boolean;
188
+ }
189
+ /** A document from `GET /api/computer/docs`. */
190
+ export interface Doc {
191
+ id: string;
192
+ filename?: string;
193
+ kind?: string;
194
+ title?: string;
195
+ path?: string;
196
+ download_url?: string;
197
+ page_count?: number;
198
+ [key: string]: unknown;
199
+ }
104
200
  /**
105
201
  * HTTP client for one Taskmaster daemon.
106
202
  * A token set here is sent on every request.
@@ -125,6 +221,66 @@ export declare class Taskmaster {
125
221
  label?: string;
126
222
  kind?: string;
127
223
  }): Promise<string>;
224
+ /** `GET /api/computer/status`. */
225
+ computerStatus(): Promise<ComputerStatus>;
226
+ /** `POST /api/computer/toggle`. Turns Local computer use on or off. */
227
+ computerEnable(enabled: boolean): Promise<ComputerStatus>;
228
+ /** `POST /api/computer/mode`. `mode` is `host` or `virtual`. */
229
+ computerMode(mode: "host" | "virtual"): Promise<ComputerStatus>;
230
+ /** `GET /api/computer/sessions`. */
231
+ computerSessions(): Promise<ComputerSessionSummary[]>;
232
+ /** `POST /api/computer/sessions`. Starts the Computer agent. */
233
+ computerStart(task: ComputerTask | string): Promise<ComputerSession>;
234
+ /** `GET /api/computer/sessions/{id}`. */
235
+ computerSession(id: string): Promise<ComputerSession>;
236
+ /** `POST /api/computer/sessions/{id}/resume`. `note` is the next instruction. */
237
+ computerResume(id: string, note?: string): Promise<ComputerSession>;
238
+ /** `POST /api/computer/sessions/{id}/cancel`. Stops the agent. */
239
+ computerCancel(id: string): Promise<unknown>;
240
+ /** `POST /api/computer/screen`. */
241
+ computerScreen(): Promise<ComputerScreen>;
242
+ /**
243
+ * `POST /api/computer/act`.
244
+ * `action` is `click`, `click_text`, `type`, `press`, `open_url`, `open_app`, and the other names the daemon accepts.
245
+ * Coordinates are a 0–1000 grid.
246
+ */
247
+ computerAct(action: string, args?: Record<string, unknown>): Promise<ComputerActResult>;
248
+ /** `GET /api/computer/routines`. */
249
+ computerRoutines(): Promise<unknown>;
250
+ /** `POST /api/computer/routines/{id}/run`. */
251
+ computerRunRoutine(id: string): Promise<unknown>;
252
+ /**
253
+ * URL of the daemon's own MCP endpoint.
254
+ * Agents already get this server. It carries the dictionary, Computer, and the document tools.
255
+ */
256
+ builtinMcpUrl(): string;
257
+ /** `GET /api/mcp`. User MCP servers saved for this project. */
258
+ mcpServers(): Promise<McpServer[]>;
259
+ /** `POST /api/mcp`. Adds or replaces a user MCP server. */
260
+ connectMcp(server: McpConnect): Promise<McpServer>;
261
+ /** `POST /api/mcp/{name}/remove`. */
262
+ disconnectMcp(name: string): Promise<unknown>;
263
+ /** `GET /api/computer/docs`. */
264
+ docs(): Promise<Doc[]>;
265
+ /** `GET /api/computer/docs/{id}`. */
266
+ doc(id: string): Promise<Doc>;
267
+ /** `POST /api/computer/files`. `dataBase64` is the file bytes. */
268
+ uploadDoc(name: string, dataBase64: string): Promise<Doc>;
269
+ /** `POST /api/computer/docs/{id}/open`. Opens the file in the host's default app. */
270
+ openDoc(id: string): Promise<unknown>;
271
+ /** Starts a Computer session that builds a PowerPoint with `doc_create_pptx`. */
272
+ makePptx(title: string, brief?: string): Promise<ComputerSession>;
273
+ /** Starts a Computer session that builds a Word document with `doc_create_docx`. */
274
+ makeDocx(title: string, brief?: string): Promise<ComputerSession>;
275
+ /** `GET /api/setup`. Each provider's install and sign-in state, plus runtimes and jobs. */
276
+ setup(): Promise<unknown>;
277
+ /**
278
+ * Connect a provider in one call.
279
+ * An API key is saved for a provider that uses one (`openrouter`). Otherwise this installs
280
+ * the CLI when it is missing, or starts its sign-in when it is already installed.
281
+ * A provider that is installed and signed in returns `{ok:true, connected:true}`.
282
+ */
283
+ connectProvider(id: string, apiKey?: string): Promise<unknown>;
128
284
  /** `GET /api/runs`. */
129
285
  runs(): Promise<RunList>;
130
286
  /** `GET /api/runs?since=`. `since` is a previous {@link RunList.seq}. */
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  /** Daemon address when `tm serve` is started with no bind flag. */
8
8
  export const DEFAULT_BASE_URL = "http://127.0.0.1:8737";
9
9
  /** Package version. Independent of the Taskmaster app version. */
10
- export const VERSION = "0.1.0";
10
+ export const VERSION = "0.3.0";
11
11
  /** The daemon refused the request, or the response was not usable JSON. `status` is `0` when no HTTP response arrived. */
12
12
  export class TaskmasterError extends Error {
13
13
  status;
@@ -67,6 +67,147 @@ export class Taskmaster {
67
67
  }
68
68
  return parsed.token;
69
69
  }
70
+ /** `GET /api/computer/status`. */
71
+ computerStatus() {
72
+ return this.call("GET", "/api/computer/status");
73
+ }
74
+ /** `POST /api/computer/toggle`. Turns Local computer use on or off. */
75
+ computerEnable(enabled) {
76
+ return this.call("POST", "/api/computer/toggle", { enabled });
77
+ }
78
+ /** `POST /api/computer/mode`. `mode` is `host` or `virtual`. */
79
+ computerMode(mode) {
80
+ return this.call("POST", "/api/computer/mode", { mode });
81
+ }
82
+ /** `GET /api/computer/sessions`. */
83
+ async computerSessions() {
84
+ const listed = (await this.call("GET", "/api/computer/sessions"));
85
+ return listed.sessions ?? [];
86
+ }
87
+ /** `POST /api/computer/sessions`. Starts the Computer agent. */
88
+ computerStart(task) {
89
+ const body = typeof task === "string" ? { task } : task;
90
+ return this.call("POST", "/api/computer/sessions", body);
91
+ }
92
+ /** `GET /api/computer/sessions/{id}`. */
93
+ computerSession(id) {
94
+ return this.call("GET", `/api/computer/sessions/${encodeURIComponent(id)}`);
95
+ }
96
+ /** `POST /api/computer/sessions/{id}/resume`. `note` is the next instruction. */
97
+ computerResume(id, note) {
98
+ const body = note ? { note } : {};
99
+ return this.call("POST", `/api/computer/sessions/${encodeURIComponent(id)}/resume`, body);
100
+ }
101
+ /** `POST /api/computer/sessions/{id}/cancel`. Stops the agent. */
102
+ computerCancel(id) {
103
+ return this.call("POST", `/api/computer/sessions/${encodeURIComponent(id)}/cancel`, {});
104
+ }
105
+ /** `POST /api/computer/screen`. */
106
+ computerScreen() {
107
+ return this.call("POST", "/api/computer/screen", {});
108
+ }
109
+ /**
110
+ * `POST /api/computer/act`.
111
+ * `action` is `click`, `click_text`, `type`, `press`, `open_url`, `open_app`, and the other names the daemon accepts.
112
+ * Coordinates are a 0–1000 grid.
113
+ */
114
+ computerAct(action, args = {}) {
115
+ return this.call("POST", "/api/computer/act", { ...args, action });
116
+ }
117
+ /** `GET /api/computer/routines`. */
118
+ computerRoutines() {
119
+ return this.call("GET", "/api/computer/routines");
120
+ }
121
+ /** `POST /api/computer/routines/{id}/run`. */
122
+ computerRunRoutine(id) {
123
+ return this.call("POST", `/api/computer/routines/${encodeURIComponent(id)}/run`, {});
124
+ }
125
+ /**
126
+ * URL of the daemon's own MCP endpoint.
127
+ * Agents already get this server. It carries the dictionary, Computer, and the document tools.
128
+ */
129
+ builtinMcpUrl() {
130
+ return `${this.baseUrl}/mcp`;
131
+ }
132
+ /** `GET /api/mcp`. User MCP servers saved for this project. */
133
+ async mcpServers() {
134
+ const listed = (await this.call("GET", "/api/mcp"));
135
+ return listed.servers ?? [];
136
+ }
137
+ /** `POST /api/mcp`. Adds or replaces a user MCP server. */
138
+ async connectMcp(server) {
139
+ const body = { name: server.name, command: server.command };
140
+ if (server.args?.length)
141
+ body.args = server.args;
142
+ if (server.env && Object.keys(server.env).length > 0)
143
+ body.env = server.env;
144
+ if (server.secret_env && Object.keys(server.secret_env).length > 0)
145
+ body.secret_env = server.secret_env;
146
+ if (server.roles?.length)
147
+ body.roles = server.roles;
148
+ if (server.enabled !== undefined)
149
+ body.enabled = server.enabled;
150
+ if (server.require_approval !== undefined)
151
+ body.require_approval = server.require_approval;
152
+ const saved = (await this.call("POST", "/api/mcp", body));
153
+ if (!saved?.server || typeof saved.server.name !== "string") {
154
+ throw new TaskmasterError(0, "mcp response had no server");
155
+ }
156
+ return saved.server;
157
+ }
158
+ /** `POST /api/mcp/{name}/remove`. */
159
+ disconnectMcp(name) {
160
+ return this.call("POST", `/api/mcp/${encodeURIComponent(name)}/remove`, {});
161
+ }
162
+ /** `GET /api/computer/docs`. */
163
+ async docs() {
164
+ const listed = (await this.call("GET", "/api/computer/docs"));
165
+ return listed.docs ?? [];
166
+ }
167
+ /** `GET /api/computer/docs/{id}`. */
168
+ doc(id) {
169
+ return this.call("GET", `/api/computer/docs/${encodeURIComponent(id)}`);
170
+ }
171
+ /** `POST /api/computer/files`. `dataBase64` is the file bytes. */
172
+ uploadDoc(name, dataBase64) {
173
+ return this.call("POST", "/api/computer/files", { name, data_base64: dataBase64 });
174
+ }
175
+ /** `POST /api/computer/docs/{id}/open`. Opens the file in the host's default app. */
176
+ openDoc(id) {
177
+ return this.call("POST", `/api/computer/docs/${encodeURIComponent(id)}/open`, {});
178
+ }
179
+ /** Starts a Computer session that builds a PowerPoint with `doc_create_pptx`. */
180
+ makePptx(title, brief) {
181
+ return this.computerStart(documentTask("PowerPoint", "doc_create_pptx", title, brief));
182
+ }
183
+ /** Starts a Computer session that builds a Word document with `doc_create_docx`. */
184
+ makeDocx(title, brief) {
185
+ return this.computerStart(documentTask("Word document", "doc_create_docx", title, brief));
186
+ }
187
+ /** `GET /api/setup`. Each provider's install and sign-in state, plus runtimes and jobs. */
188
+ setup() {
189
+ return this.call("GET", "/api/setup");
190
+ }
191
+ /**
192
+ * Connect a provider in one call.
193
+ * An API key is saved for a provider that uses one (`openrouter`). Otherwise this installs
194
+ * the CLI when it is missing, or starts its sign-in when it is already installed.
195
+ * A provider that is installed and signed in returns `{ok:true, connected:true}`.
196
+ */
197
+ async connectProvider(id, apiKey) {
198
+ const encoded = encodeURIComponent(id);
199
+ if (apiKey !== undefined) {
200
+ return this.call("POST", `/api/setup/providers/${encoded}/key`, { api_key: apiKey });
201
+ }
202
+ const setup = (await this.setup());
203
+ const provider = setup.providers?.find((item) => item.id === id);
204
+ const installed = provider?.installed === true;
205
+ const signedIn = provider?.signed_in === true;
206
+ if (installed && signedIn)
207
+ return { ok: true, connected: true, id };
208
+ const action = installed ? "login" : "install";
209
+ return this.call("POST", `/api/setup/providers/${encoded}/${action}`, {});
210
+ }
70
211
  /** `GET /api/runs`. */
71
212
  runs() {
72
213
  return this.call("GET", "/api/runs");
@@ -173,3 +314,9 @@ export class Taskmaster {
173
314
  return parsed;
174
315
  }
175
316
  }
317
+ function documentTask(kind, tool, title, brief) {
318
+ let task = `Make a ${kind} with ${tool}. Title: ${title}. Use one cohesive theme on every page.`;
319
+ if (brief)
320
+ task += ` ${brief}`;
321
+ return task;
322
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "taskmaster-api",
3
- "version": "0.1.0",
4
- "description": "Client for the Taskmaster local daemon HTTP API",
3
+ "version": "0.3.0",
4
+ "description": "Client for the Taskmaster Computer agent",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",