@toloka-platform/sdk 0.25.1 → 0.26.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.
- package/dist/cli/toloka.js +186 -165
- package/dist/cli/toloka.js.jsc +0 -0
- package/dist/cli/toloka.js.jsc.sha256 +1 -1
- package/dist/cli/toloka.js.sha256 +1 -1
- package/examples/app-crowdtesting/nodes/app-flow-test/node.ts +24 -0
- package/examples/egocentric-video-collection/nodes/record-activity/node.ts +24 -0
- package/examples/face-image-collection/nodes/annotate-faces/node.ts +16 -1
- package/examples/product-moderation/nodes/moderate-product/instruction.ts +4 -0
- package/examples/product-moderation/nodes/moderate-product/node.ts +19 -0
- package/examples/video-pair-rating/nodes/adjudicate/node.ts +18 -1
- package/examples/video-pair-rating/nodes/adjudicate_op/node.ts +18 -1
- package/examples/video-pair-rating/nodes/overall_preference_pick/node.ts +18 -1
- package/examples/video-pair-rating/nodes/rate_pair/node.ts +18 -1
- package/openapi/gen/api.schemas.ts +50 -42
- package/package.json +3 -3
- package/skills/catalog.json +6 -6
- package/skills/toloka-build/SKILL.md +6 -10
- package/skills/toloka-build/references/human-work.md +97 -8
- package/skills/toloka-build/references/workflow-and-cli.md +12 -9
- package/src/authoring/index.ts +13 -2
- package/src/checks/task-ui-typecheck.ts +1 -1
- package/src/cli/analytics.ts +1 -0
- package/src/cli/commands/schema.ts +27 -0
- package/src/cli/commands/source.ts +11 -2
- package/src/cli/format-error.ts +6 -0
- package/src/cli/help-all.ts +32 -0
- package/src/cli/index.ts +1 -0
- package/src/cli/program.ts +29 -1
- package/src/cli/project.ts +134 -15
- package/src/cli/schema.ts +633 -0
- package/src/graph-rules.json +3 -1
- package/src/importer.ts +39 -0
- package/src/index.ts +1 -0
- package/src/pipeline-graph-v1.contract.json +12 -4
- package/src/validate.ts +23 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Read this before writing or changing a `generation` or `quorum` node. Before writing its `ui`, also read [Task UI](task-ui.md); for its stored test cases, read [node checks](node-checks.md).
|
|
4
4
|
|
|
5
|
-
Distinguish server requirements from optional design choices; not every constraint below is checked when the source loads. Optional settings such as an Exam
|
|
5
|
+
Distinguish server requirements from optional design choices; not every constraint below is checked when the source loads. Optional settings such as an Exam and non-default QA should serve the task: add them when the requirements call for them, and omit blocks that add no value rather than copying placeholders, because an empty disabled block is still authored state. Preserve imported choices unless changing them is part of the task, and explain additions that affect cost or expert eligibility.
|
|
6
6
|
|
|
7
7
|
## `generation`
|
|
8
8
|
|
|
@@ -19,12 +19,15 @@ Use `about.projectType: 'data_collection'` only when experts upload or record me
|
|
|
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.
|
|
22
|
+
- `expectedExpertBehavior`: required text on a human node that describes how experts complete the task (see [Expected expert behavior](#expected-expert-behavior)).
|
|
22
23
|
- `ui`: `{ code, data, preprocess, postprocess?, constants }` for the task interface.
|
|
23
24
|
- `qualityAssurance`: `llm_only`, `hybrid`, or `human_only`, and for some teams `customer_review` (see [Customer review](#customer-review)).
|
|
24
25
|
- `audienceAndPricing`: either a human audience or synthetic generation.
|
|
25
26
|
- `onboarding`: built-in Training stage.
|
|
26
27
|
- `exam`: optional built-in qualification gate.
|
|
27
|
-
- `
|
|
28
|
+
- `checks`: stored test cases (see [node checks](node-checks.md)). `reuseAudienceWithNodeId` and `smartSearch` are still accepted but deploy ignores them.
|
|
29
|
+
|
|
30
|
+
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.
|
|
28
31
|
|
|
29
32
|
#### Entities
|
|
30
33
|
|
|
@@ -49,12 +52,100 @@ Write at least one criterion for every output entity. Each criterion needs an au
|
|
|
49
52
|
|
|
50
53
|
Use `llmQaInstruction` only when the evaluator needs a specific verification method, authoritative source, tool, or pinned edge case beyond the thresholds. It is evaluator guidance, not labeler guidance, and has no effect in `human_only` mode.
|
|
51
54
|
|
|
52
|
-
Default QA is `qualityAssurance: { qaMode: 'llm_only' }`. Keep it when it fits the task. `hybrid` adds sampled Human QA while retaining LLM review; `human_only` is appropriate when LLM grading is prohibited or human review alone is required. Suggest `customer_review` only when the user wants their own team to approve each result, such as a sign-off, acceptance against their own standard, or a contract that requires it; never suggest it by default or infer it from the quality criteria. Only some teams have it; see [Customer review](#customer-review). Recommend a mode based on the user's quality and privacy requirements, explaining cost and turnaround implications before changing it. Human-bearing modes require `humanQaTimeForTask` in whole seconds: at least 30 and at least 3 per quality criterion of the node, whichever is larger, and at most 359,999 (99:59:59). A reviewer keeps a Human QA task for `humanQaTimeForTask` plus 1 hour, and for at least 8 hours. A dropped task stays with that reviewer until this time ends, then another reviewer can take it; `smartSamplingPercent` defaults to 30 for hybrid and 100 for human-only. Use those defaults unless the task justifies a different rate. Human QA on a node is capped at the Maximum of its Human QA line in the frozen estimate: 3 reviews for each item of the run. The cap counts every item of the run, so a branch behind a `match` that receives more than its even share still gets Human QA. Before deploy, the platform counts the QA pool: experts who match the node's audience and hold the platform QA qualification and were active in the last 14 days
|
|
55
|
+
Default QA is `qualityAssurance: { qaMode: 'llm_only' }`. Keep it when it fits the task. `hybrid` adds sampled Human QA while retaining LLM review; `human_only` is appropriate when LLM grading is prohibited or human review alone is required. Suggest `customer_review` only when the user wants their own team to approve each result, such as a sign-off, acceptance against their own standard, or a contract that requires it; never suggest it by default or infer it from the quality criteria. Only some teams have it; see [Customer review](#customer-review). Recommend a mode based on the user's quality and privacy requirements, explaining cost and turnaround implications before changing it. Human-bearing modes require `humanQaTimeForTask` in whole seconds: at least 30 and at least 3 per quality criterion of the node, whichever is larger, and at most 359,999 (99:59:59). A reviewer keeps a Human QA task for `humanQaTimeForTask` plus 1 hour, and for at least 8 hours. A dropped task stays with that reviewer until this time ends, then another reviewer can take it; `smartSamplingPercent` defaults to 30 for hybrid and 100 for human-only. Use those defaults unless the task justifies a different rate. Human QA on a node is capped at the Maximum of its Human QA line in the frozen estimate: 3 reviews for each item of the run. The cap counts every item of the run, so a branch behind a `match` that receives more than its even share still gets Human QA. Before deploy, the platform counts the QA pool: experts who match the node's audience and hold the platform QA qualification and were active in the last 14 days. The data is rebuilt once a day. With none, validation returns a blocking error and the deploy is rejected. The reviewers come from the node's own audience, because a node has no separate reviewer audience. So for that error, offer to widen the audience (drop specializations first, then countries) or to switch to `llm_only`; do not suggest waiting, because the count is refreshed once a day and nothing shows whether more reviewers will become active. When the count is too small for the node's expected reviews (the platform assumes that 1 of 10 of these experts reviews, for up to 12 hours each), `toloka validate` returns a `severity: 'warning'` issue on the node whose message starts with `Human QA on "<node name>" may stall`. The warning does not block the deploy. Tell the user the numbers in the message and offer its remedies: widen the audience or switch to `llm_only` (or to `hybrid` when the node is `human_only`); change none of them without the user's approval. QA mode applies to the whole node, not individual criteria. The redo cap is platform-controlled and is not an SDK setting.
|
|
53
56
|
|
|
54
57
|
The platform also writes annotator fields on human-expert generation nodes. `<snake_cased node name>_annotator_id` is an optional string: the ID of the expert whose answer was accepted, not of earlier rejected attempts. `<snake_cased node name>_qa_annotator_id` exists only in `human_only` and `hybrid` modes: the ID of the expert who made the last human review decision, missing when sampling skipped human review. Both are missing on canceled items and on items completed before they existed; synthetic nodes have neither. The platform also writes one `*_evaluation_result` field per quality criterion with LLM or Human QA verdicts, `<snake_cased node name>_qa_metadata`, and, on a synthetic node with LLM QA, `<snake_cased node name>_evaluation_summary`. Never declare any of these with `field()`: the platform owns them, and an authored field with that name collides with it. Read them from the dataset with `toloka dataset load`.
|
|
55
58
|
|
|
56
59
|
Keep `instruction` actionable and in English. Include the workflow, concepts, quality rules, and at least one pass and fail example grounded in the task. Do not mention project schedules, dataset volume, workforce requirements, or compensation in labeler instructions.
|
|
57
60
|
|
|
61
|
+
#### Expected expert behavior
|
|
62
|
+
|
|
63
|
+
`expectedExpertBehavior` is required on every human node, not on a synthetic one, and holds up to 10,000 characters. It says how an expert completes the task; answers that break it are rejected. Experts do not see it, so the `instruction` repeats its rules. `toloka check` and `toloka apply` fail without it.
|
|
64
|
+
|
|
65
|
+
##### Ask the user about AI use
|
|
66
|
+
|
|
67
|
+
This is the only question you ask about this setting. Ask it before you write the `instruction` (in Plan mode, before the plan), in the same `ask_user` form as your other questions (up to three):
|
|
68
|
+
|
|
69
|
+
> Can experts use AI tools like ChatGPT, Claude, Gemini, or AI browser agents for this task, for example to look up facts, fix grammar, translate, or draft an answer?
|
|
70
|
+
|
|
71
|
+
- **Not allowed (recommended)**: experts write every answer themselves, without AI in any form, not even for grammar. The default.
|
|
72
|
+
- **For research only**: to look up facts or explain terms; the expert writes the answer.
|
|
73
|
+
- **For research and polishing**: also to fix grammar, rephrase, or translate the expert's own draft.
|
|
74
|
+
- **Any use**: AI may draft the answer; the expert reviews it and is responsible for it.
|
|
75
|
+
|
|
76
|
+
- The brief or the guideline already states the rule: restate it and offer Yes / Change the rules. The chat answer wins over the guideline; update both.
|
|
77
|
+
- The user skips: use Not allowed, do not ask again, and say in your final message that AI is not allowed by default and can be changed in Expected Expert Behavior in the node settings.
|
|
78
|
+
- Any use: say once that experts must review the AI output and that unchanged AI output is rejected. On a `generation` node, offer Switch to synthetic generation / Keep human experts in your next form.
|
|
79
|
+
- An answer produced entirely by AI or an AI agent is never accepted, whatever the user picks.
|
|
80
|
+
- The user asks why: so experts know which tools they may use. Never say how violations are found.
|
|
81
|
+
- The task looks impossible without AI, such as translating from a language the audience may not know: ask about the audience's language instead of weakening the rule.
|
|
82
|
+
|
|
83
|
+
##### Settle the rest yourself
|
|
84
|
+
|
|
85
|
+
Decide from the brief, the guideline, the inputs, the outputs, and the UI: which outside sources are allowed, whether media must be opened in full, what may be pasted into each text field, and which other tools (machine translation, speech-to-text, running code, autocomplete) are allowed.
|
|
86
|
+
|
|
87
|
+
| Task type | Usual answer |
|
|
88
|
+
|---|---|
|
|
89
|
+
| Writing or rewriting text | written by the expert, no paste |
|
|
90
|
+
| Fact-checking or web-grounded answers | web search is part of the task; the source URL is pasted |
|
|
91
|
+
| Rating or comparison | media watched or heard in full |
|
|
92
|
+
| Transcription or audio/video annotation | media heard in full |
|
|
93
|
+
| Translation or localization | no machine translation |
|
|
94
|
+
| Code | documentation and running code are fine |
|
|
95
|
+
| Media collection | only the expert's own recording; nothing downloaded, generated, or edited |
|
|
96
|
+
| Classification | nothing outside the task |
|
|
97
|
+
|
|
98
|
+
Ask the user only when the material is silent and the answer changes the description, for example whether machine translation may start a translation. Put it in the same form as the AI question.
|
|
99
|
+
|
|
100
|
+
##### Write it
|
|
101
|
+
|
|
102
|
+
Plain English, one section label per line, in this order. Use dashes or numbers for lists, no Markdown headings.
|
|
103
|
+
|
|
104
|
+
- `Task:` what the expert does, in one or two sentences.
|
|
105
|
+
- `Process:` the steps in order: what the expert opens, reads, watches or listens to, and fills in.
|
|
106
|
+
- `Outside the task page:` which pages, sites, or apps the expert must or may open. If none: "the task does not require leaving the task page."
|
|
107
|
+
- `Media:` only when there is video, audio, linked images, or an external page: what to open, in full or only the relevant part.
|
|
108
|
+
- `Answer fields:` for each output field: what it asks for, the kind of content (a choice, a value, a URL, an ID, a quote, or the expert's own text), its format, and what exactly may be pasted.
|
|
109
|
+
- `AI tools:` the AI rule.
|
|
110
|
+
- `Built-in tools:` only when the UI has checkers, suggestions, or hints: what they are for.
|
|
111
|
+
- `Expected behavior:` a normal completion as actions: when the expert leaves the page and why, what is pasted where, what is typed, what media is played. Mention time only when the material implies it, such as a video that must be watched in full.
|
|
112
|
+
- `Not allowed:` what breaks the rules. Always "letting an AI agent fill in the task", and, unless the rule is Any use, an answer written entirely by AI.
|
|
113
|
+
|
|
114
|
+
The AI rule:
|
|
115
|
+
|
|
116
|
+
- Write an allowed use as an action and a step ("may ask an AI tool to find sources"), never as a level ("limited AI use").
|
|
117
|
+
- Name the fields the expert writes personally and what AI text may appear in them: none, corrections of the expert's own draft, or a whole draft.
|
|
118
|
+
- Write a ban as "in any form, including research, translation, editing, and grammar checks".
|
|
119
|
+
- Quote the client's rule when there is one.
|
|
120
|
+
- Nothing is known: "AI tools: experts may not use AI tools in any form for this task, including chatbots, AI assistants, AI browser agents, and AI translation or editing tools."
|
|
121
|
+
|
|
122
|
+
| AI rule | Expected behavior | Not allowed |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| Not allowed | answers typed in the fields | AI in any form |
|
|
125
|
+
| Research only | leaving the page for search or an AI tool; answers typed in the fields | any AI text in the fields |
|
|
126
|
+
| Research and polishing | the expert's own draft, corrected by AI, pasted back into the same field | pasting an answer AI wrote from scratch |
|
|
127
|
+
| Any use | an AI draft pasted, then edited | AI output pasted without changes |
|
|
128
|
+
|
|
129
|
+
For sources, media, and pasting, `Not allowed` is the reverse of what you allowed: other sites, answering without watching, pasting anything you did not name. Name what may be pasted into which field, never "paste is allowed". Do not invent rules the material does not state or copy long parts of the guideline.
|
|
130
|
+
|
|
131
|
+
##### Give experts the same rules
|
|
132
|
+
|
|
133
|
+
Add or update a "Rules for this task" section in the `instruction`, in words for experts: what to do ("Watch the whole video before you rate it."), which tools are allowed and for what, in the same terms as `AI tools:`, what to paste where ("Paste the URL of your source into Source."), and the consequence ("Answers that break these rules are rejected; repeated violations lead to removal from the project.").
|
|
134
|
+
|
|
135
|
+
Never tell experts how violations are found, such as tracking, AI detection, or thresholds: write "complete the task on this page", not "do not switch tabs". Keep `Expected behavior:` out of the guideline.
|
|
136
|
+
|
|
137
|
+
##### Fix what the lint finds
|
|
138
|
+
|
|
139
|
+
After every apply the platform lints this text. `toloka validate --wait` shows each finding as a warning on the node, prefixed with its flag, and with "Expert Guideline:" when it is about the guideline. Warnings do not block the deploy; a failed or unfinished lint does. Fix every finding in the source and apply again:
|
|
140
|
+
|
|
141
|
+
- `section_missing`: add the section (`Media:` when the task has media).
|
|
142
|
+
- `not_in_ui`: remove or correct what the task does not have.
|
|
143
|
+
- `field_not_described`: describe the field in `Answer fields:`.
|
|
144
|
+
- `guideline_conflict`: make the guideline state the same rules as the description.
|
|
145
|
+
- `ai_use_ambiguous`: write the AI rule as an action and name the fields the expert writes.
|
|
146
|
+
- `paste_unspecified`: name what is pasted into which field.
|
|
147
|
+
- `reveals_detection`: remove from the guideline how violations are found.
|
|
148
|
+
|
|
58
149
|
#### Audience and pricing
|
|
59
150
|
|
|
60
151
|
For humans, set `audienceType: 'human'`, `verifiedExperts`, all three audience filters, `pricePerTask`, and `timeForTask`. Set `verifiedExperts: true` unless the task explicitly asks for the broad unverified crowd. The public shapes differ by filter: languages use `{ type: 'and' | 'or', values: [{ value: 'English' }] }`; specializations use `{ type: 'and' | 'or', values: [{ value, qualificationId }] }`; countries use ISO 3166-1 alpha-2 codes, for example `{ type: 'or', values: ['US'] }`. Apply rejects a country code, language, or specialization that is not in the audience catalog, and an audience that matches no experts. Derive languages and expertise from the task and its inputs, leaving specialization and country filters unrestricted unless needed. English is a reasonable starting language for an English-language task, not a universal audience default. Ask when an unresolved audience requirement changes who can do the work. Do not put specializations on an unverified audience. A specialization's `qualificationId` is platform identity: preserve an imported value, and discover new ones with `toloka audience specialization list`, copying `ID` into `qualificationId` and `NAME` into `value`; never invent one.
|
|
@@ -67,7 +158,7 @@ Use `audienceType: 'synthetic'` only when the user explicitly asks for model-gen
|
|
|
67
158
|
|
|
68
159
|
Expert lists and expert bans are enabled for a team together: `toloka expert-list` and `toloka expert-ban-list` work only for teams with expert lists enabled. Use them only when the user asks for a fixed set of experts or a ban.
|
|
69
160
|
|
|
70
|
-
- The platform decides how a `generation` or `quorum` node finds experts; there is no setting for it, and apply rejects an `audienceMode` left in an older source, so delete it.
|
|
161
|
+
- The platform decides how a `generation` or `quorum` node finds experts; there is no setting for it, and apply rejects an `audienceMode` left in an older source, so delete it. `audienceAndPricing.expertListCondition` takes the labeling experts from expert lists, and on `generation` `qualityAssurance.expertListCondition` does the same for human QA (`human_only` or `hybrid`). One list is `{ operator: "list_in", expertListId: "exl.…" }`; experts in any of several lists are `{ logic: "or", predicates: [list_in…] }`; to leave out experts who are also in other lists, wrap it as `{ logic: "and", predicates: [<the list_in part>, { operator: "list_nin", expertListId: "exl.…" }…] }`. Other combinations are rejected, and a list can't be both included and excluded. The audience filters then stop deciding who gets tasks; `pricePerTask`, `timeForTask`, and the per-expert cap still apply.
|
|
71
162
|
- Keep the settings `toloka import` wrote. Leaving a field out never detaches a list: plan shows no change for it, but apply rejects the whole graph while any node leaves out a setting the platform has, even when you only changed another node. Run `toloka import` to bring the settings into the source. To detach the lists, set `expertListCondition: null` explicitly.
|
|
72
163
|
- Manage lists with `toloka expert-list`: `list`, `create <name>`, `add <list> --file ids.txt` (one expert ID per line), `remove`, `show <list>`, `experts <list>`, `rename`, `hide`, `unhide`. `<list>` is the `exl.` ID or the list name. Pass large ID sets with `--file`, never as thousands of arguments. Copy the `exl.` ID from `toloka expert-list list` into `expertListCondition.expertListId`; an ID from another project is rejected.
|
|
73
164
|
- After adding experts, run `toloka expert-list show <list>` and report `AVAILABLE`. Availability is checked in the background, so `PENDING` drops over a few minutes. Apply rejects a node whose list has no available experts yet; wait until `AVAILABLE` is above 0, then apply. If few experts are available for the number of items, say so, and mention the per-expert cap when it is on. A hidden list keeps working in runs, but experts can't be added to or removed from it until it is unhidden.
|
|
@@ -127,7 +218,7 @@ Treat `exam` as the optional one-attempt pass/fail gate after Training and befor
|
|
|
127
218
|
|
|
128
219
|
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.
|
|
129
220
|
|
|
130
|
-
|
|
221
|
+
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.
|
|
131
222
|
|
|
132
223
|
### Traps
|
|
133
224
|
|
|
@@ -147,7 +238,7 @@ Use `reuseAudienceWithNodeId` only with real imported `{ pipelineId, nodeId }` v
|
|
|
147
238
|
|
|
148
239
|
`quorum(name, settings)` accepts `QuorumAuthoringSettings`, derived from `QuorumNodeSettings`:
|
|
149
240
|
|
|
150
|
-
- `about`, `publicName`, `entities`, `qualityCriteria`, `instruction`, `ui`, `audienceAndPricing`, `onboarding`, `exam`, `reuseAudienceWithNodeId`, `smartSearch`, and `checks` follow the human-node rules above.
|
|
241
|
+
- `about`, `publicName`, `entities`, `qualityCriteria`, `instruction`, `expectedExpertBehavior`, `ui`, `audienceAndPricing`, `onboarding`, `exam`, `reuseAudienceWithNodeId`, `smartSearch`, 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.
|
|
151
242
|
- `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.
|
|
152
243
|
- `qualityAssurance` is either `llm_only` or `none`.
|
|
153
244
|
- `offboardingRules` supports majority-vote agreement rules in No-QA mode.
|
|
@@ -203,8 +294,6 @@ The authoring helper does not translate `offboardingRules.agreementScale` from `
|
|
|
203
294
|
When a requirement depends on one of these capabilities, state the gap instead of inventing source syntax:
|
|
204
295
|
|
|
205
296
|
- Audience discovery beyond specializations has no SDK or CLI path: valid-language/country suggestions, audience-size statistics for a composed filter, and recommended-rate calculation. `toloka validate` does report an audience that matches no experts, and states the allowed range when `pricePerTask` falls outside it. Specializations and their expert counts come from `toloka audience specialization list`.
|
|
206
|
-
- Audience-reuse candidate discovery has no SDK or CLI path. Source can store a known cross-pipeline pointer, but cannot search candidates.
|
|
207
|
-
- Smart Search rendering, source-fingerprint computation, and stale-profile diagnosis have no SDK or CLI path. Source can carry the public profile; it cannot generate the server-owned fingerprint or preview rendered sourcing documents.
|
|
208
297
|
- Training's examples playbooks and automatic course authoring have no SDK/CLI path. Source can set `onboarding`, but cannot request geometry/numeric check templates or run hands-on examples against the task UI locally; `toloka check` validates only their structure.
|
|
209
298
|
- Exam golden-dataset discovery, creation by symbolic dataset name, dataset lint execution, and generated-golden confirmation flow have no high-level SDK authoring path. `exam.goldenDatasetId` requires a real ID.
|
|
210
299
|
- Generation's platform-controlled redo cap, appeal behavior, payment retry, and exact terminal handling are intentionally not configurable SDK settings.
|
|
@@ -28,12 +28,12 @@ All commands accept `--source-root <directory>`. Prefer running from the source
|
|
|
28
28
|
|
|
29
29
|
## Find commands and catalogs
|
|
30
30
|
|
|
31
|
-
Run `toloka --
|
|
31
|
+
Run `toloka help --all` once for the usage and every option of all commands of the installed version, and `toloka <command> --help` for one command with its notes. The commands fall into these groups:
|
|
32
32
|
|
|
33
33
|
- sign-in and settings: `login`, `logout`, `auth-status` (`whoami`), `config`, `version`;
|
|
34
34
|
- projects and tokens: `project` (`list`, `add`, `switch`, `current`, `url`, `remove`, `create`, `untrack`, `token`, `tokens`, `revoke-token`, `revoke-tokens`), `delivery-order list`;
|
|
35
35
|
- source reconciliation: `init`, `import`, `check`, `validate`, `plan`, `apply`, `status`, `secret set`;
|
|
36
|
-
- catalogs: `audience specialization list`, `generation-model list`, `ui components
|
|
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
39
|
- models and training: `base-model`, `model` (including `model version download`), `training`, `batch-inference` (`run`, `list`, `status`, `confirm`, `resume`, `cancel`);
|
|
@@ -45,6 +45,7 @@ Run `toloka --help` and `toloka <command> --help` for the exact commands and opt
|
|
|
45
45
|
|
|
46
46
|
`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
47
|
|
|
48
|
+
|
|
48
49
|
## Manage model checkpoints
|
|
49
50
|
|
|
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.
|
|
@@ -65,17 +66,15 @@ Use `training cost` to validate inputs and show the maximum charge before `train
|
|
|
65
66
|
|
|
66
67
|
## Check locally and validate against the platform
|
|
67
68
|
|
|
68
|
-
Check the nodes you edit locally, validate every bound pipeline
|
|
69
|
+
Check the nodes you edit locally, then apply and validate every bound pipeline in one command; apply runs the complete local gate itself:
|
|
69
70
|
|
|
70
71
|
```sh
|
|
71
72
|
toloka check <pipeline> --node <name-or-id> # while you edit a node
|
|
72
|
-
toloka validate
|
|
73
|
-
toloka
|
|
74
|
-
toloka validate --wait # after apply: waits for the platform's lints
|
|
75
|
-
toloka pipeline lint <name> --wait # after dataset changes or a failed lint: reruns the lints
|
|
73
|
+
toloka apply && toloka validate --wait # runs the unfiltered toloka check first, writes nothing when it fails, then waits for the platform's lints
|
|
74
|
+
toloka pipeline lint <name> --wait # after dataset changes or a failed lint: reruns the lints
|
|
76
75
|
```
|
|
77
76
|
|
|
78
|
-
Run the unfiltered `toloka check` on its own only when you are not about to apply, since apply would run it again. `toloka check` requires no credentials or live pipeline; SKILL.md describes what it runs and what its statuses mean. Use `toloka check <pipeline> --node <name-or-id>` for a focused edit loop, `--watch` for serialized reruns, and `--json` for automation.
|
|
77
|
+
Run the unfiltered `toloka check` on its own only when you are not about to apply, since apply would run it again. `toloka check` requires no credentials or live pipeline; SKILL.md describes what it runs and what its statuses mean. Use `toloka check <pipeline> --node <name-or-id>` for a focused edit loop, `--watch` for serialized reruns, and `--json` for automation. When it reports an unknown property or a type mismatch on an SDK type, run `toloka schema <that type>` before the next edit instead of trying another shape.
|
|
79
78
|
|
|
80
79
|
With `--watch --json`, each completed rerun writes one JSON line. Do not start another watcher while one is active.
|
|
81
80
|
|
|
@@ -95,7 +94,7 @@ The authored API still supplies extra local safety:
|
|
|
95
94
|
Treat every plan line as evidence of what apply will attempt. `toloka plan --json` prints the same plan as `{ "changes": [...], "missingSecrets": [...] }`, where each change has `kind`, `action`, `label`, and, when they apply, `pipeline`, `dataset`, and `id`.
|
|
96
95
|
|
|
97
96
|
- Confirm additions and changes match the request.
|
|
98
|
-
- Stop on an unexpected removal. Apply refuses to delete tracked pipelines or datasets merely because their source entry disappeared.
|
|
97
|
+
- Stop on an unexpected removal. Apply refuses to delete tracked pipelines or datasets merely because their source entry disappeared, and holds back a pipeline whose plan removes a node or graph field until you pass `--allow-removals`; rewired connections apply without it.
|
|
99
98
|
- Stop on a dataset field marked changed. Existing field schemas cannot be rewritten.
|
|
100
99
|
- Set every secret listed as missing before apply.
|
|
101
100
|
- If imported source contains live IDs, preserve them while editing around them.
|
|
@@ -208,6 +207,10 @@ Use the exact name reported by plan. Set it with `toloka secret set`, rerun plan
|
|
|
208
207
|
|
|
209
208
|
A 409 means live graph state changed after apply read it. Run plan again, compare the new live diff with the source, incorporate intentional live changes into source when required, and apply once more. Never add `expectedVersion` to source and never loop retries.
|
|
210
209
|
|
|
210
|
+
### Active or finalizing run
|
|
211
|
+
|
|
212
|
+
A 409 that says the pipeline has an active run, or that a run is being finalized, means the platform takes no graph change or cancel until that run ends. Check it with `toloka pipeline status <name>`, tell the user the change applies once the run ends, and apply again then. Never wait for it in a sleep loop.
|
|
213
|
+
|
|
211
214
|
### Unexplained node drift after apply
|
|
212
215
|
|
|
213
216
|
Object settings preserve omitted live keys, but list-valued settings such as conditions, predicates, entities, steps, and rules can be compared as whole values after the server adds defaults inside an element. If plan reports an unnamed node change after a clean apply, run `toloka import` into a scratch directory outside the source root, compare that node with source, and declare only the materialized key needed for convergence. Delete the scratch directory afterward and never re-apply blindly.
|
package/src/authoring/index.ts
CHANGED
|
@@ -148,7 +148,14 @@ export type CodeAuthoringSettings = Pick<
|
|
|
148
148
|
|
|
149
149
|
export type GenerationAuthoringSettings = Omit<
|
|
150
150
|
GenerationNodeSettings,
|
|
151
|
-
|
|
151
|
+
| "about"
|
|
152
|
+
| "entities"
|
|
153
|
+
| "qualityCriteria"
|
|
154
|
+
| "instruction"
|
|
155
|
+
| "expectedExpertBehavior"
|
|
156
|
+
| "ui"
|
|
157
|
+
| "onboarding"
|
|
158
|
+
| "exam"
|
|
152
159
|
> & {
|
|
153
160
|
readonly about?: Omit<GenerationNodeSettings["about"], "name"> & { readonly name?: string };
|
|
154
161
|
readonly entities: {
|
|
@@ -157,6 +164,7 @@ export type GenerationAuthoringSettings = Omit<
|
|
|
157
164
|
};
|
|
158
165
|
readonly qualityCriteria?: ReadonlyArray<GenerationQualityCriterion>;
|
|
159
166
|
readonly instruction?: string;
|
|
167
|
+
readonly expectedExpertBehavior?: string;
|
|
160
168
|
readonly ui?: GenerationNodeSettings["ui"];
|
|
161
169
|
readonly onboarding?: GenerationNodeSettings["onboarding"];
|
|
162
170
|
readonly exam?: GenerationExam;
|
|
@@ -173,13 +181,14 @@ export type MatchAuthoringSettings = Pick<MatchNodeSettings, "about"> & {
|
|
|
173
181
|
|
|
174
182
|
export type QuorumAuthoringSettings = Omit<
|
|
175
183
|
QuorumNodeSettings,
|
|
176
|
-
"entities" | "qualityCriteria" | "exam"
|
|
184
|
+
"entities" | "qualityCriteria" | "expectedExpertBehavior" | "exam"
|
|
177
185
|
> & {
|
|
178
186
|
readonly entities: {
|
|
179
187
|
readonly input: ReadonlyArray<QuorumInputEntity>;
|
|
180
188
|
readonly output: ReadonlyArray<QuorumOutputEntity>;
|
|
181
189
|
};
|
|
182
190
|
readonly qualityCriteria: ReadonlyArray<QuorumQualityCriterion>;
|
|
191
|
+
readonly expectedExpertBehavior?: string;
|
|
183
192
|
readonly exam?: QuorumExam;
|
|
184
193
|
};
|
|
185
194
|
|
|
@@ -392,6 +401,7 @@ function compileGenerationSettings(
|
|
|
392
401
|
targetEntity: criterion.targetEntity.id,
|
|
393
402
|
})),
|
|
394
403
|
instruction: settings.instruction ?? "",
|
|
404
|
+
expectedExpertBehavior: settings.expectedExpertBehavior ?? "",
|
|
395
405
|
ui: settings.ui ?? {
|
|
396
406
|
code: "<></>",
|
|
397
407
|
data: "{}",
|
|
@@ -594,6 +604,7 @@ export function quorum(
|
|
|
594
604
|
...criterion,
|
|
595
605
|
targetEntity: criterion.targetEntity.id,
|
|
596
606
|
})),
|
|
607
|
+
expectedExpertBehavior: settings.expectedExpertBehavior ?? "",
|
|
597
608
|
...(exam === undefined
|
|
598
609
|
? {}
|
|
599
610
|
: {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
createVirtualTypeScriptEnvironment,
|
|
11
11
|
} from "./typescript-vfs.js";
|
|
12
12
|
|
|
13
|
-
const tsLibDirectory =
|
|
13
|
+
export const tsLibDirectory =
|
|
14
14
|
Reflect.get(globalThis, "Bun")?.isStandaloneExecutable === true
|
|
15
15
|
? path.join(path.dirname(process.argv[1]!), "typescript-lib")
|
|
16
16
|
: path.dirname(ts.getDefaultLibFilePath({ target: ts.ScriptTarget.Latest }));
|
package/src/cli/analytics.ts
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { resolveSourceRoot, type CommandHost } from "../context";
|
|
3
|
+
import { schemaCommand } from "../schema";
|
|
4
|
+
|
|
5
|
+
export const registerSchemaCommand = (program: Command, host: CommandHost): void => {
|
|
6
|
+
const { context, globals } = host;
|
|
7
|
+
program
|
|
8
|
+
.command("schema")
|
|
9
|
+
.argument(
|
|
10
|
+
"[names...]",
|
|
11
|
+
"functions or types such as quorum, QuorumExam or TaskUiSession; omit to list every name",
|
|
12
|
+
)
|
|
13
|
+
.description(
|
|
14
|
+
"list the SDK authoring and testing functions and types, or print the full shape of the named ones from the installed SDK",
|
|
15
|
+
)
|
|
16
|
+
.addHelpText(
|
|
17
|
+
"after",
|
|
18
|
+
"\nRead from the types of the @toloka-platform/sdk installed in the project: fields, optionality, allowed values, defaults and bounds.",
|
|
19
|
+
)
|
|
20
|
+
.action(async (names: string[]) => {
|
|
21
|
+
schemaCommand({
|
|
22
|
+
sourceRoot: await resolveSourceRoot(globals(), context.io),
|
|
23
|
+
names,
|
|
24
|
+
io: context.io,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
@@ -184,8 +184,13 @@ export const registerSourceCommands = (program: Command, host: CommandHost): voi
|
|
|
184
184
|
|
|
185
185
|
program
|
|
186
186
|
.command("apply")
|
|
187
|
-
.
|
|
188
|
-
|
|
187
|
+
.option(
|
|
188
|
+
"--allow-removals",
|
|
189
|
+
"also apply pipelines whose plan removes nodes or graph fields",
|
|
190
|
+
false,
|
|
191
|
+
)
|
|
192
|
+
.description("check source, print the plan, make the platform match it, then plan again")
|
|
193
|
+
.action(async (options: { allowRemovals: boolean }) => {
|
|
189
194
|
const sourceRoot = await resolveSourceRoot(globals(), context.io);
|
|
190
195
|
const { result: checked, interruptedExitCode } = await runChecksInterruptibly(
|
|
191
196
|
{
|
|
@@ -209,7 +214,11 @@ export const registerSourceCommands = (program: Command, host: CommandHost): voi
|
|
|
209
214
|
sourceRoot,
|
|
210
215
|
source: checked.source,
|
|
211
216
|
...(projectId === undefined ? {} : { projectId }),
|
|
217
|
+
...(options.allowRemovals ? { allowRemovals: true } : {}),
|
|
218
|
+
onPlan: (plan) => context.io.stdout(plan),
|
|
212
219
|
});
|
|
213
220
|
context.io.stdout(result.output);
|
|
221
|
+
const diverged = result.remainingChanges !== undefined && !result.converged;
|
|
222
|
+
if (result.skipped.length > 0 || diverged) exitCode.value = 1;
|
|
214
223
|
});
|
|
215
224
|
};
|
package/src/cli/format-error.ts
CHANGED
|
@@ -21,6 +21,12 @@ const apiErrorHint = (error: PotatoApiError): string | undefined => {
|
|
|
21
21
|
if (error.status === 404) {
|
|
22
22
|
return "Hint: Check the id against toloka project current and the matching list command; ids belong to one project on one platform.";
|
|
23
23
|
}
|
|
24
|
+
if (
|
|
25
|
+
error.status === 409 &&
|
|
26
|
+
/because it has an active run|cannot be canceled while it is being finalized/u.test(apiErrorDetails(error) ?? "")
|
|
27
|
+
) {
|
|
28
|
+
return "Hint: A run of this pipeline is still active or being finalized, and the platform takes no graph change or cancel until it ends. Check it with toloka pipeline status <name>, and apply again once the run has ended; do not retry in a sleep loop.";
|
|
29
|
+
}
|
|
24
30
|
if (error.status === 429) {
|
|
25
31
|
return "Hint: The platform is rate limiting this key; wait a moment and retry.";
|
|
26
32
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
|
|
3
|
+
const runsItself = (command: Command): boolean =>
|
|
4
|
+
command.commands.length === 0 || Reflect.get(command, "_actionHandler") !== null;
|
|
5
|
+
|
|
6
|
+
const commandLines = (command: Command): string[] => {
|
|
7
|
+
const help = command.createHelp();
|
|
8
|
+
const options = help
|
|
9
|
+
.visibleOptions(command)
|
|
10
|
+
.filter((option) => option.long !== "--help")
|
|
11
|
+
.map((option) => ` ${help.optionTerm(option)} ${help.optionDescription(option).replace(" (default: false)", "")}`);
|
|
12
|
+
const usage = help.commandUsage(command).replace(" [options]", "");
|
|
13
|
+
const own = runsItself(command) ? [`${usage} ${command.description()}`, ...options] : [];
|
|
14
|
+
return [
|
|
15
|
+
...own,
|
|
16
|
+
...help.visibleCommands(command).filter((child) => child.name() !== "help").flatMap(commandLines),
|
|
17
|
+
];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const formatAllCommandsHelp = (program: Command): string => {
|
|
21
|
+
const help = program.createHelp();
|
|
22
|
+
const globals = help
|
|
23
|
+
.visibleOptions(program)
|
|
24
|
+
.filter((option) => option.long !== "--help" && option.long !== "--version")
|
|
25
|
+
.map((option) => help.optionTerm(option))
|
|
26
|
+
.join(", ");
|
|
27
|
+
return [
|
|
28
|
+
`Every command also takes ${globals}. Run toloka <command> --help for one command with its notes.`,
|
|
29
|
+
"",
|
|
30
|
+
...help.visibleCommands(program).filter((child) => child.name() !== "help").flatMap(commandLines),
|
|
31
|
+
].join("\n");
|
|
32
|
+
};
|
package/src/cli/index.ts
CHANGED
package/src/cli/program.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { registerReportCommand } from "./commands/report";
|
|
|
20
20
|
import { registerExpertBanListCommands } from "./commands/expert-ban-list";
|
|
21
21
|
import { registerExpertListCommands } from "./commands/expert-list";
|
|
22
22
|
import { registerReviewCommands } from "./commands/review";
|
|
23
|
+
import { registerSchemaCommand } from "./commands/schema";
|
|
23
24
|
import { registerSecretCommands } from "./commands/secret";
|
|
24
25
|
import { registerSkillCommands } from "./commands/skill";
|
|
25
26
|
import { registerSourceCommands } from "./commands/source";
|
|
@@ -39,6 +40,8 @@ import {
|
|
|
39
40
|
} from "./context";
|
|
40
41
|
import { normalizeEnvironment } from "./environment";
|
|
41
42
|
import { formatCliError } from "./format-error";
|
|
43
|
+
import { formatAllCommandsHelp } from "./help-all";
|
|
44
|
+
import { assertCli } from "./cli-error";
|
|
42
45
|
import { readAgentSkillStalenessWarning } from "./init";
|
|
43
46
|
import { SDK_VERSION } from "./sdk-version";
|
|
44
47
|
import { terminalIo } from "./terminal-io";
|
|
@@ -68,7 +71,8 @@ export function createProgram(context: ProgramContext): CreatedProgram {
|
|
|
68
71
|
writeOut: (text) => context.io.stdout(text.replace(/\n$/u, "")),
|
|
69
72
|
writeErr: (text) => context.io.stderr(text.replace(/\n$/u, "")),
|
|
70
73
|
})
|
|
71
|
-
.exitOverride()
|
|
74
|
+
.exitOverride()
|
|
75
|
+
.helpCommand(false);
|
|
72
76
|
|
|
73
77
|
const globals = (): GlobalOptions => program.opts<GlobalOptions>();
|
|
74
78
|
const host = { context, exitCode, globals };
|
|
@@ -116,6 +120,30 @@ export function createProgram(context: ProgramContext): CreatedProgram {
|
|
|
116
120
|
registerReportCommand(program, host);
|
|
117
121
|
registerSkillCommands(program, host);
|
|
118
122
|
registerUiCommands(program, host);
|
|
123
|
+
registerSchemaCommand(program, host);
|
|
124
|
+
|
|
125
|
+
program
|
|
126
|
+
.command("help")
|
|
127
|
+
.argument("[command...]", "command to describe, such as dataset upload")
|
|
128
|
+
.option("--all", "print the usage and every option of all commands at once", false)
|
|
129
|
+
.description("display help for toloka or one of its commands")
|
|
130
|
+
.action((path: string[], options: { all: boolean }) => {
|
|
131
|
+
if (options.all) {
|
|
132
|
+
context.io.stdout(formatAllCommandsHelp(program));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
let command = program;
|
|
136
|
+
for (const name of path) {
|
|
137
|
+
const child = command.commands.find(
|
|
138
|
+
(candidate) => candidate.name() === name || candidate.aliases().includes(name),
|
|
139
|
+
);
|
|
140
|
+
assertCli(child, `Unknown command: toloka ${path.join(" ")}.`, {
|
|
141
|
+
hint: { description: "Run toloka help --all to list every command." },
|
|
142
|
+
});
|
|
143
|
+
command = child;
|
|
144
|
+
}
|
|
145
|
+
command.outputHelp();
|
|
146
|
+
});
|
|
119
147
|
|
|
120
148
|
return { program, exitCode };
|
|
121
149
|
}
|