@toloka-platform/sdk 0.2.1 → 0.3.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/README.md +12 -6
- package/dist/cli/toloka.js +242 -134
- 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/docs/cli.md +73 -20
- package/docs/getting-started.md +11 -9
- package/docs/limitations.md +6 -0
- package/docs/testing-examples.md +2 -2
- package/docs/testing.md +10 -2
- package/docs/troubleshooting.md +16 -4
- package/package.json +1 -1
- package/skills/catalog.json +10 -10
- package/skills/toloka-build/SKILL.md +8 -5
- package/skills/toloka-build/references/workflow-and-cli.md +44 -22
- package/skills/toloka-fine-tuning/SKILL.md +1 -2
- package/skills/toloka-get-started/SKILL.md +4 -3
- package/skills/toloka-gisting/SKILL.md +1 -2
- package/skills/toloka-report-issue/references/report-template.md +1 -1
- package/src/cli/auth.ts +382 -81
- package/src/cli/browser-login.ts +265 -0
- package/src/cli/browser-session.ts +244 -0
- package/src/cli/commands/auth.ts +22 -15
- package/src/cli/commands/project.ts +3 -3
- package/src/cli/config.ts +41 -14
- package/src/cli/context.ts +38 -7
- package/src/cli/credentials.ts +13 -13
- package/src/cli/keycloak.ts +189 -0
- package/src/cli/program.ts +3 -0
- package/src/cli/sign-in-page.ts +153 -0
- package/src/cli/style.ts +37 -0
- package/src/cli/terminal-io.ts +9 -2
- package/src/client.ts +3 -3
- package/src/pipeline-graph-v1.contract.json +47 -24
- package/src/transport.ts +19 -11
package/dist/cli/toloka.js.jsc
CHANGED
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a22866960e3e7f99095169d57097612bd388f58b10fcc6ba2f11c44d2673a59a toloka.js.jsc
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
4280c470c616abb21bd56a2f9528ba82a88b45b6ac02fd8c8ad21a5bfedd1284 toloka.js
|
package/docs/cli.md
CHANGED
|
@@ -2,19 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
The `toloka` CLI reads TypeScript source as the desired state, compares it with the live platform state, and reconciles the two.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The CLI and SDK are versioned together. Before 1.0, commands and authoring APIs can change between minor releases.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
curl -fsSL https://platform.toloka.ai/cli/install.sh | sh
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The installer prefers stable Bun 1.4.0 or newer matching the host architecture and installs the SDK's CLI into Bun's global binary directory. If Bun is missing, older, or built for a different architecture, it installs a standalone executable in `~/.local/bin` without changing Bun. Native downloads support macOS and glibc Linux on ARM64/x64 and require `curl`, `tar`, `mktemp`, and `shasum` or `sha256sum`. Compatible Bun can be used on musl Linux; this shell installer does not support native Windows.
|
|
14
|
+
|
|
15
|
+
Force the install mode:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
curl -fsSL https://platform.toloka.ai/cli/install.sh | sh -s -- --native
|
|
19
|
+
curl -fsSL https://platform.toloka.ai/cli/install.sh | sh -s -- --bun
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
`--native` ignores installed Bun. `--bun` fails if Bun is incompatible. A Bun package installation failure is reported, not retried as a native install.
|
|
23
|
+
|
|
24
|
+
Add the printed directory to `PATH` if prompted. Verify the selected executable:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
toloka version --json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Standalone installs report `"channel":"native"`. **Bun is the recommended runtime and package manager for SDK development:**
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
bun add @toloka-platform/sdk@latest
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Use `bun i` for an existing project's dependencies. Training-only workflows need no SDK dependency. Local tests may also need Python or Chromium; see [Testing](./testing.md).
|
|
37
|
+
|
|
38
|
+
The installer accepts these environment variables:
|
|
39
|
+
|
|
40
|
+
| Variable | Effect |
|
|
41
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
42
|
+
| `TOLOKA_CLI_INSTALL_DIR` | Override the native install directory; use with `--native`. Bun mode rejects this option and uses Bun's global binary directory. |
|
|
43
|
+
| `TOLOKA_CLI_CHANNEL` | Select `latest` (the default) or `preview`. |
|
|
44
|
+
| `TOLOKA_CLI_PACKAGE` | Override the selected mode's package: an SDK package for `--bun`, a matching native package for `--native`. A trailing version or tag overrides the channel. |
|
|
45
|
+
| `TOLOKA_CLI_REGISTRY` | Fetch installer metadata and the tarball from another npm registry. Automatic updates still use the public npm registry. |
|
|
46
|
+
|
|
47
|
+
Pass overrides to the `sh` process on the right side of the pipe, for example `curl -fsSL https://platform.toloka.ai/cli/install.sh | TOLOKA_CLI_CHANNEL=preview sh`.
|
|
48
|
+
|
|
49
|
+
### Updates and migration from Bun global installs
|
|
50
|
+
|
|
51
|
+
Standalone and Bun-global CLIs check the public npm registry at most daily and install eligible releases at least 24 hours old, then rerun the command. Disable with `toloka config set auto-update false`. Project-local installs, CI, help, version, and config commands skip updates; `TOLOKA_SKIP_AUTO_UPDATE=1` also skips them. `TOLOKA_AUTO_UPDATE=0` or `1` overrides the stored setting for one command.
|
|
52
|
+
|
|
53
|
+
For a manual update, rerun the installer with the original mode (`--bun` or `--native`), directory, channel, package, and registry overrides. A version pin does not disable auto-update; automatic updates always use the public npm registry.
|
|
54
|
+
|
|
55
|
+
If both installations exist, put the desired directory first on `PATH`, run `hash -r` (Bash) or `rehash` (Zsh), and check `toloka version --json`: `native` means the standalone executable, `global-registry` means the Bun-global CLI. Credentials, settings, and project dependencies stay unchanged.
|
|
8
56
|
|
|
9
57
|
## Configuration
|
|
10
58
|
|
|
11
59
|
Credentials and the platform base URL resolve from the same precedence order, highest first.
|
|
12
60
|
|
|
13
|
-
| Precedence |
|
|
14
|
-
| ----------- |
|
|
15
|
-
| 1 (highest) | `--api-key` flag
|
|
16
|
-
| 2 | `TOLOKA_API_KEY` environment variable
|
|
17
|
-
| 3
|
|
61
|
+
| Precedence | Credential source |
|
|
62
|
+
| ----------- | ------------------------------------------------ |
|
|
63
|
+
| 1 (highest) | `--api-key` flag |
|
|
64
|
+
| 2 | `TOLOKA_API_KEY` environment variable |
|
|
65
|
+
| 3 | API key stored by `toloka login --api-key-stdin` |
|
|
66
|
+
| 4 (lowest) | browser session stored by `toloka login` |
|
|
18
67
|
|
|
19
68
|
| Precedence | Base URL source |
|
|
20
69
|
| ----------- | --------------------------------------- |
|
|
@@ -26,15 +75,13 @@ Credentials and the platform base URL resolve from the same precedence order, hi
|
|
|
26
75
|
| Precedence | Project id source |
|
|
27
76
|
| ----------- | --------------------------------------------- |
|
|
28
77
|
| 1 (highest) | `--project-id` flag |
|
|
29
|
-
| 2 | `TOLOKA_PROJECT_ID` |
|
|
78
|
+
| 2 | `TOLOKA_PROJECT_ID` environment variable |
|
|
30
79
|
| 3 | `projectId` in `toloka.json` |
|
|
31
80
|
| 4 (lowest) | `current` alias in the credentials file |
|
|
32
81
|
|
|
33
82
|
Earlier releases named these variables `POTATO_API_KEY`, `POTATO_BASE_URL`, and `POTATO_PROJECT_ID`. The CLI still reads each legacy name when its `TOLOKA_*` counterpart is unset, prefers the `TOLOKA_*` value when both are set, and prints `POTATO_API_KEY is deprecated and will stop being read; set TOLOKA_API_KEY instead.` (and the same line for the other two) on stderr once per command. The aliases remain supported for compatibility; rename them to silence the warning and use the current names in new automation.
|
|
34
83
|
|
|
35
|
-
`toloka login` verifies
|
|
36
|
-
|
|
37
|
-
Machine settings live next to that credentials file in `settings.json` and default `auto-update` to `true`. A globally installed `toloka` checks `https://registry.npmjs.org/` at most once per day and, when a newer `@toloka-platform/sdk` version has been published for at least 24 hours, installs it with `bun add --global` and re-runs the original command. The check is pinned to that registry; a checkout `.env` cannot retarget it. `config`, `version`, and `help` never trigger a check. Project-local installs, CI, and `TOLOKA_SKIP_AUTO_UPDATE=1` also skip it. `TOLOKA_AUTO_UPDATE=0` turns it off for one command; `TOLOKA_AUTO_UPDATE=1` turns it on even when the setting is false.
|
|
84
|
+
`toloka login` verifies access against the platform before saving anything. A browser login is saved as a session file under `$TOLOKA_CLI_CREDENTIALS_DIR`, which defaults to `~/.toloka/cli/credentials/<auth-host>/<realm>/<client>.json`. When `TOLOKA_CREDENTIALS_FILE` points at an explicit credentials file, sessions go to a `browser-sessions` directory next to it instead, so that profile stays isolated. The platform choice, a stored API key, and local project aliases live in `$XDG_CONFIG_HOME/toloka/credentials.json`, which defaults to `~/.config/toloka/credentials.json`. Both are written with file mode `0600` in directories with mode `0700`. The legacy `~/.toloka/credentials.json` is still read when the new path has no file. `toloka logout` ends the browser session and deletes both files; it does not revoke an API key.
|
|
38
85
|
|
|
39
86
|
Ordinary usage events (`sdk_cli_command_completed` / `sdk_cli_command_failed`) go to Toloka's PostHog project so we can see which commands run and which error classes they hit. Every failed command with an exception also emits a sanitized PostHog Error Tracking `$exception`; usage errors such as unknown commands or invalid flags do not. Command events contain only an allowlisted command classifier, duration, exit code, outcome or error code, optional HTTP status and server request ID, SDK and Bun versions, actor, and channel. Error Tracking receives the same bounded metadata plus a synthetic exception; raw arguments, flag values, environment variables, API keys, secret names, base URLs and hosts, local paths, project ids, error messages, stack traces, response bodies, and source context are not sent. GeoIP enrichment is disabled. Distinct id starts as a random UUID stored next to the credentials file. After a successful authenticated command, the CLI calls `GET /me` and aliases that UUID onto the platform user id without setting person properties. Set `TOLOKA_TELEMETRY=0` or `DO_NOT_TRACK=1` to disable capture. CI environments are disabled unless `TOLOKA_TELEMETRY=1`. The explicitly approved full-text `report` event is documented in [report](#report).
|
|
40
87
|
|
|
@@ -49,6 +96,8 @@ The root program accepts these flags before any command:
|
|
|
49
96
|
|
|
50
97
|
Commands resolve the project root by walking up from the working directory until they find a `toloka.json` file. The CLI reports that directory on stderr when it differs from the working directory. Passing `--source-root` disables discovery. With no marker found, the working directory is used. `init` and `report` do not walk up: they use the working directory or `--source-root` only. The authentication commands `login`, `logout`, and `auth-status` do not need a project root.
|
|
51
98
|
|
|
99
|
+
The CLI colors its output only when standard output is a terminal. `NO_COLOR` with any value, or `TERM=dumb`, turns color off. `FORCE_COLOR` overrides the terminal detection in both directions: `FORCE_COLOR=0` turns color off even on a terminal, and any other value turns it on even when the output is piped.
|
|
100
|
+
|
|
52
101
|
## Errors and hints
|
|
53
102
|
|
|
54
103
|
A failing command prints its message to stderr and exits `1`. Most messages are followed by a `Hint: …` line with the next command to run; messages that already spell out the remedy carry no hint. Platform failures print `Potato API request failed with status <code> (request id: <id>)`, the response body, and a status-based hint: `401`/`403` point at `toloka whoami` and `toloka login`, `404` at the selected project and the matching list command, `429` asks you to wait, and `5xx` asks you to retry and then send a report with `toloka report <report.md>`.
|
|
@@ -69,7 +118,7 @@ Resources may also expose specialized actions beyond the Base Actions, such as `
|
|
|
69
118
|
|
|
70
119
|
## version
|
|
71
120
|
|
|
72
|
-
Print the SDK/CLI version. `toloka version --json` also prints build provenance: the build commit
|
|
121
|
+
Print the SDK/CLI version. `toloka version --json` also prints build provenance: the build commit, the install channel (`native`, `global-registry`, `linked`, or `project-local`), the executable path for a native install, and the package path for a linked install. `toloka -v` and `toloka --version` remain semver-only for scripts.
|
|
73
122
|
|
|
74
123
|
```sh
|
|
75
124
|
toloka version [--json]
|
|
@@ -120,36 +169,40 @@ Lists every expert specialization (platform qualification) with `ID`, `NAME`, an
|
|
|
120
169
|
|
|
121
170
|
## login
|
|
122
171
|
|
|
123
|
-
|
|
172
|
+
Signs in through the browser, or stores an API key, after verifying access.
|
|
124
173
|
|
|
125
174
|
```sh
|
|
126
175
|
toloka login
|
|
176
|
+
toloka login --browser
|
|
177
|
+
toloka login --no-browser
|
|
127
178
|
toloka login --api-key-stdin < key.txt
|
|
128
179
|
```
|
|
129
180
|
|
|
130
|
-
|
|
181
|
+
By default the command asks whether to sign in through the browser or with an API key. The browser choice opens a local page in the system browser where you continue with Google or Microsoft, the same providers as the platform's own sign-in page (testing environments also offer email and password and the testing users), or follow the link to create a Toloka account first; the page hands you to the Toloka login page, a one-time loopback redirect returns the result to the CLI, and the CLI verifies access by listing projects before saving anything. On success it prints `Logged in to <base-url> as <email>`, then the number of projects visible and when the session stops renewing. The session carries a short-lived access token that the CLI renews on its own; renewal stops 14 days after signing in, or after 8 days without use, and the next command asks you to run `toloka login` again. The session is a credential for the platform API only; it does not work against other Toloka services. `--browser` skips the question and goes straight to the browser flow, even when `TOLOKA_API_KEY` is set; coding agents and scripts that sign the user in should pass it. `--no-browser` does the same but prints the link instead of opening a browser. Set `BROWSER` to choose the browser command.
|
|
182
|
+
|
|
183
|
+
Browser login is available for `https://platform.toloka.ai` and the `*.platform.toloka-test.ai` environments. Without a terminal the command opens the chooser page directly and fails fast when no browser can be opened; automation uses an API key instead.
|
|
131
184
|
|
|
132
|
-
|
|
185
|
+
The API key choice does not expire: the key works until it is deleted in the Business Console, which suits scripts, CI, and coding agents. Choosing it asks for the key with masked input; `--api-key-stdin` reads it from standard input instead, so it never appears in shell history or the process list; `--api-key <key>` and `TOLOKA_API_KEY` also work but expose the key to both. Platforms without a known login service go straight to the API key prompt. The command verifies the key and prints `Authenticated against <base-url> with an API key`, then the number of projects visible, where the key is stored, and a reminder that the key does not expire until you delete it in the Business Console.
|
|
133
186
|
|
|
134
187
|
## logout
|
|
135
188
|
|
|
136
|
-
|
|
189
|
+
Ends the browser login and removes stored credentials from this machine.
|
|
137
190
|
|
|
138
191
|
```sh
|
|
139
192
|
toloka logout
|
|
140
193
|
```
|
|
141
194
|
|
|
142
|
-
On success it prints `Removed <paths
|
|
195
|
+
On success it prints `Removed <paths>.`; after a browser login it also ends every stored browser session (production and testing) at the login service, and after an API-key login it notes that the key is not revoked. When nothing is stored, it prints `No stored credentials found at <path>.`
|
|
143
196
|
|
|
144
197
|
## auth-status
|
|
145
198
|
|
|
146
|
-
Shows which platform and
|
|
199
|
+
Shows which platform and login the CLI would use. Alias: `whoami`.
|
|
147
200
|
|
|
148
201
|
```sh
|
|
149
202
|
toloka auth-status [--show-token]
|
|
150
203
|
```
|
|
151
204
|
|
|
152
|
-
On success it prints the platform URL with its source, the API key
|
|
205
|
+
On success it prints the platform URL with its source, then either the masked API key or a `Login:` line for the browser session and a `Session:` line with the current refresh window, then the selected project, `Reachable: N project(s) visible.`, `Account:` with the email the platform reports, `Internal: true` or `Internal: false` for the account, and a `Teams:` line that marks each team `(internal)` and `(read-only)` where that applies. The project line is printed even when the probe fails. `--show-token` prints the full API key or the browser session's live access token instead of the mask; pass it only when you need the raw value on this terminal. It exits `1` when no login is in effect, when the browser session has expired, when the platform rejects the login (`Rejected: …`, followed by the advice to run `toloka login`), when the platform does not answer (`Not reachable: …`; the login was not evaluated), or when the platform fails (`Platform error: …`).
|
|
153
206
|
|
|
154
207
|
## config
|
|
155
208
|
|
|
@@ -372,7 +425,7 @@ toloka skill install <skillId> [--force]
|
|
|
372
425
|
|
|
373
426
|
After an SDK upgrade `list` reports installed skills whose catalog digest changed as `stale` until they are refreshed with `install --force`. Local edits to an installed skill also make it `stale`; `list` and `search` never modify local files.
|
|
374
427
|
|
|
375
|
-
The catalog is bound to the installed
|
|
428
|
+
The catalog is bound to the installed CLI version, so a skill that a newer release ships is absent from an older CLI. `install` then exits 1, names the missing skill and installed version, and creates nothing. Run `toloka skill list` to see the available skills. To get the current supported catalog, rerun the CLI installer and retry.
|
|
376
429
|
|
|
377
430
|
## Exit codes
|
|
378
431
|
|
package/docs/getting-started.md
CHANGED
|
@@ -4,16 +4,17 @@ Install the SDK, sign in, and get a pipeline project reconciling from source in
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
Install the
|
|
7
|
+
Install the CLI, then add the SDK for pipeline authoring:
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
curl -fsSL https://platform.toloka.ai/cli/install.sh | sh
|
|
11
11
|
bun add @toloka-platform/sdk@latest
|
|
12
|
+
toloka --version
|
|
12
13
|
```
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
**Bun is the recommended runtime and package manager for SDK development.** In an existing project, run `bun i` instead of adding dependencies again. The standalone CLI includes its runtime; Training-only workflows do not need the SDK.
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
The installer prefers compatible Bun and otherwise installs a standalone executable. Add the printed directory to `PATH` if prompted. See [CLI setup](./cli.md#install) for mode overrides and updates, and [Testing](./testing.md) for local test dependencies.
|
|
17
18
|
|
|
18
19
|
## Sign in
|
|
19
20
|
|
|
@@ -21,21 +22,22 @@ The installer requires Bun 1.4.0 or newer, installs `@toloka-platform/sdk` globa
|
|
|
21
22
|
toloka login
|
|
22
23
|
```
|
|
23
24
|
|
|
24
|
-
`login`
|
|
25
|
+
`login` asks whether to sign in through the browser or with an API key, opens a page in your browser where you pick the provider, verifies access against the platform, and only then stores the session. Nothing is written when the platform does not accept the account.
|
|
25
26
|
|
|
26
27
|
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
? How do you want to sign in? Sign in with your browser
|
|
29
|
+
Waiting for the sign-in to finish in your browser... If no browser opened, run toloka login --no-browser to get a link.
|
|
30
|
+
✔ Logged in to https://platform.toloka.ai as you@example.com
|
|
31
|
+
12 projects visible · session renews automatically until 2026-09-25T10:00:00Z, then run toloka login again
|
|
30
32
|
```
|
|
31
33
|
|
|
32
|
-
Check what the CLI will use at any time:
|
|
34
|
+
The session renews itself for up to 14 days; after that, run `toloka login` again. Check what the CLI will use at any time:
|
|
33
35
|
|
|
34
36
|
```sh
|
|
35
37
|
toloka whoami
|
|
36
38
|
```
|
|
37
39
|
|
|
38
|
-
CI does not need `login`. Set `TOLOKA_API_KEY` and the stored
|
|
40
|
+
CI does not need `login`. Set `TOLOKA_API_KEY` and the stored login is ignored; an agent without a terminal can pipe a key to `toloka login --api-key-stdin`. See the precedence table in the [CLI reference](./cli.md).
|
|
39
41
|
|
|
40
42
|
## Start with an agent
|
|
41
43
|
|
package/docs/limitations.md
CHANGED
|
@@ -4,6 +4,10 @@ Current constraints of the stable SDK, stated plainly so you can decide what to
|
|
|
4
4
|
|
|
5
5
|
`@toloka-platform/sdk` `0.2.0` is the current stable release on `latest`. Because it is a `0.x` release, the authoring API, CLI surface, and generated source layout can change between minor versions. Use `latest` for the current supported release, or pin `@toloka-platform/sdk@0.2.0` for reproducible installs.
|
|
6
6
|
|
|
7
|
+
## Native CLI availability
|
|
8
|
+
|
|
9
|
+
The standalone CLI supports macOS and glibc Linux on ARM64 and x64. Native Windows and musl Linux executables are not available yet. It includes its runtime, so running the CLI does not require Bun or Node.js. See [CLI installation](./cli.md#install).
|
|
10
|
+
|
|
7
11
|
## Local checks do not certify deployability
|
|
8
12
|
|
|
9
13
|
`toloka check` is the required credential-free local gate. It runs project TypeScript, automatic Task UI typechecking, Vitest, and typed node and pipeline-flow coverage. `toloka apply` reruns it before any platform write.
|
|
@@ -19,6 +23,8 @@ The typed client can list, start, and poll Remote Node Checks. `toloka check` do
|
|
|
19
23
|
|
|
20
24
|
Python code nodes have executable behavior checks but no useful static Python typecheck yet. Their generated `Inputs` and `Outputs` aliases are currently `dict[str, Any]`; adding Pyright or mypy before those aliases become field-derived `TypedDict` contracts would provide little protection.
|
|
21
25
|
|
|
26
|
+
The standalone CLI's runtime does not provide project test dependencies. Executable code-node tests need `python3` and their imported packages. Task UI tests need Playwright and its Chromium binary. See [Test pipelines locally](./testing.md#install-test-dependencies).
|
|
27
|
+
|
|
22
28
|
## Layout is not authored
|
|
23
29
|
|
|
24
30
|
Node canvas positions are not part of authored source. Existing layout is preserved across applies and the server supplies defaults for new nodes. You cannot lay out a graph from code.
|
package/docs/testing-examples.md
CHANGED
|
@@ -239,9 +239,9 @@ await task.close();
|
|
|
239
239
|
|
|
240
240
|
## Setup and execution
|
|
241
241
|
|
|
242
|
+
Install any missing test tools as described in [Test pipelines locally](./testing.md#install-test-dependencies). Then run:
|
|
243
|
+
|
|
242
244
|
```sh
|
|
243
|
-
bun add --dev vitest playwright
|
|
244
|
-
bunx playwright install chromium
|
|
245
245
|
toloka check
|
|
246
246
|
```
|
|
247
247
|
|
package/docs/testing.md
CHANGED
|
@@ -4,12 +4,20 @@ The `@toloka-platform/sdk/testing` entry point provides typed Vitest wrappers fo
|
|
|
4
4
|
|
|
5
5
|
## Install test dependencies
|
|
6
6
|
|
|
7
|
+
The standalone CLI includes its runtime, but project test runners and browser binaries remain project dependencies. Bun is the recommended runtime and package manager for SDK development. In an existing project, install its declared dependencies first:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
bun i
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
When they are not already declared, add Vitest and Playwright and install Chromium:
|
|
14
|
+
|
|
7
15
|
```sh
|
|
8
|
-
bun add
|
|
16
|
+
bun add -d vitest playwright
|
|
9
17
|
bunx playwright install chromium
|
|
10
18
|
```
|
|
11
19
|
|
|
12
|
-
|
|
20
|
+
Executable code-node tests also require `python3` on the test machine, including any third-party Python packages imported by the authored program. Browser-backed Task UI tests use the separately downloaded Playwright Chromium binary and require network access to the hosted launcher. Training-only CLI workflows require none of these project test tools or a separate JavaScript runtime. See [testing examples](./testing-examples.md) for parameterization, validation failures, hardware coverage, and cleanup patterns.
|
|
13
21
|
|
|
14
22
|
## Test a code node
|
|
15
23
|
|
package/docs/troubleshooting.md
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
The failures you will actually hit, what causes each, and the next step that works.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Platform behavior described here has been reproduced against a live platform. Installation entries describe the shipped installer and CLI. Where the right fix is platform-side rather than local, this page says so instead of suggesting a workaround that does not exist.
|
|
6
|
+
|
|
7
|
+
## Installer succeeded but the shell runs an old CLI
|
|
8
|
+
|
|
9
|
+
Run `toloka version --json`. If it reports `"channel":"global-registry"` or an unexpected version or path, follow [Updates and migration from Bun global installs](./cli.md#updates-and-migration-from-bun-global-installs). Rerun the installer for an immediate update; there is no `toloka update` command.
|
|
6
10
|
|
|
7
11
|
## plan reports a change immediately after apply
|
|
8
12
|
|
|
@@ -89,11 +93,19 @@ toloka pipeline results <runId> --failed
|
|
|
89
93
|
## Missing credentials
|
|
90
94
|
|
|
91
95
|
```
|
|
92
|
-
|
|
96
|
+
Not logged in. Run toloka login once to sign in through your browser on this machine:
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Run `toloka login`. Where a browser is not available, pipe an API key to `toloka login --api-key-stdin` or set `TOLOKA_API_KEY`. `toloka whoami` reports which platform and which login source is in effect, and exits non-zero when the platform is unreachable.
|
|
100
|
+
|
|
101
|
+
## The browser login expired
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
Your browser login for https://platform.toloka.ai has expired.
|
|
93
105
|
```
|
|
94
106
|
|
|
95
|
-
|
|
107
|
+
A browser session renews itself for up to 14 days after signing in, or 8 days without use. Run `toloka login` again.
|
|
96
108
|
|
|
97
109
|
## Authentication fails with a key you just generated
|
|
98
110
|
|
|
99
|
-
Keys are scoped to the platform that issued them. A key from one platform's console will not authenticate against a different platform. `whoami` prints the base URL it is using; confirm it matches the console where the key was generated.
|
|
111
|
+
Keys are scoped to the platform that issued them. A key from one platform's console will not authenticate against a different platform. `whoami` prints the base URL it is using; confirm it matches the console where the key was generated. The same holds for browser logins: `ENV=prestable toloka login` signs in to the testing login service, and a production login does not serve prestable.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toloka-platform/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Build, inspect, and operate Toloka pipeline projects as TypeScript source. The public API may change between minor versions before 1.0.",
|
|
6
6
|
"license": "Apache-2.0",
|
package/skills/catalog.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"testing",
|
|
12
12
|
"checks"
|
|
13
13
|
],
|
|
14
|
-
"version": "0.
|
|
15
|
-
"digest": "
|
|
14
|
+
"version": "0.3.0",
|
|
15
|
+
"digest": "c5433bf9639a469672ae24f9edcb05b091f83c3c451ed83400dba86027c4b88f",
|
|
16
16
|
"files": [
|
|
17
17
|
"SKILL.md",
|
|
18
18
|
"references/node-semantics.md",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"bug",
|
|
30
30
|
"report"
|
|
31
31
|
],
|
|
32
|
-
"version": "0.
|
|
33
|
-
"digest": "
|
|
32
|
+
"version": "0.3.0",
|
|
33
|
+
"digest": "70f0bd2c80b32f87896aeb27c363b8a2d37f40e22424f57fe1aad142e125ad67",
|
|
34
34
|
"files": [
|
|
35
35
|
"SKILL.md",
|
|
36
36
|
"references/report-template.md"
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"getting-started",
|
|
47
47
|
"agent"
|
|
48
48
|
],
|
|
49
|
-
"version": "0.
|
|
50
|
-
"digest": "
|
|
49
|
+
"version": "0.3.0",
|
|
50
|
+
"digest": "ccf148c682de4e452bb031db95d3933257899006b1766f0fdbc3d15265a63bb9",
|
|
51
51
|
"files": [
|
|
52
52
|
"SKILL.md"
|
|
53
53
|
]
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"sft",
|
|
64
64
|
"models"
|
|
65
65
|
],
|
|
66
|
-
"version": "0.
|
|
67
|
-
"digest": "
|
|
66
|
+
"version": "0.3.0",
|
|
67
|
+
"digest": "eeea5c38f65319b8d825be951094fbd00354dc5b990bdca383c1006e84c825e9",
|
|
68
68
|
"files": [
|
|
69
69
|
"SKILL.md"
|
|
70
70
|
]
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"prompt",
|
|
81
81
|
"models"
|
|
82
82
|
],
|
|
83
|
-
"version": "0.
|
|
84
|
-
"digest": "
|
|
83
|
+
"version": "0.3.0",
|
|
84
|
+
"digest": "766a4029b344469d2df97fbd5f607d4dcbbae5f1e6ab209cea65825f64cdf6f4",
|
|
85
85
|
"files": [
|
|
86
86
|
"SKILL.md"
|
|
87
87
|
]
|
|
@@ -102,12 +102,15 @@ Register code behavior with `test.code(pipeline, node, name, callback)` and exec
|
|
|
102
102
|
|
|
103
103
|
## Credentials
|
|
104
104
|
|
|
105
|
-
`toloka login`
|
|
106
|
-
`--api-key`. Precedence is flag,
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
`toloka login` signs the user in through the browser, or stores an API key when they choose that, and
|
|
106
|
+
keeps the login with owner-only permissions, so no later command needs `--api-key`. Precedence is flag,
|
|
107
|
+
then environment variable (`TOLOKA_API_KEY`, `TOLOKA_BASE_URL`), then the stored API key, then the
|
|
108
|
+
browser session. `toloka auth-status` reports what is in effect and where it came from; `toloka logout`
|
|
109
|
+
ends the browser session and removes the stored files. If credentials are missing, run `toloka login --browser`
|
|
110
|
+
yourself: it opens the sign-in page in the user's browser and waits, so ask the user to pick their
|
|
111
|
+
provider and finish signing in there. Never request a key in chat.
|
|
109
112
|
Anonymous command telemetry is on by default; set `TOLOKA_TELEMETRY=0` or `DO_NOT_TRACK=1` to disable it.
|
|
110
|
-
|
|
113
|
+
Standalone and Bun-global CLI installations check for eligible public releases at most daily; turn that off with `toloka config set auto-update false`. See [workflow and CLI recipes](references/workflow-and-cli.md) for manual updates, installer overrides, and version-pin behavior.
|
|
111
114
|
|
|
112
115
|
## Recover from expected failures
|
|
113
116
|
|
|
@@ -28,47 +28,69 @@ Treat the three layers differently:
|
|
|
28
28
|
|
|
29
29
|
For a first-time guided session, consult `https://platform.toloka.ai/agents/data-labeling.md` for orientation. Adapt the journey to the user's goal and already-complete setup while preserving dependencies, cost approval, and identity/source protection; use this reference for command details.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Bun is the recommended runtime and package manager for pipeline authoring. In an existing source root, install its declared dependencies:
|
|
32
32
|
|
|
33
33
|
```sh
|
|
34
|
-
bun
|
|
34
|
+
bun i
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
For a new pipeline project, add the SDK, TypeScript, and Vitest:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
bun add -d @toloka-platform/sdk@latest typescript vitest
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
These are project authoring and test dependencies, not prerequisites for running the standalone CLI or a Training-only workflow. Task UI scenarios additionally require Playwright and Chromium:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
bun add -d playwright
|
|
47
|
+
bunx playwright install chromium
|
|
35
48
|
```
|
|
36
49
|
|
|
37
50
|
Select or create the intended platform project before `toloka init` when the checkout should be bound immediately; follow the adoption or scratch recipe below. Running `init` without explicit or checkout-local project identity installs only the agent entry points and never adopts the machine registry's current project.
|
|
38
51
|
|
|
39
|
-
`toloka init`
|
|
52
|
+
`toloka init` warns when `@toloka-platform/sdk` is not declared in `dependencies` or `devDependencies`, then maintains one `<toloka>` Agent Bootstrap block in `AGENTS.md` and writes minimal pointers to it: a Claude skill at `.claude/skills/toloka-bootstrap/SKILL.md` when `.claude/` exists (or when no agent configuration exists at all) and an always-applied Cursor rule at `.cursor/rules/toloka-bootstrap.mdc` when `.cursor/rules/` exists. The dependency warning applies to pipeline authoring; Training commands do not require the SDK dependency. `init` writes `toloka.json` only from an explicit project flag/environment value or an existing checkout binding.
|
|
40
53
|
|
|
41
|
-
The bootstrap is small: it tells an agent to run `toloka --help`, search the bundled Skill Catalog with `toloka skill search <query>`, install the match with `toloka skill install <skill-id>`, and read `.agents/skills/<skill-id>/SKILL.md`. This skill is that installed copy. Commands warn on stderr when a generated legacy entry point is still present or the recorded bootstrap version differs from the
|
|
54
|
+
The bootstrap is small: it tells an agent to run `toloka --help`, search the bundled Skill Catalog with `toloka skill search <query>`, install the match with `toloka skill install <skill-id>`, and read `.agents/skills/<skill-id>/SKILL.md`. This skill is that installed copy. Commands warn on stderr when a generated legacy entry point is still present or the recorded bootstrap version differs from the running CLI's bundled version, independently of any project SDK dependency. Help, `init`, `report`, `project url`, `config`, and version invocations skip this checkout-dependent warning. The warning never blocks a command; after updating the standalone CLI, re-run `toloka init` to refresh the bootstrap and its pointers.
|
|
42
55
|
|
|
43
|
-
##
|
|
56
|
+
## Sign in once
|
|
44
57
|
|
|
45
58
|
```sh
|
|
46
59
|
toloka login
|
|
47
60
|
```
|
|
48
61
|
|
|
49
|
-
It
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
It asks whether to sign in through the browser or with an API key. The browser choice opens a page in
|
|
63
|
+
the browser where the user continues with Google or Microsoft (testing environments also offer email
|
|
64
|
+
and password and the testing users), hands them to the Toloka login page, waits for the sign-in to finish, verifies access by
|
|
65
|
+
listing one project, and only then saves the browser session under `~/.toloka/cli/credentials/` with
|
|
66
|
+
mode `0600`. Nothing is written when the platform does not accept the account. The session renews
|
|
67
|
+
itself for up to 14 days; after that `toloka login` is needed again. Run `toloka login --browser` yourself
|
|
68
|
+
by default: it skips the question, opens the sign-in page in the user's browser, and waits for them to
|
|
69
|
+
finish; without a terminal it fails fast when no browser can be opened. `toloka login --no-browser` prints
|
|
70
|
+
the link instead of opening a browser.
|
|
71
|
+
|
|
72
|
+
The API key choice does not expire: the key works until it is deleted in the Business Console, which
|
|
73
|
+
suits scripts, CI, and coding agents. Type it at the masked prompt, or pipe it to `toloka login --api-key-stdin`.
|
|
74
|
+
`toloka login --api-key <key>` also works but leaves the key in shell history. Most later commands read the stored login, so
|
|
75
|
+
`--api-key` becomes optional. For networked commands that do not mutate the machine project registry,
|
|
76
|
+
credential precedence is flag, then `TOLOKA_API_KEY`, then the stored API key, then the browser
|
|
77
|
+
session; CI can use an environment variable without running login. The base URL defaults to the platform.
|
|
58
78
|
|
|
59
79
|
```sh
|
|
60
80
|
toloka auth-status # or toloka whoami
|
|
61
81
|
toloka logout
|
|
62
82
|
```
|
|
63
83
|
|
|
64
|
-
`auth-status` reports which platform and
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
`auth-status` reports which platform and login are in effect and where each came from and exits
|
|
85
|
+
non-zero on failure — use it to check a setup rather than guessing. It masks the credential; `--show-token`
|
|
86
|
+
prints the full API key or the browser session's live access token, so pass it only when a command
|
|
87
|
+
genuinely needs the raw value and never paste the output into chat. Its last lines say which failure it was: `Rejected:` means the platform refused the login
|
|
88
|
+
(run `toloka login` again); `Not reachable:` means the platform did not answer, so the login was not
|
|
89
|
+
evaluated (fix network access, do not ask for a new login); `Platform error:` means the platform
|
|
90
|
+
failed (retry later). `logout` ends every stored browser session and deletes the stored files; it does not
|
|
91
|
+
revoke an API key.
|
|
70
92
|
|
|
71
|
-
|
|
93
|
+
Standalone and Bun-global `toloka` installations check the public npm registry at most once per day and install eligible releases at least 24 hours old before rerunning the command. Project-local installs, CI, and `config`, `version`, and `help` skip the check. Turn it off with `toloka config set auto-update false`. For manual standalone updates, rerun `curl -fsSL https://platform.toloka.ai/cli/install.sh | sh -s -- --native`; Bun-global updates should use `--bun` instead. Preserve the mode and put any original `TOLOKA_CLI_INSTALL_DIR`, `TOLOKA_CLI_CHANNEL`, `TOLOKA_CLI_PACKAGE`, and `TOLOKA_CLI_REGISTRY` overrides on the `sh` side of the pipe again. A package version pin does not disable automatic updates, which always use the public npm registry.
|
|
72
94
|
|
|
73
95
|
## Configure the CLI
|
|
74
96
|
|
|
@@ -90,7 +112,7 @@ The real command surface is:
|
|
|
90
112
|
toloka version [--json]
|
|
91
113
|
toloka -v
|
|
92
114
|
toloka --version
|
|
93
|
-
toloka login
|
|
115
|
+
toloka login [--browser] [--no-browser] [--api-key-stdin]
|
|
94
116
|
toloka logout
|
|
95
117
|
toloka auth-status
|
|
96
118
|
toloka config
|
|
@@ -39,10 +39,9 @@ For first-time setup details, read `https://platform.toloka.ai/agents/fine-tunin
|
|
|
39
39
|
|
|
40
40
|
### 1. Establish only the context the goal needs
|
|
41
41
|
|
|
42
|
-
When
|
|
42
|
+
When the CLI, authentication, or binding is unknown, inspect it. The runtime-inclusive standalone CLI is sufficient for Training-only work; no separate Bun or Node.js installation, SDK, TypeScript, or test packages are needed:
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
|
-
bun --version
|
|
46
45
|
toloka --version
|
|
47
46
|
toloka whoami
|
|
48
47
|
toloka project current
|
|
@@ -19,10 +19,11 @@ The workflow sequence preserves important dependencies and gates, but it is not
|
|
|
19
19
|
|
|
20
20
|
## Prepare missing prerequisites
|
|
21
21
|
|
|
22
|
-
Check the
|
|
22
|
+
Check the CLI only when its state is not already known. The installer prefers stable Bun 1.4.0 or newer matching the host architecture; otherwise it installs a standalone executable with its runtime included. Use `sh -s -- --native` or `sh -s -- --bun` on the installer pipe to force a mode. For custom packages or directories, choose the matching mode explicitly. Training-only workflows need no project SDK or test dependencies. For pipeline authoring, Bun is recommended: run `bun i` in an existing project and use `bun add -d` for missing packages.
|
|
23
|
+
|
|
24
|
+
The shell installer supports macOS and Linux on ARM64/x64. The native path requires glibc on Linux, plus `curl`, `tar`, `mktemp`, and either `shasum` or `sha256sum`; compatible Bun can be used on musl. Native Windows packages are not available.
|
|
23
25
|
|
|
24
26
|
```sh
|
|
25
|
-
bun --version
|
|
26
27
|
toloka --version
|
|
27
28
|
toloka dataset --help
|
|
28
29
|
```
|
|
@@ -39,7 +40,7 @@ Never request an API key in chat. Inspect the active identity with:
|
|
|
39
40
|
toloka whoami
|
|
40
41
|
```
|
|
41
42
|
|
|
42
|
-
If the reachable account is evidently the intended identity from the request, project, team, or established checkout, continue and report it. Ask a focused question when the identity conflicts with that context or more than one material choice remains. For a missing or rejected
|
|
43
|
+
If the reachable account is evidently the intended identity from the request, project, team, or established checkout, continue and report it. Ask a focused question when the identity conflicts with that context or more than one material choice remains. For a missing, expired, or rejected login, run `toloka login --browser` yourself: it opens the sign-in page in the user's browser and waits, so ask the user to finish signing in there, then verify `toloka whoami` again. `Rejected:` means the login was refused; `Not reachable:` means the platform did not answer and the login was not evaluated, so fix network access rather than requesting another sign-in; `Platform error:` means the platform failed, so retry later.
|
|
43
44
|
|
|
44
45
|
Pipeline work needs a source root. Reuse a suitable initialized root when one exists. In a new root, or when the Agent Bootstrap or installed skills genuinely need initialization or refresh, use:
|
|
45
46
|
|
|
@@ -40,10 +40,9 @@ For first-time setup details, read `https://platform.toloka.ai/agents/gisting.md
|
|
|
40
40
|
|
|
41
41
|
### 1. Establish only the context the goal needs
|
|
42
42
|
|
|
43
|
-
When
|
|
43
|
+
When the CLI, authentication, or binding is unknown, inspect it. The runtime-inclusive standalone CLI is sufficient for Training-only work; no separate Bun or Node.js installation, SDK, TypeScript, or test packages are needed:
|
|
44
44
|
|
|
45
45
|
```sh
|
|
46
|
-
bun --version
|
|
47
46
|
toloka --version
|
|
48
47
|
toloka whoami
|
|
49
48
|
toloka project current
|
|
@@ -26,7 +26,7 @@ The CLI exits 1 with `Potato API request failed with status 500`. The same comma
|
|
|
26
26
|
|
|
27
27
|
## Environment
|
|
28
28
|
|
|
29
|
-
-
|
|
29
|
+
- Toloka CLI: native 0.2.0, build a1b2c3d4e5f6 (`toloka version --json`); macOS 15
|
|
30
30
|
- Platform: https://platform.toloka.ai
|
|
31
31
|
|
|
32
32
|
## Redactions
|