@toloka-platform/sdk 0.27.0 → 0.28.0

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.
Files changed (37) hide show
  1. package/README.md +5 -3
  2. package/dist/cli/toloka.js +179 -190
  3. package/dist/cli/toloka.js.jsc +0 -0
  4. package/dist/cli/toloka.js.jsc.sha256 +1 -1
  5. package/dist/cli/toloka.js.sha256 +1 -1
  6. package/examples/video-pair-rating/nodes/adjudicate/node.ts +1 -1
  7. package/examples/video-pair-rating/nodes/adjudicate_op/node.ts +1 -1
  8. package/examples/video-pair-rating/nodes/overall_preference_pick/node.ts +5 -1
  9. package/examples/video-pair-rating/nodes/rate_pair/node.ts +5 -1
  10. package/openapi/gen/api.schemas.ts +51 -758
  11. package/openapi/gen/api.ts +0 -860
  12. package/package.json +2 -2
  13. package/skills/catalog.json +6 -40
  14. package/skills/toloka-build/references/human-work.md +15 -6
  15. package/skills/toloka-build/references/local-setup.md +2 -2
  16. package/skills/toloka-build/references/workflow-and-cli.md +3 -22
  17. package/skills/toloka-get-started/SKILL.md +9 -13
  18. package/src/cli/analytics.ts +0 -31
  19. package/src/cli/auth.ts +15 -7
  20. package/src/cli/config.ts +67 -3
  21. package/src/cli/context.ts +3 -124
  22. package/src/cli/credentials.ts +11 -10
  23. package/src/cli/init.ts +1 -1
  24. package/src/cli/program.ts +0 -6
  25. package/src/cli/project.ts +9 -1
  26. package/src/client.ts +3 -261
  27. package/src/importer.ts +12 -2
  28. package/src/index.ts +0 -2
  29. package/src/pipeline-graph-v1.contract.json +130 -128
  30. package/skills/toloka-fine-tuning/SKILL.md +0 -177
  31. package/skills/toloka-gisting/SKILL.md +0 -186
  32. package/src/cli/batch-inference.ts +0 -267
  33. package/src/cli/commands/batch-inference.ts +0 -116
  34. package/src/cli/commands/models.ts +0 -121
  35. package/src/cli/commands/training.ts +0 -275
  36. package/src/cli/models.ts +0 -304
  37. package/src/cli/trainings.ts +0 -880
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toloka-platform/sdk",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "private": false,
5
5
  "description": "Build, inspect, and operate Toloka pipeline projects as TypeScript source. The public API may change between minor versions before 1.0.",
6
6
  "license": "Apache-2.0",
@@ -78,6 +78,6 @@
78
78
  "bun": ">=1.4.0"
79
79
  },
80
80
  "tolokaBuild": {
81
- "commit": "e61620bbaa3d8ffaf14b60352d2026ab7fcd8df0"
81
+ "commit": "dfa95a1d978ea42cc4d598c58f3655a99dd1a777"
82
82
  }
83
83
  }
@@ -11,8 +11,8 @@
11
11
  "testing",
12
12
  "checks"
13
13
  ],
14
- "version": "0.27.0",
15
- "digest": "0820713c190feda349a949a0146124508165410b3073f2d02d11eb6613690c18",
14
+ "version": "0.28.0",
15
+ "digest": "fecd55a4ddd06d4a37a54defa053b95bcd7f509117ea36640f5ca630d2f14bf1",
16
16
  "files": [
17
17
  "SKILL.md",
18
18
  "references/human-work.md",
@@ -33,7 +33,7 @@
33
33
  "bug",
34
34
  "report"
35
35
  ],
36
- "version": "0.27.0",
36
+ "version": "0.28.0",
37
37
  "digest": "70f0bd2c80b32f87896aeb27c363b8a2d37f40e22424f57fe1aad142e125ad67",
38
38
  "files": [
39
39
  "SKILL.md",
@@ -43,49 +43,15 @@
43
43
  {
44
44
  "id": "toloka-get-started",
45
45
  "name": "Get started with Toloka",
46
- "description": "Orient a Toloka session to the user's outcome and safely reuse or establish the needed CLI, authentication, project, workflow, and approval context. Use when the user is new to Toloka, asks what to do first, or has not selected a pipeline, fine-tuning, or gisting workflow.",
46
+ "description": "Orient a Toloka session to the user's outcome and safely reuse or establish the needed CLI, authentication, project, workflow, and approval context. Use when the user is new to Toloka, asks what to do first, or needs help setting up a labeling pipeline.",
47
47
  "tags": [
48
48
  "toloka",
49
49
  "onboarding",
50
50
  "getting-started",
51
51
  "agent"
52
52
  ],
53
- "version": "0.27.0",
54
- "digest": "2278adeb46a792356579395fcf73c42322cb23bcd0c61e20856ccabdad6762d1",
55
- "files": [
56
- "SKILL.md"
57
- ]
58
- },
59
- {
60
- "id": "toloka-fine-tuning",
61
- "name": "Fine-tune a model with Toloka",
62
- "description": "Create, estimate, start, monitor, and verify a project-owned supervised fine-tuning (SFT with LoRA adapters) Training through the Toloka CLI. Use when the user wants to adapt a base model or an existing LoRA Model Version from labeled conversations.",
63
- "tags": [
64
- "toloka",
65
- "training",
66
- "fine-tuning",
67
- "sft",
68
- "models"
69
- ],
70
- "version": "0.27.0",
71
- "digest": "3ce10dee5d3c283d8b5fdea15134a58fc738c7af2c1bb19eb5a0bf70ea0bca13",
72
- "files": [
73
- "SKILL.md"
74
- ]
75
- },
76
- {
77
- "id": "toloka-gisting",
78
- "name": "Compress a prompt with gisting",
79
- "description": "Create, estimate, start, monitor, and verify a project-owned prompt-gisting Training through the Toloka CLI, which learns soft prompt tokens that stand in for a long static system prompt. Use when the user wants a compact or cheaper replacement for a fixed prompt, learned from example conversations and the prompt file.",
80
- "tags": [
81
- "toloka",
82
- "training",
83
- "gisting",
84
- "prompt",
85
- "models"
86
- ],
87
- "version": "0.27.0",
88
- "digest": "be8bce8d9cf7241ccb60d2b2a9b7cc07d7755a76e8ff8ec1b0847c49efbb3469",
53
+ "version": "0.28.0",
54
+ "digest": "eb543135ef51533ecea48eacc137b80ca1ed8211d1eed0575d0ab24a26de136a",
89
55
  "files": [
90
56
  "SKILL.md"
91
57
  ]
@@ -14,8 +14,8 @@ Use `about.projectType: 'data_collection'` only when experts upload or record me
14
14
 
15
15
  `generation(name, settings)` accepts the public `GenerationAuthoringSettings`, derived from `GenerationNodeSettings`:
16
16
 
17
- - `about`: optional `name`, `description`, and `projectType`. The constructor uses its first argument as `about.name` when omitted.
18
- - `publicName`: brand-neutral, human-readable title shown to experts.
17
+ - `about`: optional `name`, `description`, and `projectType`. The constructor uses its first argument as `about.name` when omitted. Experts see `description` as the project description; see [Expert-facing title and description](#expert-facing-title-and-description).
18
+ - `publicName`: the project title experts see; see [Expert-facing title and description](#expert-facing-title-and-description).
19
19
  - `entities.input` and `.output`: map declared fields into the labeler data model.
20
20
  - `qualityCriteria`: semantic pass/fail rubrics targeting output `Field` objects.
21
21
  - `instruction`: English labeler guidance reflecting the actual entities, UI, and criteria.
@@ -26,10 +26,19 @@ Use `about.projectType: 'data_collection'` only when experts upload or record me
26
26
  - `onboarding`: built-in Training stage.
27
27
  - `exam`: optional built-in qualification gate.
28
28
  - `allowedExperts` and `excludedExperts`: experts allowed or kept off per item, for some teams only (see [Per-item expert settings](#per-item-expert-settings)).
29
- - `checks`: stored test cases (see [node checks](node-checks.md)). `reuseAudienceWithNodeId` and `smartSearch` are still accepted but deploy ignores them.
29
+ - `checks`: stored test cases (see [node checks](node-checks.md)).
30
30
 
31
31
  This file says when and why to use each setting. For its exact shape (fields, optionality, allowed values, defaults and bounds), run `toloka schema generation` or `toloka schema quorum`, or the type name such as `Onboarding` or `GenerationExam`, before writing a setting the example you borrow from does not show.
32
32
 
33
+ #### Expert-facing title and description
34
+
35
+ Experts see `publicName` as the project title in their task list and invitation email, and `about.description` as the project description on the project page. `about.name` is an internal identifier that experts never see. Write both for the expert who will do the task, not for the client or the pipeline:
36
+
37
+ - `publicName`: a few plain words that say what the expert will do, such as `'Product image categorization'`. No snake_case, internal ids, node names, placeholders such as `survey` or `test`, dates, version tags, or brand prefixes; strip the requester's company, product, and codenames even when the request names them.
38
+ - `about.description`: one to three sentences saying what the project is about and what the expert will do. Never leave it empty on a `generation` or `quorum` node.
39
+
40
+ Whenever you set or change either one, quote both in your summary to the user so they can correct them.
41
+
33
42
  #### Entities
34
43
 
35
44
  An authored entity references a declared `field`. Choose its cardinality from the task's meaning before choosing the field schema or Task UI component:
@@ -244,7 +253,7 @@ Treat `exam` as the optional one-attempt pass/fail gate after Training and befor
244
253
 
245
254
  The `ui` strings are authored directly. Build one expert's task view, ensure component value shapes match entity schemas, read inputs as [Task UI](task-ui.md) describes, and use `postprocess` when a component's native value needs reshaping. Hardware-backed upload and recording controls require real UI verification.
246
255
 
247
- Deploy ignores `reuseAudienceWithNodeId` and `smartSearch`: every deploy sources experts through the node's own audience. Don't add them to new source; an imported value can stay.
256
+ `reuseAudienceWithNodeId` and `smartSearch` are deprecated: the platform discards them and reports both as `null`, and every deploy sources experts through the node's own audience. Don't write them; remove them from existing source.
248
257
 
249
258
  ### Traps
250
259
 
@@ -256,7 +265,7 @@ Deploy ignores `reuseAudienceWithNodeId` and `smartSearch`: every deploy sources
256
265
  - Do not flip an explicitly requested `verifiedExperts: false` to `true`. Every project type accepts either audience mode.
257
266
  - Do not set a synthetic `maxCostPerAttempt` below the `TYPICAL` cost `toloka generation-model list` shows for the selected model and reasoning effort: generation stops once the budget is spent and can truncate results. Tell the user when that raises the cost forecast.
258
267
  - Do not omit `maxCostPerAttempt` from a synthetic `audienceAndPricing`. Without it the source fails to load with `must have required property 'maxCostPerAttempt'` next to misleading errors from the human branch, such as `must have required property 'verifiedExperts'`.
259
- - Do not treat the server's materialized defaults as your configuration. An applied node reports `qualityAssurance`, `exam`, `reuseAudienceWithNodeId`, and `smartSearch` even when source never set them. Leave them out unless you mean to control them. Omitted top-level object keys are preserved, but defaults materialized inside list elements can still cause drift; use the generic import-and-diff recovery flow.
268
+ - Do not treat the server's materialized defaults as your configuration. An applied node reports `qualityAssurance` and `exam` even when source never set them. Leave them out unless you mean to control them. Omitted top-level object keys are preserved, but defaults materialized inside list elements can still cause drift; use the generic import-and-diff recovery flow.
260
269
 
261
270
  ## `quorum`
262
271
 
@@ -264,7 +273,7 @@ Deploy ignores `reuseAudienceWithNodeId` and `smartSearch`: every deploy sources
264
273
 
265
274
  `quorum(name, settings)` accepts `QuorumAuthoringSettings`, derived from `QuorumNodeSettings`:
266
275
 
267
- - `about`, `publicName`, `entities`, `qualityCriteria`, `instruction`, `expectedExpertBehavior`, `ui`, `audienceAndPricing`, `onboarding`, `exam`, `reuseAudienceWithNodeId`, `smartSearch`, `excludedExperts`, and `checks` follow the human-node rules above. A quorum task can be as complex as a generation task, so settle its expected expert behavior the same way. Quorum has no `allowedExperts`.
276
+ - `about`, `publicName`, `entities`, `qualityCriteria`, `instruction`, `expectedExpertBehavior`, `ui`, `audienceAndPricing`, `onboarding`, `exam`, `excludedExperts`, and `checks` follow the human-node rules above. A quorum task can be as complex as a generation task, so settle its expected expert behavior the same way. Quorum has no `allowedExperts`.
268
277
  - `overlap` is the fixed number of independent labelers per item: 1–100, though below 2 validation warns that one annotation per item calls for a `generation` node instead. Default to 3 when the user does not specify it; 3 gives a majority, 5 gives stronger consensus, and cost grows linearly.
269
278
  - `qualityAssurance` is either `llm_only` or `none`.
270
279
  - `offboardingRules` supports majority-vote agreement rules in No-QA mode.
@@ -18,7 +18,7 @@ For a new pipeline project, add the SDK, TypeScript, and Vitest:
18
18
  bun add -d @toloka-platform/sdk@latest typescript vitest
19
19
  ```
20
20
 
21
- These are project authoring and test dependencies, not prerequisites for running the standalone CLI or a Training-only workflow. Task UI scenarios additionally require Playwright and Chromium:
21
+ These are project authoring and test dependencies, not prerequisites for running the standalone CLI. Task UI scenarios additionally require Playwright and Chromium:
22
22
 
23
23
  ```sh
24
24
  bun add -d playwright
@@ -27,7 +27,7 @@ bunx playwright install chromium
27
27
 
28
28
  Select or create the intended platform project before `toloka init` when the checkout should be bound immediately; follow [Choose the platform project](#choose-the-platform-project). Running `init` without explicit or checkout-local project identity installs only the agent entry points and never adopts the machine registry's current project.
29
29
 
30
- `toloka init` warns when `@toloka-platform/sdk` is not declared in `dependencies` or `devDependencies`, then maintains one `<toloka>` Agent Bootstrap block in `AGENTS.md` and writes minimal pointers to it: a Claude skill at `.claude/skills/toloka-bootstrap/SKILL.md` when `.claude/` exists (or when no agent configuration exists at all) and an always-applied Cursor rule at `.cursor/rules/toloka-bootstrap.mdc` when `.cursor/rules/` exists. The dependency warning applies to pipeline authoring; Training commands do not require the SDK dependency. `init` writes `toloka.json` only from an explicit project flag/environment value or an existing checkout binding.
30
+ `toloka init` warns when `@toloka-platform/sdk` is not declared in `dependencies` or `devDependencies`, then maintains one `<toloka>` Agent Bootstrap block in `AGENTS.md` and writes minimal pointers to it: a Claude skill at `.claude/skills/toloka-bootstrap/SKILL.md` when `.claude/` exists (or when no agent configuration exists at all) and an always-applied Cursor rule at `.cursor/rules/toloka-bootstrap.mdc` when `.cursor/rules/` exists. The dependency warning applies to pipeline authoring. `init` writes `toloka.json` only from an explicit project flag/environment value or an existing checkout binding.
31
31
 
32
32
  The bootstrap is small: it tells an agent to run `toloka --help`, search the bundled Skill Catalog with `toloka skill search <query>`, install the match with `toloka skill install <skill-id>`, and read `.agents/skills/<skill-id>/SKILL.md`. This skill is that installed copy. Commands warn on stderr when a generated legacy entry point is still present or the recorded bootstrap version differs from the running CLI's bundled version, independently of any project SDK dependency. Help, `init`, `report`, `project url`, `config`, and version invocations skip this checkout-dependent warning. The warning never blocks a command; after updating the standalone CLI, re-run `toloka init` to refresh the bootstrap and its pointers.
33
33
 
@@ -36,7 +36,6 @@ Run `toloka help --all` once for the usage and every option of all commands of t
36
36
  - catalogs: `audience specialization list`, `generation-model list`, `ui components`, `schema` (the SDK authoring and testing functions and types of the installed version);
37
37
  - data and runs: `dataset` (`list`, `create`, `fields`, `fields add`, `columns`, `load`, `upload`, `split`, `slice`), `pipeline` (`list`, `run`, `status`, `runs`, `cost`, `results`, `cancel`, `lint`);
38
38
  - customer review, only for teams that have it (other teams get a 403): `review` (`list`, `get`, `accept`, `reject`), described in [Customer review](human-work.md#customer-review);
39
- - models and training: `base-model`, `model` (including `model version download`), `training`, `batch-inference` (`run`, `list`, `status`, `confirm`, `resume`, `cancel`);
40
39
  - skills and reports: `skill` (`list`, `search`, `install`), `report`.
41
40
 
42
41
  `toloka audience specialization list` prints the global specialization catalog: `ID`, `NAME`, and `EXPERTS` columns (`--json` for the array). Run it before setting `audience.specializations` on a node, pick entries by name, and copy `ID` into `qualificationId` and `NAME` into `value`; never invent a `qualificationId`. `EXPERTS` counts ID-verified experts currently eligible for tasks; a `0` means the id is valid but nobody currently qualifies, so prefer another specialization or widen the audience.
@@ -46,24 +45,6 @@ Run `toloka help --all` once for the usage and every option of all commands of t
46
45
  `toloka pipeline cost [name] [--item-limit <n>]` forecasts what a run of a live, validated pipeline would bill. It does not start a run or change the graph. If any billed node is marked `skipped`, the displayed total is incomplete and must not be presented as the pipeline price. Compute and label a labor floor for each skipped billed node as `items × pricePerTask × annotations per item`, using `1` for generation and `overlap` for quorum. Also report `maxEntities`, quality-criteria count, and only exclusions applicable to the authored QA and workflow. Apply accepting a rate does not prove its final billed value.
47
46
 
48
47
 
49
- ## Manage model checkpoints
50
-
51
- The global Base Model Catalog is read-only and uses `toloka base-model`. `base-model list` prints aligned ID, name, provider, upstream-model, revision (first 12 characters) and upstream-snapshot URL columns by default; `base-model get` prints the full pinned revision and the `https://huggingface.co/<model>/tree/<revision>` snapshot URL, which is the exact base every Training Run trains on. `toloka model` manages project-owned lineages; creation requires one catalog `baseModelId` and creates metadata without a Model Version. Every Base Model and Model command accepts `--json` for machine-readable output. `toloka model version download <model-version> --out <directory>` downloads and verifies a Model Version's content; uploading and validating a Model Version have no command yet.
52
-
53
- ## Train a model
54
-
55
- `toloka training create` requires one source (`--base-model` or `--model-version`) and the rows to learn on: `--dataset` to split a Dataset and freeze a slice for the Training, or `--slice` for a ready slice that freezes a split column. A `--model-version` source must be a LoRA adapter Model Version (one produced by fine-tuning) and works for both methods — SFT continues the adapter, gisting merges it and trains gist tokens over it; a full-weights version is rejected with "Training from a Model Version requires a LoRA adapter source". The first Training Run creates a new output Model named after the Training; a source Model Version is only the training parent, never the output binding.
56
-
57
- Hyperparameters are optional flags on `training create` and `training update`; the `toloka-fine-tuning` and `toloka-gisting` skills list their ranges and defaults. `--lora-rank` is SFT-only and `--gist-tokens` gisting-only: passing one to the other method fails before any request. `training update` has no `--method` flag: the method stays as created, and every flag you omit keeps its current value. `training cost` is blocked when the longest example exceeds `--max-sequence-length`, or when the training selection leaves fewer rows than `--batch-size` after the 10% holdout (taken only when there is no validation selection).
58
-
59
- `--dataset <name-or-id>` fills the empty cells of the Dataset's split column (a new `split` column, 80/10/10, when it has none), freezes a slice named after the Training, and trains on it. A split column adopted from an ordinary column has no shares, so `--dataset` does not fill it; give it shares first with `toloka dataset split <dataset> --column <name> --parts <name>=<roles>:<percent>,...`. When the uploaded rows have a top-level `split` field that is not a dataset field yet, `--dataset` refuses and prints the `toloka dataset fields add` command that adds it. `--slice <id>` takes a ready slice frozen with `toloka dataset slice create`. The Training learns on the split column's train parts (`--parts` picks some of them) and validates on its validate parts, including a part that also tests, or takes the 10% holdout when they are empty; `--split-column` picks the column when there are several. Rows without a part are never trained on. Rows that any split column puts in a test part stay out of training, and out of validation unless they sit in a validate + test part of the Training's own split column: `training cost` leaves them out and, when there are any, reports how many as `Left out as test`. `training update` keeps the slice, split column and train parts; a new `--dataset` or `--slice` resets the split column and train parts unless you pass them too. `training get` shows them in `configuration.sliceId`, `configuration.splitFieldId` and `configuration.trainParts`.
60
-
61
- Use `training cost` to validate inputs and show the maximum charge before `training run`. A blocked estimate exits 1 and lists the issues on stderr instead of printing the estimate; fix them and recalculate. `training run` accepts that ready estimate JSON through `--estimate-file`; without it, the command calculates a fresh ready estimate itself before creating the run. `--version-name` defaults to the Training name; pass it when a Model Version with that name already exists. Use `training status`, `training logs`, `training metrics`, `training resume`, and `training cancel` with the returned Training Run ID. `training metrics` lists each metric's latest value while the run is still training; `--key` prints one metric's point history instead. `training cancel` before training starts is free; on a run that is already training it stops the GPU job, and the run is charged only for the GPU seconds used until then and produces no Model Version.
62
-
63
- ## Answer dataset rows with a model
64
-
65
- `toloka batch-inference run --dataset <id> (--base-model <id> | --model-version <id>) (--output-field <name> | --output-dataset <name>) --max-output-tokens <n>` sends each selected row's `messages` to a qwen3-4b or qwen3-8b Base Model, or a Model Version trained from one, and writes one answer per row into a text column or a new dataset. An existing `--output-field` column must allow strings; one whose schema allows none is refused with "does not accept text", so pick or create a text column. `--filter field=value`, `--slice <id>` and `--parts <names>` (with `--split-column` when the dataset has several) narrow the rows; a slice answers the prompts it froze. `run` waits for the quote and prints the rows and the maximum charge: show them to the user and confirm only with their approval, through `--yes` on `run` or `toloka batch-inference confirm <run-id>` within 24 hours. Follow a run with `status --wait`. A `blocked` run names its reason: after `funds` or `payment`, `resume` continues it once the user adds funds; `billing_review` waits for support to reconcile the charge, and `resume` does not apply to it. `cancel` stops a run and charges the GPU time used, and `list` shows the project's runs. A scoped token needs `inference:deploy` (the `deploy` preset) to run, confirm, resume or cancel. `toloka batch-inference <command> --help` lists every flag.
66
-
67
48
  ## Check locally and validate against the platform
68
49
 
69
50
  Check the nodes you edit locally, then apply and validate the pipeline in one command; apply runs the local gate of the pipelines it applies itself:
@@ -140,16 +121,16 @@ Pull live rows with `toloka dataset load <name> --out <file> [--fields <fields>]
140
121
 
141
122
  ## Split a dataset and freeze a slice
142
123
 
143
- A split column puts each row in a part, `train`, `validate` or `test`. Trainings learn on train parts and validate on validate parts; test parts are held out for evaluations: no Training learns on a row that any split column puts in a test part, and none validates on one unless it sits in a validate + test part of the Training's own split column. A slice freezes rows: its id (`dsl.…`) always selects the same rows, and its frozen columns, always including the split columns, read as they were at the cutoff. When the user wants a fixed evaluation set, split before training:
124
+ A split column assigns rows to named parts with roles such as `train`, `validate`, and `test`. A slice (`dsl.…`) keeps the same rows and reads its frozen columns as they were at the cutoff. Split columns are always frozen. To keep a fixed split, assign the parts before creating the slice.
144
125
 
145
126
  ```sh
146
127
  toloka dataset split <dataset> --ratios 80/10/10 --balance-by <label-field>
147
128
  toloka dataset slice create <dataset> --name "<slice-name>"
148
129
  ```
149
130
 
150
- `dataset split` places every row that has no part yet and never moves a row that has one; `--filter field=value` or `--slice <slice-id>` limits it to those rows. It waits up to 60 seconds for the rows to be placed (`--timeout <ms>` sets the wait, `--no-wait` skips it); when the wait runs out the fill keeps running, and `toloka dataset columns <dataset>` shows its progress. `--ratios` takes whole percentages that add up to 100 (default `80/10/10` for a new column). `--balance-by` shares out each label's rows on their own; a label with only a few rows can still miss a part. `--seed` makes the placement repeatable, and the column keeps it: rows are ranked by the seed and their position in the dataset, so the same file uploaded in the same order splits the same way. When data is scarce, `--ratios 80/0/20 --validate-on-test` makes the test part the validation set too; say that its test score is then not fully held out. `--parts name[=roles][:percent],…` names other parts, for example `train:70,dev=validate:10,holdout=test:20`. On a split column that already has shares, `--parts` without percentages is refused: give the percentages, adding up to 100, or omit `--parts` to repeat the column's last shares. `--column <name>` picks the column (default `split`); several split columns can live on one Dataset. When a column already names each row's part, `--column <column>` adopts it: roles follow the values `train`, `validation`/`validate`/`val`/`dev` and `test`, and `--parts train,dev=validate,test` maps other names; naming it again changes nothing. Adoption places no rows, so `--seed`, `--balance-by`, `--filter` and `--slice` are refused with it. When the part is a field of the uploaded rows, such as a Hugging Face `split` field, add it as a dataset field first with `toloka dataset fields add <dataset> split`: `dataset split` refuses a name that is a field of the uploaded rows but not a dataset field, and prints that command. Any other new name creates a new, sampled split column.
131
+ `dataset split` places every row that has no part yet and never moves a row that has one; `--filter field=value` or `--slice <slice-id>` limits it to those rows. It waits up to 60 seconds for the rows to be placed (`--timeout <ms>` sets the wait, `--no-wait` skips it); when the wait runs out the fill keeps running, and `toloka dataset columns <dataset>` shows its progress. `--ratios` takes whole percentages that add up to 100 (default `80/10/10` for a new column). `--balance-by` shares out each label's rows on their own; a label with only a few rows can still miss a part. `--seed` makes the placement repeatable, and the column keeps it: rows are ranked by the seed and their position in the dataset, so the same file uploaded in the same order splits the same way. With `--ratios 80/0/20 --validate-on-test`, the same part has both the `validate` and `test` roles. `--parts name[=roles][:percent],…` names other parts, for example `train:70,dev=validate:10,holdout=test:20`. On a split column that already has shares, `--parts` without percentages is refused: give the percentages, adding up to 100, or omit `--parts` to repeat the column's last shares. `--column <name>` picks the column (default `split`); several split columns can live on one Dataset. When a column already names each row's part, `--column <column>` adopts it: roles follow the values `train`, `validation`/`validate`/`val`/`dev` and `test`, and `--parts train,dev=validate,test` maps other names; naming it again changes nothing. Adoption places no rows, so `--seed`, `--balance-by`, `--filter` and `--slice` are refused with it. When the part is a field of the uploaded rows, such as a Hugging Face `split` field, add it as a dataset field first with `toloka dataset fields add <dataset> split`: `dataset split` refuses a name that is a field of the uploaded rows but not a dataset field, and prints that command. Any other new name creates a new, sampled split column.
151
132
 
152
- When rows are added later, run `dataset split` again: it places only the new rows, with the column's last shares, balancing column and seed, so the column keeps its proportions and no test row moves into training. Then take a new slice, for example with `dataset slice create <dataset> --from <slice-id>`, which reruns the slice's filters at a new cutoff with the same frozen columns.
133
+ After adding rows, run `dataset split` again. It fills unassigned rows using the column’s saved shares, balancing column, and seed. Pass the filter or slice again to limit which rows it fills. Rows that already have a part keep it. Then take a new slice, for example with `dataset slice create <dataset> --from <slice-id>`, which reruns the slice's filters at a new cutoff with the same frozen columns.
153
134
 
154
135
  `dataset slice create` freezes every row, or only the rows that match each `--filter field=value`. `--freeze <columns>` picks the frozen columns (default: every column); split columns are always frozen. `--name` tells slices apart (default `Slice 1`, `Slice 2` and so on). Rows uploaded later are never in the slice, and `slice create` is refused while an upload is running, a split column is filling, or a field it freezes is still being copied from the uploaded rows, so run it after `dataset upload` and `dataset split` finish; a dataset without rows has nothing to freeze, so it is refused too. Both commands first wait for fields still being copied, and both wait until the rows are placed or frozen and exit with the error when the fill or slice fails; `--no-wait` returns at once, so check `dataset columns` or `dataset slice show`.
155
136
 
@@ -1,25 +1,21 @@
1
1
  ---
2
2
  name: toloka-get-started
3
- description: Orient a Toloka session to the user's outcome and safely reuse or establish the needed CLI, authentication, project, workflow, and approval context. Use when the user is new to Toloka, asks what to do first, or has not selected a pipeline, fine-tuning, or gisting workflow.
3
+ description: Orient a Toloka session to the user's outcome and safely reuse or establish the needed CLI, authentication, project, workflow, and approval context. Use when the user is new to Toloka, asks what to do first, or needs help setting up a labeling pipeline.
4
4
  ---
5
5
 
6
6
  # Get started with Toloka
7
7
 
8
8
  Use this skill to help the user reach the outcome they asked for. Start with the request, the current checkout, and observed CLI state. If setup, authentication, a project binding, or workflow source is already in place and consistent with the task, continue from it instead of repeating onboarding, replacing the binding, or creating a demo.
9
9
 
10
- ## Choose the relevant workflow
10
+ ## Start a labeling project
11
11
 
12
- Honor an explicitly requested target. Otherwise choose the workflow that fits the outcome and briefly explain the choice:
13
-
14
- - **Label data or build a pipeline:** install and read `toloka-build`, then use `https://platform.toloka.ai/agents/data-labeling.md` as a reference.
15
- - **Fine-tune a model:** install and read `toloka-fine-tuning`, then use `https://platform.toloka.ai/agents/fine-tuning.md` as a reference.
16
- - **Compress a prompt with gisting:** install and read `toloka-gisting`, then use `https://platform.toloka.ai/agents/gisting.md` as a reference.
12
+ To label data or build a pipeline, install and read `toloka-build`. Use the [Data Labeling runbook](https://platform.toloka.ai/agents/data-labeling.md) as a reference.
17
13
 
18
14
  The workflow sequence preserves important dependencies and gates, but it is not a script: skip steps that current evidence shows are already satisfied or irrelevant. If the user asks only for design, inspection, or an estimate, finish at that outcome rather than creating extra resources or starting a run.
19
15
 
20
16
  ## Prepare missing prerequisites
21
17
 
22
- Check the CLI only when its state is not already known. The installer prefers stable Bun 1.4.0 or newer matching the host architecture; otherwise it installs a standalone executable with its runtime included. Use `sh -s -- --native` or `sh -s -- --bun` on the installer pipe to force a mode. For custom packages or directories, choose the matching mode explicitly. Training-only workflows need no project SDK or test dependencies. For pipeline authoring, Bun is recommended: run `bun i` in an existing project and use `bun add -d` for missing packages.
18
+ Check the CLI only when its state is not already known. The installer prefers stable Bun 1.4.0 or newer matching the host architecture; otherwise it installs a standalone executable with its runtime included. Use `sh -s -- --native` or `sh -s -- --bun` on the installer pipe to force a mode. For custom packages or directories, choose the matching mode explicitly. For pipeline authoring, Bun is recommended: run `bun i` in an existing project and use `bun add -d` for missing packages.
23
19
 
24
20
  The shell installer supports macOS and Linux on ARM64/x64. The native path requires glibc on Linux, plus `curl`, `tar`, `mktemp`, and either `shasum` or `sha256sum`; compatible Bun can be used on musl. Native Windows packages are not available.
25
21
 
@@ -28,7 +24,7 @@ toloka --version
28
24
  toloka dataset --help
29
25
  ```
30
26
 
31
- The runbooks require a stable Toloka CLI release at version `0.2.0` or newer: `toloka --version` must print `0.2.0` or a newer version with no prerelease suffix, and `toloka dataset --help` must list `create`. If either command is unavailable, the version is older or prerelease, or the capability check fails, install the latest stable version:
27
+ The runbook requires a stable Toloka CLI release at version `0.2.0` or newer: `toloka --version` must print `0.2.0` or a newer version with no prerelease suffix, and `toloka dataset --help` must list `create`. If either command is unavailable, the version is older or prerelease, or the capability check fails, install the latest stable version:
32
28
 
33
29
  ```sh
34
30
  curl -fsSL https://platform.toloka.ai/cli/install.sh | sh
@@ -46,8 +42,8 @@ Pipeline work needs a source root. Reuse a suitable initialized root when one ex
46
42
 
47
43
  ```sh
48
44
  toloka init
49
- toloka skill search <workflow>
50
- toloka skill install <skill-id>
45
+ toloka skill search toloka-build
46
+ toloka skill install toloka-build
51
47
  ```
52
48
 
53
49
  Read the installed skill before acting. Refresh a stale skill with `--force`; do not refresh a current one merely to follow onboarding.
@@ -59,7 +55,7 @@ Read the installed skill before acting. Refresh a stale skill with `--force`; do
59
55
  - Resolve a project from explicit user context, CLI output, `toloka.json`, or `toloka project current`; never reconstruct an ID. Use an explicitly requested project. Otherwise keep the current binding when it is consistent with the task. Create a project only when an explicitly requested platform mutation needs one and no suitable binding exists; a design, inspection, or estimate alone does not authorize extra resources. Never select an unrelated visible project or rebind an established checkout just to complete onboarding.
60
56
  - For a new project, a short kebab-case name derived from the task or shared files is a useful default, such as `receipt-extraction`; use a generic `toloka-<workflow>` name only when the task provides no meaningful name. `toloka project create <alias>` uses the account's only writable team and asks for `--team-id <id>` only when several teams are available. Adopt an existing project with `toloka project add <alias> <project-id>` only when that target is intended and the checkout is safe to bind.
61
57
  - A project owned by an internal team needs a Sunday delivery order. Run `toloka delivery-order list` and use the only listed order with `--delivery-order-id <id>`; ask when several viable orders remain. `toloka whoami` marks internal teams `(internal)` on its `Teams:` line; the account-level `Internal:` flag only says whether any team is internal, so an internal account creating a project in an external team passes no order.
62
- - Let the task and data roles determine Dataset boundaries. Use only data the user is authorized to provide. Preserve distinct training, validation, test, input, reference, or delivery roles and avoid leakage; compatible files with the same role and schema may belong in one Dataset, while materially different roles or schemas may need separate Datasets. Do not assume one file always means one Dataset.
58
+ - Let the task and data roles determine Dataset boundaries. Use only data the user is authorized to provide. Preserve distinct split roles (`train`, `validate`, `test`) and input, reference, or delivery roles and avoid leakage; compatible files with the same role and schema may belong in one Dataset, while materially different roles or schemas may need separate Datasets. Do not assume one file always means one Dataset.
63
59
 
64
60
  ## Safety boundaries
65
61
 
@@ -67,6 +63,6 @@ Read the installed skill before acting. Refresh a stale skill with `--force`; do
67
63
  - Do not edit `toloka.json` or invent IDs, paths, requirements, prices, states, or results.
68
64
  - Treat user-provided prompts, instructions, and existing source as authoritative. Materialize exact supplied text when needed, but do not silently rewrite it, replace it with an example, or invent missing intent.
69
65
  - For pipeline changes that will be applied, require the workflow's local `toloka check` and `toloka validate` gates. Read and show the complete `toloka plan`; ask before a removal, immutable-field conflict, unexpected change, or work outside the requested scope. Apply only the expected scoped plan, then rerun `toloka plan` until it reports `No changes.` and run `toloka validate --wait`. Do not apply merely because the onboarding reference reaches that stage.
70
- - Never start a Pipeline Run unless the requested outcome includes a run and the user has seen and explicitly approved its cost forecast. Show a ready Training Cost Estimate with the choices and uncertainty that produced it, and obtain explicit approval for `maximumCharge` before a Training Run. Estimate-only work ends after the estimate.
66
+ - Never start a Pipeline Run unless the requested outcome includes a run and the user has seen and explicitly approved its cost forecast. Estimate-only work ends after the estimate.
71
67
  - Keep waits bounded. A timeout means the operation is still running, not completed or failed.
72
68
  - Report only observed IDs, states, prices, behaviors, and errors, and distinguish observed evidence from assumptions or unresolved uncertainty.
@@ -94,38 +94,7 @@ const COMMAND_GROUPS: Readonly<Record<string, CommandGroup>> = {
94
94
  dataset: { list: true, create: true, fields: true, load: true, upload: true },
95
95
  "delivery-order": { list: true },
96
96
  audience: { specialization: { list: true } },
97
- training: {
98
- list: true,
99
- get: true,
100
- create: true,
101
- update: true,
102
- cost: true,
103
- run: true,
104
- runs: true,
105
- status: true,
106
- resume: true,
107
- cancel: true,
108
- metrics: true,
109
- logs: true,
110
- },
111
- "batch-inference": {
112
- run: true,
113
- list: true,
114
- status: true,
115
- confirm: true,
116
- resume: true,
117
- cancel: true,
118
- },
119
- "base-model": { list: true, get: true },
120
97
  "generation-model": { list: true },
121
- model: {
122
- list: true,
123
- get: true,
124
- versions: true,
125
- create: true,
126
- archive: true,
127
- version: { download: true },
128
- },
129
98
  secret: { set: true },
130
99
  skill: { list: true, search: true, install: true },
131
100
  config: { get: true, set: true },
package/src/cli/auth.ts CHANGED
@@ -23,6 +23,7 @@ import {
23
23
  registrationUrlFor,
24
24
  resolveBaseUrl,
25
25
  resolveInternalBaseUrl,
26
+ storedApiKeyFor,
26
27
  } from "./config";
27
28
  import {
28
29
  clearStoredCredentials,
@@ -197,7 +198,7 @@ const registryFor = async (
197
198
  environment: CliEnvironment,
198
199
  baseUrl: string,
199
200
  ): Promise<Pick<StoredCredentials, "current" | "projects">> => {
200
- const existing = await inspectCredentialsFile(credentialsPath(environment));
201
+ const existing = inspectCredentialsFile(credentialsPath(environment));
201
202
  if (typeof existing !== "object") return {};
202
203
  if (normalizeBaseUrl(existing.credentials.baseUrl) !== normalizeBaseUrl(baseUrl)) return {};
203
204
  return {
@@ -345,7 +346,7 @@ const loginInBrowser = async (
345
346
 
346
347
  const readValidStoredCredentials = async (environment: CliEnvironment): Promise<StoredCredentials | undefined> => {
347
348
  for (const path of storedCredentialsPaths(environment)) {
348
- const inspected = await inspectCredentialsFile(path);
349
+ const inspected = inspectCredentialsFile(path);
349
350
  if (inspected === "missing") continue;
350
351
  return typeof inspected === "object" ? inspected.credentials : undefined;
351
352
  }
@@ -462,7 +463,7 @@ const firstDefined = <T>(candidates: ReadonlyArray<T | undefined>): T | undefine
462
463
  const resolveStatusCredential = (
463
464
  options: AuthStatusOptions,
464
465
  environment: CliEnvironment,
465
- found: FoundCredentials | undefined,
466
+ storedApiKey: string | undefined,
466
467
  storedPath: string,
467
468
  ): ResolvedCredential | undefined =>
468
469
  firstDefined<ResolvedCredential>([
@@ -485,11 +486,11 @@ const resolveStatusCredential = (
485
486
  source: "from TOLOKA_API_KEY",
486
487
  environmentVariable: "TOLOKA_API_KEY",
487
488
  },
488
- found?.credentials.apiKey === undefined
489
+ storedApiKey === undefined
489
490
  ? undefined
490
491
  : {
491
492
  type: "apiKey",
492
- value: found.credentials.apiKey,
493
+ value: storedApiKey,
493
494
  source: `stored in ${storedPath}`,
494
495
  },
495
496
  ]);
@@ -604,13 +605,20 @@ export async function authStatus(options: AuthStatusOptions = {}): Promise<AuthS
604
605
  ));
605
606
  const { found, warning } = credentialLookup;
606
607
  const storedPath = found?.path ?? credentialsPath(environment);
607
- const credential = resolveStatusCredential(options, environment, found, storedPath);
608
608
  const platform = resolvePlatform(options, environment, found);
609
+ const storedApiKey = storedApiKeyFor(platform.value, found?.credentials);
610
+ const credential = resolveStatusCredential(options, environment, storedApiKey, storedPath);
609
611
  const browser =
610
612
  credential === undefined ? await findBrowserLogin(platform.value, environment) : undefined;
611
613
  const projectLine = formatProjectContextLine(options.project, found?.credentials);
612
614
 
613
615
  const lines: string[] = warning === undefined ? [] : [warning, ""];
616
+ if (found?.credentials.apiKey !== undefined && storedApiKey === undefined && credential === undefined) {
617
+ lines.push(
618
+ `The key stored in ${found.path} is for ${found.credentials.baseUrl}, so it is not sent to ${platform.value}.`,
619
+ "",
620
+ );
621
+ }
614
622
 
615
623
  if (credential === undefined && browser === undefined) {
616
624
  lines.push(
@@ -647,7 +655,7 @@ export async function authStatus(options: AuthStatusOptions = {}): Promise<AuthS
647
655
  }
648
656
  lines.push(projectLine);
649
657
 
650
- if (found?.credentials.apiKey !== undefined && credential?.environmentVariable !== undefined) {
658
+ if (found !== undefined && storedApiKey !== undefined && credential?.environmentVariable !== undefined) {
651
659
  lines.push(
652
660
  "",
653
661
  `${credential.environmentVariable} is set, so the key stored in ${found.path} is ignored.`,
package/src/cli/config.ts CHANGED
@@ -1,5 +1,10 @@
1
+ import { existsSync } from "node:fs";
2
+ import type { ClientConfig } from "../client";
1
3
  import type { TolokaState } from "../state";
2
- import type { StoredCredentials } from "./credentials";
4
+ import { browserSessionPath, createBrowserSessionAuth } from "./browser-session";
5
+ import { CredentialsError, findStoredCredentials, normalizeBaseUrl } from "./credentials";
6
+ import type { CliEnvironment, StoredCredentials } from "./credentials";
7
+ import { browserLoginProviderFor } from "./keycloak";
3
8
  import type { BrowserLoginProvider } from "./keycloak";
4
9
  import { resolveProjectContext } from "./project-context";
5
10
  import { assertCli } from "./cli-error";
@@ -66,6 +71,20 @@ export const MISSING_CREDENTIALS_MESSAGE = [
66
71
  "Run toloka auth-status to see what is in effect.",
67
72
  ].join("\n");
68
73
 
74
+ export const storedApiKeyFor = (baseUrl: string, stored: StoredCredentials | undefined): string | undefined =>
75
+ stored !== undefined && normalizeBaseUrl(baseUrl) === normalizeBaseUrl(stored.baseUrl)
76
+ ? stored.apiKey
77
+ : undefined;
78
+
79
+ const missingCredentialMessage = (
80
+ baseUrl: string,
81
+ stored: StoredCredentials | undefined,
82
+ notLoggedIn: string,
83
+ ): string =>
84
+ stored?.apiKey !== undefined && storedApiKeyFor(baseUrl, stored) === undefined
85
+ ? `The API key saved by toloka login is for ${stored.baseUrl}, so it is not sent to ${baseUrl}. Run toloka login for ${baseUrl}, or set TOLOKA_API_KEY.`
86
+ : notLoggedIn;
87
+
69
88
  export const resolveConfiguredCredential = (
70
89
  flags: TolokaCliFlags,
71
90
  environment: TolokaEnvironment,
@@ -75,7 +94,7 @@ export const resolveConfiguredCredential = (
75
94
  if (environment.TOLOKA_SCOPED_TOKEN !== undefined) {
76
95
  return { type: "scopedToken", scopedToken: environment.TOLOKA_SCOPED_TOKEN };
77
96
  }
78
- const apiKey = environment.TOLOKA_API_KEY ?? stored?.apiKey;
97
+ const apiKey = environment.TOLOKA_API_KEY ?? storedApiKeyFor(resolveBaseUrl(flags, environment, stored), stored);
79
98
  return apiKey === undefined ? undefined : { type: "apiKey", apiKey };
80
99
  };
81
100
 
@@ -109,6 +128,51 @@ export function resolveTolokaConfig(
109
128
  const credential: CliCredential | undefined =
110
129
  configuredCredential ??
111
130
  (browserLogin === undefined ? undefined : { type: "browser", provider: browserLogin });
112
- assertCli(credential, MISSING_CREDENTIALS_MESSAGE, { hint: { disabled: true } });
131
+ assertCli(credential, missingCredentialMessage(baseUrl, stored, MISSING_CREDENTIALS_MESSAGE), {
132
+ hint: { disabled: true },
133
+ });
113
134
  return { baseUrl, credential, ...(project === undefined ? {} : { projectId: project.id }) };
114
135
  }
136
+
137
+ export const clientConfigFor = (
138
+ baseUrl: string,
139
+ credential: CliCredential,
140
+ environment: CliEnvironment,
141
+ ): ClientConfig =>
142
+ credential.type === "apiKey"
143
+ ? { baseUrl, apiKey: credential.apiKey }
144
+ : credential.type === "scopedToken"
145
+ ? { baseUrl, scopedToken: credential.scopedToken }
146
+ : {
147
+ baseUrl,
148
+ accessToken: createBrowserSessionAuth({ provider: credential.provider, baseUrl, environment }),
149
+ };
150
+
151
+ export const SDK_NOT_LOGGED_IN_MESSAGE =
152
+ "Not logged in. Run toloka login, or set TOLOKA_API_KEY for a script that runs without you.";
153
+
154
+ const readLoginCredentials = (environment: TolokaEnvironment): StoredCredentials | undefined => {
155
+ try {
156
+ return findStoredCredentials(environment)?.credentials;
157
+ } catch (error) {
158
+ if (error instanceof CredentialsError && resolveConfiguredCredential({}, environment) !== undefined) {
159
+ return undefined;
160
+ }
161
+ throw error;
162
+ }
163
+ };
164
+
165
+ export const resolveLoginClientConfig = (environment: TolokaEnvironment): ClientConfig => {
166
+ const stored = readLoginCredentials(environment);
167
+ const baseUrl = resolveBaseUrl({}, environment, stored);
168
+ const provider = browserLoginProviderFor(baseUrl);
169
+ const browserCredential: CliCredential | undefined =
170
+ provider !== undefined && existsSync(browserSessionPath(provider, environment))
171
+ ? { type: "browser", provider }
172
+ : undefined;
173
+ const credential = resolveConfiguredCredential({}, environment, stored) ?? browserCredential;
174
+ assertCli(credential, missingCredentialMessage(baseUrl, stored, SDK_NOT_LOGGED_IN_MESSAGE), {
175
+ hint: { disabled: true },
176
+ });
177
+ return clientConfigFor(baseUrl, credential, environment);
178
+ };