@toloka-platform/sdk 0.18.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/cli-v2.md DELETED
@@ -1,224 +0,0 @@
1
- # CLI v2: project as the root
2
-
3
- How `toloka` should work in the next version. Beta remains a clean cutover rather than a compatibility layer.
4
-
5
- The platform object is a **project** (`pp.…`, today's pipeline project). Windmill calls the same role a workspace. PostHog calls it a project. We keep **project** so the CLI matches the API and the console.
6
-
7
- ## Why the current CLI is wrong
8
-
9
- Today the checkout is a pipeline tree that happens to mention a project.
10
-
11
- - A directory is a project root if it has `toloka.json` **or** a `pipelines/` folder. No pipelines, no root.
12
- - `init` writes agent skills before a project exists. It writes `toloka.json` only from an explicit `--project-id`, `TOLOKA_PROJECT_ID`, or an existing checkout; it never binds a new checkout from the machine registry.
13
- - A checkout attaches when `project create` or `import` writes `toloka.json`, or when `init` receives explicit project identity.
14
- - `run`, `status`, `runs`, and `cost` pick a pipeline from `toloka.json`. Zero pipelines is an error. Several pipelines opens a picker. The command names pretend there is "the" pipeline.
15
- - `status` means "latest run of some pipeline", not "this project".
16
-
17
- That design cannot grow. Datasets, secrets, files, checks, and anything we add later are project children. Some projects will never have a pipeline. Searching for a pipeline before those commands can run is the bug.
18
-
19
- Windmill and PostHog both invert this: pick the project (workspace), then operate on resources inside it. A Windmill workspace with no flows is still a workspace. A PostHog project with no dashboards is still a project.
20
-
21
- ## Two layers of context
22
-
23
- ### Machine auth
24
-
25
- `~/.config/toloka/credentials.json` stays the home for the API key and base URL. `login` / `logout` / `whoami` do not need a project.
26
-
27
- The file also becomes a small local registry, Windmill-style:
28
-
29
- ```json
30
- {
31
- "baseUrl": "https://platform.toloka.ai",
32
- "apiKey": "…",
33
- "current": "cat-labeling",
34
- "projects": {
35
- "cat-labeling": { "id": "pp.019f…", "name": "Cat labeling" },
36
- "staging": { "id": "pp.019e…", "name": "Staging" }
37
- }
38
- }
39
- ```
40
-
41
- `current` is a local alias, not a platform field. Same key, several projects, switch without re-login. CI never uses this file.
42
-
43
- ### Checkout
44
-
45
- A directory becomes a project checkout when it contains `toloka.json`. That is the only root marker. `pipelines/` alone is not a project.
46
-
47
- ```json
48
- {
49
- "projectId": "pp.019f…",
50
- "pipelines": {},
51
- "datasets": {}
52
- }
53
- ```
54
-
55
- Empty `pipelines` and `datasets` are valid. Bindings are a cache of live ids after import/apply, not a requirement to run commands. Do not hand-edit this file.
56
-
57
- A checkout can later grow other folders (`datasets/`, `files/`, whatever we author). None of them define the root.
58
-
59
- ## How a command finds its project
60
-
61
- Highest wins:
62
-
63
- 1. `--project-id`
64
- 2. `TOLOKA_PROJECT_ID` (the legacy `POTATO_*` names are still read for one preview cycle with a deprecation warning)
65
- 3. `toloka.json` in the discovered checkout (walk up from cwd, or `--source-root`)
66
- 4. `current` in the machine registry
67
- 5. Fail: `No project selected. Run toloka project create for a new project, toloka project add for an existing project, or cd into a checkout.`
68
-
69
- A checkout wins over the machine default so a repo is self-describing for agents and CI. Flags and env still win over both, same as PostHog (`POSTHOG_CLI_PROJECT_ID`) and Windmill (`--workspace`).
70
-
71
- `whoami` prints the resolved project and which layer supplied it.
72
-
73
- ## Setting up a project
74
-
75
- This is the Windmill `workspace add` / PostHog "this is project 12345" step. Every later command assumes it already happened.
76
-
77
- ```sh
78
- toloka login
79
- toloka project list # remote projects this key can see
80
- toloka project add cat-labeling pp.019f… # register + select
81
- toloka project switch cat-labeling
82
- toloka project current # alias of the project line in whoami
83
- toloka project url # print the selected project's UI URL
84
- toloka project remove cat-labeling # local unbind only
85
- ```
86
-
87
- `project add` with no arguments prompts for alias and id, like `wmill workspace add`. The new alias becomes `current`.
88
-
89
- Create a live project and bind it in one step. The delivery order follows the owning team, not the account (`toloka whoami` marks internal teams `(internal)` on its `Teams:` line): a project in an internal team must carry an active id from `toloka delivery-order list`, and a project in an external team must not carry one, even when the account is internal:
90
-
91
- ```sh
92
- toloka project create cat-labeling --team-id <teamId>
93
- toloka project create cat-labeling --team-id <teamId> --delivery-order-id <orderId>
94
- ```
95
-
96
- `POST /projects` requires `teamId`. `GET /me` lists the caller's teams with their write access, so `--team-id` is optional when the account has exactly one writable team; with several, the CLI refuses and names them.
97
-
98
- `project create` writes the machine alias, sets `current`, and if cwd has no `toloka.json`, writes one.
99
-
100
- UI links follow the resource-first shape `toloka <resource> url`. `project url` is available now; future pipeline, dataset, and other entity links belong under their existing resource groups. Every `url` command prints exactly one URL with no label to stdout. Opening a browser, if added, must be an explicit `--web` option rather than the default.
101
-
102
- ### init
103
-
104
- `init` sets up **this directory** for an agent. A selected platform project is optional.
105
-
106
- ```sh
107
- toloka init
108
- ```
109
-
110
- It writes the agent entry points without calling the platform. It never binds a new checkout from the machine registry. With an explicit `--project-id` or project-id environment variable, it also writes `toloka.json` with empty bindings. It does not require `pipelines/`; `project create` creates the live project.
111
-
112
- `import` stays the "pull an existing live project into this checkout" path. After v2 it uses the selected project when the id is omitted:
113
-
114
- ```sh
115
- toloka import # pull the current project
116
- toloka import pp.019f… # pull that id, then bind it
117
- ```
118
-
119
- ## Commands after a project is selected
120
-
121
- Resource commands never search the disk for a pipeline first. They load the project, then the named child if the verb needs one.
122
-
123
- | Command | Scope | Pipeline required? |
124
- | ----------------------------- | ----------------------------- | ------------------ |
125
- | `project url` | project UI URL | no |
126
- | `plan` / `apply` / `validate` | whole project | no |
127
- | `secret set` | project | no |
128
- | `dataset list` | project | no |
129
- | `dataset create <name>` | project | no |
130
- | `dataset fields <name>` | named dataset in this project | no |
131
- | `dataset load <name>` | named dataset in this project | no |
132
- | `dataset upload <name>` | named dataset in this project | no |
133
- | `status` | project | no |
134
- | `pipeline list` | project | no |
135
- | `pipeline run <name>` | one pipeline | yes |
136
- | `pipeline status <name>` | one pipeline | yes |
137
- | `pipeline runs <name>` | one pipeline | yes |
138
- | `pipeline cost <name>` | one pipeline | yes |
139
- | `pipeline cancel <runId>` | run id | run id only |
140
- | `pipeline results <runId>` | run id | run id only |
141
-
142
- `status` (no prefix) is project health: id, name, team, how many pipelines/datasets/secrets, and pending source changes (`Source has no pending changes.`). Unbound live resources are not pending. It is valid on an empty project.
143
-
144
- Pipeline verbs move under `pipeline` and take an explicit name. No implicit "the only pipeline". No interactive picker as the default for scripts. A TTY may still offer a picker if the name is omitted **and** the project has more than one pipeline; non-TTY still errors with the list.
145
-
146
- A project with zero pipelines:
147
-
148
- ```
149
- $ toloka pipeline run
150
- This project has no pipelines.
151
- ```
152
-
153
- `plan` / `apply` on that same project: `No changes.`
154
-
155
- ## Datasets: catalog, not the table
156
-
157
- A live dataset can be huge. The checkout never holds the rows unless you ask.
158
-
159
- What is always local:
160
-
161
- - name and platform id in `toloka.json`
162
- - field names and JSON schemas (authored, or pulled as declarations)
163
-
164
- What stays on the platform until you pull it:
165
-
166
- - every item
167
- - upload history
168
- - anything a pipeline writes back
169
-
170
- `import`, `init`, `plan`, `apply`, `status`, and `dataset list` talk to the catalog only: names, ids, field schemas, item counts if the API returns them. They do not page items and they do not write a data file. `apply` may create an empty dataset and missing columns. It never copies rows down or up.
171
-
172
- Loading rows is a separate, explicit command:
173
-
174
- ```sh
175
- toloka dataset list
176
- toloka dataset fields images
177
- toloka dataset load images --out ./data/images.jsonl
178
- toloka dataset load images --limit 100 --out ./data/images.sample.jsonl
179
- toloka dataset upload images ./new.jsonl
180
- ```
181
-
182
- `load` starts a platform export, waits (default 60s; pass `--timeout`), downloads a JSON array, and writes JSONL to `--out`. Omit `--limit` only when you mean the whole table. `--limit` slices after that download; it still waits for the full export. There is no implicit load on `import` or `init`. A 10-million-row dataset and an empty one look the same in the checkout until you run `load`.
183
-
184
- Same rule as today, restated for a project-first CLI: source describes shape; the platform stores data; you pull or push rows when you want them on disk.
185
-
186
- ## What we stop doing
187
-
188
- - Discovering a root from `pipelines/`.
189
- - Making `run` / `status` / `runs` / `cost` top-level commands that hunt a pipeline.
190
- - Requiring a pipeline binding before the CLI will talk to a project.
191
- - Using "pipeline project" in user-facing CLI text. The noun is project.
192
-
193
- ## Later entities
194
-
195
- New resources attach to the same project the same way Windmill attaches `script` / `flow` / `app` to a workspace, and the same way PostHog attaches dashboards and flags to a project.
196
-
197
- ```
198
- toloka <resource> list
199
- toloka <resource> get <name>
200
- toloka <resource> …
201
- ```
202
-
203
- Do not add those groups until the resource exists. The rule is already fixed: the project is in context; the command names the child.
204
-
205
- ## Mapping from v1
206
-
207
- | v1 | v2 |
208
- | --------------------------------------------- | ------------------------------------------------------------------ |
209
- | `toloka init` (skills only) | `toloka init` (checkout + skills) |
210
- | `toloka import <id>` | `toloka project add` then `toloka import`, or `toloka import <id>` |
211
- | `toloka plan --project-id` | `toloka project add` / checkout, then `toloka plan` |
212
- | `toloka run [pipeline]` | `toloka pipeline run <name>` |
213
- | `toloka status [pipeline]` | `toloka status` (project) or `toloka pipeline status <name>` |
214
- | `toloka runs` / `cost` / `cancel` / `results` | `toloka pipeline …` |
215
- | root = `toloka.json` or `pipelines/` | root = `toloka.json` only |
216
-
217
- No shims. Beta callers update.
218
-
219
- ## Out of scope
220
-
221
- - Browser login, key rotation, revoke-on-logout.
222
- - Multi-project apply from one checkout (one `toloka.json`, one `projectId`).
223
- - Deletes (`destroy`).
224
- - Authoring a project that is not a platform project. If we ever have a different project type, it is still selected the same way; only the child commands change.