@toloka-platform/sdk 0.19.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
- 04aed695bf540451fb62ec4f4c40034a2e24d3b55f65d0b6cdaada4a7d25880e toloka.js.jsc
1
+ a22e3377c6ee8fef9277faea7eab586b0cf3203a85f146c01a59817abd0a9754 toloka.js.jsc
@@ -1 +1 @@
1
- 9edbb8add956099bf362cea5c124a6474fcffa1b18ae75b5a785e37f244936ad toloka.js
1
+ a636ba509f0865eaae910795309de013ba4642ba85edf52b65b3c9a3b5c4135c toloka.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toloka-platform/sdk",
3
- "version": "0.19.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": "d5dcfe5a5c49fef069ef9c9e3c8c265eca73f752"
81
+ "commit": "8577e0d2623cf9daa2b46acb9eb0f7294503de83"
81
82
  }
82
83
  }
@@ -11,7 +11,7 @@
11
11
  "testing",
12
12
  "checks"
13
13
  ],
14
- "version": "0.19.0",
14
+ "version": "0.19.1",
15
15
  "digest": "b68151cdf572a7a1ddbf27399044ecd4a35109771b3e1fc710a23c60b0a55462",
16
16
  "files": [
17
17
  "SKILL.md",
@@ -33,7 +33,7 @@
33
33
  "bug",
34
34
  "report"
35
35
  ],
36
- "version": "0.19.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.19.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.19.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.19.0",
87
+ "version": "0.19.1",
88
88
  "digest": "be8bce8d9cf7241ccb60d2b2a9b7cc07d7755a76e8ff8ec1b0847c49efbb3469",
89
89
  "files": [
90
90
  "SKILL.md"
@@ -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({
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) {