@getmagical/cli 0.2.4 → 0.2.5

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
@@ -2056,13 +2056,13 @@ var require_ast = __commonJS({
2056
2056
  helperExpression: function helperExpression(node) {
2057
2057
  return node.type === "SubExpression" || (node.type === "MustacheStatement" || node.type === "BlockStatement") && !!(node.params && node.params.length || node.hash);
2058
2058
  },
2059
- scopedId: function scopedId(path7) {
2060
- return /^\.|this\b/.test(path7.original);
2059
+ scopedId: function scopedId(path8) {
2060
+ return /^\.|this\b/.test(path8.original);
2061
2061
  },
2062
2062
  // an ID is simple if it only has one part, and that part is not
2063
2063
  // `..` or `this`.
2064
- simpleId: function simpleId(path7) {
2065
- return path7.parts.length === 1 && !AST.helpers.scopedId(path7) && !path7.depth;
2064
+ simpleId: function simpleId(path8) {
2065
+ return path8.parts.length === 1 && !AST.helpers.scopedId(path8) && !path8.depth;
2066
2066
  }
2067
2067
  }
2068
2068
  };
@@ -3132,12 +3132,12 @@ var require_helpers2 = __commonJS({
3132
3132
  loc
3133
3133
  };
3134
3134
  }
3135
- function prepareMustache(path7, params, hash, open, strip, locInfo) {
3135
+ function prepareMustache(path8, params, hash, open, strip, locInfo) {
3136
3136
  var escapeFlag = open.charAt(3) || open.charAt(2), escaped = escapeFlag !== "{" && escapeFlag !== "&";
3137
3137
  var decorator = /\*/.test(open);
3138
3138
  return {
3139
3139
  type: decorator ? "Decorator" : "MustacheStatement",
3140
- path: path7,
3140
+ path: path8,
3141
3141
  params,
3142
3142
  hash,
3143
3143
  escaped,
@@ -3455,9 +3455,9 @@ var require_compiler = __commonJS({
3455
3455
  },
3456
3456
  DecoratorBlock: function DecoratorBlock(decorator) {
3457
3457
  var program2 = decorator.program && this.compileProgram(decorator.program);
3458
- var params = this.setupFullMustacheParams(decorator, program2, void 0), path7 = decorator.path;
3458
+ var params = this.setupFullMustacheParams(decorator, program2, void 0), path8 = decorator.path;
3459
3459
  this.useDecorators = true;
3460
- this.opcode("registerDecorator", params.length, path7.original);
3460
+ this.opcode("registerDecorator", params.length, path8.original);
3461
3461
  },
3462
3462
  PartialStatement: function PartialStatement(partial) {
3463
3463
  this.usePartial = true;
@@ -3521,46 +3521,46 @@ var require_compiler = __commonJS({
3521
3521
  }
3522
3522
  },
3523
3523
  ambiguousSexpr: function ambiguousSexpr(sexpr, program2, inverse) {
3524
- var path7 = sexpr.path, name = path7.parts[0], isBlock = program2 != null || inverse != null;
3525
- this.opcode("getContext", path7.depth);
3524
+ var path8 = sexpr.path, name = path8.parts[0], isBlock = program2 != null || inverse != null;
3525
+ this.opcode("getContext", path8.depth);
3526
3526
  this.opcode("pushProgram", program2);
3527
3527
  this.opcode("pushProgram", inverse);
3528
- path7.strict = true;
3529
- this.accept(path7);
3528
+ path8.strict = true;
3529
+ this.accept(path8);
3530
3530
  this.opcode("invokeAmbiguous", name, isBlock);
3531
3531
  },
3532
3532
  simpleSexpr: function simpleSexpr(sexpr) {
3533
- var path7 = sexpr.path;
3534
- path7.strict = true;
3535
- this.accept(path7);
3533
+ var path8 = sexpr.path;
3534
+ path8.strict = true;
3535
+ this.accept(path8);
3536
3536
  this.opcode("resolvePossibleLambda");
3537
3537
  },
3538
3538
  helperSexpr: function helperSexpr(sexpr, program2, inverse) {
3539
- var params = this.setupFullMustacheParams(sexpr, program2, inverse), path7 = sexpr.path, name = path7.parts[0];
3539
+ var params = this.setupFullMustacheParams(sexpr, program2, inverse), path8 = sexpr.path, name = path8.parts[0];
3540
3540
  if (this.options.knownHelpers[name]) {
3541
3541
  this.opcode("invokeKnownHelper", params.length, name);
3542
3542
  } else if (this.options.knownHelpersOnly) {
3543
3543
  throw new _exception2["default"]("You specified knownHelpersOnly, but used the unknown helper " + name, sexpr);
3544
3544
  } else {
3545
- path7.strict = true;
3546
- path7.falsy = true;
3547
- this.accept(path7);
3548
- this.opcode("invokeHelper", params.length, path7.original, _ast2["default"].helpers.simpleId(path7));
3545
+ path8.strict = true;
3546
+ path8.falsy = true;
3547
+ this.accept(path8);
3548
+ this.opcode("invokeHelper", params.length, path8.original, _ast2["default"].helpers.simpleId(path8));
3549
3549
  }
3550
3550
  },
3551
- PathExpression: function PathExpression(path7) {
3552
- this.addDepth(path7.depth);
3553
- this.opcode("getContext", path7.depth);
3554
- var name = path7.parts[0], scoped = _ast2["default"].helpers.scopedId(path7), blockParamId = !path7.depth && !scoped && this.blockParamIndex(name);
3551
+ PathExpression: function PathExpression(path8) {
3552
+ this.addDepth(path8.depth);
3553
+ this.opcode("getContext", path8.depth);
3554
+ var name = path8.parts[0], scoped = _ast2["default"].helpers.scopedId(path8), blockParamId = !path8.depth && !scoped && this.blockParamIndex(name);
3555
3555
  if (blockParamId) {
3556
- this.opcode("lookupBlockParam", blockParamId, path7.parts);
3556
+ this.opcode("lookupBlockParam", blockParamId, path8.parts);
3557
3557
  } else if (!name) {
3558
3558
  this.opcode("pushContext");
3559
- } else if (path7.data) {
3559
+ } else if (path8.data) {
3560
3560
  this.options.data = true;
3561
- this.opcode("lookupData", path7.depth, path7.parts, path7.strict);
3561
+ this.opcode("lookupData", path8.depth, path8.parts, path8.strict);
3562
3562
  } else {
3563
- this.opcode("lookupOnContext", path7.parts, path7.falsy, path7.strict, scoped);
3563
+ this.opcode("lookupOnContext", path8.parts, path8.falsy, path8.strict, scoped);
3564
3564
  }
3565
3565
  },
3566
3566
  StringLiteral: function StringLiteral(string) {
@@ -3910,16 +3910,16 @@ var require_util2 = __commonJS({
3910
3910
  }
3911
3911
  exports.urlGenerate = urlGenerate;
3912
3912
  function normalize(aPath) {
3913
- var path7 = aPath;
3913
+ var path8 = aPath;
3914
3914
  var url = urlParse(aPath);
3915
3915
  if (url) {
3916
3916
  if (!url.path) {
3917
3917
  return aPath;
3918
3918
  }
3919
- path7 = url.path;
3919
+ path8 = url.path;
3920
3920
  }
3921
- var isAbsolute = exports.isAbsolute(path7);
3922
- var parts = path7.split(/\/+/);
3921
+ var isAbsolute = exports.isAbsolute(path8);
3922
+ var parts = path8.split(/\/+/);
3923
3923
  for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
3924
3924
  part = parts[i];
3925
3925
  if (part === ".") {
@@ -3936,15 +3936,15 @@ var require_util2 = __commonJS({
3936
3936
  }
3937
3937
  }
3938
3938
  }
3939
- path7 = parts.join("/");
3940
- if (path7 === "") {
3941
- path7 = isAbsolute ? "/" : ".";
3939
+ path8 = parts.join("/");
3940
+ if (path8 === "") {
3941
+ path8 = isAbsolute ? "/" : ".";
3942
3942
  }
3943
3943
  if (url) {
3944
- url.path = path7;
3944
+ url.path = path8;
3945
3945
  return urlGenerate(url);
3946
3946
  }
3947
- return path7;
3947
+ return path8;
3948
3948
  }
3949
3949
  exports.normalize = normalize;
3950
3950
  function join(aRoot, aPath) {
@@ -6727,8 +6727,8 @@ var require_printer = __commonJS({
6727
6727
  return this.accept(sexpr.path) + " " + params + hash;
6728
6728
  };
6729
6729
  PrintVisitor.prototype.PathExpression = function(id) {
6730
- var path7 = id.parts.join("/");
6731
- return (id.data ? "@" : "") + "PATH:" + path7;
6730
+ var path8 = id.parts.join("/");
6731
+ return (id.data ? "@" : "") + "PATH:" + path8;
6732
6732
  };
6733
6733
  PrintVisitor.prototype.StringLiteral = function(string) {
6734
6734
  return '"' + string.value + '"';
@@ -7079,8 +7079,8 @@ function getErrorMessage(error) {
7079
7079
  }
7080
7080
 
7081
7081
  // src/program.ts
7082
- import { readFile as readFile4 } from "node:fs/promises";
7083
- import path6 from "node:path";
7082
+ import { readFile as readFile5 } from "node:fs/promises";
7083
+ import path7 from "node:path";
7084
7084
 
7085
7085
  // ../common/dist/src/stdlib/json.util.js
7086
7086
  var import_ts_essentials = __toESM(require_dist(), 1);
@@ -7741,6 +7741,13 @@ function safeJsonParse(json) {
7741
7741
  return Err({ type: "invalid-json", cause: error, json });
7742
7742
  }
7743
7743
  }
7744
+ function safeJsonParseWithoutLogging(json) {
7745
+ try {
7746
+ return Ok(JSON.parse(json));
7747
+ } catch (error) {
7748
+ return Err({ type: "invalid-json", cause: error });
7749
+ }
7750
+ }
7744
7751
 
7745
7752
  // ../common/dist/src/constants/tool-declarations.js
7746
7753
  import { z as z12 } from "zod";
@@ -11915,8 +11922,8 @@ var RENDER_TEMPLATE_ERROR_REASON_CATALOG = defineErrorReasonCatalog()([
11915
11922
  ]);
11916
11923
  var storeReferencePathPattern = String.raw`store(?:\.[$A-Z_a-z][\w$]*)*`;
11917
11924
  var storeReferenceMarkdownLinkTemplateRegex = new RegExp(String.raw`(?<open>\{\{\{?)\s*\[(?<path>${storeReferencePathPattern})\]\(\s*<?https?:\/\/\k<path>>?\s*\)\s*(?<close>\}\}\}?)`, "gu");
11918
- function normalizeAutomationStoreTemplateLinkMatch([_match, open, path7]) {
11919
- return open === "{{{" ? `{{{${path7}}}}` : `{{${path7}}}`;
11925
+ function normalizeAutomationStoreTemplateLinkMatch([_match, open, path8]) {
11926
+ return open === "{{{" ? `{{{${path8}}}}` : `{{${path8}}}`;
11920
11927
  }
11921
11928
  function normalizeAutomationStoreTemplateLinks(template) {
11922
11929
  return template.replaceAll(storeReferenceMarkdownLinkTemplateRegex, (...args) => normalizeAutomationStoreTemplateLinkMatch(args));
@@ -12484,18 +12491,18 @@ var reportStopDataSchema = z11.object({
12484
12491
  // ../common/dist/src/utils/automation-store-path.util.js
12485
12492
  var AUTOMATION_STORE_ROOT_PATH = "store";
12486
12493
  var relativeStorePathRegex = /^[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*)*$/u;
12487
- function normalizeStoreMutationPath(path7) {
12488
- const trimmedPath = path7.trim();
12494
+ function normalizeStoreMutationPath(path8) {
12495
+ const trimmedPath = path8.trim();
12489
12496
  const rootPrefix = `${AUTOMATION_STORE_ROOT_PATH}.`;
12490
12497
  const relativePath = trimmedPath.startsWith(rootPrefix) ? trimmedPath.slice(rootPrefix.length) : trimmedPath;
12491
12498
  if (!relativeStorePathRegex.test(relativePath)) {
12492
12499
  return Err({
12493
12500
  type: "invalid-automation-store-path",
12494
- path: path7,
12501
+ path: path8,
12495
12502
  categories: ["customer_usage"],
12496
12503
  statusCode: 400,
12497
12504
  nonRetryable: true,
12498
- message: `Automation store path "${path7}" is invalid.`,
12505
+ message: `Automation store path "${path8}" is invalid.`,
12499
12506
  suggestedAction: "Use a dot path relative to the automation store, such as patient.name or provider.clinic."
12500
12507
  });
12501
12508
  }
@@ -12508,16 +12515,16 @@ function findAutomationStorePathOverlap(paths) {
12508
12515
  ...new Set(paths.map(getCanonicalAutomationStoreMutationPath))
12509
12516
  ].toSorted((left, right) => (left === AUTOMATION_STORE_ROOT_PATH ? 0 : left.split(".").length) - (right === AUTOMATION_STORE_ROOT_PATH ? 0 : right.split(".").length));
12510
12517
  for (const [index, ancestorPath] of canonicalPaths.entries()) {
12511
- const descendantPath = canonicalPaths.slice(index + 1).find((path7) => ancestorPath === AUTOMATION_STORE_ROOT_PATH || path7.startsWith(`${ancestorPath}.`));
12518
+ const descendantPath = canonicalPaths.slice(index + 1).find((path8) => ancestorPath === AUTOMATION_STORE_ROOT_PATH || path8.startsWith(`${ancestorPath}.`));
12512
12519
  if (descendantPath !== void 0) {
12513
12520
  return { ancestorPath, descendantPath };
12514
12521
  }
12515
12522
  }
12516
12523
  return void 0;
12517
12524
  }
12518
- function getCanonicalAutomationStoreMutationPath(path7) {
12519
- const normalizedPath = normalizeStoreMutationPath(path7);
12520
- return normalizedPath._tag === "Ok" ? normalizedPath.value : path7.trim();
12525
+ function getCanonicalAutomationStoreMutationPath(path8) {
12526
+ const normalizedPath = normalizeStoreMutationPath(path8);
12527
+ return normalizedPath._tag === "Ok" ? normalizedPath.value : path8.trim();
12521
12528
  }
12522
12529
 
12523
12530
  // ../common/dist/src/constants/tool-declarations.js
@@ -12741,9 +12748,9 @@ var baseToolDeclarations = {
12741
12748
  path: []
12742
12749
  });
12743
12750
  }
12744
- const canonicalUpdatePaths = updates.map(({ path: path7 }) => getCanonicalAutomationStoreMutationPath(path7));
12751
+ const canonicalUpdatePaths = updates.map(({ path: path8 }) => getCanonicalAutomationStoreMutationPath(path8));
12745
12752
  const canonicalClearPathSet = new Set(clears.map(getCanonicalAutomationStoreMutationPath));
12746
- const conflictedUpdatePath = canonicalUpdatePaths.find((path7) => canonicalClearPathSet.has(path7));
12753
+ const conflictedUpdatePath = canonicalUpdatePaths.find((path8) => canonicalClearPathSet.has(path8));
12747
12754
  if (conflictedUpdatePath !== void 0) {
12748
12755
  context.addIssue({
12749
12756
  code: "custom",
@@ -13186,7 +13193,7 @@ var SOM_LEGEND_HTML_ATTRIBUTES = [
13186
13193
  ];
13187
13194
 
13188
13195
  // ../common/dist/src/zod-schemas/agent-config.schema.js
13189
- import { z as z19 } from "zod";
13196
+ import { z as z21 } from "zod";
13190
13197
 
13191
13198
  // ../common/dist/src/commands/commands-registry/special.commands.js
13192
13199
  import { z as z13 } from "zod";
@@ -13422,9 +13429,9 @@ var specialCommands = {
13422
13429
  };
13423
13430
 
13424
13431
  // ../common/dist/src/utils/agent-knowledge-base-assets.util.js
13425
- function getIsKnowledgeBaseAssetPathAllowed(path7) {
13426
- const pathSegments = path7.split("/");
13427
- if (path7.length === 0 || pathSegments.some((segment) => segment.length === 0)) {
13432
+ function getIsKnowledgeBaseAssetPathAllowed(path8) {
13433
+ const pathSegments = path8.split("/");
13434
+ if (path8.length === 0 || pathSegments.some((segment) => segment.length === 0)) {
13428
13435
  return false;
13429
13436
  }
13430
13437
  const isTopLevelAssetPath = pathSegments[0] === "assets";
@@ -13444,8 +13451,88 @@ function parsePointOfNoReturnKeyFieldPath(keyField) {
13444
13451
  return segments;
13445
13452
  }
13446
13453
 
13447
- // ../common/dist/src/zod-schemas/api-request-body.schema.js
13454
+ // ../common/dist/src/zod-schemas/api-agent-file-output.schema.js
13448
13455
  import { z as z14 } from "zod";
13456
+
13457
+ // ../common/dist/src/utils/api-file-type-registry.util.js
13458
+ var ApiFileContentTypes = ["application/pdf", "image/png"];
13459
+ var PDF_CONTENT_TYPE = "application/pdf";
13460
+ var PNG_CONTENT_TYPE = "image/png";
13461
+ var API_FILE_TYPE_REGISTRY = {
13462
+ [PDF_CONTENT_TYPE]: {
13463
+ extension: "pdf",
13464
+ signature: [37, 80, 68, 70, 45]
13465
+ },
13466
+ [PNG_CONTENT_TYPE]: {
13467
+ extension: "png",
13468
+ signature: [137, 80, 78, 71, 13, 10, 26, 10]
13469
+ }
13470
+ };
13471
+
13472
+ // ../common/dist/src/zod-schemas/api-agent-file-output.schema.js
13473
+ var ApiAgentOutputModes = ["inline", "file"];
13474
+ var API_EMBEDDED_FILE_PATH_PATTERN = /^(?:\[\*\]|[A-Za-z_$][\w$-]*)(?:\[\*\]|\.[A-Za-z_$][\w$-]*)*$/u;
13475
+ var API_EMBEDDED_FILE_PATH_SEGMENT_PATTERN = /\[\*\]|[A-Za-z_$][\w$-]*/gu;
13476
+ function parseApiEmbeddedFilePath(path8) {
13477
+ if (!API_EMBEDDED_FILE_PATH_PATTERN.test(path8)) {
13478
+ return void 0;
13479
+ }
13480
+ return [...path8.matchAll(API_EMBEDDED_FILE_PATH_SEGMENT_PATTERN)].map(([segment]) => segment === "[*]" ? { type: "arrayWildcard" } : { key: segment, type: "property" });
13481
+ }
13482
+ var apiAgentEmbeddedFileSchema = z14.object({
13483
+ path: z14.string().trim().min(1, "Embedded file path is required.").refine((path8) => parseApiEmbeddedFilePath(path8) !== void 0, {
13484
+ message: "Embedded file path must use object properties and [*] array wildcards."
13485
+ }).describe("Path to a Base64 value relative to the projected API response. Supports object properties and [*] array wildcards."),
13486
+ contentType: z14.enum(ApiFileContentTypes).describe("File type of the decoded Base64 value.")
13487
+ }).strict();
13488
+ var apiAgentEmbeddedFilesSchema = z14.array(apiAgentEmbeddedFileSchema).superRefine((embeddedFiles, context) => {
13489
+ const paths = /* @__PURE__ */ new Set();
13490
+ for (const [index, { path: path8 }] of embeddedFiles.entries()) {
13491
+ if (paths.has(path8)) {
13492
+ context.addIssue({
13493
+ code: z14.ZodIssueCode.custom,
13494
+ message: `Embedded file path "${path8}" can only be configured once.`,
13495
+ path: [index, "path"]
13496
+ });
13497
+ }
13498
+ paths.add(path8);
13499
+ }
13500
+ }).describe("Base64 values to decode, upload as permanent files, and replace with file references in the projected API response.");
13501
+
13502
+ // ../common/dist/src/zod-schemas/api-agent-request-file-encoding.schema.js
13503
+ import { z as z15 } from "zod";
13504
+ var API_REQUEST_FILE_PATH_PATTERN = /^[A-Za-z_$][\w$-]*(?:\.[A-Za-z_$][\w$-]*)*$/u;
13505
+ function parseApiRequestFilePath(path8) {
13506
+ if (!API_REQUEST_FILE_PATH_PATTERN.test(path8)) {
13507
+ return void 0;
13508
+ }
13509
+ return path8.split(".");
13510
+ }
13511
+ var apiAgentRequestFileEncodingSchema = z15.object({
13512
+ sourceInput: z15.string().trim().min(1, "File input is required.").refine((path8) => parseApiRequestFilePath(path8) !== void 0, {
13513
+ message: "File input must use an object property path."
13514
+ }).describe("API Agent input containing the file reference to encode."),
13515
+ destinationPath: z15.string().trim().min(1, "Request field is required.").refine((path8) => parseApiRequestFilePath(path8) !== void 0, {
13516
+ message: "Request field must use an object property path."
13517
+ }).describe("JSON request body path where the encoded value is inserted."),
13518
+ encoding: z15.literal("base64").describe("Encoding applied to the source file before insertion.")
13519
+ }).strict();
13520
+ var apiAgentRequestFileEncodingsSchema = z15.array(apiAgentRequestFileEncodingSchema).superRefine((requestFileEncodings, context) => {
13521
+ const destinationPaths = /* @__PURE__ */ new Set();
13522
+ for (const [index, { destinationPath }] of requestFileEncodings.entries()) {
13523
+ if (destinationPaths.has(destinationPath)) {
13524
+ context.addIssue({
13525
+ code: z15.ZodIssueCode.custom,
13526
+ message: `Request field "${destinationPath}" can only be configured once.`,
13527
+ path: [index, "destinationPath"]
13528
+ });
13529
+ }
13530
+ destinationPaths.add(destinationPath);
13531
+ }
13532
+ }).describe("Files to read from API Agent inputs, encode, and insert into the JSON request body.");
13533
+
13534
+ // ../common/dist/src/zod-schemas/api-request-body.schema.js
13535
+ import { z as z16 } from "zod";
13449
13536
  var ApiRequestBodyTypes = [
13450
13537
  "json",
13451
13538
  "multipartFormData",
@@ -13454,20 +13541,20 @@ var ApiRequestBodyTypes = [
13454
13541
  var ApiMethodsWithBody = ["POST", "PUT", "PATCH", "DELETE"];
13455
13542
  var ApiMultipartFormDataFieldTypes = ["text", "file"];
13456
13543
  var MULTIPART_PART_CONTENT_TYPE_PATTERN = /^[A-Za-z0-9!#$&^_.+-]+\/[A-Za-z0-9!#$&^_.+-]+(?:\s*;\s*[A-Za-z0-9!#$&^_.+-]+=(?:"[^"]*"|[A-Za-z0-9!#$&^_.+-]+))*$/u;
13457
- var apiMultipartFormDataFieldSchema = z14.object({
13458
- key: z14.string().describe("Form field name."),
13459
- contentType: z14.string().trim().min(1).regex(MULTIPART_PART_CONTENT_TYPE_PATTERN, {
13544
+ var apiMultipartFormDataFieldSchema = z16.object({
13545
+ key: z16.string().describe("Form field name."),
13546
+ contentType: z16.string().trim().min(1).regex(MULTIPART_PART_CONTENT_TYPE_PATTERN, {
13460
13547
  message: "Content type must be a MIME type like application/json or text/plain; charset=utf-8."
13461
13548
  }).optional().describe("Optional MIME type for this multipart part. Use application/json for text parts that must be sent as JSON."),
13462
- type: z14.enum(ApiMultipartFormDataFieldTypes).optional().describe("Form field type. Defaults to text when omitted. Use file to upload a file asset selected from available inputs."),
13463
- value: z14.string().describe("Form field value.")
13549
+ type: z16.enum(ApiMultipartFormDataFieldTypes).optional().describe("Form field type. Defaults to text when omitted. Use file to upload a file asset selected from available inputs."),
13550
+ value: z16.string().describe("Form field value.")
13464
13551
  }).describe("A multipart form-data field. Defaults to a text field when type is omitted. Set contentType when the receiving API requires a MIME type for the individual part.");
13465
- var apiMultipartFormDataBodySchema = z14.array(apiMultipartFormDataFieldSchema).describe("Multipart form-data body represented as an array of typed form-data fields.");
13466
- var apiFormUrlEncodedFieldSchema = z14.object({
13467
- key: z14.string().describe("Form field name."),
13468
- value: z14.string().describe("Form field value.")
13552
+ var apiMultipartFormDataBodySchema = z16.array(apiMultipartFormDataFieldSchema).describe("Multipart form-data body represented as an array of typed form-data fields.");
13553
+ var apiFormUrlEncodedFieldSchema = z16.object({
13554
+ key: z16.string().describe("Form field name."),
13555
+ value: z16.string().describe("Form field value.")
13469
13556
  }).describe("A form URL-encoded field.");
13470
- var apiFormUrlEncodedBodySchema = z14.array(apiFormUrlEncodedFieldSchema).describe("Form URL-encoded body represented as an array of key/value fields.");
13557
+ var apiFormUrlEncodedBodySchema = z16.array(apiFormUrlEncodedFieldSchema).describe("Form URL-encoded body represented as an array of key/value fields.");
13471
13558
  function isValidApiMultipartFormDataBody({ bodyType, body }) {
13472
13559
  if (bodyType !== "multipartFormData" || body === void 0) {
13473
13560
  return true;
@@ -13482,11 +13569,11 @@ function isValidApiFormUrlEncodedBody({ bodyType, body }) {
13482
13569
  }
13483
13570
 
13484
13571
  // ../common/dist/src/zod-schemas/api-tool.schema.js
13485
- import { z as z16 } from "zod";
13572
+ import { z as z18 } from "zod";
13486
13573
 
13487
13574
  // ../common/dist/src/zod-schemas/output-store-binding.schema.js
13488
- import { z as z15 } from "zod";
13489
- var outputStorePathSchema = z15.string().regex(/^store\.[^\s.]+(?:\.[^\s.]+)*$/u, "Data Store destination must be a fully qualified path such as store.patient.name.");
13575
+ import { z as z17 } from "zod";
13576
+ var outputStorePathSchema = z17.string().regex(/^store\.[^\s.]+(?:\.[^\s.]+)*$/u, "Data Store destination must be a fully qualified path such as store.patient.name.");
13490
13577
 
13491
13578
  // ../common/dist/src/zod-schemas/api-tool.schema.js
13492
13579
  var methodsWithBody = new Set(ApiMethodsWithBody);
@@ -13503,11 +13590,11 @@ function getStaticHttpsBaseUrl(value) {
13503
13590
  const isStaticHttpsBaseUrl = url.protocol === "https:" && url.username === "" && url.password === "" && url.search === "" && url.hash === "";
13504
13591
  return isStaticHttpsBaseUrl ? url : void 0;
13505
13592
  }
13506
- var nangoBaseUrlOverrideSchema = z16.string().trim().superRefine((value, ctx) => {
13593
+ var nangoBaseUrlOverrideSchema = z18.string().trim().superRefine((value, ctx) => {
13507
13594
  const baseUrl = getStaticHttpsBaseUrl(value);
13508
13595
  if (baseUrl === void 0) {
13509
13596
  ctx.addIssue({
13510
- code: z16.ZodIssueCode.custom,
13597
+ code: z18.ZodIssueCode.custom,
13511
13598
  message: "Base URL override must be a static HTTPS URL without credentials, query parameters, fragments, or template placeholders"
13512
13599
  });
13513
13600
  }
@@ -13518,25 +13605,25 @@ var defaultApiResponseCacheConfig = {
13518
13605
  enabled: false,
13519
13606
  ttl: API_RESPONSE_CACHE_DEFAULT_TTL_SECONDS
13520
13607
  };
13521
- var apiResponseCacheConfigObjectSchema = z16.object({
13522
- enabled: z16.boolean().default(defaultApiResponseCacheConfig.enabled).describe("Whether API response caching is enabled for this request."),
13523
- ttl: z16.number().int().positive().default(defaultApiResponseCacheConfig.ttl).describe("Time-to-live for cached successful API responses, measured in seconds.")
13608
+ var apiResponseCacheConfigObjectSchema = z18.object({
13609
+ enabled: z18.boolean().default(defaultApiResponseCacheConfig.enabled).describe("Whether API response caching is enabled for this request."),
13610
+ ttl: z18.number().int().positive().default(defaultApiResponseCacheConfig.ttl).describe("Time-to-live for cached successful API responses, measured in seconds.")
13524
13611
  });
13525
13612
  var apiResponseCacheConfigSchema = apiResponseCacheConfigObjectSchema.optional().describe("Response cache configuration. Successful API responses can be reused across runs for identical rendered requests, with TTL measured in seconds.");
13526
13613
  var apiOutputStorePathSchema = outputStorePathSchema.describe("Fully qualified Data Store path that receives the selected value.");
13527
13614
  var apiOutputStoreBindingShape = {
13528
- jmesPath: z16.string().trim().min(1, "JMESPath is required. Use @ to select the entire response.").describe("JMESPath expression evaluated against the raw API response. Use @ to select the entire response."),
13615
+ jmesPath: z18.string().trim().min(1, "JMESPath is required. Use @ to select the entire response.").describe("JMESPath expression evaluated against the raw API response. Use @ to select the entire response."),
13529
13616
  storePath: apiOutputStorePathSchema,
13530
- arrayMode: z16.enum(["append", "appendList", "replace"]).optional().describe("Required for newly authored array destinations: append adds exactly one item, appendList adds multiple items, and replace sets the complete list. Omit for scalar and Object destinations; Object values replace the complete object. Legacy omitted array modes still append at runtime.")
13617
+ arrayMode: z18.enum(["append", "appendList", "replace"]).optional().describe("Required for newly authored array destinations: append adds exactly one item, appendList adds multiple items, and replace sets the complete list. Omit for scalar and Object destinations; Object values replace the complete object. Legacy omitted array modes still append at runtime.")
13531
13618
  };
13532
- var apiOutputStoreBindingObjectSchema = z16.object(apiOutputStoreBindingShape);
13533
- var apiOutputStoreBindingAuthoringSchema = z16.object(apiOutputStoreBindingShape).strict();
13534
- var legacyApiOutputStoreBindingObjectSchema = z16.object({
13535
- sourcePath: z16.literal("$"),
13619
+ var apiOutputStoreBindingObjectSchema = z18.object(apiOutputStoreBindingShape);
13620
+ var apiOutputStoreBindingAuthoringSchema = z18.object(apiOutputStoreBindingShape).strict();
13621
+ var legacyApiOutputStoreBindingObjectSchema = z18.object({
13622
+ sourcePath: z18.literal("$"),
13536
13623
  storePath: apiOutputStorePathSchema,
13537
- arrayMode: z16.enum(["append", "appendList", "replace"]).optional()
13624
+ arrayMode: z18.enum(["append", "appendList", "replace"]).optional()
13538
13625
  });
13539
- var apiOutputStoreBindingSchema = z16.union([
13626
+ var apiOutputStoreBindingSchema = z18.union([
13540
13627
  apiOutputStoreBindingObjectSchema,
13541
13628
  legacyApiOutputStoreBindingObjectSchema
13542
13629
  ]).transform((binding) => "jmesPath" in binding ? binding : {
@@ -13549,7 +13636,7 @@ function validateUniqueApiOutputStoreBindingPaths(bindings, ctx) {
13549
13636
  for (const [index, { storePath }] of bindings.entries()) {
13550
13637
  if (storePaths.has(storePath)) {
13551
13638
  ctx.addIssue({
13552
- code: z16.ZodIssueCode.custom,
13639
+ code: z18.ZodIssueCode.custom,
13553
13640
  path: [index, "storePath"],
13554
13641
  message: `Data Store destination "${storePath}" can only be written once by this node.`
13555
13642
  });
@@ -13557,32 +13644,44 @@ function validateUniqueApiOutputStoreBindingPaths(bindings, ctx) {
13557
13644
  storePaths.add(storePath);
13558
13645
  }
13559
13646
  }
13560
- var apiOutputStoreBindingsAuthoringSchema = z16.array(apiOutputStoreBindingAuthoringSchema).superRefine(validateUniqueApiOutputStoreBindingPaths).describe("Public authoring mappings from independently selected raw API response values to Data Store destinations.");
13561
- var apiOutputStoreBindingsSchema = z16.array(apiOutputStoreBindingSchema).superRefine(validateUniqueApiOutputStoreBindingPaths).describe("Optional mappings from independently selected raw API response values to Data Store destinations.");
13562
- var apiToolSchema = z16.object({
13563
- name: z16.string().describe("Unique name for the API tool."),
13564
- description: z16.string().describe("Description of what the API tool does. Shown to the agent to help it decide when to use this tool."),
13565
- inputSchema: z16.custom().optional().describe("JSON schema (in serialized Zod format) defining the input parameters for the API call."),
13566
- authInputs: z16.array(z16.object({
13567
- key: z16.string().describe("Parameter key where the auth value will be injected."),
13568
- value: z16.object({
13569
- authId: z16.string().describe("ID of the authentication credential to use."),
13570
- factor: z16.enum(IdentifierTypes).optional().describe("Type of authentication factor.")
13647
+ var apiOutputStoreBindingsAuthoringSchema = z18.array(apiOutputStoreBindingAuthoringSchema).superRefine(validateUniqueApiOutputStoreBindingPaths).describe("Public authoring mappings from independently selected raw API response values to Data Store destinations.");
13648
+ var apiOutputStoreBindingsSchema = z18.array(apiOutputStoreBindingSchema).superRefine(validateUniqueApiOutputStoreBindingPaths).describe("Optional mappings from independently selected raw API response values to Data Store destinations.");
13649
+ var apiToolSchema = z18.object({
13650
+ name: z18.string().describe("Unique name for the API tool."),
13651
+ description: z18.string().describe("Description of what the API tool does. Shown to the agent to help it decide when to use this tool."),
13652
+ inputSchema: z18.custom().optional().describe("JSON schema (in serialized Zod format) defining the input parameters for the API call."),
13653
+ authInputs: z18.array(z18.object({
13654
+ key: z18.string().describe("Parameter key where the auth value will be injected."),
13655
+ value: z18.object({
13656
+ authId: z18.string().describe("ID of the authentication credential to use."),
13657
+ factor: z18.enum(IdentifierTypes).optional().describe("Type of authentication factor.")
13571
13658
  })
13572
13659
  })).optional().describe("Authentication inputs to inject into the API call. Maps parameter keys to saved credentials."),
13573
- type: z16.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]).describe("HTTP method for the API call."),
13574
- url: z16.string().describe("URL template for the API endpoint. Can include placeholders like {paramName} for dynamic values."),
13660
+ type: z18.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]).describe("HTTP method for the API call."),
13661
+ url: z18.string().describe("URL template for the API endpoint. Can include placeholders like {paramName} for dynamic values."),
13575
13662
  baseUrlOverride: nangoBaseUrlOverrideSchema.optional().describe("Optional static base URL override for Nango-backed requests when the endpoint uses a base URL different from the provider default."),
13576
- headers: z16.record(z16.string(), z16.string()).optional().describe("HTTP headers to include in the request. Values can include placeholders."),
13577
- queryParams: z16.record(z16.string(), z16.string()).optional().describe("Query parameters to include in the URL. Values can include placeholders."),
13578
- body: z16.unknown().optional().describe("Request body template. Can include placeholders for dynamic values."),
13579
- bodyType: z16.enum(ApiRequestBodyTypes).optional().describe("Request body encoding mode. Defaults to JSON when omitted. Use multipartFormData for typed form-data fields and formUrlEncoded for application/x-www-form-urlencoded payloads."),
13580
- outputJmesPath: z16.string().optional().describe("JMESPath expression to extract specific data from the API response before returning it to the agent."),
13663
+ headers: z18.record(z18.string(), z18.string()).optional().describe("HTTP headers to include in the request. Values can include placeholders."),
13664
+ queryParams: z18.record(z18.string(), z18.string()).optional().describe("Query parameters to include in the URL. Values can include placeholders."),
13665
+ body: z18.unknown().optional().describe("Request body template. Can include placeholders for dynamic values."),
13666
+ bodyType: z18.enum(ApiRequestBodyTypes).optional().describe("Request body encoding mode. Defaults to JSON when omitted. Use multipartFormData for typed form-data fields and formUrlEncoded for application/x-www-form-urlencoded payloads."),
13667
+ requestFileEncodings: apiAgentRequestFileEncodingsSchema.optional(),
13668
+ outputJmesPath: z18.string().optional().describe("JMESPath expression to extract specific data from the API response before returning it to the agent."),
13669
+ outputMode: z18.enum(ApiAgentOutputModes).optional().describe("How to return the projected API response. File mode stores it as a permanent JSON file."),
13670
+ embeddedFiles: apiAgentEmbeddedFilesSchema.optional(),
13581
13671
  outputStoreBindings: apiOutputStoreBindingsSchema.optional(),
13582
13672
  cacheResponse: apiResponseCacheConfigSchema
13583
13673
  }).refine((data) => !(data.bodyType !== void 0 && !methodsWithBody.has(data.type)), {
13584
13674
  message: "Body type is not supported for this method",
13585
13675
  path: ["bodyType"]
13676
+ }).refine((data) => !data.requestFileEncodings?.length || methodsWithBody.has(data.type), {
13677
+ message: "Request file encoding is not supported for this method",
13678
+ path: ["requestFileEncodings"]
13679
+ }).refine((data) => !data.requestFileEncodings?.length || (data.bodyType ?? "json") === "json", {
13680
+ message: "Request file encoding is only supported for JSON bodies",
13681
+ path: ["requestFileEncodings"]
13682
+ }).refine((data) => !data.requestFileEncodings?.length || data.body !== null && typeof data.body === "object" && !Array.isArray(data.body), {
13683
+ message: "Request file encoding requires a JSON object body",
13684
+ path: ["body"]
13586
13685
  }).refine((data) => isValidApiMultipartFormDataBody({
13587
13686
  bodyType: data.bodyType,
13588
13687
  body: data.body
@@ -13598,48 +13697,48 @@ var apiToolSchema = z16.object({
13598
13697
  }).describe("Custom API tool definition. Allows agents to make HTTP requests to external APIs.");
13599
13698
 
13600
13699
  // ../common/dist/src/zod-schemas/run-limitation.schema.js
13601
- import { z as z17 } from "zod";
13700
+ import { z as z19 } from "zod";
13602
13701
  var MAX_BROWSER_SESSION_DURATION_SECONDS = 6 * 60 * 60;
13603
13702
  var BROWSER_TERMINATION_BUFFER_SECONDS = 60;
13604
13703
  var MAX_AUTOMATION_DURATION_SECONDS = MAX_BROWSER_SESSION_DURATION_SECONDS - BROWSER_TERMINATION_BUFFER_SECONDS;
13605
13704
  var MAX_AUTOMATION_TOOL_CALLS = 500;
13606
13705
  var MAX_AGENT_TOOL_CALLS = 50;
13607
- var maxDurationSecondsSchema = z17.number().min(1).max(MAX_AUTOMATION_DURATION_SECONDS).optional().default(MAX_AUTOMATION_DURATION_SECONDS).describe("Maximum execution duration in seconds. The run will be terminated if it exceeds this limit.");
13608
- var baseRunLimitationSchema = z17.object({
13706
+ var maxDurationSecondsSchema = z19.number().min(1).max(MAX_AUTOMATION_DURATION_SECONDS).optional().default(MAX_AUTOMATION_DURATION_SECONDS).describe("Maximum execution duration in seconds. The run will be terminated if it exceeds this limit.");
13707
+ var baseRunLimitationSchema = z19.object({
13609
13708
  maxDurationSeconds: maxDurationSecondsSchema,
13610
- maxToolCalls: z17.number().optional().describe("Maximum number of tool calls allowed. The run will pause with MAX_TOOL_CALLS_REACHED when exceeded."),
13611
- allowedUrlRegexes: z17.array(z17.string()).optional().describe("Array of regex patterns for URLs the agent is allowed to navigate to. If specified, navigation to non-matching URLs will be blocked.")
13709
+ maxToolCalls: z19.number().optional().describe("Maximum number of tool calls allowed. The run will pause with MAX_TOOL_CALLS_REACHED when exceeded."),
13710
+ allowedUrlRegexes: z19.array(z19.string()).optional().describe("Array of regex patterns for URLs the agent is allowed to navigate to. If specified, navigation to non-matching URLs will be blocked.")
13612
13711
  });
13613
13712
  var automationRunLimitationSchema = baseRunLimitationSchema.extend({
13614
- maxToolCalls: z17.number().optional().default(MAX_AUTOMATION_TOOL_CALLS).describe("Maximum number of tool calls allowed across all agents in the automation.")
13713
+ maxToolCalls: z19.number().optional().default(MAX_AUTOMATION_TOOL_CALLS).describe("Maximum number of tool calls allowed across all agents in the automation.")
13615
13714
  }).optional().default({
13616
13715
  maxDurationSeconds: MAX_AUTOMATION_DURATION_SECONDS,
13617
13716
  maxToolCalls: MAX_AUTOMATION_TOOL_CALLS
13618
13717
  }).describe("Resource limits for the automation run.");
13619
13718
  var agentRunLimitationSchema = baseRunLimitationSchema.extend({
13620
- maxToolCalls: z17.number().optional().default(MAX_AGENT_TOOL_CALLS).describe("Maximum number of tool calls allowed for this agent.")
13719
+ maxToolCalls: z19.number().optional().default(MAX_AGENT_TOOL_CALLS).describe("Maximum number of tool calls allowed for this agent.")
13621
13720
  }).optional().default({
13622
13721
  maxDurationSeconds: MAX_AUTOMATION_DURATION_SECONDS,
13623
13722
  maxToolCalls: MAX_AGENT_TOOL_CALLS
13624
13723
  }).describe("Resource limits for the agent run.");
13625
13724
 
13626
13725
  // ../common/dist/src/zod-schemas/voice-provider-options.schema.js
13627
- import { z as z18 } from "zod";
13628
- var voiceParticipantSchema = z18.object({
13629
- number: z18.string().min(1).optional().describe("Default phone number or endpoint to use for this call participant. Accepts a literal value or a Handlebars template with agent, shared, and context inputs."),
13630
- name: z18.string().min(1).optional().describe("Display name to associate with this call participant."),
13631
- countryCode: z18.enum(["US", "CA"]).optional().describe("Country context for local national phone numbers. US and CA numbers can be safely normalized to E.164 for providers that require it.")
13726
+ import { z as z20 } from "zod";
13727
+ var voiceParticipantSchema = z20.object({
13728
+ number: z20.string().min(1).optional().describe("Default phone number or endpoint to use for this call participant. Accepts a literal value or a Handlebars template with agent, shared, and context inputs."),
13729
+ name: z20.string().min(1).optional().describe("Display name to associate with this call participant."),
13730
+ countryCode: z20.enum(["US", "CA"]).optional().describe("Country context for local national phone numbers. US and CA numbers can be safely normalized to E.164 for providers that require it.")
13632
13731
  }).describe("Default voice call participant settings.");
13633
- var vapiVoiceProviderOptionsSchema = z18.object({
13634
- assistantId: z18.string().min(1).optional().describe("Existing Vapi assistant ID to start or hand off the call to."),
13635
- assistant: z18.record(z18.string(), z18.unknown()).optional().describe("Inline Vapi assistant definition used when an explicit assistantId is not provided."),
13636
- assistantOverrides: z18.record(z18.string(), z18.unknown()).optional().describe("Runtime assistant override payload forwarded to Vapi when starting or handing off a call."),
13732
+ var vapiVoiceProviderOptionsSchema = z20.object({
13733
+ assistantId: z20.string().min(1).optional().describe("Existing Vapi assistant ID to start or hand off the call to."),
13734
+ assistant: z20.record(z20.string(), z20.unknown()).optional().describe("Inline Vapi assistant definition used when an explicit assistantId is not provided."),
13735
+ assistantOverrides: z20.record(z20.string(), z20.unknown()).optional().describe("Runtime assistant override payload forwarded to Vapi when starting or handing off a call."),
13637
13736
  caller: voiceParticipantSchema.optional().describe("Default caller settings for outbound calls."),
13638
13737
  callee: voiceParticipantSchema.optional().describe("Default callee settings for outbound calls."),
13639
- phoneNumberId: z18.string().min(1).optional().describe("Vapi phone number ID used to originate outbound calls."),
13640
- enableDtmf: z18.boolean().optional().describe("Whether the call should support DTMF input.")
13738
+ phoneNumberId: z20.string().min(1).optional().describe("Vapi phone number ID used to originate outbound calls."),
13739
+ enableDtmf: z20.boolean().optional().describe("Whether the call should support DTMF input.")
13641
13740
  }).describe("Configuration options specific to the Vapi voice provider.");
13642
- var voiceProviderOptionsSchema = z18.object({
13741
+ var voiceProviderOptionsSchema = z20.object({
13643
13742
  vapi: vapiVoiceProviderOptionsSchema.optional().describe("Configuration options specific to the Vapi provider.")
13644
13743
  }).describe("Provider-specific voice configuration options. Only the options for the selected voiceProvider are used.");
13645
13744
 
@@ -13651,50 +13750,50 @@ var NangoSupportedMethods = [
13651
13750
  "PATCH",
13652
13751
  "DELETE"
13653
13752
  ];
13654
- var startingUrlSchema = z19.string().refine(isValidUrlOrHandlebarsTemplateString, {
13753
+ var startingUrlSchema = z21.string().refine(isValidUrlOrHandlebarsTemplateString, {
13655
13754
  message: "Starting URL must be a valid URL or Handlebars template"
13656
13755
  }).optional();
13657
- var browserSOMEnvironmentOptionsSchema = z19.object({
13658
- environment: z19.literal("browser").describe("Browser environment using Set of Marks (SOM) for element identification."),
13659
- maxMediaToIncludeInMemory: z19.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
13756
+ var browserSOMEnvironmentOptionsSchema = z21.object({
13757
+ environment: z21.literal("browser").describe("Browser environment using Set of Marks (SOM) for element identification."),
13758
+ maxMediaToIncludeInMemory: z21.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
13660
13759
  somFilter: somFilterConfigSchema.optional().describe("Default SOM overlay filter to apply for each browser iteration until the somFilter tool sets or clears a session filter."),
13661
- saveAuthCookiesAfterRun: z19.boolean().optional().describe("Whether to save authentication cookies after the run completes for reuse in future runs."),
13662
- suppressNativePrint: z19.boolean().optional().describe("Suppress native window.print dialogs for the whole browser session while still recording print calls."),
13760
+ saveAuthCookiesAfterRun: z21.boolean().optional().describe("Whether to save authentication cookies after the run completes for reuse in future runs."),
13761
+ suppressNativePrint: z21.boolean().optional().describe("Suppress native window.print dialogs for the whole browser session while still recording print calls."),
13663
13762
  startingUrl: startingUrlSchema.describe("Initial URL to navigate to when the agent starts. Accepts a valid URL or a Handlebars template with agent inputs. If not provided, uses the current URL of the browser; if this is the first agent, it will be a blank page."),
13664
- browserProvider: z19.nativeEnum(BrowserProviderNames).default(BrowserProviderNames.browserbase).describe("Browser provider to use if this agent is the first in a run to create a browser."),
13763
+ browserProvider: z21.nativeEnum(BrowserProviderNames).default(BrowserProviderNames.browserbase).describe("Browser provider to use if this agent is the first in a run to create a browser."),
13665
13764
  browserProviderOptions: browserProviderOptionsSchema.optional().describe("Provider-specific configuration options for the browser.")
13666
13765
  }).describe("Browser environment configuration using Set of Marks (SOM) for element identification. This is the recommended browser mode for most use cases.");
13667
- var browserCoordinatesEnvironmentOptionsSchema = z19.object({
13668
- environment: z19.literal("browserCoordinates").describe("Browser environment using coordinate-based interactions instead of SOM."),
13669
- maxMediaToIncludeInMemory: z19.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
13670
- saveAuthCookiesAfterRun: z19.boolean().optional().describe("Whether to save authentication cookies after the run completes for reuse in future runs."),
13671
- suppressNativePrint: z19.boolean().optional().describe("Suppress native window.print dialogs for the whole browser session while still recording print calls."),
13766
+ var browserCoordinatesEnvironmentOptionsSchema = z21.object({
13767
+ environment: z21.literal("browserCoordinates").describe("Browser environment using coordinate-based interactions instead of SOM."),
13768
+ maxMediaToIncludeInMemory: z21.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
13769
+ saveAuthCookiesAfterRun: z21.boolean().optional().describe("Whether to save authentication cookies after the run completes for reuse in future runs."),
13770
+ suppressNativePrint: z21.boolean().optional().describe("Suppress native window.print dialogs for the whole browser session while still recording print calls."),
13672
13771
  startingUrl: startingUrlSchema.describe("Initial URL to navigate to when the agent starts. Accepts a valid URL or a Handlebars template with agent inputs. If not provided, uses the current URL of the browser; if this is the first agent, it will be a blank page."),
13673
- browserProvider: z19.nativeEnum(BrowserProviderNames).default(BrowserProviderNames.browserbase).describe("Browser provider to use if this agent is the first in a run to create a browser."),
13772
+ browserProvider: z21.nativeEnum(BrowserProviderNames).default(BrowserProviderNames.browserbase).describe("Browser provider to use if this agent is the first in a run to create a browser."),
13674
13773
  browserProviderOptions: browserProviderOptionsSchema.optional().describe("Provider-specific configuration options for the browser.")
13675
13774
  }).describe("Browser environment configuration using coordinate-based interactions. Use for scenarios where SOM-based identification is insufficient.");
13676
- var guacamoleEnvironmentOptionsSchema = z19.object({
13677
- environment: z19.literal("desktop").describe("Desktop environment using Guacamole for remote desktop access."),
13678
- browserProvider: z19.nativeEnum(BrowserProviderNames).default(BrowserProviderNames.browserbase).describe("Browser provider to use to connect to Guacamole."),
13775
+ var guacamoleEnvironmentOptionsSchema = z21.object({
13776
+ environment: z21.literal("desktop").describe("Desktop environment using Guacamole for remote desktop access."),
13777
+ browserProvider: z21.nativeEnum(BrowserProviderNames).default(BrowserProviderNames.browserbase).describe("Browser provider to use to connect to Guacamole."),
13679
13778
  browserProviderOptions: browserProviderOptionsSchema.optional().describe("Provider-specific configuration options."),
13680
- maxMediaToIncludeInMemory: z19.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
13779
+ maxMediaToIncludeInMemory: z21.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
13681
13780
  startingUrl: startingUrlSchema.describe("Initial URL for the Guacamole connection. Accepts a valid URL or a Handlebars template with agent inputs."),
13682
- useCopyPasteForTyping: z19.boolean().default(false).optional().describe("Use copy-paste instead of keystroke simulation for text input. Can improve reliability in some desktop applications.")
13781
+ useCopyPasteForTyping: z21.boolean().default(false).optional().describe("Use copy-paste instead of keystroke simulation for text input. Can improve reliability in some desktop applications.")
13683
13782
  }).describe("Desktop environment configuration using Guacamole for remote desktop automation.");
13684
- var desktopAppEnvironmentOptionsSchema = z19.object({
13685
- environment: z19.literal("desktopApp").describe("Native application environment for mobile or desktop app automation."),
13686
- maxMediaToIncludeInMemory: z19.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
13783
+ var desktopAppEnvironmentOptionsSchema = z21.object({
13784
+ environment: z21.literal("desktopApp").describe("Native application environment for mobile or desktop app automation."),
13785
+ maxMediaToIncludeInMemory: z21.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
13687
13786
  viewport: viewportSizeSchema.optional().describe(`Target viewport dimensions for screenshots and coordinate-based actions. Defaults to ${BROWSER_DEFAULT_VIEWPORT.width}x${BROWSER_DEFAULT_VIEWPORT.height} when omitted.`)
13688
13787
  }).describe("Native application environment configuration for automating mobile or desktop applications.");
13689
- var minimalEnvironmentOptionsSchema = z19.object({
13690
- environment: z19.literal("minimal").describe("Minimal environment without browser or desktop capabilities. Use for non-UI agents.")
13788
+ var minimalEnvironmentOptionsSchema = z21.object({
13789
+ environment: z21.literal("minimal").describe("Minimal environment without browser or desktop capabilities. Use for non-UI agents.")
13691
13790
  }).describe("Minimal environment configuration for agents that do not require browser or desktop access (e.g., API-only agents).");
13692
- var voiceEnvironmentOptionsSchema = z19.object({
13693
- environment: z19.literal("voice").describe("Hosted voice environment for live phone or audio conversations."),
13694
- voiceProvider: z19.nativeEnum(VoiceProviderNames).default(VoiceProviderNames.vapi).describe("Voice provider to use if this agent is the first in a run to create or attach to a live call."),
13791
+ var voiceEnvironmentOptionsSchema = z21.object({
13792
+ environment: z21.literal("voice").describe("Hosted voice environment for live phone or audio conversations."),
13793
+ voiceProvider: z21.nativeEnum(VoiceProviderNames).default(VoiceProviderNames.vapi).describe("Voice provider to use if this agent is the first in a run to create or attach to a live call."),
13695
13794
  voiceProviderOptions: voiceProviderOptionsSchema.optional().describe("Provider-specific configuration options for voice runtime.")
13696
13795
  }).describe("Voice environment configuration for hosted conversational runtimes such as Vapi.");
13697
- var environmentOptionsSchema = z19.discriminatedUnion("environment", [
13796
+ var environmentOptionsSchema = z21.discriminatedUnion("environment", [
13698
13797
  browserSOMEnvironmentOptionsSchema,
13699
13798
  browserCoordinatesEnvironmentOptionsSchema,
13700
13799
  guacamoleEnvironmentOptionsSchema,
@@ -13705,7 +13804,7 @@ var environmentOptionsSchema = z19.discriminatedUnion("environment", [
13705
13804
  var runSettingsBrowserSOMEnvironmentOptionsSchema = browserSOMEnvironmentOptionsSchema.omit({
13706
13805
  somFilter: true
13707
13806
  }).describe("Browser environment configuration using Set of Marks (SOM) for element identification. This is the recommended browser mode for most use cases.");
13708
- var runSettingsEnvironmentOptionsSchema = z19.discriminatedUnion("environment", [
13807
+ var runSettingsEnvironmentOptionsSchema = z21.discriminatedUnion("environment", [
13709
13808
  runSettingsBrowserSOMEnvironmentOptionsSchema,
13710
13809
  browserCoordinatesEnvironmentOptionsSchema,
13711
13810
  guacamoleEnvironmentOptionsSchema,
@@ -13721,14 +13820,14 @@ var environmentNames = [
13721
13820
  "voice",
13722
13821
  "minimal"
13723
13822
  ];
13724
- var environmentNamesSchema = z19.enum(environmentNames).describe("Available environment types: browser (SOM-based), browserCoordinates (coordinate-based), desktop (Guacamole), desktopApp, voice, or minimal.");
13823
+ var environmentNamesSchema = z21.enum(environmentNames).describe("Available environment types: browser (SOM-based), browserCoordinates (coordinate-based), desktop (Guacamole), desktopApp, voice, or minimal.");
13725
13824
  var DEFAULT_ENVIRONMENT_OPTION = environmentOptionsSchema.parse({
13726
13825
  environment: "browser"
13727
13826
  });
13728
- var passkeyLeaseScopeSchema = z19.enum(["session", "authStep"]).describe("Passkey lock lifetime. session holds the passkey lease for the browser session; authStep starts the lease before WebAuthn is armed for login and releases it after assertion so the passkey can be reused sooner.");
13729
- var resourcePoolReferenceSchema = z19.object({
13730
- id: z19.string().uuid().describe("Unique identifier of the resource pool."),
13731
- type: z19.enum([
13827
+ var passkeyLeaseScopeSchema = z21.enum(["session", "authStep"]).describe("Passkey lock lifetime. session holds the passkey lease for the browser session; authStep starts the lease before WebAuthn is armed for login and releases it after assertion so the passkey can be reused sooner.");
13828
+ var resourcePoolReferenceSchema = z21.object({
13829
+ id: z21.string().uuid().describe("Unique identifier of the resource pool."),
13830
+ type: z21.enum([
13732
13831
  "commandGenerated",
13733
13832
  "proxy",
13734
13833
  "apiAuthentication",
@@ -13738,21 +13837,21 @@ var resourcePoolReferenceSchema = z19.object({
13738
13837
  passkeyLeaseScope: passkeyLeaseScopeSchema.optional()
13739
13838
  });
13740
13839
  var MAX_RESOURCE_POOLS_PER_STARTING_AGENT = 8;
13741
- var resourcePoolsSchema = z19.array(resourcePoolReferenceSchema).max(MAX_RESOURCE_POOLS_PER_STARTING_AGENT, "Only eight resource pools per starting agent are currently supported").optional();
13742
- var agentRunSettingsSchema = z19.object({
13840
+ var resourcePoolsSchema = z21.array(resourcePoolReferenceSchema).max(MAX_RESOURCE_POOLS_PER_STARTING_AGENT, "Only eight resource pools per starting agent are currently supported").optional();
13841
+ var agentRunSettingsSchema = z21.object({
13743
13842
  environmentOptions: runSettingsEnvironmentOptionsSchema.optional().describe("Canonical run-level browser/session settings used when this agent is selected as the run settings source. Agent-owned fields such as startingUrl and maxMediaToIncludeInMemory are intentionally ignored at runtime even if present here."),
13744
13843
  resourcePools: resourcePoolsSchema.describe("Managed resource pools used when this agent is selected as the run settings source. These may be persisted on any agent even when that agent is not currently a top-level run settings source."),
13745
- skipBrowserDebuggerPauses: z19.boolean().optional().describe("Run-level browser session startup setting. When run settings mode is active, this value is snapshotted from runSettings and legacy agent-local values are ignored.")
13844
+ skipBrowserDebuggerPauses: z21.boolean().optional().describe("Run-level browser session startup setting. When run settings mode is active, this value is snapshotted from runSettings and legacy agent-local values are ignored.")
13746
13845
  });
13747
- var remoteFileConnectionSchema = z19.object({
13748
- description: z19.string().describe("Human-readable description of this remote file connection."),
13749
- host: z19.string().describe("Hostname or IP address of the remote server."),
13750
- port: z19.number().describe("Port number for the connection (e.g., 22 for SFTP)."),
13751
- protocol: z19.enum(["sftp"]).describe("Protocol to use for the connection. Currently only SFTP is supported."),
13752
- opItemId: z19.string().describe("1Password item ID containing the credentials."),
13753
- opVaultId: z19.string().describe("1Password vault ID containing the item.")
13846
+ var remoteFileConnectionSchema = z21.object({
13847
+ description: z21.string().describe("Human-readable description of this remote file connection."),
13848
+ host: z21.string().describe("Hostname or IP address of the remote server."),
13849
+ port: z21.number().describe("Port number for the connection (e.g., 22 for SFTP)."),
13850
+ protocol: z21.enum(["sftp"]).describe("Protocol to use for the connection. Currently only SFTP is supported."),
13851
+ opItemId: z21.string().describe("1Password item ID containing the credentials."),
13852
+ opVaultId: z21.string().describe("1Password vault ID containing the item.")
13754
13853
  }).describe("Remote file connection configuration for SFTP access. Credentials are stored securely in 1Password.");
13755
- var workflowIdReusePolicySchema = z19.enum(["ALLOW_DUPLICATE", "ALLOW_DUPLICATE_FAILED_ONLY"]).describe("Controls Temporal workflow ID reuse. ALLOW_DUPLICATE allows rerunning with the same ID. ALLOW_DUPLICATE_FAILED_ONLY only allows reuse if the previous run failed.");
13854
+ var workflowIdReusePolicySchema = z21.enum(["ALLOW_DUPLICATE", "ALLOW_DUPLICATE_FAILED_ONLY"]).describe("Controls Temporal workflow ID reuse. ALLOW_DUPLICATE allows rerunning with the same ID. ALLOW_DUPLICATE_FAILED_ONLY only allows reuse if the previous run failed.");
13756
13855
  var codeLanguages = ["typescript"];
13757
13856
  var windowsAbsolutePathPattern = /^[A-Za-z]:[\\/]/u;
13758
13857
  function hasControlCharacter(value) {
@@ -13764,113 +13863,113 @@ function hasControlCharacter(value) {
13764
13863
  }
13765
13864
  return false;
13766
13865
  }
13767
- function isNormalizedRepoPath(path7) {
13768
- if (path7 === "/") {
13866
+ function isNormalizedRepoPath(path8) {
13867
+ if (path8 === "/") {
13769
13868
  return true;
13770
13869
  }
13771
- if (path7.length === 0 || path7.startsWith("/") || path7.startsWith("\\") || path7.includes("\\") || hasControlCharacter(path7) || windowsAbsolutePathPattern.test(path7)) {
13870
+ if (path8.length === 0 || path8.startsWith("/") || path8.startsWith("\\") || path8.includes("\\") || hasControlCharacter(path8) || windowsAbsolutePathPattern.test(path8)) {
13772
13871
  return false;
13773
13872
  }
13774
- return path7.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== ".." && segment !== ".git");
13873
+ return path8.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== ".." && segment !== ".git");
13775
13874
  }
13776
- function normalizeRepoPath(path7) {
13777
- if (path7 === "/") {
13778
- return path7;
13875
+ function normalizeRepoPath(path8) {
13876
+ if (path8 === "/") {
13877
+ return path8;
13779
13878
  }
13780
- return path7.replaceAll(/\/+$/gu, "");
13879
+ return path8.replaceAll(/\/+$/gu, "");
13781
13880
  }
13782
13881
  var skillPathPattern = /^(?:skills\/.+|automations\/[^/]+\/skills\/.+|automations\/[^/]+\/agents\/[^/]+\/skills\/.+)$/u;
13783
- var repoPathSchema = z19.string().min(1).transform(normalizeRepoPath).refine(isNormalizedRepoPath, {
13882
+ var repoPathSchema = z21.string().min(1).transform(normalizeRepoPath).refine(isNormalizedRepoPath, {
13784
13883
  message: "Path must be a normalized repository-relative path."
13785
13884
  });
13786
- var knowledgeBasePluginPermissionSchema = z19.object({
13885
+ var knowledgeBasePluginPermissionSchema = z21.object({
13787
13886
  path: repoPathSchema.refine(getIsKnowledgeBaseAssetPathAllowed, {
13788
13887
  message: "Knowledge Base paths must be under org, automation, or automation-agent assets."
13789
13888
  }).describe("Repository path the knowledge base plugin can access."),
13790
- access: z19.enum(["read", "write"]).describe("Access level for the path. Write access also grants reads.")
13889
+ access: z21.enum(["read", "write"]).describe("Access level for the path. Write access also grants reads.")
13791
13890
  }).describe("Path-scoped permission for the knowledge base runtime plugin.");
13792
- var knowledgeBaseConfigSchema = z19.object({
13793
- enabled: z19.boolean().default(false).describe("Explicit rollout switch for the knowledge base runtime plugin."),
13794
- permissions: z19.array(knowledgeBasePluginPermissionSchema).min(1).describe("Repository paths the knowledge base plugin can access. Write grants read and write access.")
13891
+ var knowledgeBaseConfigSchema = z21.object({
13892
+ enabled: z21.boolean().default(false).describe("Explicit rollout switch for the knowledge base runtime plugin."),
13893
+ permissions: z21.array(knowledgeBasePluginPermissionSchema).min(1).describe("Repository paths the knowledge base plugin can access. Write grants read and write access.")
13795
13894
  }).describe("Configuration for the knowledge base runtime plugin.");
13796
- var memoryConfigSchema = z19.object({
13797
- enabled: z19.boolean().default(false).describe("Explicit rollout switch for the memory runtime plugin.")
13895
+ var memoryConfigSchema = z21.object({
13896
+ enabled: z21.boolean().default(false).describe("Explicit rollout switch for the memory runtime plugin.")
13798
13897
  }).strict().describe("Configuration for the memory runtime plugin.");
13799
- var skillsConfigSchema = z19.object({
13800
- enabled: z19.boolean().default(false).describe("Explicit rollout switch for the skills runtime plugin."),
13801
- registeredSkills: z19.array(repoPathSchema.refine((path7) => skillPathPattern.test(path7), {
13898
+ var skillsConfigSchema = z21.object({
13899
+ enabled: z21.boolean().default(false).describe("Explicit rollout switch for the skills runtime plugin."),
13900
+ registeredSkills: z21.array(repoPathSchema.refine((path8) => skillPathPattern.test(path8), {
13802
13901
  message: "Skill paths must be under root, automation, or automation-agent skills."
13803
13902
  })).default(() => []).describe("Repository skill root paths available to the skills plugin."),
13804
- canEdit: z19.boolean().default(false).describe("Allows the skills runtime plugin to edit repo skills under the root skills folder.")
13903
+ canEdit: z21.boolean().default(false).describe("Allows the skills runtime plugin to edit repo skills under the root skills folder.")
13805
13904
  }).describe("Configuration for the skills runtime plugin.");
13806
- var agentPluginsConfigSchema = z19.object({
13905
+ var agentPluginsConfigSchema = z21.object({
13807
13906
  knowledgeBase: knowledgeBaseConfigSchema.optional().describe("Enables the knowledge base runtime plugin."),
13808
13907
  memory: memoryConfigSchema.optional().describe("Enables the memory runtime plugin."),
13809
13908
  skills: skillsConfigSchema.optional().describe("Enables the skills runtime plugin.")
13810
13909
  }).optional().describe("Runtime plugins enabled for this agent. Plugin tools are not controlled by the built-in tools allow-list.");
13811
- var baseAgentConfigFieldsSchema = z19.object({
13812
- apiTools: z19.array(apiToolSchema).optional().describe("Custom API tools available to this agent. Each tool defines an HTTP endpoint the agent can call."),
13813
- remoteFileConnections: z19.array(remoteFileConnectionSchema).optional().describe("Remote file server connections for SFTP operations. Enables agents to read/write files on remote servers."),
13910
+ var baseAgentConfigFieldsSchema = z21.object({
13911
+ apiTools: z21.array(apiToolSchema).optional().describe("Custom API tools available to this agent. Each tool defines an HTTP endpoint the agent can call."),
13912
+ remoteFileConnections: z21.array(remoteFileConnectionSchema).optional().describe("Remote file server connections for SFTP operations. Enables agents to read/write files on remote servers."),
13814
13913
  resourcePools: resourcePoolsSchema.describe("Deprecated compatibility shadow of runSettings.resourcePools. Keep mirrored with runSettings.resourcePools during the migration. New runtime logic should prefer runSettings.resourcePools. Maximum 8 pools per starting agent."),
13815
- tools: z19.array(z19.enum(baseToolNames)).optional().default(() => []).describe("List of built-in tools enabled for this agent (e.g., click, clickFill, scroll, navigateTo). Note: reportStop is always included by default, callSpecializedAgent is included if the agent has child agents, and queueAgents is included if queueableAgentIds is configured. An empty array will still have these automatically included tools."),
13816
- knowledgeBase: z19.object({
13817
- namespace: z19.string().describe("Vector database namespace for knowledge retrieval."),
13818
- k: z19.number().describe("Number of results to retrieve from the knowledge base per query.")
13914
+ tools: z21.array(z21.enum(baseToolNames)).optional().default(() => []).describe("List of built-in tools enabled for this agent (e.g., click, clickFill, scroll, navigateTo). Note: reportStop is always included by default, callSpecializedAgent is included if the agent has child agents, and queueAgents is included if queueableAgentIds is configured. An empty array will still have these automatically included tools."),
13915
+ knowledgeBase: z21.object({
13916
+ namespace: z21.string().describe("Vector database namespace for knowledge retrieval."),
13917
+ k: z21.number().describe("Number of results to retrieve from the knowledge base per query.")
13819
13918
  }).optional().describe("Knowledge base configuration for RAG (Retrieval-Augmented Generation). Enables the agent to query a vector database."),
13820
13919
  plugins: agentPluginsConfigSchema,
13821
- maxSessionMessages: z19.number().optional().describe("Maximum number of messages to keep in the agent session memory. Older messages are pruned to stay within this limit."),
13920
+ maxSessionMessages: z21.number().optional().describe("Maximum number of messages to keep in the agent session memory. Older messages are pruned to stay within this limit."),
13822
13921
  environmentOptions: environmentOptionsSchema.optional().default(DEFAULT_ENVIRONMENT_OPTION).describe("Environment configuration for the agent. Default is browser with SOM."),
13823
13922
  runSettings: agentRunSettingsSchema.optional().describe("Run settings persisted on the agent and used when this agent is selected as the settings source for a run while the run-settings rollout is enabled. This is the canonical runtime source for resource pools during the migration. It intentionally mirrors a subset of agent config so settings survive topology changes and can be stored on any agent regardless of that agent's own execution environment. Writers may populate this before the rollout flag is enabled, but runtime snapshotting must keep using legacy fields while the flag is disabled."),
13824
- skipBrowserDebuggerPauses: z19.boolean().optional().describe("Legacy agent-local browser session startup setting. Used only when a run is in legacy config mode; canonical run settings mode reads runSettings.skipBrowserDebuggerPauses instead."),
13923
+ skipBrowserDebuggerPauses: z21.boolean().optional().describe("Legacy agent-local browser session startup setting. Used only when a run is in legacy config mode; canonical run settings mode reads runSettings.skipBrowserDebuggerPauses instead."),
13825
13924
  limitations: agentRunLimitationSchema.describe("Resource limits for this agent, including maximum duration and tool call limits."),
13826
- commonParametersSchema: z19.custom().optional().describe("Custom schema defining metadata the agent must provide with every tool call. By default, agents provide reasoning and step information. If specified, this schema replaces the default metadata schema entirely."),
13827
- idempotencySettings: z19.object({
13828
- include: z19.array(z19.string()).optional().describe("Input field names to include in the idempotency key. If specified, only these fields are used."),
13829
- exclude: z19.array(z19.string()).optional().describe("Input field names to exclude from the idempotency key. Ignored if include is specified."),
13925
+ commonParametersSchema: z21.custom().optional().describe("Custom schema defining metadata the agent must provide with every tool call. By default, agents provide reasoning and step information. If specified, this schema replaces the default metadata schema entirely."),
13926
+ idempotencySettings: z21.object({
13927
+ include: z21.array(z21.string()).optional().describe("Input field names to include in the idempotency key. If specified, only these fields are used."),
13928
+ exclude: z21.array(z21.string()).optional().describe("Input field names to exclude from the idempotency key. Ignored if include is specified."),
13830
13929
  workflowIdReusePolicy: workflowIdReusePolicySchema.optional().default("ALLOW_DUPLICATE").describe("Policy for reusing Temporal workflow IDs.")
13831
13930
  }).optional().describe("Idempotency settings for preventing duplicate runs. Controls which input fields contribute to the unique run identifier."),
13832
- taskQueue: z19.string().optional().describe("Temporal task queue name for this agent. If specified, queued child agents run on this queue instead of the parent queue."),
13833
- waitUponQueueing: z19.boolean().optional().default(false).describe("If true, wait for queued child agents to complete before proceeding."),
13834
- queueableAgentIds: z19.array(brandedStringValidator("agentId")).optional().default(() => []).describe("List of agent IDs that this agent can queue using the queueAgents tool. Enables the agent to run a new automation with a different agent as the starting point."),
13835
- callableAgentIds: z19.array(brandedStringValidator("agentId")).optional().describe("List of external root agent IDs that this agent can call using the callSpecializedAgent tool. Same-automation callable agents continue to be configured by graph connections."),
13836
- queuedAgentVariables: z19.record(brandedStringValidator("agentId"), z19.record(z19.string(), z19.unknown())).optional().describe("Static automation variable values to pass when this agent queues another automation by target agent ID."),
13837
- checkpoint: z19.object({
13838
- name: z19.string().describe("Name for the checkpoint, used for filtering and identification."),
13839
- screenshot: z19.boolean().optional().default(false).describe("Whether to capture a screenshot when creating the checkpoint.")
13931
+ taskQueue: z21.string().optional().describe("Temporal task queue name for this agent. If specified, queued child agents run on this queue instead of the parent queue."),
13932
+ waitUponQueueing: z21.boolean().optional().default(false).describe("If true, wait for queued child agents to complete before proceeding."),
13933
+ queueableAgentIds: z21.array(brandedStringValidator("agentId")).optional().default(() => []).describe("List of agent IDs that this agent can queue using the queueAgents tool. Enables the agent to run a new automation with a different agent as the starting point."),
13934
+ callableAgentIds: z21.array(brandedStringValidator("agentId")).optional().describe("List of external root agent IDs that this agent can call using the callSpecializedAgent tool. Same-automation callable agents continue to be configured by graph connections."),
13935
+ queuedAgentVariables: z21.record(brandedStringValidator("agentId"), z21.record(z21.string(), z21.unknown())).optional().describe("Static automation variable values to pass when this agent queues another automation by target agent ID."),
13936
+ checkpoint: z21.object({
13937
+ name: z21.string().describe("Name for the checkpoint, used for filtering and identification."),
13938
+ screenshot: z21.boolean().optional().default(false).describe("Whether to capture a screenshot when creating the checkpoint.")
13840
13939
  }).optional().describe("Checkpoint configuration. When set, agent iterations are recorded as checkpoints for auditing and debugging."),
13841
- systemPrompt: z19.string().optional().describe("Custom system prompt that replaces the default system prompt for this agent. Combined with automation-level and agent-level additionalSystemPrompt values."),
13842
- additionalSystemPrompt: z19.string().optional().describe("Additional instructions appended to the system prompt for this agent. Combined with automation-level additionalSystemPrompt."),
13940
+ systemPrompt: z21.string().optional().describe("Custom system prompt that replaces the default system prompt for this agent. Combined with automation-level and agent-level additionalSystemPrompt values."),
13941
+ additionalSystemPrompt: z21.string().optional().describe("Additional instructions appended to the system prompt for this agent. Combined with automation-level additionalSystemPrompt."),
13843
13942
  // Backlinking metadata for imported agents
13844
- importedFrom: z19.object({
13943
+ importedFrom: z21.object({
13845
13944
  automationId: brandedStringValidator("draftAutomationId").describe("ID of the source automation from which this agent was imported."),
13846
13945
  originalAgentId: brandedStringValidator("agentId").describe("Original agent ID in the source automation.")
13847
13946
  }).optional().describe("Metadata for agents imported from another automation. Used for traceability and updates."),
13848
- ignoreUnstableSessionState: z19.boolean().optional().describe("When true, skips screenshot consistency checks before tool execution. Overrides the automation-level ignoreUnstableSessionState setting."),
13849
- pointOfNoReturn: z19.object({
13850
- keyFields: z19.array(z19.string().trim().min(1).refine((keyField) => parsePointOfNoReturnKeyFieldPath(keyField) !== void 0, "PONR key fields must start with input. or store. and use safe path segments")).min(1).describe("Paths resolved against the current node input or automation store into the work-item business key. A path that cannot be resolved fails closed.")
13947
+ ignoreUnstableSessionState: z21.boolean().optional().describe("When true, skips screenshot consistency checks before tool execution. Overrides the automation-level ignoreUnstableSessionState setting."),
13948
+ pointOfNoReturn: z21.object({
13949
+ keyFields: z21.array(z21.string().trim().min(1).refine((keyField) => parsePointOfNoReturnKeyFieldPath(keyField) !== void 0, "PONR key fields must start with input. or store. and use safe path segments")).min(1).describe("Paths resolved against the current node input or automation store into the work-item business key. A path that cannot be resolved fails closed.")
13851
13950
  }).optional().describe("Marks this node as a point of no return. Once the work item identified by keyFields crosses this node, the node and everything downstream never auto-run again; recovery is override-only.")
13852
13951
  }).superRefine((config, ctx) => {
13853
13952
  if (config.resourcePools !== void 0 && config.runSettings?.resourcePools !== void 0 && !isDeepEqualAndSameType(config.resourcePools, config.runSettings.resourcePools)) {
13854
13953
  ctx.addIssue({
13855
- code: z19.ZodIssueCode.custom,
13954
+ code: z21.ZodIssueCode.custom,
13856
13955
  path: ["runSettings", "resourcePools"],
13857
13956
  message: "runSettings.resourcePools must match resourcePools when both are provided"
13858
13957
  });
13859
13958
  }
13860
13959
  });
13861
13960
  var agenticAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
13862
- type: z19.literal("agentic").describe("Agentic agent type - autonomous AI agent with tool calling capabilities."),
13961
+ type: z21.literal("agentic").describe("Agentic agent type - autonomous AI agent with tool calling capabilities."),
13863
13962
  model: agentModelConfigSchema.describe("LLM model configuration for this agentic agent.")
13864
13963
  }).describe("Agentic agent configuration. Uses an LLM to autonomously decide which tools to call to accomplish tasks.");
13865
13964
  var codeAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
13866
- type: z19.literal("code").describe("Code agent type - executes predefined code instead of LLM-driven decisions."),
13867
- language: z19.enum(codeLanguages).default("typescript").describe("Programming language for the agent code. Currently only TypeScript is supported.")
13965
+ type: z21.literal("code").describe("Code agent type - executes predefined code instead of LLM-driven decisions."),
13966
+ language: z21.enum(codeLanguages).default("typescript").describe("Programming language for the agent code. Currently only TypeScript is supported.")
13868
13967
  }).describe("Code agent configuration. Executes predefined TypeScript code instead of using LLM-driven decision making.");
13869
13968
  var outputStoreSourcePathRegex = /^[$A-Z_a-z][\w$]*(?:\.[$A-Z_a-z][\w$]*)*$/u;
13870
- var outputStoreBindingSchema = z19.object({
13871
- sourcePath: z19.string().refine((sourcePath) => sourcePath === "$" || outputStoreSourcePathRegex.test(sourcePath), 'Output source path must be "$" or a dot path such as patient.name.').describe("Dot path of the node output value to write."),
13969
+ var outputStoreBindingSchema = z21.object({
13970
+ sourcePath: z21.string().refine((sourcePath) => sourcePath === "$" || outputStoreSourcePathRegex.test(sourcePath), 'Output source path must be "$" or a dot path such as patient.name.').describe("Dot path of the node output value to write."),
13872
13971
  storePath: outputStorePathSchema.describe("Fully qualified Data Store path that receives the output."),
13873
- arrayMode: z19.enum(["append", "appendList", "replace"]).optional().describe("Required for newly authored array destinations: append adds exactly one item, appendList adds multiple items, and replace sets the complete list. Omit for scalar and Object destinations; Object values replace the complete object. Legacy omitted array modes still append at runtime.")
13972
+ arrayMode: z21.enum(["append", "appendList", "replace"]).optional().describe("Required for newly authored array destinations: append adds exactly one item, appendList adds multiple items, and replace sets the complete list. Omit for scalar and Object destinations; Object values replace the complete object. Legacy omitted array modes still append at runtime.")
13874
13973
  }).describe("Maps one node output value to one Data Store destination.");
13875
13974
  function validateUniqueOutputStoreBindings(bindings, ctx) {
13876
13975
  const sourcePaths = /* @__PURE__ */ new Set();
@@ -13878,7 +13977,7 @@ function validateUniqueOutputStoreBindings(bindings, ctx) {
13878
13977
  for (const [index, { sourcePath, storePath }] of bindings.entries()) {
13879
13978
  if (sourcePaths.has(sourcePath)) {
13880
13979
  ctx.addIssue({
13881
- code: z19.ZodIssueCode.custom,
13980
+ code: z21.ZodIssueCode.custom,
13882
13981
  path: [index, "sourcePath"],
13883
13982
  message: `Output source path "${sourcePath}" can only have one Data Store destination.`
13884
13983
  });
@@ -13886,7 +13985,7 @@ function validateUniqueOutputStoreBindings(bindings, ctx) {
13886
13985
  sourcePaths.add(sourcePath);
13887
13986
  if (storePaths.has(storePath)) {
13888
13987
  ctx.addIssue({
13889
- code: z19.ZodIssueCode.custom,
13988
+ code: z21.ZodIssueCode.custom,
13890
13989
  path: [index, "storePath"],
13891
13990
  message: `Data Store destination "${storePath}" can only be written once by this node.`
13892
13991
  });
@@ -13894,12 +13993,12 @@ function validateUniqueOutputStoreBindings(bindings, ctx) {
13894
13993
  storePaths.add(storePath);
13895
13994
  }
13896
13995
  }
13897
- var extractOutputStoreBindingsSchema = z19.array(outputStoreBindingSchema).superRefine((bindings, ctx) => {
13996
+ var extractOutputStoreBindingsSchema = z21.array(outputStoreBindingSchema).superRefine((bindings, ctx) => {
13898
13997
  validateUniqueOutputStoreBindings(bindings, ctx);
13899
13998
  for (const [index, { sourcePath }] of bindings.entries()) {
13900
13999
  if (sourcePath === "$") {
13901
14000
  ctx.addIssue({
13902
- code: z19.ZodIssueCode.custom,
14001
+ code: z21.ZodIssueCode.custom,
13903
14002
  path: [index, "sourcePath"],
13904
14003
  message: "Extract output bindings must use a declared output path."
13905
14004
  });
@@ -13907,62 +14006,65 @@ var extractOutputStoreBindingsSchema = z19.array(outputStoreBindingSchema).super
13907
14006
  }
13908
14007
  }).describe("Optional mappings from declared Extract output fields to Data Store destinations.");
13909
14008
  var extractAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
13910
- type: z19.literal("extract").describe("Extract agent type - specialized for structured data extraction."),
14009
+ type: z21.literal("extract").describe("Extract agent type - specialized for structured data extraction."),
13911
14010
  model: agentModelConfigSchema.describe("LLM model configuration for this extract agent."),
13912
14011
  outputStoreBindings: extractOutputStoreBindingsSchema.optional()
13913
14012
  }).describe("Extract agent configuration. Specialized for extracting structured data from files according to a defined output schema.");
13914
- var OutcomePayloadSchema = z19.object({
13915
- id: z19.string().min(1).describe("Unique identifier for the outcome."),
13916
- input: z19.record(z19.string(), z19.unknown()).describe("Input data for the outcome. Maps parameter keys to values."),
13917
- preview: z19.string().describe("Rendered text representation of the outcome.")
14013
+ var OutcomePayloadSchema = z21.object({
14014
+ id: z21.string().min(1).describe("Unique identifier for the outcome."),
14015
+ input: z21.record(z21.string(), z21.unknown()).describe("Input data for the outcome. Maps parameter keys to values."),
14016
+ preview: z21.string().describe("Rendered text representation of the outcome.")
13918
14017
  });
13919
14018
  var branchAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
13920
- type: z19.literal("branch").describe("Decision agent type - makes decisions to route to different agents."),
14019
+ type: z21.literal("branch").describe("Decision agent type - makes decisions to route to different agents."),
13921
14020
  model: agentModelConfigSchema.describe("LLM model configuration for this decision agent."),
13922
- includeScreenshot: z19.boolean().optional().describe("Whether to include the previous agent's screen state in this decision agent's decision context."),
13923
- conditionsAndOutcomes: z19.object({
13924
- if: z19.array(z19.object({
13925
- caseName: z19.string().describe("Name of the condition case."),
13926
- condition: z19.string().min(1).describe("Condition to evaluate."),
13927
- outcome: z19.array(OutcomePayloadSchema).describe("Outcomes to return if the condition is met.")
14021
+ includeScreenshot: z21.boolean().optional().describe("Whether to include the previous agent's screen state in this decision agent's decision context."),
14022
+ conditionsAndOutcomes: z21.object({
14023
+ if: z21.array(z21.object({
14024
+ caseName: z21.string().describe("Name of the condition case."),
14025
+ condition: z21.string().min(1).describe("Condition to evaluate."),
14026
+ outcome: z21.array(OutcomePayloadSchema).describe("Outcomes to return if the condition is met.")
13928
14027
  })).min(1).describe("Conditions and outcomes for the decision agent."),
13929
- else: z19.array(OutcomePayloadSchema).min(1).describe("Outcomes to return if the condition is not met.")
14028
+ else: z21.array(OutcomePayloadSchema).min(1).describe("Outcomes to return if the condition is not met.")
13930
14029
  }).describe("Conditions and outcomes for the decision agent, including a fallback outcome.")
13931
14030
  }).describe("Decision agent configuration. Makes decisions about which agent to call next based on the current context.");
13932
14031
  var draftBranchAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
13933
- type: z19.literal("branch").describe("Decision agent draft configuration. Allows incomplete conditions and outcomes while the agent is still being authored."),
14032
+ type: z21.literal("branch").describe("Decision agent draft configuration. Allows incomplete conditions and outcomes while the agent is still being authored."),
13934
14033
  model: agentModelConfigSchema.describe("LLM model configuration for this decision agent."),
13935
- includeScreenshot: z19.boolean().optional().describe("Whether to include the previous agent's screen state in this decision agent's decision context."),
13936
- conditionsAndOutcomes: z19.object({
13937
- if: z19.array(z19.object({
13938
- caseName: z19.string().describe("Name of the condition case."),
13939
- condition: z19.string().describe("Condition to evaluate. Draft saves may include an empty placeholder while the user is still editing."),
13940
- outcome: z19.array(OutcomePayloadSchema).describe("Outcomes to return if the condition is met.")
14034
+ includeScreenshot: z21.boolean().optional().describe("Whether to include the previous agent's screen state in this decision agent's decision context."),
14035
+ conditionsAndOutcomes: z21.object({
14036
+ if: z21.array(z21.object({
14037
+ caseName: z21.string().describe("Name of the condition case."),
14038
+ condition: z21.string().describe("Condition to evaluate. Draft saves may include an empty placeholder while the user is still editing."),
14039
+ outcome: z21.array(OutcomePayloadSchema).describe("Outcomes to return if the condition is met.")
13941
14040
  })).describe("Draft decision conditions and outcomes."),
13942
- else: z19.array(OutcomePayloadSchema).describe("Draft fallback outcomes for the decision agent. May be empty while the decision agent is still being configured.")
14041
+ else: z21.array(OutcomePayloadSchema).describe("Draft fallback outcomes for the decision agent. May be empty while the decision agent is still being configured.")
13943
14042
  }).describe("Draft conditions and outcomes for the decision agent, including an optional fallback outcome while editing.")
13944
14043
  }).describe("Decision agent draft configuration. More permissive than the authored decision schema so incomplete decision agents can be saved.");
13945
14044
  var METHODS_WITH_BODY = new Set(ApiMethodsWithBody);
13946
14045
  var apiAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
13947
- type: z19.literal("api").describe("API agent type - makes HTTP requests to external APIs."),
13948
- method: z19.enum(NangoSupportedMethods).describe("HTTP method for the API request (GET, POST, PUT, PATCH, DELETE)."),
13949
- url: z19.string().describe("URL for the API endpoint. Can include placeholders like {paramName} for dynamic values from inputs."),
14046
+ type: z21.literal("api").describe("API agent type - makes HTTP requests to external APIs."),
14047
+ method: z21.enum(NangoSupportedMethods).describe("HTTP method for the API request (GET, POST, PUT, PATCH, DELETE)."),
14048
+ url: z21.string().describe("URL for the API endpoint. Can include placeholders like {paramName} for dynamic values from inputs."),
13950
14049
  baseUrlOverride: nangoBaseUrlOverrideSchema.optional().describe("Optional static base URL override for Nango-backed requests. Use when the request endpoint is hosted on a base URL different from the Nango provider default."),
13951
- headers: z19.array(z19.object({ key: z19.string(), value: z19.string() })).optional().describe("HTTP headers to include in the request. Values can include placeholders."),
13952
- queryParams: z19.array(z19.object({ key: z19.string(), value: z19.string() })).optional().describe("Query parameters to append to the URL. Values can include placeholders."),
13953
- body: z19.unknown().optional().describe("Request body for POST/PUT/PATCH requests. Can include placeholders for dynamic values."),
13954
- bodyType: z19.enum(ApiRequestBodyTypes).optional().describe("Request body encoding mode. Defaults to JSON when omitted. Use multipartFormData for typed form-data fields and formUrlEncoded for application/x-www-form-urlencoded payloads."),
13955
- outputJmesPath: z19.string().optional().describe("JMESPath expression to extract specific data from the API response before returning it."),
14050
+ headers: z21.array(z21.object({ key: z21.string(), value: z21.string() })).optional().describe("HTTP headers to include in the request. Values can include placeholders."),
14051
+ queryParams: z21.array(z21.object({ key: z21.string(), value: z21.string() })).optional().describe("Query parameters to append to the URL. Values can include placeholders."),
14052
+ body: z21.unknown().optional().describe("Request body for POST/PUT/PATCH requests. Can include placeholders for dynamic values."),
14053
+ bodyType: z21.enum(ApiRequestBodyTypes).optional().describe("Request body encoding mode. Defaults to JSON when omitted. Use multipartFormData for typed form-data fields and formUrlEncoded for application/x-www-form-urlencoded payloads."),
14054
+ requestFileEncodings: apiAgentRequestFileEncodingsSchema.optional(),
14055
+ outputJmesPath: z21.string().optional().describe("JMESPath expression to extract specific data from the API response before returning it."),
14056
+ outputMode: z21.enum(ApiAgentOutputModes).optional().describe("How to return the projected API response. File mode stores it as a permanent JSON file."),
14057
+ embeddedFiles: apiAgentEmbeddedFilesSchema.optional(),
13956
14058
  outputStoreBindings: apiOutputStoreBindingsSchema.optional(),
13957
14059
  cacheResponse: apiResponseCacheConfigSchema.describe("Response cache configuration for this API agent. TTL is measured in seconds."),
13958
- authentication: z19.discriminatedUnion("type", [
13959
- z19.object({
13960
- type: z19.literal("nangoConnection").describe("Authentication via Nango integration."),
13961
- providerConfigKey: z19.string().describe('The provider config key for the integration (e.g., "github", "slack").'),
14060
+ authentication: z21.discriminatedUnion("type", [
14061
+ z21.object({
14062
+ type: z21.literal("nangoConnection").describe("Authentication via Nango integration."),
14063
+ providerConfigKey: z21.string().describe('The provider config key for the integration (e.g., "github", "slack").'),
13962
14064
  poolId: brandedStringValidator("resourcePoolId").optional().describe("ID of the resource pool containing authentication credentials.")
13963
14065
  }),
13964
- z19.object({
13965
- type: z19.literal("customHost").describe("Authentication via 1Password credentials for custom host."),
14066
+ z21.object({
14067
+ type: z21.literal("customHost").describe("Authentication via 1Password credentials for custom host."),
13966
14068
  poolId: brandedStringValidator("resourcePoolId").optional().describe("ID of the resource pool containing 1Password authentication.")
13967
14069
  })
13968
14070
  ]).optional().describe("Authentication configuration for the API request. Uses credentials from a resource pool.")
@@ -13972,6 +14074,15 @@ var apiAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
13972
14074
  }).refine((data) => !(data.bodyType !== void 0 && !METHODS_WITH_BODY.has(data.method)), {
13973
14075
  message: "Body type is not supported for this method",
13974
14076
  path: ["bodyType"]
14077
+ }).refine((data) => !data.requestFileEncodings?.length || METHODS_WITH_BODY.has(data.method), {
14078
+ message: "Request file encoding is not supported for this method",
14079
+ path: ["requestFileEncodings"]
14080
+ }).refine((data) => !data.requestFileEncodings?.length || (data.bodyType ?? "json") === "json", {
14081
+ message: "Request file encoding is only supported for JSON bodies",
14082
+ path: ["requestFileEncodings"]
14083
+ }).refine((data) => !data.requestFileEncodings?.length || data.body !== null && typeof data.body === "object" && !Array.isArray(data.body), {
14084
+ message: "Request file encoding requires a JSON object body",
14085
+ path: ["body"]
13975
14086
  }).refine((data) => isValidApiMultipartFormDataBody({
13976
14087
  bodyType: data.bodyType,
13977
14088
  body: data.body
@@ -13989,10 +14100,10 @@ var apiAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
13989
14100
  path: ["baseUrlOverride"]
13990
14101
  }).describe("API agent configuration. Makes HTTP requests to external APIs without LLM decision making. Supports authentication via Nango connections.");
13991
14102
  var specializedAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
13992
- type: z19.literal("specialized").describe("Specialized agent type - runs a published specialized automation."),
13993
- specializedAutomationId: z19.string().min(1).describe("ID of the specialized automation to run.")
14103
+ type: z21.literal("specialized").describe("Specialized agent type - runs a published specialized automation."),
14104
+ specializedAutomationId: z21.string().min(1).describe("ID of the specialized automation to run.")
13994
14105
  }).describe("Specialized agent configuration. Runs a specialized automation shared by another organization and returns its output.");
13995
- var agentConfigSchemaUnion = z19.discriminatedUnion("type", [
14106
+ var agentConfigSchemaUnion = z21.discriminatedUnion("type", [
13996
14107
  agenticAgentConfigSchema,
13997
14108
  codeAgentConfigSchema,
13998
14109
  extractAgentConfigSchema,
@@ -14000,13 +14111,13 @@ var agentConfigSchemaUnion = z19.discriminatedUnion("type", [
14000
14111
  apiAgentConfigSchema,
14001
14112
  specializedAgentConfigSchema
14002
14113
  ]).describe("Agent configuration discriminated by type. Types: agentic (LLM-driven), code (predefined code), extract (data extraction), branch (routing decisions), api (HTTP requests), specialized (shared specialized automation).");
14003
- var agentConfigSchema = z19.preprocess((data) => {
14114
+ var agentConfigSchema = z21.preprocess((data) => {
14004
14115
  if (typeof data === "object" && data !== null && !("type" in data)) {
14005
14116
  return { ...data, type: "agentic" };
14006
14117
  }
14007
14118
  return data;
14008
14119
  }, agentConfigSchemaUnion).describe("Agent configuration. Defines the agent type, environment, available tools, model settings, and behavior options. If type is omitted, defaults to agentic.");
14009
- var draftAgentConfigSchemaUnion = z19.discriminatedUnion("type", [
14120
+ var draftAgentConfigSchemaUnion = z21.discriminatedUnion("type", [
14010
14121
  agenticAgentConfigSchema,
14011
14122
  codeAgentConfigSchema,
14012
14123
  extractAgentConfigSchema,
@@ -14014,7 +14125,7 @@ var draftAgentConfigSchemaUnion = z19.discriminatedUnion("type", [
14014
14125
  apiAgentConfigSchema,
14015
14126
  specializedAgentConfigSchema
14016
14127
  ]).describe("Draft agent configuration discriminated by type. Uses a more permissive decision schema so incomplete decision agents can be saved before publish-time validation.");
14017
- var draftAgentConfigSchema = z19.preprocess((data) => {
14128
+ var draftAgentConfigSchema = z21.preprocess((data) => {
14018
14129
  if (typeof data === "object" && data !== null && !("type" in data)) {
14019
14130
  return { ...data, type: "agentic" };
14020
14131
  }
@@ -14023,66 +14134,66 @@ var draftAgentConfigSchema = z19.preprocess((data) => {
14023
14134
  var DEFAULT_AGENT_CONFIG = agentConfigSchema.parse({});
14024
14135
 
14025
14136
  // ../common/dist/src/zod-schemas/automation-store-migration-analyzer.schema.js
14026
- import { z as z20 } from "zod";
14027
- var automationStoreMigrationMappingSchema = z20.object({
14028
- sourceAutomationId: z20.string().uuid(),
14029
- sourceAgentId: z20.string().uuid().optional(),
14030
- sourceKind: z20.enum(["input", "output", "sharedInput"]),
14031
- sourceKey: z20.string().min(1),
14032
- logicalValueId: z20.string().min(1).optional(),
14033
- outputBindingSourcePath: z20.string().min(1).optional(),
14034
- handling: z20.enum(["store", "keepLocal", "remove"]),
14035
- reason: z20.string().min(1),
14036
- targetStorePath: z20.string().min(1).optional(),
14037
- population: z20.enum([
14137
+ import { z as z23 } from "zod";
14138
+ var automationStoreMigrationMappingSchema = z23.object({
14139
+ sourceAutomationId: z23.string().uuid(),
14140
+ sourceAgentId: z23.string().uuid().optional(),
14141
+ sourceKind: z23.enum(["input", "output", "sharedInput"]),
14142
+ sourceKey: z23.string().min(1),
14143
+ logicalValueId: z23.string().min(1).optional(),
14144
+ outputBindingSourcePath: z23.string().min(1).optional(),
14145
+ handling: z23.enum(["store", "keepLocal", "remove"]),
14146
+ reason: z23.string().min(1),
14147
+ targetStorePath: z23.string().min(1).optional(),
14148
+ population: z23.enum([
14038
14149
  "default",
14039
14150
  "initialStore",
14040
14151
  "outputStoreBinding",
14041
14152
  "updateStoreValues"
14042
14153
  ]).optional(),
14043
- writerAgentId: z20.string().uuid().optional(),
14044
- isWorkItemIdentity: z20.boolean().optional(),
14045
- conversion: z20.string().min(1).optional()
14154
+ writerAgentId: z23.string().uuid().optional(),
14155
+ isWorkItemIdentity: z23.boolean().optional(),
14156
+ conversion: z23.string().min(1).optional()
14046
14157
  });
14047
- var automationStoreMigrationWritePolicySchema = z20.object({
14048
- automationId: z20.string().uuid(),
14049
- path: z20.string().min(1),
14050
- writerAgentIds: z20.array(z20.string().uuid()).min(1),
14051
- coordination: z20.enum([
14158
+ var automationStoreMigrationWritePolicySchema = z23.object({
14159
+ automationId: z23.string().uuid(),
14160
+ path: z23.string().min(1),
14161
+ writerAgentIds: z23.array(z23.string().uuid()).min(1),
14162
+ coordination: z23.enum([
14052
14163
  "singleWriter",
14053
14164
  "mutuallyExclusiveBranches",
14054
14165
  "orderedScalarOverwrite",
14055
14166
  "disjointArrayItems"
14056
14167
  ]),
14057
- arrayRetryStrategy: z20.enum(["notApplicable", "readBeforeAppend"]),
14058
- rationale: z20.string().min(1)
14168
+ arrayRetryStrategy: z23.enum(["notApplicable", "readBeforeAppend"]),
14169
+ rationale: z23.string().min(1)
14059
14170
  });
14060
- var automationStoreMigrationComparisonVersionSchema = z20.object({
14061
- automationId: z20.string().uuid(),
14062
- automationVersionId: z20.string().uuid(),
14063
- role: z20.enum(["beforeMigration", "afterMigration"]),
14064
- slotLifecycle: z20.enum(["existing", "introduced"]).default("existing"),
14065
- slot: z20.string().min(1)
14171
+ var automationStoreMigrationComparisonVersionSchema = z23.object({
14172
+ automationId: z23.string().uuid(),
14173
+ automationVersionId: z23.string().uuid(),
14174
+ role: z23.enum(["beforeMigration", "afterMigration"]),
14175
+ slotLifecycle: z23.enum(["existing", "introduced"]).default("existing"),
14176
+ slot: z23.string().min(1)
14066
14177
  });
14067
- var automationStoreMigrationComparisonSchema = z20.object({
14068
- versions: z20.array(automationStoreMigrationComparisonVersionSchema).min(1).max(40)
14178
+ var automationStoreMigrationComparisonSchema = z23.object({
14179
+ versions: z23.array(automationStoreMigrationComparisonVersionSchema).min(1).max(40)
14069
14180
  });
14070
- var automationStoreMigrationAnalyzerInputSchema = z20.object({
14071
- mode: z20.enum(["audit", "compare", "auditRuntimeEvidence"]).describe("audit reads current drafts; compare reads exact saved versions; auditRuntimeEvidence reads only caller-supplied existing runs and their exact saved versions."),
14072
- automationIds: z20.array(z20.string().uuid()).max(20).default([]).describe("Starting draft automation IDs for audit. The analyzer follows authored queue targets within a bounded organization-scoped traversal."),
14181
+ var automationStoreMigrationAnalyzerInputSchema = z23.object({
14182
+ mode: z23.enum(["audit", "compare", "auditRuntimeEvidence"]).describe("audit reads current drafts; compare reads exact saved versions; auditRuntimeEvidence reads only caller-supplied existing runs and their exact saved versions."),
14183
+ automationIds: z23.array(z23.string().uuid()).max(20).default([]).describe("Starting draft automation IDs for audit. The analyzer follows authored queue targets within a bounded organization-scoped traversal."),
14073
14184
  comparison: automationStoreMigrationComparisonSchema.nullable().default(null).describe("Exact before/after saved-version pairs for compare. Introduced slots require only an afterMigration version."),
14074
- mappings: z20.array(automationStoreMigrationMappingSchema).default([]),
14075
- storeWritePolicies: z20.array(automationStoreMigrationWritePolicySchema).max(100).default([]),
14076
- runIds: z20.array(z20.string().uuid()).max(20).default([]).describe("Existing run IDs to inspect only in auditRuntimeEvidence mode. The analyzer never creates or starts runs."),
14077
- workItem: z20.string().default("").describe("Optional name for the business work item being migrated.")
14185
+ mappings: z23.array(automationStoreMigrationMappingSchema).default([]),
14186
+ storeWritePolicies: z23.array(automationStoreMigrationWritePolicySchema).max(100).default([]),
14187
+ runIds: z23.array(z23.string().uuid()).max(20).default([]).describe("Existing run IDs to inspect only in auditRuntimeEvidence mode. The analyzer never creates or starts runs."),
14188
+ workItem: z23.string().default("").describe("Optional name for the business work item being migrated.")
14078
14189
  });
14079
14190
 
14080
14191
  // ../common/dist/src/zod-schemas/automation-run-config.schema.js
14081
- import { z as z21 } from "zod";
14082
- var automationRunResolvedRunSettingsSchema = z21.object({
14192
+ import { z as z24 } from "zod";
14193
+ var automationRunResolvedRunSettingsSchema = z24.object({
14083
14194
  environmentOptions: runSettingsEnvironmentOptionsSchema.describe("Canonical run-settings-owned environment settings snapshotted onto the automation run when it starts in runSettings mode. Agent-owned fields such as startingUrl and maxMediaToIncludeInMemory are intentionally ignored at runtime."),
14084
14195
  resourcePools: resourcePoolsSchema.describe("Canonical run-settings-owned resource pools snapshotted onto the automation run when it starts in runSettings mode. Slot assignment and queue status use this only when resolvedRunSettingsSource is runSettings."),
14085
- skipBrowserDebuggerPauses: z21.boolean().optional().describe("Canonical run-settings-owned browser session startup setting snapshotted onto the automation run when it starts in runSettings mode.")
14196
+ skipBrowserDebuggerPauses: z24.boolean().optional().describe("Canonical run-settings-owned browser session startup setting snapshotted onto the automation run when it starts in runSettings mode.")
14086
14197
  });
14087
14198
  var CONSISTENCY_CHECK_COUNT_MAX = 50;
14088
14199
  var NETWORK_TRAFFIC_CAPTURE_RECORD_MODES = [
@@ -14090,18 +14201,18 @@ var NETWORK_TRAFFIC_CAPTURE_RECORD_MODES = [
14090
14201
  "explicit"
14091
14202
  ];
14092
14203
  var DEFAULT_NETWORK_TRAFFIC_CAPTURE_RECORD_MODE = "implicit";
14093
- var networkTrafficCaptureSchema = z21.discriminatedUnion("mode", [
14094
- z21.object({
14095
- mode: z21.literal("record"),
14096
- recordMode: z21.enum(NETWORK_TRAFFIC_CAPTURE_RECORD_MODES).optional().default(DEFAULT_NETWORK_TRAFFIC_CAPTURE_RECORD_MODE).describe("Whether this recording was created implicitly by automation infrastructure or explicitly requested by the user. Explicit recordings are retained longer.")
14204
+ var networkTrafficCaptureSchema = z24.discriminatedUnion("mode", [
14205
+ z24.object({
14206
+ mode: z24.literal("record"),
14207
+ recordMode: z24.enum(NETWORK_TRAFFIC_CAPTURE_RECORD_MODES).optional().default(DEFAULT_NETWORK_TRAFFIC_CAPTURE_RECORD_MODE).describe("Whether this recording was created implicitly by automation infrastructure or explicitly requested by the user. Explicit recordings are retained longer.")
14097
14208
  }).describe("Record network traffic for this run. The recording ID is generated from the automation run ID."),
14098
- z21.object({
14099
- mode: z21.literal("replay"),
14100
- recordingId: z21.uuid().describe("Recording ID from a previous record run in the same organization.")
14209
+ z24.object({
14210
+ mode: z24.literal("replay"),
14211
+ recordingId: z24.uuid().describe("Recording ID from a previous record run in the same organization.")
14101
14212
  }).describe("Replay network traffic from a previous recording.")
14102
14213
  ]).describe("Optional network traffic capture mode for this run. Applies to browser provider traffic and supported agent tool HTTP traffic, including API tool calls and provider-authenticated helper requests.");
14103
- var automationRunSlaTypeSchema = z21.enum(["all"]);
14104
- var automationRunSlaTimestampSchema = z21.iso.datetime();
14214
+ var automationRunSlaTypeSchema = z24.enum(["all"]);
14215
+ var automationRunSlaTimestampSchema = z24.iso.datetime();
14105
14216
  function refineAutomationRunSlaTimestampOrder(sla, ctx) {
14106
14217
  const startedAtMs = Date.parse(sla.startedAt);
14107
14218
  const breachesAtMs = Date.parse(sla.breachesAt);
@@ -14131,31 +14242,31 @@ function refineAutomationRunSlaTimestampOrder(sla, ctx) {
14131
14242
  });
14132
14243
  }
14133
14244
  }
14134
- var automationRunSlaSchema = z21.object({
14245
+ var automationRunSlaSchema = z24.object({
14135
14246
  startedAt: automationRunSlaTimestampSchema.describe("ISO timestamp when SLA tracking started for this run."),
14136
14247
  highRiskAt: automationRunSlaTimestampSchema.optional().describe("Optional ISO timestamp when this run should be considered at high risk of breaching its SLA."),
14137
14248
  breachesAt: automationRunSlaTimestampSchema.describe("ISO timestamp when this run breaches its SLA."),
14138
14249
  type: automationRunSlaTypeSchema.optional().default("all").describe("SLA policy type that applies to this automation run.")
14139
14250
  }).superRefine(refineAutomationRunSlaTimestampOrder).describe("Optional service-level timing metadata for queueing and runtime consumers of this automation run.");
14140
- var automationRunConfigBaseSchema = z21.object({
14141
- approvalMode: z21.enum(["HUMAN_APPROVAL", "OFF"]).default("OFF"),
14142
- consistencyCheckCount: z21.number().int().nonnegative().max(CONSISTENCY_CHECK_COUNT_MAX).nullable().default(null),
14143
- settingsSourceAgentId: z21.uuid().nullable().optional().describe("Optional provenance/debug field recording which top-level agent supplied canonical run settings when the run started. Runtime consumers must not use this as a live pointer once resolvedRunSettingsSource has been decided."),
14144
- startInTakeOverMode: z21.boolean().default(false).describe("When true, create and prepare the remote session, then pause until a human manually starts the agent."),
14145
- captureActions: z21.boolean().default(false).describe("When true, attach an action recording while a draft run is paused in takeover mode."),
14146
- runDraftQueuedAgents: z21.boolean().optional().describe("Draft-run-only option. When false, queue-agent actions in the draft run report success without starting downstream queued draft child runs. Omit or true preserves queueing."),
14147
- allowPointOfNoReturnOverride: z21.boolean().optional().describe("Internal rerun authorization. When true, the rerun and its queued descendants may proceed past a point-of-no-return crossing owned by an earlier run."),
14148
- pointOfNoReturnGateEnabled: z21.literal(true).optional().describe("Infrastructure-owned rollout marker. PONR is enforced only for run trees created after the gate rollout."),
14251
+ var automationRunConfigBaseSchema = z24.object({
14252
+ approvalMode: z24.enum(["HUMAN_APPROVAL", "OFF"]).default("OFF"),
14253
+ consistencyCheckCount: z24.number().int().nonnegative().max(CONSISTENCY_CHECK_COUNT_MAX).nullable().default(null),
14254
+ settingsSourceAgentId: z24.uuid().nullable().optional().describe("Optional provenance/debug field recording which top-level agent supplied canonical run settings when the run started. Runtime consumers must not use this as a live pointer once resolvedRunSettingsSource has been decided."),
14255
+ startInTakeOverMode: z24.boolean().default(false).describe("When true, create and prepare the remote session, then pause until a human manually starts the agent."),
14256
+ captureActions: z24.boolean().default(false).describe("When true, attach an action recording while a draft run is paused in takeover mode."),
14257
+ runDraftQueuedAgents: z24.boolean().optional().describe("Draft-run-only option. When false, queue-agent actions in the draft run report success without starting downstream queued draft child runs. Omit or true preserves queueing."),
14258
+ allowPointOfNoReturnOverride: z24.boolean().optional().describe("Internal rerun authorization. When true, the rerun and its queued descendants may proceed past a point-of-no-return crossing owned by an earlier run."),
14259
+ pointOfNoReturnGateEnabled: z24.literal(true).optional().describe("Infrastructure-owned rollout marker. PONR is enforced only for run trees created after the gate rollout."),
14149
14260
  sla: automationRunSlaSchema.optional(),
14150
14261
  networkTrafficCapture: networkTrafficCaptureSchema.optional(),
14151
- networkTrafficCaptureExplicitlyDisabled: z21.literal(true).optional().describe("Infrastructure-owned marker indicating that network traffic capture was explicitly disabled for this run. When present, runtime policy resolution must not enable capture."),
14152
- implicitNetworkTrafficRecordingDecision: z21.object({
14153
- enabled: z21.boolean()
14262
+ networkTrafficCaptureExplicitlyDisabled: z24.literal(true).optional().describe("Infrastructure-owned marker indicating that network traffic capture was explicitly disabled for this run. When present, runtime policy resolution must not enable capture."),
14263
+ implicitNetworkTrafficRecordingDecision: z24.object({
14264
+ enabled: z24.boolean()
14154
14265
  }).optional().describe("Infrastructure-owned snapshot of the implicit network traffic recording flag decision. Runtime retries use this to avoid re-evaluating LaunchDarkly for the same run."),
14155
14266
  resolvedRunSettings: automationRunResolvedRunSettingsSchema.optional().describe("Canonical run settings snapshotted onto the automation run at creation time. Present only for runSettings mode; legacyConfig mode intentionally resolves runtime settings from each current agent config instead of storing a misleading snapshot."),
14156
14267
  queueResourcePools: resourcePoolsSchema.optional().describe("Canonical deduped resource-pool requirements snapshotted for queue and slot assignment. Present on new runs so assignment does not recompute requirements from mutable agent config."),
14157
14268
  credentialVariableResourcePools: resourcePoolsSchema.optional().describe("Additional resource pools selected through credential-valued automation variables. These are additive queue requirements and do not change whether the run uses runSettings or legacyConfig as its runtime settings source."),
14158
- resolvedRunSettingsSource: z21.enum(["runSettings", "legacyConfig"]).optional().describe("Runtime mode decided at run creation. runSettings means resolvedRunSettings is canonical for browser/session/resource-pool behaviour; legacyConfig means runtime consumers must use current agent legacy config fields.")
14269
+ resolvedRunSettingsSource: z24.enum(["runSettings", "legacyConfig"]).optional().describe("Runtime mode decided at run creation. runSettings means resolvedRunSettings is canonical for browser/session/resource-pool behaviour; legacyConfig means runtime consumers must use current agent legacy config fields.")
14159
14270
  });
14160
14271
  var automationRunConfigSchema = automationRunConfigBaseSchema.superRefine((config, ctx) => {
14161
14272
  if (config.networkTrafficCaptureExplicitlyDisabled === true && config.networkTrafficCapture !== void 0) {
@@ -14216,13 +14327,13 @@ function getMentionedStandardCommand(instructions) {
14216
14327
  const normalizedInstructions = instructions.toLowerCase();
14217
14328
  return STANDARD_COMMAND_NAMES.find((commandName) => normalizedInstructions.includes(commandName.toLowerCase())) ?? null;
14218
14329
  }
14219
- function assertCustomInstructionsCommand({ commands, path: path7 }) {
14220
- const customCommands = commands.flatMap((command, commandIndex) => command["commandName"] === "custom" ? [{ command, path: `${path7}[${commandIndex.toString()}]` }] : []);
14330
+ function assertCustomInstructionsCommand({ commands, path: path8 }) {
14331
+ const customCommands = commands.flatMap((command, commandIndex) => command["commandName"] === "custom" ? [{ command, path: `${path8}[${commandIndex.toString()}]` }] : []);
14221
14332
  if (customCommands.length === 0) {
14222
14333
  return;
14223
14334
  }
14224
14335
  if (customCommands.length > MAX_CUSTOM_COMMAND_COUNT) {
14225
- throw createInvalidValueError(`${path7} contains ${customCommands.length.toString()} custom commands. Use at most one short custom command per agent. Split policy, decision, outreach, and multi-step work into catalog commands or child agents instead.`);
14336
+ throw createInvalidValueError(`${path8} contains ${customCommands.length.toString()} custom commands. Use at most one short custom command per agent. Split policy, decision, outreach, and multi-step work into catalog commands or child agents instead.`);
14226
14337
  }
14227
14338
  const [customCommand] = customCommands;
14228
14339
  if (!customCommand) {
@@ -14242,7 +14353,7 @@ function assertCustomInstructionsCommand({ commands, path: path7 }) {
14242
14353
  }
14243
14354
 
14244
14355
  // ../mcp-registry/src/operation-specs.ts
14245
- import { z as z23 } from "zod";
14356
+ import { z as z25 } from "zod";
14246
14357
 
14247
14358
  // ../mcp-registry/src/operation-spec.ts
14248
14359
  function stripLeadingGraphqlComments(document) {
@@ -14346,14 +14457,14 @@ function jsonOption({
14346
14457
  valueType: "json"
14347
14458
  };
14348
14459
  }
14349
- var jsonObjectSchema = z23.record(z23.string(), z23.unknown());
14460
+ var jsonObjectSchema = z25.record(z25.string(), z25.unknown());
14350
14461
  function isRecord3(value) {
14351
14462
  return typeof value === "object" && value !== null && !Array.isArray(value);
14352
14463
  }
14353
14464
  function validateCustomInstructionsCommands({
14354
14465
  commands,
14355
14466
  ctx,
14356
- path: path7
14467
+ path: path8
14357
14468
  }) {
14358
14469
  if (!Array.isArray(commands)) {
14359
14470
  return;
@@ -14361,18 +14472,18 @@ function validateCustomInstructionsCommands({
14361
14472
  const validationResult = fromThrowable(() => {
14362
14473
  assertCustomInstructionsCommand({
14363
14474
  commands: commands.map((command) => isRecord3(command) ? command : {}),
14364
- path: path7.join(".").replaceAll(/\.(?<index>\d+)/gu, "[$<index>]")
14475
+ path: path8.join(".").replaceAll(/\.(?<index>\d+)/gu, "[$<index>]")
14365
14476
  });
14366
14477
  }, "invalid-custom-instructions-command");
14367
14478
  if (isErr(validationResult)) {
14368
14479
  ctx.addIssue({
14369
14480
  code: "custom",
14370
14481
  message: `${getErrorMessage2(validationResult.error.cause)} Run mgcl catalog commands to find the standard command for this work.`,
14371
- path: path7
14482
+ path: path8
14372
14483
  });
14373
14484
  }
14374
14485
  }
14375
- var automationPatchOperationsSchema = z23.array(z23.unknown()).min(1).superRefine((operations, ctx) => {
14486
+ var automationPatchOperationsSchema = z25.array(z25.unknown()).min(1).superRefine((operations, ctx) => {
14376
14487
  for (const [operationIndex, operation] of operations.entries()) {
14377
14488
  if (!isRecord3(operation)) {
14378
14489
  continue;
@@ -14514,9 +14625,9 @@ var operationSpecs = [
14514
14625
  createOperationSpec({
14515
14626
  operationName: "GetCaptureContext",
14516
14627
  kind: "query",
14517
- inputSchema: z23.object({
14518
- automationId: z23.string().min(1).optional(),
14519
- recordingId: z23.string().min(1).optional()
14628
+ inputSchema: z25.object({
14629
+ automationId: z25.string().min(1).optional(),
14630
+ recordingId: z25.string().min(1).optional()
14520
14631
  }).refine(
14521
14632
  ({ automationId, recordingId }) => [automationId, recordingId].some((value) => value !== void 0),
14522
14633
  { message: "Provide --automation-id or --recording-id." }
@@ -14554,8 +14665,8 @@ query GetCaptureContext($automationId: ID, $recordingId: ID) {
14554
14665
  createOperationSpec({
14555
14666
  operationName: "GetAgents",
14556
14667
  kind: "query",
14557
- inputSchema: z23.object({
14558
- ids: z23.array(z23.string().min(1)).min(1)
14668
+ inputSchema: z25.object({
14669
+ ids: z25.array(z25.string().min(1)).min(1)
14559
14670
  }),
14560
14671
  cli: {
14561
14672
  name: "get-agents",
@@ -14616,9 +14727,9 @@ ${agentLimitationsSelection}
14616
14727
  createOperationSpec({
14617
14728
  operationName: "GetAgentVersion",
14618
14729
  kind: "query",
14619
- inputSchema: z23.object({
14620
- agentId: z23.string().min(1),
14621
- versionId: z23.string().min(1)
14730
+ inputSchema: z25.object({
14731
+ agentId: z25.string().min(1),
14732
+ versionId: z25.string().min(1)
14622
14733
  }),
14623
14734
  cli: {
14624
14735
  name: "get-agent-version",
@@ -14681,8 +14792,8 @@ ${agentLimitationsSelection}
14681
14792
  createOperationSpec({
14682
14793
  operationName: "GetAgentVersions",
14683
14794
  kind: "query",
14684
- inputSchema: z23.object({
14685
- agentId: z23.string().min(1)
14795
+ inputSchema: z25.object({
14796
+ agentId: z25.string().min(1)
14686
14797
  }),
14687
14798
  cli: {
14688
14799
  name: "get-agent-versions",
@@ -14716,10 +14827,10 @@ query GetAgentVersions($agentId: ID!) {
14716
14827
  createOperationSpec({
14717
14828
  operationName: "DiffAgentVersion",
14718
14829
  kind: "query",
14719
- inputSchema: z23.object({
14720
- agentId: z23.string().min(1),
14721
- versionId: z23.string().min(1),
14722
- compareVersionId: z23.string().min(1).optional()
14830
+ inputSchema: z25.object({
14831
+ agentId: z25.string().min(1),
14832
+ versionId: z25.string().min(1),
14833
+ compareVersionId: z25.string().min(1).optional()
14723
14834
  }),
14724
14835
  cli: {
14725
14836
  name: "diff-agent-version",
@@ -14773,8 +14884,8 @@ query DiffAgentVersion(
14773
14884
  createOperationSpec({
14774
14885
  operationName: "GetAgentRun",
14775
14886
  kind: "query",
14776
- inputSchema: z23.object({
14777
- id: z23.string().min(1)
14887
+ inputSchema: z25.object({
14888
+ id: z25.string().min(1)
14778
14889
  }),
14779
14890
  cli: {
14780
14891
  name: "get-agent-run",
@@ -14810,8 +14921,8 @@ query GetAgentRun($id: ID!) {
14810
14921
  createOperationSpec({
14811
14922
  operationName: "GetAutomationAgents",
14812
14923
  kind: "query",
14813
- inputSchema: z23.object({
14814
- ids: z23.array(z23.string().min(1)).min(1)
14924
+ inputSchema: z25.object({
14925
+ ids: z25.array(z25.string().min(1)).min(1)
14815
14926
  }),
14816
14927
  cli: {
14817
14928
  name: "get-automation-agents",
@@ -14854,8 +14965,8 @@ query GetAutomationAgents($ids: [ID!]!) {
14854
14965
  createOperationSpec({
14855
14966
  operationName: "GetAutomationDiffFromPublished",
14856
14967
  kind: "query",
14857
- inputSchema: z23.object({
14858
- automationId: z23.string().min(1)
14968
+ inputSchema: z25.object({
14969
+ automationId: z25.string().min(1)
14859
14970
  }),
14860
14971
  cli: {
14861
14972
  name: "get-automation-diff-from-published",
@@ -14888,9 +14999,9 @@ query GetAutomationDiffFromPublished($automationId: ID!) {
14888
14999
  createOperationSpec({
14889
15000
  operationName: "GetAutomationDiffVersions",
14890
15001
  kind: "query",
14891
- inputSchema: z23.object({
14892
- baseVersionId: z23.string().min(1),
14893
- targetVersionId: z23.string().min(1)
15002
+ inputSchema: z25.object({
15003
+ baseVersionId: z25.string().min(1),
15004
+ targetVersionId: z25.string().min(1)
14894
15005
  }),
14895
15006
  cli: {
14896
15007
  name: "get-automation-diff-versions",
@@ -14931,10 +15042,10 @@ query GetAutomationDiffVersions($baseVersionId: ID!, $targetVersionId: ID!) {
14931
15042
  createOperationSpec({
14932
15043
  operationName: "GetAutomationVersionJson",
14933
15044
  kind: "query",
14934
- inputSchema: z23.object({
14935
- versionId: z23.string().min(1),
14936
- paths: z23.array(z23.string().min(1)).optional(),
14937
- format: z23.enum(["normalized", "full", "export"]).optional()
15045
+ inputSchema: z25.object({
15046
+ versionId: z25.string().min(1),
15047
+ paths: z25.array(z25.string().min(1)).optional(),
15048
+ format: z25.enum(["normalized", "full", "export"]).optional()
14938
15049
  }),
14939
15050
  cli: {
14940
15051
  name: "get-automation-version-json",
@@ -14969,8 +15080,8 @@ query GetAutomationVersionJson($versionId: ID!, $paths: [String!], $format: Stri
14969
15080
  createOperationSpec({
14970
15081
  operationName: "GetAutomationVersionJsonSkeleton",
14971
15082
  kind: "query",
14972
- inputSchema: z23.object({
14973
- versionId: z23.string().min(1)
15083
+ inputSchema: z25.object({
15084
+ versionId: z25.string().min(1)
14974
15085
  }),
14975
15086
  cli: {
14976
15087
  name: "get-automation-version-json-skeleton",
@@ -14995,8 +15106,8 @@ query GetAutomationVersionJsonSkeleton($versionId: ID!) {
14995
15106
  createOperationSpec({
14996
15107
  operationName: "GetAutomationRun",
14997
15108
  kind: "query",
14998
- inputSchema: z23.object({
14999
- id: z23.string().min(1)
15109
+ inputSchema: z25.object({
15110
+ id: z25.string().min(1)
15000
15111
  }),
15001
15112
  cli: {
15002
15113
  name: "get-automation-run",
@@ -15036,8 +15147,8 @@ query GetAutomationRun($id: ID!) {
15036
15147
  createOperationSpec({
15037
15148
  operationName: "GetAutomationRunAgentRuns",
15038
15149
  kind: "query",
15039
- inputSchema: z23.object({
15040
- automationRunId: z23.string().min(1)
15150
+ inputSchema: z25.object({
15151
+ automationRunId: z25.string().min(1)
15041
15152
  }),
15042
15153
  cli: {
15043
15154
  name: "get-automation-run-agent-runs",
@@ -15073,11 +15184,11 @@ query GetAutomationRunAgentRuns($automationRunId: ID!) {
15073
15184
  createOperationSpec({
15074
15185
  operationName: "GetAutomationRunIterations",
15075
15186
  kind: "query",
15076
- inputSchema: z23.object({
15077
- automationRunId: z23.string().min(1),
15078
- agentRunId: z23.string().min(1).optional(),
15079
- limit: z23.number().int().positive().optional(),
15080
- reverse: z23.boolean().optional()
15187
+ inputSchema: z25.object({
15188
+ automationRunId: z25.string().min(1),
15189
+ agentRunId: z25.string().min(1).optional(),
15190
+ limit: z25.number().int().positive().optional(),
15191
+ reverse: z25.boolean().optional()
15081
15192
  }),
15082
15193
  cli: {
15083
15194
  name: "get-automation-run-iterations",
@@ -15146,8 +15257,8 @@ query GetAutomationRunIterations(
15146
15257
  createOperationSpec({
15147
15258
  operationName: "InspectPausedAutomationStep",
15148
15259
  kind: "query",
15149
- inputSchema: z23.object({
15150
- runId: z23.string().min(1)
15260
+ inputSchema: z25.object({
15261
+ runId: z25.string().min(1)
15151
15262
  }),
15152
15263
  cli: {
15153
15264
  name: "inspect-paused-automation-step",
@@ -15197,14 +15308,14 @@ query InspectPausedAutomationStep($runId: ID!) {
15197
15308
  createOperationSpec({
15198
15309
  operationName: "GetAutomationRuns",
15199
15310
  kind: "query",
15200
- inputSchema: z23.object({
15201
- automationId: z23.string().min(1).optional(),
15202
- from: z23.string().min(1).optional(),
15203
- status: z23.array(z23.string().min(1)).optional(),
15204
- invocationType: z23.array(z23.string().min(1)).optional(),
15205
- limit: z23.number().int().positive().optional(),
15206
- page: z23.number().int().nonnegative().optional(),
15207
- to: z23.string().min(1).optional()
15311
+ inputSchema: z25.object({
15312
+ automationId: z25.string().min(1).optional(),
15313
+ from: z25.string().min(1).optional(),
15314
+ status: z25.array(z25.string().min(1)).optional(),
15315
+ invocationType: z25.array(z25.string().min(1)).optional(),
15316
+ limit: z25.number().int().positive().optional(),
15317
+ page: z25.number().int().nonnegative().optional(),
15318
+ to: z25.string().min(1).optional()
15208
15319
  }),
15209
15320
  cli: {
15210
15321
  name: "get-automation-runs",
@@ -15286,8 +15397,8 @@ query GetAutomationRuns(
15286
15397
  createOperationSpec({
15287
15398
  operationName: "ListAutomations",
15288
15399
  kind: "query",
15289
- inputSchema: z23.object({
15290
- limit: z23.number().positive().optional(),
15400
+ inputSchema: z25.object({
15401
+ limit: z25.number().positive().optional(),
15291
15402
  order: jsonObjectSchema.optional(),
15292
15403
  where: jsonObjectSchema.optional()
15293
15404
  }),
@@ -15338,8 +15449,8 @@ query ListAutomations(
15338
15449
  createOperationSpec({
15339
15450
  operationName: "GetAutomations",
15340
15451
  kind: "query",
15341
- inputSchema: z23.object({
15342
- ids: z23.array(z23.string().min(1)).min(1)
15452
+ inputSchema: z25.object({
15453
+ ids: z25.array(z25.string().min(1)).min(1)
15343
15454
  }),
15344
15455
  cli: {
15345
15456
  name: "get-automations",
@@ -15457,8 +15568,8 @@ query AnalyzeAutomationStoreMigration(
15457
15568
  createOperationSpec({
15458
15569
  operationName: "GetAvailableCommands",
15459
15570
  kind: "query",
15460
- inputSchema: z23.object({
15461
- env: z23.string().min(1)
15571
+ inputSchema: z25.object({
15572
+ env: z25.string().min(1)
15462
15573
  }),
15463
15574
  cli: {
15464
15575
  name: "get-available-commands",
@@ -15491,8 +15602,8 @@ query GetAvailableCommands($env: AvailableCommandsEnv!) {
15491
15602
  createOperationSpec({
15492
15603
  operationName: "GetAvailableModels",
15493
15604
  kind: "query",
15494
- inputSchema: z23.object({
15495
- agentId: z23.string().min(1)
15605
+ inputSchema: z25.object({
15606
+ agentId: z25.string().min(1)
15496
15607
  }),
15497
15608
  cli: {
15498
15609
  name: "get-available-models",
@@ -15536,9 +15647,9 @@ query GetAvailableModels($agentId: String!) {
15536
15647
  createOperationSpec({
15537
15648
  operationName: "GetAvailableTools",
15538
15649
  kind: "query",
15539
- inputSchema: z23.object({
15540
- env: z23.string().min(1),
15541
- automationId: z23.string().min(1).optional()
15650
+ inputSchema: z25.object({
15651
+ env: z25.string().min(1),
15652
+ automationId: z25.string().min(1).optional()
15542
15653
  }),
15543
15654
  cli: {
15544
15655
  name: "get-available-tools",
@@ -15572,8 +15683,8 @@ query GetAvailableTools($env: AvailableCommandsEnv!, $automationId: String) {
15572
15683
  createOperationSpec({
15573
15684
  operationName: "GetFeatureFlagsContext",
15574
15685
  kind: "query",
15575
- inputSchema: z23.object({
15576
- flagKeys: z23.array(z23.string().min(1)).min(1).max(100).optional()
15686
+ inputSchema: z25.object({
15687
+ flagKeys: z25.array(z25.string().min(1)).min(1).max(100).optional()
15577
15688
  }),
15578
15689
  cli: {
15579
15690
  name: "get-feature-flags-context",
@@ -15610,7 +15721,7 @@ query GetFeatureFlagsContext($flagKeys: [String!]) {
15610
15721
  createOperationSpec({
15611
15722
  operationName: "GetAutomationWorkbenchCredentials",
15612
15723
  kind: "query",
15613
- inputSchema: z23.object({}),
15724
+ inputSchema: z25.object({}),
15614
15725
  cli: {
15615
15726
  name: "get-automation-workbench-credentials",
15616
15727
  path: ["workbench", "credentials"],
@@ -15635,8 +15746,8 @@ query GetAutomationWorkbenchCredentials {
15635
15746
  createOperationSpec({
15636
15747
  operationName: "GetAutomationWorkbenchDiagnostics",
15637
15748
  kind: "query",
15638
- inputSchema: z23.object({
15639
- draftAutomationId: z23.string().min(1)
15749
+ inputSchema: z25.object({
15750
+ draftAutomationId: z25.string().min(1)
15640
15751
  }),
15641
15752
  cli: {
15642
15753
  name: "get-automation-workbench-diagnostics",
@@ -15701,11 +15812,11 @@ query GetAutomationWorkbenchDiagnostics($draftAutomationId: ID!) {
15701
15812
  createOperationSpec({
15702
15813
  operationName: "GetAutomationWorkbenchRunTrace",
15703
15814
  kind: "query",
15704
- inputSchema: z23.object({
15705
- automationRunId: z23.string().min(1),
15706
- agentRunId: z23.string().min(1).optional(),
15707
- limit: z23.number().int().positive().optional(),
15708
- reverse: z23.boolean().optional()
15815
+ inputSchema: z25.object({
15816
+ automationRunId: z25.string().min(1),
15817
+ agentRunId: z25.string().min(1).optional(),
15818
+ limit: z25.number().int().positive().optional(),
15819
+ reverse: z25.boolean().optional()
15709
15820
  }),
15710
15821
  cli: {
15711
15822
  name: "get-automation-workbench-run-trace",
@@ -15837,13 +15948,13 @@ query GetAutomationWorkbenchRunTrace(
15837
15948
  createOperationSpec({
15838
15949
  operationName: "GetAutomationWorkbenchAwaitRunCompletion",
15839
15950
  kind: "query",
15840
- inputSchema: z23.object({
15841
- automationRunId: z23.string().min(1),
15842
- timeoutMs: z23.number().int().min(1e3).max(6e4).optional(),
15843
- sinceSequence: z23.number().int().min(0).optional(),
15844
- agentRunId: z23.string().min(1).optional(),
15845
- limit: z23.number().int().positive().optional(),
15846
- reverse: z23.boolean().optional()
15951
+ inputSchema: z25.object({
15952
+ automationRunId: z25.string().min(1),
15953
+ timeoutMs: z25.number().int().min(1e3).max(6e4).optional(),
15954
+ sinceSequence: z25.number().int().min(0).optional(),
15955
+ agentRunId: z25.string().min(1).optional(),
15956
+ limit: z25.number().int().positive().optional(),
15957
+ reverse: z25.boolean().optional()
15847
15958
  }),
15848
15959
  cli: {
15849
15960
  name: "await-automation-workbench-run-completion",
@@ -15997,11 +16108,11 @@ query GetAutomationWorkbenchAwaitRunCompletion(
15997
16108
  createOperationSpec({
15998
16109
  operationName: "GetAutomationWorkbenchSchemaSuggestions",
15999
16110
  kind: "query",
16000
- inputSchema: z23.object({
16001
- automationRunId: z23.string().min(1),
16002
- draftAutomationId: z23.string().min(1).optional(),
16003
- minConfidence: z23.number().min(0).max(1).optional(),
16004
- includeSensitive: z23.boolean().optional()
16111
+ inputSchema: z25.object({
16112
+ automationRunId: z25.string().min(1),
16113
+ draftAutomationId: z25.string().min(1).optional(),
16114
+ minConfidence: z25.number().min(0).max(1).optional(),
16115
+ includeSensitive: z25.boolean().optional()
16005
16116
  }),
16006
16117
  cli: {
16007
16118
  name: "get-automation-workbench-schema-suggestions",
@@ -16064,12 +16175,199 @@ query GetAutomationWorkbenchSchemaSuggestions(
16064
16175
  screenshotUrl
16065
16176
  }
16066
16177
  }
16178
+ }`
16179
+ }),
16180
+ createOperationSpec({
16181
+ operationName: "skills_list",
16182
+ kind: "query",
16183
+ inputSchema: z25.object({
16184
+ ref: z25.string().min(1).optional()
16185
+ }),
16186
+ cli: {
16187
+ name: "list-skills",
16188
+ path: ["skills", "list"],
16189
+ description: "List root-level Workplace skill bundles under skills/<skill-name>.",
16190
+ resultKey: "skillsList",
16191
+ options: [
16192
+ stringOption({
16193
+ inputKey: "ref",
16194
+ flagName: "ref",
16195
+ description: "Branch, tag, or commit to list. Defaults to HEAD."
16196
+ })
16197
+ ]
16198
+ },
16199
+ mcp: { fileName: "skillsList.graphql" },
16200
+ document: `# List root-level Workplace skill bundles. Nested automation and agent skill paths are outside the v1 API scope.
16201
+ query skills_list($ref: String) {
16202
+ skillsList(ref: $ref) {
16203
+ ref
16204
+ truncated
16205
+ skills {
16206
+ name
16207
+ path
16208
+ }
16209
+ }
16210
+ }`
16211
+ }),
16212
+ createOperationSpec({
16213
+ operationName: "skills_read",
16214
+ kind: "query",
16215
+ inputSchema: z25.object({
16216
+ skill: z25.string().min(1),
16217
+ ref: z25.string().min(1).optional()
16218
+ }),
16219
+ cli: {
16220
+ name: "read-skill",
16221
+ path: ["skills", "read"],
16222
+ description: "Read every file in one root-level Workplace skill bundle.",
16223
+ resultKey: "skillsRead",
16224
+ options: [
16225
+ stringOption({
16226
+ inputKey: "skill",
16227
+ flagName: "skill",
16228
+ description: "Skill directory name or skills/<skill-name> path.",
16229
+ required: true
16230
+ }),
16231
+ stringOption({
16232
+ inputKey: "ref",
16233
+ flagName: "ref",
16234
+ description: "Branch, tag, or commit to read. Defaults to HEAD."
16235
+ })
16236
+ ]
16237
+ },
16238
+ mcp: { fileName: "skillsRead.graphql" },
16239
+ document: `# Read one complete root-level Workplace skill bundle at a single resolved commit.
16240
+ query skills_read($skill: String!, $ref: String) {
16241
+ skillsRead(skill: $skill, ref: $ref) {
16242
+ path
16243
+ ref
16244
+ files {
16245
+ path
16246
+ size
16247
+ encoding
16248
+ content
16249
+ }
16250
+ }
16251
+ }`
16252
+ }),
16253
+ createOperationSpec({
16254
+ operationName: "skills_history",
16255
+ kind: "query",
16256
+ inputSchema: z25.object({
16257
+ skill: z25.string().min(1),
16258
+ ref: z25.string().min(1).optional(),
16259
+ limit: z25.number().int().min(1).max(100).optional()
16260
+ }),
16261
+ cli: {
16262
+ name: "get-skill-history",
16263
+ path: ["skills", "history"],
16264
+ description: "List newest-first commits that changed one root-level skill bundle.",
16265
+ resultKey: "skillsHistory",
16266
+ options: [
16267
+ stringOption({
16268
+ inputKey: "skill",
16269
+ flagName: "skill",
16270
+ description: "Skill directory name or skills/<skill-name> path.",
16271
+ required: true
16272
+ }),
16273
+ stringOption({
16274
+ inputKey: "ref",
16275
+ flagName: "ref",
16276
+ description: "Branch, tag, or commit to inspect. Defaults to HEAD."
16277
+ }),
16278
+ numberOption({
16279
+ inputKey: "limit",
16280
+ flagName: "limit",
16281
+ description: "Number of commits to return, from 1 to 100."
16282
+ })
16283
+ ]
16284
+ },
16285
+ mcp: { fileName: "skillsHistory.graphql" },
16286
+ document: `# List newest-first commits that changed one root-level Workplace skill bundle.
16287
+ query skills_history($skill: String!, $ref: String, $limit: Int) {
16288
+ skillsHistory(skill: $skill, ref: $ref, limit: $limit) {
16289
+ path
16290
+ ref
16291
+ truncated
16292
+ commits {
16293
+ commit
16294
+ message
16295
+ committedAt
16296
+ author {
16297
+ name
16298
+ email
16299
+ }
16300
+ }
16301
+ }
16302
+ }`
16303
+ }),
16304
+ createOperationSpec({
16305
+ operationName: "skills_apply_patch",
16306
+ kind: "mutation",
16307
+ inputSchema: z25.object({
16308
+ patch: z25.string().min(1),
16309
+ message: z25.string().min(1),
16310
+ idempotencyKey: z25.string().min(1).optional(),
16311
+ ref: z25.string().min(1).optional()
16312
+ }),
16313
+ cli: {
16314
+ name: "apply-skills-patch",
16315
+ path: ["skills", "apply-patch"],
16316
+ description: "Atomically apply one Git patch limited to root-level skills/** files.",
16317
+ resultKey: "skillsApplyPatch",
16318
+ options: [
16319
+ stringOption({
16320
+ inputKey: "patch",
16321
+ flagName: "patch",
16322
+ description: "Raw Git unified diff changing only skills/** files.",
16323
+ required: true
16324
+ }),
16325
+ stringOption({
16326
+ inputKey: "message",
16327
+ flagName: "message",
16328
+ description: "Commit message for the atomic skill update.",
16329
+ required: true
16330
+ }),
16331
+ stringOption({
16332
+ inputKey: "idempotencyKey",
16333
+ flagName: "idempotency-key",
16334
+ description: "Optional key used to safely retry the same patch."
16335
+ }),
16336
+ stringOption({
16337
+ inputKey: "ref",
16338
+ flagName: "ref",
16339
+ description: "Branch to update. Defaults to HEAD."
16340
+ })
16341
+ ]
16342
+ },
16343
+ mcp: { fileName: "skillsApplyPatch.graphql" },
16344
+ document: `# Atomically apply one Git patch limited to root-level skills/** files.
16345
+ mutation skills_apply_patch(
16346
+ $patch: String!
16347
+ $message: String!
16348
+ $idempotencyKey: String
16349
+ $ref: String
16350
+ ) {
16351
+ skillsApplyPatch(
16352
+ patch: $patch
16353
+ message: $message
16354
+ idempotencyKey: $idempotencyKey
16355
+ ref: $ref
16356
+ ) {
16357
+ ok
16358
+ commit
16359
+ ref
16360
+ changedFiles {
16361
+ path
16362
+ status
16363
+ }
16364
+ }
16067
16365
  }`
16068
16366
  }),
16069
16367
  createOperationSpec({
16070
16368
  operationName: "CreateAutomation",
16071
16369
  kind: "mutation",
16072
- inputSchema: z23.object({
16370
+ inputSchema: z25.object({
16073
16371
  input: createAutomationInputSchema
16074
16372
  }),
16075
16373
  cli: {
@@ -16106,7 +16404,7 @@ mutation CreateAutomation($input: CreateAutomationInput!) {
16106
16404
  createOperationSpec({
16107
16405
  operationName: "GetGraphqlSchema",
16108
16406
  kind: "query",
16109
- inputSchema: z23.object({}),
16407
+ inputSchema: z25.object({}),
16110
16408
  cli: {
16111
16409
  name: "get-graphql-schema",
16112
16410
  path: ["graphql", "schema"],
@@ -16127,8 +16425,8 @@ query GetGraphqlSchema {
16127
16425
  createOperationSpec({
16128
16426
  operationName: "ApproveAutomationStep",
16129
16427
  kind: "mutation",
16130
- inputSchema: z23.object({
16131
- runId: z23.string().min(1)
16428
+ inputSchema: z25.object({
16429
+ runId: z25.string().min(1)
16132
16430
  }),
16133
16431
  cli: {
16134
16432
  name: "approve-automation-step",
@@ -16153,8 +16451,8 @@ mutation ApproveAutomationStep($runId: ID!) {
16153
16451
  createOperationSpec({
16154
16452
  operationName: "RetryAutomationStep",
16155
16453
  kind: "mutation",
16156
- inputSchema: z23.object({
16157
- runId: z23.string().min(1)
16454
+ inputSchema: z25.object({
16455
+ runId: z25.string().min(1)
16158
16456
  }),
16159
16457
  cli: {
16160
16458
  name: "retry-automation-step",
@@ -16179,8 +16477,8 @@ mutation RetryAutomationStep($runId: ID!) {
16179
16477
  createOperationSpec({
16180
16478
  operationName: "PauseAutomationRun",
16181
16479
  kind: "mutation",
16182
- inputSchema: z23.object({
16183
- automationRunId: z23.string().min(1)
16480
+ inputSchema: z25.object({
16481
+ automationRunId: z25.string().min(1)
16184
16482
  }),
16185
16483
  cli: {
16186
16484
  name: "pause-automation-run",
@@ -16205,11 +16503,11 @@ mutation PauseAutomationRun($automationRunId: ID!) {
16205
16503
  createOperationSpec({
16206
16504
  operationName: "RerunAutomation",
16207
16505
  kind: "mutation",
16208
- inputSchema: z23.object({
16209
- automationRunId: z23.string().min(1),
16210
- additionalPrompt: z23.string().min(1).optional(),
16211
- idempotencyKey: z23.string().min(1),
16212
- allowPointOfNoReturnOverride: z23.boolean().optional()
16506
+ inputSchema: z25.object({
16507
+ automationRunId: z25.string().min(1),
16508
+ additionalPrompt: z25.string().min(1).optional(),
16509
+ idempotencyKey: z25.string().min(1),
16510
+ allowPointOfNoReturnOverride: z25.boolean().optional()
16213
16511
  }),
16214
16512
  cli: {
16215
16513
  name: "rerun-automation",
@@ -16264,9 +16562,9 @@ mutation RerunAutomation(
16264
16562
  createOperationSpec({
16265
16563
  operationName: "ResumeAutomationRun",
16266
16564
  kind: "mutation",
16267
- inputSchema: z23.object({
16268
- automationRunId: z23.string().min(1),
16269
- message: z23.string().min(1).optional()
16565
+ inputSchema: z25.object({
16566
+ automationRunId: z25.string().min(1),
16567
+ message: z25.string().min(1).optional()
16270
16568
  }),
16271
16569
  cli: {
16272
16570
  name: "resume-automation-run",
@@ -16296,15 +16594,15 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
16296
16594
  createOperationSpec({
16297
16595
  operationName: "RunDraftAutomation",
16298
16596
  kind: "mutation",
16299
- inputSchema: z23.object({
16300
- draftAutomationId: z23.string().min(1),
16301
- agentId: z23.string().min(1),
16302
- idempotencyKey: z23.string().min(1),
16303
- input: z23.unknown().optional(),
16304
- initialStore: z23.record(z23.string(), z23.unknown()).optional(),
16597
+ inputSchema: z25.object({
16598
+ draftAutomationId: z25.string().min(1),
16599
+ agentId: z25.string().min(1),
16600
+ idempotencyKey: z25.string().min(1),
16601
+ input: z25.unknown().optional(),
16602
+ initialStore: z25.record(z25.string(), z25.unknown()).optional(),
16305
16603
  config: automationRunStartConfigSchema.partial().passthrough().optional(),
16306
- additionalPrompt: z23.string().min(1).optional(),
16307
- consistencyCheckCount: z23.number().int().optional()
16604
+ additionalPrompt: z25.string().min(1).optional(),
16605
+ consistencyCheckCount: z25.number().int().optional()
16308
16606
  }),
16309
16607
  cli: {
16310
16608
  name: "run-draft-automation",
@@ -16389,8 +16687,8 @@ mutation RunDraftAutomation(
16389
16687
  createOperationSpec({
16390
16688
  operationName: "StopAutomationRun",
16391
16689
  kind: "mutation",
16392
- inputSchema: z23.object({
16393
- automationRunId: z23.string().min(1)
16690
+ inputSchema: z25.object({
16691
+ automationRunId: z25.string().min(1)
16394
16692
  }),
16395
16693
  cli: {
16396
16694
  name: "stop-automation-run",
@@ -16415,9 +16713,9 @@ mutation StopAutomationRun($automationRunId: ID!) {
16415
16713
  createOperationSpec({
16416
16714
  operationName: "PreviewAutomationPatch",
16417
16715
  kind: "mutation",
16418
- inputSchema: z23.object({
16419
- draftAutomationId: z23.string().min(1),
16420
- expectedLastSavedAt: z23.string().optional(),
16716
+ inputSchema: z25.object({
16717
+ draftAutomationId: z25.string().min(1),
16718
+ expectedLastSavedAt: z25.string().optional(),
16421
16719
  operations: automationPatchOperationsSchema
16422
16720
  }),
16423
16721
  cli: {
@@ -16527,8 +16825,8 @@ mutation PreviewAutomationPatch(
16527
16825
  createOperationSpec({
16528
16826
  operationName: "ApplyAutomationPatch",
16529
16827
  kind: "mutation",
16530
- inputSchema: z23.object({
16531
- draftAutomationId: z23.string().min(1),
16828
+ inputSchema: z25.object({
16829
+ draftAutomationId: z25.string().min(1),
16532
16830
  operations: automationPatchOperationsSchema
16533
16831
  }),
16534
16832
  cli: {
@@ -16645,8 +16943,8 @@ mutation ApplyAutomationPatch(
16645
16943
  createOperationSpec({
16646
16944
  operationName: "UpdateAutomationById",
16647
16945
  kind: "mutation",
16648
- inputSchema: z23.object({
16649
- id: z23.string().min(1),
16946
+ inputSchema: z25.object({
16947
+ id: z25.string().min(1),
16650
16948
  input: updateAutomationInputSchema
16651
16949
  }),
16652
16950
  cli: {
@@ -16689,7 +16987,7 @@ mutation UpdateAutomationById($id: ID!, $input: UpdateAutomationInput!) {
16689
16987
  import { Command as Command2, InvalidArgumentError as InvalidArgumentError2, Option as Option2 } from "commander";
16690
16988
 
16691
16989
  // src/api.ts
16692
- import { z as z24 } from "zod";
16990
+ import { z as z26 } from "zod";
16693
16991
 
16694
16992
  // src/version.ts
16695
16993
  import fs from "node:fs";
@@ -16716,55 +17014,55 @@ var CLI_VERSION = cliPackageVersion;
16716
17014
  // src/api.ts
16717
17015
  var OTTO_AUTHORIZATION_HEADER_NAME = "X-Otto-Authorization";
16718
17016
  var OTTO_AUTHORIZATION_ISSUER = "magical:otto";
16719
- var workosOrganizationsResponseSchema = z24.object({
16720
- organizations: z24.array(
16721
- z24.object({
16722
- id: z24.string().min(1),
16723
- name: z24.string().min(1),
16724
- primaryDomain: z24.string().nullable().optional()
17017
+ var workosOrganizationsResponseSchema = z26.object({
17018
+ organizations: z26.array(
17019
+ z26.object({
17020
+ id: z26.string().min(1),
17021
+ name: z26.string().min(1),
17022
+ primaryDomain: z26.string().nullable().optional()
16725
17023
  })
16726
17024
  ),
16727
- success: z24.boolean()
17025
+ success: z26.boolean()
16728
17026
  });
16729
- var workosUserSchema = z24.object({
16730
- email: z24.string().nullable(),
16731
- id: z24.string().min(1)
17027
+ var workosUserSchema = z26.object({
17028
+ email: z26.string().nullable(),
17029
+ id: z26.string().min(1)
16732
17030
  });
16733
- var nangoIntegrationWireSchema = z24.object({
17031
+ var nangoIntegrationWireSchema = z26.object({
16734
17032
  // eslint-disable-next-line @typescript-eslint/naming-convention -- mirrors Nango REST payload
16735
- unique_key: z24.string().min(1)
17033
+ unique_key: z26.string().min(1)
16736
17034
  }).passthrough().transform((data) => ({
16737
17035
  ...data,
16738
17036
  uniqueKey: data.unique_key
16739
17037
  }));
16740
- var nangoIntegrationsResponseSchema = z24.array(nangoIntegrationWireSchema);
16741
- var organizationAuthenticationSchema = z24.object({
16742
- id: z24.string().min(1),
16743
- type: z24.string().min(1),
16744
- connectionId: z24.string().nullable().optional(),
16745
- providerConfigKey: z24.string().nullable().optional(),
16746
- description: z24.string().nullable().optional(),
16747
- hostname: z24.string().nullable().optional()
17038
+ var nangoIntegrationsResponseSchema = z26.array(nangoIntegrationWireSchema);
17039
+ var organizationAuthenticationSchema = z26.object({
17040
+ id: z26.string().min(1),
17041
+ type: z26.string().min(1),
17042
+ connectionId: z26.string().nullable().optional(),
17043
+ providerConfigKey: z26.string().nullable().optional(),
17044
+ description: z26.string().nullable().optional(),
17045
+ hostname: z26.string().nullable().optional()
16748
17046
  }).passthrough();
16749
- var organizationAuthenticationsResponseSchema = z24.object({
16750
- authentications: z24.array(organizationAuthenticationSchema),
16751
- success: z24.boolean()
17047
+ var organizationAuthenticationsResponseSchema = z26.object({
17048
+ authentications: z26.array(organizationAuthenticationSchema),
17049
+ success: z26.boolean()
16752
17050
  });
16753
- var graphQlResponseSchema = z24.object({
16754
- data: z24.record(z24.string(), z24.unknown()).optional(),
16755
- errors: z24.array(
16756
- z24.object({
16757
- message: z24.string().min(1)
17051
+ var graphQlResponseSchema = z26.object({
17052
+ data: z26.record(z26.string(), z26.unknown()).optional(),
17053
+ errors: z26.array(
17054
+ z26.object({
17055
+ message: z26.string().min(1)
16758
17056
  })
16759
17057
  ).optional()
16760
17058
  });
16761
- var apiErrorResponseSchema = z24.object({
16762
- errors: z24.array(
16763
- z24.object({
16764
- message: z24.string().min(1)
17059
+ var apiErrorResponseSchema = z26.object({
17060
+ errors: z26.array(
17061
+ z26.object({
17062
+ message: z26.string().min(1)
16765
17063
  })
16766
17064
  ).optional(),
16767
- message: z24.string().min(1).optional()
17065
+ message: z26.string().min(1).optional()
16768
17066
  });
16769
17067
  function getApiErrorDetail(responseBody) {
16770
17068
  const parsedResponse = apiErrorResponseSchema.safeParse(responseBody);
@@ -16835,11 +17133,11 @@ function createMagicalApiClient({
16835
17133
  accessToken,
16836
17134
  impersonatedOrganizationId,
16837
17135
  allowOttoAuthorization,
16838
- path: path7,
17136
+ path: path8,
16839
17137
  init,
16840
17138
  organizationId
16841
17139
  }) {
16842
- const url = `${trimTrailingSlash(await resolveApiBaseUrl())}${path7}`;
17140
+ const url = `${trimTrailingSlash(await resolveApiBaseUrl())}${path8}`;
16843
17141
  const headers = new Headers(init?.headers);
16844
17142
  applyAuthenticationHeaders({
16845
17143
  accessToken,
@@ -17008,6 +17306,29 @@ var CLI_ACCESS_TOKEN_FILE_NAME = "access-token.txt";
17008
17306
  var CLI_STATE_FILE_NAME = "state.json";
17009
17307
  var CLI_SETTINGS_FILE_NAME = "settings.json";
17010
17308
  var CLI_REFRESH_TOKEN_FILE_NAME = "refresh-tokens.json";
17309
+ function getIsolatedGitEnvironment() {
17310
+ const environment = {};
17311
+ environment["GIT_CONFIG_GLOBAL"] = os.devNull;
17312
+ environment["GIT_CONFIG_NOSYSTEM"] = "1";
17313
+ environment["GIT_TERMINAL_PROMPT"] = "0";
17314
+ for (const key of [
17315
+ "COMSPEC",
17316
+ "HOME",
17317
+ "PATH",
17318
+ "PATHEXT",
17319
+ "SYSTEMROOT",
17320
+ "TEMP",
17321
+ "TMP",
17322
+ "TMPDIR",
17323
+ "USERPROFILE"
17324
+ ]) {
17325
+ const value = process.env[key];
17326
+ if (value !== void 0) {
17327
+ environment[key] = value;
17328
+ }
17329
+ }
17330
+ return environment;
17331
+ }
17011
17332
  function resolvePlatformConfigDirectory() {
17012
17333
  const customConfigDirectory = process.env["MAGICAL_CLI_CONFIG_DIR"];
17013
17334
  if (customConfigDirectory) {
@@ -17053,10 +17374,10 @@ function requireWorkosClientId(config) {
17053
17374
  // src/settings.ts
17054
17375
  import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
17055
17376
  import path3 from "node:path";
17056
- import { z as z25 } from "zod";
17057
- var cliSettingsSchema = z25.object({
17058
- env: z25.object({
17059
- baseUrl: z25.url().optional()
17377
+ import { z as z27 } from "zod";
17378
+ var cliSettingsSchema = z27.object({
17379
+ env: z27.object({
17380
+ baseUrl: z27.url().optional()
17060
17381
  }).default({})
17061
17382
  });
17062
17383
  function createEmptyCliSettings() {
@@ -17199,7 +17520,8 @@ var rootOperationalGroupDescriptions = /* @__PURE__ */ new Map([
17199
17520
  ["automations", "Manage automations."],
17200
17521
  ["automation-runs", "Inspect and control automation runs."],
17201
17522
  ["catalog", "Inspect available commands, models, and tools."],
17202
- ["graphql", "Inspect GraphQL metadata."]
17523
+ ["graphql", "Inspect GraphQL metadata."],
17524
+ ["skills", "Inspect and update root-level Workplace skills."]
17203
17525
  ]);
17204
17526
  function configureCommandPresentation(command) {
17205
17527
  const originalCreateCommand = command.createCommand.bind(command);
@@ -17655,35 +17977,708 @@ ${formatExamples("Examples", [
17655
17977
  return settingsCommand;
17656
17978
  }
17657
17979
 
17658
- // src/state.ts
17659
- import { mkdir as mkdir2, readFile as readFile3, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
17980
+ // src/skills-working-copy.ts
17981
+ import { execFile } from "node:child_process";
17982
+ import { createHash, randomUUID } from "node:crypto";
17983
+ import {
17984
+ lstat,
17985
+ mkdir as mkdir2,
17986
+ mkdtemp,
17987
+ readFile as readFile3,
17988
+ readdir,
17989
+ rename,
17990
+ rm as rm3,
17991
+ writeFile as writeFile2
17992
+ } from "node:fs/promises";
17993
+ import os2 from "node:os";
17660
17994
  import path5 from "node:path";
17661
- import { z as z26 } from "zod";
17662
- var cliAccountSchema = z26.object({
17663
- clientId: z26.string().min(1),
17664
- email: z26.string().nullable(),
17665
- userId: z26.string().min(1)
17995
+ import { z as z28 } from "zod";
17996
+ var SKILLS_ROOT_PATH = "skills";
17997
+ var METADATA_DIRECTORY_NAME = "skill-working-copies";
17998
+ var MAX_GIT_OUTPUT_BYTES = 10 * 1024 * 1024;
17999
+ var GIT_TIMEOUT_MS = 3e4;
18000
+ var FULL_COMMIT_SHA_PATTERN = /^[\dA-Fa-f]{40}$/u;
18001
+ var UTF8_ENCODER = new TextEncoder();
18002
+ var WINDOWS_RESERVED_PATH_CHARACTER_PATTERN = /[<>:"|?*]/u;
18003
+ var WINDOWS_RESERVED_PATH_NAME_PATTERN = /^(?:AUX|CON|NUL|PRN|COM[1-9]|LPT[1-9])(?:\..*)?$/iu;
18004
+ var skillBundleSchema = z28.object({
18005
+ files: z28.array(
18006
+ z28.object({
18007
+ content: z28.string(),
18008
+ encoding: z28.literal("base64"),
18009
+ path: z28.string().min(1),
18010
+ size: z28.number().int().nonnegative()
18011
+ })
18012
+ ),
18013
+ path: z28.string().min(1),
18014
+ ref: z28.string().regex(FULL_COMMIT_SHA_PATTERN)
17666
18015
  });
17667
- var cliOrganizationSchema = z26.object({
17668
- id: z26.string().min(1),
17669
- name: z26.string().min(1),
17670
- primaryDomain: z26.string().nullable().default(null)
18016
+ var skillsApplyPatchResultSchema = z28.object({
18017
+ changedFiles: z28.array(
18018
+ z28.object({ path: z28.string().min(1), status: z28.string().min(1) })
18019
+ ),
18020
+ commit: z28.string().regex(FULL_COMMIT_SHA_PATTERN),
18021
+ ok: z28.boolean(),
18022
+ ref: z28.string().min(1)
18023
+ }).refine((result) => result.ok, {
18024
+ message: "Skills patch result was not successful."
18025
+ });
18026
+ var workingCopyMetadataSchema = z28.object({
18027
+ version: z28.literal(1),
18028
+ files: z28.array(
18029
+ z28.object({
18030
+ content: z28.string(),
18031
+ path: z28.string().min(1)
18032
+ })
18033
+ ),
18034
+ organizationId: z28.string().min(1),
18035
+ requestedRef: z28.string().min(1).nullable(),
18036
+ skillPath: z28.string().min(1),
18037
+ workingCopyPath: z28.string().min(1)
17671
18038
  });
17672
- var cliStateSchema = z26.object({
18039
+ function hasControlCharacter2(value) {
18040
+ return UTF8_ENCODER.encode(value).some((byte) => byte <= 31 || byte === 127);
18041
+ }
18042
+ function hasWindowsUnsafePathSyntax(value) {
18043
+ return WINDOWS_RESERVED_PATH_CHARACTER_PATTERN.test(value) || WINDOWS_RESERVED_PATH_NAME_PATTERN.test(value) || value.endsWith(".") || value.endsWith(" ");
18044
+ }
18045
+ function isSafeSkillName(value) {
18046
+ return value.length > 0 && !value.startsWith(".") && !value.includes("\\") && !hasControlCharacter2(value) && !hasWindowsUnsafePathSyntax(value) && value !== "..";
18047
+ }
18048
+ function normalizeRootSkillPath(skill) {
18049
+ const normalizedInput = skill.trim().replace(/\/+$/u, "");
18050
+ const segments = normalizedInput.split("/");
18051
+ let skillName = void 0;
18052
+ if (segments.length === 1) {
18053
+ [skillName] = segments;
18054
+ } else if (segments.length === 2 && segments[0] === SKILLS_ROOT_PATH) {
18055
+ [, skillName] = segments;
18056
+ }
18057
+ if (!skillName || !isSafeSkillName(skillName)) {
18058
+ throw new CliError(
18059
+ "Skill must be a root-level directory name or a skills/<skill-name> path."
18060
+ );
18061
+ }
18062
+ return `${SKILLS_ROOT_PATH}/${skillName}`;
18063
+ }
18064
+ function resolveWorkingCopyPath(workingDirectory, skillPath) {
18065
+ return path5.resolve(workingDirectory, ...skillPath.split("/"));
18066
+ }
18067
+ function resolveMetadataPath(stateFilePath, workingCopyPath) {
18068
+ const key = createHash("sha256").update(workingCopyPath).digest("hex");
18069
+ return path5.join(
18070
+ path5.dirname(stateFilePath),
18071
+ METADATA_DIRECTORY_NAME,
18072
+ `${key}.json`
18073
+ );
18074
+ }
18075
+ function isMissingFileError(error) {
18076
+ return error instanceof Error && "code" in error && error.code === "ENOENT";
18077
+ }
18078
+ async function pathExists(filePath) {
18079
+ return await lstat(filePath).then(() => true).catch((error) => {
18080
+ if (isMissingFileError(error)) {
18081
+ return false;
18082
+ }
18083
+ throw error;
18084
+ });
18085
+ }
18086
+ function snapshotToMetadataFiles(snapshot) {
18087
+ return [...snapshot.entries()].toSorted(([leftPath], [rightPath]) => leftPath.localeCompare(rightPath)).map(([filePath, content]) => ({
18088
+ content: content.toString("base64"),
18089
+ path: filePath
18090
+ }));
18091
+ }
18092
+ function metadataFilesToSnapshot(files) {
18093
+ return new Map(
18094
+ files.map((file) => [file.path, Buffer.from(file.content, "base64")])
18095
+ );
18096
+ }
18097
+ async function loadMetadata(metadataPath) {
18098
+ const fileContents = await readFile3(metadataPath, "utf8").catch(
18099
+ (error) => {
18100
+ if (isMissingFileError(error)) {
18101
+ return null;
18102
+ }
18103
+ throw new CliError("Failed to read Skills working-copy metadata.", {
18104
+ cause: error
18105
+ });
18106
+ }
18107
+ );
18108
+ if (fileContents === null) {
18109
+ return null;
18110
+ }
18111
+ const jsonResult = safeJsonParseWithoutLogging(fileContents);
18112
+ if (isErr(jsonResult)) {
18113
+ throw new CliError("Stored Skills working-copy metadata is invalid.");
18114
+ }
18115
+ const parsed = workingCopyMetadataSchema.safeParse(jsonResult.value);
18116
+ if (!parsed.success) {
18117
+ throw new CliError("Stored Skills working-copy metadata is invalid.");
18118
+ }
18119
+ return parsed.data;
18120
+ }
18121
+ async function saveMetadata(metadataPath, metadata) {
18122
+ await mkdir2(path5.dirname(metadataPath), { recursive: true });
18123
+ const temporaryPath = `${metadataPath}.${randomUUID()}.tmp`;
18124
+ await writeFile2(temporaryPath, `${JSON.stringify(metadata, null, 2)}
18125
+ `, {
18126
+ mode: 384
18127
+ });
18128
+ await rename(temporaryPath, metadataPath);
18129
+ }
18130
+ function assertSafeRelativeFilePath(relativePath) {
18131
+ const segments = relativePath.split("/");
18132
+ if (relativePath.length === 0 || relativePath.startsWith("/") || relativePath.includes("\\") || hasControlCharacter2(relativePath) || segments.some(
18133
+ (segment) => segment.length === 0 || segment === "." || segment === ".." || segment === ".git" || hasWindowsUnsafePathSyntax(segment)
18134
+ )) {
18135
+ throw new CliError(
18136
+ `Skill bundle returned unsafe file path "${relativePath}".`
18137
+ );
18138
+ }
18139
+ }
18140
+ function parseBundle(value, expectedSkillPath) {
18141
+ const parsed = skillBundleSchema.safeParse(value);
18142
+ if (!parsed.success) {
18143
+ throw new CliError("Skills API returned an invalid bundle.");
18144
+ }
18145
+ const bundle = parsed.data;
18146
+ if (bundle.path !== expectedSkillPath) {
18147
+ throw new CliError(
18148
+ `Skills API returned "${bundle.path}" while reading "${expectedSkillPath}".`
18149
+ );
18150
+ }
18151
+ const snapshot = /* @__PURE__ */ new Map();
18152
+ for (const file of bundle.files) {
18153
+ const prefix = `${bundle.path}/`;
18154
+ if (!file.path.startsWith(prefix)) {
18155
+ throw new CliError(
18156
+ `Skill bundle returned file outside "${bundle.path}": "${file.path}".`
18157
+ );
18158
+ }
18159
+ const relativePath = file.path.slice(prefix.length);
18160
+ assertSafeRelativeFilePath(relativePath);
18161
+ if (snapshot.has(file.path)) {
18162
+ throw new CliError(
18163
+ `Skill bundle returned duplicate file "${file.path}".`
18164
+ );
18165
+ }
18166
+ const content = Buffer.from(file.content, "base64");
18167
+ if (content.byteLength !== file.size) {
18168
+ throw new CliError(
18169
+ `Skill bundle returned an invalid size for "${file.path}".`
18170
+ );
18171
+ }
18172
+ snapshot.set(file.path, content);
18173
+ }
18174
+ if (snapshot.size === 0) {
18175
+ throw new CliError(`Skill bundle "${bundle.path}" contains no files.`);
18176
+ }
18177
+ return { bundle, snapshot };
18178
+ }
18179
+ async function readDirectorySnapshot({
18180
+ directoryPath,
18181
+ skillPath
18182
+ }) {
18183
+ if (!await pathExists(directoryPath)) {
18184
+ return /* @__PURE__ */ new Map();
18185
+ }
18186
+ const rootStats = await lstat(directoryPath);
18187
+ if (!rootStats.isDirectory()) {
18188
+ throw new CliError(
18189
+ `Skill working copy "${directoryPath}" is not a directory.`
18190
+ );
18191
+ }
18192
+ async function visit(currentDirectory, segments) {
18193
+ const entries = await readdir(currentDirectory, { withFileTypes: true });
18194
+ const nestedEntries = await Promise.all(
18195
+ entries.toSorted((left, right) => left.name.localeCompare(right.name)).map(async (entry) => {
18196
+ const nextSegments = [...segments, entry.name];
18197
+ const relativePath = nextSegments.join("/");
18198
+ assertSafeRelativeFilePath(relativePath);
18199
+ const filePath = path5.join(currentDirectory, entry.name);
18200
+ if (entry.isDirectory()) {
18201
+ return await visit(filePath, nextSegments);
18202
+ }
18203
+ if (!entry.isFile()) {
18204
+ throw new CliError(
18205
+ `Skill working copy contains unsupported entry "${filePath}". Only regular files and directories are allowed.`
18206
+ );
18207
+ }
18208
+ return [[`${skillPath}/${relativePath}`, await readFile3(filePath)]];
18209
+ })
18210
+ );
18211
+ return nestedEntries.flat();
18212
+ }
18213
+ return new Map(await visit(directoryPath, []));
18214
+ }
18215
+ function contentEquals(left, right) {
18216
+ if (left === void 0 || right === void 0) {
18217
+ return left === right;
18218
+ }
18219
+ return left.equals(right);
18220
+ }
18221
+ function snapshotsEqual(left, right) {
18222
+ if (left.size !== right.size) {
18223
+ return false;
18224
+ }
18225
+ return [...left.entries()].every(
18226
+ ([filePath, content]) => contentEquals(content, right.get(filePath))
18227
+ );
18228
+ }
18229
+ async function writeSnapshotContents(rootPath, snapshot, prefix) {
18230
+ await Promise.all(
18231
+ [...snapshot.entries()].map(async ([filePath, content]) => {
18232
+ const relativePath = prefix === null ? filePath : filePath.slice(`${prefix}/`.length);
18233
+ assertSafeRelativeFilePath(relativePath);
18234
+ const targetPath = path5.join(rootPath, ...relativePath.split("/"));
18235
+ await mkdir2(path5.dirname(targetPath), { recursive: true });
18236
+ await writeFile2(targetPath, content);
18237
+ })
18238
+ );
18239
+ }
18240
+ async function replaceWorkingCopy({
18241
+ snapshot,
18242
+ skillPath,
18243
+ workingCopyPath
18244
+ }) {
18245
+ const parentPath = path5.dirname(workingCopyPath);
18246
+ await mkdir2(parentPath, { recursive: true });
18247
+ const temporaryPath = path5.join(
18248
+ parentPath,
18249
+ `.mgcl-${path5.basename(workingCopyPath)}-${randomUUID()}.tmp`
18250
+ );
18251
+ const backupPath = `${workingCopyPath}.${randomUUID()}.bak`;
18252
+ await mkdir2(temporaryPath);
18253
+ const prepareResult = await fromThrowable(async () => {
18254
+ await writeSnapshotContents(temporaryPath, snapshot, skillPath);
18255
+ const hadExistingWorkingCopy = await pathExists(workingCopyPath);
18256
+ if (hadExistingWorkingCopy) {
18257
+ await rename(workingCopyPath, backupPath);
18258
+ }
18259
+ return hadExistingWorkingCopy;
18260
+ }, "skills-working-copy-replace-failed");
18261
+ if (isErr(prepareResult)) {
18262
+ await rm3(temporaryPath, { force: true, recursive: true });
18263
+ throw new CliError("Failed to replace the skill working copy.", {
18264
+ cause: prepareResult.error.cause
18265
+ });
18266
+ }
18267
+ const activationResult = await fromThrowable(async () => {
18268
+ await rename(temporaryPath, workingCopyPath);
18269
+ }, "skills-working-copy-activation-failed");
18270
+ if (isErr(activationResult)) {
18271
+ if (prepareResult.value) {
18272
+ await rename(backupPath, workingCopyPath);
18273
+ }
18274
+ await rm3(temporaryPath, { force: true, recursive: true });
18275
+ throw new CliError("Failed to activate the new skill working copy.", {
18276
+ cause: activationResult.error.cause
18277
+ });
18278
+ }
18279
+ if (prepareResult.value) {
18280
+ await rm3(backupPath, { force: true, recursive: true });
18281
+ }
18282
+ }
18283
+ async function runGit(arguments_, cwd, allowedExitCodes = [0]) {
18284
+ const result = await new Promise((resolve, reject) => {
18285
+ execFile(
18286
+ "git",
18287
+ arguments_,
18288
+ {
18289
+ cwd,
18290
+ encoding: "buffer",
18291
+ env: getIsolatedGitEnvironment(),
18292
+ maxBuffer: MAX_GIT_OUTPUT_BYTES,
18293
+ timeout: GIT_TIMEOUT_MS
18294
+ },
18295
+ (error, stdout, stderr) => {
18296
+ let exitCode = 0;
18297
+ if (error !== null) {
18298
+ exitCode = typeof error.code === "number" ? error.code : -1;
18299
+ }
18300
+ const commandResult = { exitCode, stderr, stdout };
18301
+ if (error && !allowedExitCodes.includes(exitCode)) {
18302
+ reject(
18303
+ new CliError(
18304
+ `Git command failed: ${stderr.toString("utf8").trim() || error.message}`,
18305
+ { cause: error }
18306
+ )
18307
+ );
18308
+ return;
18309
+ }
18310
+ resolve(commandResult);
18311
+ }
18312
+ );
18313
+ });
18314
+ return result;
18315
+ }
18316
+ async function clearDirectoryExceptGit(directoryPath) {
18317
+ const entries = await readdir(directoryPath);
18318
+ await Promise.all(
18319
+ entries.filter((entry) => entry !== ".git").map(async (entry) => {
18320
+ await rm3(path5.join(directoryPath, entry), {
18321
+ force: true,
18322
+ recursive: true
18323
+ });
18324
+ })
18325
+ );
18326
+ }
18327
+ async function createPatch(before, after) {
18328
+ if (snapshotsEqual(before, after)) {
18329
+ return "";
18330
+ }
18331
+ const repositoryPath = await mkdtemp(
18332
+ path5.join(os2.tmpdir(), "mgcl-skills-diff-")
18333
+ );
18334
+ const patchResult = await fromThrowable(async () => {
18335
+ await runGit(["init", "--quiet"], repositoryPath);
18336
+ await writeSnapshotContents(repositoryPath, before, null);
18337
+ await stageCompleteSnapshot(repositoryPath, before);
18338
+ await runGit(
18339
+ [
18340
+ "-c",
18341
+ "user.name=mgcl",
18342
+ "-c",
18343
+ "user.email=mgcl@getmagical.com",
18344
+ "-c",
18345
+ "commit.gpgsign=false",
18346
+ "commit",
18347
+ "--allow-empty",
18348
+ "--quiet",
18349
+ "-m",
18350
+ "Skills baseline"
18351
+ ],
18352
+ repositoryPath
18353
+ );
18354
+ await clearDirectoryExceptGit(repositoryPath);
18355
+ await writeSnapshotContents(repositoryPath, after, null);
18356
+ await stageCompleteSnapshot(repositoryPath, after);
18357
+ const result = await runGit(
18358
+ [
18359
+ "diff",
18360
+ "--cached",
18361
+ "--no-color",
18362
+ "--no-ext-diff",
18363
+ "--no-renames",
18364
+ "--full-index",
18365
+ "--src-prefix=a/",
18366
+ "--dst-prefix=b/",
18367
+ "HEAD",
18368
+ "--",
18369
+ "."
18370
+ ],
18371
+ repositoryPath
18372
+ );
18373
+ return result.stdout.toString("utf8");
18374
+ }, "skills-patch-generation-failed");
18375
+ await rm3(repositoryPath, { force: true, recursive: true });
18376
+ if (isErr(patchResult)) {
18377
+ throw patchResult.error.cause;
18378
+ }
18379
+ return patchResult.value;
18380
+ }
18381
+ async function stageCompleteSnapshot(repositoryPath, snapshot) {
18382
+ await runGit(["add", "--all", "--force", "--", "."], repositoryPath);
18383
+ const trackedFilesResult = await runGit(
18384
+ ["ls-files", "--cached", "-z"],
18385
+ repositoryPath
18386
+ );
18387
+ const trackedFiles = trackedFilesResult.stdout.toString("utf8").split("\0").filter((filePath) => filePath.length > 0).toSorted();
18388
+ const expectedFiles = [...snapshot.keys()].toSorted();
18389
+ if (trackedFiles.length !== expectedFiles.length || trackedFiles.some((filePath, index) => filePath !== expectedFiles[index])) {
18390
+ throw new CliError(
18391
+ "Failed to stage the complete skill snapshot for patch generation."
18392
+ );
18393
+ }
18394
+ }
18395
+ function createMetadata({
18396
+ organizationId,
18397
+ requestedRef,
18398
+ skillPath,
18399
+ snapshot,
18400
+ workingCopyPath
18401
+ }) {
18402
+ return {
18403
+ version: 1,
18404
+ files: snapshotToMetadataFiles(snapshot),
18405
+ organizationId,
18406
+ requestedRef,
18407
+ skillPath,
18408
+ workingCopyPath
18409
+ };
18410
+ }
18411
+ function assertMetadataMatchesContext({
18412
+ metadata,
18413
+ organizationId,
18414
+ skillPath,
18415
+ workingCopyPath
18416
+ }) {
18417
+ if (metadata.skillPath !== skillPath || metadata.workingCopyPath !== workingCopyPath) {
18418
+ throw new CliError(
18419
+ "Stored Skills working-copy metadata does not match this folder."
18420
+ );
18421
+ }
18422
+ if (metadata.organizationId !== organizationId) {
18423
+ throw new CliError(
18424
+ `This skill working copy belongs to organization "${metadata.organizationId}". Select that organization or pull with --force to replace it.`
18425
+ );
18426
+ }
18427
+ if (metadata.requestedRef !== null) {
18428
+ throw new CliError(
18429
+ "This skill working copy targets a non-default ref, which is no longer supported. Pull it again with --force to use the repository default branch."
18430
+ );
18431
+ }
18432
+ }
18433
+ async function requireWorkingCopy({
18434
+ organizationId,
18435
+ skill,
18436
+ stateFilePath,
18437
+ workingDirectory
18438
+ }) {
18439
+ const skillPath = normalizeRootSkillPath(skill);
18440
+ const workingCopyPath = resolveWorkingCopyPath(workingDirectory, skillPath);
18441
+ const metadataPath = resolveMetadataPath(stateFilePath, workingCopyPath);
18442
+ const metadata = await loadMetadata(metadataPath);
18443
+ if (!metadata) {
18444
+ throw new CliError(
18445
+ `No pulled working copy exists for "${skillPath}" in this folder. Run "mgcl skills pull ${skillPath}" first.`
18446
+ );
18447
+ }
18448
+ assertMetadataMatchesContext({
18449
+ metadata,
18450
+ organizationId,
18451
+ skillPath,
18452
+ workingCopyPath
18453
+ });
18454
+ return {
18455
+ base: metadataFilesToSnapshot(metadata.files),
18456
+ local: await readDirectorySnapshot({
18457
+ directoryPath: workingCopyPath,
18458
+ skillPath
18459
+ }),
18460
+ metadata,
18461
+ metadataPath,
18462
+ skillPath,
18463
+ workingCopyPath
18464
+ };
18465
+ }
18466
+ async function readRemoteBundle(api, skillPath, requestedRef) {
18467
+ return parseBundle(
18468
+ await api.read({
18469
+ skill: skillPath,
18470
+ ...requestedRef === null ? {} : { ref: requestedRef }
18471
+ }),
18472
+ skillPath
18473
+ );
18474
+ }
18475
+ function assertTextPatch(patchContents) {
18476
+ if (/^GIT binary patch$/mu.test(patchContents) || /^Binary files .* differ$/mu.test(patchContents)) {
18477
+ throw new CliError(
18478
+ "Binary skill changes cannot be pushed because repo-browser only accepts text patches."
18479
+ );
18480
+ }
18481
+ }
18482
+ function isPatchApplyConflict(error) {
18483
+ return error instanceof Error && (/Patch does not apply/iu.test(error.message) || /Branch was updated while applying patch/iu.test(error.message));
18484
+ }
18485
+ async function pullSkillWorkingCopy({
18486
+ context,
18487
+ force = false,
18488
+ skill
18489
+ }) {
18490
+ const skillPath = normalizeRootSkillPath(skill);
18491
+ const workingCopyPath = resolveWorkingCopyPath(
18492
+ context.workingDirectory,
18493
+ skillPath
18494
+ );
18495
+ const metadataPath = resolveMetadataPath(
18496
+ context.stateFilePath,
18497
+ workingCopyPath
18498
+ );
18499
+ if (!force) {
18500
+ const existingMetadata = await loadMetadata(metadataPath);
18501
+ const existingSnapshot = await readDirectorySnapshot({
18502
+ directoryPath: workingCopyPath,
18503
+ skillPath
18504
+ });
18505
+ if (!existingMetadata && existingSnapshot.size > 0) {
18506
+ throw new CliError(
18507
+ `Refusing to overwrite existing files at "${workingCopyPath}". Re-run with --force to replace them.`
18508
+ );
18509
+ }
18510
+ if (existingMetadata) {
18511
+ assertMetadataMatchesContext({
18512
+ metadata: existingMetadata,
18513
+ organizationId: context.organizationId,
18514
+ skillPath,
18515
+ workingCopyPath
18516
+ });
18517
+ const baseline = metadataFilesToSnapshot(existingMetadata.files);
18518
+ if (!snapshotsEqual(existingSnapshot, baseline)) {
18519
+ throw new CliError(
18520
+ `Refusing to overwrite local changes in "${workingCopyPath}". Run "mgcl skills diff ${skillPath}" or re-run pull with --force.`
18521
+ );
18522
+ }
18523
+ }
18524
+ }
18525
+ const { snapshot } = await readRemoteBundle(context.api, skillPath, null);
18526
+ await replaceWorkingCopy({ snapshot, skillPath, workingCopyPath });
18527
+ await saveMetadata(
18528
+ metadataPath,
18529
+ createMetadata({
18530
+ organizationId: context.organizationId,
18531
+ requestedRef: null,
18532
+ skillPath,
18533
+ snapshot,
18534
+ workingCopyPath
18535
+ })
18536
+ );
18537
+ return {
18538
+ fileCount: snapshot.size,
18539
+ path: workingCopyPath,
18540
+ skillPath
18541
+ };
18542
+ }
18543
+ async function diffSkillWorkingCopy({
18544
+ context,
18545
+ skill
18546
+ }) {
18547
+ const workingCopy = await requireWorkingCopy({
18548
+ organizationId: context.organizationId,
18549
+ skill,
18550
+ stateFilePath: context.stateFilePath,
18551
+ workingDirectory: context.workingDirectory
18552
+ });
18553
+ const patchContents = await createPatch(workingCopy.base, workingCopy.local);
18554
+ return {
18555
+ hasLocalChanges: !snapshotsEqual(workingCopy.base, workingCopy.local),
18556
+ patch: patchContents,
18557
+ skillPath: workingCopy.skillPath
18558
+ };
18559
+ }
18560
+ async function pushSkillWorkingCopy({
18561
+ context,
18562
+ message,
18563
+ skill
18564
+ }) {
18565
+ const workingCopy = await requireWorkingCopy({
18566
+ organizationId: context.organizationId,
18567
+ skill,
18568
+ stateFilePath: context.stateFilePath,
18569
+ workingDirectory: context.workingDirectory
18570
+ });
18571
+ const { base, local } = workingCopy;
18572
+ const patchContents = await createPatch(base, local);
18573
+ if (patchContents.length === 0) {
18574
+ return {
18575
+ path: workingCopy.workingCopyPath,
18576
+ pushed: false,
18577
+ skillPath: workingCopy.skillPath
18578
+ };
18579
+ }
18580
+ assertTextPatch(patchContents);
18581
+ const applyResult = await fromThrowable(
18582
+ async () => await context.api.applyPatch({
18583
+ idempotencyKey: `mgcl-skills-${randomUUID()}`,
18584
+ message: message ?? `Update ${workingCopy.skillPath} via mgcl`,
18585
+ patch: patchContents
18586
+ }),
18587
+ "skills-push-request-failed"
18588
+ );
18589
+ if (isErr(applyResult)) {
18590
+ const { cause } = applyResult.error;
18591
+ if (isPatchApplyConflict(cause)) {
18592
+ throw new CliError(
18593
+ `The skill changed remotely and your local patch no longer applies. Save your local edits elsewhere, run "mgcl skills pull ${workingCopy.skillPath} --force", reapply the changes, and push again.`,
18594
+ { cause }
18595
+ );
18596
+ }
18597
+ if (cause instanceof Error) {
18598
+ throw cause;
18599
+ }
18600
+ throw new CliError("Failed to push the skill working copy.", {
18601
+ cause
18602
+ });
18603
+ }
18604
+ const parsedResult = skillsApplyPatchResultSchema.safeParse(
18605
+ applyResult.value
18606
+ );
18607
+ if (!parsedResult.success) {
18608
+ throw new CliError("Skills API returned an invalid patch result.");
18609
+ }
18610
+ const pushResult = {
18611
+ ...parsedResult.data,
18612
+ path: workingCopy.workingCopyPath,
18613
+ pushed: true,
18614
+ skillPath: workingCopy.skillPath
18615
+ };
18616
+ const refreshResult = await fromThrowable(async () => {
18617
+ const authoritative = await readRemoteBundle(
18618
+ context.api,
18619
+ workingCopy.skillPath,
18620
+ parsedResult.data.commit
18621
+ );
18622
+ if (authoritative.bundle.ref !== parsedResult.data.commit) {
18623
+ throw new CliError(
18624
+ `Skills API returned commit "${authoritative.bundle.ref}" while reading pushed commit "${parsedResult.data.commit}".`
18625
+ );
18626
+ }
18627
+ await replaceWorkingCopy({
18628
+ snapshot: authoritative.snapshot,
18629
+ skillPath: workingCopy.skillPath,
18630
+ workingCopyPath: workingCopy.workingCopyPath
18631
+ });
18632
+ await saveMetadata(
18633
+ workingCopy.metadataPath,
18634
+ createMetadata({
18635
+ organizationId: context.organizationId,
18636
+ requestedRef: null,
18637
+ skillPath: workingCopy.skillPath,
18638
+ snapshot: authoritative.snapshot,
18639
+ workingCopyPath: workingCopy.workingCopyPath
18640
+ })
18641
+ );
18642
+ }, "skills-push-refresh-failed");
18643
+ if (isErr(refreshResult)) {
18644
+ return {
18645
+ ...pushResult,
18646
+ warning: `The push succeeded as commit ${parsedResult.data.commit}, but refreshing the local working copy from that commit failed, so this checkout may be out of sync. Run "mgcl skills pull ${workingCopy.skillPath} --force" to sync it with the server.`,
18647
+ workingCopyRefreshed: false
18648
+ };
18649
+ }
18650
+ return { ...pushResult, workingCopyRefreshed: true };
18651
+ }
18652
+
18653
+ // src/state.ts
18654
+ import { mkdir as mkdir3, readFile as readFile4, rm as rm4, writeFile as writeFile3 } from "node:fs/promises";
18655
+ import path6 from "node:path";
18656
+ import { z as z29 } from "zod";
18657
+ var cliAccountSchema = z29.object({
18658
+ clientId: z29.string().min(1),
18659
+ email: z29.string().nullable(),
18660
+ userId: z29.string().min(1)
18661
+ });
18662
+ var cliOrganizationSchema = z29.object({
18663
+ id: z29.string().min(1),
18664
+ name: z29.string().min(1),
18665
+ primaryDomain: z29.string().nullable().default(null)
18666
+ });
18667
+ var cliStateSchema = z29.object({
17673
18668
  account: cliAccountSchema,
17674
- defaultOrgId: z26.string().nullable(),
17675
- lastUsedOrgId: z26.string().nullable(),
17676
- organizations: z26.array(cliOrganizationSchema)
18669
+ defaultOrgId: z29.string().nullable(),
18670
+ lastUsedOrgId: z29.string().nullable(),
18671
+ organizations: z29.array(cliOrganizationSchema)
17677
18672
  });
17678
- var refreshTokenFileSchema = z26.record(z26.string(), z26.string());
18673
+ var refreshTokenFileSchema = z29.record(z29.string(), z29.string());
17679
18674
  function createFileStateStore(stateFilePath) {
17680
18675
  return {
17681
18676
  async clear() {
17682
- await rm3(stateFilePath, { force: true });
18677
+ await rm4(stateFilePath, { force: true });
17683
18678
  },
17684
18679
  async load() {
17685
18680
  try {
17686
- const fileContents = await readFile3(stateFilePath, "utf8");
18681
+ const fileContents = await readFile4(stateFilePath, "utf8");
17687
18682
  const parsed = cliStateSchema.safeParse(JSON.parse(fileContents));
17688
18683
  if (!parsed.success) {
17689
18684
  throw new CliError("Stored CLI state is invalid.");
@@ -17700,8 +18695,8 @@ function createFileStateStore(stateFilePath) {
17700
18695
  }
17701
18696
  },
17702
18697
  async save(state) {
17703
- await mkdir2(path5.dirname(stateFilePath), { recursive: true });
17704
- await writeFile2(stateFilePath, `${JSON.stringify(state, null, 2)}
18698
+ await mkdir3(path6.dirname(stateFilePath), { recursive: true });
18699
+ await writeFile3(stateFilePath, `${JSON.stringify(state, null, 2)}
17705
18700
  `);
17706
18701
  }
17707
18702
  };
@@ -17709,7 +18704,7 @@ function createFileStateStore(stateFilePath) {
17709
18704
  function createFileRefreshTokenStore(refreshTokenFilePath) {
17710
18705
  async function loadRefreshTokens() {
17711
18706
  try {
17712
- const fileContents = await readFile3(refreshTokenFilePath, "utf8");
18707
+ const fileContents = await readFile4(refreshTokenFilePath, "utf8");
17713
18708
  const parsed = refreshTokenFileSchema.safeParse(JSON.parse(fileContents));
17714
18709
  if (!parsed.success) {
17715
18710
  throw new CliError("Stored refresh tokens are invalid.");
@@ -17728,8 +18723,8 @@ function createFileRefreshTokenStore(refreshTokenFilePath) {
17728
18723
  }
17729
18724
  }
17730
18725
  async function saveRefreshTokens(refreshTokens) {
17731
- await mkdir2(path5.dirname(refreshTokenFilePath), { recursive: true });
17732
- await writeFile2(
18726
+ await mkdir3(path6.dirname(refreshTokenFilePath), { recursive: true });
18727
+ await writeFile3(
17733
18728
  refreshTokenFilePath,
17734
18729
  `${JSON.stringify(refreshTokens, null, 2)}
17735
18730
  `
@@ -17745,7 +18740,7 @@ function createFileRefreshTokenStore(refreshTokenFilePath) {
17745
18740
  )
17746
18741
  );
17747
18742
  if (Object.keys(nextRefreshTokens).length === 0) {
17748
- await rm3(refreshTokenFilePath, { force: true });
18743
+ await rm4(refreshTokenFilePath, { force: true });
17749
18744
  return;
17750
18745
  }
17751
18746
  await saveRefreshTokens(nextRefreshTokens);
@@ -17766,37 +18761,37 @@ function buildRefreshTokenKey(account) {
17766
18761
  }
17767
18762
 
17768
18763
  // src/workos-auth.ts
17769
- import { z as z27 } from "zod";
18764
+ import { z as z30 } from "zod";
17770
18765
  var DEFAULT_DEVICE_POLL_INTERVAL_SECONDS = 5;
17771
18766
  function buildFormHeaders() {
17772
18767
  const headers = new Headers();
17773
18768
  headers.set("content-type", "application/x-www-form-urlencoded");
17774
18769
  return headers;
17775
18770
  }
17776
- var deviceAuthorizationSchema = z27.object({
17777
- device_code: z27.string().min(1),
17778
- expires_in: z27.number().int().positive().optional(),
17779
- interval: z27.number().int().positive().optional(),
17780
- user_code: z27.string().min(1),
17781
- verification_uri: z27.url(),
17782
- verification_uri_complete: z27.url().optional()
18771
+ var deviceAuthorizationSchema = z30.object({
18772
+ device_code: z30.string().min(1),
18773
+ expires_in: z30.number().int().positive().optional(),
18774
+ interval: z30.number().int().positive().optional(),
18775
+ user_code: z30.string().min(1),
18776
+ verification_uri: z30.url(),
18777
+ verification_uri_complete: z30.url().optional()
17783
18778
  });
17784
- var tokenResponseSchema = z27.object({
17785
- access_token: z27.string().min(1),
17786
- expires_in: z27.number().int().positive().optional(),
17787
- refresh_token: z27.string().min(1),
17788
- token_type: z27.string().optional()
18779
+ var tokenResponseSchema = z30.object({
18780
+ access_token: z30.string().min(1),
18781
+ expires_in: z30.number().int().positive().optional(),
18782
+ refresh_token: z30.string().min(1),
18783
+ token_type: z30.string().optional()
17789
18784
  });
17790
- var tokenErrorSchema = z27.object({
17791
- error: z27.string().min(1),
17792
- error_description: z27.string().optional()
18785
+ var tokenErrorSchema = z30.object({
18786
+ error: z30.string().min(1),
18787
+ error_description: z30.string().optional()
17793
18788
  });
17794
- var accessTokenClaimsSchema = z27.object({
17795
- exp: z27.number().int().positive().optional(),
17796
- iss: z27.string().min(1).optional(),
17797
- org_id: z27.string().min(1).optional(),
17798
- sid: z27.string().min(1).optional(),
17799
- sub: z27.string().min(1)
18789
+ var accessTokenClaimsSchema = z30.object({
18790
+ exp: z30.number().int().positive().optional(),
18791
+ iss: z30.string().min(1).optional(),
18792
+ org_id: z30.string().min(1).optional(),
18793
+ sid: z30.string().min(1).optional(),
18794
+ sub: z30.string().min(1)
17800
18795
  });
17801
18796
  function createWorkosAuthClient({
17802
18797
  fetchFn = fetch,
@@ -18158,6 +19153,169 @@ async function handleOperationCommand(dependencies, operationSpec, commandOption
18158
19153
  }
18159
19154
  dependencies.io.info(formatHumanReadableOutput(result));
18160
19155
  }
19156
+ function getSkillsOperation(operationName) {
19157
+ const operationSpec = operationSpecs.find(
19158
+ (candidate) => candidate.operationName === operationName
19159
+ );
19160
+ if (!operationSpec) {
19161
+ throw new CliError(
19162
+ `Skills operation "${operationName}" is not registered.`
19163
+ );
19164
+ }
19165
+ return operationSpec;
19166
+ }
19167
+ async function withSkillsWorkingCopyContext(dependencies, options) {
19168
+ const { accessToken, impersonatedOrganizationId, organization, state } = await withSelectedOrganizationAndAccessToken({ dependencies, options });
19169
+ const executeOperation = async (operationName, variables) => {
19170
+ const operationSpec = getSkillsOperation(operationName);
19171
+ return await dependencies.apiClient.executeGraphQl({
19172
+ accessToken,
19173
+ ...impersonatedOrganizationId ? { impersonatedOrganizationId } : {},
19174
+ organizationId: organization.id,
19175
+ query: operationSpec.document,
19176
+ resultKey: operationSpec.cli.resultKey,
19177
+ variables
19178
+ });
19179
+ };
19180
+ return {
19181
+ context: {
19182
+ api: {
19183
+ async applyPatch(input) {
19184
+ return await executeOperation("skills_apply_patch", input);
19185
+ },
19186
+ async read(input) {
19187
+ return await executeOperation("skills_read", input);
19188
+ }
19189
+ },
19190
+ organizationId: organization.id,
19191
+ stateFilePath: dependencies.runtimeConfig.stateFilePath,
19192
+ workingDirectory: dependencies.workingDirectory ?? process.cwd()
19193
+ },
19194
+ state
19195
+ };
19196
+ }
19197
+ async function handleSkillsPullCommand(dependencies, skill, options) {
19198
+ const { context, state } = await withSkillsWorkingCopyContext(
19199
+ dependencies,
19200
+ options
19201
+ );
19202
+ const result = await pullSkillWorkingCopy({
19203
+ context,
19204
+ skill,
19205
+ ...options.force ? { force: true } : {}
19206
+ });
19207
+ await saveLastUsedOrganization({
19208
+ dependencies,
19209
+ organizationId: context.organizationId,
19210
+ state
19211
+ });
19212
+ writeCommandOutput({ dependencies, json: options.json, result });
19213
+ }
19214
+ async function handleSkillsDiffCommand(dependencies, skill, options) {
19215
+ const { context, state } = await withSkillsWorkingCopyContext(
19216
+ dependencies,
19217
+ options
19218
+ );
19219
+ const result = await diffSkillWorkingCopy({ context, skill });
19220
+ await saveLastUsedOrganization({
19221
+ dependencies,
19222
+ organizationId: context.organizationId,
19223
+ state
19224
+ });
19225
+ if (options.json) {
19226
+ writeJsonOutput3(dependencies.io, result);
19227
+ return;
19228
+ }
19229
+ dependencies.io.info(
19230
+ result.patch.length === 0 ? "No changes." : result.patch
19231
+ );
19232
+ }
19233
+ async function handleSkillsPushCommand(dependencies, skill, options) {
19234
+ const { context, state } = await withSkillsWorkingCopyContext(
19235
+ dependencies,
19236
+ options
19237
+ );
19238
+ const result = await pushSkillWorkingCopy({
19239
+ context,
19240
+ skill,
19241
+ ...options.message ? { message: options.message } : {}
19242
+ });
19243
+ await saveLastUsedOrganization({
19244
+ dependencies,
19245
+ organizationId: context.organizationId,
19246
+ state
19247
+ });
19248
+ writeCommandOutput({ dependencies, json: options.json, result });
19249
+ }
19250
+ function addSkillsWorkingCopyCommands({
19251
+ dependencies,
19252
+ skillsCommand
19253
+ }) {
19254
+ skillsCommand.command("pull <skill>").description("Download a root-level skill into ./skills/<skill-name>.").addOption(
19255
+ new Option2(
19256
+ "--org <org>",
19257
+ "Organization ID or exact organization name to use."
19258
+ ).helpGroup("Shared options:")
19259
+ ).addOption(
19260
+ new Option2(
19261
+ "--force",
19262
+ "Replace existing files or local edits with the remote bundle."
19263
+ )
19264
+ ).addHelpText(
19265
+ "after",
19266
+ `
19267
+ ${formatExamples("Examples", [
19268
+ "mgcl skills pull review",
19269
+ "mgcl skills pull skills/review"
19270
+ ])}`
19271
+ ).action(async function(skill) {
19272
+ await handleSkillsPullCommand(
19273
+ dependencies,
19274
+ skill,
19275
+ this.optsWithGlobals()
19276
+ );
19277
+ });
19278
+ skillsCommand.command("diff <skill>").description("Preview local skill changes against the pulled bundle.").addOption(
19279
+ new Option2(
19280
+ "--org <org>",
19281
+ "Organization ID or exact organization name to use."
19282
+ ).helpGroup("Shared options:")
19283
+ ).addHelpText(
19284
+ "after",
19285
+ `
19286
+ ${formatExamples("Examples", [
19287
+ "mgcl skills diff review",
19288
+ "mgcl skills diff skills/review --json"
19289
+ ])}`
19290
+ ).action(async function(skill) {
19291
+ await handleSkillsDiffCommand(
19292
+ dependencies,
19293
+ skill,
19294
+ this.optsWithGlobals()
19295
+ );
19296
+ });
19297
+ skillsCommand.command("push <skill>").description("Atomically push local changes for one root-level skill.").addOption(
19298
+ new Option2(
19299
+ "--org <org>",
19300
+ "Organization ID or exact organization name to use."
19301
+ ).helpGroup("Shared options:")
19302
+ ).addOption(
19303
+ new Option2("--message <message>", "Commit message for the skill update.")
19304
+ ).addHelpText(
19305
+ "after",
19306
+ `
19307
+ ${formatExamples("Examples", [
19308
+ "mgcl skills push review",
19309
+ 'mgcl skills push skills/review --message "Improve review guidance"'
19310
+ ])}`
19311
+ ).action(async function(skill) {
19312
+ await handleSkillsPushCommand(
19313
+ dependencies,
19314
+ skill,
19315
+ this.optsWithGlobals()
19316
+ );
19317
+ });
19318
+ }
18161
19319
  async function withSelectedOrganizationAndAccessToken({
18162
19320
  dependencies,
18163
19321
  options
@@ -18262,7 +19420,7 @@ async function resolveDirectAccessTokenOrganizationId({
18262
19420
  if (!accessTokenFilePath) {
18263
19421
  return null;
18264
19422
  }
18265
- const accessToken = await readFile4(accessTokenFilePath, "utf8").then((value) => value.trim()).catch((error) => {
19423
+ const accessToken = await readFile5(accessTokenFilePath, "utf8").then((value) => value.trim()).catch((error) => {
18266
19424
  if (error instanceof Error && "code" in error && error.code === "ENOENT") {
18267
19425
  return null;
18268
19426
  }
@@ -18374,12 +19532,12 @@ function createConsoleIo() {
18374
19532
  function createDefaultDependencies() {
18375
19533
  const runtimeConfig = getRuntimeConfig();
18376
19534
  const settingsStore = createFileSettingsStore(runtimeConfig.stateFilePath);
18377
- const accessTokenFilePath = runtimeConfig.accessTokenFilePath ?? path6.join(
18378
- path6.dirname(runtimeConfig.stateFilePath),
19535
+ const accessTokenFilePath = runtimeConfig.accessTokenFilePath ?? path7.join(
19536
+ path7.dirname(runtimeConfig.stateFilePath),
18379
19537
  CLI_ACCESS_TOKEN_FILE_NAME
18380
19538
  );
18381
- const refreshTokenFilePath = runtimeConfig.refreshTokenFilePath ?? path6.join(
18382
- path6.dirname(runtimeConfig.stateFilePath),
19539
+ const refreshTokenFilePath = runtimeConfig.refreshTokenFilePath ?? path7.join(
19540
+ path7.dirname(runtimeConfig.stateFilePath),
18383
19541
  CLI_REFRESH_TOKEN_FILE_NAME
18384
19542
  );
18385
19543
  const selfUpdateOptions = {
@@ -18555,6 +19713,11 @@ ${formatExamples("Examples", ["mgcl update", "mgcl --update"])}`
18555
19713
  operationSpec
18556
19714
  });
18557
19715
  }
19716
+ const skillsCommand = operationalCommandGroups.get("skills");
19717
+ if (!skillsCommand) {
19718
+ throw new CliError("Skills operation group is not registered.");
19719
+ }
19720
+ addSkillsWorkingCopyCommands({ dependencies, skillsCommand });
18558
19721
  return program2;
18559
19722
  }
18560
19723