taskmaster-api 0.3.0__py3-none-any.whl → 0.3.1__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.
@@ -1,6 +1,6 @@
1
1
  """Client for a Taskmaster daemon running on this machine."""
2
2
 
3
- from .client import DEFAULT_BASE_URL, VERSION, Taskmaster, TaskmasterError
3
+ from .client import DEFAULT_BASE_URL, PROVIDER_INFO, PROVIDERS, VERSION, Taskmaster, TaskmasterError
4
4
 
5
- __all__ = ["DEFAULT_BASE_URL", "VERSION", "Taskmaster", "TaskmasterError"]
5
+ __all__ = ["DEFAULT_BASE_URL", "PROVIDER_INFO", "PROVIDERS", "VERSION", "Taskmaster", "TaskmasterError"]
6
6
  __version__ = VERSION
taskmaster_api/client.py CHANGED
@@ -12,7 +12,19 @@ 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.3.0"
15
+ VERSION = "0.3.1"
16
+
17
+ # Provider ids Taskmaster installs and signs in, in the app's order.
18
+ # The five CLIs install and sign in. OpenRouter connects with an API key.
19
+ PROVIDERS = ("claude", "agy", "grok", "codex", "opencode", "openrouter")
20
+ PROVIDER_INFO = (
21
+ {"id": "claude", "name": "Claude Code", "api_key": False},
22
+ {"id": "agy", "name": "Antigravity", "api_key": False},
23
+ {"id": "grok", "name": "Grok Build", "api_key": False},
24
+ {"id": "codex", "name": "Codex", "api_key": False},
25
+ {"id": "opencode", "name": "OpenCode", "api_key": False},
26
+ {"id": "openrouter", "name": "OpenRouter", "api_key": True},
27
+ )
16
28
 
17
29
 
18
30
  class TaskmasterError(Exception):
@@ -231,27 +243,30 @@ class Taskmaster:
231
243
  return self._object(self.call("GET", "/api/setup"))
232
244
 
233
245
  def connect_provider(self, provider_id: str, api_key: Optional[str] = None) -> Any:
234
- """Connect a provider in one call.
246
+ """Connect any Taskmaster provider in one call.
247
+
248
+ The ids are ``PROVIDERS``: ``claude``, ``agy``, ``grok``, ``codex``,
249
+ ``opencode``, and ``openrouter``. Any other id the daemon knows is
250
+ accepted the same way.
235
251
 
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}``.
252
+ A CLI is installed when it is missing, or signed in when it is already
253
+ installed. One that is installed and signed in returns
254
+ ``{"ok": true, "connected": true}``. ``openrouter``, and any provider
255
+ whose setup row has ``version`` ``api``, saves ``api_key`` instead.
240
256
  """
241
257
  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
258
  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
259
+ match = _setup_provider(setup, provider_id)
260
+ if _provider_uses_api_key(provider_id, match):
261
+ if api_key is not None:
262
+ return self.call("POST", f"/api/setup/providers/{segment}/key", {"api_key": api_key})
263
+ if match is not None and match.get("signed_in") is True:
264
+ return {"ok": True, "connected": True, "id": provider_id}
265
+ raise TaskmasterError(0, f"{provider_id} connects with an API key. Pass the key to connect_provider.")
266
+ if api_key is not None:
267
+ raise TaskmasterError(0, f"{provider_id} signs in through its own CLI. Omit the API key to install or sign in.")
252
268
  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:
269
+ if installed and match is not None and match.get("signed_in") is True:
255
270
  return {"ok": True, "connected": True, "id": provider_id}
256
271
  action = "login" if installed else "install"
257
272
  return self.call("POST", f"/api/setup/providers/{segment}/{action}", {})
@@ -400,6 +415,23 @@ class Taskmaster:
400
415
  return value
401
416
 
402
417
 
418
+ def _setup_provider(setup: Mapping[str, Any], provider_id: str) -> Optional[dict[str, Any]]:
419
+ providers = setup.get("providers")
420
+ if not isinstance(providers, list):
421
+ return None
422
+ for item in providers:
423
+ if isinstance(item, dict) and item.get("id") == provider_id:
424
+ return item
425
+ return None
426
+
427
+
428
+ def _provider_uses_api_key(provider_id: str, provider: Optional[Mapping[str, Any]]) -> bool:
429
+ for info in PROVIDER_INFO:
430
+ if info["id"] == provider_id:
431
+ return bool(info["api_key"])
432
+ return provider is not None and provider.get("version") == "api"
433
+
434
+
403
435
  def _document_task(kind: str, tool: str, title: str, brief: Optional[str]) -> str:
404
436
  task = f"Make a {kind} with {tool}. Title: {title}. Use one cohesive theme on every page."
405
437
  if brief:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: taskmaster-api
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: Client for the Taskmaster Computer agent
5
5
  Author: Naren Sengodan
6
6
  License-Expression: MIT
@@ -43,7 +43,8 @@ print(acted["result"])
43
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
44
 
45
45
  ```python
46
- tm.connect_provider("grok")
46
+ for provider in ("claude", "agy", "grok", "codex", "opencode"):
47
+ tm.connect_provider(provider)
47
48
  tm.connect_provider("openrouter", api_key="sk-...")
48
49
  tm.connect_mcp("linear", "npx", args=["-y", "mcp-remote"], secret_env={"LINEAR_API_KEY": "..."})
49
50
  session = tm.make_pptx("Q4 plan", "Three slides: goal, plan, ask")
@@ -0,0 +1,8 @@
1
+ taskmaster_api/__init__.py,sha256=47g0ILv6UHiXoLTd8A0awu3gZSnT23GKoFbbdYCwZD8,292
2
+ taskmaster_api/client.py,sha256=KX6kTinl2MKqsYMc2s8RYxE8dMbTL-IEpsaxd9Ouux0,19316
3
+ taskmaster_api/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ taskmaster_api-0.3.1.dist-info/licenses/LICENSE,sha256=dMTuPSKtnP69xjRoU09WxOfzuCXMfZ_e8GPCjZEY830,1071
5
+ taskmaster_api-0.3.1.dist-info/METADATA,sha256=qnDU2E-EjJ4gVSse7NOkqk4Sv0OvjhWrYgnXy2RK1OU,2170
6
+ taskmaster_api-0.3.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
7
+ taskmaster_api-0.3.1.dist-info/top_level.txt,sha256=bN4d_q-hbPNkU7dCogKdyXzJg8JZyhtdlAnmcsH_RE4,15
8
+ taskmaster_api-0.3.1.dist-info/RECORD,,
@@ -1,8 +0,0 @@
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,,