@toloka-platform/sdk 0.19.1 → 0.20.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.
@@ -11,8 +11,8 @@
11
11
  "testing",
12
12
  "checks"
13
13
  ],
14
- "version": "0.19.1",
15
- "digest": "b68151cdf572a7a1ddbf27399044ecd4a35109771b3e1fc710a23c60b0a55462",
14
+ "version": "0.20.0",
15
+ "digest": "f7d62bb54636b2653b9ee3afc4cad5c83440ebce712cf7296df314f27be2fbf3",
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.19.1",
36
+ "version": "0.20.0",
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.1",
53
+ "version": "0.20.0",
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.1",
70
+ "version": "0.20.0",
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.1",
87
+ "version": "0.20.0",
88
88
  "digest": "be8bce8d9cf7241ccb60d2b2a9b7cc07d7755a76e8ff8ec1b0847c49efbb3469",
89
89
  "files": [
90
90
  "SKILL.md"
@@ -63,6 +63,17 @@ You choose `pricePerTask`: apply accepts any value inside the audience's range a
63
63
 
64
64
  Use `audienceType: 'synthetic'` only when the user explicitly asks for model-generated output instead of human work; otherwise the audience is human. Explain the quality and cost tradeoff when you set it up. Set the required `maxCostPerAttempt`, the per-attempt ceiling in charged US dollars across fresh input, cached input, and output together, and configure the optional `generationModelId`, `reasoningEffort`, and `llmInstruction`; do not include human pricing or audience fields. Pick the model, its reasoning effort and the budget from `toloka generation-model list`: copy `ID` into `generationModelId` (it must also be in the `generationModelId` union of the installed SDK; a newer model needs an SDK update), set `reasoningEffort` only for a model that lists reasoning efforts (apply rejects it on any other model), and keep `maxCostPerAttempt` between `MIN` and `MAX`, at or above `TYPICAL`. Use a model suited to the task when there is evidence for that choice, or omit `generationModelId` to use the default model the command names; do not guess IDs or capabilities. Synthetic generation is incompatible with `data_collection`, human QA, audience reuse, expert sourcing, and Training.
65
65
 
66
+ #### Expert lists and bans
67
+
68
+ Expert lists, expert bans, and the audience service are enabled for a team separately: `toloka expert-list` works only for teams with expert lists enabled, `toloka expert-ban-list` only for teams with expert bans enabled, and apply rejects `audienceMode: 'service'` unless the team also has the audience service enabled. Use them only when the user asks for a fixed set of experts or a ban.
69
+
70
+ - `audienceMode: 'service'` on a `generation` or `quorum` node switches it to the audience service; `'legacy'` (or omitting it on a new node) keeps audience filters and smart search. With the service, `audienceAndPricing.expertListId` takes the labeling experts from an expert list, and on `generation` `qualityAssurance.expertListId` does the same for human QA (`human_only` or `hybrid`). The audience filters then stop deciding who gets tasks; `pricePerTask`, `timeForTask`, and the per-expert cap still apply.
71
+ - Keep the settings `toloka import` wrote. Leaving a field out never detaches a list: plan shows no change for it, but apply rejects the whole graph while any node leaves out a setting the platform has, even when you only changed another node. Run `toloka import` to bring the settings into the source. To remove them, set `audienceMode: 'legacy'` and `expertListId: null` explicitly.
72
+ - Manage lists with `toloka expert-list`: `list`, `create <name>`, `add <list> --file ids.txt` (one expert ID per line), `remove`, `show <list>`, `experts <list>`, `rename`, `hide`, `unhide`. `<list>` is the `exl.` ID or the list name. Pass large ID sets with `--file`, never as thousands of arguments. Copy the `exl.` ID from `toloka expert-list list` into `expertListId`; an ID from another project is rejected.
73
+ - After adding experts, run `toloka expert-list show <list>` and report `AVAILABLE`. Availability is checked in the background, so `PENDING` drops over a few minutes. Apply rejects a node whose list has no available experts yet; wait until `AVAILABLE` is above 0, then apply. If few experts are available for the number of items, say so, and mention the per-expert cap when it is on. A hidden list keeps working in runs, but experts can't be added to or removed from it until it is unhidden.
74
+ - Don't use the same list for labeling and human QA: experts would review their own work, and validation warns about it.
75
+ - Ban experts from the project with `toloka expert-ban-list add <expertIds...> --reason <text>` (or `--file`), lift bans with `toloka expert-ban-list remove`, and see them with `toloka expert-ban-list show` and `toloka expert-ban-list experts`. Banned experts can't be invited and are removed from the work they are in, so confirm the expert IDs with the user before banning. Team-wide bans are managed in the platform UI only.
76
+
66
77
  #### Training, Exam, UI, and advanced settings
67
78
 
68
79
  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.
@@ -0,0 +1,69 @@
1
+ import type { Command } from "commander";
2
+ import { assertCli } from "../cli-error";
3
+ import { positiveInteger, resolveContext, type CommandHost } from "../context";
4
+ import {
5
+ addExpertBanListExperts,
6
+ listExpertBanListExperts,
7
+ readExpertIds,
8
+ removeExpertBanListExperts,
9
+ showExpertBanList,
10
+ } from "../experts";
11
+ import { assertProjectSelected } from "../project-context";
12
+
13
+ export const registerExpertBanListCommands = (program: Command, host: CommandHost): void => {
14
+ const { context, globals } = host;
15
+
16
+ const expertBanList = program
17
+ .command("expert-ban-list")
18
+ .description("manage the project's expert ban list: banned experts can't work on the project");
19
+
20
+ expertBanList
21
+ .command("show")
22
+ .option("--json", "print JSON", false)
23
+ .description("show how many experts are banned and in which status")
24
+ .action(async (options: { json: boolean }) => {
25
+ const { client, projectId } = await resolveContext(globals(), context);
26
+ assertProjectSelected(projectId);
27
+ await showExpertBanList(client, { projectId, json: options.json }, context.io);
28
+ });
29
+
30
+ expertBanList
31
+ .command("experts")
32
+ .option("--after <expertId>", "start after this expert id, from the previous page")
33
+ .option("--limit <count>", "experts per page, up to 1000", positiveInteger)
34
+ .option("--json", "print JSON", false)
35
+ .description("list a page of the banned experts with their status")
36
+ .action(async (options: { after?: string; limit?: number; json: boolean }) => {
37
+ const { client, projectId } = await resolveContext(globals(), context);
38
+ assertProjectSelected(projectId);
39
+ await listExpertBanListExperts(client, { projectId, ...options }, context.io);
40
+ });
41
+
42
+ expertBanList
43
+ .command("add")
44
+ .argument("[expertIds...]", "expert ids to ban")
45
+ .option("--file <path>", "file with one expert id per line")
46
+ .requiredOption("--reason <text>", "why the experts are banned, applied to each of them")
47
+ .description("ban experts: they can't be invited and are removed from the work they're in")
48
+ .action(async (expertIds: string[], options: { file?: string; reason: string }) => {
49
+ assertCli(options.reason.trim().length > 0, "Missing --reason.", {
50
+ hint: { description: "Say why the experts are banned with --reason <text>." },
51
+ });
52
+ const { client, projectId } = await resolveContext(globals(), context);
53
+ assertProjectSelected(projectId);
54
+ const ids = await readExpertIds({ expertIds, ...(options.file === undefined ? {} : { file: options.file }) });
55
+ await addExpertBanListExperts(client, { projectId, expertIds: ids, reason: options.reason }, context.io);
56
+ });
57
+
58
+ expertBanList
59
+ .command("remove")
60
+ .argument("[expertIds...]", "expert ids to unban")
61
+ .option("--file <path>", "file with one expert id per line")
62
+ .description("lift the bans of experts")
63
+ .action(async (expertIds: string[], options: { file?: string }) => {
64
+ const { client, projectId } = await resolveContext(globals(), context);
65
+ assertProjectSelected(projectId);
66
+ const ids = await readExpertIds({ expertIds, ...(options.file === undefined ? {} : { file: options.file }) });
67
+ await removeExpertBanListExperts(client, { projectId, expertIds: ids }, context.io);
68
+ });
69
+ };
@@ -0,0 +1,124 @@
1
+ import type { Command } from "commander";
2
+ import { positiveInteger, resolveContext, type CommandHost } from "../context";
3
+ import {
4
+ createExpertList,
5
+ addExpertListExperts,
6
+ listExpertListExperts,
7
+ listExpertLists,
8
+ readExpertIds,
9
+ removeExpertListExperts,
10
+ resolveExpertListId,
11
+ showExpertList,
12
+ updateExpertList,
13
+ } from "../experts";
14
+ import { assertProjectSelected } from "../project-context";
15
+
16
+ export const registerExpertListCommands = (program: Command, host: CommandHost): void => {
17
+ const { context, globals } = host;
18
+
19
+ const resolveList = async (list: string) => {
20
+ const { client, projectId } = await resolveContext(globals(), context);
21
+ assertProjectSelected(projectId);
22
+
23
+ return { client, projectId, expertListId: await resolveExpertListId(client, { projectId, list }) };
24
+ };
25
+
26
+ const expertList = program
27
+ .command("expert-list")
28
+ .description("manage the project's expert lists, which nodes with audienceMode service take experts from");
29
+
30
+ expertList
31
+ .command("list")
32
+ .option("--json", "print JSON", false)
33
+ .description("list the project's expert lists")
34
+ .action(async (options: { json: boolean }) => {
35
+ const { client, projectId } = await resolveContext(globals(), context);
36
+ assertProjectSelected(projectId);
37
+ await listExpertLists(client, { projectId, json: options.json }, context.io);
38
+ });
39
+
40
+ expertList
41
+ .command("create")
42
+ .argument("<name>", "name of the new list")
43
+ .option("--json", "print JSON", false)
44
+ .description("create an empty expert list")
45
+ .action(async (name: string, options: { json: boolean }) => {
46
+ const { client, projectId } = await resolveContext(globals(), context);
47
+ assertProjectSelected(projectId);
48
+ await createExpertList(client, { projectId, name, json: options.json }, context.io);
49
+ });
50
+
51
+ expertList
52
+ .command("show")
53
+ .argument("<list>", "list id (exl.…) or name")
54
+ .option("--json", "print JSON", false)
55
+ .description("show a list and how many of its experts are available")
56
+ .action(async (list: string, options: { json: boolean }) => {
57
+ const { client, expertListId } = await resolveList(list);
58
+ await showExpertList(client, { expertListId, json: options.json }, context.io);
59
+ });
60
+
61
+ expertList
62
+ .command("rename")
63
+ .argument("<list>", "list id (exl.…) or name")
64
+ .argument("<name>", "new name")
65
+ .description("rename a list")
66
+ .action(async (list: string, name: string) => {
67
+ const { client, expertListId } = await resolveList(list);
68
+ await updateExpertList(client, { expertListId, name }, context.io);
69
+ });
70
+
71
+ expertList
72
+ .command("hide")
73
+ .argument("<list>", "list id (exl.…) or name")
74
+ .description("hide a list: its experts can't be added or removed until it is shown again; nodes that use it keep working")
75
+ .action(async (list: string) => {
76
+ const { client, expertListId } = await resolveList(list);
77
+ await updateExpertList(client, { expertListId, hidden: true }, context.io);
78
+ });
79
+
80
+ expertList
81
+ .command("unhide")
82
+ .argument("<list>", "list id (exl.…) or name")
83
+ .description("show a hidden list again")
84
+ .action(async (list: string) => {
85
+ const { client, expertListId } = await resolveList(list);
86
+ await updateExpertList(client, { expertListId, hidden: false }, context.io);
87
+ });
88
+
89
+ expertList
90
+ .command("experts")
91
+ .argument("<list>", "list id (exl.…) or name")
92
+ .option("--after <expertId>", "start after this expert id, from the previous page")
93
+ .option("--limit <count>", "experts per page, up to 1000", positiveInteger)
94
+ .option("--json", "print JSON", false)
95
+ .description("list a page of the list's experts with their status")
96
+ .action(async (list: string, options: { after?: string; limit?: number; json: boolean }) => {
97
+ const { client, expertListId } = await resolveList(list);
98
+ await listExpertListExperts(client, { expertListId, ...options }, context.io);
99
+ });
100
+
101
+ expertList
102
+ .command("add")
103
+ .argument("<list>", "list id (exl.…) or name")
104
+ .argument("[expertIds...]", "expert ids to add")
105
+ .option("--file <path>", "file with one expert id per line")
106
+ .description("add experts to a list, from arguments or a file")
107
+ .action(async (list: string, expertIds: string[], options: { file?: string }) => {
108
+ const { client, expertListId } = await resolveList(list);
109
+ const ids = await readExpertIds({ expertIds, ...(options.file === undefined ? {} : { file: options.file }) });
110
+ await addExpertListExperts(client, { expertListId, expertIds: ids }, context.io);
111
+ });
112
+
113
+ expertList
114
+ .command("remove")
115
+ .argument("<list>", "list id (exl.…) or name")
116
+ .argument("[expertIds...]", "expert ids to remove")
117
+ .option("--file <path>", "file with one expert id per line")
118
+ .description("remove experts from a list")
119
+ .action(async (list: string, expertIds: string[], options: { file?: string }) => {
120
+ const { client, expertListId } = await resolveList(list);
121
+ const ids = await readExpertIds({ expertIds, ...(options.file === undefined ? {} : { file: options.file }) });
122
+ await removeExpertListExperts(client, { expertListId, expertIds: ids }, context.io);
123
+ });
124
+ };
@@ -0,0 +1,293 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import type { PotatoClient } from "../client";
3
+ import { PotatoApiError } from "../errors";
4
+ import { TolokaCliError } from "./cli-error";
5
+ import { formatTable, type TableIo, writeOutput } from "./table";
6
+
7
+ type ExpertListApi = Pick<PotatoClient, "expertLists">;
8
+ type ExpertBanListApi = Pick<PotatoClient, "expertBanList">;
9
+
10
+ const MAX_EXPERT_IDS_PER_REQUEST = 10_000;
11
+
12
+ const experts = (count: number) => `${count} expert${count === 1 ? "" : "s"}`;
13
+
14
+ const notAvailable = (error: unknown, feature: string): never => {
15
+ if (error instanceof PotatoApiError && error.status === 404) {
16
+ const reason = typeof error.body === "string" && error.body.length > 0 ? error.body : "Not found";
17
+ throw new TolokaCliError(`${feature}: ${reason}.`, {
18
+ cause: error,
19
+ hint: {
20
+ description:
21
+ "Check the id or name you passed and the selected project (toloka status). If both are right, this feature is not enabled for the team.",
22
+ },
23
+ });
24
+ }
25
+ throw error;
26
+ };
27
+
28
+ const explainingNotFound = async <Result>(feature: string, call: () => Promise<Result>): Promise<Result> => {
29
+ try {
30
+ return await call();
31
+ } catch (error) {
32
+ return notAvailable(error, feature);
33
+ }
34
+ };
35
+
36
+ const listExpertListsOrExplain = (client: ExpertListApi, projectId: string) =>
37
+ explainingNotFound("Expert lists", () => client.expertLists.list({ projectId }));
38
+
39
+ export const resolveExpertListId = async (
40
+ client: ExpertListApi,
41
+ input: { projectId: string; list: string },
42
+ ): Promise<string> => {
43
+ if (input.list.startsWith("exl.")) return input.list;
44
+
45
+ const [match, ...others] = (await listExpertListsOrExplain(client, input.projectId)).filter(
46
+ (expertList) => expertList.name === input.list,
47
+ );
48
+
49
+ if (match === undefined || others.length > 0) {
50
+ throw new TolokaCliError(
51
+ match === undefined
52
+ ? `No expert list named "${input.list}" in this project.`
53
+ : `Several expert lists are named "${input.list}"; pass the list id (exl.…) instead.`,
54
+ { hint: { description: "Run toloka expert-list list to see the lists and their ids." } },
55
+ );
56
+ }
57
+
58
+ return match.id;
59
+ };
60
+
61
+ export const readExpertIds = async (input: {
62
+ expertIds: readonly string[];
63
+ file?: string;
64
+ }): Promise<string[]> => {
65
+ const fromFile = input.file === undefined ? [] : (await readFile(input.file, "utf8")).split(/\r?\n/u);
66
+ const expertIds = [
67
+ ...new Set([...fromFile, ...input.expertIds].map((id) => id.trim()).filter((id) => id.length > 0)),
68
+ ];
69
+
70
+ if (expertIds.length === 0) {
71
+ throw new TolokaCliError("No expert IDs given.", {
72
+ hint: { description: "Pass expert IDs as arguments or a file with one ID per line with --file." },
73
+ });
74
+ }
75
+
76
+ if (expertIds.length > MAX_EXPERT_IDS_PER_REQUEST) {
77
+ throw new TolokaCliError(`Too many expert IDs: ${expertIds.length}, at most ${MAX_EXPERT_IDS_PER_REQUEST}.`, {
78
+ hint: { description: "Split the file and run the command once per part." },
79
+ });
80
+ }
81
+
82
+ return expertIds;
83
+ };
84
+
85
+ export const listExpertLists = async (
86
+ client: ExpertListApi,
87
+ input: { projectId: string; json: boolean },
88
+ io: TableIo,
89
+ ): Promise<void> => {
90
+ const expertLists = await listExpertListsOrExplain(client, input.projectId);
91
+
92
+ writeOutput(
93
+ io,
94
+ input.json,
95
+ expertLists,
96
+ expertLists.length === 0
97
+ ? "No expert lists in this project."
98
+ : formatTable([
99
+ ["ID", "NAME", "EXPERTS", "HIDDEN"],
100
+ ...expertLists.map((expertList) => [
101
+ expertList.id,
102
+ expertList.name,
103
+ String(expertList.expertCount),
104
+ expertList.hidden ? "yes" : "no",
105
+ ]),
106
+ ]),
107
+ );
108
+ };
109
+
110
+ export const createExpertList = async (
111
+ client: ExpertListApi,
112
+ input: { projectId: string; name: string; json: boolean },
113
+ io: TableIo,
114
+ ): Promise<void> => {
115
+ const expertList = await explainingNotFound("Expert lists", () =>
116
+ client.expertLists.create({ projectId: input.projectId, name: input.name }),
117
+ );
118
+
119
+ writeOutput(io, input.json, expertList, `Created expert list ${expertList.id} "${expertList.name}".`);
120
+ };
121
+
122
+ export const showExpertList = async (
123
+ client: ExpertListApi,
124
+ input: { expertListId: string; json: boolean },
125
+ io: TableIo,
126
+ ): Promise<void> => {
127
+ const expertList = await explainingNotFound("Expert lists", () => client.expertLists.get({ expertListId: input.expertListId }));
128
+ const { stats } = expertList;
129
+
130
+ writeOutput(
131
+ io,
132
+ input.json,
133
+ expertList,
134
+ formatTable([
135
+ ["ID", expertList.id],
136
+ ["NAME", expertList.name],
137
+ ["HIDDEN", expertList.hidden ? "yes" : "no"],
138
+ ["EXPERTS", String(expertList.expertCount)],
139
+ ["AVAILABLE", String(stats.available)],
140
+ ["PENDING", String(stats.pending)],
141
+ ["UNAVAILABLE", String(stats.unavailable)],
142
+ ["NOT FOUND", String(stats.notFound)],
143
+ ["BANNED", String(stats.banned)],
144
+ ]),
145
+ );
146
+ };
147
+
148
+ export const updateExpertList = async (
149
+ client: ExpertListApi,
150
+ input: { expertListId: string; name?: string; hidden?: boolean },
151
+ io: TableIo,
152
+ ): Promise<void> => {
153
+ const { expertListId, ...body } = input;
154
+ const expertList = await explainingNotFound("Expert lists", () => client.expertLists.update({ expertListId, ...body }));
155
+
156
+ io.stdout(`Updated expert list ${expertList.id} "${expertList.name}"${expertList.hidden ? " (hidden)" : ""}.`);
157
+ };
158
+
159
+ export const addExpertListExperts = async (
160
+ client: ExpertListApi,
161
+ input: { expertListId: string; expertIds: string[] },
162
+ io: TableIo,
163
+ ): Promise<void> => {
164
+ const result = await explainingNotFound("Expert lists", () => client.expertLists.addExperts({
165
+ expertListId: input.expertListId,
166
+ expertIds: input.expertIds,
167
+ }));
168
+
169
+ io.stdout(
170
+ `Added ${experts(result.changedCount)}; experts already in the list were skipped. ` +
171
+ "Availability is checked in the background: run toloka expert-list show to see it.",
172
+ );
173
+ };
174
+
175
+ export const removeExpertListExperts = async (
176
+ client: ExpertListApi,
177
+ input: { expertListId: string; expertIds: string[] },
178
+ io: TableIo,
179
+ ): Promise<void> => {
180
+ const result = await explainingNotFound("Expert lists", () => client.expertLists.removeExperts({
181
+ expertListId: input.expertListId,
182
+ expertIds: input.expertIds,
183
+ }));
184
+
185
+ io.stdout(`Removed ${experts(result.changedCount)}; experts not in the list were skipped.`);
186
+ };
187
+
188
+ export const listExpertListExperts = async (
189
+ client: ExpertListApi,
190
+ input: { expertListId: string; after?: string; limit?: number; json: boolean },
191
+ io: TableIo,
192
+ ): Promise<void> => {
193
+ const page = await explainingNotFound("Expert lists", () => client.expertLists.listExpertsPage({
194
+ expertListId: input.expertListId,
195
+ ...(input.after === undefined ? {} : { after: input.after }),
196
+ ...(input.limit === undefined ? {} : { limit: input.limit }),
197
+ }));
198
+
199
+ writeOutput(
200
+ io,
201
+ input.json,
202
+ page,
203
+ [
204
+ page.experts.length === 0
205
+ ? "No experts."
206
+ : formatTable([["EXPERT", "STATUS"], ...page.experts.map((expert) => [expert.expertId, expert.status])]),
207
+ ...(page.nextAfter === null ? [] : [`More experts: pass --after ${page.nextAfter}`]),
208
+ ].join("\n"),
209
+ );
210
+ };
211
+
212
+ export const showExpertBanList = async (
213
+ client: ExpertBanListApi,
214
+ input: { projectId: string; json: boolean },
215
+ io: TableIo,
216
+ ): Promise<void> => {
217
+ const banList = await explainingNotFound("Banned experts", () =>
218
+ client.expertBanList.get({ projectId: input.projectId }),
219
+ );
220
+
221
+ writeOutput(
222
+ io,
223
+ input.json,
224
+ banList,
225
+ formatTable([
226
+ ["EXPERTS", String(banList.expertCount)],
227
+ ["BANNED", String(banList.stats.banned)],
228
+ ["PENDING", String(banList.stats.pending)],
229
+ ["UNBANNING", String(banList.stats.unbanning)],
230
+ ["NOT FOUND", String(banList.stats.notFound)],
231
+ ]),
232
+ );
233
+ };
234
+
235
+ export const listExpertBanListExperts = async (
236
+ client: ExpertBanListApi,
237
+ input: { projectId: string; after?: string; limit?: number; json: boolean },
238
+ io: TableIo,
239
+ ): Promise<void> => {
240
+ const page = await explainingNotFound("Banned experts", () =>
241
+ client.expertBanList.listExpertsPage({
242
+ projectId: input.projectId,
243
+ ...(input.after === undefined ? {} : { after: input.after }),
244
+ ...(input.limit === undefined ? {} : { limit: input.limit }),
245
+ }),
246
+ );
247
+
248
+ writeOutput(
249
+ io,
250
+ input.json,
251
+ page,
252
+ [
253
+ page.experts.length === 0
254
+ ? "No banned experts."
255
+ : formatTable([
256
+ ["EXPERT", "STATUS", "REASON"],
257
+ ...page.experts.map((expert) => [expert.expertId, expert.status, expert.reason]),
258
+ ]),
259
+ ...(page.nextAfter === null ? [] : [`More experts: pass --after ${page.nextAfter}`]),
260
+ ].join("\n"),
261
+ );
262
+ };
263
+
264
+ export const addExpertBanListExperts = async (
265
+ client: ExpertBanListApi,
266
+ input: { projectId: string; expertIds: string[]; reason: string },
267
+ io: TableIo,
268
+ ): Promise<void> => {
269
+ const result = await explainingNotFound("Banned experts", () =>
270
+ client.expertBanList.addExperts({
271
+ projectId: input.projectId,
272
+ expertIds: input.expertIds,
273
+ reason: input.reason,
274
+ }),
275
+ );
276
+
277
+ io.stdout(`Banned ${experts(result.changedCount)}.`);
278
+ };
279
+
280
+ export const removeExpertBanListExperts = async (
281
+ client: ExpertBanListApi,
282
+ input: { projectId: string; expertIds: string[] },
283
+ io: TableIo,
284
+ ): Promise<void> => {
285
+ const result = await explainingNotFound("Banned experts", () =>
286
+ client.expertBanList.removeExperts({
287
+ projectId: input.projectId,
288
+ expertIds: input.expertIds,
289
+ }),
290
+ );
291
+
292
+ io.stdout(`Unbanned ${experts(result.changedCount)}; experts that were not banned were skipped.`);
293
+ };
@@ -17,6 +17,8 @@ import { registerModelCommands } from "./commands/models";
17
17
  import { registerPipelineCommands } from "./commands/pipeline";
18
18
  import { registerProjectCommands } from "./commands/project";
19
19
  import { registerReportCommand } from "./commands/report";
20
+ import { registerExpertBanListCommands } from "./commands/expert-ban-list";
21
+ import { registerExpertListCommands } from "./commands/expert-list";
20
22
  import { registerSecretCommands } from "./commands/secret";
21
23
  import { registerSkillCommands } from "./commands/skill";
22
24
  import { registerSourceCommands } from "./commands/source";
@@ -101,6 +103,8 @@ export function createProgram(context: ProgramContext): CreatedProgram {
101
103
  registerGenerationModelCommands(program, host);
102
104
  registerSourceCommands(program, host);
103
105
  registerSecretCommands(program, host);
106
+ registerExpertListCommands(program, host);
107
+ registerExpertBanListCommands(program, host);
104
108
  registerModelCommands(program, host);
105
109
  registerTrainingCommands(program, host);
106
110
  registerBatchInferenceCommands(program, host);
@@ -167,6 +167,31 @@ const projectAuthoredKeys = (authored: unknown, live: unknown): unknown => {
167
167
  const matchesAuthored = (authored: unknown, live: unknown) =>
168
168
  valueKey(authored) === valueKey(projectAuthoredKeys(authored, live));
169
169
 
170
+ const isHumanQa = (qualityAssurance: unknown): qualityAssurance is Record<string, unknown> =>
171
+ isPlainObject(qualityAssurance) &&
172
+ (qualityAssurance.qaMode === "human_only" || qualityAssurance.qaMode === "hybrid");
173
+
174
+ const withAudienceSourcingDefaults = (node: PipelineGraphV1["nodes"][number]): unknown => {
175
+ if (node.type !== "generation" && node.type !== "quorum") return node;
176
+
177
+ const audienceAndPricing: unknown = node.settings.audienceAndPricing;
178
+ const qualityAssurance: unknown = node.type === "generation" ? node.settings.qualityAssurance : undefined;
179
+
180
+ return {
181
+ ...node,
182
+ settings: {
183
+ audienceMode: "legacy",
184
+ ...node.settings,
185
+ ...(isPlainObject(audienceAndPricing) && audienceAndPricing.audienceType === "human"
186
+ ? { audienceAndPricing: { expertListId: null, ...audienceAndPricing } }
187
+ : {}),
188
+ ...(isHumanQa(qualityAssurance)
189
+ ? { qualityAssurance: { expertListId: null, ...qualityAssurance } }
190
+ : {}),
191
+ },
192
+ };
193
+ };
194
+
170
195
  const collectAsync = async <Value>(values: AsyncIterable<Value>): Promise<Value[]> => {
171
196
  const collected: Value[] = [];
172
197
  for await (const value of values) collected.push(value);
@@ -243,7 +268,11 @@ export function diffPipelineGraphs(
243
268
  id: field.id,
244
269
  }),
245
270
  ),
246
- ...diffKeyed(authoredNodes, liveNodes, matchesAuthored, (node, action) => ({
271
+ ...diffKeyed(
272
+ authoredNodes,
273
+ liveNodes,
274
+ (authored, live) => matchesAuthored(authored, withAudienceSourcingDefaults(live)),
275
+ (node, action) => ({
247
276
  kind: "node",
248
277
  action,
249
278
  label: nodeLabel(node),