@soat/cli 0.19.0 → 0.19.2

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 (2) hide show
  1. package/dist/index.mjs +52 -31
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -13,7 +13,7 @@ import { load } from "js-yaml";
13
13
  import * as os from "node:os";
14
14
 
15
15
  //#region package.json
16
- var version = "0.19.0";
16
+ var version = "0.19.2";
17
17
 
18
18
  //#endregion
19
19
  //#region src/cli-wrappers/wrappers/formations.ts
@@ -254,6 +254,51 @@ var extractPositionalArgs = args => {
254
254
  }
255
255
  return positional;
256
256
  };
257
+ /**
258
+ * Coerce a raw flag value to the JSON type the spec declares for it.
259
+ *
260
+ * `declaredType` comes from the generated route manifest. A flag the spec
261
+ * declares as `string` is passed through untouched — its content is data, not
262
+ * syntax, so a value that merely *looks* like JSON (a GCP service account key
263
+ * file in `create-secret --value`) or like a number (an account number) must
264
+ * still arrive as a string. Coercing it produced a body the server rejects,
265
+ * with no way to escape it from the shell.
266
+ *
267
+ * The one value a string flag still coerces is the literal `null`: "set it to
268
+ * null to clear" is the documented way to detach a nullable reference
269
+ * (`--default_model_route_id null`, `--ai_provider_id null`), and the shell has
270
+ * no other way to spell JSON null. The cost is that a string whose entire value
271
+ * is `null` cannot be sent — a far rarer need than clearing a field.
272
+ *
273
+ * Every other flag keeps the permissive behavior: an undeclared type (a flag
274
+ * the manifest has no entry for) is still sniffed, since that is the only
275
+ * signal available.
276
+ */
277
+ var parseFlagValue = (value, declaredType) => {
278
+ if (declaredType === "string") return value.trim() === "null" ? null : value;
279
+ const trimmed = value.trim();
280
+ if (trimmed.startsWith("{") || trimmed.startsWith("[") || trimmed === "true" || trimmed === "false" || trimmed === "null" || /^-?\d+(\.\d+)?$/.test(trimmed)) try {
281
+ return JSON.parse(trimmed);
282
+ } catch {
283
+ return value;
284
+ }
285
+ return value;
286
+ };
287
+ /**
288
+ * Build the value for an array-typed flag. Collects repeated occurrences
289
+ * (`--document_paths /a/ --document_paths /b/`) into a list, coercing each
290
+ * element with `parseFlagValue`. A single JSON-array literal
291
+ * (`--document_ids '["doc_1","doc_2"]'`) is passed through as-is rather than
292
+ * being wrapped again, and a single scalar (`--document_paths /playbooks/`)
293
+ * becomes a one-element array.
294
+ */
295
+ var buildArrayFlagValue = rawValues => {
296
+ const parsed = rawValues.map(v => {
297
+ return parseFlagValue(v);
298
+ });
299
+ if (parsed.length === 1 && Array.isArray(parsed[0])) return parsed[0];
300
+ return parsed;
301
+ };
257
302
 
258
303
  //#endregion
259
304
  //#region src/cli-wrappers/index.ts
@@ -772,7 +817,7 @@ var routes = {
772
817
  "in": "body"
773
818
  }, {
774
819
  "name": "output_schema",
775
- "description": "JSON Schema describing the structured object the model must return. When set, non-streaming generations use the AI SDK to constrain output to this schema; the parsed value is returned as `output.object` in the generation response. See the Structured Output section in the Agents module docs.",
820
+ "description": "JSON Schema describing the structured object the model must return. When set, non-streaming generations constrain output to this schema and the parsed value is returned as `output.object`. The schema is enforced on the way back, not just sent to the model: an object that violates it fails the generation with 502 `OUTPUT_SCHEMA_VALIDATION_FAILED`, naming the violated field. Constraints beyond `required`/`type` (`minLength`, `enum`, `pattern`, `minItems`) are honored and are what reject a structurally valid but degenerate answer. See the Structured Output section in the Agents module docs.",
776
821
  "required": false,
777
822
  "type": "object",
778
823
  "in": "body"
@@ -936,7 +981,7 @@ var routes = {
936
981
  "in": "body"
937
982
  }, {
938
983
  "name": "output_schema",
939
- "description": "JSON Schema describing the structured object the model must return. When set, non-streaming generations use the AI SDK to constrain output to this schema; the parsed value is returned as `output.object` in the generation response. See the Structured Output section in the Agents module docs.",
984
+ "description": "JSON Schema describing the structured object the model must return. When set, non-streaming generations constrain output to this schema and the parsed value is returned as `output.object`. The schema is enforced on the way back, not just sent to the model: an object that violates it fails the generation with 502 `OUTPUT_SCHEMA_VALIDATION_FAILED`, naming the violated field. Constraints beyond `required`/`type` (`minLength`, `enum`, `pattern`, `minItems`) are honored and are what reject a structurally valid but degenerate answer. See the Structured Output section in the Agents module docs.",
940
985
  "required": false,
941
986
  "type": "object",
942
987
  "in": "body"
@@ -1084,7 +1129,7 @@ var routes = {
1084
1129
  "in": "body"
1085
1130
  }, {
1086
1131
  "name": "output_schema",
1087
- "description": "JSON Schema describing the structured object the model must return. When set, non-streaming generations use the AI SDK to constrain output to this schema; the parsed value is returned as `output.object` in the generation response. See the Structured Output section in the Agents module docs.",
1132
+ "description": "JSON Schema describing the structured object the model must return. When set, non-streaming generations constrain output to this schema and the parsed value is returned as `output.object`. The schema is enforced on the way back, not just sent to the model: an object that violates it fails the generation with 502 `OUTPUT_SCHEMA_VALIDATION_FAILED`, naming the violated field. Constraints beyond `required`/`type` (`minLength`, `enum`, `pattern`, `minItems`) are honored and are what reject a structurally valid but degenerate answer. See the Structured Output section in the Agents module docs.",
1088
1133
  "required": false,
1089
1134
  "type": "object",
1090
1135
  "in": "body"
@@ -7713,31 +7758,6 @@ var formatResultData = async data => {
7713
7758
  if (data instanceof Blob) return data.text();
7714
7759
  return JSON.stringify(data, null, 2);
7715
7760
  };
7716
- var parseFlagValue = value => {
7717
- const trimmed = value.trim();
7718
- if (trimmed.startsWith("{") || trimmed.startsWith("[") || trimmed === "true" || trimmed === "false" || trimmed === "null" || /^-?\d+(\.\d+)?$/.test(trimmed)) try {
7719
- return JSON.parse(trimmed);
7720
- } catch {
7721
- return value;
7722
- }
7723
- return value;
7724
- };
7725
- /**
7726
- * Build the value for an array-typed flag. Collects repeated occurrences
7727
- * (`--document_paths /a/ --document_paths /b/`) into a list, coercing each
7728
- * element with `parseFlagValue`. A single JSON-array literal
7729
- * (`--document_ids '["doc_1","doc_2"]'`) is passed through as-is rather than
7730
- * being wrapped again, and a single scalar (`--document_paths /playbooks/`)
7731
- * becomes a one-element array.
7732
- */
7733
- var buildArrayFlagValue = rawValues => {
7734
- const parsed = rawValues.map(v => {
7735
- return parseFlagValue(v);
7736
- });
7737
- if (parsed.length === 1 && Array.isArray(parsed[0])) return parsed[0];
7738
- return parsed;
7739
- };
7740
- /** Normalize symbol names to compare exports across acronym casing differences. */
7741
7761
  var normalizeSymbol = name => {
7742
7762
  return name.toLowerCase().replace(/[^a-z0-9]/g, "");
7743
7763
  };
@@ -7926,7 +7946,8 @@ program.argument("[command]", "API command in kebab-case (e.g. list-actors)").ar
7926
7946
  for (const [flagKey, val] of Object.entries(flags)) {
7927
7947
  if (flagKey === "profile" || flagKey === "id") continue;
7928
7948
  const canonical = toCanonical(flagKey);
7929
- const parsedValue = flagTypeByCanonical.get(canonical) === "array" ? buildArrayFlagValue(repeatedFlags[flagKey] ?? [val]) : parseFlagValue(val);
7949
+ const declaredType = flagTypeByCanonical.get(canonical);
7950
+ const parsedValue = declaredType === "array" ? buildArrayFlagValue(repeatedFlags[flagKey] ?? [val]) : parseFlagValue(val, declaredType);
7930
7951
  const pathParam = route.pathParams.find(p => {
7931
7952
  return toCanonical(p) === canonical;
7932
7953
  });
@@ -7940,7 +7961,7 @@ program.argument("[command]", "API command in kebab-case (e.g. list-actors)").ar
7940
7961
  });
7941
7962
  const idAlias = flags["id"] ?? positionalArgs[0];
7942
7963
  const solePathParam = route.pathParams.length === 1 && route.pathParams[0];
7943
- if (idAlias !== void 0 && solePathParam && !(solePathParam in pathArgs)) pathArgs[solePathParam] = parseFlagValue(idAlias);
7964
+ if (idAlias !== void 0 && solePathParam && !(solePathParam in pathArgs)) pathArgs[solePathParam] = parseFlagValue(idAlias, flagTypeByCanonical.get(toCanonical(solePathParam)));
7944
7965
  const missingPathParams = route.pathParams.filter(p => {
7945
7966
  return !(p in pathArgs);
7946
7967
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soat/cli",
3
- "version": "0.19.0",
3
+ "version": "0.19.2",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@inquirer/input": "^5.1.2",
@@ -8,7 +8,7 @@
8
8
  "@ttoss/logger": "^0.8.19",
9
9
  "commander": "^15.0.0",
10
10
  "js-yaml": "^5.2.1",
11
- "@soat/sdk": "0.19.0"
11
+ "@soat/sdk": "0.19.2"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@ttoss/config": "^1.37.17",