kiteml-cli 0.8.0__tar.gz → 0.9.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.
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/PKG-INFO +12 -1
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/README.md +11 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/pyproject.toml +1 -1
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/__init__.py +1 -1
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/cli/commands/augment.py +5 -5
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/cli/commands/evaluations.py +9 -9
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/cli/commands/rl.py +14 -14
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/cli/commands/twin.py +66 -11
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/cli/main.py +14 -1
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/client.py +39 -3
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/mcp/common.py +5 -2
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/mcp/server.py +95 -43
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/.gitignore +0 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/archive.py +0 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/auth.py +0 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/cli/__init__.py +0 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/cli/commands/__init__.py +0 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/cli/commands/auth_cmd.py +0 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/cli/commands/config_cmd.py +0 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/config.py +0 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/mcp/__init__.py +0 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/output.py +0 -0
- {kiteml_cli-0.8.0 → kiteml_cli-0.9.0}/src/kite_cli/progress.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: kiteml-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.0
|
|
4
4
|
Summary: Kite CLI and MCP server: train robot policies with reinforcement learning in simulation, augment LeRobot datasets, and build MuJoCo digital twins, from your terminal or an AI agent.
|
|
5
5
|
Project-URL: Homepage, https://kiteml.com
|
|
6
6
|
Project-URL: Documentation, https://docs.kiteml.com/tools/cli-and-mcp
|
|
@@ -109,6 +109,7 @@ lerobot/pusht to look like this photo".
|
|
|
109
109
|
| `kite_rl_status`, `kite_rl_metrics`, `kite_rl_report`, `kite_rl_list` | Follow training and read each run's verdict |
|
|
110
110
|
| `kite_augment_create`, `kite_augment_status`, `kite_augment_list`, `kite_augment_cancel` | Augment LeRobot datasets |
|
|
111
111
|
| `kite_twin_validate`, `kite_twin_create`, `kite_twin_status`, `kite_twin_list`, `kite_twin_cancel`, `kite_twin_resume` | Build MuJoCo digital twins (beta) |
|
|
112
|
+
| `kite_twin_note`, `kite_twin_answer` | Guide a twin while it builds: leave notes for its agents, answer their questions |
|
|
112
113
|
| `kite_eval_validate`, `kite_eval_run`, `kite_eval_status`, `kite_eval_list`, `kite_eval_report`, `kite_eval_logs`, `kite_eval_cancel`, `kite_eval_resume` | Evaluate a policy on a Kite SDK spec on Kite's machines and read the scorecard (beta) |
|
|
113
114
|
| `kite_doctor` | Check connectivity and authentication |
|
|
114
115
|
|
|
@@ -141,6 +142,16 @@ Build a digital twin (beta, enabled per account):
|
|
|
141
142
|
kite twin create lerobot/svla_so101_pickplace --robot so101 --out ./twins # -> ./twins/twin_.../scene.xml
|
|
142
143
|
```
|
|
143
144
|
|
|
145
|
+
While it builds, `kite twin status twin_...` shows each judged round's scores, what the agents are doing, an open
|
|
146
|
+
question and your notes. Guide it:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
kite twin note twin_... "It is 2.5 cm, a matte red cube" --on red_block # read by the agents at their next step
|
|
150
|
+
kite twin note twin_... --delete note_...
|
|
151
|
+
kite twin answer twin_... "2.5 cm" # answers the open question
|
|
152
|
+
kite twin resume twin_... --from-round 1 # go back to a kept round
|
|
153
|
+
```
|
|
154
|
+
|
|
144
155
|
Evaluate a policy on a Kite SDK spec, on Kite's machines (beta):
|
|
145
156
|
|
|
146
157
|
```bash
|
|
@@ -67,6 +67,7 @@ lerobot/pusht to look like this photo".
|
|
|
67
67
|
| `kite_rl_status`, `kite_rl_metrics`, `kite_rl_report`, `kite_rl_list` | Follow training and read each run's verdict |
|
|
68
68
|
| `kite_augment_create`, `kite_augment_status`, `kite_augment_list`, `kite_augment_cancel` | Augment LeRobot datasets |
|
|
69
69
|
| `kite_twin_validate`, `kite_twin_create`, `kite_twin_status`, `kite_twin_list`, `kite_twin_cancel`, `kite_twin_resume` | Build MuJoCo digital twins (beta) |
|
|
70
|
+
| `kite_twin_note`, `kite_twin_answer` | Guide a twin while it builds: leave notes for its agents, answer their questions |
|
|
70
71
|
| `kite_eval_validate`, `kite_eval_run`, `kite_eval_status`, `kite_eval_list`, `kite_eval_report`, `kite_eval_logs`, `kite_eval_cancel`, `kite_eval_resume` | Evaluate a policy on a Kite SDK spec on Kite's machines and read the scorecard (beta) |
|
|
71
72
|
| `kite_doctor` | Check connectivity and authentication |
|
|
72
73
|
|
|
@@ -99,6 +100,16 @@ Build a digital twin (beta, enabled per account):
|
|
|
99
100
|
kite twin create lerobot/svla_so101_pickplace --robot so101 --out ./twins # -> ./twins/twin_.../scene.xml
|
|
100
101
|
```
|
|
101
102
|
|
|
103
|
+
While it builds, `kite twin status twin_...` shows each judged round's scores, what the agents are doing, an open
|
|
104
|
+
question and your notes. Guide it:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
kite twin note twin_... "It is 2.5 cm, a matte red cube" --on red_block # read by the agents at their next step
|
|
108
|
+
kite twin note twin_... --delete note_...
|
|
109
|
+
kite twin answer twin_... "2.5 cm" # answers the open question
|
|
110
|
+
kite twin resume twin_... --from-round 1 # go back to a kept round
|
|
111
|
+
```
|
|
112
|
+
|
|
102
113
|
Evaluate a policy on a Kite SDK spec, on Kite's machines (beta):
|
|
103
114
|
|
|
104
115
|
```bash
|
|
@@ -14,7 +14,7 @@ from typing import List, Optional
|
|
|
14
14
|
|
|
15
15
|
import typer
|
|
16
16
|
|
|
17
|
-
from kite_cli.client import KiteClient, KiteAPIError
|
|
17
|
+
from kite_cli.client import KiteClient, KiteAPIError, seg
|
|
18
18
|
from kite_cli.output import print_error, print_json
|
|
19
19
|
from kite_cli.progress import wait_for_completion
|
|
20
20
|
|
|
@@ -166,7 +166,7 @@ def status(
|
|
|
166
166
|
"""Get an augmentation's status."""
|
|
167
167
|
try:
|
|
168
168
|
client = KiteClient()
|
|
169
|
-
path = f"/v1/augmentations/{aug_id}"
|
|
169
|
+
path = f"/v1/augmentations/{seg(aug_id)}"
|
|
170
170
|
result = wait_for_completion(client, path, terminal_states=_TERMINAL) if wait else client.get(path)
|
|
171
171
|
print_json(result)
|
|
172
172
|
except KiteAPIError as e:
|
|
@@ -189,7 +189,7 @@ def cancel(aug_id: str = typer.Argument(..., help="Augmentation id (aug_...)")):
|
|
|
189
189
|
"""Cancel a running augmentation."""
|
|
190
190
|
try:
|
|
191
191
|
client = KiteClient()
|
|
192
|
-
result = client.post(f"/v1/augmentations/{aug_id}/cancel")
|
|
192
|
+
result = client.post(f"/v1/augmentations/{seg(aug_id)}/cancel")
|
|
193
193
|
print_json(result)
|
|
194
194
|
except KiteAPIError as e:
|
|
195
195
|
print_error(e.message, code=e.code, details=e.details)
|
|
@@ -220,7 +220,7 @@ def download(
|
|
|
220
220
|
"""Download a finished download-output dataset, preserving its file layout."""
|
|
221
221
|
try:
|
|
222
222
|
client = KiteClient()
|
|
223
|
-
result = client.get(f"/v1/augmentations/{aug_id}")
|
|
223
|
+
result = client.get(f"/v1/augmentations/{seg(aug_id)}")
|
|
224
224
|
if result.get("status") != "succeeded":
|
|
225
225
|
print_error(f"Augmentation is '{result.get('status')}', not succeeded yet.")
|
|
226
226
|
return
|
|
@@ -234,7 +234,7 @@ def download(
|
|
|
234
234
|
# to a GCS signed URL); the layout is reconstructed from each file's path.
|
|
235
235
|
dest = out / f["path"]
|
|
236
236
|
dest.parent.mkdir(parents=True, exist_ok=True)
|
|
237
|
-
client.download(f"/v1/augmentations/{aug_id}/files/{f['path']}", str(dest))
|
|
237
|
+
client.download(f"/v1/augmentations/{seg(aug_id)}/files/{f['path']}", str(dest))
|
|
238
238
|
written.append(str(dest))
|
|
239
239
|
print_json({"downloaded": written, "dir": str(out)})
|
|
240
240
|
except KiteAPIError as e:
|
|
@@ -43,7 +43,7 @@ import httpx
|
|
|
43
43
|
import typer
|
|
44
44
|
|
|
45
45
|
from kite_cli.archive import storage_client, unpack, verified
|
|
46
|
-
from kite_cli.client import KiteAPIError, KiteClient, post_create
|
|
46
|
+
from kite_cli.client import KiteAPIError, KiteClient, post_create, seg
|
|
47
47
|
from kite_cli.output import print_error, print_json
|
|
48
48
|
from kite_cli.progress import wait_for_completion
|
|
49
49
|
|
|
@@ -155,7 +155,7 @@ def status(
|
|
|
155
155
|
"""A run's live status, phase, episodes done, and once it has succeeded its result and `download`."""
|
|
156
156
|
try:
|
|
157
157
|
client = KiteClient()
|
|
158
|
-
path = f"/v1/evaluations/{run_id}"
|
|
158
|
+
path = f"/v1/evaluations/{seg(run_id)}"
|
|
159
159
|
if wait:
|
|
160
160
|
print_json(wait_for_completion(client, path, terminal_states=_TERMINAL, poll_interval=_POLL_S))
|
|
161
161
|
else:
|
|
@@ -180,7 +180,7 @@ def list_runs(
|
|
|
180
180
|
def report(run_id: str = typer.Argument(..., help="Evaluation id (eval_...)")):
|
|
181
181
|
"""A succeeded run's scorecard: every evaluator's value, interval and count, and what was not measured."""
|
|
182
182
|
try:
|
|
183
|
-
print_json(KiteClient().get(f"/v1/evaluations/{run_id}/report"))
|
|
183
|
+
print_json(KiteClient().get(f"/v1/evaluations/{seg(run_id)}/report"))
|
|
184
184
|
except KiteAPIError as e:
|
|
185
185
|
print_error(e.message, code=e.code, details=e.details)
|
|
186
186
|
|
|
@@ -192,7 +192,7 @@ def logs(
|
|
|
192
192
|
):
|
|
193
193
|
"""What the SDK printed, oldest first: readable while the run builds and after."""
|
|
194
194
|
try:
|
|
195
|
-
print_json(KiteClient().get(f"/v1/evaluations/{run_id}/logs", params={"tail": tail}))
|
|
195
|
+
print_json(KiteClient().get(f"/v1/evaluations/{seg(run_id)}/logs", params={"tail": tail}))
|
|
196
196
|
except KiteAPIError as e:
|
|
197
197
|
print_error(e.message, code=e.code, details=e.details)
|
|
198
198
|
|
|
@@ -205,7 +205,7 @@ def list_files(
|
|
|
205
205
|
all_pages: bool = typer.Option(False, "--all", help="Follow next_cursor through every page; print one list"),
|
|
206
206
|
):
|
|
207
207
|
"""The files of a succeeded run's directory (path, bytes, sha256), sorted by path."""
|
|
208
|
-
path = f"/v1/evaluations/{run_id}/files"
|
|
208
|
+
path = f"/v1/evaluations/{seg(run_id)}/files"
|
|
209
209
|
size = limit or 100
|
|
210
210
|
try:
|
|
211
211
|
client = KiteClient()
|
|
@@ -236,7 +236,7 @@ def download(
|
|
|
236
236
|
"""Download a succeeded run: <out>/<run_id>.tar.gz, sha256-verified, unpacked to <out>/<run_id>/."""
|
|
237
237
|
try:
|
|
238
238
|
client = KiteClient(timeout=120)
|
|
239
|
-
print_json(_save(client, client.get(f"/v1/evaluations/{run_id}"), _out_dir(out), extract=extract))
|
|
239
|
+
print_json(_save(client, client.get(f"/v1/evaluations/{seg(run_id)}"), _out_dir(out), extract=extract))
|
|
240
240
|
except KiteAPIError as e:
|
|
241
241
|
print_error(e.message, code=e.code, details=e.details)
|
|
242
242
|
|
|
@@ -246,7 +246,7 @@ def cancel(run_id: str = typer.Argument(..., help="Evaluation id (eval_...)")):
|
|
|
246
246
|
"""Stop a queued or running run: canceling until its job has stopped, then canceled. It pays the minutes it
|
|
247
247
|
ran."""
|
|
248
248
|
try:
|
|
249
|
-
print_json(KiteClient().post(f"/v1/evaluations/{run_id}/cancel"))
|
|
249
|
+
print_json(KiteClient().post(f"/v1/evaluations/{seg(run_id)}/cancel"))
|
|
250
250
|
except KiteAPIError as e:
|
|
251
251
|
print_error(e.message, code=e.code, details=e.details)
|
|
252
252
|
|
|
@@ -255,7 +255,7 @@ def cancel(run_id: str = typer.Argument(..., help="Evaluation id (eval_...)")):
|
|
|
255
255
|
def resume(run_id: str = typer.Argument(..., help="Evaluation id (eval_...)")):
|
|
256
256
|
"""Run a failed or canceled run again from its request, as a new attempt: it reserves its cap again."""
|
|
257
257
|
try:
|
|
258
|
-
print_json(KiteClient().post(f"/v1/evaluations/{run_id}/resume"))
|
|
258
|
+
print_json(KiteClient().post(f"/v1/evaluations/{seg(run_id)}/resume"))
|
|
259
259
|
except KiteAPIError as e:
|
|
260
260
|
print_error(e.message, code=e.code, details=e.details)
|
|
261
261
|
|
|
@@ -488,7 +488,7 @@ def _twin_edits(client: KiteClient, twin_id: str, local: Path) -> List[str]:
|
|
|
488
488
|
have: Dict[str, str] = {}
|
|
489
489
|
after = None
|
|
490
490
|
while True:
|
|
491
|
-
page = client.get(f"/v1/twins/{twin_id}/files", params={"limit": 100, **({"after": after} if after else {})})
|
|
491
|
+
page = client.get(f"/v1/twins/{seg(twin_id)}/files", params={"limit": 100, **({"after": after} if after else {})})
|
|
492
492
|
have.update((f["path"], f["sha256"]) for f in page.get("data") or [])
|
|
493
493
|
after = page.get("next_cursor")
|
|
494
494
|
if not page.get("has_more") or not after:
|
|
@@ -35,7 +35,7 @@ from typing import List, Optional
|
|
|
35
35
|
import httpx
|
|
36
36
|
import typer
|
|
37
37
|
|
|
38
|
-
from kite_cli.client import KiteAPIError, KiteClient, post_create
|
|
38
|
+
from kite_cli.client import KiteAPIError, KiteClient, post_create, seg
|
|
39
39
|
from kite_cli.output import print_error, print_json
|
|
40
40
|
from kite_cli.progress import wait_for_completion
|
|
41
41
|
|
|
@@ -103,7 +103,7 @@ def estimate(spec: Path = _SPEC):
|
|
|
103
103
|
@app.command()
|
|
104
104
|
def train(
|
|
105
105
|
spec: Path = _SPEC,
|
|
106
|
-
seeds: Optional[int] = typer.Option(None, "--seeds", help="Runs to start, one per seed (1-
|
|
106
|
+
seeds: Optional[int] = typer.Option(None, "--seeds", help="Runs to start, one per seed (1-4)"),
|
|
107
107
|
budget: Optional[str] = typer.Option(
|
|
108
108
|
None, "--budget", help="probe (300 iterations, a first signal in minutes) or standard; replaces the "
|
|
109
109
|
"spec's budget.iterations"
|
|
@@ -143,7 +143,7 @@ def status(
|
|
|
143
143
|
"""A run's live status, phase, progress and metrics; once packaged, its verdict and `output`."""
|
|
144
144
|
try:
|
|
145
145
|
client = KiteClient()
|
|
146
|
-
path = f"/v1/rl_runs/{run_id}"
|
|
146
|
+
path = f"/v1/rl_runs/{seg(run_id)}"
|
|
147
147
|
if wait:
|
|
148
148
|
print_json(wait_for_completion(client, path, terminal_states=_TERMINAL, poll_interval=_POLL_S))
|
|
149
149
|
else:
|
|
@@ -157,7 +157,7 @@ def metrics(run_id: str = _RUN_ID):
|
|
|
157
157
|
"""The training curve, every 5 iterations: mean reward per step, the same by reward term, episode length and
|
|
158
158
|
throughput."""
|
|
159
159
|
try:
|
|
160
|
-
print_json(KiteClient().get(f"/v1/rl_runs/{run_id}/metrics"))
|
|
160
|
+
print_json(KiteClient().get(f"/v1/rl_runs/{seg(run_id)}/metrics"))
|
|
161
161
|
except KiteAPIError as e:
|
|
162
162
|
print_error(e.message, code=e.code, details=e.details)
|
|
163
163
|
|
|
@@ -167,7 +167,7 @@ def report(run_id: str = _RUN_ID):
|
|
|
167
167
|
"""The verdict and how it was reached: each check with its value and limit, the metrics, the judge's read of the
|
|
168
168
|
clip, and the checkpoint chosen. run_not_ready until the run is packaged."""
|
|
169
169
|
try:
|
|
170
|
-
print_json(KiteClient().get(f"/v1/rl_runs/{run_id}/report"))
|
|
170
|
+
print_json(KiteClient().get(f"/v1/rl_runs/{seg(run_id)}/report"))
|
|
171
171
|
except KiteAPIError as e:
|
|
172
172
|
print_error(e.message, code=e.code, details=e.details)
|
|
173
173
|
|
|
@@ -175,7 +175,7 @@ def report(run_id: str = _RUN_ID):
|
|
|
175
175
|
@app.command()
|
|
176
176
|
def files(run_id: str = _RUN_ID):
|
|
177
177
|
"""Every file in a packaged run's bundle (path, bytes, sha256), sorted by path, following the cursor."""
|
|
178
|
-
path, params = f"/v1/rl_runs/{run_id}/files", {"limit": 100}
|
|
178
|
+
path, params = f"/v1/rl_runs/{seg(run_id)}/files", {"limit": 100}
|
|
179
179
|
try:
|
|
180
180
|
client = KiteClient()
|
|
181
181
|
data: list = []
|
|
@@ -207,7 +207,7 @@ def download(
|
|
|
207
207
|
def checkpoints(run_id: str = _RUN_ID):
|
|
208
208
|
"""The iterations the run saved (about every tenth of its budget, and the last)."""
|
|
209
209
|
try:
|
|
210
|
-
print_json(KiteClient().get(f"/v1/rl_runs/{run_id}/checkpoints"))
|
|
210
|
+
print_json(KiteClient().get(f"/v1/rl_runs/{seg(run_id)}/checkpoints"))
|
|
211
211
|
except KiteAPIError as e:
|
|
212
212
|
print_error(e.message, code=e.code, details=e.details)
|
|
213
213
|
|
|
@@ -223,7 +223,7 @@ def checkpoint(
|
|
|
223
223
|
"""Download one saved iteration of a run's policy."""
|
|
224
224
|
dest = (out or Path(f"{run_id}_{iteration}.{fmt}")).expanduser().resolve()
|
|
225
225
|
try:
|
|
226
|
-
KiteClient(timeout=120).download(f"/v1/rl_runs/{run_id}/checkpoints/{iteration}/download?format={fmt}", str(dest))
|
|
226
|
+
KiteClient(timeout=120).download(f"/v1/rl_runs/{seg(run_id)}/checkpoints/{iteration}/download?format={fmt}", str(dest))
|
|
227
227
|
print_json({"id": run_id, "iteration": iteration, "format": fmt, "path": str(dest)})
|
|
228
228
|
except KiteAPIError as e:
|
|
229
229
|
print_error(e.message, code=e.code, details=e.details)
|
|
@@ -235,7 +235,7 @@ def cancel(run_id: str = _RUN_ID):
|
|
|
235
235
|
then canceled with its outputs, charged for the minutes it trained. One that never started, or left nothing to
|
|
236
236
|
package, is refunded in full."""
|
|
237
237
|
try:
|
|
238
|
-
print_json(KiteClient().post(f"/v1/rl_runs/{run_id}/cancel"))
|
|
238
|
+
print_json(KiteClient().post(f"/v1/rl_runs/{seg(run_id)}/cancel"))
|
|
239
239
|
except KiteAPIError as e:
|
|
240
240
|
print_error(e.message, code=e.code, details=e.details)
|
|
241
241
|
|
|
@@ -245,13 +245,13 @@ def fork(
|
|
|
245
245
|
run_id: str = _RUN_ID,
|
|
246
246
|
overrides: List[str] = typer.Option([], "--set", help="key=value: a reward or randomization parameter "
|
|
247
247
|
"(repeatable; `kite rl catalog` lists them)"),
|
|
248
|
-
seeds: Optional[int] = typer.Option(None, "--seeds", help="Runs to start, one per seed (1-
|
|
248
|
+
seeds: Optional[int] = typer.Option(None, "--seeds", help="Runs to start, one per seed (1-4)"),
|
|
249
249
|
idempotency_key: Optional[str] = _KEY,
|
|
250
250
|
):
|
|
251
251
|
"""Train from a run's weights: its robot, task and budget, with the parameters you --set."""
|
|
252
252
|
params = _params(overrides)
|
|
253
253
|
try:
|
|
254
|
-
body = from_run(KiteClient().get(f"/v1/rl_runs/{run_id}"), "fork", params=params)
|
|
254
|
+
body = from_run(KiteClient().get(f"/v1/rl_runs/{seg(run_id)}"), "fork", params=params)
|
|
255
255
|
except KiteAPIError as e:
|
|
256
256
|
print_error(e.message, code=e.code, details=e.details)
|
|
257
257
|
return
|
|
@@ -269,7 +269,7 @@ def continue_run(
|
|
|
269
269
|
):
|
|
270
270
|
"""Keep training a run: its weights, schedule and optimizer, with its robot, task and budget."""
|
|
271
271
|
try:
|
|
272
|
-
body = from_run(KiteClient().get(f"/v1/rl_runs/{run_id}"), "continue", iterations=iterations)
|
|
272
|
+
body = from_run(KiteClient().get(f"/v1/rl_runs/{seg(run_id)}"), "continue", iterations=iterations)
|
|
273
273
|
except KiteAPIError as e:
|
|
274
274
|
print_error(e.message, code=e.code, details=e.details)
|
|
275
275
|
return
|
|
@@ -336,11 +336,11 @@ def _unzip(client: KiteClient, run_id: str, out: Path) -> Path:
|
|
|
336
336
|
unpack it into `out`; keeps no zip. A mismatch, or a file outside kiteml_<run_id>/, refuses the whole archive."""
|
|
337
337
|
if not re.fullmatch(r"[A-Za-z0-9_-]+", run_id):
|
|
338
338
|
raise KiteAPIError(400, f"unexpected run id {run_id!r}", code="parameter_invalid")
|
|
339
|
-
expected = str((client.get(f"/v1/rl_runs/{run_id}").get("output") or {}).get("sha256") or "").lower()
|
|
339
|
+
expected = str((client.get(f"/v1/rl_runs/{seg(run_id)}").get("output") or {}).get("sha256") or "").lower()
|
|
340
340
|
out.mkdir(parents=True, exist_ok=True)
|
|
341
341
|
part = out / f"{run_id}.zip.part"
|
|
342
342
|
try:
|
|
343
|
-
client.download(f"/v1/rl_runs/{run_id}/archive", str(part))
|
|
343
|
+
client.download(f"/v1/rl_runs/{seg(run_id)}/archive", str(part))
|
|
344
344
|
if expected and hashlib.sha256(part.read_bytes()).hexdigest() != expected:
|
|
345
345
|
raise KiteAPIError(502, f"{run_id}.zip does not match its sha256; download it again",
|
|
346
346
|
code="archive_invalid")
|
|
@@ -4,11 +4,14 @@ MuJoCo scene out (about 100 minutes per twin).
|
|
|
4
4
|
kite twin validate lerobot/svla_so101_pickplace [--camera side] free: cameras, episodes, time and price
|
|
5
5
|
kite twin validate s3://my-bucket/my_dataset --robot so101 a dataset in a public S3 bucket
|
|
6
6
|
kite twin create lerobot/svla_so101_pickplace --wait --out ./twins -> ./twins/twin_.../scene.xml
|
|
7
|
-
kite twin status twin_01K... [--wait]
|
|
7
|
+
kite twin status twin_01K... [--wait] while it builds, also its rounds, agents, open question and notes
|
|
8
8
|
kite twin list [--limit 20] [--after twin_...]
|
|
9
9
|
kite twin files twin_01K... [--limit 20] [--after PATH] [--all] what the archive holds, once succeeded
|
|
10
10
|
kite twin cancel twin_01K... -> canceling, then canceled once the build has stopped
|
|
11
|
-
kite twin resume twin_01K...
|
|
11
|
+
kite twin resume twin_01K... [--from-round N] --from-round goes back to a kept round, building or not
|
|
12
|
+
kite twin note twin_01K... "It is 2.5 cm, a matte red cube" [--on red_block] read by the agents next step
|
|
13
|
+
kite twin note twin_01K... --delete note_01K...
|
|
14
|
+
kite twin answer twin_01K... "2.5 cm" answers the twin's open question
|
|
12
15
|
kite twin download twin_01K... [--out DIR] [--no-extract]
|
|
13
16
|
|
|
14
17
|
DATASET is a Hugging Face repo id or URL, which the API takes as {"source": {"type": "huggingface", "repo_id": DATASET}},
|
|
@@ -32,7 +35,7 @@ import httpx
|
|
|
32
35
|
import typer
|
|
33
36
|
|
|
34
37
|
from kite_cli.archive import storage_client, unpack, verified
|
|
35
|
-
from kite_cli.client import KiteAPIError, KiteClient, post_create
|
|
38
|
+
from kite_cli.client import KiteAPIError, KiteClient, post_create, seg
|
|
36
39
|
from kite_cli.output import print_error, print_json
|
|
37
40
|
from kite_cli.progress import wait_for_completion
|
|
38
41
|
|
|
@@ -116,10 +119,11 @@ def status(
|
|
|
116
119
|
twin_id: str = typer.Argument(..., help="Twin id (twin_...)"),
|
|
117
120
|
wait: bool = typer.Option(False, "--wait", help="Poll until succeeded | failed | canceled"),
|
|
118
121
|
):
|
|
119
|
-
"""A twin's live status, progress, stage and stage measurements;
|
|
122
|
+
"""A twin's live status, progress, stage and stage measurements; while it builds, its rounds (scores, layer scores,
|
|
123
|
+
issues), agents, open question and notes; `download` once succeeded."""
|
|
120
124
|
try:
|
|
121
125
|
client = KiteClient()
|
|
122
|
-
path = f"/v1/twins/{twin_id}"
|
|
126
|
+
path = f"/v1/twins/{seg(twin_id)}"
|
|
123
127
|
if wait:
|
|
124
128
|
print_json(wait_for_completion(client, path, terminal_states=_TERMINAL, poll_interval=_POLL_S))
|
|
125
129
|
else:
|
|
@@ -151,7 +155,7 @@ def list_files(
|
|
|
151
155
|
all_pages: bool = typer.Option(False, "--all", help="Follow next_cursor through every page; print one list"),
|
|
152
156
|
):
|
|
153
157
|
"""The files in a succeeded twin's archive (path, bytes, sha256), sorted by path; twin_not_ready before that."""
|
|
154
|
-
path = f"/v1/twins/{twin_id}/files"
|
|
158
|
+
path = f"/v1/twins/{seg(twin_id)}/files"
|
|
155
159
|
size = limit if limit is not None else (100 if all_pages else 20)
|
|
156
160
|
try:
|
|
157
161
|
client = KiteClient()
|
|
@@ -176,21 +180,72 @@ def cancel(twin_id: str = typer.Argument(..., help="Twin id (twin_...)")):
|
|
|
176
180
|
"""Stop a queued or processing twin: it reads canceling until the build has stopped, then canceled. The
|
|
177
181
|
stages it finished stay cached for a resume."""
|
|
178
182
|
try:
|
|
179
|
-
print_json(KiteClient().post(f"/v1/twins/{twin_id}/cancel"))
|
|
183
|
+
print_json(KiteClient().post(f"/v1/twins/{seg(twin_id)}/cancel"))
|
|
180
184
|
except KiteAPIError as e:
|
|
181
185
|
print_error(e.message, code=e.code, details=e.details)
|
|
182
186
|
|
|
183
187
|
|
|
184
188
|
@app.command()
|
|
185
|
-
def resume(
|
|
189
|
+
def resume(
|
|
190
|
+
twin_id: str = typer.Argument(..., help="Twin id (twin_...)"),
|
|
191
|
+
from_round: Optional[int] = typer.Option(
|
|
192
|
+
None, "--from-round", min=0, help="Go back to this kept round (rounds[].kept): a failed or canceled twin "
|
|
193
|
+
"resumes from it; a building one starts its next round from it, free"
|
|
194
|
+
),
|
|
195
|
+
):
|
|
186
196
|
"""Re-queue a failed or canceled twin; only the stages that did not finish run again. Free while it's paid for;
|
|
187
|
-
a twin that was refunded is charged 25,000 tokens again."""
|
|
197
|
+
a twin that was refunded is charged 25,000 tokens again. --from-round goes back to a kept round."""
|
|
188
198
|
try:
|
|
189
|
-
print_json(KiteClient().post(f"/v1/twins/{twin_id}/resume"))
|
|
199
|
+
print_json(KiteClient().post(f"/v1/twins/{seg(twin_id)}/resume", json_data=_body(from_round=from_round) or None))
|
|
190
200
|
except KiteAPIError as e:
|
|
191
201
|
print_error(e.message, code=e.code, details=e.details)
|
|
192
202
|
|
|
193
203
|
|
|
204
|
+
@app.command()
|
|
205
|
+
def note(
|
|
206
|
+
twin_id: str = typer.Argument(..., help="Twin id (twin_...)"),
|
|
207
|
+
text: Optional[str] = typer.Argument(None, help="What is wrong, a size, a colour (up to 2,000 characters)"),
|
|
208
|
+
on: Optional[str] = typer.Option(None, "--on", help="What it is about: a layer (registration, objects, table, "
|
|
209
|
+
"room, motion) or a body in the twin's scene; default the whole twin"),
|
|
210
|
+
delete: Optional[str] = typer.Option(None, "--delete", help="Remove this note (note_...) instead"),
|
|
211
|
+
):
|
|
212
|
+
"""Leave a note for the agents building a twin, read at their next step until it is deleted or the twin ends
|
|
213
|
+
(free); or --delete one."""
|
|
214
|
+
try:
|
|
215
|
+
client = KiteClient()
|
|
216
|
+
if delete:
|
|
217
|
+
client.delete(f"/v1/twins/{seg(twin_id)}/notes/{seg(delete)}")
|
|
218
|
+
print_json({"id": delete, "deleted": True})
|
|
219
|
+
elif text:
|
|
220
|
+
print_json(client.post(f"/v1/twins/{seg(twin_id)}/notes", json_data=_body(text=text, on=on)))
|
|
221
|
+
else:
|
|
222
|
+
print_error("give the note's text, or --delete NOTE_ID", code="parameter_invalid")
|
|
223
|
+
except KiteAPIError as e:
|
|
224
|
+
print_error(e.message, code=e.code, details=e.details)
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@app.command()
|
|
228
|
+
def answer(
|
|
229
|
+
twin_id: str = typer.Argument(..., help="Twin id (twin_...)"),
|
|
230
|
+
text: str = typer.Argument(..., help="One of the question's options, or your own words (up to 500 characters)"),
|
|
231
|
+
):
|
|
232
|
+
"""Answer the twin's open question (see `status`): the answer becomes a note the agents read at their next step.
|
|
233
|
+
Free."""
|
|
234
|
+
try:
|
|
235
|
+
print_json(answer_question(KiteClient(), twin_id, text))
|
|
236
|
+
except KiteAPIError as e:
|
|
237
|
+
print_error(e.message, code=e.code, details=e.details)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def answer_question(client: KiteClient, twin_id: str, text: str) -> dict:
|
|
241
|
+
"""Answer the question a GET of the twin shows open; question_closed when there is none. Shared with the MCP
|
|
242
|
+
tool kite_twin_answer."""
|
|
243
|
+
question = client.get(f"/v1/twins/{seg(twin_id)}").get("question")
|
|
244
|
+
if not question:
|
|
245
|
+
raise KiteAPIError(409, f"Twin '{twin_id}' has no open question.", code="question_closed")
|
|
246
|
+
return client.post(f"/v1/twins/{seg(twin_id)}/answers", json_data={"question": question["id"], "answer": text})
|
|
247
|
+
|
|
248
|
+
|
|
194
249
|
@app.command()
|
|
195
250
|
def download(
|
|
196
251
|
twin_id: str = typer.Argument(..., help="Twin id (twin_...)"),
|
|
@@ -202,7 +257,7 @@ def download(
|
|
|
202
257
|
"""Download a succeeded twin: <out>/<twin_id>.tar.gz, sha256-verified, unpacked to <out>/<twin_id>/scene.xml."""
|
|
203
258
|
try:
|
|
204
259
|
client = KiteClient(timeout=120)
|
|
205
|
-
print_json(_save(client, client.get(f"/v1/twins/{twin_id}"), _out_dir(out), extract=extract))
|
|
260
|
+
print_json(_save(client, client.get(f"/v1/twins/{seg(twin_id)}"), _out_dir(out), extract=extract))
|
|
206
261
|
except KiteAPIError as e:
|
|
207
262
|
print_error(e.message, code=e.code, details=e.details)
|
|
208
263
|
|
|
@@ -101,5 +101,18 @@ def doctor():
|
|
|
101
101
|
raise typer.Exit(code=1)
|
|
102
102
|
|
|
103
103
|
|
|
104
|
+
def main() -> None:
|
|
105
|
+
"""The `kite` command: the app, with a request that never got an answer (a timeout, no connection, a URL httpx
|
|
106
|
+
refuses) printed as a structured error like the API's own, never a traceback."""
|
|
107
|
+
import httpx
|
|
108
|
+
|
|
109
|
+
from kite_cli.output import print_error
|
|
110
|
+
|
|
111
|
+
try:
|
|
112
|
+
app()
|
|
113
|
+
except (httpx.HTTPError, httpx.InvalidURL) as e:
|
|
114
|
+
print_error(f"{type(e).__name__}: {e}", code="network_error")
|
|
115
|
+
|
|
116
|
+
|
|
104
117
|
if __name__ == "__main__":
|
|
105
|
-
|
|
118
|
+
main()
|
|
@@ -14,10 +14,14 @@ Shared by both CLI commands and the MCP server.
|
|
|
14
14
|
from __future__ import annotations
|
|
15
15
|
|
|
16
16
|
import json
|
|
17
|
+
import os
|
|
18
|
+
import socket
|
|
17
19
|
import sys
|
|
18
20
|
import time
|
|
19
21
|
from pathlib import Path
|
|
20
22
|
from typing import Any, BinaryIO, Dict, Optional
|
|
23
|
+
from urllib.parse import quote
|
|
24
|
+
from urllib.request import getproxies
|
|
21
25
|
|
|
22
26
|
import httpx
|
|
23
27
|
|
|
@@ -32,6 +36,24 @@ API_VERSION = "2026-10-12"
|
|
|
32
36
|
VERSION_HEADER = "Kite-Version"
|
|
33
37
|
|
|
34
38
|
|
|
39
|
+
# TCP keepalive every 2 s on the API connection: a network that drops a connection idle for a few seconds would
|
|
40
|
+
# otherwise lose the answer to a call the API takes ~10 s over (`kite rl plan`). TCP_KEEPIDLE is Linux's (and
|
|
41
|
+
# Windows') name for the idle time, TCP_KEEPALIVE macOS's; each option is set only where the platform has it.
|
|
42
|
+
_KEEPALIVE = [(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)] + [
|
|
43
|
+
(socket.IPPROTO_TCP, getattr(socket, name), 2)
|
|
44
|
+
for name in ("TCP_KEEPIDLE", "TCP_KEEPALIVE", "TCP_KEEPINTVL") if hasattr(socket, name)]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def seg(value: Any) -> str:
|
|
48
|
+
"""A caller's value (a run id, a twin id) as one URL path segment, percent-encoded, so it can't leave its
|
|
49
|
+
resource (`../credits`), add a segment (`x/resume`) or end the path early (`?`, `#`). `.` and `..` alone are
|
|
50
|
+
refused: no encoding stops a URL from resolving them."""
|
|
51
|
+
s = quote(str(value), safe="")
|
|
52
|
+
if s in ("", ".", ".."):
|
|
53
|
+
raise KiteAPIError(400, f"{value!r} is not an id", code="parameter_invalid")
|
|
54
|
+
return s
|
|
55
|
+
|
|
56
|
+
|
|
35
57
|
def user_agent(surface: str = "kite-cli") -> str:
|
|
36
58
|
"""The User-Agent every request sends: `kite-cli/<version>`, or `kite-mcp/<version>` from the MCP server. The
|
|
37
59
|
API's request log and run attribution read the surface from this prefix."""
|
|
@@ -88,10 +110,13 @@ class KiteClient:
|
|
|
88
110
|
self.base_url = (api_url or get_api_url()).rstrip("/")
|
|
89
111
|
self._token_override = token
|
|
90
112
|
self._user_agent = user_agent(surface)
|
|
113
|
+
# httpx ignores the proxy settings once it is given a transport, so behind a proxy it keeps its own.
|
|
114
|
+
proxied = getproxies().keys() & {"http", "https", "all"}
|
|
91
115
|
self._client = httpx.Client(
|
|
92
116
|
base_url=self.base_url,
|
|
93
117
|
timeout=timeout,
|
|
94
118
|
follow_redirects=True,
|
|
119
|
+
transport=None if proxied else httpx.HTTPTransport(socket_options=_KEEPALIVE),
|
|
95
120
|
)
|
|
96
121
|
|
|
97
122
|
def _base_headers(self) -> Dict[str, str]:
|
|
@@ -106,10 +131,21 @@ class KiteClient:
|
|
|
106
131
|
def _headers(self) -> Dict[str, str]:
|
|
107
132
|
return {"Content-Type": "application/json", **self._base_headers()}
|
|
108
133
|
|
|
134
|
+
def _error(self, resp: httpx.Response) -> KiteAPIError:
|
|
135
|
+
"""The response's error. A key missing a scope that is the KITE_API_KEY set in the environment says so: it is
|
|
136
|
+
used ahead of `kite auth login`'s key, so a stale one there is easy to miss."""
|
|
137
|
+
e = _api_error(resp)
|
|
138
|
+
env_key = os.environ.get("KITE_API_KEY")
|
|
139
|
+
if e.code == "missing_scope" and env_key and env_key == (self._token_override or get_token()):
|
|
140
|
+
e = KiteAPIError(e.status_code, f"{e.message} (the key is KITE_API_KEY from the environment, used instead "
|
|
141
|
+
"of your `kite auth login` key: unset it or give it the scope)",
|
|
142
|
+
code=e.code, details=e.details, param=e.param, request_id=e.request_id)
|
|
143
|
+
return e
|
|
144
|
+
|
|
109
145
|
def _handle_response(self, resp: httpx.Response) -> dict:
|
|
110
146
|
"""Parse response, raise KiteAPIError on non-2xx."""
|
|
111
147
|
if resp.status_code >= 400:
|
|
112
|
-
raise
|
|
148
|
+
raise self._error(resp)
|
|
113
149
|
|
|
114
150
|
if resp.status_code == 204:
|
|
115
151
|
return {"ok": True}
|
|
@@ -155,7 +191,7 @@ class KiteClient:
|
|
|
155
191
|
with self._client.stream("GET", path, headers=headers) as resp:
|
|
156
192
|
if resp.status_code >= 400:
|
|
157
193
|
resp.read()
|
|
158
|
-
raise
|
|
194
|
+
raise self._error(resp)
|
|
159
195
|
resp.raise_for_status()
|
|
160
196
|
with open(output_path, "wb") as f:
|
|
161
197
|
for chunk in resp.iter_bytes(chunk_size=8192):
|
|
@@ -169,7 +205,7 @@ class KiteClient:
|
|
|
169
205
|
return resp.headers.get("location")
|
|
170
206
|
if resp.status_code >= 400:
|
|
171
207
|
resp.read()
|
|
172
|
-
raise
|
|
208
|
+
raise self._error(resp)
|
|
173
209
|
return None
|
|
174
210
|
|
|
175
211
|
def close(self) -> None:
|
|
@@ -18,5 +18,8 @@ def ok(data: Any) -> list[TextContent]:
|
|
|
18
18
|
return [TextContent(type="text", text=json.dumps({"ok": True, "data": data}, default=str, indent=2))]
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def err(message: str) -> list[TextContent]:
|
|
22
|
-
|
|
21
|
+
def err(message: str, **fields: Any) -> list[TextContent]:
|
|
22
|
+
"""`{"ok": false, "error": message}` plus whichever of `fields` are set: an API error's `code`, `status` and
|
|
23
|
+
`details`, the same fields the CLI prints, so an agent can act on the code instead of parsing the message."""
|
|
24
|
+
extra = {k: v for k, v in fields.items() if v}
|
|
25
|
+
return [TextContent(type="text", text=json.dumps({"ok": False, "error": message, **extra}, default=str))]
|
|
@@ -18,6 +18,7 @@ import json
|
|
|
18
18
|
import logging
|
|
19
19
|
import os
|
|
20
20
|
import sys
|
|
21
|
+
import uuid
|
|
21
22
|
|
|
22
23
|
try:
|
|
23
24
|
from mcp.server import Server
|
|
@@ -27,7 +28,8 @@ except ModuleNotFoundError as e: # `pip install kiteml-cli` without the extra i
|
|
|
27
28
|
raise ModuleNotFoundError('kite-mcp needs the MCP extra: pip install "kiteml-cli[mcp]"', name=e.name) from e
|
|
28
29
|
|
|
29
30
|
from kite_cli import __version__
|
|
30
|
-
from kite_cli.client import KiteClient, KiteAPIError
|
|
31
|
+
from kite_cli.client import KiteClient, KiteAPIError, post_create, seg
|
|
32
|
+
from kite_cli.config import get_app_url
|
|
31
33
|
from kite_cli.mcp.common import DESTRUCTIVE, READ, WRITE, err as _err, ok as _ok
|
|
32
34
|
|
|
33
35
|
logger = logging.getLogger(__name__)
|
|
@@ -40,7 +42,7 @@ _request_token: contextvars.ContextVar[str | None] = contextvars.ContextVar(
|
|
|
40
42
|
)
|
|
41
43
|
|
|
42
44
|
|
|
43
|
-
def _client() -> KiteClient:
|
|
45
|
+
def _client(timeout: float = 30.0) -> KiteClient:
|
|
44
46
|
"""Create a KiteClient. In HTTP mode, uses the per-request token from the
|
|
45
47
|
Authorization header. In stdio mode, falls back to env vars."""
|
|
46
48
|
token = (
|
|
@@ -48,7 +50,7 @@ def _client() -> KiteClient:
|
|
|
48
50
|
or os.environ.get("KITE_API_KEY")
|
|
49
51
|
or os.environ.get("KITE_TOKEN")
|
|
50
52
|
)
|
|
51
|
-
return KiteClient(api_url=os.environ.get("KITE_API_URL"), token=token, surface="kite-mcp")
|
|
53
|
+
return KiteClient(api_url=os.environ.get("KITE_API_URL"), token=token, timeout=timeout, surface="kite-mcp")
|
|
52
54
|
|
|
53
55
|
|
|
54
56
|
def _fetch_command(d: dict, fname: str, client: KiteClient) -> str:
|
|
@@ -82,9 +84,12 @@ def _twin_view(twin: dict, client: KiteClient) -> dict:
|
|
|
82
84
|
+ (f" (link valid until {d['expires_at']}; call kite_twin_status again for a fresh one)"
|
|
83
85
|
if d.get("expires_at") else ""))
|
|
84
86
|
elif status in ("queued", "processing"):
|
|
85
|
-
eta = twin.get("eta_seconds")
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
eta, q = twin.get("eta_seconds"), twin.get("question")
|
|
88
|
+
wait = ("call kite_twin_status again in a few minutes"
|
|
89
|
+
+ (f" (stage {twin['stage']}, about {max(1, eta // 60)} min left)" if eta and twin.get("stage") else ""))
|
|
90
|
+
out["next"] = (f'kite_twin_answer {tid} answers the agents\' open question "{q.get("text")}"'
|
|
91
|
+
+ (f" (options: {', '.join(q['options'])})" if q.get("options") else "")
|
|
92
|
+
+ f'; until then the build carries on with "{q.get("default")}". Then {wait}') if q else wait
|
|
88
93
|
elif status == "canceling":
|
|
89
94
|
out["next"] = ("call kite_twin_status again in a few seconds: the cancel was accepted and the build is "
|
|
90
95
|
"stopping; it then reads canceled")
|
|
@@ -148,6 +153,8 @@ def _rl_view(run: dict, client: KiteClient) -> dict:
|
|
|
148
153
|
cannot write to the agent's disk, so a packaged run's `next` is the exact command that fetches its bundle."""
|
|
149
154
|
out = dict(run)
|
|
150
155
|
status, rid = run.get("status"), run.get("id")
|
|
156
|
+
charged = int((run.get("tokens") or {}).get("charged") or 0)
|
|
157
|
+
cost = f"it was charged {charged:,} tokens" if charged else "nothing was charged"
|
|
151
158
|
if run.get("output"): # packaged: succeeded, or canceled after it trained
|
|
152
159
|
url = f"{client.base_url.rstrip('/')}{run['output']['archive_url']}"
|
|
153
160
|
top = f"kiteml_{rid}"
|
|
@@ -160,11 +167,24 @@ def _rl_view(run: dict, client: KiteClient) -> dict:
|
|
|
160
167
|
elif status == "canceling":
|
|
161
168
|
out["next"] = ("the cancel was accepted: the run stops, keeps the policy it has and is packaged, then reads "
|
|
162
169
|
"canceled; call kite_rl_status again in a few minutes")
|
|
170
|
+
elif run.get("studio_run_id"): # made in RL Studio, which keeps its policy, report and checkpoints
|
|
171
|
+
sid, trained = run["studio_run_id"], int((run.get("metrics") or {}).get("iteration") or 0)
|
|
172
|
+
studio = f"open {get_app_url().rstrip('/')}/rl-studio?run={sid}"
|
|
173
|
+
if status == "succeeded":
|
|
174
|
+
clip = f"{client.base_url.rstrip('/')}/v1/rl_runs/{rid}/files/media/video.mp4"
|
|
175
|
+
out["next"] = (f"made in RL Studio, which keeps its policy, report and publishing: {studio}. Its clip: "
|
|
176
|
+
f'curl -fL -H "Authorization: Bearer $KITE_API_KEY" "{clip}" -o {rid}.mp4')
|
|
177
|
+
elif trained or charged:
|
|
178
|
+
out["next"] = (f"{status} at iteration {trained} in RL Studio, which keeps any policy it saved: {studio}; "
|
|
179
|
+
f"{cost}" + ("; read `error`" if status == "failed" else ""))
|
|
180
|
+
else:
|
|
181
|
+
out["next"] = f"{status} before it trained, so there is nothing to download and {cost}"
|
|
163
182
|
elif status == "failed":
|
|
164
|
-
out["next"] = "read `error
|
|
183
|
+
out["next"] = (f"read `error` ({cost}), then start a new run with kite_rl_train (or kite_rl_fork from a run "
|
|
184
|
+
"that trained)")
|
|
165
185
|
elif status == "canceled":
|
|
166
|
-
out["next"] = ("it was canceled before it saved a policy, so there is nothing to download and
|
|
167
|
-
"
|
|
186
|
+
out["next"] = (f"it was canceled before it saved a policy, so there is nothing to download and {cost}; start "
|
|
187
|
+
"a new run with kite_rl_train")
|
|
168
188
|
return out
|
|
169
189
|
|
|
170
190
|
|
|
@@ -187,7 +207,7 @@ _RL_SPEC = {
|
|
|
187
207
|
"kite_rl_plan writes one"},
|
|
188
208
|
"budget": {"type": "object", "description": "{preset: probe | standard, iterations?, num_envs?, max_tokens?}; "
|
|
189
209
|
"probe is 300 iterations, a first signal in minutes. Optional"},
|
|
190
|
-
"seeds": {"type": "integer", "description": "Runs to start, one per seed (1-
|
|
210
|
+
"seeds": {"type": "integer", "description": "Runs to start, one per seed (1-4, default 1). Optional"},
|
|
191
211
|
"from": {"type": "object", "description": "Start from a trained policy instead of from scratch: {run: rlr_..., "
|
|
192
212
|
"mode: fork | continue} or {policy: <public policy id>}. Optional"},
|
|
193
213
|
"description": {"type": "string", "description": "What the behavior should look like; the report compares the "
|
|
@@ -283,7 +303,7 @@ TOOLS = [
|
|
|
283
303
|
"idempotency_key": {"type": "string", "description": "Reuse the same key when retrying, so a retry never builds twice. Optional"}},
|
|
284
304
|
"required": ["dataset", "robot"]}, annotations=_WRITE),
|
|
285
305
|
Tool(name="kite_twin_status", title="Get Digital Twin Status",
|
|
286
|
-
description="Get a twin's status (queued/processing/canceling/succeeded/failed/canceled), stage, progress, each finished stage's measurement, and a `next` instruction. canceling means a cancel was accepted but the build has not stopped yet; it becomes canceled. When succeeded, `download.url` is a direct link to the whole scene as one .tar.gz and `next` is the exact command to fetch and extract it (the folder contains scene.xml for MuJoCo).",
|
|
306
|
+
description="Get a twin's status (queued/processing/canceling/succeeded/failed/canceled), stage, progress, each finished stage's measurement, and a `next` instruction. canceling means a cancel was accepted but the build has not stopped yet; it becomes canceled. While it builds: `rounds` (each judged round's score against target_score, its layer scores, summary and issues; `best_round` becomes the download), `agents` (what each is doing), `question` (an agent's open question, which `next` names: answer it with kite_twin_answer) and `notes` (yours, queued or read). When succeeded, `download.url` is a direct link to the whole scene as one .tar.gz and `next` is the exact command to fetch and extract it (the folder contains scene.xml for MuJoCo).",
|
|
287
307
|
inputSchema={"type": "object", "properties": {
|
|
288
308
|
"twin_id": {"type": "string", "description": "Twin id (twin_...) from kite_twin_create"}},
|
|
289
309
|
"required": ["twin_id"]}, annotations=_READ),
|
|
@@ -297,10 +317,25 @@ TOOLS = [
|
|
|
297
317
|
"twin_id": {"type": "string", "description": "Twin id (twin_...)"}},
|
|
298
318
|
"required": ["twin_id"]}, annotations=_DESTRUCTIVE),
|
|
299
319
|
Tool(name="kite_twin_resume", title="Resume Digital Twin",
|
|
300
|
-
description="Re-queue a failed or canceled twin. Every stage it finished is cached, so only what did not finish runs again. Free while the twin is paid for; one that was refunded (it ended before authoring) is charged 25,000 tokens again.",
|
|
320
|
+
description="Re-queue a failed or canceled twin. Every stage it finished is cached, so only what did not finish runs again. Free while the twin is paid for; one that was refunded (it ended before authoring) is charged 25,000 tokens again. With from_round, go back to a kept round (rounds[].kept, else round_not_kept): a failed or canceled twin resumes from that round's snapshot, and a building twin starts its next round from it once the current round finishes, free.",
|
|
301
321
|
inputSchema={"type": "object", "properties": {
|
|
302
|
-
"twin_id": {"type": "string", "description": "Twin id (twin_...)"}
|
|
322
|
+
"twin_id": {"type": "string", "description": "Twin id (twin_...)"},
|
|
323
|
+
"from_round": {"type": "integer", "minimum": 0, "description": "A kept round to go back to (kite_twin_status lists rounds). Optional"}},
|
|
324
|
+
"required": ["twin_id"]}, annotations=_WRITE),
|
|
325
|
+
Tool(name="kite_twin_note", title="Leave a Note for a Digital Twin's Agents",
|
|
326
|
+
description="Leave a note for the agents building a twin: what is wrong, a size, a colour, about one thing in the scene (`on`) or the whole twin. Every agent step reads it until it is deleted or the twin ends; it reads queued, then read with read_in_round, and the next round's scores and issues show whether it helped. With `delete` (a note id), removes that note instead. Free; twin_not_building once the twin has ended, too_many_notes past 20 active notes.",
|
|
327
|
+
inputSchema={"type": "object", "properties": {
|
|
328
|
+
"twin_id": {"type": "string", "description": "Twin id (twin_...)"},
|
|
329
|
+
"text": {"type": "string", "description": "The note, up to 2,000 characters (not with delete)"},
|
|
330
|
+
"on": {"type": "string", "description": "What it is about: a layer (registration, objects, table, room, motion) or a body name from the twin's scene (as rounds[].issues[].object names them). Optional: the whole twin"},
|
|
331
|
+
"delete": {"type": "string", "description": "A note id (note_...) to remove instead. Optional"}},
|
|
303
332
|
"required": ["twin_id"]}, annotations=_WRITE),
|
|
333
|
+
Tool(name="kite_twin_answer", title="Answer a Digital Twin's Question",
|
|
334
|
+
description="Answer the open question an agent building a twin asked (kite_twin_status shows it as `question`, with its options and the default the build carries on with meanwhile). The answer becomes a note the agents read at their next step; returns that note. Free; question_closed when no question is open.",
|
|
335
|
+
inputSchema={"type": "object", "properties": {
|
|
336
|
+
"twin_id": {"type": "string", "description": "Twin id (twin_...)"},
|
|
337
|
+
"answer": {"type": "string", "description": "One of the question's options, or your own words (up to 500 characters)"}},
|
|
338
|
+
"required": ["twin_id", "answer"]}, annotations=_WRITE),
|
|
304
339
|
|
|
305
340
|
# Evaluations (public /v1 API): a Kite SDK spec on Kite's machines -> a scorecard and a verifiable run directory
|
|
306
341
|
Tool(name="kite_eval_validate", title="Validate Evaluation",
|
|
@@ -363,6 +398,7 @@ TOOLS = [
|
|
|
363
398
|
description="List your RL training runs, newest first, with their last known status (kite_rl_status has live progress).",
|
|
364
399
|
inputSchema={"type": "object", "properties": {
|
|
365
400
|
"limit": {"type": "integer", "description": "Max rows (1-100, default 20)"},
|
|
401
|
+
"after": {"type": "string", "description": "The previous page's next_cursor, for the page after it. Optional"},
|
|
366
402
|
"group_id": {"type": "string", "description": "Only the runs one kite_rl_train started (rlg_...). Optional"}}},
|
|
367
403
|
annotations=_READ),
|
|
368
404
|
Tool(name="kite_rl_status", title="Get RL Run Status",
|
|
@@ -409,11 +445,15 @@ async def list_tools() -> list[Tool]:
|
|
|
409
445
|
|
|
410
446
|
@server.call_tool()
|
|
411
447
|
async def call_tool(name: str, arguments: dict) -> list[TextContent]:
|
|
448
|
+
from kite_cli.cli.commands.rl import _SLOW_S
|
|
449
|
+
|
|
412
450
|
try:
|
|
413
|
-
|
|
451
|
+
# The RL calls the CLI gives three minutes: plan asks a model, validate rolls policies, create starts jobs.
|
|
452
|
+
client = _client(_SLOW_S if name in ("kite_rl_plan", "kite_rl_validate", "kite_rl_train", "kite_rl_fork")
|
|
453
|
+
else 30.0)
|
|
414
454
|
return await _dispatch(name, arguments, client)
|
|
415
455
|
except KiteAPIError as e:
|
|
416
|
-
return _err(
|
|
456
|
+
return _err(e.message, code=e.code, status=e.status_code, details=e.details)
|
|
417
457
|
except Exception as e:
|
|
418
458
|
return _err(str(e))
|
|
419
459
|
|
|
@@ -460,14 +500,14 @@ async def _dispatch(name: str, args: dict, client: KiteClient) -> list[TextConte
|
|
|
460
500
|
]
|
|
461
501
|
return _ok(client.post("/v1/augmentations", json_data=body))
|
|
462
502
|
if name == "kite_augment_status":
|
|
463
|
-
return _ok(client.get(f"/v1/augmentations/{args['aug_id']}"))
|
|
503
|
+
return _ok(client.get(f"/v1/augmentations/{seg(args['aug_id'])}"))
|
|
464
504
|
if name == "kite_augment_list":
|
|
465
505
|
return _ok(client.get("/v1/augmentations", params={"limit": args.get("limit", 20)}))
|
|
466
506
|
if name == "kite_augment_cancel":
|
|
467
|
-
return _ok(client.post(f"/v1/augmentations/{args['aug_id']}/cancel"))
|
|
507
|
+
return _ok(client.post(f"/v1/augmentations/{seg(args['aug_id'])}/cancel"))
|
|
468
508
|
|
|
469
509
|
# --- Digital twins (public /v1 API) ---
|
|
470
|
-
from kite_cli.cli.commands.twin import twin_source
|
|
510
|
+
from kite_cli.cli.commands.twin import answer_question, twin_source
|
|
471
511
|
|
|
472
512
|
if name == "kite_twin_validate":
|
|
473
513
|
body = {"source": twin_source(args["dataset"]), **{k: args[k] for k in ("camera", "robot") if args.get(k)}}
|
|
@@ -478,13 +518,24 @@ async def _dispatch(name: str, args: dict, client: KiteClient) -> list[TextConte
|
|
|
478
518
|
headers = {"Idempotency-Key": args["idempotency_key"]} if args.get("idempotency_key") else None
|
|
479
519
|
return _ok(_twin_view(client.post("/v1/twins", json_data=body, extra_headers=headers), client))
|
|
480
520
|
if name == "kite_twin_status":
|
|
481
|
-
return _ok(_twin_view(client.get(f"/v1/twins/{args['twin_id']}"), client))
|
|
521
|
+
return _ok(_twin_view(client.get(f"/v1/twins/{seg(args['twin_id'])}"), client))
|
|
482
522
|
if name == "kite_twin_list":
|
|
483
523
|
return _ok(client.get("/v1/twins", params={"limit": args.get("limit", 20)}))
|
|
484
524
|
if name == "kite_twin_cancel":
|
|
485
|
-
return _ok(_twin_view(client.post(f"/v1/twins/{args['twin_id']}/cancel"), client))
|
|
525
|
+
return _ok(_twin_view(client.post(f"/v1/twins/{seg(args['twin_id'])}/cancel"), client))
|
|
486
526
|
if name == "kite_twin_resume":
|
|
487
|
-
|
|
527
|
+
body = {"from_round": args["from_round"]} if args.get("from_round") is not None else None
|
|
528
|
+
return _ok(_twin_view(client.post(f"/v1/twins/{seg(args['twin_id'])}/resume", json_data=body), client))
|
|
529
|
+
if name == "kite_twin_note":
|
|
530
|
+
notes = f"/v1/twins/{seg(args['twin_id'])}/notes"
|
|
531
|
+
if args.get("delete"):
|
|
532
|
+
client.delete(f"{notes}/{seg(args['delete'])}")
|
|
533
|
+
return _ok({"id": args["delete"], "deleted": True})
|
|
534
|
+
if not args.get("text"):
|
|
535
|
+
return _err("pass `text`, or `delete` with a note id")
|
|
536
|
+
return _ok(client.post(notes, json_data={k: args[k] for k in ("text", "on") if args.get(k)}))
|
|
537
|
+
if name == "kite_twin_answer":
|
|
538
|
+
return _ok(answer_question(client, args["twin_id"], args["answer"]))
|
|
488
539
|
|
|
489
540
|
# --- Evaluations (public /v1 API) ---
|
|
490
541
|
if name in ("kite_eval_validate", "kite_eval_run"):
|
|
@@ -501,17 +552,17 @@ async def _dispatch(name: str, args: dict, client: KiteClient) -> list[TextConte
|
|
|
501
552
|
headers = {"Idempotency-Key": args["idempotency_key"]} if args.get("idempotency_key") else None
|
|
502
553
|
return _ok(_eval_view(client.post("/v1/evaluations", json_data=body, extra_headers=headers), client))
|
|
503
554
|
if name == "kite_eval_status":
|
|
504
|
-
return _ok(_eval_view(client.get(f"/v1/evaluations/{args['run_id']}"), client))
|
|
555
|
+
return _ok(_eval_view(client.get(f"/v1/evaluations/{seg(args['run_id'])}"), client))
|
|
505
556
|
if name == "kite_eval_list":
|
|
506
557
|
return _ok(client.get("/v1/evaluations", params={"limit": args.get("limit", 20)}))
|
|
507
558
|
if name == "kite_eval_report":
|
|
508
|
-
return _ok(client.get(f"/v1/evaluations/{args['run_id']}/report"))
|
|
559
|
+
return _ok(client.get(f"/v1/evaluations/{seg(args['run_id'])}/report"))
|
|
509
560
|
if name == "kite_eval_logs":
|
|
510
|
-
return _ok(client.get(f"/v1/evaluations/{args['run_id']}/logs", params={"tail": args.get("tail", 200)}))
|
|
561
|
+
return _ok(client.get(f"/v1/evaluations/{seg(args['run_id'])}/logs", params={"tail": args.get("tail", 200)}))
|
|
511
562
|
if name == "kite_eval_cancel":
|
|
512
|
-
return _ok(_eval_view(client.post(f"/v1/evaluations/{args['run_id']}/cancel"), client))
|
|
563
|
+
return _ok(_eval_view(client.post(f"/v1/evaluations/{seg(args['run_id'])}/cancel"), client))
|
|
513
564
|
if name == "kite_eval_resume":
|
|
514
|
-
return _ok(_eval_view(client.post(f"/v1/evaluations/{args['run_id']}/resume"), client))
|
|
565
|
+
return _ok(_eval_view(client.post(f"/v1/evaluations/{seg(args['run_id'])}/resume"), client))
|
|
515
566
|
|
|
516
567
|
# --- RL runs (public /v1 API) ---
|
|
517
568
|
if name == "kite_rl_catalog":
|
|
@@ -520,31 +571,32 @@ async def _dispatch(name: str, args: dict, client: KiteClient) -> list[TextConte
|
|
|
520
571
|
return _ok(client.post("/v1/rl_runs/plan", json_data=args))
|
|
521
572
|
if name == "kite_rl_validate":
|
|
522
573
|
return _ok(client.post("/v1/rl_runs/validate", json_data=args))
|
|
523
|
-
if name
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
574
|
+
if name in ("kite_rl_train", "kite_rl_fork"):
|
|
575
|
+
# As `kite rl train`: a key of its own when the agent sends none, and a lost answer retried with it, so a
|
|
576
|
+
# retry never trains twice.
|
|
577
|
+
if name == "kite_rl_train":
|
|
578
|
+
body = {k: v for k, v in args.items() if k != "idempotency_key"}
|
|
579
|
+
else:
|
|
580
|
+
from kite_cli.cli.commands.rl import from_run
|
|
581
|
+
|
|
582
|
+
body = from_run(client.get(f"/v1/rl_runs/{seg(args['run_id'])}"), "fork", params=args.get("params"))
|
|
583
|
+
if args.get("seeds"):
|
|
584
|
+
body["seeds"] = args["seeds"]
|
|
585
|
+
key = args.get("idempotency_key") or str(uuid.uuid4())
|
|
586
|
+
return _ok(_rl_runs(post_create(client, "/v1/rl_runs", body, key), client))
|
|
535
587
|
if name == "kite_rl_list":
|
|
536
|
-
params = {"limit": args.get("limit", 20), **
|
|
588
|
+
params = {"limit": args.get("limit", 20), **{k: args[k] for k in ("after", "group_id") if args.get(k)}}
|
|
537
589
|
return _ok(client.get("/v1/rl_runs", params=params))
|
|
538
590
|
if name == "kite_rl_status":
|
|
539
|
-
return _ok(_rl_view(client.get(f"/v1/rl_runs/{args['run_id']}"), client))
|
|
591
|
+
return _ok(_rl_view(client.get(f"/v1/rl_runs/{seg(args['run_id'])}"), client))
|
|
540
592
|
if name == "kite_rl_report":
|
|
541
|
-
return _ok(client.get(f"/v1/rl_runs/{args['run_id']}/report"))
|
|
593
|
+
return _ok(client.get(f"/v1/rl_runs/{seg(args['run_id'])}/report"))
|
|
542
594
|
if name == "kite_rl_metrics":
|
|
543
|
-
rows = client.get(f"/v1/rl_runs/{args['run_id']}/metrics").get("data") or []
|
|
595
|
+
rows = client.get(f"/v1/rl_runs/{seg(args['run_id'])}/metrics").get("data") or []
|
|
544
596
|
step = max(1, (len(rows) + 49) // 50) # at most 50 points, counted back from the latest
|
|
545
597
|
return _ok(rows[::-1][::step][::-1])
|
|
546
598
|
if name == "kite_rl_cancel":
|
|
547
|
-
return _ok(_rl_view(client.post(f"/v1/rl_runs/{args['run_id']}/cancel"), client))
|
|
599
|
+
return _ok(_rl_view(client.post(f"/v1/rl_runs/{seg(args['run_id'])}/cancel"), client))
|
|
548
600
|
|
|
549
601
|
# --- Doctor ---
|
|
550
602
|
if name == "kite_doctor":
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|