@getmagical/cli 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1897,13 +1897,13 @@ var require_ast = __commonJS({
1897
1897
  helperExpression: function helperExpression(node) {
1898
1898
  return node.type === "SubExpression" || (node.type === "MustacheStatement" || node.type === "BlockStatement") && !!(node.params && node.params.length || node.hash);
1899
1899
  },
1900
- scopedId: function scopedId(path20) {
1901
- return /^\.|this\b/.test(path20.original);
1900
+ scopedId: function scopedId(path21) {
1901
+ return /^\.|this\b/.test(path21.original);
1902
1902
  },
1903
1903
  // an ID is simple if it only has one part, and that part is not
1904
1904
  // `..` or `this`.
1905
- simpleId: function simpleId(path20) {
1906
- return path20.parts.length === 1 && !AST.helpers.scopedId(path20) && !path20.depth;
1905
+ simpleId: function simpleId(path21) {
1906
+ return path21.parts.length === 1 && !AST.helpers.scopedId(path21) && !path21.depth;
1907
1907
  }
1908
1908
  }
1909
1909
  };
@@ -2973,12 +2973,12 @@ var require_helpers2 = __commonJS({
2973
2973
  loc
2974
2974
  };
2975
2975
  }
2976
- function prepareMustache(path20, params, hash, open2, strip, locInfo) {
2976
+ function prepareMustache(path21, params, hash, open2, strip, locInfo) {
2977
2977
  var escapeFlag = open2.charAt(3) || open2.charAt(2), escaped = escapeFlag !== "{" && escapeFlag !== "&";
2978
2978
  var decorator = /\*/.test(open2);
2979
2979
  return {
2980
2980
  type: decorator ? "Decorator" : "MustacheStatement",
2981
- path: path20,
2981
+ path: path21,
2982
2982
  params,
2983
2983
  hash,
2984
2984
  escaped,
@@ -3296,9 +3296,9 @@ var require_compiler = __commonJS({
3296
3296
  },
3297
3297
  DecoratorBlock: function DecoratorBlock(decorator) {
3298
3298
  var program2 = decorator.program && this.compileProgram(decorator.program);
3299
- var params = this.setupFullMustacheParams(decorator, program2, void 0), path20 = decorator.path;
3299
+ var params = this.setupFullMustacheParams(decorator, program2, void 0), path21 = decorator.path;
3300
3300
  this.useDecorators = true;
3301
- this.opcode("registerDecorator", params.length, path20.original);
3301
+ this.opcode("registerDecorator", params.length, path21.original);
3302
3302
  },
3303
3303
  PartialStatement: function PartialStatement(partial) {
3304
3304
  this.usePartial = true;
@@ -3362,46 +3362,46 @@ var require_compiler = __commonJS({
3362
3362
  }
3363
3363
  },
3364
3364
  ambiguousSexpr: function ambiguousSexpr(sexpr, program2, inverse) {
3365
- var path20 = sexpr.path, name = path20.parts[0], isBlock = program2 != null || inverse != null;
3366
- this.opcode("getContext", path20.depth);
3365
+ var path21 = sexpr.path, name = path21.parts[0], isBlock = program2 != null || inverse != null;
3366
+ this.opcode("getContext", path21.depth);
3367
3367
  this.opcode("pushProgram", program2);
3368
3368
  this.opcode("pushProgram", inverse);
3369
- path20.strict = true;
3370
- this.accept(path20);
3369
+ path21.strict = true;
3370
+ this.accept(path21);
3371
3371
  this.opcode("invokeAmbiguous", name, isBlock);
3372
3372
  },
3373
3373
  simpleSexpr: function simpleSexpr(sexpr) {
3374
- var path20 = sexpr.path;
3375
- path20.strict = true;
3376
- this.accept(path20);
3374
+ var path21 = sexpr.path;
3375
+ path21.strict = true;
3376
+ this.accept(path21);
3377
3377
  this.opcode("resolvePossibleLambda");
3378
3378
  },
3379
3379
  helperSexpr: function helperSexpr(sexpr, program2, inverse) {
3380
- var params = this.setupFullMustacheParams(sexpr, program2, inverse), path20 = sexpr.path, name = path20.parts[0];
3380
+ var params = this.setupFullMustacheParams(sexpr, program2, inverse), path21 = sexpr.path, name = path21.parts[0];
3381
3381
  if (this.options.knownHelpers[name]) {
3382
3382
  this.opcode("invokeKnownHelper", params.length, name);
3383
3383
  } else if (this.options.knownHelpersOnly) {
3384
3384
  throw new _exception2["default"]("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
3385
3385
  } else {
3386
- path20.strict = true;
3387
- path20.falsy = true;
3388
- this.accept(path20);
3389
- this.opcode("invokeHelper", params.length, path20.original, _ast2["default"].helpers.simpleId(path20));
3386
+ path21.strict = true;
3387
+ path21.falsy = true;
3388
+ this.accept(path21);
3389
+ this.opcode("invokeHelper", params.length, path21.original, _ast2["default"].helpers.simpleId(path21));
3390
3390
  }
3391
3391
  },
3392
- PathExpression: function PathExpression(path20) {
3393
- this.addDepth(path20.depth);
3394
- this.opcode("getContext", path20.depth);
3395
- var name = path20.parts[0], scoped = _ast2["default"].helpers.scopedId(path20), blockParamId = !path20.depth && !scoped && this.blockParamIndex(name);
3392
+ PathExpression: function PathExpression(path21) {
3393
+ this.addDepth(path21.depth);
3394
+ this.opcode("getContext", path21.depth);
3395
+ var name = path21.parts[0], scoped = _ast2["default"].helpers.scopedId(path21), blockParamId = !path21.depth && !scoped && this.blockParamIndex(name);
3396
3396
  if (blockParamId) {
3397
- this.opcode("lookupBlockParam", blockParamId, path20.parts);
3397
+ this.opcode("lookupBlockParam", blockParamId, path21.parts);
3398
3398
  } else if (!name) {
3399
3399
  this.opcode("pushContext");
3400
- } else if (path20.data) {
3400
+ } else if (path21.data) {
3401
3401
  this.options.data = true;
3402
- this.opcode("lookupData", path20.depth, path20.parts, path20.strict);
3402
+ this.opcode("lookupData", path21.depth, path21.parts, path21.strict);
3403
3403
  } else {
3404
- this.opcode("lookupOnContext", path20.parts, path20.falsy, path20.strict, scoped);
3404
+ this.opcode("lookupOnContext", path21.parts, path21.falsy, path21.strict, scoped);
3405
3405
  }
3406
3406
  },
3407
3407
  StringLiteral: function StringLiteral(string) {
@@ -3751,16 +3751,16 @@ var require_util = __commonJS({
3751
3751
  }
3752
3752
  exports.urlGenerate = urlGenerate;
3753
3753
  function normalize(aPath) {
3754
- var path20 = aPath;
3754
+ var path21 = aPath;
3755
3755
  var url = urlParse(aPath);
3756
3756
  if (url) {
3757
3757
  if (!url.path) {
3758
3758
  return aPath;
3759
3759
  }
3760
- path20 = url.path;
3760
+ path21 = url.path;
3761
3761
  }
3762
- var isAbsolute = exports.isAbsolute(path20);
3763
- var parts = path20.split(/\/+/);
3762
+ var isAbsolute = exports.isAbsolute(path21);
3763
+ var parts = path21.split(/\/+/);
3764
3764
  for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
3765
3765
  part = parts[i];
3766
3766
  if (part === ".") {
@@ -3777,15 +3777,15 @@ var require_util = __commonJS({
3777
3777
  }
3778
3778
  }
3779
3779
  }
3780
- path20 = parts.join("/");
3781
- if (path20 === "") {
3782
- path20 = isAbsolute ? "/" : ".";
3780
+ path21 = parts.join("/");
3781
+ if (path21 === "") {
3782
+ path21 = isAbsolute ? "/" : ".";
3783
3783
  }
3784
3784
  if (url) {
3785
- url.path = path20;
3785
+ url.path = path21;
3786
3786
  return urlGenerate(url);
3787
3787
  }
3788
- return path20;
3788
+ return path21;
3789
3789
  }
3790
3790
  exports.normalize = normalize;
3791
3791
  function join(aRoot, aPath) {
@@ -6568,8 +6568,8 @@ var require_printer = __commonJS({
6568
6568
  return this.accept(sexpr.path) + " " + params + hash;
6569
6569
  };
6570
6570
  PrintVisitor.prototype.PathExpression = function(id) {
6571
- var path20 = id.parts.join("/");
6572
- return (id.data ? "@" : "") + "PATH:" + path20;
6571
+ var path21 = id.parts.join("/");
6572
+ return (id.data ? "@" : "") + "PATH:" + path21;
6573
6573
  };
6574
6574
  PrintVisitor.prototype.StringLiteral = function(string) {
6575
6575
  return '"' + string.value + '"';
@@ -7219,7 +7219,7 @@ function getErrorMessage(error) {
7219
7219
 
7220
7220
  // src/program.ts
7221
7221
  import { randomUUID as randomUUID7 } from "node:crypto";
7222
- import path19 from "node:path";
7222
+ import path20 from "node:path";
7223
7223
  import { setTimeout as sleep2 } from "node:timers/promises";
7224
7224
 
7225
7225
  // ../common/dist/src/stdlib/json.util.js
@@ -12394,8 +12394,8 @@ var RENDER_TEMPLATE_ERROR_REASON_CATALOG = defineErrorReasonCatalog()([
12394
12394
  ]);
12395
12395
  var storeReferencePathPattern = String.raw`store(?:\.[$A-Z_a-z][\w$]*)*`;
12396
12396
  var storeReferenceMarkdownLinkTemplateRegex = new RegExp(String.raw`(?<open>\{\{\{?)\s*\[(?<path>${storeReferencePathPattern})\]\(\s*<?https?:\/\/\k<path>>?\s*\)\s*(?<close>\}\}\}?)`, "gu");
12397
- function normalizeAutomationStoreTemplateLinkMatch([_match, open2, path20]) {
12398
- return open2 === "{{{" ? `{{{${path20}}}}` : `{{${path20}}}`;
12397
+ function normalizeAutomationStoreTemplateLinkMatch([_match, open2, path21]) {
12398
+ return open2 === "{{{" ? `{{{${path21}}}}` : `{{${path21}}}`;
12399
12399
  }
12400
12400
  function normalizeAutomationStoreTemplateLinks(template) {
12401
12401
  return template.replaceAll(storeReferenceMarkdownLinkTemplateRegex, (...args) => normalizeAutomationStoreTemplateLinkMatch(args));
@@ -12883,16 +12883,19 @@ var clickAndConfirmAgentcoreInputSchema = clickAndConfirmMarkerInputSchema.exten
12883
12883
  var clickAndConfirmComparisonSchema = clickAndConfirmAgentcoreInputSchema.extend({
12884
12884
  [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
12885
12885
  });
12886
+ var textEntryModeSchema = z10.enum(["direct", "keyboard"]).describe("Internal clickFill input strategy. Copy textEntryMode from the command instructions; use direct when unspecified. Never infer the mode from the field or text. Browser keyboard mode enters text character by character. Desktop retains its configured input method for either mode.");
12886
12887
  var clickFillMarkerInputSchema = z10.object({
12887
12888
  marker: markerSchema("The marker of the input field to fill."),
12888
- text: z10.string().describe("The text to fill the marker with")
12889
+ text: z10.string().describe("The text to fill the marker with"),
12890
+ textEntryMode: textEntryModeSchema.default("direct")
12889
12891
  });
12890
12892
  var clickFillCoordinateInputSchema = z10.object({
12891
12893
  coordinates: coordinateSchema({
12892
12894
  xDescription: "The x coordinate of the element to fill.",
12893
12895
  yDescription: "The y coordinate of the element to fill."
12894
12896
  }),
12895
- text: z10.string().describe("The text to fill the field with")
12897
+ text: z10.string().describe("The text to fill the field with"),
12898
+ textEntryMode: textEntryModeSchema.default("direct")
12896
12899
  });
12897
12900
  var clickFillComparisonSchema = z10.union([
12898
12901
  clickFillMarkerInputSchema.extend({
@@ -13881,18 +13884,18 @@ var specialCommands = {
13881
13884
  // ../common/dist/src/utils/automation-store-path.util.js
13882
13885
  var AUTOMATION_STORE_ROOT_PATH = "store";
13883
13886
  var relativeStorePathRegex = /^[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*)*$/u;
13884
- function normalizeStoreMutationPath(path20) {
13885
- const trimmedPath = path20.trim();
13887
+ function normalizeStoreMutationPath(path21) {
13888
+ const trimmedPath = path21.trim();
13886
13889
  const rootPrefix = `${AUTOMATION_STORE_ROOT_PATH}.`;
13887
13890
  const relativePath = trimmedPath.startsWith(rootPrefix) ? trimmedPath.slice(rootPrefix.length) : trimmedPath;
13888
13891
  if (!relativeStorePathRegex.test(relativePath)) {
13889
13892
  return Err({
13890
13893
  type: "invalid-automation-store-path",
13891
- path: path20,
13894
+ path: path21,
13892
13895
  categories: ["customer_usage"],
13893
13896
  statusCode: 400,
13894
13897
  nonRetryable: true,
13895
- message: `Automation store path "${path20}" is invalid.`,
13898
+ message: `Automation store path "${path21}" is invalid.`,
13896
13899
  suggestedAction: "Use a dot path relative to the automation store, such as patient.name or provider.clinic."
13897
13900
  });
13898
13901
  }
@@ -13905,16 +13908,16 @@ function findAutomationStorePathOverlap(paths) {
13905
13908
  ...new Set(paths.map(getCanonicalAutomationStoreMutationPath))
13906
13909
  ].toSorted((left, right) => (left === AUTOMATION_STORE_ROOT_PATH ? 0 : left.split(".").length) - (right === AUTOMATION_STORE_ROOT_PATH ? 0 : right.split(".").length));
13907
13910
  for (const [index, ancestorPath] of canonicalPaths.entries()) {
13908
- const descendantPath = canonicalPaths.slice(index + 1).find((path20) => ancestorPath === AUTOMATION_STORE_ROOT_PATH || path20.startsWith(`${ancestorPath}.`));
13911
+ const descendantPath = canonicalPaths.slice(index + 1).find((path21) => ancestorPath === AUTOMATION_STORE_ROOT_PATH || path21.startsWith(`${ancestorPath}.`));
13909
13912
  if (descendantPath !== void 0) {
13910
13913
  return { ancestorPath, descendantPath };
13911
13914
  }
13912
13915
  }
13913
13916
  return void 0;
13914
13917
  }
13915
- function getCanonicalAutomationStoreMutationPath(path20) {
13916
- const normalizedPath = normalizeStoreMutationPath(path20);
13917
- return normalizedPath._tag === "Ok" ? normalizedPath.value : path20.trim();
13918
+ function getCanonicalAutomationStoreMutationPath(path21) {
13919
+ const normalizedPath = normalizeStoreMutationPath(path21);
13920
+ return normalizedPath._tag === "Ok" ? normalizedPath.value : path21.trim();
13918
13921
  }
13919
13922
 
13920
13923
  // ../common/dist/src/constants/tool-declarations.js
@@ -14093,9 +14096,9 @@ var baseToolDeclarations = {
14093
14096
  path: []
14094
14097
  });
14095
14098
  }
14096
- const canonicalUpdatePaths = updates.map(({ path: path20 }) => getCanonicalAutomationStoreMutationPath(path20));
14099
+ const canonicalUpdatePaths = updates.map(({ path: path21 }) => getCanonicalAutomationStoreMutationPath(path21));
14097
14100
  const canonicalClearPathSet = new Set(clears.map(getCanonicalAutomationStoreMutationPath));
14098
- const conflictedUpdatePath = canonicalUpdatePaths.find((path20) => canonicalClearPathSet.has(path20));
14101
+ const conflictedUpdatePath = canonicalUpdatePaths.find((path21) => canonicalClearPathSet.has(path21));
14099
14102
  if (conflictedUpdatePath !== void 0) {
14100
14103
  context.addIssue({
14101
14104
  code: "custom",
@@ -14628,9 +14631,9 @@ var magicalApiKeyPermissionPresets = [
14628
14631
  import { z as z25 } from "zod";
14629
14632
 
14630
14633
  // ../common/dist/src/utils/agent-knowledge-base-assets.util.js
14631
- function getIsKnowledgeBaseAssetPathAllowed(path20) {
14632
- const pathSegments = path20.split("/");
14633
- if (path20.length === 0 || pathSegments.some((segment) => segment.length === 0)) {
14634
+ function getIsKnowledgeBaseAssetPathAllowed(path21) {
14635
+ const pathSegments = path21.split("/");
14636
+ if (path21.length === 0 || pathSegments.some((segment) => segment.length === 0)) {
14634
14637
  return false;
14635
14638
  }
14636
14639
  const isTopLevelAssetPath = pathSegments[0] === "assets";
@@ -14685,29 +14688,29 @@ var ApiEmbeddedFileContentTypes = [
14685
14688
  ];
14686
14689
  var API_EMBEDDED_FILE_PATH_PATTERN = /^(?:\[\*\]|[A-Za-z_$][\w$-]*)(?:\[\*\]|\.[A-Za-z_$][\w$-]*)*$/u;
14687
14690
  var API_EMBEDDED_FILE_PATH_SEGMENT_PATTERN = /\[\*\]|[A-Za-z_$][\w$-]*/gu;
14688
- function parseApiEmbeddedFilePath(path20) {
14689
- if (!API_EMBEDDED_FILE_PATH_PATTERN.test(path20)) {
14691
+ function parseApiEmbeddedFilePath(path21) {
14692
+ if (!API_EMBEDDED_FILE_PATH_PATTERN.test(path21)) {
14690
14693
  return void 0;
14691
14694
  }
14692
- return [...path20.matchAll(API_EMBEDDED_FILE_PATH_SEGMENT_PATTERN)].map(([segment]) => segment === "[*]" ? { type: "arrayWildcard" } : { key: segment, type: "property" });
14695
+ return [...path21.matchAll(API_EMBEDDED_FILE_PATH_SEGMENT_PATTERN)].map(([segment]) => segment === "[*]" ? { type: "arrayWildcard" } : { key: segment, type: "property" });
14693
14696
  }
14694
14697
  var apiAgentEmbeddedFileSchema = z17.object({
14695
- path: z17.string().trim().min(1, "Embedded file path is required.").refine((path20) => parseApiEmbeddedFilePath(path20) !== void 0, {
14698
+ path: z17.string().trim().min(1, "Embedded file path is required.").refine((path21) => parseApiEmbeddedFilePath(path21) !== void 0, {
14696
14699
  message: "Embedded file path must use object properties and [*] array wildcards."
14697
14700
  }).describe("Path to a Base64 value relative to the projected API response. Supports object properties and [*] array wildcards."),
14698
14701
  contentType: z17.enum(ApiEmbeddedFileContentTypes).describe("File type of the decoded Base64 value. Use auto to detect PDF, PNG, or JPEG from each file\u2019s contents. Unrecognized files are skipped.")
14699
14702
  }).strict();
14700
14703
  var apiAgentEmbeddedFilesSchema = z17.array(apiAgentEmbeddedFileSchema).superRefine((embeddedFiles, context) => {
14701
14704
  const paths = /* @__PURE__ */ new Set();
14702
- for (const [index, { path: path20 }] of embeddedFiles.entries()) {
14703
- if (paths.has(path20)) {
14705
+ for (const [index, { path: path21 }] of embeddedFiles.entries()) {
14706
+ if (paths.has(path21)) {
14704
14707
  context.addIssue({
14705
14708
  code: z17.ZodIssueCode.custom,
14706
- message: `Embedded file path "${path20}" can only be configured once.`,
14709
+ message: `Embedded file path "${path21}" can only be configured once.`,
14707
14710
  path: [index, "path"]
14708
14711
  });
14709
14712
  }
14710
- paths.add(path20);
14713
+ paths.add(path21);
14711
14714
  }
14712
14715
  }).describe("Base64 values to decode, upload as permanent files, and replace with file references in the projected API response.");
14713
14716
 
@@ -14717,13 +14720,13 @@ var API_REQUEST_FILE_PATH_PATTERN = /^[A-Za-z_$][\w$-]*(?:\.[A-Za-z_$][\w$-]*)*$
14717
14720
  var API_REQUEST_BASE64_FILE_HELPER_PATTERN = /^\s*\{\{\s*base64File\s+(?<sourceInput>[^{}\s]+)\s*\}\}\s*$/u;
14718
14721
  var API_REQUEST_BASE64_FILE_HELPER_USAGE_PATTERN = /\{\{\s*base64File\b/u;
14719
14722
  var API_REQUEST_BASE64_FILE_HELPER_EXAMPLE = "{{base64File fileInput}}";
14720
- function parseApiRequestFilePath(path20) {
14721
- if (!API_REQUEST_FILE_PATH_PATTERN.test(path20)) {
14723
+ function parseApiRequestFilePath(path21) {
14724
+ if (!API_REQUEST_FILE_PATH_PATTERN.test(path21)) {
14722
14725
  return void 0;
14723
14726
  }
14724
- return path20.split(".");
14727
+ return path21.split(".");
14725
14728
  }
14726
- function inspectApiRequestBase64FileHelperValue({ path: path20, value }) {
14729
+ function inspectApiRequestBase64FileHelperValue({ path: path21, value }) {
14727
14730
  const match = API_REQUEST_BASE64_FILE_HELPER_PATTERN.exec(value);
14728
14731
  if (match === null) {
14729
14732
  return API_REQUEST_BASE64_FILE_HELPER_USAGE_PATTERN.test(value) ? {
@@ -14731,7 +14734,7 @@ function inspectApiRequestBase64FileHelperValue({ path: path20, value }) {
14731
14734
  issues: [
14732
14735
  {
14733
14736
  message: `Use ${API_REQUEST_BASE64_FILE_HELPER_EXAMPLE} as the entire JSON field value.`,
14734
- path: path20
14737
+ path: path21
14735
14738
  }
14736
14739
  ]
14737
14740
  } : { helpers: [], issues: [] };
@@ -14743,24 +14746,24 @@ function inspectApiRequestBase64FileHelperValue({ path: path20, value }) {
14743
14746
  issues: [
14744
14747
  {
14745
14748
  message: "Base64 file helper input must use an object property path.",
14746
- path: path20
14749
+ path: path21
14747
14750
  }
14748
14751
  ]
14749
14752
  };
14750
14753
  }
14751
14754
  return {
14752
- helpers: [{ destinationPath: path20, sourceInput }],
14755
+ helpers: [{ destinationPath: path21, sourceInput }],
14753
14756
  issues: []
14754
14757
  };
14755
14758
  }
14756
- function inspectApiRequestBase64FileHelpers(body, path20 = []) {
14759
+ function inspectApiRequestBase64FileHelpers(body, path21 = []) {
14757
14760
  if (typeof body === "string") {
14758
- return inspectApiRequestBase64FileHelperValue({ path: path20, value: body });
14761
+ return inspectApiRequestBase64FileHelperValue({ path: path21, value: body });
14759
14762
  }
14760
14763
  if (Array.isArray(body)) {
14761
14764
  return body.reduce((inspection, value, index) => {
14762
14765
  const nestedInspection = inspectApiRequestBase64FileHelpers(value, [
14763
- ...path20,
14766
+ ...path21,
14764
14767
  index
14765
14768
  ]);
14766
14769
  return {
@@ -14774,7 +14777,7 @@ function inspectApiRequestBase64FileHelpers(body, path20 = []) {
14774
14777
  }
14775
14778
  return Object.entries(body).reduce((inspection, [key, value]) => {
14776
14779
  const nestedInspection = inspectApiRequestBase64FileHelpers(value, [
14777
- ...path20,
14780
+ ...path21,
14778
14781
  key
14779
14782
  ]);
14780
14783
  return {
@@ -14818,10 +14821,10 @@ function validateApiRequestBase64FileHelpers({ body, bodyType, context, supports
14818
14821
  }
14819
14822
  }
14820
14823
  var apiAgentRequestFileEncodingSchema = z18.object({
14821
- sourceInput: z18.string().trim().min(1, "File input is required.").refine((path20) => parseApiRequestFilePath(path20) !== void 0, {
14824
+ sourceInput: z18.string().trim().min(1, "File input is required.").refine((path21) => parseApiRequestFilePath(path21) !== void 0, {
14822
14825
  message: "File input must use an object property path."
14823
14826
  }).describe("API Agent input containing the file reference to encode."),
14824
- destinationPath: z18.string().trim().min(1, "Request field is required.").refine((path20) => parseApiRequestFilePath(path20) !== void 0, {
14827
+ destinationPath: z18.string().trim().min(1, "Request field is required.").refine((path21) => parseApiRequestFilePath(path21) !== void 0, {
14825
14828
  message: "Request field must use an object property path."
14826
14829
  }).describe("JSON request body path where the encoded value is inserted."),
14827
14830
  encoding: z18.literal("base64").describe("Encoding applied to the source file before insertion.")
@@ -15179,30 +15182,30 @@ function hasControlCharacter(value) {
15179
15182
  }
15180
15183
  return false;
15181
15184
  }
15182
- function isNormalizedRepoPath(path20) {
15183
- if (path20 === "/") {
15185
+ function isNormalizedRepoPath(path21) {
15186
+ if (path21 === "/") {
15184
15187
  return true;
15185
15188
  }
15186
- if (path20.length === 0 || path20.startsWith("/") || path20.startsWith("\\") || path20.includes("\\") || hasControlCharacter(path20) || windowsAbsolutePathPattern.test(path20)) {
15189
+ if (path21.length === 0 || path21.startsWith("/") || path21.startsWith("\\") || path21.includes("\\") || hasControlCharacter(path21) || windowsAbsolutePathPattern.test(path21)) {
15187
15190
  return false;
15188
15191
  }
15189
- return path20.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== ".." && segment !== ".git");
15192
+ return path21.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== ".." && segment !== ".git");
15190
15193
  }
15191
- function normalizeRepoPath(path20) {
15192
- if (path20 === "/") {
15193
- return path20;
15194
+ function normalizeRepoPath(path21) {
15195
+ if (path21 === "/") {
15196
+ return path21;
15194
15197
  }
15195
- return path20.replaceAll(/\/+$/gu, "");
15198
+ return path21.replaceAll(/\/+$/gu, "");
15196
15199
  }
15197
15200
  var skillPathPattern = /^(?:skills\/.+|automations\/[^/]+\/skills\/.+|automations\/[^/]+\/agents\/[^/]+\/skills\/.+)$/u;
15198
15201
  var skillRootPathPattern = /^(?:skills\/[^/]+|automations\/[^/]+\/skills\/[^/]+|automations\/[^/]+\/agents\/[^/]+\/skills\/[^/]+)$/u;
15199
15202
  var repoPathSchema = z25.string().min(1).transform(normalizeRepoPath).refine(isNormalizedRepoPath, {
15200
15203
  message: "Path must be a normalized repository-relative path."
15201
15204
  });
15202
- var registeredSkillPathSchema = repoPathSchema.refine((path20) => skillPathPattern.test(path20), {
15205
+ var registeredSkillPathSchema = repoPathSchema.refine((path21) => skillPathPattern.test(path21), {
15203
15206
  message: "Skill paths must be under root, automation, or automation-agent skills."
15204
15207
  });
15205
- var registeredSkillRootPathSchema = registeredSkillPathSchema.refine((path20) => skillRootPathPattern.test(path20) && !path20.endsWith("/SKILL.md"), {
15208
+ var registeredSkillRootPathSchema = registeredSkillPathSchema.refine((path21) => skillRootPathPattern.test(path21) && !path21.endsWith("/SKILL.md"), {
15206
15209
  message: "Registered skill paths must identify a skill root directory."
15207
15210
  });
15208
15211
  var knowledgeBasePluginPermissionSchema = z25.object({
@@ -15838,13 +15841,13 @@ function getMentionedStandardCommand(instructions) {
15838
15841
  const normalizedInstructions = instructions.toLowerCase();
15839
15842
  return STANDARD_COMMAND_NAMES.find((commandName) => normalizedInstructions.includes(commandName.toLowerCase())) ?? null;
15840
15843
  }
15841
- function assertCustomInstructionsCommand({ commands, path: path20 }) {
15842
- const customCommands = commands.flatMap((command, commandIndex) => command["commandName"] === "custom" ? [{ command, path: `${path20}[${commandIndex.toString()}]` }] : []);
15844
+ function assertCustomInstructionsCommand({ commands, path: path21 }) {
15845
+ const customCommands = commands.flatMap((command, commandIndex) => command["commandName"] === "custom" ? [{ command, path: `${path21}[${commandIndex.toString()}]` }] : []);
15843
15846
  if (customCommands.length === 0) {
15844
15847
  return;
15845
15848
  }
15846
15849
  if (customCommands.length > MAX_CUSTOM_COMMAND_COUNT) {
15847
- throw createInvalidValueError(`${path20} contains ${customCommands.length.toString()} custom commands. Use at most ${MAX_CUSTOM_COMMAND_COUNT.toString()} short custom commands per agent. Split policy, decision, outreach, and multi-step work into catalog commands or child agents instead.`);
15850
+ throw createInvalidValueError(`${path21} contains ${customCommands.length.toString()} custom commands. Use at most ${MAX_CUSTOM_COMMAND_COUNT.toString()} short custom commands per agent. Split policy, decision, outreach, and multi-step work into catalog commands or child agents instead.`);
15848
15851
  }
15849
15852
  for (const customCommand of customCommands) {
15850
15853
  const instructions = getCustomInstructions(customCommand.command);
@@ -16073,8 +16076,8 @@ function createOperationSpec(spec) {
16073
16076
  }
16074
16077
 
16075
16078
  // ../mcp-registry/src/operation-specs.ts
16076
- var AUTOMATION_BRANCH_NAME_PATTERN = /^[\da-z]+(?:-[\da-z]+)*$/u;
16077
- var AUTOMATION_BRANCH_NAME_MESSAGE = 'Branch name must use lowercase letters or numbers separated by single dashes (for example, "release-2").';
16079
+ var AUTOMATION_BRANCH_NAME_PATTERN = /^[\da-z]+(?:[-/][\da-z]+)*$/u;
16080
+ var AUTOMATION_BRANCH_NAME_MESSAGE = 'Branch name must use lowercase letters or numbers separated by single dashes or slashes (for example, "otto/branch-fix").';
16078
16081
  function stringOption({
16079
16082
  clientOnly = false,
16080
16083
  description,
@@ -16226,7 +16229,7 @@ function isRecord3(value) {
16226
16229
  function validateCustomInstructionsCommands({
16227
16230
  commands,
16228
16231
  ctx,
16229
- path: path20
16232
+ path: path21
16230
16233
  }) {
16231
16234
  if (!Array.isArray(commands)) {
16232
16235
  return;
@@ -16234,14 +16237,14 @@ function validateCustomInstructionsCommands({
16234
16237
  const validationResult = fromThrowable(() => {
16235
16238
  assertCustomInstructionsCommand({
16236
16239
  commands: commands.map((command) => isRecord3(command) ? command : {}),
16237
- path: path20.join(".").replaceAll(/\.(?<index>\d+)/gu, "[$<index>]")
16240
+ path: path21.join(".").replaceAll(/\.(?<index>\d+)/gu, "[$<index>]")
16238
16241
  });
16239
16242
  }, "invalid-custom-instructions-command");
16240
16243
  if (isErr(validationResult)) {
16241
16244
  ctx.addIssue({
16242
16245
  code: "custom",
16243
16246
  message: `${getErrorMessage2(validationResult.error.cause)} Run mgcl catalog commands to find the standard command for this work.`,
16244
- path: path20
16247
+ path: path21
16245
16248
  });
16246
16249
  }
16247
16250
  }
@@ -16544,7 +16547,8 @@ var automationRunsInputSchema = z28.object({
16544
16547
  limit: z28.number().int().positive().optional(),
16545
16548
  orderBy: z28.enum(["createdAtAsc", "createdAtDesc", "random"]).optional(),
16546
16549
  page: z28.number().int().nonnegative().optional(),
16547
- to: z28.string().min(1).optional()
16550
+ to: z28.string().min(1).optional(),
16551
+ workflowIds: z28.array(z28.string().min(1)).optional()
16548
16552
  }).refine(({ orderBy, page }) => orderBy !== "random" || (page ?? 0) === 0, {
16549
16553
  message: "Random ordering reshuffles on every call, so --page cannot be combined with --order-by random."
16550
16554
  });
@@ -16588,9 +16592,46 @@ var automationRunsCliOptions = [
16588
16592
  inputKey: "to",
16589
16593
  flagName: "to",
16590
16594
  description: "Optional inclusive createdAt upper bound ISO timestamp."
16595
+ }),
16596
+ stringArrayOption({
16597
+ inputKey: "workflowIds",
16598
+ flagName: "workflow-ids",
16599
+ description: "Optional workflow IDs. Find them with `mgcl workflows list`."
16591
16600
  })
16592
16601
  ];
16593
16602
  var operationSpecs = [
16603
+ createOperationSpec({
16604
+ operationName: "Classify",
16605
+ apiKeyAccess: apiKeyAccessPolicies.baseline,
16606
+ kind: "query",
16607
+ inputSchema: z28.object({ input: jsonObjectSchema }),
16608
+ cli: {
16609
+ name: "classify",
16610
+ path: ["classify"],
16611
+ description: "Answer typed noul, choice, and score questions about supplied context.",
16612
+ resultKey: "classify",
16613
+ options: [
16614
+ stringOption({
16615
+ clientOnly: true,
16616
+ description: "TypeSafe-shaped request object as inline JSON.",
16617
+ flagName: "input-json",
16618
+ inputKey: "inputJson",
16619
+ valueHint: "JSON"
16620
+ }),
16621
+ stringOption({
16622
+ clientOnly: true,
16623
+ description: "Path to request JSON, or - to read stdin.",
16624
+ flagName: "input-file",
16625
+ inputKey: "inputFile"
16626
+ })
16627
+ ]
16628
+ },
16629
+ mcp: { exposed: false, fileName: "classify.graphql" },
16630
+ document: `# Answer typed questions about caller-supplied context
16631
+ query Classify($input: JSON!) {
16632
+ classify(input: $input)
16633
+ }`
16634
+ }),
16594
16635
  createOperationSpec({
16595
16636
  operationName: "KnowledgeFiles",
16596
16637
  apiKeyAccess: apiKeyAccessPolicies.knowledgeRead,
@@ -17767,7 +17808,7 @@ query InspectPausedAutomationStep($runId: ID!) {
17767
17808
  options: automationRunsCliOptions
17768
17809
  },
17769
17810
  mcp: { fileName: "automationRuns.graphql" },
17770
- document: `# Query automation run history with optional automation and time-window filters
17811
+ document: `# Query automation run history with optional automation, workflow, and time-window filters
17771
17812
  query GetAutomationRuns(
17772
17813
  $automationId: ID
17773
17814
  $from: String
@@ -17777,6 +17818,7 @@ query GetAutomationRuns(
17777
17818
  $orderBy: AutomationRunOrderBy
17778
17819
  $page: Int
17779
17820
  $to: String
17821
+ $workflowIds: [ID!]
17780
17822
  ) {
17781
17823
  automationRuns(
17782
17824
  automationId: $automationId
@@ -17787,6 +17829,7 @@ query GetAutomationRuns(
17787
17829
  orderBy: $orderBy
17788
17830
  page: $page
17789
17831
  to: $to
17832
+ workflowIds: $workflowIds
17790
17833
  ) {
17791
17834
  id
17792
17835
  automationId
@@ -17826,6 +17869,7 @@ query GetAutomationRunsPage(
17826
17869
  $orderBy: AutomationRunOrderBy
17827
17870
  $page: Int
17828
17871
  $to: String
17872
+ $workflowIds: [ID!]
17829
17873
  ) {
17830
17874
  automationRunsPage(
17831
17875
  automationId: $automationId
@@ -17836,6 +17880,7 @@ query GetAutomationRunsPage(
17836
17880
  orderBy: $orderBy
17837
17881
  page: $page
17838
17882
  to: $to
17883
+ workflowIds: $workflowIds
17839
17884
  ) {
17840
17885
  items {
17841
17886
  id
@@ -17856,6 +17901,27 @@ query GetAutomationRunsPage(
17856
17901
  pageSize
17857
17902
  isTotalTruncated
17858
17903
  }
17904
+ }`
17905
+ }),
17906
+ createOperationSpec({
17907
+ operationName: "ListWorkflows",
17908
+ apiKeyAccess: apiKeyAccessPolicies.automationRead,
17909
+ kind: "query",
17910
+ inputSchema: z28.object({}),
17911
+ cli: {
17912
+ name: "list-workflows",
17913
+ path: ["workflows", "list"],
17914
+ description: "List workflows. Pass their IDs to `mgcl automation-runs list --workflow-ids`.",
17915
+ resultKey: "workflows",
17916
+ options: []
17917
+ },
17918
+ mcp: { fileName: "workflows.graphql" },
17919
+ document: `# List workflows so their IDs can filter automation runs
17920
+ query ListWorkflows {
17921
+ workflows {
17922
+ id
17923
+ name
17924
+ }
17859
17925
  }`
17860
17926
  }),
17861
17927
  createOperationSpec({
@@ -17891,7 +17957,7 @@ query GetAutomationRunsPage(
17891
17957
  ]
17892
17958
  },
17893
17959
  mcp: { fileName: "listAutomations.graphql" },
17894
- document: `# Query to list automations with flat fields only (no nested objects)
17960
+ document: `# Query to list automations with flat fields plus the workflow reference
17895
17961
  # Excludes config and agents for MCP tool simplicity
17896
17962
  query ListAutomations(
17897
17963
  $limit: Int
@@ -17908,6 +17974,10 @@ query ListAutomations(
17908
17974
  lastSavedAt
17909
17975
  publishedVersionId
17910
17976
  draftVersionId
17977
+ workflow {
17978
+ id
17979
+ name
17980
+ }
17911
17981
  }
17912
17982
  }`
17913
17983
  }),
@@ -17948,6 +18018,10 @@ query GetAutomations($ids: [ID!]!) {
17948
18018
  lastSavedAt
17949
18019
  publishedVersionId
17950
18020
  draftVersionId
18021
+ workflow {
18022
+ id
18023
+ name
18024
+ }
17951
18025
  config {
17952
18026
  sharedInputSchema {
17953
18027
  key
@@ -18061,7 +18135,7 @@ query ListAutomationBranches($automationId: ID!) {
18061
18135
  stringOption({
18062
18136
  inputKey: "name",
18063
18137
  flagName: "name",
18064
- description: 'Lowercase branch name with single dashes between words or numbers (for example, "release-2").',
18138
+ description: 'Lowercase branch name with single dashes or slashes between words or numbers (for example, "otto/branch-fix").',
18065
18139
  required: true
18066
18140
  }),
18067
18141
  stringOption({
@@ -19275,7 +19349,7 @@ mutation skills_apply_patch(
19275
19349
  cli: {
19276
19350
  name: "create-automation",
19277
19351
  path: ["automations", "create"],
19278
- description: "Create a draft automation.",
19352
+ description: "Create a draft automation. Inspect publishChecks and repair blocking failures before completing the task.",
19279
19353
  resultKey: "createAutomation",
19280
19354
  options: [
19281
19355
  jsonOption({
@@ -19288,10 +19362,12 @@ mutation skills_apply_patch(
19288
19362
  },
19289
19363
  mcp: { fileName: "createAutomation.graphql" },
19290
19364
  document: `# Mutation to create a draft automation with optional initial values
19365
+ # Draft saves are allowed. Inspect publishChecks, repair blocking failures, and save again before completing the task. Unknown means checks must be retried.
19291
19366
  # Returns flat fields only for MCP tool simplicity
19292
19367
  mutation CreateAutomation($input: CreateAutomationInput!) {
19293
19368
  createAutomation(input: $input) {
19294
19369
  id
19370
+ publishChecks
19295
19371
  name
19296
19372
  organizationId
19297
19373
  createdAt
@@ -19873,7 +19949,7 @@ mutation ValidateAutomationPatchReadiness(
19873
19949
  branchContext: "optional",
19874
19950
  name: "apply-automation-patch",
19875
19951
  path: ["workbench", "patch", "apply"],
19876
- description: "Apply semantic workbench patch operations through the versioned save path.",
19952
+ description: "Apply semantic workbench patch operations through the versioned save path. Inspect publishChecks and repair blocking failures before completing the task.",
19877
19953
  resultKey: "applyAutomationPatch",
19878
19954
  options: [
19879
19955
  stringOption({
@@ -19897,6 +19973,7 @@ mutation ValidateAutomationPatchReadiness(
19897
19973
  },
19898
19974
  mcp: { fileName: "applyAutomationPatch.graphql" },
19899
19975
  document: `# Apply semantic automation patch operations through the versioned save path.
19976
+ # Inspect publishChecks after saving. Repair blocking failures and save again before completing the task; retry unknown checks.
19900
19977
  mutation ApplyAutomationPatch(
19901
19978
  $draftAutomationId: ID!
19902
19979
  $branchId: ID
@@ -19913,6 +19990,7 @@ mutation ApplyAutomationPatch(
19913
19990
  branchId
19914
19991
  headVersionId
19915
19992
  applied
19993
+ publishChecks
19916
19994
  updateInput
19917
19995
  before {
19918
19996
  name
@@ -19998,7 +20076,7 @@ mutation ApplyAutomationPatch(
19998
20076
  branchContext: "optional",
19999
20077
  name: "update-automation-by-id",
20000
20078
  path: ["automations", "update"],
20001
- description: "Update an automation.",
20079
+ description: "Update an automation. Inspect publishChecks and repair blocking failures before completing the task. Changing agent types is not supported. Do not attempt type changes or replacement workarounds.",
20002
20080
  resultKey: "updateAutomation",
20003
20081
  options: [
20004
20082
  stringOption({
@@ -20021,13 +20099,14 @@ mutation ApplyAutomationPatch(
20021
20099
  # If this mutation returns a draft-automation-version-conflict, discard the generated update, refetch the automation and agents, inspect what changed, then regenerate the update on top of the latest version.
20022
20100
  # config.storeSchema remains additive. Use removeStoreSchemaPaths to delete named properties (and combine it with config.storeSchema for an atomic rename), or replaceStoreSchema for an exact replacement. replaceStoreSchema cannot be combined with either of those fields.
20023
20101
  # Destructive Store schema changes are rejected when the final agent set still references a removed property. Rewrite those agent references in the same update or leave the property in place.
20024
- # Returns only id and lastSavedAt for MCP tool simplicity
20102
+ # Draft saves are allowed. Inspect publishChecks, repair blocking failures, and save again before completing the task. Unknown means checks must be retried.
20025
20103
  mutation UpdateAutomationById($id: ID!, $branchId: ID, $input: UpdateAutomationInput!) {
20026
20104
  updateAutomation(id: $id, branchId: $branchId, input: $input) {
20027
20105
  id
20028
20106
  branchId
20029
20107
  headVersionId
20030
20108
  lastSavedAt
20109
+ publishChecks
20031
20110
  }
20032
20111
  }`
20033
20112
  }),
@@ -21388,18 +21467,18 @@ async function downloadAuthenticatedFileFromApi({
21388
21467
  organizationId,
21389
21468
  outputPath,
21390
21469
  overwrite = false,
21391
- path: path20,
21470
+ path: path21,
21392
21471
  resolveApiBaseUrl,
21393
21472
  timeoutMs
21394
21473
  }) {
21395
- if (!path20.startsWith("/") || path20.startsWith("//")) {
21474
+ if (!path21.startsWith("/") || path21.startsWith("//")) {
21396
21475
  throw new CliError(
21397
21476
  "Authenticated file download path must be relative to the configured Magical API."
21398
21477
  );
21399
21478
  }
21400
21479
  const normalizedApiBaseUrl = trimTrailingSlash(await resolveApiBaseUrl());
21401
21480
  const apiBaseResult = safeUrlConstructor(`${normalizedApiBaseUrl}/`);
21402
- const urlResult = safeUrlConstructor(`${normalizedApiBaseUrl}${path20}`);
21481
+ const urlResult = safeUrlConstructor(`${normalizedApiBaseUrl}${path21}`);
21403
21482
  if (isErr(apiBaseResult) || isErr(urlResult) || urlResult.value.origin !== apiBaseResult.value.origin || !urlResult.value.pathname.startsWith(apiBaseResult.value.pathname)) {
21404
21483
  throw new CliError(
21405
21484
  "Authenticated file download path must stay within the configured Magical API."
@@ -21496,16 +21575,16 @@ function buildPathwayRegressionAgentVersionPath({
21496
21575
  leafPath,
21497
21576
  runsPerPath
21498
21577
  }) {
21499
- const path20 = `/pathway-regression/automation-versions/${encodeURIComponent(
21578
+ const path21 = `/pathway-regression/automation-versions/${encodeURIComponent(
21500
21579
  automationVersionId
21501
21580
  )}/agent-versions/${encodeURIComponent(agentVersionId)}/${leafPath}`;
21502
21581
  if (runsPerPath === void 0) {
21503
- return path20;
21582
+ return path21;
21504
21583
  }
21505
21584
  const queryParams = new URLSearchParams({
21506
21585
  runsPerPath: String(runsPerPath)
21507
21586
  });
21508
- return `${path20}?${queryParams.toString()}`;
21587
+ return `${path21}?${queryParams.toString()}`;
21509
21588
  }
21510
21589
  function applyAuthenticationHeaders({
21511
21590
  accessToken,
@@ -21541,11 +21620,11 @@ function createFetchJson({
21541
21620
  accessToken,
21542
21621
  impersonatedOrganizationId,
21543
21622
  allowOttoAuthorization,
21544
- path: path20,
21623
+ path: path21,
21545
21624
  init,
21546
21625
  organizationId
21547
21626
  }) {
21548
- const url = `${trimTrailingSlash(await resolveApiBaseUrl())}${path20}`;
21627
+ const url = `${trimTrailingSlash(await resolveApiBaseUrl())}${path21}`;
21549
21628
  const usesWorkOSApiKey = isWorkOSApiKey(accessToken);
21550
21629
  const headers = new Headers(init?.headers);
21551
21630
  applyAuthenticationHeaders({
@@ -21745,7 +21824,7 @@ function createMagicalApiClient({
21745
21824
  organizationId,
21746
21825
  outputPath,
21747
21826
  overwrite = false,
21748
- path: path20,
21827
+ path: path21,
21749
21828
  timeoutMs
21750
21829
  }) {
21751
21830
  await downloadAuthenticatedFileFromApi({
@@ -21758,7 +21837,7 @@ function createMagicalApiClient({
21758
21837
  ...maxSizeBytes === void 0 ? {} : { maxSizeBytes },
21759
21838
  outputPath,
21760
21839
  overwrite,
21761
- path: path20,
21840
+ path: path21,
21762
21841
  resolveApiBaseUrl,
21763
21842
  ...timeoutMs === void 0 ? {} : { timeoutMs }
21764
21843
  });
@@ -27188,6 +27267,140 @@ async function pollCaptureRecording({
27188
27267
  });
27189
27268
  }
27190
27269
 
27270
+ // src/classify-command.ts
27271
+ import { readFile as readFile3 } from "node:fs/promises";
27272
+ import path8 from "node:path";
27273
+ import { z as z36 } from "zod";
27274
+ var classifyRequestSchema = z36.object({
27275
+ model: z36.string().refine((model) => model.trim().length > 0, "Model must not be empty.").optional(),
27276
+ questions: z36.record(z36.string(), z36.unknown()).refine(
27277
+ (questions) => Object.keys(questions).length > 0,
27278
+ "Questions must contain at least one named question."
27279
+ ),
27280
+ state: z36.unknown()
27281
+ }).passthrough().refine((input) => Object.hasOwn(input, "state"), {
27282
+ message: "Classify input must include state.",
27283
+ path: ["state"]
27284
+ });
27285
+ var CLASSIFY_OPERATION_NAME = "Classify";
27286
+ var CLASSIFY_HELP_TEXT = `
27287
+ Classify input:
27288
+ Pass exactly one of --input-json, --input-file <path>, or --input-file - for stdin.
27289
+ All named questions share the supplied state and are answered independently.
27290
+ The backend defaults to jev-latest; set model in the request to select an explicit supported model.
27291
+ Noul values are probabilities, choice answers retain option probabilities, and scores may be fractional.
27292
+ Supply text or JSON evidence only; URLs and named files are not fetched. Output is always the full JSON response.
27293
+
27294
+ Examples:
27295
+ mgcl classify --input-file request.json
27296
+ mgcl classify --input-json '{"state":"Refund requested","questions":{"refund":{"type":"noul","instructions":"Is a refund requested?"}}}'
27297
+ cat request.json | mgcl classify --input-file -`;
27298
+ async function readStdin() {
27299
+ process.stdin.setEncoding("utf8");
27300
+ let contents = "";
27301
+ for await (const chunk of process.stdin) {
27302
+ if (typeof chunk !== "string") {
27303
+ throw new CliError("Classify stdin must be UTF-8 text.");
27304
+ }
27305
+ contents += chunk;
27306
+ }
27307
+ return contents;
27308
+ }
27309
+ async function readInputFile({
27310
+ inputFile,
27311
+ runtime
27312
+ }) {
27313
+ if (inputFile === "-") {
27314
+ return await (runtime.readStdin ?? readStdin)().catch(
27315
+ (error) => {
27316
+ throw new CliError("Failed to read classify input from stdin.", {
27317
+ cause: error
27318
+ });
27319
+ }
27320
+ );
27321
+ }
27322
+ const inputPath = path8.resolve(
27323
+ runtime.workingDirectory ?? process.cwd(),
27324
+ inputFile
27325
+ );
27326
+ return await readFile3(inputPath, "utf8").catch((error) => {
27327
+ throw new CliError(`Failed to read classify input file "${inputPath}".`, {
27328
+ cause: error
27329
+ });
27330
+ });
27331
+ }
27332
+ async function resolveClassifyVariables({
27333
+ inputFile,
27334
+ inputJson,
27335
+ runtime = {}
27336
+ }) {
27337
+ const hasInputFile = inputFile !== void 0;
27338
+ const hasInputJson = inputJson !== void 0;
27339
+ if (Number(hasInputFile) + Number(hasInputJson) !== 1) {
27340
+ throw new CliError(
27341
+ "Pass exactly one of --input-json or --input-file for classify input."
27342
+ );
27343
+ }
27344
+ let input = inputJson;
27345
+ if (hasInputFile) {
27346
+ if (typeof inputFile !== "string" || inputFile.length === 0) {
27347
+ throw new CliError("--input-file must name a JSON file or - for stdin.");
27348
+ }
27349
+ const contents = await readInputFile({ inputFile, runtime });
27350
+ const parsedJson = safeJsonParseWithoutLogging(contents);
27351
+ if (isErr(parsedJson)) {
27352
+ const source = inputFile === "-" ? "stdin" : `file "${inputFile}"`;
27353
+ throw new CliError(`Classify input from ${source} must be valid JSON.`, {
27354
+ cause: parsedJson.error
27355
+ });
27356
+ }
27357
+ input = parsedJson.value;
27358
+ } else if (typeof inputJson === "string") {
27359
+ const parsedJson = safeJsonParseWithoutLogging(inputJson);
27360
+ if (isErr(parsedJson)) {
27361
+ throw new CliError(
27362
+ "Classify input from --input-json must be valid JSON.",
27363
+ {
27364
+ cause: parsedJson.error
27365
+ }
27366
+ );
27367
+ }
27368
+ input = parsedJson.value;
27369
+ }
27370
+ const parsedInput = classifyRequestSchema.safeParse(input);
27371
+ if (!parsedInput.success) {
27372
+ throw new CliError(
27373
+ parsedInput.error.issues[0]?.message ?? "Classify input must be a JSON object containing state and questions."
27374
+ );
27375
+ }
27376
+ return { input: parsedInput.data };
27377
+ }
27378
+ async function resolveClassifyOperationVariables({
27379
+ defaultVariables,
27380
+ operationName,
27381
+ options,
27382
+ runtime,
27383
+ workingDirectory
27384
+ }) {
27385
+ if (operationName !== CLASSIFY_OPERATION_NAME) {
27386
+ return defaultVariables;
27387
+ }
27388
+ return await resolveClassifyVariables({
27389
+ inputFile: options["inputFile"],
27390
+ inputJson: options["inputJson"],
27391
+ runtime: {
27392
+ ...runtime,
27393
+ workingDirectory: runtime?.workingDirectory ?? workingDirectory
27394
+ }
27395
+ });
27396
+ }
27397
+ function configureClassifyHelp(command, operationName) {
27398
+ if (operationName === CLASSIFY_OPERATION_NAME) {
27399
+ command.addHelpText("after", CLASSIFY_HELP_TEXT);
27400
+ command.setOptionValueWithSource("json", true, "default");
27401
+ }
27402
+ }
27403
+
27191
27404
  // src/cli-io.ts
27192
27405
  function createConsoleIo() {
27193
27406
  return {
@@ -27204,53 +27417,53 @@ function createConsoleIo() {
27204
27417
 
27205
27418
  // src/eval-commands.ts
27206
27419
  import { randomUUID as randomUUID4 } from "node:crypto";
27207
- import { access as access2, readFile as readFile3 } from "node:fs/promises";
27208
- import path8 from "node:path";
27420
+ import { access as access2, readFile as readFile4 } from "node:fs/promises";
27421
+ import path9 from "node:path";
27209
27422
  import { createInterface } from "node:readline/promises";
27210
- import { z as z36 } from "zod";
27423
+ import { z as z37 } from "zod";
27211
27424
  var MAX_AWAIT_REQUEST_MS = 6e4;
27212
27425
  var MIN_AWAIT_REQUEST_MS = 1e3;
27213
27426
  var EXPORT_POLL_INTERVAL_MS = 1e3;
27214
- var evalRunStatusSchema2 = z36.enum([
27427
+ var evalRunStatusSchema2 = z37.enum([
27215
27428
  "QUEUED",
27216
27429
  "RUNNING",
27217
27430
  "COMPLETE",
27218
27431
  "FAILED",
27219
27432
  "CANCELLED"
27220
27433
  ]);
27221
- var awaitResultSchema = z36.object({
27222
- elapsedMs: z36.number().nonnegative(),
27223
- evalRun: z36.object({
27224
- id: z36.string().min(1),
27434
+ var awaitResultSchema = z37.object({
27435
+ elapsedMs: z37.number().nonnegative(),
27436
+ evalRun: z37.object({
27437
+ id: z37.string().min(1),
27225
27438
  status: evalRunStatusSchema2
27226
27439
  }).passthrough(),
27227
- pollCount: z36.number().int().nonnegative(),
27228
- reachedTerminal: z36.boolean()
27440
+ pollCount: z37.number().int().nonnegative(),
27441
+ reachedTerminal: z37.boolean()
27229
27442
  }).passthrough();
27230
- var planResultSchema = z36.object({ trialCount: z36.number().int().nonnegative() }).passthrough();
27231
- var startResultSchema = z36.object({
27232
- evalRunId: z36.string().min(1),
27233
- idempotencyKey: z36.string().min(1),
27234
- workflowId: z36.string().min(1),
27235
- workflowRunId: z36.string().min(1)
27443
+ var planResultSchema = z37.object({ trialCount: z37.number().int().nonnegative() }).passthrough();
27444
+ var startResultSchema = z37.object({
27445
+ evalRunId: z37.string().min(1),
27446
+ idempotencyKey: z37.string().min(1),
27447
+ workflowId: z37.string().min(1),
27448
+ workflowRunId: z37.string().min(1)
27236
27449
  }).passthrough();
27237
- var exportResultSchema = z36.object({
27238
- downloadUrl: z36.string().min(1).nullable().optional(),
27239
- evalRunId: z36.string().min(1),
27240
- exportId: z36.string().min(1),
27241
- status: z36.enum(["QUEUED", "RUNNING", "COMPLETE", "FAILED"])
27450
+ var exportResultSchema = z37.object({
27451
+ downloadUrl: z37.string().min(1).nullable().optional(),
27452
+ evalRunId: z37.string().min(1),
27453
+ exportId: z37.string().min(1),
27454
+ status: z37.enum(["QUEUED", "RUNNING", "COMPLETE", "FAILED"])
27242
27455
  }).passthrough();
27243
- var inputOptionsSchema = z36.object({
27244
- inputFile: z36.string().min(1).optional(),
27245
- inputJson: z36.unknown().optional()
27456
+ var inputOptionsSchema = z37.object({
27457
+ inputFile: z37.string().min(1).optional(),
27458
+ inputJson: z37.unknown().optional()
27246
27459
  });
27247
27460
  var commonRunOptionsSchema = inputOptionsSchema.extend({
27248
- description: z36.string().min(1).optional(),
27249
- maxConcurrency: z36.number().int().positive().optional(),
27250
- name: z36.string().min(1).optional(),
27251
- repeatCount: z36.number().int().positive().optional(),
27252
- slug: z36.string().min(1),
27253
- tags: z36.array(z36.string().min(1)).optional()
27461
+ description: z37.string().min(1).optional(),
27462
+ maxConcurrency: z37.number().int().positive().optional(),
27463
+ name: z37.string().min(1).optional(),
27464
+ repeatCount: z37.number().int().positive().optional(),
27465
+ slug: z37.string().min(1),
27466
+ tags: z37.array(z37.string().min(1)).optional()
27254
27467
  });
27255
27468
  function parseApiResult(value, schema, label) {
27256
27469
  const parsedResult = schema.safeParse(value);
@@ -27263,8 +27476,8 @@ async function parseInputFile({
27263
27476
  inputFile,
27264
27477
  workingDirectory
27265
27478
  }) {
27266
- const inputPath = path8.resolve(workingDirectory, inputFile);
27267
- const contents = await readFile3(inputPath, "utf8").catch(
27479
+ const inputPath = path9.resolve(workingDirectory, inputFile);
27480
+ const contents = await readFile4(inputPath, "utf8").catch(
27268
27481
  (error) => {
27269
27482
  throw new CliError(`Failed to read eval input file "${inputPath}".`, {
27270
27483
  cause: error
@@ -27292,7 +27505,7 @@ async function resolveEvalInput({
27292
27505
  );
27293
27506
  }
27294
27507
  const input = inputFile === void 0 ? inputJson : await parseInputFile({ inputFile, workingDirectory });
27295
- const parsedInput = z36.record(z36.string(), z36.unknown()).safeParse(input);
27508
+ const parsedInput = z37.record(z37.string(), z37.unknown()).safeParse(input);
27296
27509
  if (!parsedInput.success) {
27297
27510
  throw new CliError("Eval input must be a JSON object.");
27298
27511
  }
@@ -27329,7 +27542,7 @@ function parseDurationMs(value) {
27329
27542
  );
27330
27543
  const amount = Number(match?.groups?.["amount"]);
27331
27544
  const multiplierByUnit = { h: 36e5, m: 6e4, ms: 1, s: 1e3 };
27332
- const parsedUnit = z36.enum(["h", "m", "ms", "s"]).safeParse(match?.groups?.["unit"]?.toLowerCase());
27545
+ const parsedUnit = z37.enum(["h", "m", "ms", "s"]).safeParse(match?.groups?.["unit"]?.toLowerCase());
27333
27546
  const durationMs = parsedUnit.success ? amount * multiplierByUnit[parsedUnit.data] : Number.NaN;
27334
27547
  if (!Number.isSafeInteger(durationMs) || durationMs < MIN_AWAIT_REQUEST_MS) {
27335
27548
  throw new CliError(
@@ -27538,10 +27751,10 @@ async function executeStartRegisteredEvalRun({
27538
27751
  workingDirectory
27539
27752
  }) {
27540
27753
  const parsedOptions = commonRunOptionsSchema.extend({
27541
- confirmTrials: z36.number().int().positive().optional(),
27542
- idempotencyKey: z36.string().trim().min(1).optional(),
27543
- json: z36.boolean().optional(),
27544
- wait: z36.boolean().optional()
27754
+ confirmTrials: z37.number().int().positive().optional(),
27755
+ idempotencyKey: z37.string().trim().min(1).optional(),
27756
+ json: z37.boolean().optional(),
27757
+ wait: z37.boolean().optional()
27545
27758
  }).parse(options);
27546
27759
  const input = await resolveEvalInputFromOptions({
27547
27760
  ...parsedOptions,
@@ -27601,7 +27814,7 @@ async function executeAwaitEvalRun({
27601
27814
  options,
27602
27815
  runtime
27603
27816
  }) {
27604
- const parsedOptions = z36.object({ id: z36.string().min(1), timeout: z36.string().optional() }).parse(options);
27817
+ const parsedOptions = z37.object({ id: z37.string().min(1), timeout: z37.string().optional() }).parse(options);
27605
27818
  return await awaitEvalRun({
27606
27819
  evalRunId: parsedOptions.id,
27607
27820
  executeOperation,
@@ -27620,13 +27833,13 @@ async function executeRequestEvalRunExport({
27620
27833
  runtime,
27621
27834
  workingDirectory
27622
27835
  }) {
27623
- const parsedOptions = z36.object({
27624
- force: z36.boolean().optional(),
27625
- id: z36.string().min(1),
27626
- output: z36.string().min(1),
27627
- wait: z36.boolean().optional()
27836
+ const parsedOptions = z37.object({
27837
+ force: z37.boolean().optional(),
27838
+ id: z37.string().min(1),
27839
+ output: z37.string().min(1),
27840
+ wait: z37.boolean().optional()
27628
27841
  }).parse(options);
27629
- const outputPath = path8.resolve(workingDirectory, parsedOptions.output);
27842
+ const outputPath = path9.resolve(workingDirectory, parsedOptions.output);
27630
27843
  const force = parsedOptions.force === true;
27631
27844
  const shouldWait = parsedOptions.wait === true;
27632
27845
  if (shouldWait) {
@@ -27692,28 +27905,28 @@ async function executeEvalCliOperation({
27692
27905
  // src/file-upload-commands.ts
27693
27906
  import { createReadStream as createReadStream2 } from "node:fs";
27694
27907
  import { stat as stat2 } from "node:fs/promises";
27695
- import path9 from "node:path";
27908
+ import path10 from "node:path";
27696
27909
  import mimeTypes from "mime-types";
27697
- import { z as z37 } from "zod";
27698
- var fileUploadIntentSchema = z37.object({
27699
- file: z37.object({
27700
- checksum: z37.object({
27701
- algorithm: z37.literal("CRC32"),
27702
- value: z37.string().min(1)
27910
+ import { z as z38 } from "zod";
27911
+ var fileUploadIntentSchema = z38.object({
27912
+ file: z38.object({
27913
+ checksum: z38.object({
27914
+ algorithm: z38.literal("CRC32"),
27915
+ value: z38.string().min(1)
27703
27916
  }),
27704
- key: z37.string().startsWith("s3://"),
27705
- mimeType: z37.string().min(1),
27706
- name: z37.string().min(1),
27707
- sizeBytes: z37.number().int().nonnegative()
27917
+ key: z38.string().startsWith("s3://"),
27918
+ mimeType: z38.string().min(1),
27919
+ name: z38.string().min(1),
27920
+ sizeBytes: z38.number().int().nonnegative()
27708
27921
  }),
27709
- upload: z37.object({
27710
- headers: z37.record(z37.string(), z37.string()),
27711
- method: z37.literal("PUT"),
27712
- url: z37.url()
27922
+ upload: z38.object({
27923
+ headers: z38.record(z38.string(), z38.string()),
27924
+ method: z38.literal("PUT"),
27925
+ url: z38.url()
27713
27926
  })
27714
27927
  });
27715
27928
  async function prepareFileUpload(inputPath, workingDirectory) {
27716
- const filePath = path9.resolve(workingDirectory, inputPath);
27929
+ const filePath = path10.resolve(workingDirectory, inputPath);
27717
27930
  const fileStats = await stat2(filePath).catch((error) => {
27718
27931
  throw new CliError(`Failed to inspect upload file "${filePath}".`, {
27719
27932
  cause: error
@@ -27752,7 +27965,7 @@ async function prepareFileUpload(inputPath, workingDirectory) {
27752
27965
  variables: {
27753
27966
  checksum: encodeS3Crc32Checksum(checksum),
27754
27967
  mimeType: mimeTypes.lookup(filePath) || "application/octet-stream",
27755
- name: path9.basename(filePath),
27968
+ name: path10.basename(filePath),
27756
27969
  sizeBytes: fileStats.size
27757
27970
  }
27758
27971
  };
@@ -27798,20 +28011,20 @@ async function handleFileUploadCliOperation(apiClient, intent, prepared) {
27798
28011
  }
27799
28012
 
27800
28013
  // src/iteration-media-commands.ts
27801
- import path12 from "node:path";
27802
- import { z as z40 } from "zod";
28014
+ import path13 from "node:path";
28015
+ import { z as z41 } from "zod";
27803
28016
 
27804
28017
  // src/file-commands.ts
27805
- import path10 from "node:path";
27806
- import { z as z38 } from "zod";
27807
- var fileAssetAccessSchema = z38.object({
27808
- status: z38.enum([
28018
+ import path11 from "node:path";
28019
+ import { z as z39 } from "zod";
28020
+ var fileAssetAccessSchema = z39.object({
28021
+ status: z39.enum([
27809
28022
  "AVAILABLE",
27810
28023
  "INVALID_KEY",
27811
28024
  "NOT_FOUND",
27812
28025
  "URL_UNAVAILABLE"
27813
28026
  ]),
27814
- url: z38.string().url().nullable()
28027
+ url: z39.string().url().nullable()
27815
28028
  }).superRefine((value, ctx) => {
27816
28029
  if (value.status === "AVAILABLE" && value.url === null) {
27817
28030
  ctx.addIssue({
@@ -27821,13 +28034,13 @@ var fileAssetAccessSchema = z38.object({
27821
28034
  });
27822
28035
  }
27823
28036
  });
27824
- var fileCommandOptionsSchema = z38.object({
27825
- download: z38.string().min(1).optional(),
27826
- force: z38.boolean().optional(),
27827
- key: z38.string().min(1)
28037
+ var fileCommandOptionsSchema = z39.object({
28038
+ download: z39.string().min(1).optional(),
28039
+ force: z39.boolean().optional(),
28040
+ key: z39.string().min(1)
27828
28041
  });
27829
28042
  function sanitizeDownloadFileName(fileName, fallback = "magical-file.bin") {
27830
- const sanitizedFileName = path10.basename(fileName).replaceAll(/[^\p{L}\p{N}._-]/gu, "_").slice(0, 160);
28043
+ const sanitizedFileName = path11.basename(fileName).replaceAll(/[^\p{L}\p{N}._-]/gu, "_").slice(0, 160);
27831
28044
  return sanitizedFileName && sanitizedFileName !== "." && sanitizedFileName !== ".." ? sanitizedFileName : fallback;
27832
28045
  }
27833
28046
  function getSafeFileName(fileKey) {
@@ -27849,7 +28062,7 @@ async function downloadFileToLocalPath({
27849
28062
  "File download is not configured for this CLI instance."
27850
28063
  );
27851
28064
  }
27852
- const outputPath = path10.resolve(
28065
+ const outputPath = path11.resolve(
27853
28066
  runtime.workingDirectory,
27854
28067
  destination ?? sanitizeDownloadFileName(fallbackFileName)
27855
28068
  );
@@ -27895,19 +28108,19 @@ async function handleFileCliOperation({
27895
28108
  }
27896
28109
 
27897
28110
  // src/repository-file-commands.ts
27898
- import path11 from "node:path";
27899
- import { z as z39 } from "zod";
28111
+ import path12 from "node:path";
28112
+ import { z as z40 } from "zod";
27900
28113
  var repositoryFileOperationNames = /* @__PURE__ */ new Set(["KnowledgeFile", "MemoryFile"]);
27901
- var repositoryFileOptionsSchema = z39.object({
27902
- download: z39.string().min(1),
27903
- force: z39.boolean().optional(),
27904
- key: z39.string().min(1)
28114
+ var repositoryFileOptionsSchema = z40.object({
28115
+ download: z40.string().min(1),
28116
+ force: z40.boolean().optional(),
28117
+ key: z40.string().min(1)
27905
28118
  });
27906
- var repositoryFileAccessSchema = z39.object({
27907
- commit: z39.string().regex(/^[\da-f]{40}$/u).nullable(),
27908
- path: z39.string().min(1).nullable(),
27909
- status: z39.enum(["AVAILABLE", "INVALID_KEY", "NOT_FOUND", "UNAVAILABLE"]),
27910
- url: z39.url().nullable()
28119
+ var repositoryFileAccessSchema = z40.object({
28120
+ commit: z40.string().regex(/^[\da-f]{40}$/u).nullable(),
28121
+ path: z40.string().min(1).nullable(),
28122
+ status: z40.enum(["AVAILABLE", "INVALID_KEY", "NOT_FOUND", "UNAVAILABLE"]),
28123
+ url: z40.url().nullable()
27911
28124
  }).superRefine((value, ctx) => {
27912
28125
  if (value.status === "AVAILABLE" && (value.url === null || value.path === null || value.commit === null)) {
27913
28126
  ctx.addIssue({
@@ -27944,7 +28157,7 @@ async function handleRepositoryFileCliOperation({
27944
28157
  }
27945
28158
  const outputPath = await downloadFileToLocalPath({
27946
28159
  destination: parsedOptions.download,
27947
- fallbackFileName: path11.basename(repositoryPath),
28160
+ fallbackFileName: path12.basename(repositoryPath),
27948
28161
  force: parsedOptions.force === true,
27949
28162
  runtime,
27950
28163
  url
@@ -27959,14 +28172,14 @@ async function handleRepositoryFileCliOperation({
27959
28172
  }
27960
28173
 
27961
28174
  // src/iteration-media-commands.ts
27962
- var iterationMediaOptionsSchema = z40.object({
27963
- download: z40.string().min(1),
27964
- force: z40.boolean().optional(),
27965
- iterationId: z40.uuid(),
27966
- mediaId: z40.uuid()
28175
+ var iterationMediaOptionsSchema = z41.object({
28176
+ download: z41.string().min(1),
28177
+ force: z41.boolean().optional(),
28178
+ iterationId: z41.uuid(),
28179
+ mediaId: z41.uuid()
27967
28180
  });
27968
- var iterationMediaAccessSchema = z40.object({
27969
- downloadPath: z40.string().min(1)
28181
+ var iterationMediaAccessSchema = z41.object({
28182
+ downloadPath: z41.string().min(1)
27970
28183
  });
27971
28184
  async function handleIterationMediaCliOperation({
27972
28185
  accessToken,
@@ -27997,7 +28210,7 @@ async function handleIterationMediaCliOperation({
27997
28210
  "Authenticated file download is not configured for this CLI instance."
27998
28211
  );
27999
28212
  }
28000
- const outputPath = path12.resolve(workingDirectory, parsedOptions.download);
28213
+ const outputPath = path13.resolve(workingDirectory, parsedOptions.download);
28001
28214
  const downloadResult = await fromThrowable(async () => {
28002
28215
  await downloadAuthenticatedFile({
28003
28216
  accessToken,
@@ -28111,16 +28324,16 @@ import { randomUUID as randomUUID5 } from "node:crypto";
28111
28324
  import { createReadStream as createReadStream3, createWriteStream as createWriteStream2 } from "node:fs";
28112
28325
  import { link as link3, mkdir as mkdir3, mkdtemp, rm as rm3 } from "node:fs/promises";
28113
28326
  import os2 from "node:os";
28114
- import path14 from "node:path";
28327
+ import path15 from "node:path";
28115
28328
  import { pipeline as pipeline2 } from "node:stream/promises";
28116
28329
  import { Command as Command3, InvalidArgumentError, Option as Option3 } from "commander";
28117
28330
 
28118
28331
  // src/network-recording-parser.ts
28119
28332
  import { spawn } from "node:child_process";
28120
28333
  import { existsSync } from "node:fs";
28121
- import path13 from "node:path";
28334
+ import path14 from "node:path";
28122
28335
  import { fileURLToPath as fileURLToPath2 } from "node:url";
28123
- import { z as z41 } from "zod";
28336
+ import { z as z42 } from "zod";
28124
28337
  var NETWORK_RECORDING_ARCHIVE_MAX_BYTES = 256 * 1024 * 1024;
28125
28338
  var NETWORK_RECORDING_MAX_FLOWS = 2e4;
28126
28339
  var NETWORK_RECORDING_MAX_ENCODED_BODY_BYTES = 32 * 1024 * 1024;
@@ -28132,57 +28345,57 @@ var DEFAULT_MAX_EXCHANGES = 100;
28132
28345
  var MAX_EXCHANGES = 1e3;
28133
28346
  var MAX_HELPER_OUTPUT_BYTES = 1024 * 1024;
28134
28347
  var PYTHON_ENVIRONMENT_VARIABLE = "MGCL_MITMPROXY_PYTHON";
28135
- var archiveIdentitySchema = z41.object({
28136
- sha256: z41.string().regex(/^[0-9a-f]{64}$/u),
28137
- sizeBytes: z41.number().int().nonnegative()
28138
- });
28139
- var bodyMetadataSchema = z41.object({
28140
- state: z41.enum(["PRESENT", "EMPTY", "MISSING"]),
28141
- encodedSizeBytes: z41.number().int().nonnegative().nullable()
28142
- });
28143
- var exchangeSchema = z41.object({
28144
- exchange: z41.string().regex(/^mitm-v1:[0-9a-f]{64}:[0-9]+$/u),
28145
- index: z41.number().int().nonnegative(),
28146
- method: z41.string().min(1),
28147
- origin: z41.string().min(1),
28148
- timestamp: z41.string().nullable(),
28149
- response: z41.object({
28150
- status: z41.number().int(),
28151
- contentType: z41.string().nullable(),
28348
+ var archiveIdentitySchema = z42.object({
28349
+ sha256: z42.string().regex(/^[0-9a-f]{64}$/u),
28350
+ sizeBytes: z42.number().int().nonnegative()
28351
+ });
28352
+ var bodyMetadataSchema = z42.object({
28353
+ state: z42.enum(["PRESENT", "EMPTY", "MISSING"]),
28354
+ encodedSizeBytes: z42.number().int().nonnegative().nullable()
28355
+ });
28356
+ var exchangeSchema = z42.object({
28357
+ exchange: z42.string().regex(/^mitm-v1:[0-9a-f]{64}:[0-9]+$/u),
28358
+ index: z42.number().int().nonnegative(),
28359
+ method: z42.string().min(1),
28360
+ origin: z42.string().min(1),
28361
+ timestamp: z42.string().nullable(),
28362
+ response: z42.object({
28363
+ status: z42.number().int(),
28364
+ contentType: z42.string().nullable(),
28152
28365
  body: bodyMetadataSchema
28153
28366
  }).nullable()
28154
28367
  });
28155
- var inspectionResultSchema = z41.object({
28368
+ var inspectionResultSchema = z42.object({
28156
28369
  archive: archiveIdentitySchema,
28157
- exchanges: z41.array(exchangeSchema),
28158
- scan: z41.object({
28159
- scannedFlowCount: z41.number().int().nonnegative(),
28160
- returnedExchangeCount: z41.number().int().nonnegative(),
28161
- complete: z41.boolean(),
28162
- resultLimit: z41.number().int().positive(),
28163
- flowLimit: z41.number().int().positive(),
28164
- truncationReason: z41.enum(["RESULT_LIMIT", "FLOW_LIMIT"]).nullable()
28370
+ exchanges: z42.array(exchangeSchema),
28371
+ scan: z42.object({
28372
+ scannedFlowCount: z42.number().int().nonnegative(),
28373
+ returnedExchangeCount: z42.number().int().nonnegative(),
28374
+ complete: z42.boolean(),
28375
+ resultLimit: z42.number().int().positive(),
28376
+ flowLimit: z42.number().int().positive(),
28377
+ truncationReason: z42.enum(["RESULT_LIMIT", "FLOW_LIMIT"]).nullable()
28165
28378
  })
28166
28379
  });
28167
- var extractionResultSchema = z41.object({
28380
+ var extractionResultSchema = z42.object({
28168
28381
  archive: archiveIdentitySchema,
28169
- exchange: z41.string().regex(/^mitm-v1:[0-9a-f]{64}:[0-9]+$/u),
28170
- index: z41.number().int().nonnegative(),
28171
- response: z41.object({
28172
- contentType: z41.string().nullable(),
28173
- sourceContentEncoding: z41.string().nullable(),
28174
- representation: z41.literal("decoded-entity-body"),
28175
- encodedSizeBytes: z41.number().int().nonnegative(),
28176
- sizeBytes: z41.number().int().nonnegative(),
28177
- sha256: z41.string().regex(/^[0-9a-f]{64}$/u)
28382
+ exchange: z42.string().regex(/^mitm-v1:[0-9a-f]{64}:[0-9]+$/u),
28383
+ index: z42.number().int().nonnegative(),
28384
+ response: z42.object({
28385
+ contentType: z42.string().nullable(),
28386
+ sourceContentEncoding: z42.string().nullable(),
28387
+ representation: z42.literal("decoded-entity-body"),
28388
+ encodedSizeBytes: z42.number().int().nonnegative(),
28389
+ sizeBytes: z42.number().int().nonnegative(),
28390
+ sha256: z42.string().regex(/^[0-9a-f]{64}$/u)
28178
28391
  }),
28179
- outputPath: z41.string().min(1)
28392
+ outputPath: z42.string().min(1)
28180
28393
  });
28181
- var helperResponseSchema = z41.union([
28182
- z41.object({ ok: z41.literal(true), result: z41.unknown() }),
28183
- z41.object({
28184
- ok: z41.literal(false),
28185
- error: z41.object({ code: z41.string().min(1), message: z41.string().min(1) })
28394
+ var helperResponseSchema = z42.union([
28395
+ z42.object({ ok: z42.literal(true), result: z42.unknown() }),
28396
+ z42.object({
28397
+ ok: z42.literal(false),
28398
+ error: z42.object({ code: z42.string().min(1), message: z42.string().min(1) })
28186
28399
  })
28187
28400
  ]);
28188
28401
  var NetworkRecordingParserError = class extends CliError {
@@ -28194,12 +28407,12 @@ var NetworkRecordingParserError = class extends CliError {
28194
28407
  }
28195
28408
  };
28196
28409
  function helperPath() {
28197
- const moduleDirectory = path13.dirname(fileURLToPath2(import.meta.url));
28198
- const bundledPath = path13.resolve(
28410
+ const moduleDirectory = path14.dirname(fileURLToPath2(import.meta.url));
28411
+ const bundledPath = path14.resolve(
28199
28412
  moduleDirectory,
28200
28413
  "network-recording-archive.py"
28201
28414
  );
28202
- return existsSync(bundledPath) ? bundledPath : path13.resolve(moduleDirectory, "../scripts/network-recording-archive.py");
28415
+ return existsSync(bundledPath) ? bundledPath : path14.resolve(moduleDirectory, "../scripts/network-recording-archive.py");
28203
28416
  }
28204
28417
  function pythonCandidates() {
28205
28418
  const configuredPython = getRuntimeEnvironment()[PYTHON_ENVIRONMENT_VARIABLE];
@@ -28513,11 +28726,11 @@ async function installPrivateOutput({
28513
28726
  destination,
28514
28727
  source
28515
28728
  }) {
28516
- const outputPath = path14.resolve(destination);
28517
- await mkdir3(path14.dirname(outputPath), { recursive: true });
28518
- const temporaryPath = path14.join(
28519
- path14.dirname(outputPath),
28520
- `.${path14.basename(outputPath)}.${randomUUID5()}.tmp`
28729
+ const outputPath = path15.resolve(destination);
28730
+ await mkdir3(path15.dirname(outputPath), { recursive: true });
28731
+ const temporaryPath = path15.join(
28732
+ path15.dirname(outputPath),
28733
+ `.${path15.basename(outputPath)}.${randomUUID5()}.tmp`
28521
28734
  );
28522
28735
  await pipeline2(
28523
28736
  createReadStream3(source),
@@ -28547,9 +28760,9 @@ async function withPrivateArchive({
28547
28760
  recording
28548
28761
  }) {
28549
28762
  const temporaryDirectory = await mkdtemp(
28550
- path14.join(os2.tmpdir(), "mgcl-network-recording-")
28763
+ path15.join(os2.tmpdir(), "mgcl-network-recording-")
28551
28764
  );
28552
- const archivePath = path14.join(temporaryDirectory, "recording.mitm");
28765
+ const archivePath = path15.join(temporaryDirectory, "recording.mitm");
28553
28766
  try {
28554
28767
  await downloadRecording({
28555
28768
  dependencies,
@@ -28597,7 +28810,7 @@ function addNetworkRecordingCommands({
28597
28810
  });
28598
28811
  const result = getSafeMetadata(recording.metadata);
28599
28812
  if (options.output) {
28600
- const outputPath = path14.resolve(
28813
+ const outputPath = path15.resolve(
28601
28814
  dependencies.workingDirectory ?? process.cwd(),
28602
28815
  options.output
28603
28816
  );
@@ -28678,11 +28891,11 @@ function addNetworkRecordingCommands({
28678
28891
  {
28679
28892
  archivePath,
28680
28893
  exchange: options.exchange,
28681
- outputPath: path14.join(temporaryDirectory, "response-body")
28894
+ outputPath: path15.join(temporaryDirectory, "response-body")
28682
28895
  }
28683
28896
  );
28684
28897
  const outputPath = await installPrivateOutput({
28685
- destination: path14.resolve(
28898
+ destination: path15.resolve(
28686
28899
  dependencies.workingDirectory ?? process.cwd(),
28687
28900
  options.output
28688
28901
  ),
@@ -29026,29 +29239,29 @@ ${formatExamples("Examples", [
29026
29239
 
29027
29240
  // src/run-evidence-commands.ts
29028
29241
  import { Option as Option5 } from "commander";
29029
- import { z as z42 } from "zod";
29242
+ import { z as z43 } from "zod";
29030
29243
  var ITERATION_PAGE_SIZE = 100;
29031
29244
  var MAX_SCANNED_ITERATIONS = 1e4;
29032
- var automationRunSchema = z42.object({
29033
- id: z42.string().min(1),
29034
- input: z42.unknown().nullable()
29245
+ var automationRunSchema = z43.object({
29246
+ id: z43.string().min(1),
29247
+ input: z43.unknown().nullable()
29035
29248
  }).passthrough();
29036
- var agentRunSchema = z42.object({
29037
- id: z42.string().min(1),
29038
- input: z42.unknown().nullable(),
29039
- parentAgentRunId: z42.string().nullable()
29249
+ var agentRunSchema = z43.object({
29250
+ id: z43.string().min(1),
29251
+ input: z43.unknown().nullable(),
29252
+ parentAgentRunId: z43.string().nullable()
29040
29253
  }).passthrough();
29041
- var memorySchema = z42.object({
29042
- id: z42.string().min(1),
29043
- sequence: z42.number().int(),
29044
- type: z42.string(),
29045
- value: z42.unknown()
29254
+ var memorySchema = z43.object({
29255
+ id: z43.string().min(1),
29256
+ sequence: z43.number().int(),
29257
+ type: z43.string(),
29258
+ value: z43.unknown()
29046
29259
  }).passthrough();
29047
- var iterationSchema = z42.object({
29048
- agentRunId: z42.string().min(1),
29049
- id: z42.string().min(1),
29050
- memories: z42.array(memorySchema),
29051
- sequence: z42.number().int()
29260
+ var iterationSchema = z43.object({
29261
+ agentRunId: z43.string().min(1),
29262
+ id: z43.string().min(1),
29263
+ memories: z43.array(memorySchema),
29264
+ sequence: z43.number().int()
29052
29265
  }).passthrough();
29053
29266
  var latestIterationSchema = iterationSchema.nullable();
29054
29267
  var GET_AUTOMATION_RUN_FILE_INPUT_DOCUMENT = `
@@ -29203,21 +29416,21 @@ function collectIterationOccurrences(iteration) {
29203
29416
  function formatRunFiles(result) {
29204
29417
  const parsed = parseOperationResult(
29205
29418
  result,
29206
- z42.object({
29207
- automationRunId: z42.string(),
29208
- files: z42.array(
29209
- z42.object({
29210
- agentRunId: z42.string().nullable(),
29211
- fieldPath: z42.string(),
29212
- iterationId: z42.string().nullable(),
29213
- key: z42.string(),
29214
- role: z42.string(),
29215
- source: z42.string(),
29216
- toolName: z42.string().nullable()
29419
+ z43.object({
29420
+ automationRunId: z43.string(),
29421
+ files: z43.array(
29422
+ z43.object({
29423
+ agentRunId: z43.string().nullable(),
29424
+ fieldPath: z43.string(),
29425
+ iterationId: z43.string().nullable(),
29426
+ key: z43.string(),
29427
+ role: z43.string(),
29428
+ source: z43.string(),
29429
+ toolName: z43.string().nullable()
29217
29430
  })
29218
29431
  ),
29219
- scannedIterationCount: z42.number(),
29220
- truncated: z42.boolean()
29432
+ scannedIterationCount: z43.number(),
29433
+ truncated: z43.boolean()
29221
29434
  }),
29222
29435
  "Run file inventory"
29223
29436
  );
@@ -29242,9 +29455,9 @@ function formatRunFiles(result) {
29242
29455
  function formatAgentRunOutput(result) {
29243
29456
  const parsed = parseOperationResult(
29244
29457
  result,
29245
- z42.object({
29246
- output: z42.unknown(),
29247
- status: z42.enum(["AVAILABLE", "NOT_FOUND"])
29458
+ z43.object({
29459
+ output: z43.unknown(),
29460
+ status: z43.enum(["AVAILABLE", "NOT_FOUND"])
29248
29461
  }),
29249
29462
  "Agent run output"
29250
29463
  );
@@ -29303,7 +29516,7 @@ async function handleAutomationRunFiles({
29303
29516
  );
29304
29517
  const agentRuns = parseOperationResult(
29305
29518
  agentRunsResult,
29306
- z42.array(agentRunSchema),
29519
+ z43.array(agentRunSchema),
29307
29520
  "Automation run agent runs"
29308
29521
  );
29309
29522
  const iterations = [];
@@ -29322,7 +29535,7 @@ async function handleAutomationRunFiles({
29322
29535
  });
29323
29536
  const parsedPage = parseOperationResult(
29324
29537
  pageResult,
29325
- z42.array(iterationSchema),
29538
+ z43.array(iterationSchema),
29326
29539
  "Automation run iterations"
29327
29540
  );
29328
29541
  iterations.push(...parsedPage);
@@ -29343,7 +29556,7 @@ async function handleAutomationRunFiles({
29343
29556
  });
29344
29557
  truncated = parseOperationResult(
29345
29558
  peekResult,
29346
- z42.array(iterationSchema),
29559
+ z43.array(iterationSchema),
29347
29560
  "Automation run iterations"
29348
29561
  ).length > 0;
29349
29562
  }
@@ -29476,7 +29689,7 @@ function addRunEvidenceCommands({
29476
29689
  // src/self-update.ts
29477
29690
  import { spawn as spawn3 } from "node:child_process";
29478
29691
  import fs2 from "node:fs";
29479
- import path15 from "node:path";
29692
+ import path16 from "node:path";
29480
29693
  import { fileURLToPath as fileURLToPath3 } from "node:url";
29481
29694
  var CLI_PACKAGE_NAME = "@getmagical/cli";
29482
29695
  var DEFAULT_CLI_DIST_TAG2 = "latest";
@@ -29487,9 +29700,9 @@ function resolveInstalledPackageRoot({
29487
29700
  packageName
29488
29701
  }) {
29489
29702
  const packagePathSegments = packageName.split("/");
29490
- let currentPath = path15.dirname(entryFilePath);
29703
+ let currentPath = path16.dirname(entryFilePath);
29491
29704
  for (; ; ) {
29492
- const currentPathSegments = currentPath.split(path15.sep).filter(Boolean);
29705
+ const currentPathSegments = currentPath.split(path16.sep).filter(Boolean);
29493
29706
  const currentPackageSegments = currentPathSegments.slice(
29494
29707
  -packagePathSegments.length
29495
29708
  );
@@ -29498,7 +29711,7 @@ function resolveInstalledPackageRoot({
29498
29711
  )) {
29499
29712
  return currentPath;
29500
29713
  }
29501
- const parentPath = path15.dirname(currentPath);
29714
+ const parentPath = path16.dirname(currentPath);
29502
29715
  if (parentPath === currentPath) {
29503
29716
  return null;
29504
29717
  }
@@ -29508,14 +29721,14 @@ function resolveInstalledPackageRoot({
29508
29721
  function resolveInstallPrefixFromPackageRoot(packageRootPath) {
29509
29722
  let currentPath = packageRootPath;
29510
29723
  for (; ; ) {
29511
- if (path15.basename(currentPath) === "node_modules") {
29512
- const nodeModulesParentPath = path15.dirname(currentPath);
29513
- if (path15.basename(nodeModulesParentPath) === "lib") {
29514
- return path15.dirname(nodeModulesParentPath);
29724
+ if (path16.basename(currentPath) === "node_modules") {
29725
+ const nodeModulesParentPath = path16.dirname(currentPath);
29726
+ if (path16.basename(nodeModulesParentPath) === "lib") {
29727
+ return path16.dirname(nodeModulesParentPath);
29515
29728
  }
29516
29729
  return nodeModulesParentPath;
29517
29730
  }
29518
- const parentPath = path15.dirname(currentPath);
29731
+ const parentPath = path16.dirname(currentPath);
29519
29732
  if (parentPath === currentPath) {
29520
29733
  return null;
29521
29734
  }
@@ -29532,13 +29745,13 @@ function resolveManagedNpmCommand(installPrefix) {
29532
29745
  if (process.platform === "win32") {
29533
29746
  return null;
29534
29747
  }
29535
- const managedNodeExecutable = path15.join(
29748
+ const managedNodeExecutable = path16.join(
29536
29749
  installPrefix,
29537
29750
  MANAGED_NODE_SUBPATH,
29538
29751
  "bin",
29539
29752
  "node"
29540
29753
  );
29541
- const managedNpmCli = path15.join(
29754
+ const managedNpmCli = path16.join(
29542
29755
  installPrefix,
29543
29756
  MANAGED_NODE_SUBPATH,
29544
29757
  "lib",
@@ -29637,15 +29850,15 @@ async function selfUpdateInstalledCli({
29637
29850
  }
29638
29851
 
29639
29852
  // src/settings.ts
29640
- import { mkdir as mkdir4, readFile as readFile4, rm as rm4, writeFile as writeFile2 } from "node:fs/promises";
29641
- import path16 from "node:path";
29642
- import { z as z43 } from "zod";
29643
- var cliSettingsSchema = z43.object({
29644
- env: z43.object({
29645
- baseUrl: z43.url().optional(),
29646
- domain: z43.url().optional(),
29647
- env: z43.enum(["us", "uk", "stg"]).optional(),
29648
- workosEnv: z43.string().min(1).optional()
29853
+ import { mkdir as mkdir4, readFile as readFile5, rm as rm4, writeFile as writeFile2 } from "node:fs/promises";
29854
+ import path17 from "node:path";
29855
+ import { z as z44 } from "zod";
29856
+ var cliSettingsSchema = z44.object({
29857
+ env: z44.object({
29858
+ baseUrl: z44.url().optional(),
29859
+ domain: z44.url().optional(),
29860
+ env: z44.enum(["us", "uk", "stg"]).optional(),
29861
+ workosEnv: z44.string().min(1).optional()
29649
29862
  }).default({})
29650
29863
  });
29651
29864
  function createEmptyCliSettings() {
@@ -29657,13 +29870,13 @@ function hasCliSettingsOverrides(settings) {
29657
29870
  return Object.values(settings.env).some((value) => value !== void 0);
29658
29871
  }
29659
29872
  function resolveSettingsFilePath(stateFilePath) {
29660
- return path16.join(path16.dirname(stateFilePath), CLI_SETTINGS_FILE_NAME);
29873
+ return path17.join(path17.dirname(stateFilePath), CLI_SETTINGS_FILE_NAME);
29661
29874
  }
29662
29875
  function createFileSettingsStore(stateFilePath) {
29663
29876
  const settingsFilePath = resolveSettingsFilePath(stateFilePath);
29664
29877
  return {
29665
29878
  async load() {
29666
- const fileContents = await readFile4(settingsFilePath, "utf8").catch(
29879
+ const fileContents = await readFile5(settingsFilePath, "utf8").catch(
29667
29880
  (error) => {
29668
29881
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
29669
29882
  return null;
@@ -29693,7 +29906,7 @@ function createFileSettingsStore(stateFilePath) {
29693
29906
  await rm4(settingsFilePath, { force: true });
29694
29907
  return;
29695
29908
  }
29696
- await mkdir4(path16.dirname(settingsFilePath), { recursive: true });
29909
+ await mkdir4(path17.dirname(settingsFilePath), { recursive: true });
29697
29910
  await writeFile2(
29698
29911
  settingsFilePath,
29699
29912
  `${JSON.stringify(settings, null, 2)}
@@ -29861,15 +30074,15 @@ import {
29861
30074
  lstat as lstat2,
29862
30075
  mkdir as mkdir5,
29863
30076
  mkdtemp as mkdtemp2,
29864
- readFile as readFile5,
30077
+ readFile as readFile6,
29865
30078
  readdir,
29866
30079
  rename as rename4,
29867
30080
  rm as rm5,
29868
30081
  writeFile as writeFile3
29869
30082
  } from "node:fs/promises";
29870
30083
  import os3 from "node:os";
29871
- import path17 from "node:path";
29872
- import { z as z44 } from "zod";
30084
+ import path18 from "node:path";
30085
+ import { z as z45 } from "zod";
29873
30086
  var SKILLS_ROOT_PATH = "skills";
29874
30087
  var METADATA_DIRECTORY_NAME = "skill-working-copies";
29875
30088
  var MAX_GIT_OUTPUT_BYTES = 10 * 1024 * 1024;
@@ -29878,40 +30091,40 @@ var FULL_COMMIT_SHA_PATTERN = /^[\dA-Fa-f]{40}$/u;
29878
30091
  var UTF8_ENCODER = new TextEncoder();
29879
30092
  var WINDOWS_RESERVED_PATH_CHARACTER_PATTERN = /[<>:"|?*]/u;
29880
30093
  var WINDOWS_RESERVED_PATH_NAME_PATTERN = /^(?:AUX|CON|NUL|PRN|COM[1-9]|LPT[1-9])(?:\..*)?$/iu;
29881
- var skillBundleSchema = z44.object({
29882
- files: z44.array(
29883
- z44.object({
29884
- content: z44.string(),
29885
- encoding: z44.literal("base64"),
29886
- path: z44.string().min(1),
29887
- size: z44.number().int().nonnegative()
30094
+ var skillBundleSchema = z45.object({
30095
+ files: z45.array(
30096
+ z45.object({
30097
+ content: z45.string(),
30098
+ encoding: z45.literal("base64"),
30099
+ path: z45.string().min(1),
30100
+ size: z45.number().int().nonnegative()
29888
30101
  })
29889
30102
  ),
29890
- path: z44.string().min(1),
29891
- ref: z44.string().regex(FULL_COMMIT_SHA_PATTERN)
30103
+ path: z45.string().min(1),
30104
+ ref: z45.string().regex(FULL_COMMIT_SHA_PATTERN)
29892
30105
  });
29893
- var skillsApplyPatchResultSchema = z44.object({
29894
- changedFiles: z44.array(
29895
- z44.object({ path: z44.string().min(1), status: z44.string().min(1) })
30106
+ var skillsApplyPatchResultSchema = z45.object({
30107
+ changedFiles: z45.array(
30108
+ z45.object({ path: z45.string().min(1), status: z45.string().min(1) })
29896
30109
  ),
29897
- commit: z44.string().regex(FULL_COMMIT_SHA_PATTERN),
29898
- ok: z44.boolean(),
29899
- ref: z44.string().min(1)
30110
+ commit: z45.string().regex(FULL_COMMIT_SHA_PATTERN),
30111
+ ok: z45.boolean(),
30112
+ ref: z45.string().min(1)
29900
30113
  }).refine((result) => result.ok, {
29901
30114
  message: "Skills patch result was not successful."
29902
30115
  });
29903
- var workingCopyMetadataSchema = z44.object({
29904
- version: z44.literal(1),
29905
- files: z44.array(
29906
- z44.object({
29907
- content: z44.string(),
29908
- path: z44.string().min(1)
30116
+ var workingCopyMetadataSchema = z45.object({
30117
+ version: z45.literal(1),
30118
+ files: z45.array(
30119
+ z45.object({
30120
+ content: z45.string(),
30121
+ path: z45.string().min(1)
29909
30122
  })
29910
30123
  ),
29911
- organizationId: z44.string().min(1),
29912
- requestedRef: z44.string().min(1).nullable(),
29913
- skillPath: z44.string().min(1),
29914
- workingCopyPath: z44.string().min(1)
30124
+ organizationId: z45.string().min(1),
30125
+ requestedRef: z45.string().min(1).nullable(),
30126
+ skillPath: z45.string().min(1),
30127
+ workingCopyPath: z45.string().min(1)
29915
30128
  });
29916
30129
  function hasControlCharacter2(value) {
29917
30130
  return UTF8_ENCODER.encode(value).some((byte) => byte <= 31 || byte === 127);
@@ -29939,12 +30152,12 @@ function normalizeRootSkillPath(skill) {
29939
30152
  return `${SKILLS_ROOT_PATH}/${skillName}`;
29940
30153
  }
29941
30154
  function resolveWorkingCopyPath(workingDirectory, skillPath) {
29942
- return path17.resolve(workingDirectory, ...skillPath.split("/"));
30155
+ return path18.resolve(workingDirectory, ...skillPath.split("/"));
29943
30156
  }
29944
30157
  function resolveMetadataPath(stateFilePath, workingCopyPath) {
29945
30158
  const key = createHash3("sha256").update(workingCopyPath).digest("hex");
29946
- return path17.join(
29947
- path17.dirname(stateFilePath),
30159
+ return path18.join(
30160
+ path18.dirname(stateFilePath),
29948
30161
  METADATA_DIRECTORY_NAME,
29949
30162
  `${key}.json`
29950
30163
  );
@@ -29972,7 +30185,7 @@ function metadataFilesToSnapshot(files) {
29972
30185
  );
29973
30186
  }
29974
30187
  async function loadMetadata(metadataPath) {
29975
- const fileContents = await readFile5(metadataPath, "utf8").catch(
30188
+ const fileContents = await readFile6(metadataPath, "utf8").catch(
29976
30189
  (error) => {
29977
30190
  if (isMissingFileError3(error)) {
29978
30191
  return null;
@@ -29996,7 +30209,7 @@ async function loadMetadata(metadataPath) {
29996
30209
  return parsed.data;
29997
30210
  }
29998
30211
  async function saveMetadata(metadataPath, metadata) {
29999
- await mkdir5(path17.dirname(metadataPath), { recursive: true });
30212
+ await mkdir5(path18.dirname(metadataPath), { recursive: true });
30000
30213
  const temporaryPath = `${metadataPath}.${randomUUID6()}.tmp`;
30001
30214
  await writeFile3(temporaryPath, `${JSON.stringify(metadata, null, 2)}
30002
30215
  `, {
@@ -30073,7 +30286,7 @@ async function readDirectorySnapshot({
30073
30286
  const nextSegments = [...segments, entry.name];
30074
30287
  const relativePath = nextSegments.join("/");
30075
30288
  assertSafeRelativeFilePath(relativePath);
30076
- const filePath = path17.join(currentDirectory, entry.name);
30289
+ const filePath = path18.join(currentDirectory, entry.name);
30077
30290
  if (entry.isDirectory()) {
30078
30291
  return await visit(filePath, nextSegments);
30079
30292
  }
@@ -30082,7 +30295,7 @@ async function readDirectorySnapshot({
30082
30295
  `Skill working copy contains unsupported entry "${filePath}". Only regular files and directories are allowed.`
30083
30296
  );
30084
30297
  }
30085
- return [[`${skillPath}/${relativePath}`, await readFile5(filePath)]];
30298
+ return [[`${skillPath}/${relativePath}`, await readFile6(filePath)]];
30086
30299
  })
30087
30300
  );
30088
30301
  return nestedEntries.flat();
@@ -30108,8 +30321,8 @@ async function writeSnapshotContents(rootPath, snapshot, prefix) {
30108
30321
  [...snapshot.entries()].map(async ([filePath, content]) => {
30109
30322
  const relativePath = prefix === null ? filePath : filePath.slice(`${prefix}/`.length);
30110
30323
  assertSafeRelativeFilePath(relativePath);
30111
- const targetPath = path17.join(rootPath, ...relativePath.split("/"));
30112
- await mkdir5(path17.dirname(targetPath), { recursive: true });
30324
+ const targetPath = path18.join(rootPath, ...relativePath.split("/"));
30325
+ await mkdir5(path18.dirname(targetPath), { recursive: true });
30113
30326
  await writeFile3(targetPath, content);
30114
30327
  })
30115
30328
  );
@@ -30119,11 +30332,11 @@ async function replaceWorkingCopy({
30119
30332
  skillPath,
30120
30333
  workingCopyPath
30121
30334
  }) {
30122
- const parentPath = path17.dirname(workingCopyPath);
30335
+ const parentPath = path18.dirname(workingCopyPath);
30123
30336
  await mkdir5(parentPath, { recursive: true });
30124
- const temporaryPath = path17.join(
30337
+ const temporaryPath = path18.join(
30125
30338
  parentPath,
30126
- `.mgcl-${path17.basename(workingCopyPath)}-${randomUUID6()}.tmp`
30339
+ `.mgcl-${path18.basename(workingCopyPath)}-${randomUUID6()}.tmp`
30127
30340
  );
30128
30341
  const backupPath = `${workingCopyPath}.${randomUUID6()}.bak`;
30129
30342
  await mkdir5(temporaryPath);
@@ -30194,7 +30407,7 @@ async function clearDirectoryExceptGit(directoryPath) {
30194
30407
  const entries = await readdir(directoryPath);
30195
30408
  await Promise.all(
30196
30409
  entries.filter((entry) => entry !== ".git").map(async (entry) => {
30197
- await rm5(path17.join(directoryPath, entry), {
30410
+ await rm5(path18.join(directoryPath, entry), {
30198
30411
  force: true,
30199
30412
  recursive: true
30200
30413
  });
@@ -30206,7 +30419,7 @@ async function createPatch(before, after) {
30206
30419
  return "";
30207
30420
  }
30208
30421
  const repositoryPath = await mkdtemp2(
30209
- path17.join(os3.tmpdir(), "mgcl-skills-diff-")
30422
+ path18.join(os3.tmpdir(), "mgcl-skills-diff-")
30210
30423
  );
30211
30424
  const patchResult = await fromThrowable(async () => {
30212
30425
  await runGit(["init", "--quiet"], repositoryPath);
@@ -30528,27 +30741,27 @@ async function pushSkillWorkingCopy({
30528
30741
  }
30529
30742
 
30530
30743
  // src/state.ts
30531
- import { mkdir as mkdir6, readFile as readFile6, rm as rm6, writeFile as writeFile4 } from "node:fs/promises";
30532
- import path18 from "node:path";
30533
- import { z as z45 } from "zod";
30534
- var cliAccountSchema = z45.object({
30535
- clientId: z45.string().min(1),
30536
- email: z45.string().nullable(),
30537
- userId: z45.string().min(1)
30744
+ import { mkdir as mkdir6, readFile as readFile7, rm as rm6, writeFile as writeFile4 } from "node:fs/promises";
30745
+ import path19 from "node:path";
30746
+ import { z as z46 } from "zod";
30747
+ var cliAccountSchema = z46.object({
30748
+ clientId: z46.string().min(1),
30749
+ email: z46.string().nullable(),
30750
+ userId: z46.string().min(1)
30538
30751
  });
30539
- var cliOrganizationSchema = z45.object({
30540
- id: z45.string().min(1),
30541
- name: z45.string().min(1),
30542
- primaryDomain: z45.string().nullable().default(null)
30752
+ var cliOrganizationSchema = z46.object({
30753
+ id: z46.string().min(1),
30754
+ name: z46.string().min(1),
30755
+ primaryDomain: z46.string().nullable().default(null)
30543
30756
  });
30544
- var cliStateSchema = z45.object({
30757
+ var cliStateSchema = z46.object({
30545
30758
  account: cliAccountSchema,
30546
30759
  deploymentTarget: resolvedDeploymentTargetSchema.optional(),
30547
- defaultOrgId: z45.string().nullable(),
30548
- lastUsedOrgId: z45.string().nullable(),
30549
- organizations: z45.array(cliOrganizationSchema)
30760
+ defaultOrgId: z46.string().nullable(),
30761
+ lastUsedOrgId: z46.string().nullable(),
30762
+ organizations: z46.array(cliOrganizationSchema)
30550
30763
  });
30551
- var refreshTokenFileSchema = z45.record(z45.string(), z45.string());
30764
+ var refreshTokenFileSchema = z46.record(z46.string(), z46.string());
30552
30765
  function createFileStateStore(stateFilePath) {
30553
30766
  return {
30554
30767
  async clear() {
@@ -30556,7 +30769,7 @@ function createFileStateStore(stateFilePath) {
30556
30769
  },
30557
30770
  async load() {
30558
30771
  try {
30559
- const fileContents = await readFile6(stateFilePath, "utf8");
30772
+ const fileContents = await readFile7(stateFilePath, "utf8");
30560
30773
  const parsed = cliStateSchema.safeParse(JSON.parse(fileContents));
30561
30774
  if (!parsed.success) {
30562
30775
  throw new CliError("Stored CLI state is invalid.");
@@ -30573,7 +30786,7 @@ function createFileStateStore(stateFilePath) {
30573
30786
  }
30574
30787
  },
30575
30788
  async save(state) {
30576
- await mkdir6(path18.dirname(stateFilePath), { recursive: true });
30789
+ await mkdir6(path19.dirname(stateFilePath), { recursive: true });
30577
30790
  await writeFile4(stateFilePath, `${JSON.stringify(state, null, 2)}
30578
30791
  `);
30579
30792
  }
@@ -30582,7 +30795,7 @@ function createFileStateStore(stateFilePath) {
30582
30795
  function createFileRefreshTokenStore(refreshTokenFilePath) {
30583
30796
  async function loadRefreshTokens() {
30584
30797
  try {
30585
- const fileContents = await readFile6(refreshTokenFilePath, "utf8");
30798
+ const fileContents = await readFile7(refreshTokenFilePath, "utf8");
30586
30799
  const parsed = refreshTokenFileSchema.safeParse(JSON.parse(fileContents));
30587
30800
  if (!parsed.success) {
30588
30801
  throw new CliError("Stored refresh tokens are invalid.");
@@ -30601,7 +30814,7 @@ function createFileRefreshTokenStore(refreshTokenFilePath) {
30601
30814
  }
30602
30815
  }
30603
30816
  async function saveRefreshTokens(refreshTokens) {
30604
- await mkdir6(path18.dirname(refreshTokenFilePath), { recursive: true });
30817
+ await mkdir6(path19.dirname(refreshTokenFilePath), { recursive: true });
30605
30818
  await writeFile4(
30606
30819
  refreshTokenFilePath,
30607
30820
  `${JSON.stringify(refreshTokens, null, 2)}
@@ -30639,37 +30852,37 @@ function buildRefreshTokenKey(account) {
30639
30852
  }
30640
30853
 
30641
30854
  // src/workos-auth.ts
30642
- import { z as z46 } from "zod";
30855
+ import { z as z47 } from "zod";
30643
30856
  var DEFAULT_DEVICE_POLL_INTERVAL_SECONDS = 5;
30644
30857
  function buildFormHeaders() {
30645
30858
  const headers = new Headers();
30646
30859
  headers.set("content-type", "application/x-www-form-urlencoded");
30647
30860
  return headers;
30648
30861
  }
30649
- var deviceAuthorizationSchema = z46.object({
30650
- device_code: z46.string().min(1),
30651
- expires_in: z46.number().int().positive().optional(),
30652
- interval: z46.number().int().positive().optional(),
30653
- user_code: z46.string().min(1),
30654
- verification_uri: z46.url(),
30655
- verification_uri_complete: z46.url().optional()
30656
- });
30657
- var tokenResponseSchema = z46.object({
30658
- access_token: z46.string().min(1),
30659
- expires_in: z46.number().int().positive().optional(),
30660
- refresh_token: z46.string().min(1),
30661
- token_type: z46.string().optional()
30662
- });
30663
- var tokenErrorSchema = z46.object({
30664
- error: z46.string().min(1),
30665
- error_description: z46.string().optional()
30666
- });
30667
- var accessTokenClaimsSchema = z46.object({
30668
- exp: z46.number().int().positive().optional(),
30669
- iss: z46.string().min(1).optional(),
30670
- org_id: z46.string().min(1).optional(),
30671
- sid: z46.string().min(1).optional(),
30672
- sub: z46.string().min(1)
30862
+ var deviceAuthorizationSchema = z47.object({
30863
+ device_code: z47.string().min(1),
30864
+ expires_in: z47.number().int().positive().optional(),
30865
+ interval: z47.number().int().positive().optional(),
30866
+ user_code: z47.string().min(1),
30867
+ verification_uri: z47.url(),
30868
+ verification_uri_complete: z47.url().optional()
30869
+ });
30870
+ var tokenResponseSchema = z47.object({
30871
+ access_token: z47.string().min(1),
30872
+ expires_in: z47.number().int().positive().optional(),
30873
+ refresh_token: z47.string().min(1),
30874
+ token_type: z47.string().optional()
30875
+ });
30876
+ var tokenErrorSchema = z47.object({
30877
+ error: z47.string().min(1),
30878
+ error_description: z47.string().optional()
30879
+ });
30880
+ var accessTokenClaimsSchema = z47.object({
30881
+ exp: z47.number().int().positive().optional(),
30882
+ iss: z47.string().min(1).optional(),
30883
+ org_id: z47.string().min(1).optional(),
30884
+ sid: z47.string().min(1).optional(),
30885
+ sub: z47.string().min(1)
30673
30886
  });
30674
30887
  function createWorkosAuthClient({
30675
30888
  fetchFn = fetch,
@@ -30979,13 +31192,17 @@ async function handleOperationCommand(dependencies, operationSpec, commandOption
30979
31192
  commandOptions,
30980
31193
  dependencies.workingDirectory ?? process.cwd()
30981
31194
  );
30982
- const variables = parseOperationVariables(
30983
- operationSpec,
30984
- getFileUploadOperationVariables(
31195
+ const operationVariables = await resolveClassifyOperationVariables({
31196
+ defaultVariables: getFileUploadOperationVariables(
30985
31197
  collectOperationVariableInput(operationSpec, commandOptions),
30986
31198
  preparedUpload
30987
- )
30988
- );
31199
+ ),
31200
+ operationName: operationSpec.operationName,
31201
+ options: commandOptions,
31202
+ runtime: dependencies.classifyCommandRuntime,
31203
+ workingDirectory: dependencies.workingDirectory ?? process.cwd()
31204
+ });
31205
+ const variables = parseOperationVariables(operationSpec, operationVariables);
30989
31206
  const apiKeyEnvironment = getApiKeyEnvironment(
30990
31207
  dependencies,
30991
31208
  commandOptions.apiKey
@@ -31965,6 +32182,9 @@ function addRegistryOperationCommand({
31965
32182
  }
31966
32183
  const command = parentCommand.command(leafCommandName);
31967
32184
  configureOperationalCommand(command, dependencies, operationSpec);
32185
+ if (parentCommand === program2) {
32186
+ return;
32187
+ }
31968
32188
  const legacyAliasCommand = program2.command(operationSpec.cli.name, {
31969
32189
  hidden: true
31970
32190
  });
@@ -31989,6 +32209,7 @@ ${formatExamples(
31989
32209
  createOperationHelpExamples(operationSpec)
31990
32210
  )}`
31991
32211
  );
32212
+ configureClassifyHelp(command, operationSpec.operationName);
31992
32213
  for (const optionSpec of operationSpec.cli.options) {
31993
32214
  command.addOption(
31994
32215
  createCliCommanderOption(
@@ -32014,12 +32235,12 @@ function createDefaultDependencies() {
32014
32235
  return resolveDeploymentTarget({ savedEnv: settings.env, selectors });
32015
32236
  };
32016
32237
  const resolveApiBaseUrl = () => deploymentTargetContext.get().apiUrl;
32017
- const accessTokenFilePath = runtimeConfig.accessTokenFilePath ?? path19.join(
32018
- path19.dirname(runtimeConfig.stateFilePath),
32238
+ const accessTokenFilePath = runtimeConfig.accessTokenFilePath ?? path20.join(
32239
+ path20.dirname(runtimeConfig.stateFilePath),
32019
32240
  CLI_ACCESS_TOKEN_FILE_NAME
32020
32241
  );
32021
- const refreshTokenFilePath = runtimeConfig.refreshTokenFilePath ?? path19.join(
32022
- path19.dirname(runtimeConfig.stateFilePath),
32242
+ const refreshTokenFilePath = runtimeConfig.refreshTokenFilePath ?? path20.join(
32243
+ path20.dirname(runtimeConfig.stateFilePath),
32023
32244
  CLI_REFRESH_TOKEN_FILE_NAME
32024
32245
  );
32025
32246
  const selfUpdateOptions = {
@@ -32037,8 +32258,8 @@ function createDefaultDependencies() {
32037
32258
  io: createConsoleIo(),
32038
32259
  openExternalUrl,
32039
32260
  orgPreferencesStore: createFileOrgPreferencesStore(
32040
- path19.join(
32041
- path19.dirname(runtimeConfig.stateFilePath),
32261
+ path20.join(
32262
+ path20.dirname(runtimeConfig.stateFilePath),
32042
32263
  "organization-preferences"
32043
32264
  )
32044
32265
  ),