@toloka-platform/sdk 0.18.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -1 +1 @@
1
- 1c1342774214ac699c199df16e02b37b4eb0460ec165a3b79c4ebfb507a64065 toloka.js.jsc
1
+ a22e3377c6ee8fef9277faea7eab586b0cf3203a85f146c01a59817abd0a9754 toloka.js.jsc
@@ -1 +1 @@
1
- 18e0f27091285d85ab4ed60da287852f6f33cec576e7b2b22e3ac52773ea9bda toloka.js
1
+ a636ba509f0865eaae910795309de013ba4642ba85edf52b65b3c9a3b5c4135c toloka.js
@@ -2304,6 +2304,12 @@ export type RunItemStateOutput = {
2304
2304
  fieldProxyRevisions: RunItemStateOutputFieldProxyRevisions;
2305
2305
  } | null;
2306
2306
 
2307
+ export type RunItemStatePartialOutputFieldProxyRevisions = {[key: string]: string};
2308
+
2309
+ export type RunItemStatePartialOutput = {
2310
+ fieldProxyRevisions: RunItemStatePartialOutputFieldProxyRevisions;
2311
+ } | null;
2312
+
2307
2313
  export interface RunItemState {
2308
2314
  status: RunItemStateStatus;
2309
2315
  startedAt: string | null;
@@ -2311,6 +2317,7 @@ export interface RunItemState {
2311
2317
  error?: string | null;
2312
2318
  input: RunItemStateInput;
2313
2319
  output: RunItemStateOutput;
2320
+ partialOutput: RunItemStatePartialOutput;
2314
2321
  }
2315
2322
 
2316
2323
  export interface RunItem {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toloka-platform/sdk",
3
- "version": "0.18.0",
3
+ "version": "0.19.1",
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",
@@ -10,7 +10,6 @@
10
10
  "files": [
11
11
  "README.md",
12
12
  "bin",
13
- "docs",
14
13
  "dist",
15
14
  "examples",
16
15
  "openapi/gen",
@@ -34,6 +33,8 @@
34
33
  "build": "bun ./scripts/build-cli.ts ./dist/cli",
35
34
  "generate": "orval --config ./openapi/orval.config.js",
36
35
  "generate:check": "bun ./scripts/check-generated-client.ts",
36
+ "docs:generate": "bun ./scripts/generate-docs-reference.ts",
37
+ "docs:check": "bun ./scripts/generate-docs-reference.ts --check",
37
38
  "prepack": "bun run build",
38
39
  "sync-skill-catalog": "bun ./scripts/sync-skill-catalog.ts",
39
40
  "sync-task-ui-declarations": "bun ./scripts/sync-task-ui-declarations.ts",
@@ -43,7 +44,7 @@
43
44
  },
44
45
  "dependencies": {
45
46
  "@inquirer/select": "5.2.1",
46
- "@typescript/vfs": "1.6.2",
47
+ "@typescript/vfs": "1.6.5",
47
48
  "ajv": "8.17.1",
48
49
  "ajv-formats": "3.0.1",
49
50
  "commander": "15.0.0",
@@ -56,13 +57,13 @@
56
57
  "devDependencies": {
57
58
  "@types/node": "24.10.1",
58
59
  "orval": "8.40.0",
59
- "playwright": "1.56.1",
60
- "typescript": "7.0.2",
60
+ "playwright": "1.63.0",
61
+ "typescript": "7.1.0-beta",
61
62
  "vitest": "4.1.0",
62
63
  "yaml": "2.9.0"
63
64
  },
64
65
  "peerDependencies": {
65
- "playwright": ">=1.56.1 <2",
66
+ "playwright": ">=1.63.0 <2",
66
67
  "vitest": ">=4.1.0 <5"
67
68
  },
68
69
  "peerDependenciesMeta": {
@@ -77,6 +78,6 @@
77
78
  "bun": ">=1.4.0"
78
79
  },
79
80
  "tolokaBuild": {
80
- "commit": "83e43ae012b37459f1b18b2e9d0dab903e2171e1"
81
+ "commit": "8577e0d2623cf9daa2b46acb9eb0f7294503de83"
81
82
  }
82
83
  }
@@ -11,8 +11,8 @@
11
11
  "testing",
12
12
  "checks"
13
13
  ],
14
- "version": "0.18.0",
15
- "digest": "43925dfb6b02dae7940e0e70ad9b4167744fa80a76f28c2d49db3c1918151024",
14
+ "version": "0.19.1",
15
+ "digest": "b68151cdf572a7a1ddbf27399044ecd4a35109771b3e1fc710a23c60b0a55462",
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.18.0",
36
+ "version": "0.19.1",
37
37
  "digest": "70f0bd2c80b32f87896aeb27c363b8a2d37f40e22424f57fe1aad142e125ad67",
38
38
  "files": [
39
39
  "SKILL.md",
@@ -50,7 +50,7 @@
50
50
  "getting-started",
51
51
  "agent"
52
52
  ],
53
- "version": "0.18.0",
53
+ "version": "0.19.1",
54
54
  "digest": "2278adeb46a792356579395fcf73c42322cb23bcd0c61e20856ccabdad6762d1",
55
55
  "files": [
56
56
  "SKILL.md"
@@ -67,7 +67,7 @@
67
67
  "sft",
68
68
  "models"
69
69
  ],
70
- "version": "0.18.0",
70
+ "version": "0.19.1",
71
71
  "digest": "3ce10dee5d3c283d8b5fdea15134a58fc738c7af2c1bb19eb5a0bf70ea0bca13",
72
72
  "files": [
73
73
  "SKILL.md"
@@ -84,7 +84,7 @@
84
84
  "prompt",
85
85
  "models"
86
86
  ],
87
- "version": "0.18.0",
87
+ "version": "0.19.1",
88
88
  "digest": "be8bce8d9cf7241ccb60d2b2a9b7cc07d7755a76e8ff8ec1b0847c49efbb3469",
89
89
  "files": [
90
90
  "SKILL.md"
@@ -80,7 +80,7 @@ Let constructors mint IDs for new declarations. Preserve `id` options generated
80
80
 
81
81
  `definePipeline` and typed ports check local declaration and connection invariants. The published JSON contract is still available as `validate(graph)` for importer and fixture tests; it makes no server call.
82
82
 
83
- `toloka check` is the required local gate. It runs the project TypeScript compiler, typechecks every authored Task UI against declarations bundled with this SDK version, runs Vitest, and requires passing typed `test.code`, `test.ui`, and `test.pipeline` evidence for every checkable node and pipeline. Use `toloka check <pipeline> --node <name-or-id>` while iterating, where `<name-or-id>` is the node's name or ID, not the name of the TypeScript constant that holds it, then run the unfiltered command before plan or run. Status `missing` means required test evidence does not exist; `failed` means a check ran and failed; `infrastructure_error` means the checker could not run. All three block apply. `partial` means a Task UI has upload or recording fields the headless browser cannot exercise; it does not block apply, but tell the user to try the task on a real device before launching a run. `warning` on `platform-rules` lists nodes connected to the root that break a platform rule (names, quality elements, thresholds, review time, price, data collection media, exam limits): check still passes, but apply refuses to write that pipeline until they are fixed, so fix them before apply.
83
+ `toloka check` is the required local gate. It runs the project TypeScript compiler, typechecks every authored Task UI against declarations bundled with this SDK version, runs Vitest, and requires passing typed `test.code`, `test.ui`, and `test.pipeline` evidence for every checkable node and pipeline. Use `toloka check <pipeline> --node <name-or-id>` while iterating, where `<name-or-id>` is the node's name or ID, not the name of the TypeScript constant that holds it, then run the unfiltered command before plan or run. Status `missing` means required test evidence does not exist; `failed` means a check ran and failed; `infrastructure_error` means the checker could not run. All three block apply. `partial` means a Task UI has upload or recording fields the headless browser cannot exercise; it does not block apply, but tell the user to try the task on a real device before launching a run. `warning` on `platform-rules` lists nodes connected to the root that break a platform rule (names, quality elements, thresholds, review time, price, data collection media, exam limits, Training structure, and the 150,000-character limit for one node setting): check still passes, but apply refuses to write that pipeline until they are fixed, so fix them before apply.
84
84
 
85
85
  `toloka validate` posts each bound graph to the platform and prints one status per pipeline. It exits 1 when any pipeline is `invalid` or `checks-running`, otherwise 0.
86
86
 
@@ -65,7 +65,19 @@ Use `audienceType: 'synthetic'` only when the user explicitly asks for model-gen
65
65
 
66
66
  #### Training, Exam, UI, and advanced settings
67
67
 
68
- Treat `onboarding` as the node's Training course. It has `enabled`, `steps`, and `info` (`estimatedTime`, `role`, `goal`, `successCriteria`). Give every new human node a real course built from the instruction, criteria, UI, edge cases, and verified examples; the constructor's placeholder is not one. While it is enabled, validation requires non-empty `info.role`, `info.goal`, and `info.successCriteria`, three to six steps, and at least one quiz block; a course uses either a practice block or an examples block, not both, and an examples block needs a built UI. A practice block together with an enabled Exam draws a warning, because the Exam already tests experts on real tasks. Preserve an explicit `enabled: false`. Never invent golden answers or media URLs. Training teaches with retries; it is not an admission gate.
68
+ Treat `onboarding` as the node's Training course. It has `enabled`, `steps`, and `info` (`estimatedTime`, `role`, `goal`, `successCriteria`). Give every new human node a real course built from the instruction, criteria, UI, edge cases, and verified examples; the constructor's placeholder, one text step without a quiz, is not one and fails the rules below. While it is enabled, validation requires non-empty `info.role`, `info.goal`, and `info.successCriteria`, three to six steps, and at least one quiz block; a course uses either a practice block or an examples block, not both, and an examples block needs a built UI. A practice block together with an enabled Exam draws a warning, because the Exam already tests experts on real tasks. Preserve an explicit `enabled: false`. Never invent golden answers or media URLs. Training teaches with retries; it is not an admission gate.
69
+
70
+ Each step holds `blocks`, and every block needs its content:
71
+
72
+ - `text`: markdown in `content[0].value`.
73
+ - `quiz`: `questions[0]` with a `question`, at least two `options` with labels, and a `correctAnswer` that is one of the option values (an array for `multiple-choice`).
74
+ - `practice`: a free-text exercise, not an ungraded note. `content[0].value` is the task; an LLM grades every answer against `validators[0].criteria`, which is required.
75
+ - `examples`: real task inputs shown in the built task UI, each with at least one check (`exact` with `path`, `golden`, and `hint`; `code` with `code` and `hint`; or `llm` with `paths` and `criteria`).
76
+ - `consent`: an agreement the expert must accept, labeled by `consentLabel`.
77
+
78
+ All text in `onboarding` counts together against the platform limit of 150,000 characters for one node setting; `instruction`, `ui`, and the other settings each have the same limit. A course teaches the task; it is not a copy of long source material. When the user asks to carry long material over verbatim, measure it before building: if it would not fit, say so in the plan and ask what to condense or drop.
79
+
80
+ `toloka check` reports every rule above as a `platform-rules` warning that names the node and the setting path, such as `onboarding/steps/2/blocks/0/validators/0/criteria`, and `toloka apply` refuses to write the pipeline until it is fixed.
69
81
 
70
82
  Treat `exam` as the optional one-attempt pass/fail gate after Training and before production. Configure it before finalizing Training. `tasksPerExpert` is 1–10; `passThreshold` is a count from 1 through `tasksPerExpert`. Each `gradedEntities` entry targets an output `Field` and sets `mode: 'ground_truth' | 'quality_criteria' | 'not_graded'`, `groundTruthType: 'direct' | 'custom'`, `customInstruction` (at least 10 characters for custom ground truth, otherwise `''`), and `disabledCriterionIds` (`[]` to keep every criterion). Exact labels favor direct ground truth; free-form work with criteria favors quality criteria; structured comparisons that need tolerance favor custom ground truth. `goldenDatasetId` is a live dataset ID and cannot be derived from a dataset name by the authoring helper; only preserve an imported ID or obtain a real one. Never fabricate one. With `verifiedExperts: false`, the exam also limits how many experts can join the node. Deploy sizes that limit from the tasks the run estimate expects at this node (its expected items, times the overlap on a `quorum` node), the per-expert cap, and the measured exam pass rate, between 100 and 10,000. Behind a `match` router the estimate splits items evenly across the branches, so each branch gets a limit for its share, not for the whole run.
71
83
 
@@ -149,7 +161,7 @@ When a requirement depends on one of these capabilities, state the gap instead o
149
161
  - 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`.
150
162
  - Audience-reuse candidate discovery has no SDK or CLI path. Source can store a known cross-pipeline pointer, but cannot search candidates.
151
163
  - 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.
152
- - 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 validate hands-on examples locally beyond the public graph schema.
164
+ - 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.
153
165
  - 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.
154
166
  - Generation's platform-controlled redo cap, appeal behavior, payment retry, and exact terminal handling are intentionally not configurable SDK settings.
155
167
  - Dynamic quorum and per-item overlap are unsupported by both surfaces; this is a platform limitation, not missing TypeScript syntax.
@@ -100,7 +100,7 @@ Treat every plan line as evidence of what apply will attempt. `toloka plan --jso
100
100
 
101
101
  Apply preserves the canvas position of existing nodes and the root's live item filter. Do not add either to authored source; SKILL.md says where the server places new nodes. For graph replacement, apply reads the live graph version and sends it as `expectedVersion`; never put a version in source or state yourself.
102
102
 
103
- On first apply, the CLI creates each missing named dataset, adds fields required by the authored graphs, creates each missing pipeline, attaches its dataset, and records the resolved IDs. Two pipelines that name the same dataset contribute the union of their required fields.
103
+ On first apply, the CLI imports each missing pipeline without its dataset, so the platform validates the graph before anything else is created; then it creates each missing named dataset, adds fields required by the authored graphs, attaches each new pipeline's dataset, and records the resolved IDs. Two pipelines that name the same dataset contribute the union of their required fields.
104
104
 
105
105
  ## Add dataset rows
106
106
 
@@ -212,7 +212,7 @@ Object settings preserve omitted live keys, but list-valued settings such as con
212
212
 
213
213
  ### Server 400 after a clean validate
214
214
 
215
- A new pipeline is skipped by `toloka validate` until it exists remotely, and apply can create its dataset and fields before pipeline import returns a 400. Fix the reported path or reason, then run plan again. If only the pipeline addition remains, continue from that diff; do not recreate or rename resources already created. If the rejection means a newly created field schema is wrong, that field is already immutable: follow the field schema conflict rule, prefer the option that preserves names the request fixes, and report the orphaned field instead of deleting it. Check connection endpoints, duplicate or unknown imported IDs, field references, and accidentally authored layout. Never bypass reconciliation with a raw API call.
215
+ A new pipeline is skipped by `toloka validate` until it exists remotely. Apply imports it before creating any dataset or field, so when its import returns a 400, no dataset or field was created, although pipelines imported earlier in the same apply remain: fix the reported path or reason, then run plan again. If a later step of that apply fails, the pipeline already exists without its dataset, and the next apply finds it by name and binds the dataset; do not recreate or rename resources already created. For a pipeline that already exists, apply adds new dataset fields before it writes the graph, so a rejected graph write can leave those fields behind. If the rejection means a newly created field schema is wrong, that field is already immutable: follow the field schema conflict rule, prefer the option that preserves names the request fixes, and report the orphaned field instead of deleting it. Check connection endpoints, duplicate or unknown imported IDs, field references, and accidentally authored layout. Never bypass reconciliation with a raw API call.
216
216
 
217
217
  ### Platform connection lost
218
218
 
package/src/cli/check.ts CHANGED
@@ -532,7 +532,7 @@ const platformRuleResults = (
532
532
  ? []
533
533
  : [
534
534
  ...issues.map((issue) => ({
535
- message: `node ${issue.node}: ${issue.reason}`,
535
+ message: `node ${issue.node}, ${issue.setting}: ${issue.reason}`,
536
536
  severity: "warning" as const,
537
537
  })),
538
538
  {
@@ -21,8 +21,8 @@ export const registerAuthCommands = (program: Command, host: CommandHost): void
21
21
  program
22
22
  .command("login")
23
23
  .description("sign in through your browser, or store an API key, after verifying access")
24
- .option("--browser", "sign in through your browser without asking; pick the provider on the page it opens")
25
- .option("--no-browser", "the same, but print the sign-in link instead of opening a browser")
24
+ .option("--browser", "sign in through your browser without asking; choose a sign-in method on the page it opens")
25
+ .option("--no-browser", "print the browser sign-in link without asking or opening a browser")
26
26
  .option("--api-key-stdin", "store an API key read from standard input instead", false)
27
27
  .action(async (options: LoginCommandOptions) => {
28
28
  const apiKey = options.apiKeyStdin ? (await context.io.readStdin()).trim() : globals().apiKey;
@@ -43,10 +43,10 @@ export const registerBatchInferenceCommands = (program: Command, host: CommandHo
43
43
  "--split-column <name-or-id>",
44
44
  "split column that --parts names, when the dataset has more than one",
45
45
  )
46
- .option("--base-model <id>", "catalog Base Model that answers", parseBaseModelId)
47
- .option("--model-version <id>", "Model Version that answers: mdv.<id> or Model@name")
48
- .option("--output-field <name>", "text column on the dataset that receives the answers")
49
- .option("--output-dataset <name>", "new dataset that receives the prompts and answers")
46
+ .option("--base-model <id>", "catalog Base Model that answers; pass exactly one of --base-model or --model-version", parseBaseModelId)
47
+ .option("--model-version <id>", "Model Version that answers: mdv.<id> or Model@name; pass exactly one of --base-model or --model-version")
48
+ .option("--output-field <name>", "text field on the dataset that receives the answers; pass exactly one of --output-field or --output-dataset")
49
+ .option("--output-dataset <name>", "new dataset that receives the prompts and answers; pass exactly one of --output-field or --output-dataset")
50
50
  .requiredOption(
51
51
  "--max-output-tokens <count>",
52
52
  "token limit per answer, at most 8192",
@@ -78,7 +78,7 @@ export const registerBatchInferenceCommands = (program: Command, host: CommandHo
78
78
  batchInference
79
79
  .command("list")
80
80
  .option("--json", "print JSON", false)
81
- .description("list the selected project's Batch Inference Runs")
81
+ .description("list up to 100 of the selected project's Batch Inference Runs (first page only)")
82
82
  .action(async (options: { json: boolean }) => {
83
83
  const { client, projectId } = await resolveContext(globals(), context);
84
84
  assertProjectSelected(projectId);
@@ -6,7 +6,7 @@ export const registerConfigCommands = (program: Command, host: CommandHost): voi
6
6
  const config = program.command("config").description("read and write machine CLI settings");
7
7
  config
8
8
  .command("get")
9
- .argument("[name]", "setting name; omit to print every setting")
9
+ .argument("[name]", "supported setting: auto-update (default true); omit to print every setting")
10
10
  .description("print a CLI setting, or every setting")
11
11
  .action(async (name?: string) => {
12
12
  const settings = await readCliSettings(host.context.environment);
@@ -14,9 +14,10 @@ export const registerConfigCommands = (program: Command, host: CommandHost): voi
14
14
  });
15
15
  config
16
16
  .command("set")
17
- .argument("<name>", "setting name")
18
- .argument("<value>", "setting value")
17
+ .argument("<name>", "supported setting: auto-update (default true)")
18
+ .argument("<value>", "enable with true/1/yes/on; disable with false/0/no/off (case-insensitive)")
19
19
  .description("write a CLI setting for this machine")
20
+ .addHelpText("after", "\nExamples:\n toloka config set auto-update false")
20
21
  .action(async (name: string, value: string) => {
21
22
  const result = await setCliSetting(host.context.environment, name, value);
22
23
  host.context.io.stdout(result.output);
@@ -71,7 +71,7 @@ export const registerDatasetCommands = (program: Command, host: CommandHost): vo
71
71
  .option("--all", "add every top-level field of the uploaded rows that is not a dataset field yet", false)
72
72
  .option("--no-wait", "return as soon as the fields are added, while their values are still being copied")
73
73
  .option("--timeout <ms>", "how long to wait for the values to be copied", positiveInteger)
74
- .option("--json", "print JSON", false)
74
+ .option("--json", "print added fields as JSON; when --all adds nothing, print a text message", false)
75
75
  .description(
76
76
  "add dataset fields from fields of the uploaded rows, so filters, --balance-by and split columns can use their values; uploads after this fill them too",
77
77
  )
@@ -188,7 +188,7 @@ export const registerDatasetCommands = (program: Command, host: CommandHost): vo
188
188
  slice
189
189
  .command("list")
190
190
  .argument("<name>", "dataset name or id")
191
- .description("list the slices of a dataset, newest first")
191
+ .description("list up to 100 slices of a dataset, newest first (first page only)")
192
192
  .action(async (name: string) => {
193
193
  const { sourceRoot, client, projectId } = await resolveContext(globals(), context);
194
194
  const result = await listDatasetSlices(client, {
@@ -43,7 +43,7 @@ export const registerModelCommands = (program: Command, host: CommandHost): void
43
43
  model
44
44
  .command("list")
45
45
  .option("--json", "print JSON", false)
46
- .description("list Models owned by the selected project")
46
+ .description("list up to 100 Models owned by the selected project (first page only)")
47
47
  .action(async (options: { json: boolean }) => {
48
48
  const { client, projectId } = await resolveContext(globals(), context);
49
49
  assertProjectSelected(projectId);
@@ -148,7 +148,7 @@ export const registerPipelineCommands = (program: Command, host: CommandHost): v
148
148
  pipeline
149
149
  .command("results")
150
150
  .argument("<runId>", "run to read")
151
- .option("--limit <n>", "how many items to scan", positiveInteger)
151
+ .option("--limit <n>", "maximum matching items to return (default 20). With --failed, scans up to 500 items, or --limit if larger", positiveInteger)
152
152
  .option("--failed", "only report failed items", false)
153
153
  .description("report a run's items")
154
154
  .action(async (runId: string, options: { limit?: number; failed: boolean }) => {
@@ -11,7 +11,7 @@ export const registerReportCommand = (program: Command, host: CommandHost): void
11
11
  .argument("<markdownPath>", "path to a UTF-8 Markdown report")
12
12
  .option("--authored-by <who>", "human or agent", authoredByOption, "human")
13
13
  .option("--confirm", "confirm submission in a non-interactive environment", false)
14
- .description("preview and send an issue report to Toloka through PostHog")
14
+ .description("preview and send an issue report to Toloka")
15
15
  .action(
16
16
  async (
17
17
  markdownPath: string,
@@ -38,7 +38,7 @@ export const registerTrainingCommands = (program: Command, host: CommandHost): v
38
38
  training
39
39
  .command("list")
40
40
  .option("--json", "print JSON", false)
41
- .description("list active Trainings owned by the selected project")
41
+ .description("list up to 100 active Trainings owned by the selected project (first page only)")
42
42
  .action(async (options: { json: boolean }) => {
43
43
  const { client, projectId } = await resolveContext(globals(), context);
44
44
  assertProjectSelected(projectId);
@@ -57,9 +57,9 @@ export const registerTrainingCommands = (program: Command, host: CommandHost): v
57
57
  training
58
58
  .command("create")
59
59
  .argument("<name>", "new Training name")
60
- .option("--method <method>", "Training method", trainingMethod, "sft")
61
- .option("--base-model <id>", "catalog Base Model source", parseBaseModelId)
62
- .option("--model-version <id>", "exact Model Version source")
60
+ .option("--method <method>", "Training method: sft or gisting", trainingMethod, "sft")
61
+ .option("--base-model <id>", "catalog Base Model source; pass exactly one of --base-model or --model-version", parseBaseModelId)
62
+ .option("--model-version <id>", "exact Model Version source; pass exactly one of --base-model or --model-version")
63
63
  .option(
64
64
  "--dataset <name-or-id>",
65
65
  "Dataset to train on: fills the empty cells of its split column (a new split column, 80/10/10, when it has none) and freezes a slice named after the Training; pass --dataset or --slice",
@@ -89,9 +89,9 @@ export const registerTrainingCommands = (program: Command, host: CommandHost): v
89
89
  "token budget per example, 64 through 16384 (default 12288 for SFT, 3072 for gisting)",
90
90
  trainingMaxSequenceLength,
91
91
  )
92
- .option("--prompt-file <path>", "gisting prompt text file")
92
+ .option("--prompt-file <path>", "required for gisting: non-empty UTF-8 prompt text file, at most 256 KiB")
93
93
  .option("--json", "print JSON", false)
94
- .description("create a normalized Training draft")
94
+ .description("create a Training draft")
95
95
  .action(async (name: string, options: RawTrainingDraftOptions & { json: boolean }) => {
96
96
  const { sourceRoot, client, projectId } = await resolveContext(globals(), context);
97
97
  assertProjectSelected(projectId);
@@ -118,32 +118,32 @@ export const registerTrainingCommands = (program: Command, host: CommandHost): v
118
118
  )
119
119
  .option("--slice <id>", "replacement ready Dataset Slice that freezes a split column")
120
120
  .option("--split-column <name-or-id>", "split column to train with, when the slice freezes more than one")
121
- .option("--parts <names>", "train parts to learn on, comma-separated (default: every part with the train role)", partNames)
122
- .option("--lora-rank <rank>", "SFT LoRA adapter rank: 8, 16, or 32 (default 16)", trainingLoraRank)
121
+ .option("--parts <names>", "train parts to learn on, comma-separated", partNames)
122
+ .option("--lora-rank <rank>", "SFT LoRA adapter rank: 8, 16, or 32", trainingLoraRank)
123
123
  .option(
124
124
  "--gist-tokens <count>",
125
- 'gisting soft tokens: 8, 32, or 64, or a fraction of the prompt "1/4", "1/8", "1/16", "1/32" (default "1/8")',
125
+ 'gisting soft tokens: 8, 32, or 64, or a fraction of the prompt "1/4", "1/8", "1/16", "1/32"',
126
126
  trainingGistTokens,
127
127
  )
128
- .option("--epochs <count>", "training epochs, 1 through 5 (default 3)", trainingEpochs)
128
+ .option("--epochs <count>", "training epochs, 1 through 5", trainingEpochs)
129
129
  .option(
130
130
  "--learning-rate <rate>",
131
- "optimizer learning rate (default 0.00015 for SFT, 0.03 for gisting)",
131
+ "optimizer learning rate",
132
132
  trainingLearningRate,
133
133
  )
134
134
  .option(
135
135
  "--batch-size <count>",
136
- "sequences per optimizer step: 8, 16, 32, or 64 (default 8)",
136
+ "sequences per optimizer step: 8, 16, 32, or 64",
137
137
  trainingBatchSize,
138
138
  )
139
139
  .option(
140
140
  "--max-sequence-length <tokens>",
141
- "token budget per example, 64 through 16384 (default 12288 for SFT, 3072 for gisting)",
141
+ "token budget per example, 64 through 16384",
142
142
  trainingMaxSequenceLength,
143
143
  )
144
144
  .option("--prompt-file <path>", "replacement gisting prompt text file")
145
145
  .option("--json", "print JSON", false)
146
- .description("replace the complete Training draft")
146
+ .description("update a Training draft. Omitted hyperparameters keep their current values.")
147
147
  .action(async (nameOrId: string, options: RawTrainingDraftOptions & { json: boolean }) => {
148
148
  const { sourceRoot, client, projectId } = await resolveContext(globals(), context);
149
149
  assertProjectSelected(projectId);
@@ -201,7 +201,7 @@ export const registerTrainingCommands = (program: Command, host: CommandHost): v
201
201
  .command("runs")
202
202
  .argument("<name-or-id>", "Training name or ID")
203
203
  .option("--json", "print JSON", false)
204
- .description("list Training Run history")
204
+ .description("list up to 100 Training Runs (first page only)")
205
205
  .action(async (nameOrId: string, options: { json: boolean }) => {
206
206
  const { client, projectId } = await resolveContext(globals(), context);
207
207
  assertProjectSelected(projectId);
@@ -229,7 +229,7 @@ export const registerTrainingCommands = (program: Command, host: CommandHost): v
229
229
  .command("cancel")
230
230
  .argument("<training-run-id>", "Training Run ID")
231
231
  .option("--json", "print JSON", false)
232
- .description("cancel a Training Run before provider work completes")
232
+ .description("cancel a Training Run before training completes")
233
233
  .action(async (trainingRunId: string, options: { json: boolean }) => {
234
234
  const { client } = await resolveContext(globals(), context);
235
235
  await cancelTrainingRun(client, { trainingRunId, json: options.json }, context.io);
@@ -5,7 +5,7 @@ import { uiComponentsCommand } from "../ui";
5
5
 
6
6
  export const registerUiCommands = (program: Command, host: CommandHost): void => {
7
7
  const { context, globals } = host;
8
- const ui = program.command("ui").description("inspect the Task UI components the launcher renders");
8
+ const ui = program.command("ui").description("inspect components available for labeling interfaces");
9
9
  ui.command("components")
10
10
  .argument("[names...]", "component names such as Field.RadioGroup; omit to list every component")
11
11
  .option("--json", "print the component contracts as JSON", false)
@@ -55,10 +55,10 @@ export function createProgram(context: ProgramContext): CreatedProgram {
55
55
  .version(SDK_VERSION, "-v, --version", "output the current version")
56
56
  .option(
57
57
  "--source-root <directory>",
58
- "project root; discovered from the working directory when omitted",
58
+ "project root; otherwise search the working directory and parents; init and report use only the working directory",
59
59
  )
60
- .option("--api-key <key>", "API key for this command only")
61
- .option("--base-url <url>", "platform base URL for this command only")
60
+ .option("--api-key <key>", "API key override; login stores the key it verifies")
61
+ .option("--base-url <url>", "platform base URL override; login saves the selected URL")
62
62
  .option("--project-id <id>", "target project; overrides toloka.json")
63
63
  .addHelpText("after", `\n${CREDENTIAL_PRECEDENCE}`)
64
64
  .configureOutput({
@@ -807,9 +807,9 @@ export async function projectStatus(
807
807
 
808
808
  const applyPipeline = async (
809
809
  client: PotatoClient,
810
- projectId: string,
811
810
  pipelineInspection: PipelineInspection,
812
811
  datasetIds: ReadonlyMap<string, string>,
812
+ importedPipelineId: string | undefined,
813
813
  ): Promise<{ readonly pipelineId: string; readonly writes: number }> => {
814
814
  const datasetName = pipelineInspection.source.definition.dataset;
815
815
  const datasetId = datasetName === undefined ? undefined : datasetIds.get(datasetName);
@@ -818,20 +818,20 @@ const applyPipeline = async (
818
818
  `Dataset ${datasetName} has no resolved ID.`,
819
819
  { hint: REPORT_HINT },
820
820
  );
821
+ if (importedPipelineId !== undefined) {
822
+ if (datasetId === undefined) return { pipelineId: importedPipelineId, writes: 0 };
823
+ await client.pipelines.attachDataset({ pipelineId: importedPipelineId, datasetId });
824
+ return { pipelineId: importedPipelineId, writes: 1 };
825
+ }
826
+ assertCli(
827
+ pipelineInspection.pipeline,
828
+ `Pipeline ${pipelineInspection.source.sourceDirectory} has no live pipeline.`,
829
+ { hint: REPORT_HINT },
830
+ );
821
831
  const desiredGraph = resolvePipelineDefinition(
822
832
  pipelineInspection.source.definition,
823
833
  datasetId === undefined ? {} : { datasetId },
824
834
  );
825
- if (pipelineInspection.pipeline === undefined) {
826
- const pipeline = await client.pipelines.import({
827
- projectId,
828
- name: pipelineInspection.source.name,
829
- graph: desiredGraph,
830
- });
831
- if (datasetId === undefined) return { pipelineId: pipeline.id, writes: 1 };
832
- await client.pipelines.attachDataset({ pipelineId: pipeline.id, datasetId });
833
- return { pipelineId: pipeline.id, writes: 2 };
834
- }
835
835
  const pipelineId = pipelineInspection.pipeline.id;
836
836
  if (pipelineInspection.graphChanges.length === 0) return { pipelineId, writes: 0 };
837
837
  const snapshot = pipelineInspection.snapshot;
@@ -890,7 +890,7 @@ export async function applyProject(
890
890
  .filter((pipeline) => pipeline.pipeline === undefined || pipeline.graphChanges.length > 0)
891
891
  .flatMap((pipeline) =>
892
892
  platformRuleIssues(pipeline.source.definition.graph).map(
893
- (issue) => `- ${pipeline.source.sourceDirectory}, node ${issue.node}: ${issue.reason}`,
893
+ (issue) => `- ${pipeline.source.sourceDirectory}, node ${issue.node}, ${issue.setting}: ${issue.reason}`,
894
894
  ),
895
895
  );
896
896
  assertCli(
@@ -900,6 +900,18 @@ export async function applyProject(
900
900
  );
901
901
 
902
902
  let writes = 0;
903
+ const importedPipelineIds = new Map<string, string>();
904
+ for (const pipelineInspection of inspection.pipelines) {
905
+ if (pipelineInspection.pipeline !== undefined) continue;
906
+ const imported = await client.pipelines.import({
907
+ projectId: inspection.projectId,
908
+ name: pipelineInspection.source.name,
909
+ graph: resolvePipelineDefinition(pipelineInspection.source.definition, {}),
910
+ });
911
+ importedPipelineIds.set(pipelineInspection.source.sourceDirectory, imported.id);
912
+ writes += 1;
913
+ }
914
+
903
915
  const datasetIds = new Map<string, string>();
904
916
  for (const datasetInspection of inspection.datasets) {
905
917
  let dataset = datasetInspection.dataset;
@@ -925,7 +937,12 @@ export async function applyProject(
925
937
 
926
938
  const pipelineIds = new Map<string, string>();
927
939
  for (const pipelineInspection of inspection.pipelines) {
928
- const applied = await applyPipeline(client, inspection.projectId, pipelineInspection, datasetIds);
940
+ const applied = await applyPipeline(
941
+ client,
942
+ pipelineInspection,
943
+ datasetIds,
944
+ importedPipelineIds.get(pipelineInspection.source.sourceDirectory),
945
+ );
929
946
  pipelineIds.set(pipelineInspection.source.sourceDirectory, applied.pipelineId);
930
947
  writes += applied.writes;
931
948
  }
@@ -7,5 +7,8 @@
7
7
  "humanQaSecondsPerQualityCriterion": 3,
8
8
  "minQualityThresholdLength": 10,
9
9
  "maxExamTasksPerExpert": 10,
10
- "mediaUploadComponentPattern": "<Field\\.(?:Video(?:Upload|Record)|FileUpload)\\b"
10
+ "mediaUploadComponentPattern": "<Field\\.(?:Video(?:Upload|Record)|FileUpload)\\b",
11
+ "nodeSettingMaxCharacters": 150000,
12
+ "minTrainingSteps": 3,
13
+ "maxTrainingSteps": 6
11
14
  }
package/src/transport.ts CHANGED
@@ -19,6 +19,8 @@ const TUNNEL_UNAVAILABLE = "tunnel-unavailable";
19
19
  export const TUNNEL_RETRY_DELAYS_MS: readonly number[] = [
20
20
  1_000, 2_000, 4_000, 8_000, 15_000, 15_000, 15_000, 15_000, 15_000,
21
21
  ];
22
+ const RATE_LIMIT_RETRIES = 3;
23
+ const MAX_RATE_LIMIT_DELAY_MS = 60_000;
22
24
 
23
25
  type TransportRequestInit = RequestInit & {
24
26
  readonly fetch?: typeof globalThis.fetch;
@@ -26,6 +28,13 @@ type TransportRequestInit = RequestInit & {
26
28
  readonly tunnelRetryDelaysMs?: readonly number[];
27
29
  };
28
30
 
31
+ const rateLimitDelayMs = (response: Response): number | undefined => {
32
+ const retryAfter = response.headers.get("retry-after");
33
+ if (response.status !== 429 || retryAfter === null || retryAfter.trim() === "") return undefined;
34
+ const seconds = Number(retryAfter);
35
+ return Number.isFinite(seconds) && seconds >= 0 ? Math.min(seconds * 1_000, MAX_RATE_LIMIT_DELAY_MS) : undefined;
36
+ };
37
+
29
38
  export const createRequestOptions = (
30
39
  baseUrl: string,
31
40
  credential: ClientCredential,
@@ -109,6 +118,15 @@ export async function potatoFetch(url: string, options: TransportRequestInit): P
109
118
  response = await send();
110
119
  }
111
120
 
121
+ for (let retry = 0; replayableBody && retry < RATE_LIMIT_RETRIES; retry += 1) {
122
+ const delayMs = rateLimitDelayMs(response);
123
+ if (delayMs === undefined) break;
124
+
125
+ await response.body?.cancel();
126
+ await delay(delayMs, { signal: requestOptions.signal ?? undefined });
127
+ response = await send();
128
+ }
129
+
112
130
  const text = await response.text();
113
131
 
114
132
  if (!response.ok) {