taskmaster-api 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl

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.
taskmaster_api/client.py CHANGED
@@ -12,7 +12,7 @@ import urllib.request
12
12
  from typing import Any, Mapping, Optional
13
13
 
14
14
  DEFAULT_BASE_URL = "http://127.0.0.1:8737"
15
- VERSION = "0.2.0"
15
+ VERSION = "0.3.0"
16
16
 
17
17
 
18
18
  class TaskmasterError(Exception):
@@ -143,6 +143,119 @@ class Taskmaster:
143
143
  """``POST /api/computer/routines/{id}/run``."""
144
144
  return self.call("POST", f"/api/computer/routines/{_segment(routine_id)}/run", {})
145
145
 
146
+ def builtin_mcp_url(self) -> str:
147
+ """URL of the daemon's own MCP endpoint.
148
+
149
+ Agents already get this server. It carries the dictionary, Computer,
150
+ and the document tools. ``connect_mcp`` adds another server.
151
+ """
152
+ return f"{self.base_url}/mcp"
153
+
154
+ def mcp_servers(self) -> list[Any]:
155
+ """``GET /api/mcp``. User MCP servers saved for this project."""
156
+ listed = self._object(self.call("GET", "/api/mcp"))
157
+ servers = listed.get("servers")
158
+ if not isinstance(servers, list):
159
+ raise TaskmasterError(0, "mcp response had no list")
160
+ return servers
161
+
162
+ def connect_mcp(
163
+ self,
164
+ name: str,
165
+ command: str,
166
+ *,
167
+ args: Optional[list[str]] = None,
168
+ env: Optional[Mapping[str, str]] = None,
169
+ secret_env: Optional[Mapping[str, str]] = None,
170
+ roles: Optional[list[str]] = None,
171
+ enabled: Optional[bool] = None,
172
+ require_approval: Optional[bool] = None,
173
+ ) -> dict[str, Any]:
174
+ """``POST /api/mcp``. Adds or replaces a user MCP server.
175
+
176
+ ``secret_env`` values go to the OS keychain. The daemon does not echo them.
177
+ """
178
+ body: dict[str, Any] = {"name": name, "command": command}
179
+ if args:
180
+ body["args"] = args
181
+ if env:
182
+ body["env"] = dict(env)
183
+ if secret_env:
184
+ body["secret_env"] = dict(secret_env)
185
+ if roles:
186
+ body["roles"] = roles
187
+ if enabled is not None:
188
+ body["enabled"] = enabled
189
+ if require_approval is not None:
190
+ body["require_approval"] = require_approval
191
+ saved = self._object(self.call("POST", "/api/mcp", body))
192
+ server = saved.get("server")
193
+ if not isinstance(server, dict):
194
+ raise TaskmasterError(0, "mcp response had no server")
195
+ return server
196
+
197
+ def disconnect_mcp(self, name: str) -> Any:
198
+ """``POST /api/mcp/{name}/remove``."""
199
+ return self.call("POST", f"/api/mcp/{_segment(name)}/remove", {})
200
+
201
+ def docs(self) -> list[Any]:
202
+ """``GET /api/computer/docs``."""
203
+ listed = self._object(self.call("GET", "/api/computer/docs"))
204
+ docs = listed.get("docs")
205
+ if not isinstance(docs, list):
206
+ raise TaskmasterError(0, "docs response had no list")
207
+ return docs
208
+
209
+ def doc(self, doc_id: str) -> dict[str, Any]:
210
+ """``GET /api/computer/docs/{id}``."""
211
+ return self._object(self.call("GET", f"/api/computer/docs/{_segment(doc_id)}"))
212
+
213
+ def upload_doc(self, name: str, data_base64: str) -> dict[str, Any]:
214
+ """``POST /api/computer/files``. ``data_base64`` is the file bytes."""
215
+ return self._object(self.call("POST", "/api/computer/files", {"name": name, "data_base64": data_base64}))
216
+
217
+ def open_doc(self, doc_id: str) -> Any:
218
+ """``POST /api/computer/docs/{id}/open``. Opens the file in the host's default app."""
219
+ return self.call("POST", f"/api/computer/docs/{_segment(doc_id)}/open", {})
220
+
221
+ def make_pptx(self, title: str, brief: Optional[str] = None) -> dict[str, Any]:
222
+ """Start a Computer session that builds a PowerPoint with ``doc_create_pptx``."""
223
+ return self.computer_start(_document_task("PowerPoint", "doc_create_pptx", title, brief))
224
+
225
+ def make_docx(self, title: str, brief: Optional[str] = None) -> dict[str, Any]:
226
+ """Start a Computer session that builds a Word document with ``doc_create_docx``."""
227
+ return self.computer_start(_document_task("Word document", "doc_create_docx", title, brief))
228
+
229
+ def setup(self) -> dict[str, Any]:
230
+ """``GET /api/setup``. Each provider's install and sign-in state, plus runtimes and jobs."""
231
+ return self._object(self.call("GET", "/api/setup"))
232
+
233
+ def connect_provider(self, provider_id: str, api_key: Optional[str] = None) -> Any:
234
+ """Connect a provider in one call.
235
+
236
+ An ``api_key`` is saved for a provider that uses one (``openrouter``).
237
+ Otherwise this installs the CLI when it is missing, or starts its sign-in
238
+ when it is already installed. A provider that is installed and signed in
239
+ returns ``{"ok": true, "connected": true}``.
240
+ """
241
+ segment = _segment(provider_id)
242
+ if api_key is not None:
243
+ return self.call("POST", f"/api/setup/providers/{segment}/key", {"api_key": api_key})
244
+ setup = self.setup()
245
+ providers = setup.get("providers")
246
+ match = None
247
+ if isinstance(providers, list):
248
+ for item in providers:
249
+ if isinstance(item, dict) and item.get("id") == provider_id:
250
+ match = item
251
+ break
252
+ installed = bool(match and match.get("installed") is True)
253
+ signed_in = bool(match and match.get("signed_in") is True)
254
+ if installed and signed_in:
255
+ return {"ok": True, "connected": True, "id": provider_id}
256
+ action = "login" if installed else "install"
257
+ return self.call("POST", f"/api/setup/providers/{segment}/{action}", {})
258
+
146
259
  def runs(self) -> dict[str, Any]:
147
260
  """``GET /api/runs``. The body is ``{"runs": [...], "seq": n}``."""
148
261
  return self._object(self.call("GET", "/api/runs"))
@@ -287,6 +400,13 @@ class Taskmaster:
287
400
  return value
288
401
 
289
402
 
403
+ def _document_task(kind: str, tool: str, title: str, brief: Optional[str]) -> str:
404
+ task = f"Make a {kind} with {tool}. Title: {title}. Use one cohesive theme on every page."
405
+ if brief:
406
+ task = f"{task} {brief}"
407
+ return task
408
+
409
+
290
410
  def _segment(run_id: str) -> str:
291
411
  from urllib.parse import quote
292
412
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: taskmaster-api
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Client for the Taskmaster Computer agent
5
5
  Author: Naren Sengodan
6
6
  License-Expression: MIT
@@ -40,6 +40,16 @@ acted = tm.computer_act("open_url", url="https://example.com", capture_after=Tru
40
40
  print(acted["result"])
41
41
  ```
42
42
 
43
+ Connect a provider, save an MCP server, or start a deck. `builtin_mcp_url()` is the daemon's own `/mcp`, which already has Computer and the document tools.
44
+
45
+ ```python
46
+ tm.connect_provider("grok")
47
+ tm.connect_provider("openrouter", api_key="sk-...")
48
+ tm.connect_mcp("linear", "npx", args=["-y", "mcp-remote"], secret_env={"LINEAR_API_KEY": "..."})
49
+ session = tm.make_pptx("Q4 plan", "Three slides: goal, plan, ask")
50
+ print(tm.docs())
51
+ ```
52
+
43
53
  The standard library is the only dependency. Coding-run methods (`start`, `approve`, `events`) remain. `call(method, path, body)` sends any other route.
44
54
 
45
55
  The same client is published for Rust (`cargo add taskmaster-api`) and JavaScript (`npm install taskmaster-api`).
@@ -0,0 +1,8 @@
1
+ taskmaster_api/__init__.py,sha256=hBTAlTQhG9qByXoDJILAlfmJeNdMoWrwG2fsXuvEM1M,236
2
+ taskmaster_api/client.py,sha256=o3fZNIERYGQR71MQmVzgsiI-6bGOMq-wg4Ej2MlVuj4,17680
3
+ taskmaster_api/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ taskmaster_api-0.3.0.dist-info/licenses/LICENSE,sha256=dMTuPSKtnP69xjRoU09WxOfzuCXMfZ_e8GPCjZEY830,1071
5
+ taskmaster_api-0.3.0.dist-info/METADATA,sha256=oyOfLgJA-05F80b-BtxbQqwQDkS8XpuJFn4a4cr_OUw,2100
6
+ taskmaster_api-0.3.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
7
+ taskmaster_api-0.3.0.dist-info/top_level.txt,sha256=bN4d_q-hbPNkU7dCogKdyXzJg8JZyhtdlAnmcsH_RE4,15
8
+ taskmaster_api-0.3.0.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- taskmaster_api/__init__.py,sha256=hBTAlTQhG9qByXoDJILAlfmJeNdMoWrwG2fsXuvEM1M,236
2
- taskmaster_api/client.py,sha256=-N64YwiEpuJj2cMCzW9ChbEcKk2nUXLprJoXYuQWjkE,12368
3
- taskmaster_api/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
- taskmaster_api-0.2.0.dist-info/licenses/LICENSE,sha256=dMTuPSKtnP69xjRoU09WxOfzuCXMfZ_e8GPCjZEY830,1071
5
- taskmaster_api-0.2.0.dist-info/METADATA,sha256=XXOVDvhK_72UhOHezpw2BP1FlHVjIywSSmXjx2VLGWQ,1667
6
- taskmaster_api-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
7
- taskmaster_api-0.2.0.dist-info/top_level.txt,sha256=bN4d_q-hbPNkU7dCogKdyXzJg8JZyhtdlAnmcsH_RE4,15
8
- taskmaster_api-0.2.0.dist-info/RECORD,,