taskmaster-api 0.2.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
@@ -23,6 +23,21 @@ const acted = await tm.computerAct("click_text", { text: "Search" });
23
23
  console.log(acted.result);
24
24
  ```
25
25
 
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
+
26
41
  Requires Node 18 or newer. Coding-run methods (`start`, `approve`, `events`) remain. `call(method, path, body)` sends any other route.
27
42
 
28
43
  The same client is published for Rust (`cargo add taskmaster-api`) and Python (`pip install taskmaster-api`).
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.2.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;
@@ -162,6 +162,41 @@ export interface ComputerActResult {
162
162
  result: string;
163
163
  screen?: ComputerScreen;
164
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
+ }
165
200
  /**
166
201
  * HTTP client for one Taskmaster daemon.
167
202
  * A token set here is sent on every request.
@@ -214,6 +249,38 @@ export declare class Taskmaster {
214
249
  computerRoutines(): Promise<unknown>;
215
250
  /** `POST /api/computer/routines/{id}/run`. */
216
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>;
217
284
  /** `GET /api/runs`. */
218
285
  runs(): Promise<RunList>;
219
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.2.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;
@@ -122,6 +122,92 @@ export class Taskmaster {
122
122
  computerRunRoutine(id) {
123
123
  return this.call("POST", `/api/computer/routines/${encodeURIComponent(id)}/run`, {});
124
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
+ }
125
211
  /** `GET /api/runs`. */
126
212
  runs() {
127
213
  return this.call("GET", "/api/runs");
@@ -228,3 +314,9 @@ export class Taskmaster {
228
314
  return parsed;
229
315
  }
230
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,6 +1,6 @@
1
1
  {
2
2
  "name": "taskmaster-api",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Client for the Taskmaster Computer agent",
5
5
  "license": "MIT",
6
6
  "type": "module",