cmdop 3.0.1__tar.gz → 3.2.0__tar.gz
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.
- {cmdop-3.0.1 → cmdop-3.2.0}/PKG-INFO +5 -2
- {cmdop-3.0.1 → cmdop-3.2.0}/README.md +4 -1
- {cmdop-3.0.1 → cmdop-3.2.0}/pyproject.toml +5 -2
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/__init__.py +8 -1
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/_async.py +10 -11
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/_client.py +13 -14
- cmdop-3.2.0/src/cmdop/_screen.py +42 -0
- cmdop-3.2.0/src/cmdop/generated/__init__.py +1 -0
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/generated/args.py +17 -9
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/generated/call.py +3 -2
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/generated/models.py +1 -1
- cmdop-3.2.0/src/cmdop/generated/server.py +61 -0
- cmdop-3.2.0/src/cmdop/generated/server_args.py +69 -0
- cmdop-3.2.0/src/cmdop/generated/server_models.py +287 -0
- cmdop-3.2.0/src/cmdop/generated/tools.py +1035 -0
- cmdop-3.0.1/src/cmdop/generated/__init__.py +0 -1
- cmdop-3.0.1/src/cmdop/generated/tools.py +0 -411
- {cmdop-3.0.1 → cmdop-3.2.0}/.gitignore +0 -0
- {cmdop-3.0.1 → cmdop-3.2.0}/LICENSE +0 -0
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/_errors.py +0 -0
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/_sealing.py +0 -0
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/carriers/__init__.py +0 -0
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/carriers/_carrier.py +0 -0
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/carriers/http.py +0 -0
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/carriers/memory.py +0 -0
- {cmdop-3.0.1 → cmdop-3.2.0}/src/cmdop/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cmdop
|
|
3
|
-
Version: 3.0
|
|
3
|
+
Version: 3.2.0
|
|
4
4
|
Summary: Your machines' tools from a program: the same tools agents use through MCP, typed from Rust.
|
|
5
5
|
Project-URL: Homepage, https://cmdop.ai
|
|
6
6
|
Project-URL: Documentation, https://docs.cmdop.ai/reference/sdk/python
|
|
@@ -34,7 +34,10 @@ with cmdop.connect() as c: # CMDOP_TOKEN, CMDOP_URL
|
|
|
34
34
|
print(run.result.exit_code)
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
Every tool is a typed method on a machine (`box.fs_read(path=...)`), also under its group (`box.fs.read(path=...)`);
|
|
38
|
+
`box.screenshot()` decodes the picture. The tools the server answers itself are methods of the client, with no
|
|
39
|
+
machine: `c.machines_list()`, `c.tasks_list()`, `c.history_search(text=...)` and `c.showtime_guide(language=...)`,
|
|
40
|
+
the guide for a short live demo of what your machines can do. `cmdop.connect_async()` is the same, awaited. `src/cmdop/generated/` is generated by `make sdk-generate`; never edit it.
|
|
38
41
|
|
|
39
42
|
## The same tools over MCP
|
|
40
43
|
|
|
@@ -14,7 +14,10 @@ with cmdop.connect() as c: # CMDOP_TOKEN, CMDOP_URL
|
|
|
14
14
|
print(run.result.exit_code)
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Every tool is a typed method on a machine (`box.fs_read(path=...)`), also under its group (`box.fs.read(path=...)`);
|
|
18
|
+
`box.screenshot()` decodes the picture. The tools the server answers itself are methods of the client, with no
|
|
19
|
+
machine: `c.machines_list()`, `c.tasks_list()`, `c.history_search(text=...)` and `c.showtime_guide(language=...)`,
|
|
20
|
+
the guide for a short live demo of what your machines can do. `cmdop.connect_async()` is the same, awaited. `src/cmdop/generated/` is generated by `make sdk-generate`; never edit it.
|
|
18
21
|
|
|
19
22
|
## The same tools over MCP
|
|
20
23
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "cmdop"
|
|
3
|
-
version = "3.0
|
|
3
|
+
version = "3.2.0"
|
|
4
4
|
description = "Your machines' tools from a program: the same tools agents use through MCP, typed from Rust."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -34,7 +34,10 @@ include = ["src", "tests"]
|
|
|
34
34
|
typeCheckingMode = "strict"
|
|
35
35
|
pythonVersion = "3.10"
|
|
36
36
|
# Generated models are checked by their own generator; the methods that use them are checked here.
|
|
37
|
-
exclude = [
|
|
37
|
+
exclude = [
|
|
38
|
+
"src/cmdop/generated/args.py", "src/cmdop/generated/models.py", "src/cmdop/generated/call.py",
|
|
39
|
+
"src/cmdop/generated/server_args.py", "src/cmdop/generated/server_models.py",
|
|
40
|
+
]
|
|
38
41
|
|
|
39
42
|
[tool.pytest.ini_options]
|
|
40
43
|
testpaths = ["tests"]
|
|
@@ -5,20 +5,25 @@ import cmdop
|
|
|
5
5
|
with cmdop.connect() as c: # CMDOP_TOKEN, CMDOP_URL
|
|
6
6
|
box = c.machine("box")
|
|
7
7
|
print(box.run("uptime").stdout)
|
|
8
|
+
print(c.showtime_guide(language="en")) # the server's own tools are client methods
|
|
8
9
|
```
|
|
9
10
|
"""
|
|
10
11
|
|
|
11
12
|
from ._async import AsyncClient, AsyncMachine, AsyncRun, connect_async
|
|
12
13
|
from ._client import Client, Machine, Piece, Run, connect
|
|
13
14
|
from ._errors import CarrierError, CmdopError
|
|
15
|
+
from ._screen import DecodedImage, Screenshot
|
|
14
16
|
from .carriers import AsyncMemoryCarrier, MemoryCarrier
|
|
15
17
|
from .generated.call import ENVELOPE_MAX_BYTES, ERROR_CODES, PIECE_MAX_BYTES
|
|
16
|
-
from .generated.
|
|
18
|
+
from .generated.server import SERVER_TOOLS
|
|
19
|
+
from .generated.tools import GROUPS, TOOLS
|
|
17
20
|
|
|
18
21
|
__all__ = [
|
|
19
22
|
"ENVELOPE_MAX_BYTES",
|
|
20
23
|
"ERROR_CODES",
|
|
24
|
+
"GROUPS",
|
|
21
25
|
"PIECE_MAX_BYTES",
|
|
26
|
+
"SERVER_TOOLS",
|
|
22
27
|
"TOOLS",
|
|
23
28
|
"AsyncClient",
|
|
24
29
|
"AsyncMachine",
|
|
@@ -27,10 +32,12 @@ __all__ = [
|
|
|
27
32
|
"CarrierError",
|
|
28
33
|
"Client",
|
|
29
34
|
"CmdopError",
|
|
35
|
+
"DecodedImage",
|
|
30
36
|
"Machine",
|
|
31
37
|
"MemoryCarrier",
|
|
32
38
|
"Piece",
|
|
33
39
|
"Run",
|
|
40
|
+
"Screenshot",
|
|
34
41
|
"connect",
|
|
35
42
|
"connect_async",
|
|
36
43
|
]
|
|
@@ -6,16 +6,14 @@ import time
|
|
|
6
6
|
from collections.abc import AsyncIterator, Callable
|
|
7
7
|
from typing import Any, Generic, TypeVar
|
|
8
8
|
|
|
9
|
-
from pydantic import BaseModel
|
|
10
|
-
from typing_extensions import Unpack
|
|
9
|
+
from pydantic import BaseModel, TypeAdapter
|
|
11
10
|
|
|
12
11
|
from ._client import Piece, carrier_name, piece, request, settle, token_of, url_of
|
|
13
12
|
from ._errors import CarrierError, CmdopError
|
|
14
13
|
from ._sealing import Sealing
|
|
15
14
|
from .carriers import AsyncCarrier, AsyncHttpCarrier, Json
|
|
16
15
|
from .carriers._carrier import is_answer
|
|
17
|
-
from .generated import
|
|
18
|
-
from .generated import models as m
|
|
16
|
+
from .generated.server import AsyncServerTools
|
|
19
17
|
from .generated.tools import AsyncTools
|
|
20
18
|
|
|
21
19
|
T = TypeVar("T", bound=BaseModel)
|
|
@@ -76,16 +74,13 @@ class AsyncMachine(AsyncTools):
|
|
|
76
74
|
async def _tool(self, name: str, args: dict[str, Any], out: type[T], deadline: float | None) -> T:
|
|
77
75
|
return out.model_validate(await self._client.call(name, args, machine=self.name, deadline=deadline))
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return await self.exec_run(deadline=deadline, **{**args, "command": command})
|
|
77
|
+
def _stream(self, name: str, args: dict[str, Any], out: type[T], deadline: float | None) -> AsyncRun[T]:
|
|
78
|
+
return self._client.stream(name, args, machine=self.name, deadline=deadline, out=out)
|
|
82
79
|
|
|
83
|
-
def stream(self, command: str, /, *, deadline: float | None = None, **args: Unpack[a.ExecRunArgs]) -> AsyncRun[m.ExecRunOut]:
|
|
84
|
-
"""`exec_run` with its output as it comes."""
|
|
85
|
-
return self._client.stream("exec_run", {**args, "command": command}, machine=self.name, deadline=deadline, out=m.ExecRunOut)
|
|
86
80
|
|
|
81
|
+
class AsyncClient(AsyncServerTools):
|
|
82
|
+
"""`Client`, awaited. The server's own tools are its methods (`await cmdop.showtime_guide()`)."""
|
|
87
83
|
|
|
88
|
-
class AsyncClient:
|
|
89
84
|
def __init__(self, carrier: AsyncCarrier, e2e: Sealing | None = None) -> None:
|
|
90
85
|
self.carrier_impl = carrier
|
|
91
86
|
self._sealer = e2e
|
|
@@ -108,6 +103,10 @@ class AsyncClient:
|
|
|
108
103
|
sealed, replies = self._sealer.seal(req, await self.machines(), time.time())
|
|
109
104
|
return settle(self._sealer.open_answer(await self.carrier_impl.call(sealed), replies))
|
|
110
105
|
|
|
106
|
+
async def _server(self, name: str, args: dict[str, Any], out: Any, deadline: float | None) -> Any:
|
|
107
|
+
# The server reads these arguments and answers from its own records: there is no machine to seal for.
|
|
108
|
+
return TypeAdapter(out).validate_python(settle(await self.carrier_impl.call(request(name, args, None, deadline))))
|
|
109
|
+
|
|
111
110
|
def stream(
|
|
112
111
|
self, tool: str, args: dict[str, Any], *, machine: str | None = None, deadline: float | None = None, out: type[T] | None = None
|
|
113
112
|
) -> AsyncRun[Any]:
|
|
@@ -12,16 +12,14 @@ import time
|
|
|
12
12
|
from collections.abc import Callable, Iterator
|
|
13
13
|
from typing import Any, Generic, TypeVar
|
|
14
14
|
|
|
15
|
-
from pydantic import BaseModel
|
|
16
|
-
from typing_extensions import Unpack
|
|
15
|
+
from pydantic import BaseModel, TypeAdapter
|
|
17
16
|
|
|
18
17
|
from ._errors import CarrierError, CmdopError
|
|
19
18
|
from ._sealing import Sealing
|
|
20
19
|
from .carriers import Carrier, HttpCarrier, Json
|
|
21
20
|
from .carriers._carrier import is_answer
|
|
22
|
-
from .generated import args as a
|
|
23
|
-
from .generated import models as m
|
|
24
21
|
from .generated.call import OutputChunk
|
|
22
|
+
from .generated.server import ServerTools
|
|
25
23
|
from .generated.tools import Tools
|
|
26
24
|
|
|
27
25
|
T = TypeVar("T", bound=BaseModel)
|
|
@@ -149,7 +147,8 @@ class Run(Generic[R]):
|
|
|
149
147
|
|
|
150
148
|
|
|
151
149
|
class Machine(Tools):
|
|
152
|
-
"""One machine: every tool as a method (`box.fs_read(path=...)`)
|
|
150
|
+
"""One machine: every tool as a method (`box.fs_read(path=...)`), under its group (`box.fs.read(path=...)`), and the
|
|
151
|
+
short forms (`run`, `stream`, `screenshot`), all generated (`generated/tools.py`)."""
|
|
153
152
|
|
|
154
153
|
def __init__(self, client: Client, name: str | None) -> None:
|
|
155
154
|
self._client = client
|
|
@@ -158,17 +157,13 @@ class Machine(Tools):
|
|
|
158
157
|
def _tool(self, name: str, args: dict[str, Any], out: type[T], deadline: float | None) -> T:
|
|
159
158
|
return out.model_validate(self._client.call(name, args, machine=self.name, deadline=deadline))
|
|
160
159
|
|
|
161
|
-
def
|
|
162
|
-
|
|
163
|
-
return self.exec_run(deadline=deadline, **{**args, "command": command})
|
|
160
|
+
def _stream(self, name: str, args: dict[str, Any], out: type[T], deadline: float | None) -> Run[T]:
|
|
161
|
+
return self._client.stream(name, args, machine=self.name, deadline=deadline, out=out)
|
|
164
162
|
|
|
165
|
-
def stream(self, command: str, /, *, deadline: float | None = None, **args: Unpack[a.ExecRunArgs]) -> Run[m.ExecRunOut]:
|
|
166
|
-
"""`exec_run` with its output as it comes."""
|
|
167
|
-
return self._client.stream("exec_run", {**args, "command": command}, machine=self.name, deadline=deadline, out=m.ExecRunOut)
|
|
168
163
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
164
|
+
class Client(ServerTools):
|
|
165
|
+
"""Your machines. Use `cmdop.connect()`; close it, or use it as a context manager. The tools the server answers
|
|
166
|
+
itself are its methods (`cmdop.showtime_guide()`, `cmdop.tasks_list()`), generated (`generated/server.py`)."""
|
|
172
167
|
|
|
173
168
|
def __init__(self, carrier: Carrier, e2e: Sealing | None = None) -> None:
|
|
174
169
|
self.carrier_impl = carrier
|
|
@@ -196,6 +191,10 @@ class Client:
|
|
|
196
191
|
sealed, replies = self._sealer.seal(req, self.machines(), time.time())
|
|
197
192
|
return settle(self._sealer.open_answer(self.carrier_impl.call(sealed), replies))
|
|
198
193
|
|
|
194
|
+
def _server(self, name: str, args: dict[str, Any], out: Any, deadline: float | None) -> Any:
|
|
195
|
+
# The server reads these arguments and answers from its own records: there is no machine to seal for.
|
|
196
|
+
return TypeAdapter(out).validate_python(settle(self.carrier_impl.call(request(name, args, None, deadline))))
|
|
197
|
+
|
|
199
198
|
def stream(
|
|
200
199
|
self, tool: str, args: dict[str, Any], *, machine: str | None = None, deadline: float | None = None, out: type[T] | None = None
|
|
201
200
|
) -> Run[Any]:
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""A screenshot as bytes: the machine answers base64 PNG inside the JSON; this decodes it (the twin of `screen.ts`)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import base64
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
|
|
8
|
+
from .generated import models as m
|
|
9
|
+
|
|
10
|
+
_MIME = {"png": "image/png", "jpeg": "image/jpeg", "jpg": "image/jpeg", "webp": "image/webp"}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class DecodedImage:
|
|
15
|
+
"""A decoded picture: `data` is the encoded file (PNG), ready to write to a `.png`."""
|
|
16
|
+
|
|
17
|
+
data: bytes
|
|
18
|
+
mime: str
|
|
19
|
+
width: int
|
|
20
|
+
height: int
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass(frozen=True)
|
|
24
|
+
class Screenshot:
|
|
25
|
+
"""What `box.screenshot()` returns. Pixel coordinates of every pointer tool are pixels of `image` (see `geometry`)."""
|
|
26
|
+
|
|
27
|
+
image: DecodedImage
|
|
28
|
+
geometry: m.Geometry
|
|
29
|
+
audit_id: str
|
|
30
|
+
"""Id of the audit line and the saved copy on the machine."""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def decode_image(image: m.Image) -> DecodedImage:
|
|
34
|
+
"""Decodes the base64 `data` of a machine picture. Raises on a format this SDK does not know, rather than guess."""
|
|
35
|
+
mime = _MIME.get(image.format.lower())
|
|
36
|
+
if mime is None:
|
|
37
|
+
raise ValueError(f"unknown image format {image.format!r}")
|
|
38
|
+
return DecodedImage(base64.b64decode(image.data), mime, image.width, image.height)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def to_screenshot(out: m.ScreenCaptureOut) -> Screenshot:
|
|
42
|
+
return Screenshot(decode_image(out.image), out.geometry, out.audit_id)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Generated from cmdop/crates/tools/tools.schema.json (sha256 d9aba5e354666f95, cmdop 0.1.10) by exports/sdk/gen/gen.ts. Do not edit.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Generated from cmdop/crates/tools/tools.schema.json (sha256
|
|
1
|
+
# Generated from cmdop/crates/tools/tools.schema.json (sha256 d9aba5e354666f95, cmdop 0.1.10) by exports/sdk/gen/gen.ts. Do not edit.
|
|
2
2
|
# Types by datamodel-code-generator==0.30.2.
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
@@ -51,7 +51,8 @@ class ExecRunArgs(TypedDict):
|
|
|
51
51
|
"""
|
|
52
52
|
env: NotRequired[dict[str, str]]
|
|
53
53
|
"""
|
|
54
|
-
Extra environment variables for this command.
|
|
54
|
+
Extra environment variables for this command. It gets these and a small base (PATH, HOME,
|
|
55
|
+
USER, SHELL, the locale, the desktop session); nothing else of cmdop's own environment.
|
|
55
56
|
"""
|
|
56
57
|
stdin: NotRequired[str | None]
|
|
57
58
|
"""
|
|
@@ -59,18 +60,21 @@ class ExecRunArgs(TypedDict):
|
|
|
59
60
|
"""
|
|
60
61
|
timeout_secs: NotRequired[int | None]
|
|
61
62
|
"""
|
|
62
|
-
Seconds before the command
|
|
63
|
+
Seconds before the command and its whole process group are stopped (default 120, at most
|
|
64
|
+
600). Long work goes to `task_start`.
|
|
63
65
|
"""
|
|
64
66
|
|
|
65
67
|
|
|
66
68
|
class FsDeleteArgs(TypedDict):
|
|
67
69
|
path: str
|
|
68
70
|
"""
|
|
69
|
-
File or folder on the machine. Absolute, or relative to the user's home folder.
|
|
71
|
+
File or folder on the machine. Absolute, or relative to the user's home folder. The home
|
|
72
|
+
folder, the file system root and the machine's allowed roots themselves are refused.
|
|
70
73
|
"""
|
|
71
74
|
permanent: NotRequired[bool]
|
|
72
75
|
"""
|
|
73
|
-
Remove for good instead of moving to the trash
|
|
76
|
+
Remove for good instead of moving to the trash (macOS ~/.Trash, Linux the freedesktop
|
|
77
|
+
trash). Only where the trash cannot take it.
|
|
74
78
|
"""
|
|
75
79
|
recursive: NotRequired[bool]
|
|
76
80
|
"""
|
|
@@ -81,7 +85,8 @@ class FsDeleteArgs(TypedDict):
|
|
|
81
85
|
class FsEditArgs(TypedDict):
|
|
82
86
|
expect_sha256: NotRequired[str | None]
|
|
83
87
|
"""
|
|
84
|
-
Refuse unless the file's SHA-256 is this
|
|
88
|
+
Refuse unless the file's SHA-256 is this: from `fs_stat` with hash=true, or the sha256 the
|
|
89
|
+
last write of it returned.
|
|
85
90
|
"""
|
|
86
91
|
new: str
|
|
87
92
|
"""
|
|
@@ -89,7 +94,8 @@ class FsEditArgs(TypedDict):
|
|
|
89
94
|
"""
|
|
90
95
|
old: str
|
|
91
96
|
"""
|
|
92
|
-
The exact text to replace, whitespace included
|
|
97
|
+
The exact text to replace, whitespace included; no regular expressions, no fuzzy matching.
|
|
98
|
+
Must occur once, unless `replace_all`.
|
|
93
99
|
"""
|
|
94
100
|
path: str
|
|
95
101
|
"""
|
|
@@ -160,7 +166,8 @@ class FsSearchArgs(TypedDict):
|
|
|
160
166
|
"""
|
|
161
167
|
root: str
|
|
162
168
|
"""
|
|
163
|
-
Folder to search under. Absolute, or relative to the user's home folder.
|
|
169
|
+
Folder to search under. Absolute, or relative to the user's home folder. Symlinks are not
|
|
170
|
+
followed; folders holding keys and credentials are skipped.
|
|
164
171
|
"""
|
|
165
172
|
|
|
166
173
|
|
|
@@ -200,7 +207,8 @@ class FsWriteArgs(TypedDict):
|
|
|
200
207
|
"""
|
|
201
208
|
path: str
|
|
202
209
|
"""
|
|
203
|
-
File on the machine. Absolute, or relative to the user's home folder.
|
|
210
|
+
File on the machine. Absolute, or relative to the user's home folder. An existing file
|
|
211
|
+
keeps its permissions.
|
|
204
212
|
"""
|
|
205
213
|
|
|
206
214
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Generated from cmdop/crates/tools/tools.schema.json (sha256
|
|
1
|
+
# Generated from cmdop/crates/tools/tools.schema.json (sha256 d9aba5e354666f95, cmdop 0.1.10) by exports/sdk/gen/gen.ts. Do not edit.
|
|
2
2
|
# Types by datamodel-code-generator==0.30.2.
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
@@ -93,7 +93,8 @@ class ToolError(BaseModel):
|
|
|
93
93
|
] = Field(..., title="ErrorCode")
|
|
94
94
|
"""
|
|
95
95
|
`denied`: The grant or the machine's ceiling does not allow it.
|
|
96
|
-
`unknown_tool`: This machine does not have the tool
|
|
96
|
+
`unknown_tool`: This machine does not have the tool: its program is older, or a screen tool has no screen
|
|
97
|
+
there. A tool the machine's own limit leaves out is `denied` instead.
|
|
97
98
|
`bad_args`: The arguments do not match the tool's schema.
|
|
98
99
|
`not_found`: The path or the thing named does not exist.
|
|
99
100
|
`busy`: The machine runs too many calls already.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Generated from cmdop/crates/tools/tools.schema.json (sha256
|
|
1
|
+
# Generated from cmdop/crates/tools/tools.schema.json (sha256 d9aba5e354666f95, cmdop 0.1.10) by exports/sdk/gen/gen.ts. Do not edit.
|
|
2
2
|
# Types by datamodel-code-generator==0.30.2.
|
|
3
3
|
|
|
4
4
|
from __future__ import annotations
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Generated from cmdop/crates/tools/tools.schema.json (sha256 d9aba5e354666f95, cmdop 0.1.10) by exports/sdk/gen/gen.ts. Do not edit.
|
|
2
|
+
"""The tools the server answers itself, as methods of `Client` and `AsyncClient`. No machine, never sealed."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from typing_extensions import Unpack
|
|
9
|
+
|
|
10
|
+
from . import server_args as sa
|
|
11
|
+
from . import server_models as sm
|
|
12
|
+
|
|
13
|
+
SERVER_TOOLS: dict[str, str] = {
|
|
14
|
+
"history_search": "Search history",
|
|
15
|
+
"machines_list": "List machines",
|
|
16
|
+
"showtime_guide": "Showtime guide",
|
|
17
|
+
"tasks_list": "List running work",
|
|
18
|
+
}
|
|
19
|
+
"""Every server tool and its title."""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ServerTools:
|
|
23
|
+
def _server(self, name: str, args: dict[str, Any], out: Any, deadline: float | None) -> Any:
|
|
24
|
+
raise NotImplementedError
|
|
25
|
+
|
|
26
|
+
def history_search(self, *, deadline: float | None = None, **args: Unpack[sa.HistorySearchArgs]) -> sm.HistorySearchOut:
|
|
27
|
+
"""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."""
|
|
28
|
+
return self._server("history_search", dict(args), sm.HistorySearchOut, deadline)
|
|
29
|
+
|
|
30
|
+
def machines_list(self, *, deadline: float | None = None, **args: Unpack[sa.MachinesListArgs]) -> list[sm.MachineRow]:
|
|
31
|
+
"""The owner's machines: name, id, `state` (online; stale = linked, not answering; paused; offline), `last_seen`, `activity`, `tools`, build, `behind` (newer release out). Only online ones take calls."""
|
|
32
|
+
return self._server("machines_list", dict(args), list[sm.MachineRow], deadline)
|
|
33
|
+
|
|
34
|
+
def showtime_guide(self, *, deadline: float | None = None, **args: Unpack[sa.ShowtimeGuideArgs]) -> str:
|
|
35
|
+
"""Call when the user asks to see what CMDOP can do (a demo or a show): returns a guide for a short live demonstration on their machines."""
|
|
36
|
+
return self._server("showtime_guide", dict(args), str, deadline)
|
|
37
|
+
|
|
38
|
+
def tasks_list(self, *, deadline: float | None = None, **args: Unpack[sa.TasksListArgs]) -> sm.TasksListOut:
|
|
39
|
+
"""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."""
|
|
40
|
+
return self._server("tasks_list", dict(args), sm.TasksListOut, deadline)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class AsyncServerTools:
|
|
44
|
+
async def _server(self, name: str, args: dict[str, Any], out: Any, deadline: float | None) -> Any:
|
|
45
|
+
raise NotImplementedError
|
|
46
|
+
|
|
47
|
+
async def history_search(self, *, deadline: float | None = None, **args: Unpack[sa.HistorySearchArgs]) -> sm.HistorySearchOut:
|
|
48
|
+
"""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."""
|
|
49
|
+
return await self._server("history_search", dict(args), sm.HistorySearchOut, deadline)
|
|
50
|
+
|
|
51
|
+
async def machines_list(self, *, deadline: float | None = None, **args: Unpack[sa.MachinesListArgs]) -> list[sm.MachineRow]:
|
|
52
|
+
"""The owner's machines: name, id, `state` (online; stale = linked, not answering; paused; offline), `last_seen`, `activity`, `tools`, build, `behind` (newer release out). Only online ones take calls."""
|
|
53
|
+
return await self._server("machines_list", dict(args), list[sm.MachineRow], deadline)
|
|
54
|
+
|
|
55
|
+
async def showtime_guide(self, *, deadline: float | None = None, **args: Unpack[sa.ShowtimeGuideArgs]) -> str:
|
|
56
|
+
"""Call when the user asks to see what CMDOP can do (a demo or a show): returns a guide for a short live demonstration on their machines."""
|
|
57
|
+
return await self._server("showtime_guide", dict(args), str, deadline)
|
|
58
|
+
|
|
59
|
+
async def tasks_list(self, *, deadline: float | None = None, **args: Unpack[sa.TasksListArgs]) -> sm.TasksListOut:
|
|
60
|
+
"""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."""
|
|
61
|
+
return await self._server("tasks_list", dict(args), sm.TasksListOut, deadline)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Generated from cmdop/crates/tools/tools.schema.json (sha256 d9aba5e354666f95, cmdop 0.1.10) by exports/sdk/gen/gen.ts. Do not edit.
|
|
2
|
+
# Types by datamodel-code-generator==0.30.2.
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import Literal, TypedDict
|
|
7
|
+
|
|
8
|
+
from typing_extensions import NotRequired
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class HistorySearchArgs(TypedDict):
|
|
12
|
+
author: NotRequired[str | None]
|
|
13
|
+
"""
|
|
14
|
+
Author or its start: `owner`, `agent:` (every agent), `agent:<name>`.
|
|
15
|
+
"""
|
|
16
|
+
kind: NotRequired[list[Literal["tasks", "sessions", "calls"]]]
|
|
17
|
+
"""
|
|
18
|
+
What to return. Default: tasks, sessions and calls.
|
|
19
|
+
"""
|
|
20
|
+
limit: NotRequired[int | None]
|
|
21
|
+
"""
|
|
22
|
+
At most this many of each kind, newest first (default 50, at most 200).
|
|
23
|
+
"""
|
|
24
|
+
machine: NotRequired[str | None]
|
|
25
|
+
"""
|
|
26
|
+
Only this machine (name or id).
|
|
27
|
+
"""
|
|
28
|
+
since: NotRequired[int | None]
|
|
29
|
+
"""
|
|
30
|
+
Started (sessions: last changed) at or after this time, unix seconds.
|
|
31
|
+
"""
|
|
32
|
+
task: NotRequired[int | None]
|
|
33
|
+
"""
|
|
34
|
+
Only this task (its row and the calls that started or named it; no sessions).
|
|
35
|
+
"""
|
|
36
|
+
text: NotRequired[str | None]
|
|
37
|
+
"""
|
|
38
|
+
Text, any case. Tasks: the command, the folder or the error (another author's only for an
|
|
39
|
+
agent granted exec). Sessions: path, id, folder. Calls: the tool name.
|
|
40
|
+
"""
|
|
41
|
+
until: NotRequired[int | None]
|
|
42
|
+
"""
|
|
43
|
+
Started (sessions: last changed) before this time, unix seconds.
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class MachinesListArgs(TypedDict):
|
|
48
|
+
"""
|
|
49
|
+
No arguments.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class ShowtimeGuideArgs(TypedDict):
|
|
54
|
+
language: NotRequired[str | None]
|
|
55
|
+
"""
|
|
56
|
+
The language to speak to the user in, e.g. "Russian" or "de". Default: the user's.
|
|
57
|
+
"""
|
|
58
|
+
os: NotRequired[Literal["macos", "linux"] | None]
|
|
59
|
+
"""
|
|
60
|
+
The stage machine's OS (`sys_info` `os`). Default: the notes for every OS.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class TasksListArgs(TypedDict):
|
|
65
|
+
machine: NotRequired[str | None]
|
|
66
|
+
"""
|
|
67
|
+
Only this machine (name or id). Default: all machines.
|
|
68
|
+
"""
|
|
69
|
+
|