@work-shape/catalyst-cli 0.8.0-rc.10 → 0.8.0-rc.11

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +307 -0
  2. package/dist/index.js +1124 -34
  3. package/package.json +5 -4
package/dist/index.js CHANGED
@@ -19,6 +19,48 @@ var SKILL_RESOURCE_MEDIA_TYPES = [
19
19
  ];
20
20
  var APP_AUDIENCES = ["self", "workspace", "instance"];
21
21
 
22
+ // ../asset-schemas/src/bedrock-profiles.ts
23
+ var BEDROCK_REGION = "eu-central-1";
24
+ var BEDROCK_ARN = /^arn:aws:bedrock:([a-z0-9-]*):(\d{12}):([a-z-]+)\/([a-zA-Z0-9.:_-]+)$/u;
25
+ var APPLICATION_INFERENCE_PROFILE = "application-inference-profile";
26
+ var AWS_ACCOUNT_ID = /^\d{12}$/u;
27
+ function bedrockProfileRefusal(model, accountId) {
28
+ const arn = BEDROCK_ARN.exec(model);
29
+ if (!arn) {
30
+ return "a model id or a shared inference profile such as 'eu.anthropic.\u2026' is not attributed to this consumer";
31
+ }
32
+ if (arn[3] !== APPLICATION_INFERENCE_PROFILE) {
33
+ return "the ARN names a foundation model or a shared inference profile, which is not attributed to this consumer";
34
+ }
35
+ if (arn[1] !== BEDROCK_REGION) {
36
+ return `the profile is in another region, and calls go to ${BEDROCK_REGION} only`;
37
+ }
38
+ if (arn[2] !== accountId) {
39
+ return "the profile belongs to another AWS account than the provider's 'accountId'";
40
+ }
41
+ return void 0;
42
+ }
43
+
44
+ // ../asset-schemas/src/config-merge.ts
45
+ function mergeConfigObjects(base, overrides) {
46
+ const result = { ...base };
47
+ for (const [key2, override] of Object.entries(overrides)) {
48
+ if (key2 === "__proto__") {
49
+ continue;
50
+ }
51
+ const baseValue = result[key2];
52
+ result[key2] = isPlainConfigObject(baseValue) && isPlainConfigObject(override) ? mergeConfigObjects(baseValue, override) : override;
53
+ }
54
+ return result;
55
+ }
56
+ function isPlainConfigObject(value) {
57
+ if (typeof value !== "object" || value === null) {
58
+ return false;
59
+ }
60
+ const prototype = Object.getPrototypeOf(value);
61
+ return prototype === Object.prototype || prototype === null;
62
+ }
63
+
22
64
  // ../asset-schemas/src/contract-values/agent.ts
23
65
  var AGENT_ACTIONS = [
24
66
  "agent.read",
@@ -397,6 +439,8 @@ var TOOL_GROUPS = [
397
439
  ];
398
440
  var INFRASTRUCTURE_SECRET_STATES = ["set", "missing"];
399
441
  var INFRASTRUCTURE_WITHHELD_FIELDS = ["endpointHost", "bucket"];
442
+ var OPENAI_COMPATIBLE_APIS = ["chat_completions", "responses"];
443
+ var MODEL_PROVIDER_AUTH_MODES = ["bearer", "api-key"];
400
444
  var CONVERSATION_VISIBILITIES = ["workspace", "private"];
401
445
  var WEB_SOURCE_PROVIDERS = [
402
446
  "openai-native",
@@ -657,6 +701,7 @@ var MESSAGE_FINISH_STATUSES = [
657
701
  "completed",
658
702
  "cancelled"
659
703
  ];
704
+ var MODEL_FALLBACK_REASONS = ["rate_limit", "unavailable"];
660
705
  var ARTIFACT_PREVIEW_IMAGE_MIME_TYPES = [
661
706
  "image/png",
662
707
  "image/jpeg",
@@ -874,6 +919,7 @@ var agentConfigSchema = z.object({
874
919
  modelBindingId: z.string().min(1).optional(),
875
920
  reasoningEffort: z.enum(REASONING_EFFORTS).optional(),
876
921
  fastMode: z.boolean().optional(),
922
+ useModelFallback: z.boolean().optional(),
877
923
  userSelectableModelBindingIds: z.array(z.string().min(1)).optional(),
878
924
  modelReasoningEfforts: z.record(z.string().min(1), z.enum(REASONING_EFFORTS)).optional(),
879
925
  maxSteps: z.number().int().positive().optional(),
@@ -913,6 +959,31 @@ var workflowConfigSchema = z.strictObject({
913
959
  files: z.array(z.strictObject({ path: z.string(), content: z.string() })).optional()
914
960
  });
915
961
 
962
+ // ../asset-schemas/src/secret-names.ts
963
+ var SECRET_NAME_MAX_LENGTH = 64;
964
+ var SECRET_NAME_SINGLE_WORD_MAX_LENGTH = 12;
965
+ var SECRET_NAME_WORD = /^[A-Z0-9]{1,16}$/u;
966
+ var SECRET_NAME_WORD_MAX_DIGITS = 2;
967
+ var CREDENTIAL_SHAPE = /^(?:(?:AKIA|ASIA)[A-Z0-9]{16}$|GH[OPRSU]_[A-Z0-9]{20,}|AIZA[A-Z0-9_-]{30,}|XOX[A-Z]-|EYJ[A-Z0-9_-]{16,})/iu;
968
+ var SECRET_NAME_EXPECTATION = "expected the name of an environment variable such as MODEL_API_KEY (upper-case words joined by underscores, at most 64 characters); the value given does not read as one and looks like a credential value";
969
+ function isSecretName(value) {
970
+ if (value.length > SECRET_NAME_MAX_LENGTH || CREDENTIAL_SHAPE.test(value)) {
971
+ return false;
972
+ }
973
+ const words = value.split("_");
974
+ if (words.length === 1 && value.length > SECRET_NAME_SINGLE_WORD_MAX_LENGTH) {
975
+ return false;
976
+ }
977
+ return /^[A-Z]/u.test(value) && words.every(isSecretNameWord);
978
+ }
979
+ function isSecretNameWord(word2) {
980
+ if (!SECRET_NAME_WORD.test(word2)) {
981
+ return false;
982
+ }
983
+ const digits = word2.replace(/[A-Z]/gu, "").length;
984
+ return digits === word2.length ? word2.length <= 4 : digits <= SECRET_NAME_WORD_MAX_DIGITS;
985
+ }
986
+
916
987
  // ../asset-schemas/src/skill-markdown.ts
917
988
  import yaml from "js-yaml";
918
989
 
@@ -941,13 +1012,13 @@ function checkStorableTexts(value, maxValues) {
941
1012
  return "storable";
942
1013
  }
943
1014
  function readYamlData(text2, file, options = {}) {
944
- const fail = (code, message, line, column) => ({
1015
+ const fail = (code, message, line, column2) => ({
945
1016
  ok: false,
946
1017
  issue: {
947
1018
  code,
948
1019
  message,
949
1020
  ...line === void 0 ? {} : { line },
950
- ...column === void 0 ? {} : { column }
1021
+ ...column2 === void 0 ? {} : { column: column2 }
951
1022
  }
952
1023
  });
953
1024
  let value;
@@ -958,8 +1029,8 @@ function readYamlData(text2, file, options = {}) {
958
1029
  const markLine = error.mark?.line;
959
1030
  const line = markLine === void 0 ? void 0 : markLine + 1;
960
1031
  const markColumn = error.mark?.column;
961
- const column = markColumn === void 0 ? void 0 : markColumn + 1;
962
- return error.reason.startsWith("nesting exceeded") ? fail("yaml_too_deep", `'${file}' ${error.reason}.`, line) : fail("yaml_invalid", `'${file}' is not valid YAML: ${error.reason}.`, line, column);
1032
+ const column2 = markColumn === void 0 ? void 0 : markColumn + 1;
1033
+ return error.reason.startsWith("nesting exceeded") ? fail("yaml_too_deep", `'${file}' ${error.reason}.`, line) : fail("yaml_invalid", `'${file}' is not valid YAML: ${error.reason}.`, line, column2);
963
1034
  }
964
1035
  throw error;
965
1036
  }
@@ -1069,10 +1140,10 @@ function loadFrontmatter(text2, skillFile) {
1069
1140
  throw new SkillMarkdownError(`Skill file '${skillFile}' frontmatter: ${issue.message}`);
1070
1141
  }
1071
1142
  const line = issue.line + 1;
1072
- const { column } = issue;
1143
+ const { column: column2 } = issue;
1073
1144
  throw new SkillMarkdownError(
1074
- `Skill file '${skillFile}' frontmatter is not valid YAML at line ${line}, column ${column}: ${issue.message} A value that holds a colon and a space, as a description often does, is written in quotes: description: "Use this when: the user asks"`,
1075
- { issues: [{ message: issue.message, path: [], line, column }] }
1145
+ `Skill file '${skillFile}' frontmatter is not valid YAML at line ${line}, column ${column2}: ${issue.message} A value that holds a colon and a space, as a description often does, is written in quotes: description: "Use this when: the user asks"`,
1146
+ { issues: [{ message: issue.message, path: [], line, column: column2 }] }
1076
1147
  );
1077
1148
  }
1078
1149
  function deriveSkillTitle(name2, content) {
@@ -2396,7 +2467,7 @@ import { z as z58 } from "zod";
2396
2467
  // ../api-contract/package.json
2397
2468
  var package_default = {
2398
2469
  name: "@work-shape/catalyst-api-contract",
2399
- version: "0.8.0-rc.10",
2470
+ version: "0.8.0-rc.11",
2400
2471
  license: "MIT",
2401
2472
  repository: {
2402
2473
  type: "git",
@@ -3077,7 +3148,12 @@ var apiUserSchema = z21.object({
3077
3148
  principal: authPrincipalSchema.optional(),
3078
3149
  subjectUserId: z21.string().optional(),
3079
3150
  delegatedActor: delegatedActorSchema.optional(),
3080
- scopes: z21.array(authScopeSchema).optional()
3151
+ scopes: z21.array(authScopeSchema).optional(),
3152
+ /**
3153
+ * Two-factor sign-in of a person signed in with a password (TWO-FACTOR-1): whether the instance
3154
+ * requires it and whether the person has set it up. Left out for every other way in.
3155
+ */
3156
+ twoFactor: z21.object({ required: z21.boolean(), enrolled: z21.boolean() }).optional()
3081
3157
  });
3082
3158
  var issueSessionTokenRequestSchema = z21.object({
3083
3159
  externalUserId: z21.string().min(1),
@@ -3125,7 +3201,9 @@ var administeredUserSchema = z21.object({
3125
3201
  createdAt: timestampSchema,
3126
3202
  updatedAt: timestampSchema,
3127
3203
  lastAuthenticatedAt: timestampSchema.optional(),
3128
- identities: z21.array(administeredUserIdentitySchema)
3204
+ identities: z21.array(administeredUserIdentitySchema),
3205
+ /** Whether the user's password sign-in has a second factor. Left out without a password sign-in. */
3206
+ twoFactorEnabled: z21.boolean().optional()
3129
3207
  });
3130
3208
  var administeredUserPasswordSignInRequestSchema = z21.object({
3131
3209
  password: z21.string().min(8)
@@ -3179,6 +3257,10 @@ var resetAdministeredUserPasswordRequestSchema = z21.object({
3179
3257
  var resetAdministeredUserPasswordResponseSchema = z21.object({
3180
3258
  ok: z21.literal(true)
3181
3259
  });
3260
+ var resetAdministeredUserTwoFactorResponseSchema = z21.object({
3261
+ ok: z21.literal(true),
3262
+ hadFactor: z21.boolean()
3263
+ });
3182
3264
  var requestPasswordResetRequestSchema = z21.object({
3183
3265
  email: z21.string().email()
3184
3266
  });
@@ -3566,7 +3648,9 @@ var configAssetReferencesSchema = z22.object({
3566
3648
  id: z22.string(),
3567
3649
  model: z22.string(),
3568
3650
  /** The name people read, when release config gives one. */
3569
- label: z22.string().optional()
3651
+ label: z22.string().optional(),
3652
+ /** The binding that answers when this one is overloaded or down, where it names one. */
3653
+ fallback: z22.string().optional()
3570
3654
  })
3571
3655
  ),
3572
3656
  fastModeModelBindingIds: z22.array(z22.string()),
@@ -4528,6 +4612,16 @@ var storedModelContextSnapshotSchema = z27.object({
4528
4612
  compactThresholdTokens: z27.number(),
4529
4613
  compacted: z27.boolean()
4530
4614
  });
4615
+ var storedModelFallbackBindingSchema = z27.object({
4616
+ bindingId: z27.string(),
4617
+ model: z27.string(),
4618
+ label: z27.string().optional()
4619
+ });
4620
+ var storedModelFallbackSchema = z27.object({
4621
+ from: storedModelFallbackBindingSchema,
4622
+ to: storedModelFallbackBindingSchema,
4623
+ reason: z27.enum(MODEL_FALLBACK_REASONS)
4624
+ });
4531
4625
  var storedToolCallSchema = z27.object({
4532
4626
  toolCallId: z27.string(),
4533
4627
  toolName: z27.string(),
@@ -4598,7 +4692,9 @@ var assistantFinalMessageMetadataSchema = z27.object({
4598
4692
  sources: z27.array(webSourceSchema).optional(),
4599
4693
  knowledgeSources: z27.array(knowledgeCitationSourceSchema).optional(),
4600
4694
  citations: z27.array(messageCitationSchema).optional(),
4601
- modelContext: storedModelContextSnapshotSchema.optional()
4695
+ modelContext: storedModelContextSnapshotSchema.optional(),
4696
+ /** The run switched to its binding's fallback, which wrote this answer. */
4697
+ modelFallback: storedModelFallbackSchema.optional()
4602
4698
  });
4603
4699
  var toolResultMessageMetadataSchema = z27.object({
4604
4700
  version: messageMetadataVersionSchema,
@@ -7383,6 +7479,20 @@ var connectionTestResultSchema = z37.object({
7383
7479
  status: z37.enum(CONNECTOR_TEST_STATUSES),
7384
7480
  testedAt: timestampSchema
7385
7481
  });
7482
+ var sourceFolderSchema = z37.object({
7483
+ id: z37.string().min(1).max(500),
7484
+ name: z37.string().min(1).max(1e3)
7485
+ });
7486
+ var connectionSourceFoldersQuerySchema = z37.object({
7487
+ parent: z37.string().min(1).max(500).optional(),
7488
+ pageToken: z37.string().min(1).max(4e3).optional()
7489
+ });
7490
+ var connectionSourceFoldersSchema = z37.object({
7491
+ /** The folder listed, with its path from the top; `/` for the top. */
7492
+ folder: sourceFolderSchema.extend({ path: z37.string().min(1).max(4e3) }),
7493
+ folders: z37.array(sourceFolderSchema),
7494
+ nextPageToken: z37.string().min(1).max(4e3).optional()
7495
+ });
7386
7496
  var connectionToolSchema = z37.object({
7387
7497
  toolName: z37.string(),
7388
7498
  operation: z37.string(),
@@ -7758,6 +7868,21 @@ var connectionOperations = {
7758
7868
  errors: ["NOT_FOUND", "CONFLICT"],
7759
7869
  rateClass: "write"
7760
7870
  }),
7871
+ "connections.source_folders": defineRegisteredOperation({
7872
+ id: "connections.source_folders",
7873
+ method: "GET",
7874
+ path: "/api/v1/connections/:name/source-folders",
7875
+ summary: "List the folders inside one folder of a document source, to choose a Knowledge Base's folders",
7876
+ tag: "Connections",
7877
+ auth: "principal",
7878
+ scope: "config_assets:read",
7879
+ requires: [],
7880
+ effect: "reading",
7881
+ query: connectionSourceFoldersQuerySchema,
7882
+ response: json(connectionSourceFoldersSchema),
7883
+ errors: ["NOT_FOUND", "CONFLICT", "TIMEOUT"],
7884
+ rateClass: "read"
7885
+ }),
7761
7886
  // A path of its own: `agent-tools` would be a valid Connection name under `/connections/`.
7762
7887
  "connections.connector_types": defineRegisteredOperation({
7763
7888
  id: "connections.connector_types",
@@ -10871,6 +10996,20 @@ var userOperations = {
10871
10996
  errors: ["NOT_FOUND"],
10872
10997
  rateClass: "write"
10873
10998
  }),
10999
+ "users.two_factor.reset": defineRegisteredOperation({
11000
+ id: "users.two_factor.reset",
11001
+ method: "POST",
11002
+ path: "/api/v1/instance/users/:userId/two-factor/reset",
11003
+ summary: "Reset a user's two-factor sign-in: delete their second factor and trusted browsers and end their sessions. Needs the right `users.manage`. Only a superadmin resets a superadmin; nobody resets their own.",
11004
+ tag: "Users",
11005
+ auth: "user",
11006
+ scope: "user_admin:write",
11007
+ requires: [],
11008
+ effect: "changing",
11009
+ response: json(resetAdministeredUserTwoFactorResponseSchema),
11010
+ errors: ["NOT_FOUND"],
11011
+ rateClass: "write"
11012
+ }),
10874
11013
  "users.invitation.send": defineRegisteredOperation({
10875
11014
  id: "users.invitation.send",
10876
11015
  method: "POST",
@@ -11584,8 +11723,8 @@ async function* readServerSentEvents(body) {
11584
11723
  buffer += done ? decoder.decode() : decoder.decode(value, { stream: true });
11585
11724
  const blocks = buffer.replaceAll("\r\n", "\n").split("\n\n");
11586
11725
  buffer = done ? "" : blocks.pop() ?? "";
11587
- for (const block of blocks) {
11588
- const data = readEventData(block);
11726
+ for (const block2 of blocks) {
11727
+ const data = readEventData(block2);
11589
11728
  if (data !== void 0) {
11590
11729
  yield data;
11591
11730
  }
@@ -11596,8 +11735,8 @@ async function* readServerSentEvents(body) {
11596
11735
  reader.releaseLock();
11597
11736
  }
11598
11737
  }
11599
- function readEventData(block) {
11600
- const data = block.split("\n").filter((line) => line.startsWith("data:")).map((line) => line.slice("data:".length).replace(/^ /u, "")).join("\n");
11738
+ function readEventData(block2) {
11739
+ const data = block2.split("\n").filter((line) => line.startsWith("data:")).map((line) => line.slice("data:".length).replace(/^ /u, "")).join("\n");
11601
11740
  return data === "" ? void 0 : data;
11602
11741
  }
11603
11742
 
@@ -13880,8 +14019,8 @@ function detailLines(details) {
13880
14019
  function issueLocation(issue) {
13881
14020
  if (typeof issue.file === "string" && issue.file !== "") {
13882
14021
  const line = typeof issue.line === "number" ? `:${issue.line}` : "";
13883
- const column = line && typeof issue.column === "number" ? `:${issue.column}` : "";
13884
- return `${issue.file}${line}${column}: `;
14022
+ const column2 = line && typeof issue.column === "number" ? `:${issue.column}` : "";
14023
+ return `${issue.file}${line}${column2}: `;
13885
14024
  }
13886
14025
  return Array.isArray(issue.path) && issue.path.length > 0 ? `${issue.path.join(".")}: ` : "";
13887
14026
  }
@@ -13893,11 +14032,11 @@ function list(values) {
13893
14032
  }
13894
14033
  function table(head, rows) {
13895
14034
  const widths = head.map(
13896
- (title, column) => Math.max(title.length, ...rows.map((row) => row[column]?.length ?? 0))
14035
+ (title, column2) => Math.max(title.length, ...rows.map((row) => row[column2]?.length ?? 0))
13897
14036
  );
13898
14037
  return [head, ...rows].map(
13899
14038
  (row) => row.map(
13900
- (cell, column) => column === row.length - 1 ? cell : cell.padEnd(widths[column] ?? 0)
14039
+ (cell, column2) => column2 === row.length - 1 ? cell : cell.padEnd(widths[column2] ?? 0)
13901
14040
  ).join(" ")
13902
14041
  ).join("\n");
13903
14042
  }
@@ -17805,7 +17944,7 @@ async function connectConnection(api, name2, options) {
17805
17944
  ].join("\n")
17806
17945
  );
17807
17946
  if (options.openBrowser) (options.openUrl ?? openProviderPage)(start.authorizationUrl);
17808
- const sleep = options.sleep ?? ((milliseconds) => new Promise((resolve14) => setTimeout(resolve14, milliseconds)));
17947
+ const sleep = options.sleep ?? ((milliseconds) => new Promise((resolve15) => setTimeout(resolve15, milliseconds)));
17809
17948
  const until = Date.parse(start.expiresAt);
17810
17949
  let readsSinceEnded = 0;
17811
17950
  for (; ; ) {
@@ -17868,7 +18007,7 @@ async function readSecret(input, prompt) {
17868
18007
  emitKeypressEvents(input);
17869
18008
  setRawMode(true);
17870
18009
  try {
17871
- return await new Promise((resolve14, reject) => {
18010
+ return await new Promise((resolve15, reject) => {
17872
18011
  let value = "";
17873
18012
  const cleanup = () => {
17874
18013
  input.removeListener("keypress", keypress);
@@ -17887,7 +18026,7 @@ async function readSecret(input, prompt) {
17887
18026
  if (key2.ctrl && (key2.name === "c" || key2.name === "d")) return ended2();
17888
18027
  if (key2.name === "return" || key2.name === "enter") {
17889
18028
  cleanup();
17890
- resolve14(value);
18029
+ resolve15(value);
17891
18030
  } else if (key2.name === "backspace") {
17892
18031
  value = [...value].slice(0, -1).join("");
17893
18032
  } else if (!key2.ctrl && text2 && !text2.includes("\x1B")) {
@@ -18712,10 +18851,960 @@ var knowledgeGroup = {
18712
18851
  run: runKnowledgeCommand
18713
18852
  };
18714
18853
 
18715
- // src/named-commands.ts
18716
- import { readFile as readFile12 } from "fs/promises";
18717
- import { resolve as resolve13 } from "path";
18854
+ // src/model-commands.ts
18718
18855
  import { parseArgs as parseArgs9 } from "util";
18856
+
18857
+ // src/model-provider-kinds.ts
18858
+ var MODEL_PROVIDER_KINDS = ["azure", "vertex", "bedrock", "openai-compatible"];
18859
+ var ADDED_PROVIDER_REGION = "eu";
18860
+ var httpsUrl = (what) => (value) => {
18861
+ let url;
18862
+ try {
18863
+ url = new URL(value);
18864
+ } catch {
18865
+ return `${what} must be an https:// address.`;
18866
+ }
18867
+ if (url.protocol !== "https:") return `${what} must be an https:// address.`;
18868
+ if (url.username || url.password || url.search || url.hash)
18869
+ return `${what} must carry no credentials, query or fragment.`;
18870
+ return void 0;
18871
+ };
18872
+ var word = (what) => (value) => /^\S+$/u.test(value) ? void 0 : `${what} must be one word without spaces.`;
18873
+ var oneOf = (what, allowed) => (value) => allowed.includes(value) ? void 0 : `${what} must be one of ${allowed.join(", ")}.`;
18874
+ function azureBaseUrl(endpoint) {
18875
+ const url = new URL(endpoint);
18876
+ const path = url.pathname.replace(/\/+$/u, "");
18877
+ return `${url.origin}${path.endsWith("/openai/v1") ? path : `${path}/openai/v1`}`;
18878
+ }
18879
+ var PROVIDER_KINDS = {
18880
+ azure: {
18881
+ provider: "openai-compatible",
18882
+ summary: "Azure OpenAI: a deployment of an Azure OpenAI resource in an EU region",
18883
+ defaultId: "azure-eu",
18884
+ defaultSecret: "AZURE_OPENAI_API_KEY",
18885
+ secretSuffix: "API_KEY",
18886
+ secretHolds: "a key of the Azure OpenAI resource",
18887
+ vendor: "openai",
18888
+ agentSelectable: true,
18889
+ pricesAboveZero: false,
18890
+ fields: [
18891
+ {
18892
+ flag: "endpoint",
18893
+ question: "Endpoint of the Azure OpenAI resource (https://<resource>.openai.azure.com)",
18894
+ required: true,
18895
+ refusal: httpsUrl("--endpoint")
18896
+ },
18897
+ {
18898
+ flag: "model",
18899
+ question: "Name of the deployment on that resource",
18900
+ required: true,
18901
+ refusal: word("--model")
18902
+ },
18903
+ {
18904
+ flag: "api",
18905
+ question: "API of the deployment (responses or chat_completions)",
18906
+ required: false,
18907
+ refusal: oneOf("--api", OPENAI_COMPATIBLE_APIS)
18908
+ }
18909
+ ],
18910
+ entry: (values) => ({
18911
+ provider: "openai-compatible",
18912
+ region: ADDED_PROVIDER_REGION,
18913
+ api: values.api ?? "responses",
18914
+ model: values.model,
18915
+ baseUrl: azureBaseUrl(required2(values, "endpoint")),
18916
+ authMode: "api-key"
18917
+ }),
18918
+ checkShows: "The check listed the models of the resource with the key. It does not call the deployment."
18919
+ },
18920
+ vertex: {
18921
+ provider: "google-vertex",
18922
+ summary: "Gemini on Vertex AI over Google's EU endpoint, for the product's own calls",
18923
+ defaultId: "vertex-eu",
18924
+ defaultSecret: "GOOGLE_VERTEX_CREDENTIALS",
18925
+ secretSuffix: "CREDENTIALS",
18926
+ secretHolds: "the JSON key of a service account with the role Vertex AI User (with the environment provider, mount the file and set <NAME>_FILE to its path)",
18927
+ vendor: "google",
18928
+ // The adapter carries no tool calls, which every agent run needs.
18929
+ agentSelectable: false,
18930
+ pricesAboveZero: false,
18931
+ fields: [
18932
+ {
18933
+ flag: "project",
18934
+ question: "Google Cloud project id",
18935
+ required: true,
18936
+ refusal: (value) => /^[a-z][a-z0-9-]{4,28}[a-z0-9]$/u.test(value) ? void 0 : "--project must be a Google Cloud project id: 6 to 30 lower-case letters, digits and hyphens."
18937
+ },
18938
+ {
18939
+ flag: "model",
18940
+ question: "Gemini model, such as gemini-3.1-flash-lite",
18941
+ required: true,
18942
+ refusal: word("--model")
18943
+ }
18944
+ ],
18945
+ entry: (values) => ({
18946
+ provider: "google-vertex",
18947
+ region: ADDED_PROVIDER_REGION,
18948
+ model: values.model,
18949
+ projectId: values.project
18950
+ }),
18951
+ checkShows: "The check asked Google for a token with the key: the key is taken. It does not show that the account may call the model."
18952
+ },
18953
+ bedrock: {
18954
+ provider: "aws-bedrock",
18955
+ summary: `Claude on Amazon Bedrock in ${BEDROCK_REGION}, through an application inference profile`,
18956
+ defaultId: "bedrock-eu",
18957
+ defaultSecret: "AWS_BEARER_TOKEN_BEDROCK",
18958
+ secretSuffix: "BEARER_TOKEN",
18959
+ secretHolds: "a Bedrock API key",
18960
+ vendor: "anthropic",
18961
+ agentSelectable: true,
18962
+ pricesAboveZero: true,
18963
+ fields: [
18964
+ {
18965
+ flag: "model",
18966
+ question: `ARN of the application inference profile in ${BEDROCK_REGION}`,
18967
+ required: true,
18968
+ refusal: (value, values) => {
18969
+ const account = values.account ?? accountOfProfile(value);
18970
+ const refusal = bedrockProfileRefusal(value, account ?? "");
18971
+ return refusal === void 0 ? void 0 : `--model must be the ARN of an application inference profile in ${BEDROCK_REGION}: ${refusal}.`;
18972
+ }
18973
+ },
18974
+ {
18975
+ flag: "account",
18976
+ question: "AWS account id of the profile (12 digits)",
18977
+ required: false,
18978
+ refusal: (value) => AWS_ACCOUNT_ID.test(value) ? void 0 : "--account must be the 12 digits of an AWS account id."
18979
+ },
18980
+ {
18981
+ flag: "label",
18982
+ question: "Name people read for the model, such as Claude Sonnet 4.6",
18983
+ required: true
18984
+ }
18985
+ ],
18986
+ entry: (values) => ({
18987
+ provider: "aws-bedrock",
18988
+ region: ADDED_PROVIDER_REGION,
18989
+ accountId: values.account ?? accountOfProfile(required2(values, "model")),
18990
+ model: values.model
18991
+ }),
18992
+ checkShows: "The check sent the key with a request Bedrock refuses as invalid: the key is taken. It does not show that the key may call the profile."
18993
+ },
18994
+ "openai-compatible": {
18995
+ provider: "openai-compatible",
18996
+ summary: "Any endpoint that speaks the OpenAI API, hosted in an EU region",
18997
+ secretSuffix: "API_KEY",
18998
+ secretHolds: "the API key of the endpoint",
18999
+ agentSelectable: true,
19000
+ pricesAboveZero: false,
19001
+ fields: [
19002
+ {
19003
+ flag: "base-url",
19004
+ question: "Base address of the API (https://<host>/v1)",
19005
+ required: true,
19006
+ refusal: httpsUrl("--base-url")
19007
+ },
19008
+ { flag: "model", question: "Model name", required: true, refusal: word("--model") },
19009
+ {
19010
+ flag: "api",
19011
+ question: "API (responses or chat_completions)",
19012
+ required: false,
19013
+ refusal: oneOf("--api", OPENAI_COMPATIBLE_APIS)
19014
+ },
19015
+ {
19016
+ flag: "auth",
19017
+ question: "How the key is sent (bearer or api-key)",
19018
+ required: false,
19019
+ refusal: oneOf("--auth", MODEL_PROVIDER_AUTH_MODES)
19020
+ }
19021
+ ],
19022
+ entry: (values) => ({
19023
+ provider: "openai-compatible",
19024
+ region: ADDED_PROVIDER_REGION,
19025
+ ...values.api === void 0 ? {} : { api: values.api },
19026
+ model: values.model,
19027
+ baseUrl: required2(values, "base-url").replace(/\/+$/u, ""),
19028
+ ...values.auth === void 0 ? {} : { authMode: values.auth }
19029
+ }),
19030
+ checkShows: "The check listed the models of the endpoint with the key. It does not call the model."
19031
+ }
19032
+ };
19033
+ function required2(values, flag) {
19034
+ const value = values[flag];
19035
+ if (value === void 0) throw new Error(`--${flag} is required.`);
19036
+ return value;
19037
+ }
19038
+ function accountOfProfile(arn) {
19039
+ const account = arn.split(":")[4];
19040
+ return account !== void 0 && AWS_ACCOUNT_ID.test(account) ? account : void 0;
19041
+ }
19042
+ var COMMON_FIELDS = [
19043
+ {
19044
+ flag: "input-price",
19045
+ question: "Price of a million uncached input tokens",
19046
+ required: true
19047
+ },
19048
+ {
19049
+ flag: "cached-input-price",
19050
+ question: "Price of a million cached input tokens",
19051
+ required: true
19052
+ },
19053
+ { flag: "output-price", question: "Price of a million output tokens", required: true }
19054
+ ];
19055
+ function idRefusal(flag, value) {
19056
+ return /^[a-z][a-z0-9-]{0,47}$/u.test(value) ? void 0 : `--${flag} must be lower-case letters, digits and hyphens, starting with a letter, at most 48 characters.`;
19057
+ }
19058
+ function secretNameRefusal(value) {
19059
+ return isSecretName(value) ? void 0 : `--secret is refused: ${SECRET_NAME_EXPECTATION}.`;
19060
+ }
19061
+ function priceRefusal(flag, value, aboveZero) {
19062
+ const price = Number(value);
19063
+ if (value.trim() === "" || !Number.isFinite(price) || price < 0)
19064
+ return `--${flag} must be a number of at least zero.`;
19065
+ if (aboveZero && price === 0)
19066
+ return `--${flag} must be above zero: this provider bills every token, and the instance makes no call it cannot price.`;
19067
+ return void 0;
19068
+ }
19069
+ function regionRefusal(kind, region) {
19070
+ if (region === ADDED_PROVIDER_REGION) return void 0;
19071
+ const where = kind === "bedrock" ? `Bedrock is called in ${BEDROCK_REGION} only` : kind === "vertex" ? "Vertex is called over Google's EU endpoint" : "the endpoint must be deployed in an EU region";
19072
+ return `--region must be 'eu': a provider added with this command processes data in the EU, and ${where}. A provider outside the EU is a decision for the release config's owner, written there by hand.`;
19073
+ }
19074
+
19075
+ // src/release-config-file.ts
19076
+ import { access, readFile as readFile12, readdir as readdir5, writeFile as writeFile9 } from "fs/promises";
19077
+ import { dirname as dirname9, extname as extname2, relative as relative5, resolve as resolve13 } from "path";
19078
+ import { isDeepStrictEqual } from "util";
19079
+ import {
19080
+ isMap,
19081
+ isNode,
19082
+ isScalar,
19083
+ isSeq,
19084
+ parseDocument,
19085
+ stringify
19086
+ } from "yaml";
19087
+ var RELEASE_CONFIG_CANDIDATES = ["config/app.yaml", "config/app.base.yaml"];
19088
+ var ReleaseConfigError = class extends Error {
19089
+ };
19090
+ async function locateReleaseConfig(cwd, named) {
19091
+ if (named !== void 0) {
19092
+ const path = resolve13(cwd, named);
19093
+ if (!await exists(path)) throw new ReleaseConfigError(`There is no file ${named}.`);
19094
+ return path;
19095
+ }
19096
+ for (const candidate of RELEASE_CONFIG_CANDIDATES) {
19097
+ const path = resolve13(cwd, candidate);
19098
+ if (await exists(path)) return path;
19099
+ }
19100
+ throw new ReleaseConfigError(
19101
+ `No release config here: looked for ${RELEASE_CONFIG_CANDIDATES.join(" and ")}. Run the command in the deployment repository, or name the file with --config <file>.`
19102
+ );
19103
+ }
19104
+ async function readReleaseConfig(path) {
19105
+ const chain = [];
19106
+ for (let next = path; next !== void 0; ) {
19107
+ if (chain.some((file2) => file2.path === next)) {
19108
+ throw new ReleaseConfigError(
19109
+ `The files extend each other in a circle: ${[...chain.map((file2) => file2.path), next].join(" -> ")}`
19110
+ );
19111
+ }
19112
+ const text2 = (await readFile12(next, "utf8")).replaceAll("\r\n", "\n");
19113
+ const raw = loadYamlData(text2, next);
19114
+ if (!isPlainConfigObject(raw))
19115
+ throw new ReleaseConfigError(`${next} holds no mapping of settings.`);
19116
+ const { extends: extendsValue, ...data } = raw;
19117
+ chain.push({ path: next, text: text2, data });
19118
+ if (extendsValue === void 0) next = void 0;
19119
+ else if (typeof extendsValue === "string" && extendsValue.length > 0)
19120
+ next = resolve13(dirname9(next), extendsValue);
19121
+ else throw new ReleaseConfigError(`'extends' in ${next} must name a file.`);
19122
+ }
19123
+ const [file] = chain;
19124
+ if (file === void 0) throw misplaced();
19125
+ return {
19126
+ file,
19127
+ chain,
19128
+ merged: chain.reduceRight(
19129
+ (base, file2) => mergeConfigObjects(base, file2.data),
19130
+ {}
19131
+ )
19132
+ };
19133
+ }
19134
+ function valueAt(data, path) {
19135
+ let current = data;
19136
+ for (const key2 of path) {
19137
+ if (!isPlainConfigObject(current)) return void 0;
19138
+ current = current[key2];
19139
+ }
19140
+ return current;
19141
+ }
19142
+ function fileSetting(config, path) {
19143
+ return config.chain.find((file) => valueAt(file.data, path) !== void 0);
19144
+ }
19145
+ async function overlaysReplacing(path, lists) {
19146
+ const directory = dirname9(path);
19147
+ const found = [];
19148
+ for (const name2 of (await readdir5(directory)).sort()) {
19149
+ if (![".yaml", ".yml"].includes(extname2(name2))) continue;
19150
+ const candidate = resolve13(directory, name2);
19151
+ if (candidate === path) continue;
19152
+ let config;
19153
+ try {
19154
+ config = await readReleaseConfig(candidate);
19155
+ } catch {
19156
+ continue;
19157
+ }
19158
+ const position = config.chain.findIndex((file) => file.path === path);
19159
+ if (position <= 0) continue;
19160
+ for (const list2 of lists) {
19161
+ const setting = fileSetting(config, list2);
19162
+ if (setting !== void 0 && config.chain.indexOf(setting) < position) {
19163
+ found.push({ file: candidate, list: list2 });
19164
+ }
19165
+ }
19166
+ }
19167
+ return found;
19168
+ }
19169
+ async function addToReleaseConfigFile(file, additions, shown) {
19170
+ const original = await readFile12(file.path, "utf8");
19171
+ const lineEnding = original.includes("\r\n") ? "\r\n" : "\n";
19172
+ const text2 = additions.reduce(
19173
+ (current, addition, index) => placeAddition(current, addition, shown, index === 0),
19174
+ original.replaceAll("\r\n", "\n")
19175
+ );
19176
+ const expected = loadYamlData(original.replaceAll("\r\n", "\n"), file.path);
19177
+ for (const addition of additions) applyToData(expected, addition);
19178
+ if (!isDeepStrictEqual(loadYamlData(text2, file.path), expected)) {
19179
+ throw new ReleaseConfigError(
19180
+ `The change could not be placed in ${shown} without touching what is there. Nothing was written.`
19181
+ );
19182
+ }
19183
+ await writeFile9(file.path, lineEnding === "\n" ? text2 : text2.replaceAll("\n", "\r\n"));
19184
+ }
19185
+ function shownPath(cwd, path) {
19186
+ const shown = relative5(cwd, path).replaceAll("\\", "/");
19187
+ return shown.startsWith("..") ? path : shown;
19188
+ }
19189
+ function placeAddition(text2, addition, shown, original) {
19190
+ const document = parseDocument(text2);
19191
+ const [invalid] = document.errors;
19192
+ if (invalid !== void 0) {
19193
+ throw new ReleaseConfigError(
19194
+ original ? `${shown} is not valid YAML: ${invalid.message}` : `The change could not be placed in ${shown} without touching what is there. Nothing was written.`
19195
+ );
19196
+ }
19197
+ const root = document.contents;
19198
+ const path = addition.path;
19199
+ const rest = (from) => nested(
19200
+ path.slice(from),
19201
+ "item" in addition ? [addition.item] : { [addition.key]: addition.value }
19202
+ );
19203
+ if (root === null)
19204
+ return `${text2}${text2 === "" || text2.endsWith("\n") ? "" : "\n"}${block(rest(0), 0)}
19205
+ `;
19206
+ if (!isMap(root) || root.flow)
19207
+ throw new ReleaseConfigError(`${shown} holds no mapping of settings.`);
19208
+ let map = root;
19209
+ for (let depth = 0; depth < path.length; depth += 1) {
19210
+ const pair = map.items.find((candidate) => keyOf(candidate) === path[depth]);
19211
+ if (pair === void 0) return appendToMap(text2, map, rest(depth));
19212
+ const value = pair.value;
19213
+ const where = path.slice(0, depth + 1).join(".");
19214
+ if (depth === path.length - 1 && "item" in addition) {
19215
+ if (isSeq(value) && !value.flow && value.items.length > 0) {
19216
+ return appendToSequence(text2, value.items, addition.item);
19217
+ }
19218
+ if (isEmpty(value)) return fillEmptyKey(text2, pair, [addition.item]);
19219
+ throw new ReleaseConfigError(
19220
+ `'${where}' in ${shown} is not a list written one item per line. Add the item there by hand.`
19221
+ );
19222
+ }
19223
+ if (isMap(value) && !value.flow && value.items.length > 0) {
19224
+ map = value;
19225
+ continue;
19226
+ }
19227
+ if (isEmpty(value)) return fillEmptyKey(text2, pair, rest(depth + 1));
19228
+ throw new ReleaseConfigError(
19229
+ `'${where}' in ${shown} is not a mapping written one key per line. Add the setting there by hand.`
19230
+ );
19231
+ }
19232
+ if ("key" in addition && map.items.some((candidate) => keyOf(candidate) === addition.key)) {
19233
+ throw new ReleaseConfigError(
19234
+ `'${[...path, addition.key].join(".")}' is already set in ${shown}.`
19235
+ );
19236
+ }
19237
+ return appendToMap(text2, map, rest(path.length));
19238
+ }
19239
+ function appendToMap(text2, map, value) {
19240
+ const first = map.items[0];
19241
+ const last = map.items.at(-1);
19242
+ if (first === void 0 || last === void 0) throw misplaced();
19243
+ const indent = column(text2, rangeOf(first.key)[0]);
19244
+ return insertLines(text2, endOf(last), block(value, indent), indent);
19245
+ }
19246
+ function appendToSequence(text2, items, item) {
19247
+ const first = rangeOf(items[0])[0];
19248
+ const lineStart = text2.lastIndexOf("\n", first - 1) + 1;
19249
+ const dash = text2.lastIndexOf("-", first - 1);
19250
+ if (dash < lineStart) throw misplaced();
19251
+ const indent = dash - lineStart;
19252
+ return insertLines(text2, rangeOf(items.at(-1))[1], block([item], indent), indent);
19253
+ }
19254
+ function fillEmptyKey(text2, pair, value) {
19255
+ const keyRange = rangeOf(pair.key);
19256
+ const indent = column(text2, keyRange[0]) + 2;
19257
+ const colon = text2.indexOf(":", keyRange[1]);
19258
+ const end = pair.value ? rangeOf(pair.value)[1] : colon + 1;
19259
+ const written = text2.slice(colon + 1, end);
19260
+ const empty = /^\s*(?:\{\}|\[\]|~|null|Null|NULL)/u.exec(written);
19261
+ const cleared = empty === null ? text2 : text2.slice(0, colon + 1) + text2.slice(colon + 1 + empty[0].length);
19262
+ return insertLines(cleared, colon + 1, block(value, indent), indent);
19263
+ }
19264
+ function insertLines(text2, offset, lines, indent) {
19265
+ const atLineStart = offset > 0 && text2[offset - 1] === "\n";
19266
+ let at = atLineStart ? offset - 1 : text2.indexOf("\n", offset);
19267
+ while (at !== -1) {
19268
+ const next = text2.indexOf("\n", at + 1);
19269
+ const line = text2.slice(at + 1, next === -1 ? text2.length : next);
19270
+ const trimmed = line.trimStart();
19271
+ if (!trimmed.startsWith("#") || line.length - trimmed.length <= indent) break;
19272
+ at = next;
19273
+ }
19274
+ if (at === -1) at = text2.length;
19275
+ return `${text2.slice(0, at)}
19276
+ ${lines}${text2.slice(at)}`;
19277
+ }
19278
+ function block(value, indent) {
19279
+ const lines = stringify(value, { indent: 2, indentSeq: true, lineWidth: 0 }).replace(/\n$/u, "");
19280
+ const pad = " ".repeat(indent);
19281
+ return lines.split("\n").map((line) => line === "" ? line : pad + line).join("\n");
19282
+ }
19283
+ function nested(path, leaf) {
19284
+ if (path.length === 0) {
19285
+ if (!isPlainConfigObject(leaf)) throw new ReleaseConfigError("A list cannot stand alone.");
19286
+ return leaf;
19287
+ }
19288
+ const [head, ...tail] = path;
19289
+ if (head === void 0) throw misplaced();
19290
+ return { [head]: tail.length === 0 ? leaf : nested(tail, leaf) };
19291
+ }
19292
+ function applyToData(data, addition) {
19293
+ if (!isPlainConfigObject(data))
19294
+ throw new ReleaseConfigError("The file holds no mapping of settings.");
19295
+ let current = data;
19296
+ const steps = "item" in addition ? addition.path.slice(0, -1) : addition.path;
19297
+ for (const key2 of steps) {
19298
+ const next = current[key2];
19299
+ if (isPlainConfigObject(next)) current = next;
19300
+ else {
19301
+ const created = {};
19302
+ current[key2] = created;
19303
+ current = created;
19304
+ }
19305
+ }
19306
+ if ("item" in addition) {
19307
+ const last = addition.path.at(-1);
19308
+ if (last === void 0) throw misplaced();
19309
+ const existing = current[last];
19310
+ current[last] = [...Array.isArray(existing) ? existing : [], addition.item];
19311
+ } else current[addition.key] = addition.value;
19312
+ }
19313
+ function keyOf(pair) {
19314
+ return isScalar(pair.key) ? pair.key.value : pair.key;
19315
+ }
19316
+ function isEmpty(value) {
19317
+ return value === null || value === void 0 || isScalar(value) && value.value === null || (isMap(value) || isSeq(value)) && value.flow === true && value.items.length === 0;
19318
+ }
19319
+ function rangeOf(node) {
19320
+ if (!isNode(node) || !node.range) throw misplaced();
19321
+ return [node.range[0], node.range[1]];
19322
+ }
19323
+ function misplaced() {
19324
+ return new ReleaseConfigError("A setting was not where it was expected. Nothing was written.");
19325
+ }
19326
+ function endOf(pair) {
19327
+ return rangeOf(pair.value ?? pair.key)[1];
19328
+ }
19329
+ function column(text2, offset) {
19330
+ return offset - (text2.lastIndexOf("\n", offset - 1) + 1);
19331
+ }
19332
+ async function exists(path) {
19333
+ try {
19334
+ await access(path);
19335
+ return true;
19336
+ } catch {
19337
+ return false;
19338
+ }
19339
+ }
19340
+
19341
+ // src/model-commands.ts
19342
+ var BINDINGS = ["modelBindings"];
19343
+ var PRICES = ["usage", "costs", "customer", "models"];
19344
+ var DEFAULT_CURRENCY = "EUR";
19345
+ var modelsHelpText = `Usage: catalyst models <add|check|list> [options]
19346
+
19347
+ Model providers of a deployment repository's release config, and their state on an instance.
19348
+
19349
+ Commands:
19350
+ catalyst models add <${MODEL_PROVIDER_KINDS.join("|")}>
19351
+ Write a model provider into the release config: its entry under infrastructure.models,
19352
+ a model binding and its price. Prints the one secret to set. It never asks for a key
19353
+ and never writes one
19354
+ catalyst models check <id>
19355
+ Check the provider on a running instance, where its key is (instance.infrastructure.check)
19356
+ catalyst models list
19357
+ The model providers of the release config; with --instance, also what the instance
19358
+ reports for each (instance.infrastructure.get)
19359
+
19360
+ Options of add:
19361
+ --id <id> The provider's id (azure: azure-eu, vertex: vertex-eu,
19362
+ bedrock: bedrock-eu; openai-compatible: required)
19363
+ --binding <id> The model binding's id (default: the provider's id)
19364
+ --model <name> azure: the deployment; vertex: the Gemini model; bedrock: the ARN
19365
+ of the application inference profile; openai-compatible: the model
19366
+ --endpoint <url> azure: the resource's endpoint
19367
+ --api <responses|chat_completions>
19368
+ azure (default responses) and openai-compatible
19369
+ --project <id> vertex: the Google Cloud project
19370
+ --account <12 digits> bedrock: the AWS account (default: the one the ARN names)
19371
+ --base-url <url> openai-compatible: the base address of the API
19372
+ --auth <bearer|api-key> openai-compatible: how the key is sent (default bearer)
19373
+ --label <name> The name people read for the model (required for bedrock)
19374
+ --vendor <name> Who makes the model, for its logo
19375
+ --fallback <binding> The chat binding that answers when this model is overloaded or
19376
+ cannot be reached; it must be on a provider with region eu
19377
+ --secret <NAME> The name of the secret that holds the key. Never the key
19378
+ --region eu The only region this command writes
19379
+ --input-price <n> Price of a million uncached input tokens
19380
+ --cached-input-price <n> Price of a million cached input tokens
19381
+ --output-price <n> Price of a million output tokens
19382
+ --currency <ABC> The rate card's currency where the config has none yet (EUR)
19383
+
19384
+ Common options:
19385
+ --config <file> The release config (default: ${RELEASE_CONFIG_CANDIDATES.join(", then ")})
19386
+ --instance <name-or-url> The instance check and list ask
19387
+ --json check and list: print JSON
19388
+ --help Show this help
19389
+
19390
+ At a terminal, add asks for what its flags leave out. A provider is added in the EU only:
19391
+ another region is refused with the reason. Who may add one is whoever may change and deploy
19392
+ the deployment repository; check asks the instance and needs the right of the Infrastructure page
19393
+ (system.view). Exit codes: 0 done or ok, 1 refused or the check failed, 2 usage.
19394
+ `;
19395
+ var UsageError3 = class extends Error {
19396
+ };
19397
+ async function runModelsCommand(argv, base) {
19398
+ const verb = argv[1];
19399
+ if (verb === void 0 || verb === "--help" || verb === "-h") {
19400
+ writeOutput(base, modelsHelpText.trimEnd());
19401
+ return 0;
19402
+ }
19403
+ try {
19404
+ let parsed;
19405
+ try {
19406
+ parsed = parseArgs9({
19407
+ args: argv.slice(2),
19408
+ options: {
19409
+ id: { type: "string" },
19410
+ binding: { type: "string" },
19411
+ model: { type: "string" },
19412
+ endpoint: { type: "string" },
19413
+ api: { type: "string" },
19414
+ project: { type: "string" },
19415
+ account: { type: "string" },
19416
+ "base-url": { type: "string" },
19417
+ auth: { type: "string" },
19418
+ label: { type: "string" },
19419
+ vendor: { type: "string" },
19420
+ fallback: { type: "string" },
19421
+ secret: { type: "string" },
19422
+ region: { type: "string" },
19423
+ "input-price": { type: "string" },
19424
+ "cached-input-price": { type: "string" },
19425
+ "output-price": { type: "string" },
19426
+ currency: { type: "string" },
19427
+ config: { type: "string" },
19428
+ instance: { type: "string" },
19429
+ dir: { type: "string" },
19430
+ json: { type: "boolean" },
19431
+ help: { type: "boolean", short: "h" }
19432
+ },
19433
+ allowPositionals: true,
19434
+ strict: true
19435
+ });
19436
+ } catch {
19437
+ throw new UsageError3("Invalid command options. See 'catalyst models --help'.");
19438
+ }
19439
+ const { values, positionals } = parsed;
19440
+ if (values.help) {
19441
+ writeOutput(base, modelsHelpText.trimEnd());
19442
+ return 0;
19443
+ }
19444
+ const options = {
19445
+ ...base,
19446
+ ...values.instance === void 0 ? {} : { instance: values.instance },
19447
+ ...values.dir === void 0 ? {} : { dir: values.dir }
19448
+ };
19449
+ if (verb === "add") {
19450
+ const kind = positionals[0];
19451
+ if (positionals.length !== 1 || !isKind(kind))
19452
+ throw new UsageError3(
19453
+ `Usage: catalyst models add <${MODEL_PROVIDER_KINDS.join("|")}> [options]`
19454
+ );
19455
+ if (values.json)
19456
+ throw new UsageError3("--json belongs to 'catalyst models check' and 'list'.");
19457
+ return await addProvider(kind, values, options);
19458
+ }
19459
+ if (verb === "check") {
19460
+ if (positionals.length !== 1 || !positionals[0])
19461
+ throw new UsageError3(
19462
+ "Usage: catalyst models check <id> [--instance <name-or-url>] [--json]"
19463
+ );
19464
+ return await checkProvider(positionals[0], values.json === true, options);
19465
+ }
19466
+ if (verb === "list") {
19467
+ if (positionals.length > 0)
19468
+ throw new UsageError3(
19469
+ "Usage: catalyst models list [--config <file>] [--instance <name-or-url>] [--json]"
19470
+ );
19471
+ return await listProviders(values.config, values.json === true, options);
19472
+ }
19473
+ throw new UsageError3(`Unknown models command. See 'catalyst models --help'.`);
19474
+ } catch (error) {
19475
+ const converted = toConfigApiError(error);
19476
+ writeError(
19477
+ base,
19478
+ converted instanceof ConfigApiError ? formatRefusal(converted) : formatCommandError(converted)
19479
+ );
19480
+ return error instanceof UsageError3 ? 2 : 1;
19481
+ }
19482
+ }
19483
+ async function addProvider(kind, flags, options) {
19484
+ const spec = PROVIDER_KINDS[kind];
19485
+ const values = {};
19486
+ for (const [flag, value] of Object.entries(flags))
19487
+ if (typeof value === "string") values[flag] = value.trim();
19488
+ const region = values.region ?? "eu";
19489
+ const regionProblem = regionRefusal(kind, region);
19490
+ if (regionProblem) throw new ReleaseConfigError(regionProblem);
19491
+ for (const flag of ["model", "endpoint", "api", "project", "account", "base-url", "auth"]) {
19492
+ if (values[flag] !== void 0 && !spec.fields.some((field) => field.flag === flag))
19493
+ throw new UsageError3(`--${flag} does not belong to 'catalyst models add ${kind}'.`);
19494
+ }
19495
+ if (values.secret !== void 0) {
19496
+ const refusal = secretNameRefusal(values.secret);
19497
+ if (refusal) throw new ReleaseConfigError(refusal);
19498
+ }
19499
+ if (values.currency !== void 0 && !/^[A-Z]{3}$/u.test(values.currency))
19500
+ throw new UsageError3("--currency must be three upper-case letters, such as EUR.");
19501
+ const path = await locateReleaseConfig(
19502
+ options.cwd,
19503
+ typeof flags.config === "string" ? flags.config : void 0
19504
+ );
19505
+ const shown = shownPath(options.cwd, path);
19506
+ const config = await readReleaseConfig(path);
19507
+ const fields = [
19508
+ ...spec.defaultId === void 0 ? [{ flag: "id", question: "Id of the provider, such as acme-eu", required: true }] : [],
19509
+ ...spec.fields,
19510
+ ...COMMON_FIELDS
19511
+ ];
19512
+ const missing = fields.filter((field) => field.required && values[field.flag] === void 0);
19513
+ if (missing.length > 0 && options.prompt === void 0) {
19514
+ throw new UsageError3(
19515
+ `Missing ${missing.map((field) => `--${field.flag}`).join(", ")}. See 'catalyst models --help'.`
19516
+ );
19517
+ }
19518
+ const card = valueAt(config.merged, ["usage", "costs", "customer"]);
19519
+ const currency = isPlainConfigObject(card) && typeof card.currency === "string" ? card.currency : values.currency ?? DEFAULT_CURRENCY;
19520
+ for (const field of fields) {
19521
+ if (values[field.flag] === void 0 && field.required) {
19522
+ const suffix = field.flag.endsWith("price") ? ` in ${currency}` : "";
19523
+ if (options.prompt === void 0) throw new UsageError3(`--${field.flag} is required.`);
19524
+ const answer = (await options.prompt(`${field.question}${suffix}: `)).trim();
19525
+ if (answer === "") throw new UsageError3(`--${field.flag} is required.`);
19526
+ values[field.flag] = answer;
19527
+ }
19528
+ const value = values[field.flag];
19529
+ if (value === void 0) continue;
19530
+ const refusal = field.flag.endsWith("price") ? priceRefusal(field.flag, value, spec.pricesAboveZero) : field.flag === "id" ? idRefusal("id", value) : field.refusal?.(value, values);
19531
+ if (refusal) throw new ReleaseConfigError(refusal);
19532
+ }
19533
+ const id3 = values.id ?? spec.defaultId;
19534
+ if (id3 === void 0) throw new UsageError3("--id is required.");
19535
+ const bindingId = values.binding ?? id3;
19536
+ for (const [flag, value] of [
19537
+ ["id", id3],
19538
+ ["binding", bindingId]
19539
+ ]) {
19540
+ const refusal = idRefusal(flag, value);
19541
+ if (refusal) throw new ReleaseConfigError(refusal);
19542
+ }
19543
+ const models = valueAt(config.merged, ["infrastructure", "models"]);
19544
+ if (isPlainConfigObject(models) && id3 in models)
19545
+ throw new ReleaseConfigError(
19546
+ `The release config already has a model provider '${id3}'. Choose another --id.`
19547
+ );
19548
+ const bindings = valueAt(config.merged, BINDINGS);
19549
+ if (Array.isArray(bindings) && bindings.some((binding2) => isRecord5(binding2) && binding2.id === bindingId))
19550
+ throw new ReleaseConfigError(
19551
+ `The release config already has a model binding '${bindingId}'. Choose another --binding.`
19552
+ );
19553
+ if (values.fallback !== void 0) {
19554
+ const refusal = fallbackRefusal(values.fallback, bindings, models);
19555
+ if (refusal) throw new ReleaseConfigError(refusal);
19556
+ }
19557
+ const secret = values.secret ?? defaultSecret(kind, id3, config);
19558
+ if (secret === void 0)
19559
+ throw new ReleaseConfigError(`Name the secret that holds the key with --secret <NAME>.`);
19560
+ const entry = { ...spec.entry(values), credentialSecret: secret };
19561
+ const model = String(entry.model);
19562
+ const binding = {
19563
+ id: bindingId,
19564
+ providerId: id3,
19565
+ model,
19566
+ ...values.label === void 0 ? {} : { label: values.label },
19567
+ ...(values.vendor ?? spec.vendor) === void 0 ? {} : { vendor: values.vendor ?? spec.vendor },
19568
+ ...spec.agentSelectable ? {} : { agentSelectable: false },
19569
+ ...values.fallback === void 0 ? {} : { fallback: values.fallback }
19570
+ };
19571
+ const price = {
19572
+ providerId: id3,
19573
+ model,
19574
+ uncachedInputPricePerMillionTokens: Number(values["input-price"]),
19575
+ cachedInputPricePerMillionTokens: Number(values["cached-input-price"]),
19576
+ outputPricePerMillionTokens: Number(values["output-price"])
19577
+ };
19578
+ const prices = valueAt(config.merged, PRICES);
19579
+ if (Array.isArray(prices) && prices.some((row) => isRecord5(row) && row.providerId === id3 && row.model === model))
19580
+ throw new ReleaseConfigError(
19581
+ `The rate card already prices '${model}' of provider '${id3}'. Remove that row, or choose another --id.`
19582
+ );
19583
+ const target = config.file;
19584
+ for (const list2 of [BINDINGS, PRICES]) {
19585
+ const owner = fileSetting(config, list2);
19586
+ if (owner !== void 0 && owner !== target) {
19587
+ const ownerShown = shownPath(options.cwd, owner.path);
19588
+ throw new ReleaseConfigError(
19589
+ `${shown} takes '${list2.join(".")}' from ${ownerShown}; a list written here would replace that one. Add the provider to ${ownerShown} with --config ${ownerShown}. Nothing was written.`
19590
+ );
19591
+ }
19592
+ }
19593
+ const [clash] = await overlaysReplacing(target.path, [["infrastructure", "models", id3]]);
19594
+ if (clash !== void 0) {
19595
+ throw new ReleaseConfigError(
19596
+ `${shownPath(options.cwd, clash.file)} already sets a model provider '${id3}', and the entry written into ${shown} would merge into it. Choose another --id. Nothing was written.`
19597
+ );
19598
+ }
19599
+ const additions = [
19600
+ { path: ["infrastructure", "models"], key: id3, value: entry },
19601
+ { path: BINDINGS, item: binding },
19602
+ isPlainConfigObject(card) ? { path: PRICES, item: price } : {
19603
+ path: ["usage", "costs"],
19604
+ key: "customer",
19605
+ value: {
19606
+ id: rateCardId(config),
19607
+ version: (/* @__PURE__ */ new Date()).toISOString().slice(0, 7),
19608
+ currency,
19609
+ models: [price]
19610
+ }
19611
+ }
19612
+ ];
19613
+ await addToReleaseConfigFile(target, additions, shown);
19614
+ const out = (text2) => writeOutput(options, text2);
19615
+ out(`Added model provider '${id3}' to ${shown}:`);
19616
+ const written = [
19617
+ [`infrastructure.models.${id3}`, `${spec.provider}, region eu`],
19618
+ [
19619
+ BINDINGS.join("."),
19620
+ `'${bindingId}'${spec.agentSelectable ? "" : ", not offered to agents"}${values.fallback === void 0 ? "" : `, falls back to '${values.fallback}'`}`
19621
+ ],
19622
+ [
19623
+ PRICES.join("."),
19624
+ `${price.uncachedInputPricePerMillionTokens} input, ${price.cachedInputPricePerMillionTokens} cached input, ${price.outputPricePerMillionTokens} output per million tokens (${currency})`
19625
+ ]
19626
+ ];
19627
+ const width = Math.max(...written.map(([where]) => where.length));
19628
+ for (const [where, what] of written) out(` ${where.padEnd(width)} ${what}`);
19629
+ for (const overlay of await overlaysReplacing(target.path, [BINDINGS, PRICES])) {
19630
+ out(
19631
+ `Note: ${shownPath(options.cwd, overlay.file)} sets its own '${overlay.list.join(".")}', which replaces this one there: add the ${overlay.list === BINDINGS ? "binding" : "price"} to it as well for that environment.`
19632
+ );
19633
+ }
19634
+ if (!spec.agentSelectable) {
19635
+ out(
19636
+ `Note: no agent runs on '${bindingId}': the ${spec.provider} adapter carries no tool calls, which every agent run needs. It serves the product's own calls, such as document extraction.`
19637
+ );
19638
+ }
19639
+ out("");
19640
+ out("Next:");
19641
+ out(
19642
+ ` 1. Set the secret ${secret} where the instance reads its secrets. It holds ${spec.secretHolds}.`
19643
+ );
19644
+ out(` This command never asks for the key and never writes it.`);
19645
+ out(` 2. Deploy the release config.`);
19646
+ out(` 3. catalyst models check ${id3} --instance <url>`);
19647
+ return 0;
19648
+ }
19649
+ function fallbackRefusal(fallbackId, bindings, models) {
19650
+ const fallback = Array.isArray(bindings) ? bindings.find((binding) => isRecord5(binding) && binding.id === fallbackId) : void 0;
19651
+ if (!isRecord5(fallback))
19652
+ return `The release config has no model binding '${fallbackId}' to fall back to. Name one of its chat bindings with --fallback.`;
19653
+ if (fallback.kind === "embedding")
19654
+ return `'${fallbackId}' is an embedding binding; a fallback answers chat calls. Name a chat binding with --fallback.`;
19655
+ const entry = isPlainConfigObject(models) && typeof fallback.providerId === "string" ? models[fallback.providerId] : void 0;
19656
+ const region = isPlainConfigObject(entry) ? entry.region : void 0;
19657
+ if (region !== "eu")
19658
+ return `'${fallbackId}' runs on a provider with region '${typeof region === "string" ? region : "unset"}', and this provider runs in eu; a fallback runs in the binding's region.`;
19659
+ return void 0;
19660
+ }
19661
+ function defaultSecret(kind, id3, config) {
19662
+ const spec = PROVIDER_KINDS[kind];
19663
+ const models = valueAt(config.merged, ["infrastructure", "models"]);
19664
+ const taken = new Set(
19665
+ isPlainConfigObject(models) ? Object.values(models).flatMap(
19666
+ (entry) => isRecord5(entry) && typeof entry.credentialSecret === "string" ? [entry.credentialSecret] : []
19667
+ ) : []
19668
+ );
19669
+ if (spec.defaultSecret !== void 0 && !taken.has(spec.defaultSecret)) return spec.defaultSecret;
19670
+ const named = `${id3.toUpperCase().replaceAll("-", "_")}_${spec.secretSuffix}`;
19671
+ return secretNameRefusal(named) === void 0 && !taken.has(named) ? named : void 0;
19672
+ }
19673
+ function rateCardId(config) {
19674
+ const instance = valueAt(config.merged, ["clientInstance", "id"]);
19675
+ return typeof instance === "string" && instance !== "" ? instance : "rate-card";
19676
+ }
19677
+ async function checkProvider(id3, json2, options) {
19678
+ const { api } = await openInstance(options);
19679
+ const answer = await api.read((client) => client.instance.infrastructure.check());
19680
+ const item = answer.items.find(
19681
+ (candidate) => candidate.class === "models" && candidate.name === id3
19682
+ );
19683
+ if (item === void 0) {
19684
+ const known = answer.items.filter((candidate) => candidate.class === "models").map((candidate) => candidate.name);
19685
+ writeError(
19686
+ options,
19687
+ `The instance has no model provider by that id${known.length > 0 ? ` (it has ${known.join(", ")})` : ""}. Deploy the release config that adds it, then check again.`
19688
+ );
19689
+ return 1;
19690
+ }
19691
+ if (json2) {
19692
+ writeOutput(options, JSON.stringify(item, null, 2));
19693
+ return item.check.status === "ok" ? 0 : 1;
19694
+ }
19695
+ for (const line of describeCheck(item)) writeOutput(options, line);
19696
+ return item.check.status === "ok" ? 0 : 1;
19697
+ }
19698
+ function describeCheck(item) {
19699
+ const head = `${item.check.status === "ok" ? "ok" : item.check.status === "failed" ? "failed" : item.check.status.replace("_", " ")} ${item.id} ${item.type}${item.region ? `, region ${item.region}` : ""}${item.endpointHost ? `, ${item.endpointHost}` : ""}`;
19700
+ const lines = [head];
19701
+ for (const secret of item.secrets) {
19702
+ lines.push(
19703
+ ` secret ${secret.name ?? secret.field ?? ""}: ${secret.state === "set" ? "set" : "missing"}`
19704
+ );
19705
+ }
19706
+ const check = item.check;
19707
+ if (check.status === "ok") {
19708
+ const kind = MODEL_PROVIDER_KINDS.find(
19709
+ (candidate) => PROVIDER_KINDS[candidate].provider === item.type
19710
+ );
19711
+ if (kind !== void 0) lines.push(` ${PROVIDER_KINDS[kind].checkShows}`);
19712
+ } else if (check.status === "failed") {
19713
+ lines.push(` ${check.errorClass}: ${CHECK_SENTENCES[check.errorClass]}`);
19714
+ } else if (check.status === "pending") {
19715
+ lines.push(" No check of it has ended yet. Check again in a minute.");
19716
+ } else {
19717
+ lines.push(" The process that holds the provider has not reported a check.");
19718
+ }
19719
+ return lines;
19720
+ }
19721
+ var CHECK_SENTENCES = {
19722
+ unreachable: "The provider could not be reached.",
19723
+ timeout: "The provider did not answer in time.",
19724
+ access_denied: "The provider refused the credentials.",
19725
+ not_found: "The provider does not know what was asked for.",
19726
+ bucket_missing: "The bucket does not exist. The check does not create it.",
19727
+ rejected: "The provider refused the request.",
19728
+ failed: "The check failed.",
19729
+ no_report: "The worker that checks the provider has stopped reporting."
19730
+ };
19731
+ async function listProviders(configFlag, json2, options) {
19732
+ const path = await locateReleaseConfig(options.cwd, configFlag);
19733
+ const config = await readReleaseConfig(path);
19734
+ const models = valueAt(config.merged, ["infrastructure", "models"]);
19735
+ const bindings = valueAt(config.merged, BINDINGS);
19736
+ const prices = valueAt(config.merged, PRICES);
19737
+ const listed = Object.entries(isPlainConfigObject(models) ? models : {}).map(
19738
+ ([id3, entry]) => {
19739
+ const record = isRecord5(entry) ? entry : {};
19740
+ const ownBindings = (Array.isArray(bindings) ? bindings : []).filter(
19741
+ (binding) => isRecord5(binding) && binding.providerId === id3
19742
+ );
19743
+ const billed = [record.model, ...ownBindings.map((binding) => binding.model)].filter(
19744
+ (model) => typeof model === "string"
19745
+ );
19746
+ return {
19747
+ id: id3,
19748
+ provider: typeof record.provider === "string" ? record.provider : "?",
19749
+ ...typeof record.region === "string" ? { region: record.region } : {},
19750
+ ...typeof record.model === "string" ? { model: record.model } : {},
19751
+ ...typeof record.credentialSecret === "string" ? { secret: record.credentialSecret } : {},
19752
+ bindings: ownBindings.map((binding) => String(binding.id)),
19753
+ priced: billed.length > 0 && billed.every(
19754
+ (model) => (Array.isArray(prices) ? prices : []).some(
19755
+ (row) => isRecord5(row) && row.providerId === id3 && row.model === model
19756
+ )
19757
+ )
19758
+ };
19759
+ }
19760
+ );
19761
+ if (options.instance !== void 0) {
19762
+ const { api } = await openInstance(options);
19763
+ const answer = await api.read((client) => client.instance.infrastructure.get());
19764
+ for (const provider of listed) {
19765
+ const item = answer.items.find(
19766
+ (candidate) => candidate.class === "models" && candidate.name === provider.id
19767
+ );
19768
+ provider.instance = item === void 0 ? "absent" : { secrets: item.secrets, check: item.check };
19769
+ }
19770
+ }
19771
+ if (json2) {
19772
+ writeOutput(
19773
+ options,
19774
+ JSON.stringify({ config: shownPath(options.cwd, path), providers: listed }, null, 2)
19775
+ );
19776
+ return 0;
19777
+ }
19778
+ writeOutput(options, `Model providers of ${shownPath(options.cwd, path)}:`);
19779
+ for (const provider of listed) {
19780
+ const state = provider.instance === void 0 ? "" : provider.instance === "absent" ? " instance: not deployed" : ` instance: ${provider.instance.check.status === "failed" ? `failed (${provider.instance.check.errorClass})` : provider.instance.check.status.replace("_", " ")}${provider.instance.secrets.some((secret) => secret.state === "missing") ? ", secret missing" : ""}`;
19781
+ writeOutput(
19782
+ options,
19783
+ ` ${provider.id} ${provider.provider}, region ${provider.region ?? "unset"}${provider.secret ? `, secret ${provider.secret}` : ""}, bindings: ${provider.bindings.length > 0 ? provider.bindings.join(", ") : "none"}${provider.priced ? "" : ", not priced"}${state}`
19784
+ );
19785
+ }
19786
+ return 0;
19787
+ }
19788
+ function isKind(value) {
19789
+ return MODEL_PROVIDER_KINDS.some((kind) => kind === value);
19790
+ }
19791
+
19792
+ // src/command-groups/models.ts
19793
+ var modelsGroup = {
19794
+ names: ["models add", "models check", "models list"],
19795
+ matches: (argv) => argv[0] === "models",
19796
+ help: modelsHelpText,
19797
+ run: (argv, runtime) => runModelsCommand(argv, {
19798
+ ...runtime,
19799
+ cwd: runtime.cwd,
19800
+ ...runtime.prompt !== void 0 ? { prompt: runtime.prompt } : process.stdin.isTTY ? { prompt: askTerminal } : {}
19801
+ })
19802
+ };
19803
+
19804
+ // src/named-commands.ts
19805
+ import { readFile as readFile13 } from "fs/promises";
19806
+ import { resolve as resolve14 } from "path";
19807
+ import { parseArgs as parseArgs10 } from "util";
18719
19808
  import yaml11 from "js-yaml";
18720
19809
  var commands2 = {
18721
19810
  "workflow test": {
@@ -18793,15 +19882,15 @@ function isNamedCommand(argv) {
18793
19882
  function isNamedNoun(noun) {
18794
19883
  return Object.keys(commands2).some((command) => command.split(" ")[0] === noun);
18795
19884
  }
18796
- var UsageError3 = class extends Error {
19885
+ var UsageError4 = class extends Error {
18797
19886
  };
18798
19887
  async function runNamedCommand(argv, base) {
18799
19888
  try {
18800
19889
  const command = commands2[`${argv[0]} ${argv[1]}`];
18801
- if (!command) throw new UsageError3("Unknown command. See 'catalyst --help'.");
19890
+ if (!command) throw new UsageError4("Unknown command. See 'catalyst --help'.");
18802
19891
  let parsed;
18803
19892
  try {
18804
- parsed = parseArgs9({
19893
+ parsed = parseArgs10({
18805
19894
  args: argv.slice(2),
18806
19895
  options: {
18807
19896
  instance: { type: "string" },
@@ -18814,7 +19903,7 @@ async function runNamedCommand(argv, base) {
18814
19903
  strict: true
18815
19904
  });
18816
19905
  } catch {
18817
- throw new UsageError3(`Usage: catalyst ${command.usage}`);
19906
+ throw new UsageError4(`Usage: catalyst ${command.usage}`);
18818
19907
  }
18819
19908
  const { values, positionals } = parsed;
18820
19909
  if (values.help) {
@@ -18826,17 +19915,17 @@ ${command.operation.summary}
18826
19915
  const [name2] = positionals;
18827
19916
  const count3 = command.param ? 1 : 0;
18828
19917
  if ((command.optionalName ? positionals.length > 1 : positionals.length !== count3) || name2 !== void 0 && name2 === "" || !command.from && values.from !== void 0) {
18829
- throw new UsageError3(`Usage: catalyst ${command.usage}`);
19918
+ throw new UsageError4(`Usage: catalyst ${command.usage}`);
18830
19919
  }
18831
19920
  let body;
18832
19921
  if (command.from) {
18833
19922
  const source = values.from;
18834
- const text2 = source === void 0 ? "{}" : source === "-" ? await readStdin(base.stdin ?? process.stdin) : await readFile12(resolve13(base.cwd, source), "utf8");
19923
+ const text2 = source === void 0 ? "{}" : source === "-" ? await readStdin(base.stdin ?? process.stdin) : await readFile13(resolve14(base.cwd, source), "utf8");
18835
19924
  try {
18836
19925
  const input = JSON.parse(text2);
18837
19926
  body = command.operation.body?.parse(input);
18838
19927
  } catch {
18839
- throw new UsageError3(command.fromShape ?? `Usage: catalyst ${command.usage}`);
19928
+ throw new UsageError4(command.fromShape ?? `Usage: catalyst ${command.usage}`);
18840
19929
  }
18841
19930
  }
18842
19931
  const options = { ...base, instance: values.instance, dir: values.dir };
@@ -18874,7 +19963,7 @@ ${command.operation.summary}
18874
19963
  base,
18875
19964
  converted instanceof ConfigApiError ? formatRefusal(converted) : formatCommandError(converted)
18876
19965
  );
18877
- return error instanceof UsageError3 ? 2 : 1;
19966
+ return error instanceof UsageError4 ? 2 : 1;
18878
19967
  }
18879
19968
  }
18880
19969
  var namedHelpText = `Named operations (readable output by default; --json for JSON):
@@ -18922,6 +20011,7 @@ var commandGroups = [
18922
20011
  dataStoreReviewGroup,
18923
20012
  initGroup,
18924
20013
  knowledgeGroup,
20014
+ modelsGroup,
18925
20015
  namedGroup,
18926
20016
  operationsGroup
18927
20017
  ];