@toloka-platform/sdk 0.19.1 → 0.21.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.
@@ -1,6 +1,8 @@
1
1
  import type {
2
2
  AddDatasetItems200,
3
3
  AddDatasetItemsBody,
4
+ AddExpertBanListExpertsBody,
5
+ AddExpertListExpertsBody,
4
6
  AttachPipelineDatasetBody,
5
7
  BaseModel,
6
8
  BaseModelId,
@@ -18,6 +20,7 @@ import type {
18
20
  CreateDatasetSliceBody,
19
21
  CreateDatasetUpload200,
20
22
  CreateDatasetUploadBody,
23
+ CreateExpertListBody,
21
24
  CreatePipelineCheckBody,
22
25
  CreateProjectBody,
23
26
  CreateProjectFileUpload200,
@@ -34,6 +37,10 @@ import type {
34
37
  DatasetSlice,
35
38
  EstimatePipelineCostBody,
36
39
  EstimateTrainingCostBody,
40
+ ExpertBanListDetails,
41
+ ExpertChangeResult,
42
+ ExpertList,
43
+ ExpertListDetails,
37
44
  ExportId,
38
45
  ExportJob,
39
46
  ExportPipeline200,
@@ -53,6 +60,11 @@ import type {
53
60
  ListDatasetSlices200,
54
61
  ListDatasetSlicesParams,
55
62
  ListDeliveryOrders200,
63
+ ListExpertBanListExperts200,
64
+ ListExpertBanListExpertsParams,
65
+ ListExpertListExperts200,
66
+ ListExpertListExpertsParams,
67
+ ListExpertLists200,
56
68
  ListGenerationModels200,
57
69
  ListModelVersions200,
58
70
  ListModelVersionsParams,
@@ -95,6 +107,8 @@ import type {
95
107
  ProjectId,
96
108
  ProjectSecret,
97
109
  ProjectSecretName,
110
+ RemoveExpertBanListExpertsBody,
111
+ RemoveExpertListExpertsBody,
98
112
  ReplacePipelineGraphBody,
99
113
  ReplaceTrainingConfigurationBody,
100
114
  RevokedScopedTokens,
@@ -119,6 +133,7 @@ import type {
119
133
  TrainingRunLogs,
120
134
  TrainingRunMetricHistory,
121
135
  TrainingRunMetrics,
136
+ UpdateExpertListBody,
122
137
  UpdatePipelineBody,
123
138
  UpdateProjectBody,
124
139
  UpdateTrainingMetadataBody,
@@ -828,6 +843,345 @@ export const listAudienceSpecializations = async (params?: ListAudienceSpecializ
828
843
 
829
844
 
830
845
 
846
+ export const getListExpertListsUrl = (projectId: ProjectId,) => {
847
+
848
+
849
+
850
+
851
+ return `/api/v2-beta/projects/${projectId}/expert-lists`
852
+ }
853
+
854
+ export const listExpertLists = async (projectId: ProjectId, options?: Parameters<typeof potatoFetch>[1]): Promise<ListExpertLists200> => {
855
+
856
+ return potatoFetch<ListExpertLists200>(getListExpertListsUrl(projectId),
857
+ {
858
+ ...options,
859
+ method: 'GET'
860
+
861
+
862
+ }
863
+ );}
864
+
865
+
866
+
867
+ export const getCreateExpertListUrl = (projectId: ProjectId,) => {
868
+
869
+
870
+
871
+
872
+ return `/api/v2-beta/projects/${projectId}/expert-lists`
873
+ }
874
+
875
+ export const createExpertList = async (projectId: ProjectId,
876
+ createExpertListBody: CreateExpertListBody, options?: Parameters<typeof potatoFetch>[1]): Promise<ExpertList> => {
877
+
878
+ const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {
879
+ if (!h) return {};
880
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
881
+ if (Symbol.iterator in h) {
882
+ return Object.fromEntries(
883
+ Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),
884
+ );
885
+ }
886
+ const headers: Record<string, string | readonly string[]> = {};
887
+ for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {
888
+ if (value !== undefined) headers[name] = value;
889
+ }
890
+ return headers;
891
+ };
892
+ return potatoFetch<ExpertList>(getCreateExpertListUrl(projectId),
893
+ {
894
+ ...options,
895
+ method: 'POST',
896
+ headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },
897
+ body: JSON.stringify(createExpertListBody)
898
+ }
899
+ );}
900
+
901
+
902
+
903
+ export const getGetExpertListUrl = (expertListId: string,) => {
904
+
905
+
906
+
907
+
908
+ return `/api/v2-beta/expert-lists/${expertListId}`
909
+ }
910
+
911
+ export const getExpertList = async (expertListId: string, options?: Parameters<typeof potatoFetch>[1]): Promise<ExpertListDetails> => {
912
+
913
+ return potatoFetch<ExpertListDetails>(getGetExpertListUrl(expertListId),
914
+ {
915
+ ...options,
916
+ method: 'GET'
917
+
918
+
919
+ }
920
+ );}
921
+
922
+
923
+
924
+ export const getUpdateExpertListUrl = (expertListId: string,) => {
925
+
926
+
927
+
928
+
929
+ return `/api/v2-beta/expert-lists/${expertListId}`
930
+ }
931
+
932
+ export const updateExpertList = async (expertListId: string,
933
+ updateExpertListBody: UpdateExpertListBody, options?: Parameters<typeof potatoFetch>[1]): Promise<ExpertList> => {
934
+
935
+ const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {
936
+ if (!h) return {};
937
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
938
+ if (Symbol.iterator in h) {
939
+ return Object.fromEntries(
940
+ Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),
941
+ );
942
+ }
943
+ const headers: Record<string, string | readonly string[]> = {};
944
+ for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {
945
+ if (value !== undefined) headers[name] = value;
946
+ }
947
+ return headers;
948
+ };
949
+ return potatoFetch<ExpertList>(getUpdateExpertListUrl(expertListId),
950
+ {
951
+ ...options,
952
+ method: 'PATCH',
953
+ headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },
954
+ body: JSON.stringify(updateExpertListBody)
955
+ }
956
+ );}
957
+
958
+
959
+
960
+ export const getListExpertListExpertsUrl = (expertListId: string,
961
+ params?: ListExpertListExpertsParams,) => {
962
+ const normalizedParams = new URLSearchParams();
963
+
964
+ Object.entries(params || {}).forEach(([key, value]) => {
965
+
966
+ if (value !== undefined) {
967
+ normalizedParams.append(key, value === null ? 'null' : String(value))
968
+ }
969
+ });
970
+
971
+ const stringifiedParams = normalizedParams.toString();
972
+
973
+ return stringifiedParams.length > 0 ? `/api/v2-beta/expert-lists/${expertListId}/experts?${stringifiedParams}` : `/api/v2-beta/expert-lists/${expertListId}/experts`
974
+ }
975
+
976
+ export const listExpertListExperts = async (expertListId: string,
977
+ params?: ListExpertListExpertsParams, options?: Parameters<typeof potatoFetch>[1]): Promise<ListExpertListExperts200> => {
978
+
979
+ return potatoFetch<ListExpertListExperts200>(getListExpertListExpertsUrl(expertListId,params),
980
+ {
981
+ ...options,
982
+ method: 'GET'
983
+
984
+
985
+ }
986
+ );}
987
+
988
+
989
+
990
+ export const getAddExpertListExpertsUrl = (expertListId: string,) => {
991
+
992
+
993
+
994
+
995
+ return `/api/v2-beta/expert-lists/${expertListId}/experts/add`
996
+ }
997
+
998
+ export const addExpertListExperts = async (expertListId: string,
999
+ addExpertListExpertsBody: AddExpertListExpertsBody, options?: Parameters<typeof potatoFetch>[1]): Promise<ExpertChangeResult> => {
1000
+
1001
+ const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {
1002
+ if (!h) return {};
1003
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1004
+ if (Symbol.iterator in h) {
1005
+ return Object.fromEntries(
1006
+ Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),
1007
+ );
1008
+ }
1009
+ const headers: Record<string, string | readonly string[]> = {};
1010
+ for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {
1011
+ if (value !== undefined) headers[name] = value;
1012
+ }
1013
+ return headers;
1014
+ };
1015
+ return potatoFetch<ExpertChangeResult>(getAddExpertListExpertsUrl(expertListId),
1016
+ {
1017
+ ...options,
1018
+ method: 'POST',
1019
+ headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },
1020
+ body: JSON.stringify(addExpertListExpertsBody)
1021
+ }
1022
+ );}
1023
+
1024
+
1025
+
1026
+ export const getRemoveExpertListExpertsUrl = (expertListId: string,) => {
1027
+
1028
+
1029
+
1030
+
1031
+ return `/api/v2-beta/expert-lists/${expertListId}/experts/remove`
1032
+ }
1033
+
1034
+ export const removeExpertListExperts = async (expertListId: string,
1035
+ removeExpertListExpertsBody: RemoveExpertListExpertsBody, options?: Parameters<typeof potatoFetch>[1]): Promise<ExpertChangeResult> => {
1036
+
1037
+ const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {
1038
+ if (!h) return {};
1039
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1040
+ if (Symbol.iterator in h) {
1041
+ return Object.fromEntries(
1042
+ Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),
1043
+ );
1044
+ }
1045
+ const headers: Record<string, string | readonly string[]> = {};
1046
+ for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {
1047
+ if (value !== undefined) headers[name] = value;
1048
+ }
1049
+ return headers;
1050
+ };
1051
+ return potatoFetch<ExpertChangeResult>(getRemoveExpertListExpertsUrl(expertListId),
1052
+ {
1053
+ ...options,
1054
+ method: 'POST',
1055
+ headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },
1056
+ body: JSON.stringify(removeExpertListExpertsBody)
1057
+ }
1058
+ );}
1059
+
1060
+
1061
+
1062
+ export const getGetExpertBanListUrl = (projectId: ProjectId,) => {
1063
+
1064
+
1065
+
1066
+
1067
+ return `/api/v2-beta/projects/${projectId}/expert-ban-list`
1068
+ }
1069
+
1070
+ export const getExpertBanList = async (projectId: ProjectId, options?: Parameters<typeof potatoFetch>[1]): Promise<ExpertBanListDetails> => {
1071
+
1072
+ return potatoFetch<ExpertBanListDetails>(getGetExpertBanListUrl(projectId),
1073
+ {
1074
+ ...options,
1075
+ method: 'GET'
1076
+
1077
+
1078
+ }
1079
+ );}
1080
+
1081
+
1082
+
1083
+ export const getListExpertBanListExpertsUrl = (projectId: ProjectId,
1084
+ params?: ListExpertBanListExpertsParams,) => {
1085
+ const normalizedParams = new URLSearchParams();
1086
+
1087
+ Object.entries(params || {}).forEach(([key, value]) => {
1088
+
1089
+ if (value !== undefined) {
1090
+ normalizedParams.append(key, value === null ? 'null' : String(value))
1091
+ }
1092
+ });
1093
+
1094
+ const stringifiedParams = normalizedParams.toString();
1095
+
1096
+ return stringifiedParams.length > 0 ? `/api/v2-beta/projects/${projectId}/expert-ban-list/experts?${stringifiedParams}` : `/api/v2-beta/projects/${projectId}/expert-ban-list/experts`
1097
+ }
1098
+
1099
+ export const listExpertBanListExperts = async (projectId: ProjectId,
1100
+ params?: ListExpertBanListExpertsParams, options?: Parameters<typeof potatoFetch>[1]): Promise<ListExpertBanListExperts200> => {
1101
+
1102
+ return potatoFetch<ListExpertBanListExperts200>(getListExpertBanListExpertsUrl(projectId,params),
1103
+ {
1104
+ ...options,
1105
+ method: 'GET'
1106
+
1107
+
1108
+ }
1109
+ );}
1110
+
1111
+
1112
+
1113
+ export const getAddExpertBanListExpertsUrl = (projectId: ProjectId,) => {
1114
+
1115
+
1116
+
1117
+
1118
+ return `/api/v2-beta/projects/${projectId}/expert-ban-list/experts/add`
1119
+ }
1120
+
1121
+ export const addExpertBanListExperts = async (projectId: ProjectId,
1122
+ addExpertBanListExpertsBody: AddExpertBanListExpertsBody, options?: Parameters<typeof potatoFetch>[1]): Promise<ExpertChangeResult> => {
1123
+
1124
+ const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {
1125
+ if (!h) return {};
1126
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1127
+ if (Symbol.iterator in h) {
1128
+ return Object.fromEntries(
1129
+ Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),
1130
+ );
1131
+ }
1132
+ const headers: Record<string, string | readonly string[]> = {};
1133
+ for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {
1134
+ if (value !== undefined) headers[name] = value;
1135
+ }
1136
+ return headers;
1137
+ };
1138
+ return potatoFetch<ExpertChangeResult>(getAddExpertBanListExpertsUrl(projectId),
1139
+ {
1140
+ ...options,
1141
+ method: 'POST',
1142
+ headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },
1143
+ body: JSON.stringify(addExpertBanListExpertsBody)
1144
+ }
1145
+ );}
1146
+
1147
+
1148
+
1149
+ export const getRemoveExpertBanListExpertsUrl = (projectId: ProjectId,) => {
1150
+
1151
+
1152
+
1153
+
1154
+ return `/api/v2-beta/projects/${projectId}/expert-ban-list/experts/remove`
1155
+ }
1156
+
1157
+ export const removeExpertBanListExperts = async (projectId: ProjectId,
1158
+ removeExpertBanListExpertsBody: RemoveExpertBanListExpertsBody, options?: Parameters<typeof potatoFetch>[1]): Promise<ExpertChangeResult> => {
1159
+
1160
+ const getHeaders = (h?: NonNullable<RequestInit['headers']>): Record<string, string | readonly string[]> => {
1161
+ if (!h) return {};
1162
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
1163
+ if (Symbol.iterator in h) {
1164
+ return Object.fromEntries(
1165
+ Array.from(h as Iterable<Iterable<string>>, (entry) => Array.from(entry) as [string, string]),
1166
+ );
1167
+ }
1168
+ const headers: Record<string, string | readonly string[]> = {};
1169
+ for (const [name, value] of Object.entries<string | readonly string[] | undefined>(h)) {
1170
+ if (value !== undefined) headers[name] = value;
1171
+ }
1172
+ return headers;
1173
+ };
1174
+ return potatoFetch<ExpertChangeResult>(getRemoveExpertBanListExpertsUrl(projectId),
1175
+ {
1176
+ ...options,
1177
+ method: 'POST',
1178
+ headers: { 'Content-Type': 'application/json', ...getHeaders(options?.headers) },
1179
+ body: JSON.stringify(removeExpertBanListExpertsBody)
1180
+ }
1181
+ );}
1182
+
1183
+
1184
+
831
1185
  export const getListGenerationModelsUrl = () => {
832
1186
 
833
1187
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toloka-platform/sdk",
3
- "version": "0.19.1",
3
+ "version": "0.21.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",
@@ -40,7 +40,7 @@
40
40
  "sync-task-ui-declarations": "bun ./scripts/sync-task-ui-declarations.ts",
41
41
  "test": "vitest run",
42
42
  "test:browser": "vitest run --config vitest.browser.config.ts",
43
- "typecheck": "tsc --noEmit"
43
+ "typecheck": "tsrs --noEmit"
44
44
  },
45
45
  "dependencies": {
46
46
  "@inquirer/select": "5.2.1",
@@ -59,12 +59,12 @@
59
59
  "orval": "8.40.0",
60
60
  "playwright": "1.63.0",
61
61
  "typescript": "7.1.0-beta",
62
- "vitest": "4.1.0",
62
+ "vitest": "5.0.5",
63
63
  "yaml": "2.9.0"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "playwright": ">=1.63.0 <2",
67
- "vitest": ">=4.1.0 <5"
67
+ "vitest": ">=4.1.0 <6"
68
68
  },
69
69
  "peerDependenciesMeta": {
70
70
  "playwright": {
@@ -78,6 +78,6 @@
78
78
  "bun": ">=1.4.0"
79
79
  },
80
80
  "tolokaBuild": {
81
- "commit": "8577e0d2623cf9daa2b46acb9eb0f7294503de83"
81
+ "commit": "ebb44d001f2d81bea3c678bebfa24afaee273bd8"
82
82
  }
83
83
  }
@@ -11,8 +11,8 @@
11
11
  "testing",
12
12
  "checks"
13
13
  ],
14
- "version": "0.19.1",
15
- "digest": "b68151cdf572a7a1ddbf27399044ecd4a35109771b3e1fc710a23c60b0a55462",
14
+ "version": "0.21.0",
15
+ "digest": "77d79baf90674ec502155aab57d3a80bc9e9a2f5679d0269c8bd160c8c64f9ee",
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.21.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.21.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.21.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.21.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 and expert bans are enabled for a team together, and only on top of the audience service: `toloka expert-list` and `toloka expert-ban-list` work only for teams with expert lists enabled, and apply rejects `audienceMode: 'service'` unless the team 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
+ };