@getmagical/cli 0.1.16 → 0.1.18

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
@@ -573,12 +573,12 @@ var require_unreachable_case_error = __commonJS({
573
573
  "use strict";
574
574
  Object.defineProperty(exports, "__esModule", { value: true });
575
575
  exports.UnreachableCaseError = void 0;
576
- var UnreachableCaseError2 = class extends Error {
576
+ var UnreachableCaseError3 = class extends Error {
577
577
  constructor(value) {
578
578
  super(`Unreachable case: ${value}`);
579
579
  }
580
580
  };
581
- exports.UnreachableCaseError = UnreachableCaseError2;
581
+ exports.UnreachableCaseError = UnreachableCaseError3;
582
582
  }
583
583
  });
584
584
 
@@ -736,6 +736,166 @@ var require_dist = __commonJS({
736
736
  }
737
737
  });
738
738
 
739
+ // ../../node_modules/fast-deep-equal/es6/index.js
740
+ var require_es6 = __commonJS({
741
+ "../../node_modules/fast-deep-equal/es6/index.js"(exports, module) {
742
+ "use strict";
743
+ module.exports = function equal(a, b) {
744
+ if (a === b) return true;
745
+ if (a && b && typeof a == "object" && typeof b == "object") {
746
+ if (a.constructor !== b.constructor) return false;
747
+ var length, i, keys;
748
+ if (Array.isArray(a)) {
749
+ length = a.length;
750
+ if (length != b.length) return false;
751
+ for (i = length; i-- !== 0; )
752
+ if (!equal(a[i], b[i])) return false;
753
+ return true;
754
+ }
755
+ if (a instanceof Map && b instanceof Map) {
756
+ if (a.size !== b.size) return false;
757
+ for (i of a.entries())
758
+ if (!b.has(i[0])) return false;
759
+ for (i of a.entries())
760
+ if (!equal(i[1], b.get(i[0]))) return false;
761
+ return true;
762
+ }
763
+ if (a instanceof Set && b instanceof Set) {
764
+ if (a.size !== b.size) return false;
765
+ for (i of a.entries())
766
+ if (!b.has(i[0])) return false;
767
+ return true;
768
+ }
769
+ if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
770
+ length = a.length;
771
+ if (length != b.length) return false;
772
+ for (i = length; i-- !== 0; )
773
+ if (a[i] !== b[i]) return false;
774
+ return true;
775
+ }
776
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
777
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
778
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
779
+ keys = Object.keys(a);
780
+ length = keys.length;
781
+ if (length !== Object.keys(b).length) return false;
782
+ for (i = length; i-- !== 0; )
783
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
784
+ for (i = length; i-- !== 0; ) {
785
+ var key = keys[i];
786
+ if (!equal(a[key], b[key])) return false;
787
+ }
788
+ return true;
789
+ }
790
+ return a !== a && b !== b;
791
+ };
792
+ }
793
+ });
794
+
795
+ // ../../node_modules/json-stringify-deterministic/lib/defaults.js
796
+ var require_defaults = __commonJS({
797
+ "../../node_modules/json-stringify-deterministic/lib/defaults.js"(exports, module) {
798
+ "use strict";
799
+ module.exports = {
800
+ space: "",
801
+ cycles: false,
802
+ replacer: (k, v) => v,
803
+ stringify: JSON.stringify
804
+ };
805
+ }
806
+ });
807
+
808
+ // ../../node_modules/json-stringify-deterministic/lib/util.js
809
+ var require_util = __commonJS({
810
+ "../../node_modules/json-stringify-deterministic/lib/util.js"(exports, module) {
811
+ "use strict";
812
+ module.exports = {
813
+ isArray: Array.isArray,
814
+ assign: Object.assign,
815
+ isObject: (v) => typeof v === "object",
816
+ isFunction: (v) => typeof v === "function",
817
+ isBoolean: (v) => typeof v === "boolean",
818
+ isRegex: (v) => v instanceof RegExp,
819
+ keys: Object.keys
820
+ };
821
+ }
822
+ });
823
+
824
+ // ../../node_modules/json-stringify-deterministic/lib/index.js
825
+ var require_lib = __commonJS({
826
+ "../../node_modules/json-stringify-deterministic/lib/index.js"(exports, module) {
827
+ "use strict";
828
+ var DEFAULTS = require_defaults();
829
+ var isFunction = require_util().isFunction;
830
+ var isBoolean = require_util().isBoolean;
831
+ var isObject = require_util().isObject;
832
+ var isArray = require_util().isArray;
833
+ var isRegex = require_util().isRegex;
834
+ var assign = require_util().assign;
835
+ var keys = require_util().keys;
836
+ function serialize(obj) {
837
+ if (obj === null || obj === void 0) return obj;
838
+ if (isRegex(obj)) return obj.toString();
839
+ return obj.toJSON ? obj.toJSON() : obj;
840
+ }
841
+ function stringifyDeterministic(obj, opts) {
842
+ opts = opts || assign({}, DEFAULTS);
843
+ if (isFunction(opts)) opts = { compare: opts };
844
+ const space = opts.space || DEFAULTS.space;
845
+ const cycles = isBoolean(opts.cycles) ? opts.cycles : DEFAULTS.cycles;
846
+ const replacer = opts.replacer || DEFAULTS.replacer;
847
+ const stringify2 = opts.stringify || DEFAULTS.stringify;
848
+ const compare = opts.compare && /* @__PURE__ */ (function(f) {
849
+ return function(node) {
850
+ return function(a, b) {
851
+ const aobj = { key: a, value: node[a] };
852
+ const bobj = { key: b, value: node[b] };
853
+ return f(aobj, bobj);
854
+ };
855
+ };
856
+ })(opts.compare);
857
+ if (!cycles) stringify2(obj);
858
+ const seen = [];
859
+ return (function _deterministic(parent, key, node, level) {
860
+ const indent2 = space ? "\n" + new Array(level + 1).join(space) : "";
861
+ const colonSeparator = space ? ": " : ":";
862
+ node = serialize(node);
863
+ node = replacer.call(parent, key, node);
864
+ if (node === void 0) return;
865
+ if (!isObject(node) || node === null) return stringify2(node);
866
+ if (isArray(node)) {
867
+ const out = [];
868
+ for (let i = 0; i < node.length; i++) {
869
+ const item = _deterministic(node, i, node[i], level + 1) || stringify2(null);
870
+ out.push(indent2 + space + item);
871
+ }
872
+ return "[" + out.join(",") + indent2 + "]";
873
+ } else {
874
+ if (cycles) {
875
+ if (seen.indexOf(node) !== -1) {
876
+ return stringify2("[Circular]");
877
+ } else {
878
+ seen.push(node);
879
+ }
880
+ }
881
+ const nodeKeys = keys(node).sort(compare && compare(node));
882
+ const out = [];
883
+ for (let i = 0; i < nodeKeys.length; i++) {
884
+ const key2 = nodeKeys[i];
885
+ const value = _deterministic(node, key2, node[key2], level + 1);
886
+ if (!value) continue;
887
+ const keyValue = stringify2(key2) + colonSeparator + value;
888
+ out.push(indent2 + space + keyValue);
889
+ }
890
+ seen.splice(seen.indexOf(node), 1);
891
+ return "{" + out.join(",") + indent2 + "}";
892
+ }
893
+ })({ "": obj }, "", obj, 0);
894
+ }
895
+ module.exports = stringifyDeterministic;
896
+ }
897
+ });
898
+
739
899
  // ../../node_modules/handlebars/dist/cjs/handlebars/utils.js
740
900
  var require_utils = __commonJS({
741
901
  "../../node_modules/handlebars/dist/cjs/handlebars/utils.js"(exports) {
@@ -1185,7 +1345,7 @@ var require_helpers = __commonJS({
1185
1345
  if (instance.helpers[helperName]) {
1186
1346
  instance.hooks[helperName] = instance.helpers[helperName];
1187
1347
  if (!keepHelper) {
1188
- delete instance.helpers[helperName];
1348
+ instance.helpers[helperName] = void 0;
1189
1349
  }
1190
1350
  }
1191
1351
  }
@@ -1277,22 +1437,6 @@ var require_logger = __commonJS({
1277
1437
  }
1278
1438
  });
1279
1439
 
1280
- // ../../node_modules/handlebars/dist/cjs/handlebars/internal/create-new-lookup-object.js
1281
- var require_create_new_lookup_object = __commonJS({
1282
- "../../node_modules/handlebars/dist/cjs/handlebars/internal/create-new-lookup-object.js"(exports) {
1283
- "use strict";
1284
- exports.__esModule = true;
1285
- exports.createNewLookupObject = createNewLookupObject;
1286
- var _utils = require_utils();
1287
- function createNewLookupObject() {
1288
- for (var _len = arguments.length, sources = Array(_len), _key = 0; _key < _len; _key++) {
1289
- sources[_key] = arguments[_key];
1290
- }
1291
- return _utils.extend.apply(void 0, [/* @__PURE__ */ Object.create(null)].concat(sources));
1292
- }
1293
- }
1294
- });
1295
-
1296
1440
  // ../../node_modules/handlebars/dist/cjs/handlebars/internal/proto-access.js
1297
1441
  var require_proto_access = __commonJS({
1298
1442
  "../../node_modules/handlebars/dist/cjs/handlebars/internal/proto-access.js"(exports) {
@@ -1304,25 +1448,28 @@ var require_proto_access = __commonJS({
1304
1448
  function _interopRequireDefault(obj) {
1305
1449
  return obj && obj.__esModule ? obj : { "default": obj };
1306
1450
  }
1307
- var _createNewLookupObject = require_create_new_lookup_object();
1451
+ var _utils = require_utils();
1308
1452
  var _logger = require_logger();
1309
1453
  var _logger2 = _interopRequireDefault(_logger);
1310
1454
  var loggedProperties = /* @__PURE__ */ Object.create(null);
1311
1455
  function createProtoAccessControl(runtimeOptions) {
1312
- var defaultMethodWhiteList = /* @__PURE__ */ Object.create(null);
1313
- defaultMethodWhiteList["constructor"] = false;
1314
- defaultMethodWhiteList["__defineGetter__"] = false;
1315
- defaultMethodWhiteList["__defineSetter__"] = false;
1316
- defaultMethodWhiteList["__lookupGetter__"] = false;
1317
- var defaultPropertyWhiteList = /* @__PURE__ */ Object.create(null);
1318
- defaultPropertyWhiteList["__proto__"] = false;
1456
+ var propertyWhiteList = /* @__PURE__ */ Object.create(null);
1457
+ propertyWhiteList["__proto__"] = false;
1458
+ _utils.extend(propertyWhiteList, runtimeOptions.allowedProtoProperties);
1459
+ var methodWhiteList = /* @__PURE__ */ Object.create(null);
1460
+ methodWhiteList["constructor"] = false;
1461
+ methodWhiteList["__defineGetter__"] = false;
1462
+ methodWhiteList["__defineSetter__"] = false;
1463
+ methodWhiteList["__lookupGetter__"] = false;
1464
+ methodWhiteList["__lookupSetter__"] = false;
1465
+ _utils.extend(methodWhiteList, runtimeOptions.allowedProtoMethods);
1319
1466
  return {
1320
1467
  properties: {
1321
- whitelist: _createNewLookupObject.createNewLookupObject(defaultPropertyWhiteList, runtimeOptions.allowedProtoProperties),
1468
+ whitelist: propertyWhiteList,
1322
1469
  defaultValue: runtimeOptions.allowProtoPropertiesByDefault
1323
1470
  },
1324
1471
  methods: {
1325
- whitelist: _createNewLookupObject.createNewLookupObject(defaultMethodWhiteList, runtimeOptions.allowedProtoMethods),
1472
+ whitelist: methodWhiteList,
1326
1473
  defaultValue: runtimeOptions.allowProtoMethodsByDefault
1327
1474
  }
1328
1475
  };
@@ -1375,7 +1522,7 @@ var require_base = __commonJS({
1375
1522
  var _logger = require_logger();
1376
1523
  var _logger2 = _interopRequireDefault(_logger);
1377
1524
  var _internalProtoAccess = require_proto_access();
1378
- var VERSION = "4.7.8";
1525
+ var VERSION = "4.7.9";
1379
1526
  exports.VERSION = VERSION;
1380
1527
  var COMPILER_REVISION = 8;
1381
1528
  exports.COMPILER_REVISION = COMPILER_REVISION;
@@ -1561,14 +1708,12 @@ var require_runtime = __commonJS({
1561
1708
  }
1562
1709
  }
1563
1710
  partial = env.VM.resolvePartial.call(this, partial, context, options);
1564
- var extendedOptions = Utils.extend({}, options, {
1565
- hooks: this.hooks,
1566
- protoAccessControl: this.protoAccessControl
1567
- });
1568
- var result = env.VM.invokePartial.call(this, partial, context, extendedOptions);
1711
+ options.hooks = this.hooks;
1712
+ options.protoAccessControl = this.protoAccessControl;
1713
+ var result = env.VM.invokePartial.call(this, partial, context, options);
1569
1714
  if (result == null && env.compile) {
1570
1715
  options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);
1571
- result = options.partials[options.name](context, extendedOptions);
1716
+ result = options.partials[options.name](context, options);
1572
1717
  }
1573
1718
  if (result != null) {
1574
1719
  if (options.indent) {
@@ -1613,7 +1758,7 @@ var require_runtime = __commonJS({
1613
1758
  for (var i = 0; i < len; i++) {
1614
1759
  var result = depths[i] && container.lookupProperty(depths[i], name);
1615
1760
  if (result != null) {
1616
- return depths[i][name];
1761
+ return result;
1617
1762
  }
1618
1763
  }
1619
1764
  },
@@ -1679,8 +1824,9 @@ var require_runtime = __commonJS({
1679
1824
  ret.isTop = true;
1680
1825
  ret._setup = function(options) {
1681
1826
  if (!options.partial) {
1682
- var mergedHelpers = Utils.extend({}, env.helpers, options.helpers);
1683
- wrapHelpersToPassLookupProperty(mergedHelpers, container);
1827
+ var mergedHelpers = {};
1828
+ addHelpers(mergedHelpers, env.helpers, container);
1829
+ addHelpers(mergedHelpers, options.helpers, container);
1684
1830
  container.helpers = mergedHelpers;
1685
1831
  if (templateSpec.usePartial) {
1686
1832
  container.partials = container.mergeIfNeeded(options.partials, env.partials);
@@ -1730,18 +1876,18 @@ var require_runtime = __commonJS({
1730
1876
  function resolvePartial(partial, context, options) {
1731
1877
  if (!partial) {
1732
1878
  if (options.name === "@partial-block") {
1733
- partial = options.data["partial-block"];
1879
+ partial = lookupOwnProperty(options.data, "partial-block");
1734
1880
  } else {
1735
- partial = options.partials[options.name];
1881
+ partial = lookupOwnProperty(options.partials, options.name);
1736
1882
  }
1737
1883
  } else if (!partial.call && !options.name) {
1738
1884
  options.name = partial;
1739
- partial = options.partials[partial];
1885
+ partial = lookupOwnProperty(options.partials, partial);
1740
1886
  }
1741
1887
  return partial;
1742
1888
  }
1743
1889
  function invokePartial(partial, context, options) {
1744
- var currentPartialBlock = options.data && options.data["partial-block"];
1890
+ var currentPartialBlock = lookupOwnProperty(options.data, "partial-block");
1745
1891
  options.partial = true;
1746
1892
  if (options.ids) {
1747
1893
  options.data.contextPath = options.ids[0] || options.data.contextPath;
@@ -1774,6 +1920,11 @@ var require_runtime = __commonJS({
1774
1920
  function noop() {
1775
1921
  return "";
1776
1922
  }
1923
+ function lookupOwnProperty(obj, name) {
1924
+ if (obj && Object.prototype.hasOwnProperty.call(obj, name)) {
1925
+ return obj[name];
1926
+ }
1927
+ }
1777
1928
  function initData(context, data) {
1778
1929
  if (!data || !("root" in data)) {
1779
1930
  data = data ? _base.createFrame(data) : {};
@@ -1789,16 +1940,18 @@ var require_runtime = __commonJS({
1789
1940
  }
1790
1941
  return prog;
1791
1942
  }
1792
- function wrapHelpersToPassLookupProperty(mergedHelpers, container) {
1793
- Object.keys(mergedHelpers).forEach(function(helperName) {
1794
- var helper = mergedHelpers[helperName];
1943
+ function addHelpers(mergedHelpers, helpers, container) {
1944
+ if (!helpers) return;
1945
+ Object.keys(helpers).forEach(function(helperName) {
1946
+ var helper = helpers[helperName];
1795
1947
  mergedHelpers[helperName] = passLookupPropertyOption(helper, container);
1796
1948
  });
1797
1949
  }
1798
1950
  function passLookupPropertyOption(helper, container) {
1799
1951
  var lookupProperty = container.lookupProperty;
1800
1952
  return _internalWrapHelper.wrapHelper(helper, function(options) {
1801
- return Utils.extend({ lookupProperty }, options);
1953
+ options.lookupProperty = lookupProperty;
1954
+ return options;
1802
1955
  });
1803
1956
  }
1804
1957
  }
@@ -2608,7 +2761,7 @@ var require_parser = __commonJS({
2608
2761
  break;
2609
2762
  }
2610
2763
  };
2611
- lexer2.rules = [/^(?:[^\x00]*?(?=(\{\{)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/, /^(?:\{\{\{\{(?=[^/]))/, /^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/, /^(?:[^\x00]+?(?=(\{\{\{\{)))/, /^(?:[\s\S]*?--(~)?\}\})/, /^(?:\()/, /^(?:\))/, /^(?:\{\{\{\{)/, /^(?:\}\}\}\})/, /^(?:\{\{(~)?>)/, /^(?:\{\{(~)?#>)/, /^(?:\{\{(~)?#\*?)/, /^(?:\{\{(~)?\/)/, /^(?:\{\{(~)?\^\s*(~)?\}\})/, /^(?:\{\{(~)?\s*else\s*(~)?\}\})/, /^(?:\{\{(~)?\^)/, /^(?:\{\{(~)?\s*else\b)/, /^(?:\{\{(~)?\{)/, /^(?:\{\{(~)?&)/, /^(?:\{\{(~)?!--)/, /^(?:\{\{(~)?![\s\S]*?\}\})/, /^(?:\{\{(~)?\*?)/, /^(?:=)/, /^(?:\.\.)/, /^(?:\.(?=([=~}\s\/.)|])))/, /^(?:[\/.])/, /^(?:\s+)/, /^(?:\}(~)?\}\})/, /^(?:(~)?\}\})/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*')/, /^(?:@)/, /^(?:true(?=([~}\s)])))/, /^(?:false(?=([~}\s)])))/, /^(?:undefined(?=([~}\s)])))/, /^(?:null(?=([~}\s)])))/, /^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/, /^(?:as\s+\|)/, /^(?:\|)/, /^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/, /^(?:\[(\\\]|[^\]])*\])/, /^(?:.)/, /^(?:$)/];
2764
+ lexer2.rules = [/^(?:[^\x00]*?(?=(\{\{)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/, /^(?:\{\{\{\{(?=[^\/]))/, /^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/, /^(?:[^\x00]+?(?=(\{\{\{\{)))/, /^(?:[\s\S]*?--(~)?\}\})/, /^(?:\()/, /^(?:\))/, /^(?:\{\{\{\{)/, /^(?:\}\}\}\})/, /^(?:\{\{(~)?>)/, /^(?:\{\{(~)?#>)/, /^(?:\{\{(~)?#\*?)/, /^(?:\{\{(~)?\/)/, /^(?:\{\{(~)?\^\s*(~)?\}\})/, /^(?:\{\{(~)?\s*else\s*(~)?\}\})/, /^(?:\{\{(~)?\^)/, /^(?:\{\{(~)?\s*else\b)/, /^(?:\{\{(~)?\{)/, /^(?:\{\{(~)?&)/, /^(?:\{\{(~)?!--)/, /^(?:\{\{(~)?![\s\S]*?\}\})/, /^(?:\{\{(~)?\*?)/, /^(?:=)/, /^(?:\.\.)/, /^(?:\.(?=([=~}\s\/.)|])))/, /^(?:[\/.])/, /^(?:\s+)/, /^(?:\}(~)?\}\})/, /^(?:(~)?\}\})/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*')/, /^(?:@)/, /^(?:true(?=([~}\s)])))/, /^(?:false(?=([~}\s)])))/, /^(?:undefined(?=([~}\s)])))/, /^(?:null(?=([~}\s)])))/, /^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/, /^(?:as\s+\|)/, /^(?:\|)/, /^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/, /^(?:\[(\\\]|[^\]])*\])/, /^(?:.)/, /^(?:$)/];
2612
2765
  lexer2.conditions = { "mu": { "rules": [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], "inclusive": false }, "emu": { "rules": [2], "inclusive": false }, "com": { "rules": [6], "inclusive": false }, "raw": { "rules": [3, 4, 5], "inclusive": false }, "INITIAL": { "rules": [0, 1, 44], "inclusive": true } };
2613
2766
  return lexer2;
2614
2767
  })();
@@ -3115,12 +3268,15 @@ var require_base2 = __commonJS({
3115
3268
  var _whitespaceControl2 = _interopRequireDefault(_whitespaceControl);
3116
3269
  var _helpers = require_helpers2();
3117
3270
  var Helpers = _interopRequireWildcard(_helpers);
3271
+ var _exception = require_exception();
3272
+ var _exception2 = _interopRequireDefault(_exception);
3118
3273
  var _utils = require_utils();
3119
3274
  exports.parser = _parser2["default"];
3120
3275
  var yy = {};
3121
3276
  _utils.extend(yy, Helpers);
3122
3277
  function parseWithoutProcessing(input, options) {
3123
3278
  if (input.type === "Program") {
3279
+ validateInputAst(input);
3124
3280
  return input;
3125
3281
  }
3126
3282
  _parser2["default"].yy = yy;
@@ -3135,6 +3291,51 @@ var require_base2 = __commonJS({
3135
3291
  var strip = new _whitespaceControl2["default"](options);
3136
3292
  return strip.accept(ast);
3137
3293
  }
3294
+ function validateInputAst(ast) {
3295
+ validateAstNode(ast);
3296
+ }
3297
+ function validateAstNode(node) {
3298
+ if (node == null) {
3299
+ return;
3300
+ }
3301
+ if (Array.isArray(node)) {
3302
+ node.forEach(validateAstNode);
3303
+ return;
3304
+ }
3305
+ if (typeof node !== "object") {
3306
+ return;
3307
+ }
3308
+ if (node.type === "PathExpression") {
3309
+ if (!isValidDepth(node.depth)) {
3310
+ throw new _exception2["default"]("Invalid AST: PathExpression.depth must be an integer");
3311
+ }
3312
+ if (!Array.isArray(node.parts)) {
3313
+ throw new _exception2["default"]("Invalid AST: PathExpression.parts must be an array");
3314
+ }
3315
+ for (var i = 0; i < node.parts.length; i++) {
3316
+ if (typeof node.parts[i] !== "string") {
3317
+ throw new _exception2["default"]("Invalid AST: PathExpression.parts must only contain strings");
3318
+ }
3319
+ }
3320
+ } else if (node.type === "NumberLiteral") {
3321
+ if (typeof node.value !== "number" || !isFinite(node.value)) {
3322
+ throw new _exception2["default"]("Invalid AST: NumberLiteral.value must be a number");
3323
+ }
3324
+ } else if (node.type === "BooleanLiteral") {
3325
+ if (typeof node.value !== "boolean") {
3326
+ throw new _exception2["default"]("Invalid AST: BooleanLiteral.value must be a boolean");
3327
+ }
3328
+ }
3329
+ Object.keys(node).forEach(function(propertyName) {
3330
+ if (propertyName === "loc") {
3331
+ return;
3332
+ }
3333
+ validateAstNode(node[propertyName]);
3334
+ });
3335
+ }
3336
+ function isValidDepth(depth) {
3337
+ return typeof depth === "number" && isFinite(depth) && Math.floor(depth) === depth && depth >= 0;
3338
+ }
3138
3339
  }
3139
3340
  });
3140
3341
 
@@ -3658,7 +3859,7 @@ var require_base64_vlq = __commonJS({
3658
3859
  });
3659
3860
 
3660
3861
  // ../../node_modules/source-map/lib/util.js
3661
- var require_util = __commonJS({
3862
+ var require_util2 = __commonJS({
3662
3863
  "../../node_modules/source-map/lib/util.js"(exports) {
3663
3864
  "use strict";
3664
3865
  function getArg(aArgs, aName, aDefaultValue) {
@@ -3806,8 +4007,8 @@ var require_util = __commonJS({
3806
4007
  var obj = /* @__PURE__ */ Object.create(null);
3807
4008
  return !("__proto__" in obj);
3808
4009
  })();
3809
- function identity(s) {
3810
- return s;
4010
+ function identity(s2) {
4011
+ return s2;
3811
4012
  }
3812
4013
  function toSetString(aStr) {
3813
4014
  if (isProtoString(aStr)) {
@@ -3823,19 +4024,19 @@ var require_util = __commonJS({
3823
4024
  return aStr;
3824
4025
  }
3825
4026
  exports.fromSetString = supportsNullProto ? identity : fromSetString;
3826
- function isProtoString(s) {
3827
- if (!s) {
4027
+ function isProtoString(s2) {
4028
+ if (!s2) {
3828
4029
  return false;
3829
4030
  }
3830
- var length = s.length;
4031
+ var length = s2.length;
3831
4032
  if (length < 9) {
3832
4033
  return false;
3833
4034
  }
3834
- if (s.charCodeAt(length - 1) !== 95 || s.charCodeAt(length - 2) !== 95 || s.charCodeAt(length - 3) !== 111 || s.charCodeAt(length - 4) !== 116 || s.charCodeAt(length - 5) !== 111 || s.charCodeAt(length - 6) !== 114 || s.charCodeAt(length - 7) !== 112 || s.charCodeAt(length - 8) !== 95 || s.charCodeAt(length - 9) !== 95) {
4035
+ if (s2.charCodeAt(length - 1) !== 95 || s2.charCodeAt(length - 2) !== 95 || s2.charCodeAt(length - 3) !== 111 || s2.charCodeAt(length - 4) !== 116 || s2.charCodeAt(length - 5) !== 111 || s2.charCodeAt(length - 6) !== 114 || s2.charCodeAt(length - 7) !== 112 || s2.charCodeAt(length - 8) !== 95 || s2.charCodeAt(length - 9) !== 95) {
3835
4036
  return false;
3836
4037
  }
3837
4038
  for (var i = length - 10; i >= 0; i--) {
3838
- if (s.charCodeAt(i) !== 36) {
4039
+ if (s2.charCodeAt(i) !== 36) {
3839
4040
  return false;
3840
4041
  }
3841
4042
  }
@@ -3963,7 +4164,7 @@ var require_util = __commonJS({
3963
4164
  var require_array_set = __commonJS({
3964
4165
  "../../node_modules/source-map/lib/array-set.js"(exports) {
3965
4166
  "use strict";
3966
- var util = require_util();
4167
+ var util = require_util2();
3967
4168
  var has = Object.prototype.hasOwnProperty;
3968
4169
  var hasNativeMap = typeof Map !== "undefined";
3969
4170
  function ArraySet() {
@@ -4034,7 +4235,7 @@ var require_array_set = __commonJS({
4034
4235
  var require_mapping_list = __commonJS({
4035
4236
  "../../node_modules/source-map/lib/mapping-list.js"(exports) {
4036
4237
  "use strict";
4037
- var util = require_util();
4238
+ var util = require_util2();
4038
4239
  function generatedPositionAfter(mappingA, mappingB) {
4039
4240
  var lineA = mappingA.generatedLine;
4040
4241
  var lineB = mappingB.generatedLine;
@@ -4075,7 +4276,7 @@ var require_source_map_generator = __commonJS({
4075
4276
  "../../node_modules/source-map/lib/source-map-generator.js"(exports) {
4076
4277
  "use strict";
4077
4278
  var base64VLQ = require_base64_vlq();
4078
- var util = require_util();
4279
+ var util = require_util2();
4079
4280
  var ArraySet = require_array_set().ArraySet;
4080
4281
  var MappingList = require_mapping_list().MappingList;
4081
4282
  function SourceMapGenerator(aArgs) {
@@ -4444,7 +4645,7 @@ var require_quick_sort = __commonJS({
4444
4645
  var require_source_map_consumer = __commonJS({
4445
4646
  "../../node_modules/source-map/lib/source-map-consumer.js"(exports) {
4446
4647
  "use strict";
4447
- var util = require_util();
4648
+ var util = require_util2();
4448
4649
  var binarySearch = require_binary_search();
4449
4650
  var ArraySet = require_array_set().ArraySet;
4450
4651
  var base64VLQ = require_base64_vlq();
@@ -4591,8 +4792,8 @@ var require_source_map_consumer = __commonJS({
4591
4792
  });
4592
4793
  this._names = ArraySet.fromArray(names.map(String), true);
4593
4794
  this._sources = ArraySet.fromArray(sources, true);
4594
- this._absoluteSources = this._sources.toArray().map(function(s) {
4595
- return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
4795
+ this._absoluteSources = this._sources.toArray().map(function(s2) {
4796
+ return util.computeSourceURL(sourceRoot, s2, aSourceMapURL);
4596
4797
  });
4597
4798
  this.sourceRoot = sourceRoot;
4598
4799
  this.sourcesContent = sourcesContent;
@@ -4629,8 +4830,8 @@ var require_source_map_consumer = __commonJS({
4629
4830
  );
4630
4831
  smc.file = aSourceMap._file;
4631
4832
  smc._sourceMapURL = aSourceMapURL;
4632
- smc._absoluteSources = smc._sources.toArray().map(function(s) {
4633
- return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
4833
+ smc._absoluteSources = smc._sources.toArray().map(function(s2) {
4834
+ return util.computeSourceURL(smc.sourceRoot, s2, aSourceMapURL);
4634
4835
  });
4635
4836
  var generatedMappings = aSourceMap._mappings.toArray().slice();
4636
4837
  var destGeneratedMappings = smc.__generatedMappings = [];
@@ -4897,11 +5098,11 @@ var require_source_map_consumer = __commonJS({
4897
5098
  line: -1,
4898
5099
  column: 0
4899
5100
  };
4900
- this._sections = sections.map(function(s) {
4901
- if (s.url) {
5101
+ this._sections = sections.map(function(s2) {
5102
+ if (s2.url) {
4902
5103
  throw new Error("Support for url field in sections not implemented.");
4903
5104
  }
4904
- var offset = util.getArg(s, "offset");
5105
+ var offset = util.getArg(s2, "offset");
4905
5106
  var offsetLine = util.getArg(offset, "line");
4906
5107
  var offsetColumn = util.getArg(offset, "column");
4907
5108
  if (offsetLine < lastOffset.line || offsetLine === lastOffset.line && offsetColumn < lastOffset.column) {
@@ -4915,7 +5116,7 @@ var require_source_map_consumer = __commonJS({
4915
5116
  generatedLine: offsetLine + 1,
4916
5117
  generatedColumn: offsetColumn + 1
4917
5118
  },
4918
- consumer: new SourceMapConsumer(util.getArg(s, "map"), aSourceMapURL)
5119
+ consumer: new SourceMapConsumer(util.getArg(s2, "map"), aSourceMapURL)
4919
5120
  };
4920
5121
  });
4921
5122
  }
@@ -4965,8 +5166,8 @@ var require_source_map_consumer = __commonJS({
4965
5166
  });
4966
5167
  };
4967
5168
  IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = function IndexedSourceMapConsumer_hasContentsOfAllSources() {
4968
- return this._sections.every(function(s) {
4969
- return s.consumer.hasContentsOfAllSources();
5169
+ return this._sections.every(function(s2) {
5170
+ return s2.consumer.hasContentsOfAllSources();
4970
5171
  });
4971
5172
  };
4972
5173
  IndexedSourceMapConsumer.prototype.sourceContentFor = function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
@@ -5047,7 +5248,7 @@ var require_source_node = __commonJS({
5047
5248
  "../../node_modules/source-map/lib/source-node.js"(exports) {
5048
5249
  "use strict";
5049
5250
  var SourceMapGenerator = require_source_map_generator().SourceMapGenerator;
5050
- var util = require_util();
5251
+ var util = require_util2();
5051
5252
  var REGEX_NEWLINE = /(\r?\n)/;
5052
5253
  var NEWLINE_CODE = 10;
5053
5254
  var isSourceNode = "$$$isSourceNode$$$";
@@ -5574,12 +5775,10 @@ var require_javascript_compiler = __commonJS({
5574
5775
  var programs = _context.programs;
5575
5776
  var decorators = _context.decorators;
5576
5777
  for (i = 0, l = programs.length; i < l; i++) {
5577
- if (programs[i]) {
5578
- ret[i] = programs[i];
5579
- if (decorators[i]) {
5580
- ret[i + "_d"] = decorators[i];
5581
- ret.useDecorators = true;
5582
- }
5778
+ ret[i] = programs[i];
5779
+ if (decorators[i]) {
5780
+ ret[i + "_d"] = decorators[i];
5781
+ ret.useDecorators = true;
5583
5782
  }
5584
5783
  }
5585
5784
  if (this.environment.usePartial) {
@@ -5840,22 +6039,25 @@ var require_javascript_compiler = __commonJS({
5840
6039
  }
5841
6040
  this.resolvePath("data", parts, 0, true, strict);
5842
6041
  },
5843
- resolvePath: function resolvePath(type, parts, i, falsy, strict) {
6042
+ resolvePath: function resolvePath(type, parts, startPartIndex, falsy, strict) {
5844
6043
  var _this2 = this;
5845
6044
  if (this.options.strict || this.options.assumeObjects) {
5846
- this.push(strictLookup(this.options.strict && strict, this, parts, i, type));
6045
+ this.push(strictLookup(this.options.strict && strict, this, parts, startPartIndex, type));
5847
6046
  return;
5848
6047
  }
5849
6048
  var len = parts.length;
5850
- for (; i < len; i++) {
5851
- this.replaceStack(function(current) {
5852
- var lookup = _this2.nameLookup(current, parts[i], type);
6049
+ var _loop = function(i2) {
6050
+ _this2.replaceStack(function(current) {
6051
+ var lookup = _this2.nameLookup(current, parts[i2], type);
5853
6052
  if (!falsy) {
5854
6053
  return [" != null ? ", lookup, " : ", current];
5855
6054
  } else {
5856
6055
  return [" && ", lookup];
5857
6056
  }
5858
6057
  });
6058
+ };
6059
+ for (var i = startPartIndex; i < len; i++) {
6060
+ _loop(i);
5859
6061
  }
5860
6062
  },
5861
6063
  // [resolvePossibleLambda]
@@ -5959,7 +6161,9 @@ var require_javascript_compiler = __commonJS({
5959
6161
  // and inserts the decorator into the decorators list.
5960
6162
  registerDecorator: function registerDecorator(paramSize, name) {
5961
6163
  var foundDecorator = this.nameLookup("decorators", name, "decorator"), options = this.setupHelperArgs(name, paramSize);
5962
- this.decorators.push(["fn = ", this.decorators.functionCall(foundDecorator, "", ["fn", "props", "container", options]), " || fn;"]);
6164
+ this.decorators.push(["var decorator = ", foundDecorator, ";"]);
6165
+ this.decorators.push(['if (typeof decorator !== "function") { throw new Error(', this.quotedString('Missing decorator: "' + name + '"'), "); }"]);
6166
+ this.decorators.push(["fn = ", this.decorators.functionCall("decorator", "", ["fn", "props", "container", options]), " || fn;"]);
5963
6167
  },
5964
6168
  // [invokeHelper]
5965
6169
  //
@@ -6106,8 +6310,7 @@ var require_javascript_compiler = __commonJS({
6106
6310
  compiler = new this.compiler();
6107
6311
  var existing = this.matchExistingProgram(child);
6108
6312
  if (existing == null) {
6109
- this.context.programs.push("");
6110
- var index = this.context.programs.length;
6313
+ var index = this.context.programs.push("") - 1;
6111
6314
  child.index = index;
6112
6315
  child.name = "program" + index;
6113
6316
  this.context.programs[index] = compiler.compile(child, options, this.context, !this.precompile);
@@ -6351,16 +6554,16 @@ var require_javascript_compiler = __commonJS({
6351
6554
  JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
6352
6555
  return !JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name);
6353
6556
  };
6354
- function strictLookup(requireTerminal, compiler, parts, i, type) {
6557
+ function strictLookup(requireTerminal, compiler, parts, startPartIndex, type) {
6355
6558
  var stack = compiler.popStack(), len = parts.length;
6356
6559
  if (requireTerminal) {
6357
6560
  len--;
6358
6561
  }
6359
- for (; i < len; i++) {
6562
+ for (var i = startPartIndex; i < len; i++) {
6360
6563
  stack = compiler.nameLookup(stack, parts[i], type);
6361
6564
  }
6362
6565
  if (requireTerminal) {
6363
- return [compiler.aliasable("container.strict"), "(", stack, ", ", compiler.quotedString(parts[i]), ", ", JSON.stringify(compiler.source.currentLocation), " )"];
6566
+ return [compiler.aliasable("container.strict"), "(", stack, ", ", compiler.quotedString(parts[len]), ", ", JSON.stringify(compiler.source.currentLocation), " )"];
6364
6567
  } else {
6365
6568
  return stack;
6366
6569
  }
@@ -6564,7 +6767,7 @@ var require_printer = __commonJS({
6564
6767
  });
6565
6768
 
6566
6769
  // ../../node_modules/handlebars/lib/index.js
6567
- var require_lib = __commonJS({
6770
+ var require_lib2 = __commonJS({
6568
6771
  "../../node_modules/handlebars/lib/index.js"(exports, module) {
6569
6772
  "use strict";
6570
6773
  var handlebars = require_handlebars()["default"];
@@ -7443,6 +7646,16 @@ function ErrFromThrowable(error) {
7443
7646
  error
7444
7647
  };
7445
7648
  }
7649
+ function resolveAppErrorInfo(errorInfo, cause) {
7650
+ if (typeof errorInfo !== "function") {
7651
+ return errorInfo;
7652
+ }
7653
+ const result = fromThrowable(() => errorInfo(cause), "resolve-app-error-info-error");
7654
+ return isOk(result) ? result.value : void 0;
7655
+ }
7656
+ function isOk(result) {
7657
+ return result._tag === "Ok";
7658
+ }
7446
7659
  function isErr(result) {
7447
7660
  return result._tag === "Err";
7448
7661
  }
@@ -7451,7 +7664,7 @@ function fromThrowable(fn, errorType, errorInfo) {
7451
7664
  const result = fn();
7452
7665
  if (result && typeof result.then === "function") {
7453
7666
  return result.then((value) => Ok(value)).catch((err) => Err({
7454
- ...errorInfo,
7667
+ ...resolveAppErrorInfo(errorInfo, err),
7455
7668
  type: errorType,
7456
7669
  cause: err
7457
7670
  }));
@@ -7459,7 +7672,7 @@ function fromThrowable(fn, errorType, errorInfo) {
7459
7672
  return Ok(result);
7460
7673
  } catch (err) {
7461
7674
  return Err({
7462
- ...errorInfo,
7675
+ ...resolveAppErrorInfo(errorInfo, err),
7463
7676
  type: errorType,
7464
7677
  cause: err
7465
7678
  });
@@ -7476,68 +7689,2321 @@ function safeJsonParse(json) {
7476
7689
  }
7477
7690
  }
7478
7691
 
7479
- // ../mcp-registry/src/operation-specs.ts
7480
- import { z as z2 } from "zod";
7692
+ // ../common/dist/src/constants/tool-declarations.js
7693
+ import { z as z10 } from "zod";
7481
7694
 
7482
- // ../mcp-registry/src/operation-spec.ts
7483
- function stripLeadingGraphqlComments(document) {
7484
- return document.replace(/^(?:\s*#.*\n)+/u, "").trimStart();
7485
- }
7486
- function assertDocumentMatchesOperation({
7487
- document,
7488
- kind,
7489
- operationName
7490
- }) {
7491
- const normalizedDocument = stripLeadingGraphqlComments(document);
7492
- const match = /^(?<actualKind>query|mutation)\s+(?<actualOperationName>[_A-Za-z][_0-9A-Za-z]*)/u.exec(
7493
- normalizedDocument
7494
- );
7495
- const actualKind = match?.groups?.["actualKind"];
7496
- const actualOperationName = match?.groups?.["actualOperationName"];
7497
- if (!actualKind || !actualOperationName) {
7498
- throw new Error(
7499
- `Operation "${operationName}" is missing a top-level GraphQL ${kind} definition.`
7695
+ // ../common/dist/src/zod-schemas/model-config.schema.js
7696
+ import { z as z5 } from "zod";
7697
+
7698
+ // ../common/dist/src/utils/zod.util.js
7699
+ var import_ts_essentials2 = __toESM(require_dist(), 1);
7700
+ import { z as z4, ZodObject } from "zod";
7701
+
7702
+ // ../../node_modules/zodex/dist/esm/index.js
7703
+ import { z as z2 } from "zod";
7704
+ import { z as z22 } from "zod";
7705
+ var STRING_KINDS = /* @__PURE__ */ new Set([
7706
+ "url",
7707
+ "emoji",
7708
+ "nanoid",
7709
+ "cuid",
7710
+ "cuid2",
7711
+ "ulid",
7712
+ "date",
7713
+ "duration",
7714
+ "base64",
7715
+ "base64url",
7716
+ "guid",
7717
+ "xid",
7718
+ "ksuid",
7719
+ "json_string",
7720
+ "e164",
7721
+ "jwt",
7722
+ "ipv4",
7723
+ "ipv6",
7724
+ "cidrv4",
7725
+ "cidrv6",
7726
+ "e164"
7727
+ // "uuidv8", // In docs only
7728
+ // "ascii", // In docs only
7729
+ // "utf8", // In docs only
7730
+ // "lowercase", // Doesn't appear to have enough data to serialize
7731
+ // "uppercase", // Doesn't appear to have enough data to serialize
7732
+ ]);
7733
+ var getCustomChecksAndErrors = (def, opts) => {
7734
+ let customChecks = null;
7735
+ if ("checks" in opts && opts.checks) {
7736
+ customChecks = def.checks?.filter((check) => {
7737
+ const chk = check._zod.def.check;
7738
+ return chk == "custom";
7739
+ }).map((check) => {
7740
+ const name = Object.entries(
7741
+ /* c8 ignore next -- TS doesn't catch */
7742
+ opts.checks || {}
7743
+ ).find(([, checkFunc]) => {
7744
+ return checkFunc === check._zod.check;
7745
+ })?.[0];
7746
+ if (name) {
7747
+ return { name };
7748
+ }
7749
+ return null;
7750
+ }).filter(Boolean);
7751
+ }
7752
+ let customError;
7753
+ if ("error" in def) {
7754
+ const key = Object.entries(opts.errors ?? {}).find(([, func]) => {
7755
+ return func === def.error;
7756
+ })?.[0];
7757
+ customError = typeof key == "string" ? { key } : (
7758
+ // Not supplying an issue should not be a problem for regular
7759
+ // wrapped string errors
7760
+ def.error()
7500
7761
  );
7501
7762
  }
7502
- if (actualKind !== kind || actualOperationName !== operationName) {
7503
- throw new Error(
7504
- `Operation "${operationName}" does not match its GraphQL document (${actualKind} ${actualOperationName}).`
7763
+ return Object.assign(
7764
+ customChecks ? { checks: customChecks } : {},
7765
+ customError ? { error: customError } : {}
7766
+ );
7767
+ };
7768
+ var s = zerializeRefs;
7769
+ var zerializers = {
7770
+ optional: (def, opts) => ({
7771
+ ...s(def.innerType, opts, true),
7772
+ isOptional: true
7773
+ }),
7774
+ nullable: (def, opts) => ({
7775
+ ...s(def.innerType, opts, true),
7776
+ isNullable: true
7777
+ }),
7778
+ default: (def, opts) => ({
7779
+ ...s(def.innerType, opts, true),
7780
+ defaultValue: def.innerType._zod.def.type === "bigint" ? String(def.defaultValue) : def.innerType._zod.def.type === "date" ? def.defaultValue.getTime() : def.defaultValue
7781
+ }),
7782
+ number: (def, opts) => {
7783
+ const checks = def.checks?.reduce((o, check) => {
7784
+ const chk = check._zod.def.check;
7785
+ const format = check._zod.def.format;
7786
+ return {
7787
+ ...o,
7788
+ ...chk == "greater_than" ? {
7789
+ min: check._zod.def.value,
7790
+ ...check._zod.def.inclusive ? { minInclusive: true } : {}
7791
+ } : chk == "less_than" ? {
7792
+ max: check._zod.def.value,
7793
+ ...check._zod.def.inclusive ? { maxInclusive: true } : {}
7794
+ } : chk == "multiple_of" ? {
7795
+ multipleOf: check._zod.def.value
7796
+ /* c8 ignore next 2 -- Guard */
7797
+ } : {}
7798
+ };
7799
+ }, {});
7800
+ return Object.assign(
7801
+ {
7802
+ type: "number",
7803
+ ...checks,
7804
+ ...getCustomChecksAndErrors(def, opts),
7805
+ // Check is on `def` itself
7806
+ ..."check" in def && def.check === "number_format" && "format" in def ? { format: def.format } : {}
7807
+ },
7808
+ def.coerce ? { coerce: true } : {}
7809
+ );
7810
+ },
7811
+ template_literal: (def, opts) => {
7812
+ const parts = def.parts.map((part, idx) => {
7813
+ if (typeof part == "string") {
7814
+ return part;
7815
+ }
7816
+ return s(part, {
7817
+ ...opts,
7818
+ currentPath: [...opts.currentPath, "parts", String(idx)]
7819
+ });
7820
+ });
7821
+ return {
7822
+ type: "templateLiteral",
7823
+ parts,
7824
+ ...def.format ? { format: def.format } : {}
7825
+ };
7826
+ },
7827
+ string: (def, opts) => {
7828
+ const checks = def.checks?.reduce((o, check) => {
7829
+ const chk = check._zod.def.check;
7830
+ const format2 = check._zod.def.format;
7831
+ return {
7832
+ ...o,
7833
+ ...chk == "min_length" ? { min: check._zod.def.minimum } : chk == "max_length" ? { max: check._zod.def.maximum } : chk == "length_equals" ? {
7834
+ length: check._zod.def.length
7835
+ } : (
7836
+ // Any way around this?
7837
+ chk === "overwrite" && check._zod.def.tx.toString() === "(input) => input.toUpperCase()" ? { toUpperCase: true } : chk === "overwrite" && check._zod.def.tx.toString() === "(input) => input.toLowerCase()" ? { toLowerCase: true } : chk === "overwrite" && check._zod.def.tx.toString() === "(input) => input.trim()" ? { trim: true } : (
7838
+ // No apparent check
7839
+ // : chk == "string_format" && format == "trim"
7840
+ // ? { trim: true }
7841
+ chk == "string_format" && format2 == "starts_with" ? {
7842
+ startsWith: check._zod.def.prefix
7843
+ } : chk == "string_format" && format2 == "ends_with" ? {
7844
+ endsWith: check._zod.def.suffix
7845
+ } : chk == "string_format" && format2 == "includes" ? {
7846
+ includes: check._zod.def.includes,
7847
+ position: check._zod.def.position
7848
+ } : chk == "string_format" && format2 == "regex" ? {
7849
+ regex: check._zod.def.pattern.source,
7850
+ ...check._zod.def.pattern.flags ? {
7851
+ flags: check._zod.def.pattern.flags
7852
+ } : {}
7853
+ /* c8 ignore next 2 -- Guard */
7854
+ } : {}
7855
+ )
7856
+ )
7857
+ };
7858
+ }, {});
7859
+ const format = "format" in def && def.format;
7860
+ return Object.assign(
7861
+ {
7862
+ type: "string",
7863
+ ...checks,
7864
+ ...getCustomChecksAndErrors(def, opts),
7865
+ // Check is on `def` itself
7866
+ ...format == "ipv4" ? { kind: "ip", version: "v4" } : format == "ipv6" ? { kind: "ip", version: "v6" } : format == "cidrv4" ? { kind: "cidr", version: "v4" } : format == "cidrv6" ? { kind: "cidr", version: "v6" } : format == "uuid" ? {
7867
+ kind: "uuid",
7868
+ ..."version" in def ? { version: def.version } : {}
7869
+ } : format == "jwt" ? {
7870
+ kind: "jwt",
7871
+ ..."alg" in def ? { algorithm: def.alg } : {}
7872
+ } : format == "email" ? {
7873
+ kind: "email",
7874
+ ..."pattern" in def && def.pattern && typeof def.pattern == "object" && "source" in def.pattern && "flags" in def.pattern && def.pattern.source !== z22.regexes.email.source ? {
7875
+ pattern: def.pattern.source,
7876
+ flags: def.pattern.flags
7877
+ } : {}
7878
+ } : "format" in def && STRING_KINDS.has(format) || format == "datetime" || format == "time" ? {
7879
+ kind: format,
7880
+ ..."precision" in def && def.precision ? {
7881
+ precision: def.precision
7882
+ } : {},
7883
+ ..."offset" in def && def.offset ? {
7884
+ offset: def.offset
7885
+ } : {},
7886
+ ..."local" in def && def.local ? {
7887
+ local: def.local
7888
+ } : {}
7889
+ } : {}
7890
+ },
7891
+ def.coerce ? { coerce: true } : {}
7892
+ );
7893
+ },
7894
+ boolean: (def) => Object.assign({ type: "boolean" }, def.coerce ? { coerce: true } : {}),
7895
+ nan: () => ({ type: "nan" }),
7896
+ symbol: () => ({ type: "symbol" }),
7897
+ bigint: (def, opts) => {
7898
+ const checks = def.checks?.reduce((o, check) => {
7899
+ const chk = check._zod.def.check;
7900
+ return {
7901
+ ...o,
7902
+ ...chk == "greater_than" ? {
7903
+ min: String(
7904
+ check._zod.def.value
7905
+ ),
7906
+ ...check._zod.def.inclusive ? { minInclusive: true } : {}
7907
+ } : chk == "less_than" ? {
7908
+ max: String(
7909
+ check._zod.def.value
7910
+ ),
7911
+ ...check._zod.def.inclusive ? { maxInclusive: true } : {}
7912
+ } : chk == "multiple_of" ? {
7913
+ multipleOf: String(
7914
+ check._zod.def.value
7915
+ )
7916
+ /* c8 ignore next 2 -- Guard */
7917
+ } : {}
7918
+ };
7919
+ }, {});
7920
+ return Object.assign(
7921
+ {
7922
+ type: "bigInt",
7923
+ ...checks,
7924
+ ...getCustomChecksAndErrors(def, opts),
7925
+ // Check is on `def` itself
7926
+ ..."check" in def && def.check === "bigint_format" && "format" in def ? { format: def.format } : {}
7927
+ },
7928
+ def.coerce ? { coerce: true } : {}
7929
+ );
7930
+ },
7931
+ file: (def) => {
7932
+ const checks = def.checks?.reduce((o, check) => {
7933
+ const chk = check._zod.def.check;
7934
+ return {
7935
+ ...o,
7936
+ ...chk == "min_size" ? {
7937
+ min: check._zod.def.minimum
7938
+ } : chk == "max_size" ? {
7939
+ max: check._zod.def.maximum
7940
+ } : chk == "mime_type" ? {
7941
+ mime: check._zod.def.mime
7942
+ /* c8 ignore next 2 -- Guard */
7943
+ } : {}
7944
+ };
7945
+ }, {});
7946
+ return {
7947
+ type: "file",
7948
+ ...checks
7949
+ };
7950
+ },
7951
+ date: (def, opts) => {
7952
+ const checks = def.checks?.reduce((o, check) => {
7953
+ const chk = check._zod.def.check;
7954
+ return {
7955
+ ...o,
7956
+ ...chk == "greater_than" ? {
7957
+ min: check._zod.def.value.getTime()
7958
+ // ...((check as z.core.$ZodCheckLessThan<Date>)._zod.def.inclusive
7959
+ // ? { minInclusive: true }
7960
+ // : {}),
7961
+ } : chk == "less_than" ? {
7962
+ max: check._zod.def.value.getTime()
7963
+ // ...((check as z.core.$ZodCheckLessThan<Date>)._zod.def.inclusive
7964
+ // ? { maxInclusive: true }
7965
+ // : {}),
7966
+ } : (
7967
+ /* c8 ignore next -- Guard */
7968
+ {}
7969
+ )
7970
+ };
7971
+ }, {});
7972
+ return Object.assign(
7973
+ { type: "date", ...checks, ...getCustomChecksAndErrors(def, opts) },
7974
+ def.coerce ? { coerce: true } : {}
7975
+ );
7976
+ },
7977
+ undefined: () => ({ type: "undefined" }),
7978
+ null: () => ({ type: "null" }),
7979
+ any: () => ({ type: "any" }),
7980
+ unknown: () => ({ type: "unknown" }),
7981
+ never: () => ({ type: "never" }),
7982
+ void: () => ({ type: "void" }),
7983
+ literal: (def) => ({ type: "literal", values: def.values }),
7984
+ tuple: (def, opts) => ({
7985
+ type: "tuple",
7986
+ ...getCustomChecksAndErrors(def, opts),
7987
+ items: def.items.map((item, idx) => {
7988
+ const result = s(item, {
7989
+ ...opts,
7990
+ currentPath: [...opts.currentPath, "items", String(idx)]
7991
+ });
7992
+ return result;
7993
+ }),
7994
+ ...def.rest ? {
7995
+ rest: s(def.rest, {
7996
+ ...opts,
7997
+ currentPath: [...opts.currentPath, "rest"]
7998
+ })
7999
+ } : {}
8000
+ }),
8001
+ set: (def, opts) => {
8002
+ const checks = def.checks?.reduce((o, check) => {
8003
+ const chk = check._zod.def.check;
8004
+ return {
8005
+ ...o,
8006
+ ...chk == "min_size" ? {
8007
+ minSize: check._zod.def.minimum
8008
+ } : chk == "max_size" ? {
8009
+ maxSize: check._zod.def.maximum
8010
+ } : chk == "size_equals" ? {
8011
+ minSize: check._zod.def.size,
8012
+ maxSize: check._zod.def.size
8013
+ /* c8 ignore next 2 -- Guard */
8014
+ } : {}
8015
+ };
8016
+ }, {});
8017
+ return {
8018
+ type: "set",
8019
+ value: s(def.valueType, {
8020
+ ...opts,
8021
+ currentPath: [...opts.currentPath, "value"]
8022
+ }),
8023
+ ...getCustomChecksAndErrors(def, opts),
8024
+ ...checks
8025
+ };
8026
+ },
8027
+ array: (def, opts) => {
8028
+ const checks = def.checks?.reduce((o, check) => {
8029
+ const chk = check._zod.def.check;
8030
+ return {
8031
+ ...o,
8032
+ ...chk == "min_length" ? { minLength: check._zod.def.minimum } : chk == "max_length" ? {
8033
+ maxLength: check._zod.def.maximum
8034
+ } : chk == "length_equals" ? {
8035
+ minLength: check._zod.def.length,
8036
+ maxLength: check._zod.def.length
8037
+ /* c8 ignore next 2 -- Guard */
8038
+ } : {}
8039
+ };
8040
+ }, {});
8041
+ return {
8042
+ type: "array",
8043
+ element: s(def.element, {
8044
+ ...opts,
8045
+ currentPath: [...opts.currentPath, "element"]
8046
+ }),
8047
+ ...getCustomChecksAndErrors(def, opts),
8048
+ ...checks
8049
+ };
8050
+ },
8051
+ object: (def, opts) => {
8052
+ return {
8053
+ type: "object",
8054
+ ...getCustomChecksAndErrors(def, opts),
8055
+ ...!def.catchall ? {} : {
8056
+ catchall: s(def.catchall, {
8057
+ ...opts,
8058
+ currentPath: [...opts.currentPath, "catchall"]
8059
+ })
8060
+ },
8061
+ properties: Object.fromEntries(
8062
+ Object.entries(def.shape).map(([key, schema]) => [
8063
+ key,
8064
+ s(schema, {
8065
+ ...opts,
8066
+ currentPath: [...opts.currentPath, "properties", key]
8067
+ })
8068
+ ])
8069
+ )
8070
+ };
8071
+ },
8072
+ record: (def, opts) => ({
8073
+ type: "record",
8074
+ ...getCustomChecksAndErrors(def, opts),
8075
+ key: s(def.keyType, {
8076
+ ...opts,
8077
+ currentPath: [...opts.currentPath, "key"]
8078
+ }),
8079
+ value: s(def.valueType, {
8080
+ ...opts,
8081
+ currentPath: [...opts.currentPath, "value"]
8082
+ })
8083
+ }),
8084
+ map: (def, opts) => ({
8085
+ type: "map",
8086
+ ...getCustomChecksAndErrors(def, opts),
8087
+ key: s(def.keyType, {
8088
+ ...opts,
8089
+ currentPath: [...opts.currentPath, "key"]
8090
+ }),
8091
+ value: s(def.valueType, {
8092
+ ...opts,
8093
+ currentPath: [...opts.currentPath, "value"]
8094
+ })
8095
+ }),
8096
+ enum: (def) => ({ type: "enum", values: def.entries }),
8097
+ union: (def, opts) => {
8098
+ return {
8099
+ type: "discriminator" in def ? "discriminatedUnion" : "union",
8100
+ ..."discriminator" in def ? {
8101
+ discriminator: def.discriminator
8102
+ } : {},
8103
+ ...getCustomChecksAndErrors(def, opts),
8104
+ options: def.options.map((opt, idx) => {
8105
+ const result = s(opt, {
8106
+ ...opts,
8107
+ currentPath: [...opts.currentPath, "options", String(idx)]
8108
+ });
8109
+ return result;
8110
+ })
8111
+ };
8112
+ },
8113
+ intersection: (def, opts) => ({
8114
+ type: "intersection",
8115
+ ...getCustomChecksAndErrors(def, opts),
8116
+ left: s(def.left, {
8117
+ ...opts,
8118
+ currentPath: [...opts.currentPath, "left"]
8119
+ }),
8120
+ right: s(def.right, {
8121
+ ...opts,
8122
+ currentPath: [...opts.currentPath, "right"]
8123
+ })
8124
+ }),
8125
+ promise: (def, opts) => ({
8126
+ type: "promise",
8127
+ value: s(def.innerType, {
8128
+ ...opts,
8129
+ currentPath: [...opts.currentPath, "value"]
8130
+ })
8131
+ }),
8132
+ lazy: (def, opts) => {
8133
+ const getter = def.getter();
8134
+ return s(
8135
+ getter,
8136
+ opts,
8137
+ // official equivalent for `isOptional`
8138
+ getter.safeParse(void 0).success || // official equivalent for `isNullable`
8139
+ getter.safeParse(null).success
7505
8140
  );
8141
+ },
8142
+ transform: (def, opts) => {
8143
+ let name = null;
8144
+ if ("transforms" in opts && opts.transforms) {
8145
+ for (const [transformName, transformItem] of Object.entries(
8146
+ opts.transforms
8147
+ )) {
8148
+ if (def.type === "transform" && transformItem === def.transform) {
8149
+ name = transformName;
8150
+ break;
8151
+ }
8152
+ }
8153
+ }
8154
+ return {
8155
+ type: "transform",
8156
+ name
8157
+ // inner: s(def.out, {
8158
+ // ...opts,
8159
+ // currentPath: [...opts.currentPath, "inner"],
8160
+ // }),
8161
+ };
8162
+ },
8163
+ pipe: (def, opts) => {
8164
+ if (!("transforms" in opts)) {
8165
+ return s(def.out, opts);
8166
+ }
8167
+ return {
8168
+ type: "pipe",
8169
+ ...getCustomChecksAndErrors(def, opts),
8170
+ inner: s(def.in, opts),
8171
+ outer: s(def.out, opts)
8172
+ };
8173
+ },
8174
+ catch: (def, opts) => {
8175
+ const catchValue = def.catchValue({
8176
+ value: null,
8177
+ issues: [],
8178
+ // No errors to report, so just add an empty set
8179
+ /* c8 ignore next 3 -- Unused */
8180
+ get error() {
8181
+ return new z22.ZodError([]);
8182
+ },
8183
+ // We don't have any input yet, so just provide `undefined`
8184
+ input: void 0
8185
+ });
8186
+ return {
8187
+ type: "catch",
8188
+ value: catchValue,
8189
+ innerType: s(def.innerType, opts)
8190
+ };
8191
+ },
8192
+ readonly: (def, opts) => ({
8193
+ ...s(def.innerType, opts, true),
8194
+ readonly: true
8195
+ })
8196
+ };
8197
+ function zerializeRefs(schema, opts, wrapReferences) {
8198
+ if (opts.seenObjects.has(schema)) {
8199
+ return wrapReferences ? {
8200
+ type: "union",
8201
+ options: [{ $ref: opts.seenObjects.get(schema) }],
8202
+ ...typeof schema.description === "string" ? {
8203
+ description: schema.description
8204
+ } : {}
8205
+ } : { $ref: opts.seenObjects.get(schema) };
7506
8206
  }
8207
+ const {
8208
+ _zod: { def }
8209
+ } = schema;
8210
+ const objectPath = "#" + (opts.currentPath.length ? "/" + opts.currentPath.join("/") : "");
8211
+ opts.seenObjects.set(schema, objectPath);
8212
+ const zer = zerializers[def.type](def, opts);
8213
+ if (typeof schema.description === "string") {
8214
+ zer.description = schema.description;
8215
+ }
8216
+ return zer;
7507
8217
  }
7508
- function createOperationSpec(spec) {
7509
- assertDocumentMatchesOperation(spec);
7510
- return spec;
8218
+ function zerialize(schema, opts = {}) {
8219
+ if (!opts.currentPath) {
8220
+ opts.currentPath = [];
8221
+ }
8222
+ if (!opts.seenObjects) {
8223
+ opts.seenObjects = /* @__PURE__ */ new WeakMap();
8224
+ }
8225
+ return zerializeRefs(schema, opts);
7511
8226
  }
7512
8227
 
7513
- // ../mcp-registry/src/operation-specs.ts
7514
- function stringOption({
7515
- description,
7516
- flagName,
7517
- inputKey,
7518
- required = false
7519
- }) {
7520
- return {
7521
- description,
7522
- flagName,
7523
- inputKey,
7524
- required,
7525
- valueType: "string"
7526
- };
8228
+ // ../common/dist/src/stdlib/object.util.js
8229
+ var import_es6 = __toESM(require_es6(), 1);
8230
+ function isDeepEqualAndSameType(a, b) {
8231
+ return (0, import_es6.default)(a, b);
7527
8232
  }
7528
- function numberOption({
7529
- description,
7530
- flagName,
7531
- inputKey,
7532
- required = false
7533
- }) {
7534
- return {
7535
- description,
7536
- flagName,
7537
- inputKey,
7538
- required,
7539
- valueType: "number"
7540
- };
8233
+
8234
+ // ../common/dist/src/stdlib/string.util.js
8235
+ var import_json_stringify_deterministic = __toESM(require_lib(), 1);
8236
+ import { z as z3 } from "zod";
8237
+ function brandString(value) {
8238
+ return value;
8239
+ }
8240
+ var entityMap = {
8241
+ /* eslint-disable @typescript-eslint/naming-convention */
8242
+ "&#x27;": "'",
8243
+ "&#39;": "'",
8244
+ "&quot;": '"',
8245
+ "&amp;": "&",
8246
+ "&lt;": "<",
8247
+ "&gt;": ">",
8248
+ "&nbsp;": " "
8249
+ /* eslint-enable @typescript-eslint/naming-convention */
8250
+ };
8251
+ var entityRegex = new RegExp(Object.keys(entityMap).join("|"), "gu");
8252
+
8253
+ // ../common/dist/src/utils/zod.util.js
8254
+ function brandedStringValidator(_brand) {
8255
+ return z4.string().transform((val) => brandString(val));
8256
+ }
8257
+ var emptySchema = zerialize(z4.object({}));
8258
+
8259
+ // ../common/dist/src/zod-schemas/model-config.schema.js
8260
+ var magicalBaseModels = [
8261
+ "gemini-2.5-flash",
8262
+ "gemini-3-pro-preview",
8263
+ "o3",
8264
+ "gpt-4o",
8265
+ "gpt-5-mini",
8266
+ "gpt-5.4"
8267
+ ];
8268
+ var DEFAULT_MODEL = "gemini-2.5-flash";
8269
+ var modelOptionsSchema = z5.object({
8270
+ reasoningEffort: z5.enum(["low", "medium", "high"]).optional().describe("Reasoning effort level for models that support it (e.g., o1, o3). Higher effort may produce better results but takes longer."),
8271
+ temperature: z5.number().min(0).max(2).optional().describe("Controls randomness in model output. 0 is deterministic, higher values (up to 2) increase creativity and randomness.")
8272
+ });
8273
+ var modelIdSchema = brandedStringValidator("modelId").or(z5.enum(magicalBaseModels));
8274
+ var baseModelConfigSchema = z5.object({
8275
+ id: modelIdSchema.default(DEFAULT_MODEL)
8276
+ }).extend(modelOptionsSchema.shape);
8277
+ var fallbackModelConfigSchema = z5.object({
8278
+ ...baseModelConfigSchema.shape,
8279
+ useAfterAttempt: z5.number().min(1).describe("Number of failed attempts with the primary model before switching to this fallback model.")
8280
+ }).describe("Configuration for a fallback model to use after primary failures.");
8281
+ var modelConfigSchema = z5.union([
8282
+ modelIdSchema.default(DEFAULT_MODEL),
8283
+ z5.object({
8284
+ ...baseModelConfigSchema.shape,
8285
+ fallbackModels: z5.array(fallbackModelConfigSchema).optional().describe("List of fallback models to try if the primary model fails. Models are tried in order based on useAfterAttempt.")
8286
+ }).describe("Full model configuration with options and fallbacks.")
8287
+ ]).describe("LLM model configuration. Can be a simple model ID string or an object with advanced options like temperature, reasoning effort, and fallback models.").transform((data) => {
8288
+ if (typeof data === "string") {
8289
+ return { id: data };
8290
+ }
8291
+ return data;
8292
+ });
8293
+ var agentSingleModelConfigSchema = z5.object({
8294
+ type: z5.literal("single-model"),
8295
+ ...baseModelConfigSchema.shape,
8296
+ fallbackModels: z5.array(fallbackModelConfigSchema).optional().describe("List of fallback models to try if the primary model fails. Models are tried in order based on useAfterAttempt.")
8297
+ }).describe("Agent model configuration for selecting a single model directly.");
8298
+ var agentModelPoolConfigSchema = z5.object({
8299
+ type: z5.literal("model-pool"),
8300
+ poolId: brandedStringValidator("resourcePoolId").describe("Resource pool ID containing candidate models. The highest-priority model is primary."),
8301
+ ...modelOptionsSchema.shape,
8302
+ fallbackModels: z5.array(fallbackModelConfigSchema).optional().describe("Optional explicit fallback list. If omitted, fallbacks are derived from remaining models in the pool by priority.")
8303
+ }).describe("Agent model configuration for selecting models from a resource pool.");
8304
+ var agentModelConfigSchema = z5.preprocess((data) => {
8305
+ if (typeof data === "string") {
8306
+ return {
8307
+ type: "single-model",
8308
+ id: data
8309
+ };
8310
+ }
8311
+ if (typeof data === "object" && data !== null && !("type" in data)) {
8312
+ return {
8313
+ type: "single-model",
8314
+ ...data
8315
+ };
8316
+ }
8317
+ return data;
8318
+ }, z5.discriminatedUnion("type", [
8319
+ agentSingleModelConfigSchema,
8320
+ agentModelPoolConfigSchema
8321
+ ])).default({
8322
+ type: "single-model",
8323
+ id: DEFAULT_MODEL
8324
+ }).describe("Agent LLM model configuration. Supports direct model selection (single-model) and model-pool selection with priority-based fallback behavior.");
8325
+
8326
+ // ../common/dist/src/zod-schemas/browser-provider-options.schema.js
8327
+ import { z as z6 } from "zod";
8328
+ var viewportSizeSchema = z6.object({
8329
+ width: z6.number().min(800).max(3840).describe("Viewport width in pixels. Must be between 800 and 3840."),
8330
+ height: z6.number().min(600).max(2160).describe("Viewport height in pixels. Must be between 600 and 2160.")
8331
+ }).describe("Viewport dimensions in pixels. A 16:9 aspect ratio is recommended for optimal LLM performance.");
8332
+ var BROWSER_DEFAULT_VIEWPORT = {
8333
+ width: 1366,
8334
+ height: 768
8335
+ };
8336
+ var browserProviderOptionsSchema = z6.object({
8337
+ browserbase: z6.object({
8338
+ advancedStealth: z6.boolean().default(false).optional().describe("Enable advanced stealth mode to better avoid bot detection."),
8339
+ contextId: z6.string().min(1).optional().describe("Browserbase context ID for session persistence across runs."),
8340
+ extensionId: z6.string().min(1).optional().describe("Browser extension ID to load in the session."),
8341
+ enablePdfViewer: z6.boolean().optional().describe("Display PDFs in the browser instead of auto-downloading them."),
8342
+ instanceSize: z6.enum(["small", "medium", "large"]).optional().describe("Browser instance size. Larger instances have more resources but cost more. Beta feature."),
8343
+ blockAds: z6.boolean().optional().describe("Block ads when rendering pages in the session."),
8344
+ solveCaptchas: z6.boolean().default(true).optional().describe("Automatically solve CAPTCHAs in the background when encountered."),
8345
+ viewport: viewportSizeSchema.optional()
8346
+ }).optional().describe("Configuration options specific to the Browserbase provider."),
8347
+ agentCore: z6.object({
8348
+ viewport: viewportSizeSchema.optional(),
8349
+ enableWebBotAuth: z6.boolean().default(false).optional().describe("Enable WebBot authentication flow.")
8350
+ }).optional().describe("Configuration options specific to the AgentCore provider."),
8351
+ local: z6.object({
8352
+ viewport: viewportSizeSchema.optional()
8353
+ }).optional().describe("Configuration options for local browser execution (development only)."),
8354
+ hyperbrowser: z6.object({
8355
+ solveCaptchas: z6.boolean().default(true).optional().describe("Automatically solve CAPTCHAs in the background when encountered."),
8356
+ viewport: viewportSizeSchema.optional()
8357
+ }).optional().describe("Configuration options specific to the Hyperbrowser provider."),
8358
+ steel: z6.object({
8359
+ extensionIds: z6.array(z6.string().min(1)).optional().describe("List of browser extension IDs to load in the session."),
8360
+ region: z6.enum(["iad", "ord", "lax"]).optional().describe("Steel data center region. Options: iad (Virginia), ord (Chicago), lax (Los Angeles)."),
8361
+ solveCaptcha: z6.boolean().default(true).optional().describe("Automatically solve CAPTCHAs when encountered."),
8362
+ viewport: viewportSizeSchema.optional()
8363
+ }).optional().describe("Configuration options specific to the Steel provider.")
8364
+ }).describe("Provider-specific browser configuration options. Only the options for the selected browserProvider are used.");
8365
+
8366
+ // ../../node_modules/uuid/dist-node/stringify.js
8367
+ var byteToHex = [];
8368
+ for (let i = 0; i < 256; ++i) {
8369
+ byteToHex.push((i + 256).toString(16).slice(1));
8370
+ }
8371
+ function unsafeStringify(arr, offset = 0) {
8372
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
8373
+ }
8374
+
8375
+ // ../../node_modules/uuid/dist-node/rng.js
8376
+ var rnds8 = new Uint8Array(16);
8377
+ function rng() {
8378
+ return crypto.getRandomValues(rnds8);
8379
+ }
8380
+
8381
+ // ../../node_modules/uuid/dist-node/v4.js
8382
+ function v4(options, buf, offset) {
8383
+ if (!buf && !options && crypto.randomUUID) {
8384
+ return crypto.randomUUID();
8385
+ }
8386
+ return _v4(options, buf, offset);
8387
+ }
8388
+ function _v4(options, buf, offset) {
8389
+ options = options || {};
8390
+ const rnds = options.random ?? options.rng?.() ?? rng();
8391
+ if (rnds.length < 16) {
8392
+ throw new Error("Random bytes length must be >= 16");
8393
+ }
8394
+ rnds[6] = rnds[6] & 15 | 64;
8395
+ rnds[8] = rnds[8] & 63 | 128;
8396
+ if (buf) {
8397
+ offset = offset || 0;
8398
+ if (offset < 0 || offset + 16 > buf.length) {
8399
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
8400
+ }
8401
+ for (let i = 0; i < 16; ++i) {
8402
+ buf[offset + i] = rnds[i];
8403
+ }
8404
+ return buf;
8405
+ }
8406
+ return unsafeStringify(rnds);
8407
+ }
8408
+ var v4_default = v4;
8409
+
8410
+ // ../common/dist/src/stdlib/uuid.utils.js
8411
+ function uuidV4Branded() {
8412
+ return v4_default();
8413
+ }
8414
+
8415
+ // ../common/dist/src/stdlib/url.utils.js
8416
+ var import_handlebars = __toESM(require_lib2(), 1);
8417
+ var HANDLEBARS_TEMPLATE_REGEX = /\{\{\{?[\s\S]*?\}\}\}?/u;
8418
+ var HANDLEBARS_TEMPLATE_GLOBAL_REGEX = /\{\{\{?[\s\S]*?\}\}\}?/gu;
8419
+ var LEADING_HANDLEBARS_TEMPLATE_REGEX = /^(?:\{\{\{?[\s\S]*?\}\}\}?)/u;
8420
+ var URL_TEMPLATE_PLACEHOLDER_VALUE = "handlebars-template-value";
8421
+ var LEADING_URL_TEMPLATE_PLACEHOLDER_VALUE = "https://handlebars-template.example";
8422
+ function safeUrlConstructor(url, baseUrl) {
8423
+ try {
8424
+ return Ok(baseUrl ? new URL(url, baseUrl) : new URL(url));
8425
+ } catch {
8426
+ return Err({
8427
+ type: "invalid-url",
8428
+ message: `Invalid URL`,
8429
+ url
8430
+ });
8431
+ }
8432
+ }
8433
+ function isValidUrl(url) {
8434
+ try {
8435
+ new URL(url);
8436
+ return true;
8437
+ } catch {
8438
+ return false;
8439
+ }
8440
+ }
8441
+ function isHandlebarsTemplateString(value) {
8442
+ return HANDLEBARS_TEMPLATE_REGEX.test(value);
8443
+ }
8444
+ function isValidHandlebarsTemplateString(template) {
8445
+ try {
8446
+ import_handlebars.default.parse(template);
8447
+ return true;
8448
+ } catch {
8449
+ return false;
8450
+ }
8451
+ }
8452
+ function isValidUrlOrHandlebarsTemplateString(value) {
8453
+ if (!isHandlebarsTemplateString(value)) {
8454
+ return isValidUrl(value);
8455
+ }
8456
+ if (!isValidHandlebarsTemplateString(value)) {
8457
+ return false;
8458
+ }
8459
+ if (isValidUrl(replaceHandlebarsTemplates(value))) {
8460
+ return true;
8461
+ }
8462
+ const leadingHandlebarsTemplate = getLeadingHandlebarsTemplate(value);
8463
+ if (!leadingHandlebarsTemplate) {
8464
+ return false;
8465
+ }
8466
+ return isValidUrl(replaceHandlebarsTemplates(value.replace(leadingHandlebarsTemplate, LEADING_URL_TEMPLATE_PLACEHOLDER_VALUE)));
8467
+ }
8468
+ function getLeadingHandlebarsTemplate(value) {
8469
+ const leadingHandlebarsTemplate = LEADING_HANDLEBARS_TEMPLATE_REGEX.exec(value)?.[0];
8470
+ if (!leadingHandlebarsTemplate) {
8471
+ return void 0;
8472
+ }
8473
+ return leadingHandlebarsTemplate;
8474
+ }
8475
+ function replaceHandlebarsTemplates(value) {
8476
+ return value.replaceAll(HANDLEBARS_TEMPLATE_GLOBAL_REGEX, URL_TEMPLATE_PLACEHOLDER_VALUE);
8477
+ }
8478
+
8479
+ // ../common/dist/src/stdlib/state-machine.util.js
8480
+ var StateMachine = class {
8481
+ states;
8482
+ forwardTransitions;
8483
+ reverseTransitions;
8484
+ constructor({ states, transitions }) {
8485
+ this.states = Object.freeze([...states]);
8486
+ const forward = {};
8487
+ for (const state of this.states) {
8488
+ const toStates = transitions[state] ?? [];
8489
+ const deduped = dedupePreservingOrder(toStates);
8490
+ forward[state] = Object.freeze(deduped);
8491
+ }
8492
+ this.forwardTransitions = Object.freeze(forward);
8493
+ const reverse = {};
8494
+ for (const s2 of this.states) {
8495
+ const sources = this.states.filter((src) => this.forwardTransitions[src].includes(s2));
8496
+ reverse[s2] = Object.freeze(sources);
8497
+ }
8498
+ this.reverseTransitions = Object.freeze(reverse);
8499
+ }
8500
+ /** Returns the full set of states registered in this machine. */
8501
+ getAllStates() {
8502
+ return this.states;
8503
+ }
8504
+ /** Returns the allowed target states for a given source state. */
8505
+ getAllowedTargets(from) {
8506
+ return this.forwardTransitions[from];
8507
+ }
8508
+ /** Returns the allowed source states for a given target state. */
8509
+ getAllowedSources(to) {
8510
+ return this.reverseTransitions[to];
8511
+ }
8512
+ /** Checks if a transition from `from` to `to` is allowed. */
8513
+ isTransitionAllowed(from, to) {
8514
+ return this.forwardTransitions[from].includes(to);
8515
+ }
8516
+ };
8517
+ function dedupePreservingOrder(values) {
8518
+ const seen = /* @__PURE__ */ new Set();
8519
+ const result = [];
8520
+ for (const v of values) {
8521
+ if (!seen.has(v)) {
8522
+ seen.add(v);
8523
+ result.push(v);
8524
+ }
8525
+ }
8526
+ return result;
8527
+ }
8528
+
8529
+ // ../common/dist/src/models/websocket/actions/scroll.js
8530
+ import { z as z7 } from "zod";
8531
+ var scrollDataSchema = z7.object({
8532
+ direction: z7.enum(["UP", "DOWN", "LEFT", "RIGHT"]),
8533
+ length: z7.number().min(1).describe("The number of pixels to scroll by. Must be positive and at least 1.")
8534
+ });
8535
+ var ScrollEvent;
8536
+ (function(ScrollEvent2) {
8537
+ let Request;
8538
+ (function(Request2) {
8539
+ function create({ direction, length, agentId, sessionId }) {
8540
+ return {
8541
+ id: uuidV4Branded(),
8542
+ agentId,
8543
+ sessionId,
8544
+ type: "scroll",
8545
+ direction: "request",
8546
+ data: {
8547
+ direction,
8548
+ length
8549
+ }
8550
+ };
8551
+ }
8552
+ Request2.create = create;
8553
+ })(Request = ScrollEvent2.Request || (ScrollEvent2.Request = {}));
8554
+ let Response;
8555
+ (function(Response2) {
8556
+ function create({ id, agentId, sessionId, response }) {
8557
+ return {
8558
+ id,
8559
+ agentId,
8560
+ sessionId,
8561
+ direction: "response",
8562
+ type: "scroll-response",
8563
+ response
8564
+ };
8565
+ }
8566
+ Response2.create = create;
8567
+ })(Response = ScrollEvent2.Response || (ScrollEvent2.Response = {}));
8568
+ })(ScrollEvent || (ScrollEvent = {}));
8569
+
8570
+ // ../common/dist/src/models/websocket/actions/press.js
8571
+ import { z as z8 } from "zod";
8572
+ var PressEvent;
8573
+ (function(PressEvent2) {
8574
+ let Request;
8575
+ (function(Request2) {
8576
+ function create({ keys, sessionId, agentId }) {
8577
+ return {
8578
+ id: uuidV4Branded(),
8579
+ agentId,
8580
+ sessionId,
8581
+ type: "press",
8582
+ direction: "request",
8583
+ data: {
8584
+ keys
8585
+ }
8586
+ };
8587
+ }
8588
+ Request2.create = create;
8589
+ })(Request = PressEvent2.Request || (PressEvent2.Request = {}));
8590
+ let Response;
8591
+ (function(Response2) {
8592
+ function create({ id, agentId, sessionId, response }) {
8593
+ return {
8594
+ id,
8595
+ agentId,
8596
+ sessionId,
8597
+ direction: "response",
8598
+ type: "press-response",
8599
+ response
8600
+ };
8601
+ }
8602
+ Response2.create = create;
8603
+ })(Response = PressEvent2.Response || (PressEvent2.Response = {}));
8604
+ })(PressEvent || (PressEvent = {}));
8605
+ var Keys = [
8606
+ // Modifiers
8607
+ "Alt",
8608
+ "CapsLock",
8609
+ "Control",
8610
+ "Fn",
8611
+ "Shift",
8612
+ "Meta",
8613
+ // Whitespace keys
8614
+ "Enter",
8615
+ "Tab",
8616
+ "Space",
8617
+ // Navigation keys
8618
+ "ArrowUp",
8619
+ "ArrowDown",
8620
+ "ArrowLeft",
8621
+ "ArrowRight",
8622
+ "Home",
8623
+ "End",
8624
+ "PageUp",
8625
+ "PageDown",
8626
+ // Editing keys
8627
+ "Backspace",
8628
+ "Delete",
8629
+ // UI keys
8630
+ "Escape",
8631
+ "Pause",
8632
+ "Play",
8633
+ // Function keys
8634
+ "F1",
8635
+ "F2",
8636
+ "F3",
8637
+ "F4",
8638
+ "F5",
8639
+ "F6",
8640
+ "F7",
8641
+ "F8",
8642
+ "F9",
8643
+ "F10",
8644
+ "F11",
8645
+ "F12",
8646
+ "F13",
8647
+ "F14",
8648
+ "F15",
8649
+ "F16",
8650
+ "F17",
8651
+ "F18",
8652
+ "F19",
8653
+ "F20",
8654
+ // Alphanumerics (case-sensitive)
8655
+ "A",
8656
+ "a",
8657
+ "B",
8658
+ "b",
8659
+ "C",
8660
+ "c",
8661
+ "D",
8662
+ "d",
8663
+ "E",
8664
+ "e",
8665
+ "F",
8666
+ "f",
8667
+ "G",
8668
+ "g",
8669
+ "H",
8670
+ "h",
8671
+ "I",
8672
+ "i",
8673
+ "J",
8674
+ "j",
8675
+ "K",
8676
+ "k",
8677
+ "L",
8678
+ "l",
8679
+ "M",
8680
+ "m",
8681
+ "N",
8682
+ "n",
8683
+ "O",
8684
+ "o",
8685
+ "P",
8686
+ "p",
8687
+ "Q",
8688
+ "q",
8689
+ "R",
8690
+ "r",
8691
+ "S",
8692
+ "s",
8693
+ "T",
8694
+ "t",
8695
+ "U",
8696
+ "u",
8697
+ "V",
8698
+ "v",
8699
+ "W",
8700
+ "w",
8701
+ "X",
8702
+ "x",
8703
+ "Y",
8704
+ "y",
8705
+ "Z",
8706
+ "z",
8707
+ "0",
8708
+ "1",
8709
+ "2",
8710
+ "3",
8711
+ "4",
8712
+ "5",
8713
+ "6",
8714
+ "7",
8715
+ "8",
8716
+ "9",
8717
+ // Punctuation
8718
+ "Minus",
8719
+ "Equal",
8720
+ "BracketLeft",
8721
+ "BracketRight",
8722
+ "Backslash",
8723
+ "Semicolon",
8724
+ "Quote",
8725
+ "Comma",
8726
+ "Period",
8727
+ "Slash",
8728
+ "Backquote",
8729
+ // System keys
8730
+ "Insert",
8731
+ "PrintScreen"
8732
+ ];
8733
+ var pressDataSchema = z8.object({
8734
+ keys: z8.array(z8.enum(Keys))
8735
+ });
8736
+
8737
+ // ../common/dist/src/models/websocket/actions/report-stop.js
8738
+ import { z as z9 } from "zod";
8739
+ var reportStopDataSchema = z9.object({
8740
+ status: z9.enum(["success", "fail"]).describe("Whether the instructions were completed successfully or not"),
8741
+ output: z9.string().optional().describe('Put the user-requested result content here when asked to return it with reportStop. This is for unstructured results only; do not include statuses ("success", "fail") and do not place results in metadata.reasoning. If the user did not request return content, omit this field.')
8742
+ });
8743
+
8744
+ // ../common/dist/src/constants/tool-declarations.js
8745
+ var COMMON_PARAMETERS_KEY = "metadata";
8746
+ var COMMON_PARAMETERS_DESCRIPTION = `REQUIRED metadata object that must be provided with every tool call. This object contains context and tracking information that helps monitor agent progress and decision-making. MUST be provided as a JSON object (not a string) under the 'metadata' parameter for all tool calls.`;
8747
+ var DEFAULT_COMMON_PARAMETERS = z10.object({
8748
+ reasoning: z10.string().describe("Explain clearly why this tool is being used at this point. Include the goal it helps achieve and the context behind the decision."),
8749
+ step: z10.coerce.string().regex(/^[\dA-Za-z]+(?:\.[\dA-Za-z]+)*$/u, {
8750
+ message: 'Step must follow the format of numbers separated by periods (e.g., "1", "1.2", "2.3.1")'
8751
+ }).describe(String.raw`Indicate the exact step in the process where this tool is being used. MUST use a hierarchical numbering format like "1", "1.2", or "2.3.1" to reflect the structure of the workflow. MUST match this regex: /^[\dA-Za-z]+(?:\.[\dA-Za-z]+)*$/u`),
8752
+ isRetry: z10.boolean().default(false).describe("Indicates whether this tool call is a retry of the previous step.")
8753
+ }).describe(COMMON_PARAMETERS_DESCRIPTION);
8754
+ var scrollToTextPositionEnum = z10.enum(["start", "center", "end"]);
8755
+ var agentToolSchema = z10.object({
8756
+ agentId: z10.string(),
8757
+ args: z10.unknown().optional()
8758
+ });
8759
+ var baseToolDeclarations = {
8760
+ clickFill: {
8761
+ id: "clickFill",
8762
+ description: 'ONLY USE FOR TEXT INPUT FIELDS. This tool combines two actions: (1) clicking on a form input field and (2) typing text into it. NEVER use this for buttons, links, checkboxes, radio buttons, or any non-input elements. ONLY use when you need to enter text into a field. If you only want to click something without entering text, use "click" instead.',
8763
+ parameters: z10.object({
8764
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8765
+ marker: markerSchema("The marker of the input field to fill."),
8766
+ text: z10.string().describe("The text to fill the marker with")
8767
+ })
8768
+ },
8769
+ click: {
8770
+ id: "click",
8771
+ description: 'ONLY USE FOR CLICKING WITHOUT ENTERING TEXT. This tool clicks on an element but DOES NOT allow entering text. Use for buttons, links, checkboxes, dropdown toggles, tabs, and other clickable elements. NEVER use this when you need to enter text into a field - for text entry, use "clickFill" instead, this tool automatically moves the cursor to the element, no need to use the move tool first.',
8772
+ parameters: z10.object({
8773
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8774
+ marker: markerSchema("The marker of the element to click."),
8775
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).describe("The type of click to perform")
8776
+ })
8777
+ },
8778
+ multiClick: {
8779
+ id: "multiClick",
8780
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
8781
+ parameters: z10.object({
8782
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8783
+ markers: z10.array(markerSchema("The marker of the element to click.")).min(1)
8784
+ })
8785
+ },
8786
+ clickAndConfirm: {
8787
+ id: "clickAndConfirm",
8788
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
8789
+ parameters: z10.object({
8790
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8791
+ marker: markerSchema("The marker of the element to click."),
8792
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).describe("The type of click to perform"),
8793
+ promptMessage: z10.string().min(1).describe("The prompt message to respond to.")
8794
+ })
8795
+ },
8796
+ copy: {
8797
+ id: "copy",
8798
+ description: "Copy given text to the clipboard.",
8799
+ parameters: z10.object({
8800
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8801
+ text: z10.string().describe("The text to copy to the clipboard.")
8802
+ })
8803
+ },
8804
+ downloadFile: {
8805
+ id: "downloadFile",
8806
+ description: "Download a file in the browser by clicking on something",
8807
+ parameters: z10.object({
8808
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8809
+ marker: markerSchema("The marker to click on the page to initiate the download"),
8810
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).describe("The type of click to perform")
8811
+ })
8812
+ },
8813
+ downloadNextDocumentRequest: {
8814
+ id: "downloadNextDocumentRequest",
8815
+ description: "Download file types that a browser doesn't automatically download (like images) by specifying the file extension and either clicking a marker or navigating to a URL. Must provide either marker or URL parameter.",
8816
+ parameters: z10.object({
8817
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8818
+ marker: markerSchema("The marker of the element that triggers the new page").optional(),
8819
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).optional().describe("The type of click to perform"),
8820
+ url: z10.url().optional().describe("The url to navigate to that triggers the new page"),
8821
+ extension: z10.string().describe("The extension of the downloaded document")
8822
+ })
8823
+ },
8824
+ downloadNextNetworkRequest: {
8825
+ id: "downloadNextNetworkRequest",
8826
+ description: "Download the next network request by listening for a specific content type and resource type",
8827
+ parameters: z10.object({
8828
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8829
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).describe("The type of click to perform"),
8830
+ extension: z10.string().describe("The extension of the downloaded document"),
8831
+ contentType: z10.string().describe("The content type of the network request"),
8832
+ // The actual tool is using an enum for the resourceType
8833
+ resourceType: z10.string().describe("The resource type of the network request"),
8834
+ urlPattern: z10.string().min(1).optional().describe("An optional regular expression pattern to match against the request URL")
8835
+ })
8836
+ },
8837
+ printToPDF: {
8838
+ id: "printToPDF",
8839
+ description: "Print the current page to a PDF file",
8840
+ parameters: z10.object({
8841
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
8842
+ })
8843
+ },
8844
+ printFrameToPDF: {
8845
+ id: "printFrameToPDF",
8846
+ description: "Print the selected frame to a PDF file",
8847
+ parameters: z10.object({
8848
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8849
+ frameSelector: z10.string().describe("The selector of the frame to print")
8850
+ })
8851
+ },
8852
+ printFocusedFrameToPDF: {
8853
+ id: "printFocusedFrameToPDF",
8854
+ description: "Print the focused frame to a PDF file",
8855
+ parameters: z10.object({
8856
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
8857
+ })
8858
+ },
8859
+ capturePrintOutput: {
8860
+ id: "capturePrintOutput",
8861
+ description: "Capture the next printed content triggered by clicking an element, then save it as a PDF",
8862
+ parameters: z10.object({
8863
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8864
+ marker: markerSchema("The marker of the element that triggers the print request"),
8865
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).optional().describe("The type of click to perform")
8866
+ })
8867
+ },
8868
+ drag: {
8869
+ id: "drag",
8870
+ description: 'Perform a drag-and-drop operation by clicking at the "from" position, holding the mouse button down, and moving to the "to" position before releasing. Use this for dragging elements, sliders, or selecting text. If "from" is not provided, it will start from the current cursor position.',
8871
+ parameters: z10.object({
8872
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8873
+ from: markerSchema("The marker to drag from").optional(),
8874
+ to: markerSchema("The marker to drag to")
8875
+ })
8876
+ },
8877
+ extractInfoFromFile: {
8878
+ id: "extractInfoFromFile",
8879
+ description: "Extract information from a previously downloaded file using specific prompts. Provide the file URL using `s3://{key}` and clearly defined extraction instructions.",
8880
+ parameters: z10.object({
8881
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8882
+ filePath: z10.string().describe("The URI to the file, starting with s3://"),
8883
+ extractions: z10.array(z10.object({
8884
+ name: z10.string().describe("The name of the extraction"),
8885
+ prompt: z10.string().describe("Instructions on how to find")
8886
+ }))
8887
+ })
8888
+ },
8889
+ getDropdownOptions: {
8890
+ id: "getDropdownOptions",
8891
+ description: "Get dropdown option labels of a `<select>` dropdown element",
8892
+ parameters: z10.object({
8893
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8894
+ marker: markerSchema("The marker of the `<select>` dropdown to get option labels from")
8895
+ })
8896
+ },
8897
+ /**
8898
+ * Playwright will lose track of this position between workflow activities because we create a
8899
+ * new Playwright client each time. The webpage will still think the cursor is at the previous
8900
+ * location but some Playwright methods rely on its own cached last position which will be reset
8901
+ * to 0,0. See AGT-658 for details.
8902
+ */
8903
+ move: {
8904
+ id: "move",
8905
+ description: `Simply move the cursor to a marker location without clicking. Only use this when you need to position the cursor without performing any action, e.g. to make something appear upon hovering. For most interactions, use click or clickFill which already include cursor movement. Don't use this before "scroll", instead provide a marker to "scroll" that indicates the position to scroll from.`,
8906
+ parameters: z10.object({
8907
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8908
+ marker: markerSchema("The marker to move the mouse to")
8909
+ })
8910
+ },
8911
+ paste: {
8912
+ id: "paste",
8913
+ description: "Paste text from the clipboard.",
8914
+ parameters: z10.object({
8915
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
8916
+ })
8917
+ },
8918
+ pressKeys: {
8919
+ id: "pressKeys",
8920
+ description: "Press given keys",
8921
+ parameters: z10.object({
8922
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8923
+ ...pressDataSchema.shape
8924
+ })
8925
+ },
8926
+ reportStop: {
8927
+ id: "reportStop",
8928
+ description: "Report that you have stopped either because you have succeeded in completing all your assigned tasks, or because you were told to do so. If the user asks to return something with it, put it in output (unstructured). Omit output if there is no extra info to return.",
8929
+ parameters: z10.object({
8930
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8931
+ ...reportStopDataSchema.shape
8932
+ })
8933
+ },
8934
+ scroll: {
8935
+ id: "scroll",
8936
+ description: "Scroll the page in a specified direction by a defined amount at the specified location. Useful for navigating to content that is out of view",
8937
+ parameters: z10.object({
8938
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8939
+ ...scrollDataSchema.shape,
8940
+ // The previous mouse/cursor position is lost between workflow activities because we create a
8941
+ // new Playwright client each time. See AGT-658 for details.
8942
+ marker: z10.union([
8943
+ markerSchema("The marker to move the cursor to before scrolling. This mark should usually have a scroll-distance-* attribute indicating the maximum distance that can be scrolled in a given direction."),
8944
+ z10.enum(["body"]).describe('Specify the string "body" to scroll the top frame if there is no relevant marker.')
8945
+ ])
8946
+ })
8947
+ },
8948
+ scrollToText: {
8949
+ id: "scrollToText",
8950
+ description: "Scroll the page until the specified text string is visible. Use when you need to locate and bring a certain piece of visible text into view.",
8951
+ parameters: z10.object({
8952
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8953
+ text: z10.string().describe("The text to find and scroll to"),
8954
+ scrollPosition: scrollToTextPositionEnum.optional().describe("The position the text should be relative to its scrollable container."),
8955
+ instance: z10.number().int().min(1).default(1).describe("If there are multiple matching elements, indicate which occurrence the agent should be scrolled to.")
8956
+ })
8957
+ },
8958
+ scrollToPattern: {
8959
+ id: "scrollToPattern",
8960
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
8961
+ parameters: z10.object({
8962
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8963
+ pattern: z10.string().min(1).describe("The regular expression to match."),
8964
+ flags: z10.string().regex(/^[dgimsuvy]*$/u, {
8965
+ message: "Flags can only contain valid RegExp flag characters: d, g, i, m, s, u, v, y"
8966
+ }).describe('The flags to use for the regular expression. Defaults to "iu" if not specified.').default("iu"),
8967
+ scrollPosition: scrollToTextPositionEnum.optional().describe("The position the text should be relative to its scrollable container."),
8968
+ instance: z10.number().int().min(1).default(1).describe("If there are multiple matching elements, indicate which occurrence the agent should be scrolled to.")
8969
+ })
8970
+ },
8971
+ selectDropdownOptions: {
8972
+ id: "selectDropdownOptions",
8973
+ description: "Select dropdown options with the given label text, replacing existing selections.",
8974
+ parameters: z10.object({
8975
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8976
+ marker: markerSchema("The marker of the `<select>` dropdown to change"),
8977
+ labels: z10.array(z10.string().describe("The label text of the dropdown option to select"))
8978
+ })
8979
+ },
8980
+ type: {
8981
+ id: "type",
8982
+ description: "Type in the currently focused element with the given text",
8983
+ parameters: z10.object({
8984
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8985
+ text: z10.string().describe("The text to type")
8986
+ })
8987
+ },
8988
+ getNDCFromMedication: {
8989
+ id: "getNDCFromMedication",
8990
+ description: "Extract the National Drug Code (NDC) for a medication by providing detailed medication information including name, route of administration (roa), supply, quantity, and strength. Returns the standardized NDC identifier.",
8991
+ parameters: z10.object({
8992
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8993
+ roa: z10.string().describe("The route of administration of the medication"),
8994
+ name: z10.string().describe("The name of the medication"),
8995
+ supply: z10.string().describe("The supply of the medication"),
8996
+ quantity: z10.string().describe("The quantity of the medication"),
8997
+ strength: z10.string().describe("The strength of the medication")
8998
+ })
8999
+ },
9000
+ navigateTo: {
9001
+ id: "navigateTo",
9002
+ description: "Navigate the browser to the specified URL. Use this when explicitly instructed to navigate to a URL.",
9003
+ parameters: z10.object({
9004
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9005
+ url: z10.url().describe("The URL to navigate to")
9006
+ })
9007
+ },
9008
+ navigateToLinkFromNewTab: {
9009
+ id: "navigateToLinkFromNewTab",
9010
+ description: "When clicking a link would open content in a new tab, this tool captures the destination URL and loads it in the current tab instead. Useful for links with target='_blank' or JavaScript-triggered new windows.",
9011
+ parameters: z10.object({
9012
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9013
+ marker: markerSchema("The item to click on which opens in a new tab.")
9014
+ })
9015
+ },
9016
+ listTabs: {
9017
+ id: "listTabs",
9018
+ description: "List all open tabs in the browser session, including each tab ID, URL, and whether it is active.",
9019
+ parameters: z10.object({
9020
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9021
+ })
9022
+ },
9023
+ openNewTab: {
9024
+ id: "openNewTab",
9025
+ description: "Open a new browser tab, navigate it to the provided URL, and switch the active tab to it.",
9026
+ parameters: z10.object({
9027
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9028
+ url: z10.url().describe("The URL to open in a new tab and navigate to.")
9029
+ })
9030
+ },
9031
+ switchToTab: {
9032
+ id: "switchToTab",
9033
+ description: "Switch the active browser tab to the tab ID returned by listTabs.",
9034
+ parameters: z10.object({
9035
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9036
+ tabId: z10.string().min(1).describe("The ID of the tab to activate.")
9037
+ })
9038
+ },
9039
+ closeTabs: {
9040
+ id: "closeTabs",
9041
+ description: "Close one or more tabs by ID. At least one tab must remain open after closing.",
9042
+ parameters: z10.object({
9043
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9044
+ tabIds: z10.array(z10.string().min(1)).min(1).describe("A list of tab IDs to close.")
9045
+ })
9046
+ },
9047
+ uploadFile: {
9048
+ id: "uploadFile",
9049
+ description: "Upload a file to a file input element in the browser. The filePath must be an S3 URI like s3://{key}",
9050
+ parameters: z10.object({
9051
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9052
+ filePath: z10.string().describe("The URI to the file to upload like s3://{key}, it should be a valid URI to a file"),
9053
+ marker: markerSchema("The marker of the element to upload the file to")
9054
+ })
9055
+ },
9056
+ uploadScreenshot: {
9057
+ id: "uploadScreenshot",
9058
+ description: "Take a screenshot of the current view, optionally target a marked element or crop it to a bounding box, upload it to storage, and return a reference to the uploaded screenshot.",
9059
+ parameters: z10.object({
9060
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9061
+ filename: z10.string().regex(/^[\w-]+$/u, "Filename can only contain letters, numbers, underscores, and hyphens").optional().describe("Optional custom filename for the screenshot. If not provided, a unique filename will be generated."),
9062
+ marker: markerSchema("Optional marker of the element to capture instead of the full screenshot.").optional(),
9063
+ boundingBox: z10.object({
9064
+ x: z10.number().int().min(0).describe("The left edge of the bounding box in screenshot coordinates."),
9065
+ y: z10.number().int().min(0).describe("The top edge of the bounding box in screenshot coordinates."),
9066
+ width: z10.number().int().positive().describe("The width of the bounding box in screenshot pixels."),
9067
+ height: z10.number().int().positive().describe("The height of the bounding box in screenshot pixels.")
9068
+ }).optional().describe("Optional bounding box in screenshot coordinates for capturing only part of the current screenshot.")
9069
+ })
9070
+ },
9071
+ wait: {
9072
+ id: "wait",
9073
+ description: "Wait the specified number of seconds before proceeding to the next action. Use when pages, elements, or processes need time to load or complete. No network idle check is performed after this tool.",
9074
+ parameters: z10.object({
9075
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9076
+ seconds: z10.number().min(1).describe("The number of seconds to wait (must be at least 1)")
9077
+ })
9078
+ },
9079
+ notepad: {
9080
+ id: "notepad",
9081
+ description: "Append information to the session's persistent notepad. Each call adds to the end and does not overwrite existing notes. Notes persist between tool calls and can be accessed throughout the entire session.",
9082
+ parameters: z10.object({
9083
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9084
+ text: z10.string().describe("The text to write to the notepad")
9085
+ })
9086
+ },
9087
+ setCheckpointId: {
9088
+ id: "setCheckpointId",
9089
+ description: "Set a context identifier for this agent run that labels all checkpoints within it. This allows filtering and grouping checkpoints by meaningful identifiers like patient ID, email, order number, etc. All iterations marked as checkpoints in this agent run will be associated with this identifier.",
9090
+ parameters: z10.object({
9091
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9092
+ name: z10.string().describe('The identifier name/type (e.g., "patientId", "email", "orderId")'),
9093
+ value: z10.string().describe('The identifier value (e.g., "12345", "user@example.com", "ORD-789")')
9094
+ })
9095
+ },
9096
+ checkpoint: {
9097
+ id: "checkpoint",
9098
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9099
+ parameters: z10.object({
9100
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9101
+ })
9102
+ },
9103
+ requestHumanIntervention: {
9104
+ id: "requestHumanIntervention",
9105
+ description: "Request intervention from a human. This tool should only be used when you are stuck and need to ask a human for help.",
9106
+ parameters: z10.object({
9107
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9108
+ pauseReason: z10.enum(["UNEXPECTED_BLOCKER", "HUMAN_INPUT_EXPLICITLY_REQUESTED"]).describe("The reason for requesting human intervention. Use UNEXPECTED_BLOCKER when encountering unexpected issues that prevent progress, or HUMAN_INPUT_EXPLICITLY_REQUESTED when pausing was requested in the instructions."),
9109
+ message: z10.string().describe("The message to send to the human. This should be a clear and concise message that describes the problem you are facing.")
9110
+ })
9111
+ },
9112
+ /**
9113
+ * Should only be used in cases where markers are not being chosen correctly.
9114
+ * Updating the system and user prompts should be the first resort.
9115
+ */
9116
+ somFilter: {
9117
+ id: "somFilter",
9118
+ description: "IMPORTANT: DO NOT USE THIS TOOL. You are only allowed to use this tool if user specifically asks you to use it.",
9119
+ parameters: z10.object({
9120
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9121
+ includeMarks: z10.object({
9122
+ tagNames: z10.array(z10.string()),
9123
+ additionalLegendAttributes: z10.array(z10.string()).optional()
9124
+ }).describe("The marker tagNames to include").optional(),
9125
+ excludeMarks: z10.object({
9126
+ tagNames: z10.array(z10.string())
9127
+ }).describe("The marker tagNames to exclude").optional(),
9128
+ clearFilters: z10.boolean().default(false).describe("Whether to clear current som filter")
9129
+ })
9130
+ },
9131
+ fillCredential: {
9132
+ id: "fillCredential",
9133
+ description: "Enter a saved credential (e.g., username, password, or code) into the specified input field marked by a given marker. **You are only allowed to use this tool if user specifically asks you to use it.**",
9134
+ parameters: z10.object({
9135
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9136
+ marker: markerSchema("The marker to fill the credential into"),
9137
+ credential: z10.object({
9138
+ id: z10.string(),
9139
+ type: z10.enum([
9140
+ "email",
9141
+ "username",
9142
+ "password",
9143
+ "authenticatorCode",
9144
+ "phoneAuthenticatorCode"
9145
+ ]),
9146
+ args: z10.record(z10.string(), z10.unknown())
9147
+ })
9148
+ })
9149
+ },
9150
+ readRemoteFile: {
9151
+ id: "readRemoteFile",
9152
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9153
+ parameters: z10.object({
9154
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9155
+ })
9156
+ },
9157
+ listRemoteFiles: {
9158
+ id: "listRemoteFiles",
9159
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9160
+ parameters: z10.object({
9161
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9162
+ })
9163
+ },
9164
+ writeRemoteFile: {
9165
+ id: "writeRemoteFile",
9166
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9167
+ parameters: z10.object({
9168
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9169
+ })
9170
+ },
9171
+ writeRemoteFileFromStorage: {
9172
+ id: "writeRemoteFileFromStorage",
9173
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9174
+ parameters: z10.object({
9175
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9176
+ })
9177
+ },
9178
+ reloadPage: {
9179
+ id: "experimental_reloadPage",
9180
+ description: "Reload the current page.",
9181
+ parameters: z10.object({
9182
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9183
+ })
9184
+ },
9185
+ navigateBack: {
9186
+ id: "navigateBack",
9187
+ description: "Navigate the browser to the previous page in the history.",
9188
+ parameters: z10.object({
9189
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9190
+ })
9191
+ },
9192
+ getCurrentUrl: {
9193
+ id: "getCurrentUrl",
9194
+ description: "Get the current URL of the web page. Returns the full URL including protocol, domain, path, and query parameters.",
9195
+ parameters: z10.object({
9196
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9197
+ })
9198
+ },
9199
+ getSelectedText: {
9200
+ id: "getSelectedText",
9201
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9202
+ parameters: z10.object({
9203
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9204
+ })
9205
+ },
9206
+ notify: {
9207
+ id: "notify",
9208
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9209
+ parameters: z10.object({
9210
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9211
+ })
9212
+ },
9213
+ readDownloadedFile: {
9214
+ id: "readDownloadedFile",
9215
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9216
+ parameters: z10.object({
9217
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9218
+ })
9219
+ },
9220
+ fillCredentialsAndSubmit: {
9221
+ id: "fillCredentialsAndSubmit",
9222
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9223
+ parameters: z10.object({
9224
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9225
+ })
9226
+ },
9227
+ callSpecializedAgent: {
9228
+ id: "callSpecializedAgent",
9229
+ description: "Call a specialized agent to complete a task.",
9230
+ parameters: z10.object({
9231
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9232
+ agent: agentToolSchema
9233
+ })
9234
+ },
9235
+ queueAgents: {
9236
+ id: "queueAgents",
9237
+ description: "ONLY USE THIS IF EXPLICITLY MENTIONED IN THE INSTRUCTIONS. Queue a list of agents. When waitUponQueueing is true, this waits for every queued workflow in the call and returns their outputs.",
9238
+ parameters: z10.object({
9239
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9240
+ idempotencyKey: z10.string().optional(),
9241
+ waitUponQueueing: z10.boolean().optional().describe("Applies to every queued agent in this call. If true, wait for all queued workflows to finish and return their outputs before continuing."),
9242
+ queueItems: z10.array(agentToolSchema)
9243
+ })
9244
+ },
9245
+ callAPI: {
9246
+ id: "callAPI",
9247
+ description: "Call an API to complete a task.",
9248
+ parameters: z10.object({
9249
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9250
+ api: z10.unknown()
9251
+ })
9252
+ },
9253
+ generateObject: {
9254
+ id: "generateObject",
9255
+ description: "Generate an object using the AI.",
9256
+ parameters: z10.object({
9257
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9258
+ model: modelConfigSchema,
9259
+ prompt: z10.string().describe("The prompt to use for the generation."),
9260
+ successMessage: z10.string().optional().describe("The success message to use for the generation."),
9261
+ schema: z10.custom().describe("The output schema to use for the generation."),
9262
+ fileAssets: z10.array(z10.string()).optional().describe("The file assets to use for the generation.")
9263
+ })
9264
+ }
9265
+ };
9266
+ var triggerAgentToolDeclarations = {
9267
+ queueAgents: {
9268
+ id: "queueAgents",
9269
+ description: "ONLY USE THIS IF EXPLICITLY MENTIONED IN THE INSTRUCTIONS. Queue a list of agents. When waitUponQueueing is true, this waits for every queued workflow in the call and returns their outputs.",
9270
+ parameters: z10.object({
9271
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9272
+ idempotencyKey: z10.string().optional().describe("ONLY CALL THIS IF EXPLICITLY CALLED OUT, OTHERWISE LEAVE EMPTY. A unique identifier for this specific agent run to ensure exactly-once execution. If provided, the system guarantees that multiple queue operations with the same ID will only be executed once."),
9273
+ runTime: z10.string().datetime({
9274
+ local: false
9275
+ }).optional().describe("When should this run? ONLY CALL THIS IF EXPLICITLY CALLED OUT, OTHERWISE LEAVE EMPTY. Date time is in UTC and is a JS date string."),
9276
+ waitUponQueueing: z10.boolean().optional().describe("Applies to every queued agent in this call. If true, wait for all queued workflows to finish and return their outputs before continuing."),
9277
+ queueItems: z10.array(agentToolSchema)
9278
+ })
9279
+ },
9280
+ callSpecializedAgent: {
9281
+ id: "callSpecializedAgent",
9282
+ description: "Call a specialized agent to complete a task.",
9283
+ parameters: z10.object({
9284
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9285
+ agent: agentToolSchema
9286
+ })
9287
+ }
9288
+ };
9289
+ var baseToolNames = Object.keys(baseToolDeclarations);
9290
+ var triggerAgentToolNames = Object.keys(triggerAgentToolDeclarations);
9291
+ var allToolNames = [
9292
+ ...baseToolNames,
9293
+ ...triggerAgentToolNames
9294
+ ];
9295
+ function markerSchema(description) {
9296
+ return z10.string().describe(`${description}
9297
+ MUST match this regex: /^[A-NP-Z][1-9]$/`);
9298
+ }
9299
+
9300
+ // ../common/dist/src/zod-schemas/agent-config.schema.js
9301
+ import { z as z15 } from "zod";
9302
+
9303
+ // ../common/dist/src/zod-schemas/api-request-body.schema.js
9304
+ import { z as z11 } from "zod";
9305
+ var ApiRequestBodyTypes = [
9306
+ "json",
9307
+ "multipartFormData",
9308
+ "formUrlEncoded"
9309
+ ];
9310
+ var ApiMethodsWithBody = ["POST", "PUT", "PATCH", "DELETE"];
9311
+ var ApiMultipartFormDataFieldTypes = ["text", "file"];
9312
+ var apiMultipartFormDataFieldSchema = z11.object({
9313
+ key: z11.string().describe("Form field name."),
9314
+ type: z11.enum(ApiMultipartFormDataFieldTypes).optional().describe("Form field type. Defaults to text when omitted. Use file to upload a file asset selected from available inputs."),
9315
+ value: z11.string().describe("Form field value.")
9316
+ }).describe("A multipart form-data field. Defaults to a text field when type is omitted.");
9317
+ var apiMultipartFormDataBodySchema = z11.array(apiMultipartFormDataFieldSchema).describe("Multipart form-data body represented as an array of typed form-data fields.");
9318
+ var apiFormUrlEncodedFieldSchema = z11.object({
9319
+ key: z11.string().describe("Form field name."),
9320
+ value: z11.string().describe("Form field value.")
9321
+ }).describe("A form URL-encoded field.");
9322
+ var apiFormUrlEncodedBodySchema = z11.array(apiFormUrlEncodedFieldSchema).describe("Form URL-encoded body represented as an array of key/value fields.");
9323
+ function isValidApiMultipartFormDataBody({ bodyType, body }) {
9324
+ if (bodyType !== "multipartFormData" || body === void 0) {
9325
+ return true;
9326
+ }
9327
+ return apiMultipartFormDataBodySchema.safeParse(body).success;
9328
+ }
9329
+ function isValidApiFormUrlEncodedBody({ bodyType, body }) {
9330
+ if (bodyType !== "formUrlEncoded" || body === void 0) {
9331
+ return true;
9332
+ }
9333
+ return apiFormUrlEncodedBodySchema.safeParse(body).success;
9334
+ }
9335
+
9336
+ // ../common/dist/src/zod-schemas/api-tool.schema.js
9337
+ import { z as z12 } from "zod";
9338
+
9339
+ // ../common/dist/src/zod-schemas/enums.js
9340
+ var IdentifierTypes = {
9341
+ password: "password",
9342
+ username: "username",
9343
+ email: "email",
9344
+ authenticatorCode: "authenticatorCode",
9345
+ otp: "otp"
9346
+ };
9347
+ var RunStatuses = {
9348
+ queued: "QUEUED",
9349
+ running: "RUNNING",
9350
+ complete: "COMPLETE",
9351
+ pausedAsInstructed: "PAUSED_AS_INSTRUCTED",
9352
+ // Deprecated: use PAUSED status
9353
+ pausedForTestConfirmation: "PAUSED_FOR_TEST_CONFIRMATION",
9354
+ incompleteDueToError: "INCOMPLETE_DUE_TO_ERROR",
9355
+ manuallyStopped: "MANUALLY_STOPPED",
9356
+ pausedDueToUnforeseenBlocker: "PAUSED_DUE_TO_UNFORESEEN_BLOCKER",
9357
+ inconsistentResults: "INCONSISTENT_RESULTS",
9358
+ paused: "PAUSED"
9359
+ };
9360
+ var RUNNING_STATUSES = /* @__PURE__ */ new Set([
9361
+ RunStatuses.queued,
9362
+ RunStatuses.running,
9363
+ RunStatuses.pausedAsInstructed,
9364
+ RunStatuses.pausedDueToUnforeseenBlocker,
9365
+ RunStatuses.paused
9366
+ ]);
9367
+ var PAUSED_STATUSES = /* @__PURE__ */ new Set([
9368
+ RunStatuses.pausedAsInstructed,
9369
+ RunStatuses.pausedDueToUnforeseenBlocker,
9370
+ RunStatuses.paused
9371
+ ]);
9372
+ var STOPPED_STATUSES = /* @__PURE__ */ new Set([
9373
+ RunStatuses.complete,
9374
+ RunStatuses.incompleteDueToError,
9375
+ RunStatuses.manuallyStopped,
9376
+ RunStatuses.inconsistentResults
9377
+ ]);
9378
+ var RunStatusStateMachine = new StateMachine({
9379
+ states: Object.values(RunStatuses),
9380
+ transitions: {
9381
+ [RunStatuses.queued]: [
9382
+ RunStatuses.running,
9383
+ RunStatuses.incompleteDueToError,
9384
+ RunStatuses.manuallyStopped
9385
+ ],
9386
+ [RunStatuses.running]: [
9387
+ RunStatuses.pausedAsInstructed,
9388
+ RunStatuses.pausedDueToUnforeseenBlocker,
9389
+ RunStatuses.paused,
9390
+ RunStatuses.incompleteDueToError,
9391
+ RunStatuses.manuallyStopped,
9392
+ RunStatuses.complete,
9393
+ RunStatuses.inconsistentResults
9394
+ ],
9395
+ [RunStatuses.pausedAsInstructed]: [
9396
+ RunStatuses.running,
9397
+ RunStatuses.incompleteDueToError,
9398
+ RunStatuses.manuallyStopped,
9399
+ /*
9400
+ * Handles race condition: If agent tries to pause at the same time (i.e. before we handle the
9401
+ * user set pause in the DB) we want to show the agent's pause message over the
9402
+ * non-descriptive one given when the automation is paused by the user.
9403
+ */
9404
+ RunStatuses.pausedDueToUnforeseenBlocker,
9405
+ /*
9406
+ * Handles race condition: If agent requests confirmation while user pauses, allow the agent
9407
+ * to set PAUSED status (with statusDetail) to provide context about what needs confirmation.
9408
+ */
9409
+ RunStatuses.paused,
9410
+ /*
9411
+ * The agent will complete its current action before it is paused, that action could be
9412
+ * reportStop, which would cause the automation to be marked as complete.
9413
+ */
9414
+ RunStatuses.complete
9415
+ ],
9416
+ [RunStatuses.pausedDueToUnforeseenBlocker]: [
9417
+ RunStatuses.running,
9418
+ RunStatuses.incompleteDueToError,
9419
+ RunStatuses.manuallyStopped
9420
+ ],
9421
+ [RunStatuses.paused]: [
9422
+ RunStatuses.running,
9423
+ RunStatuses.incompleteDueToError,
9424
+ RunStatuses.manuallyStopped
9425
+ ],
9426
+ [RunStatuses.incompleteDueToError]: [],
9427
+ [RunStatuses.manuallyStopped]: [],
9428
+ [RunStatuses.complete]: [],
9429
+ [RunStatuses.inconsistentResults]: []
9430
+ }
9431
+ });
9432
+ var BrowserProviderNames = {
9433
+ local: "local",
9434
+ browserbase: "browserbase",
9435
+ agentcore: "agentcore",
9436
+ hyperbrowser: "hyperbrowser",
9437
+ steel: "steel"
9438
+ };
9439
+ var VoiceProviderNames = {
9440
+ vapi: "vapi"
9441
+ };
9442
+ var EvalRunStatuses = {
9443
+ queued: "QUEUED",
9444
+ running: "RUNNING",
9445
+ complete: "COMPLETE",
9446
+ failed: "FAILED",
9447
+ cancelled: "CANCELLED"
9448
+ };
9449
+ var EVAL_RUNNING_STATUSES = /* @__PURE__ */ new Set([
9450
+ EvalRunStatuses.queued,
9451
+ EvalRunStatuses.running
9452
+ ]);
9453
+ var EVAL_STOPPED_STATUSES = /* @__PURE__ */ new Set([
9454
+ EvalRunStatuses.complete,
9455
+ EvalRunStatuses.failed,
9456
+ EvalRunStatuses.cancelled
9457
+ ]);
9458
+ var EvalRunStatusStateMachine = new StateMachine({
9459
+ states: Object.values(EvalRunStatuses),
9460
+ transitions: {
9461
+ [EvalRunStatuses.queued]: [
9462
+ EvalRunStatuses.running,
9463
+ EvalRunStatuses.failed,
9464
+ EvalRunStatuses.cancelled
9465
+ ],
9466
+ [EvalRunStatuses.running]: [
9467
+ EvalRunStatuses.complete,
9468
+ EvalRunStatuses.failed,
9469
+ EvalRunStatuses.cancelled
9470
+ ],
9471
+ [EvalRunStatuses.complete]: [],
9472
+ [EvalRunStatuses.failed]: [],
9473
+ [EvalRunStatuses.cancelled]: []
9474
+ }
9475
+ });
9476
+ var ErrorCategorizations = {
9477
+ toolCallFailed: "TOOL_CALL_FAILED",
9478
+ noToolInStep: "NO_TOOL_IN_STEP",
9479
+ pageLoadingIssue: "PAGE_LOADING_ISSUE",
9480
+ captchaBlocker: "CAPTCHA_BLOCKER",
9481
+ loginCredentialsRequired: "LOGIN_CREDENTIALS_REQUIRED",
9482
+ serverError: "SERVER_ERROR",
9483
+ elementNotFound: "ELEMENT_NOT_FOUND",
9484
+ sessionError: "SESSION_ERROR",
9485
+ dataExtractionIssue: "DATA_EXTRACTION_ISSUE",
9486
+ authenticationFailed: "AUTHENTICATION_FAILED",
9487
+ navigationIssue: "NAVIGATION_ISSUE",
9488
+ unstablePageState: "UNSTABLE_PAGE_STATE",
9489
+ other: "OTHER",
9490
+ // Step-following analysis categories
9491
+ repeatAction: "REPEAT_ACTION",
9492
+ stepSkipped: "STEP_SKIPPED",
9493
+ unexpectedDeviation: "UNEXPECTED_DEVIATION",
9494
+ attemptedRecovery: "ATTEMPTED_RECOVERY",
9495
+ unusualPath: "UNUSUAL_PATH"
9496
+ };
9497
+ var STEP_FOLLOWING_CATEGORIZATIONS = /* @__PURE__ */ new Set([
9498
+ ErrorCategorizations.repeatAction,
9499
+ ErrorCategorizations.stepSkipped,
9500
+ ErrorCategorizations.unexpectedDeviation,
9501
+ ErrorCategorizations.attemptedRecovery,
9502
+ ErrorCategorizations.unusualPath
9503
+ ]);
9504
+ var ERROR_CATEGORIZATION_LIST = [
9505
+ ...Object.values(ErrorCategorizations).filter((category) => category !== ErrorCategorizations.other && category !== ErrorCategorizations.attemptedRecovery && category !== ErrorCategorizations.unusualPath),
9506
+ ErrorCategorizations.other
9507
+ ];
9508
+ var ERROR_CATEGORIZATION_DESCRIPTIONS = {
9509
+ [ErrorCategorizations.toolCallFailed]: "A tool failed but the specific reason is unclear or does not fit other categories. Only use this as a fallback when none of the other categories clearly apply.",
9510
+ [ErrorCategorizations.noToolInStep]: 'No tool is mentioned in the instructions for this step. Common phrases: "no tool", "missing tool", "tool not specified".',
9511
+ [ErrorCategorizations.pageLoadingIssue]: 'Page is blank, not loading, taking too long to load, or requires waiting for loading to complete. Common phrases: "blank page", "not loading", "loading timeout", "page timeout", "still loading".',
9512
+ [ErrorCategorizations.captchaBlocker]: 'CAPTCHA or reCAPTCHA challenge appeared and requires human intervention to solve. Common phrases: "CAPTCHA", "reCAPTCHA", "challenge", "verification required".',
9513
+ [ErrorCategorizations.loginCredentialsRequired]: 'Login page appeared, credentials are required, password/username fields need to be filled, or login instructions are needed. Common phrases: "login page", "credentials required", "missing password", "missing username", "authentication required".',
9514
+ [ErrorCategorizations.serverError]: 'Server or service errors. Common: "500", "502", "503", "504", "service unavailable", "internal server error".',
9515
+ [ErrorCategorizations.sessionError]: 'Browser/remote session or connection failures Common: "browserType.connectOverCDP", "connection timeout", "browserbase", "session disconnected".',
9516
+ [ErrorCategorizations.elementNotFound]: 'Unable to locate or find a required element on the page. Common phrases: "cannot find", "unable to find", "element not found", "button not found", "field not found" (button, field, dropdown, link, etc.).',
9517
+ [ErrorCategorizations.dataExtractionIssue]: 'Issue extracting, finding, or reading required data from the page. Common phrases: "cannot extract", "unable to read", "data not found", "cannot find data" (tables, text, values, forms).',
9518
+ [ErrorCategorizations.authenticationFailed]: 'Authentication or login attempt failed. Common phrases: "authentication failed", "login failed", "invalid credentials", "locked account", "expired session", "2FA required".',
9519
+ [ErrorCategorizations.navigationIssue]: 'Navigation problem. Common phrases: "wrong page", "redirect issue", "URL error", "cannot reach site", "SSL error", "navigation failed".',
9520
+ [ErrorCategorizations.unstablePageState]: 'Page changed unexpectedly between decision and execution. Common: "markers moved", "page state changed", "unstable session state", "screenshot inconsistency".',
9521
+ [ErrorCategorizations.other]: "Other types of errors not covered above",
9522
+ [ErrorCategorizations.repeatAction]: "Agent repeated an action that caused critical real-world side effects (e.g., duplicate submissions, repeated sends).",
9523
+ [ErrorCategorizations.stepSkipped]: "Agent skipped a required step, causing missed real-world effects or derailing positioning for future steps.",
9524
+ [ErrorCategorizations.unexpectedDeviation]: "Agent performed an unauthorized action that caused critical impact (e.g., submitted unplanned data, took destructive actions).",
9525
+ [ErrorCategorizations.attemptedRecovery]: "Agent deviated from instructions but was performing valid recovery (e.g., navigating back, re-logging in, retracing steps).",
9526
+ [ErrorCategorizations.unusualPath]: "Agent took a different path than instructed but with no critical impact and no clear recovery intent."
9527
+ };
9528
+ var ERROR_CATEGORIZATION_LABEL = {
9529
+ [ErrorCategorizations.toolCallFailed]: "Tool call failed",
9530
+ [ErrorCategorizations.noToolInStep]: "No tool in step",
9531
+ [ErrorCategorizations.pageLoadingIssue]: "Page loading issue",
9532
+ [ErrorCategorizations.captchaBlocker]: "Captcha blocker",
9533
+ [ErrorCategorizations.loginCredentialsRequired]: "Login credentials required",
9534
+ [ErrorCategorizations.serverError]: "Server error",
9535
+ [ErrorCategorizations.sessionError]: "Session error",
9536
+ [ErrorCategorizations.unstablePageState]: "Unstable page state",
9537
+ [ErrorCategorizations.elementNotFound]: "Element not found",
9538
+ [ErrorCategorizations.dataExtractionIssue]: "Data extraction issue",
9539
+ [ErrorCategorizations.authenticationFailed]: "Authentication failed",
9540
+ [ErrorCategorizations.navigationIssue]: "Navigation issue",
9541
+ [ErrorCategorizations.other]: "Other",
9542
+ [ErrorCategorizations.repeatAction]: "Repeat action",
9543
+ [ErrorCategorizations.stepSkipped]: "Step skipped",
9544
+ [ErrorCategorizations.unexpectedDeviation]: "Unexpected deviation",
9545
+ [ErrorCategorizations.attemptedRecovery]: "Attempted recovery",
9546
+ [ErrorCategorizations.unusualPath]: "Unusual path"
9547
+ };
9548
+
9549
+ // ../common/dist/src/zod-schemas/api-tool.schema.js
9550
+ var methodsWithBody = new Set(ApiMethodsWithBody);
9551
+ var SECONDS_PER_DAY = 24 * 60 * 60;
9552
+ var API_RESPONSE_CACHE_DEFAULT_TTL_DAYS = 7;
9553
+ var API_RESPONSE_CACHE_DEFAULT_TTL_SECONDS = API_RESPONSE_CACHE_DEFAULT_TTL_DAYS * SECONDS_PER_DAY;
9554
+ var defaultApiResponseCacheConfig = {
9555
+ enabled: false,
9556
+ ttl: API_RESPONSE_CACHE_DEFAULT_TTL_SECONDS
9557
+ };
9558
+ var apiResponseCacheConfigObjectSchema = z12.object({
9559
+ enabled: z12.boolean().default(defaultApiResponseCacheConfig.enabled).describe("Whether API response caching is enabled for this request."),
9560
+ ttl: z12.number().int().positive().default(defaultApiResponseCacheConfig.ttl).describe("Time-to-live for cached successful API responses, measured in seconds.")
9561
+ });
9562
+ 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.");
9563
+ var apiToolSchema = z12.object({
9564
+ name: z12.string().describe("Unique name for the API tool."),
9565
+ description: z12.string().describe("Description of what the API tool does. Shown to the agent to help it decide when to use this tool."),
9566
+ inputSchema: z12.custom().optional().describe("JSON schema (in serialized Zod format) defining the input parameters for the API call."),
9567
+ authInputs: z12.array(z12.object({
9568
+ key: z12.string().describe("Parameter key where the auth value will be injected."),
9569
+ value: z12.object({
9570
+ authId: z12.string().describe("ID of the authentication credential to use."),
9571
+ factor: z12.enum(IdentifierTypes).optional().describe("Type of authentication factor.")
9572
+ })
9573
+ })).optional().describe("Authentication inputs to inject into the API call. Maps parameter keys to saved credentials."),
9574
+ type: z12.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]).describe("HTTP method for the API call."),
9575
+ url: z12.string().describe("URL template for the API endpoint. Can include placeholders like {paramName} for dynamic values."),
9576
+ headers: z12.record(z12.string(), z12.string()).optional().describe("HTTP headers to include in the request. Values can include placeholders."),
9577
+ queryParams: z12.record(z12.string(), z12.string()).optional().describe("Query parameters to include in the URL. Values can include placeholders."),
9578
+ body: z12.unknown().optional().describe("Request body template. Can include placeholders for dynamic values."),
9579
+ bodyType: z12.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."),
9580
+ outputJmesPath: z12.string().optional().describe("JMESPath expression to extract specific data from the API response before returning it to the agent."),
9581
+ cacheResponse: apiResponseCacheConfigSchema
9582
+ }).refine((data) => !(data.bodyType !== void 0 && !methodsWithBody.has(data.type)), {
9583
+ message: "Body type is not supported for this method",
9584
+ path: ["bodyType"]
9585
+ }).refine((data) => isValidApiMultipartFormDataBody({
9586
+ bodyType: data.bodyType,
9587
+ body: data.body
9588
+ }), {
9589
+ message: "Multipart form-data body must be an array of { key, type?, value } fields",
9590
+ path: ["body"]
9591
+ }).refine((data) => isValidApiFormUrlEncodedBody({
9592
+ bodyType: data.bodyType,
9593
+ body: data.body
9594
+ }), {
9595
+ message: "Form URL-encoded body must be an array of { key, value } fields",
9596
+ path: ["body"]
9597
+ }).describe("Custom API tool definition. Allows agents to make HTTP requests to external APIs.");
9598
+
9599
+ // ../common/dist/src/zod-schemas/run-limitation.schema.js
9600
+ import { z as z13 } from "zod";
9601
+ var MAX_BROWSER_SESSION_DURATION_SECONDS = 6 * 60 * 60;
9602
+ var BROWSER_TERMINATION_BUFFER_SECONDS = 60;
9603
+ var MAX_AUTOMATION_DURATION_SECONDS = MAX_BROWSER_SESSION_DURATION_SECONDS - BROWSER_TERMINATION_BUFFER_SECONDS;
9604
+ var MAX_AUTOMATION_TOOL_CALLS = 500;
9605
+ var MAX_AGENT_TOOL_CALLS = 50;
9606
+ var maxDurationSecondsSchema = z13.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.");
9607
+ var baseRunLimitationSchema = z13.object({
9608
+ maxDurationSeconds: maxDurationSecondsSchema,
9609
+ maxToolCalls: z13.number().optional().describe("Maximum number of tool calls allowed. The run will pause with MAX_TOOL_CALLS_REACHED when exceeded."),
9610
+ allowedUrlRegexes: z13.array(z13.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.")
9611
+ });
9612
+ var automationRunLimitationSchema = baseRunLimitationSchema.extend({
9613
+ maxToolCalls: z13.number().optional().default(MAX_AUTOMATION_TOOL_CALLS).describe("Maximum number of tool calls allowed across all agents in the automation.")
9614
+ }).optional().default({
9615
+ maxDurationSeconds: MAX_AUTOMATION_DURATION_SECONDS,
9616
+ maxToolCalls: MAX_AUTOMATION_TOOL_CALLS
9617
+ }).describe("Resource limits for the automation run.");
9618
+ var agentRunLimitationSchema = baseRunLimitationSchema.extend({
9619
+ maxToolCalls: z13.number().optional().default(MAX_AGENT_TOOL_CALLS).describe("Maximum number of tool calls allowed for this agent.")
9620
+ }).optional().default({
9621
+ maxDurationSeconds: MAX_AUTOMATION_DURATION_SECONDS,
9622
+ maxToolCalls: MAX_AGENT_TOOL_CALLS
9623
+ }).describe("Resource limits for the agent run.");
9624
+
9625
+ // ../common/dist/src/zod-schemas/voice-provider-options.schema.js
9626
+ import { z as z14 } from "zod";
9627
+ var voiceParticipantSchema = z14.object({
9628
+ number: z14.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."),
9629
+ name: z14.string().min(1).optional().describe("Display name to associate with this call participant.")
9630
+ }).describe("Default voice call participant settings.");
9631
+ var vapiVoiceProviderOptionsSchema = z14.object({
9632
+ assistantId: z14.string().min(1).optional().describe("Existing Vapi assistant ID to start or hand off the call to."),
9633
+ assistant: z14.record(z14.string(), z14.unknown()).optional().describe("Inline Vapi assistant definition used when an explicit assistantId is not provided."),
9634
+ assistantOverrides: z14.record(z14.string(), z14.unknown()).optional().describe("Runtime assistant override payload forwarded to Vapi when starting or handing off a call."),
9635
+ caller: voiceParticipantSchema.optional().describe("Default caller settings for outbound calls."),
9636
+ callee: voiceParticipantSchema.optional().describe("Default callee settings for outbound calls."),
9637
+ phoneNumberId: z14.string().min(1).optional().describe("Vapi phone number ID used to originate outbound calls."),
9638
+ enableDtmf: z14.boolean().optional().describe("Whether the call should support DTMF input.")
9639
+ }).describe("Configuration options specific to the Vapi voice provider.");
9640
+ var voiceProviderOptionsSchema = z14.object({
9641
+ vapi: vapiVoiceProviderOptionsSchema.optional().describe("Configuration options specific to the Vapi provider.")
9642
+ }).describe("Provider-specific voice configuration options. Only the options for the selected voiceProvider are used.");
9643
+
9644
+ // ../common/dist/src/zod-schemas/agent-config.schema.js
9645
+ var NangoSupportedMethods = [
9646
+ "GET",
9647
+ "POST",
9648
+ "PUT",
9649
+ "PATCH",
9650
+ "DELETE"
9651
+ ];
9652
+ var startingUrlSchema = z15.string().refine(isValidUrlOrHandlebarsTemplateString, {
9653
+ message: "Starting URL must be a valid URL or Handlebars template"
9654
+ }).optional();
9655
+ var browserSOMEnvironmentOptionsSchema = z15.object({
9656
+ environment: z15.literal("browser").describe("Browser environment using Set of Marks (SOM) for element identification."),
9657
+ maxMediaToIncludeInMemory: z15.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
9658
+ saveAuthCookiesAfterRun: z15.boolean().optional().describe("Whether to save authentication cookies after the run completes for reuse in future runs."),
9659
+ 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."),
9660
+ browserProvider: z15.nativeEnum(BrowserProviderNames).default(BrowserProviderNames.browserbase).describe("Browser provider to use if this agent is the first in a run to create a browser."),
9661
+ browserProviderOptions: browserProviderOptionsSchema.optional().describe("Provider-specific configuration options for the browser.")
9662
+ }).describe("Browser environment configuration using Set of Marks (SOM) for element identification. This is the recommended browser mode for most use cases.");
9663
+ var browserCoordinatesEnvironmentOptionsSchema = z15.object({
9664
+ environment: z15.literal("browserCoordinates").describe("Browser environment using coordinate-based interactions instead of SOM."),
9665
+ maxMediaToIncludeInMemory: z15.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
9666
+ saveAuthCookiesAfterRun: z15.boolean().optional().describe("Whether to save authentication cookies after the run completes for reuse in future runs."),
9667
+ 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."),
9668
+ browserProvider: z15.nativeEnum(BrowserProviderNames).default(BrowserProviderNames.browserbase).describe("Browser provider to use if this agent is the first in a run to create a browser."),
9669
+ browserProviderOptions: browserProviderOptionsSchema.optional().describe("Provider-specific configuration options for the browser.")
9670
+ }).describe("Browser environment configuration using coordinate-based interactions. Use for scenarios where SOM-based identification is insufficient.");
9671
+ var guacamoleEnvironmentOptionsSchema = z15.object({
9672
+ environment: z15.literal("desktop").describe("Desktop environment using Guacamole for remote desktop access."),
9673
+ browserProvider: z15.nativeEnum(BrowserProviderNames).default(BrowserProviderNames.browserbase).describe("Browser provider to use to connect to Guacamole."),
9674
+ browserProviderOptions: browserProviderOptionsSchema.optional().describe("Provider-specific configuration options."),
9675
+ maxMediaToIncludeInMemory: z15.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
9676
+ startingUrl: startingUrlSchema.describe("Initial URL for the Guacamole connection. Accepts a valid URL or a Handlebars template with agent inputs."),
9677
+ useCopyPasteForTyping: z15.boolean().default(false).optional().describe("Use copy-paste instead of keystroke simulation for text input. Can improve reliability in some desktop applications.")
9678
+ }).describe("Desktop environment configuration using Guacamole for remote desktop automation.");
9679
+ var desktopAppEnvironmentOptionsSchema = z15.object({
9680
+ environment: z15.literal("desktopApp").describe("Native application environment for mobile or desktop app automation."),
9681
+ maxMediaToIncludeInMemory: z15.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
9682
+ 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.`)
9683
+ }).describe("Native application environment configuration for automating mobile or desktop applications.");
9684
+ var minimalEnvironmentOptionsSchema = z15.object({
9685
+ environment: z15.literal("minimal").describe("Minimal environment without browser or desktop capabilities. Use for non-UI agents.")
9686
+ }).describe("Minimal environment configuration for agents that do not require browser or desktop access (e.g., API-only agents).");
9687
+ var voiceEnvironmentOptionsSchema = z15.object({
9688
+ environment: z15.literal("voice").describe("Hosted voice environment for live phone or audio conversations."),
9689
+ voiceProvider: z15.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."),
9690
+ voiceProviderOptions: voiceProviderOptionsSchema.optional().describe("Provider-specific configuration options for voice runtime.")
9691
+ }).describe("Voice environment configuration for hosted conversational runtimes such as Vapi.");
9692
+ var environmentOptionsSchema = z15.discriminatedUnion("environment", [
9693
+ browserSOMEnvironmentOptionsSchema,
9694
+ browserCoordinatesEnvironmentOptionsSchema,
9695
+ guacamoleEnvironmentOptionsSchema,
9696
+ desktopAppEnvironmentOptionsSchema,
9697
+ voiceEnvironmentOptionsSchema,
9698
+ minimalEnvironmentOptionsSchema
9699
+ ]).describe("Environment configuration for the agent. Determines the execution context.");
9700
+ var environmentNames = [
9701
+ "browser",
9702
+ "browserCoordinates",
9703
+ "desktop",
9704
+ "desktopApp",
9705
+ "voice",
9706
+ "minimal"
9707
+ ];
9708
+ var environmentNamesSchema = z15.enum(environmentNames).describe("Available environment types: browser (SOM-based), browserCoordinates (coordinate-based), desktop (Guacamole), desktopApp, voice, or minimal.");
9709
+ var DEFAULT_ENVIRONMENT_OPTION = environmentOptionsSchema.parse({
9710
+ environment: "browser"
9711
+ });
9712
+ var resourcePoolReferenceSchema = z15.object({
9713
+ id: z15.string().uuid().describe("Unique identifier of the resource pool."),
9714
+ type: z15.enum([
9715
+ "commandGenerated",
9716
+ "proxy",
9717
+ "apiAuthentication",
9718
+ "desktopAppAuthentication"
9719
+ ]).nullable().optional().describe("Resource pool type: commandGenerated (dynamic resources), proxy (proxy pool for browser sessions), apiAuthentication (authentication pool for API agents), or desktopAppAuthentication (desktop app pool for native desktop sessions).")
9720
+ });
9721
+ var resourcePoolsSchema = z15.array(resourcePoolReferenceSchema).max(5, "Only five resource pools per starting agent are currently supported").optional();
9722
+ var agentRunSettingsSchema = z15.object({
9723
+ environmentOptions: environmentOptionsSchema.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."),
9724
+ 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."),
9725
+ skipBrowserDebuggerPauses: z15.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.")
9726
+ });
9727
+ var remoteFileConnectionSchema = z15.object({
9728
+ description: z15.string().describe("Human-readable description of this remote file connection."),
9729
+ host: z15.string().describe("Hostname or IP address of the remote server."),
9730
+ port: z15.number().describe("Port number for the connection (e.g., 22 for SFTP)."),
9731
+ protocol: z15.enum(["sftp"]).describe("Protocol to use for the connection. Currently only SFTP is supported."),
9732
+ opItemId: z15.string().describe("1Password item ID containing the credentials."),
9733
+ opVaultId: z15.string().describe("1Password vault ID containing the item.")
9734
+ }).describe("Remote file connection configuration for SFTP access. Credentials are stored securely in 1Password.");
9735
+ var workflowIdReusePolicySchema = z15.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.");
9736
+ var codeLanguages = ["typescript"];
9737
+ var windowsAbsolutePathPattern = /^[A-Za-z]:[\\/]/u;
9738
+ function hasControlCharacter(value) {
9739
+ for (const character of value) {
9740
+ const codePoint = character.codePointAt(0);
9741
+ if (codePoint !== void 0 && (codePoint <= 31 || codePoint === 127)) {
9742
+ return true;
9743
+ }
9744
+ }
9745
+ return false;
9746
+ }
9747
+ function isNormalizedRepoPath(path7) {
9748
+ if (path7 === "/") {
9749
+ return true;
9750
+ }
9751
+ if (path7.length === 0 || path7.startsWith("/") || path7.startsWith("\\") || path7.includes("\\") || hasControlCharacter(path7) || windowsAbsolutePathPattern.test(path7)) {
9752
+ return false;
9753
+ }
9754
+ return path7.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== ".." && segment !== ".git");
9755
+ }
9756
+ var knowledgeBasePluginPermissionSchema = z15.object({
9757
+ path: z15.string().min(1).refine(isNormalizedRepoPath, {
9758
+ message: "Path must be a normalized repository-relative path."
9759
+ }).describe("Repository path the knowledge base plugin can access."),
9760
+ access: z15.enum(["read", "write"]).describe("Access level for the path. Write access also grants reads.")
9761
+ }).describe("Path-scoped permission for the knowledge base runtime plugin.");
9762
+ var knowledgeBaseConfigSchema = z15.object({
9763
+ enabled: z15.boolean().default(false).describe("Explicit rollout switch for the knowledge base runtime plugin."),
9764
+ permissions: z15.array(knowledgeBasePluginPermissionSchema).min(1).describe("Repository paths the knowledge base plugin can access. Write grants read and write access.")
9765
+ }).describe("Configuration for the knowledge base runtime plugin.");
9766
+ var agentPluginsConfigSchema = z15.object({
9767
+ knowledgeBase: knowledgeBaseConfigSchema.optional().describe("Enables the knowledge base runtime plugin.")
9768
+ }).optional().describe("Runtime plugins enabled for this agent. Plugin tools are not controlled by the built-in tools allow-list.");
9769
+ var baseAgentConfigFieldsSchema = z15.object({
9770
+ apiTools: z15.array(apiToolSchema).optional().describe("Custom API tools available to this agent. Each tool defines an HTTP endpoint the agent can call."),
9771
+ remoteFileConnections: z15.array(remoteFileConnectionSchema).optional().describe("Remote file server connections for SFTP operations. Enables agents to read/write files on remote servers."),
9772
+ 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 5 pools per starting agent."),
9773
+ tools: z15.array(z15.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."),
9774
+ knowledgeBase: z15.object({
9775
+ namespace: z15.string().describe("Vector database namespace for knowledge retrieval."),
9776
+ k: z15.number().describe("Number of results to retrieve from the knowledge base per query.")
9777
+ }).optional().describe("Knowledge base configuration for RAG (Retrieval-Augmented Generation). Enables the agent to query a vector database."),
9778
+ plugins: agentPluginsConfigSchema,
9779
+ maxSessionMessages: z15.number().optional().describe("Maximum number of messages to keep in the agent session memory. Older messages are pruned to stay within this limit."),
9780
+ environmentOptions: environmentOptionsSchema.optional().default(DEFAULT_ENVIRONMENT_OPTION).describe("Environment configuration for the agent. Default is browser with SOM."),
9781
+ 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."),
9782
+ skipBrowserDebuggerPauses: z15.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."),
9783
+ limitations: agentRunLimitationSchema.describe("Resource limits for this agent, including maximum duration and tool call limits."),
9784
+ commonParametersSchema: z15.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."),
9785
+ idempotencySettings: z15.object({
9786
+ include: z15.array(z15.string()).optional().describe("Input field names to include in the idempotency key. If specified, only these fields are used."),
9787
+ exclude: z15.array(z15.string()).optional().describe("Input field names to exclude from the idempotency key. Ignored if include is specified."),
9788
+ workflowIdReusePolicy: workflowIdReusePolicySchema.optional().default("ALLOW_DUPLICATE").describe("Policy for reusing Temporal workflow IDs.")
9789
+ }).optional().describe("Idempotency settings for preventing duplicate runs. Controls which input fields contribute to the unique run identifier."),
9790
+ taskQueue: z15.string().optional().describe("Temporal task queue name for this agent. If specified, queued child agents run on this queue instead of the parent queue."),
9791
+ waitUponQueueing: z15.boolean().optional().default(false).describe("If true, wait for queued child agents to complete before proceeding."),
9792
+ queueableAgentIds: z15.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."),
9793
+ checkpoint: z15.object({
9794
+ name: z15.string().describe("Name for the checkpoint, used for filtering and identification."),
9795
+ screenshot: z15.boolean().optional().default(false).describe("Whether to capture a screenshot when creating the checkpoint.")
9796
+ }).optional().describe("Checkpoint configuration. When set, agent iterations are recorded as checkpoints for auditing and debugging."),
9797
+ systemPrompt: z15.string().optional().describe("Custom system prompt that replaces the default system prompt for this agent. Combined with automation-level and agent-level additionalSystemPrompt values."),
9798
+ additionalSystemPrompt: z15.string().optional().describe("Additional instructions appended to the system prompt for this agent. Combined with automation-level additionalSystemPrompt."),
9799
+ // Backlinking metadata for imported agents
9800
+ importedFrom: z15.object({
9801
+ automationId: brandedStringValidator("draftAutomationId").describe("ID of the source automation from which this agent was imported."),
9802
+ originalAgentId: brandedStringValidator("agentId").describe("Original agent ID in the source automation.")
9803
+ }).optional().describe("Metadata for agents imported from another automation. Used for traceability and updates."),
9804
+ ignoreUnstableSessionState: z15.boolean().optional().describe("When true, skips screenshot consistency checks before tool execution. Overrides the automation-level ignoreUnstableSessionState setting.")
9805
+ }).superRefine((config, ctx) => {
9806
+ if (config.resourcePools !== void 0 && config.runSettings?.resourcePools !== void 0 && !isDeepEqualAndSameType(config.resourcePools, config.runSettings.resourcePools)) {
9807
+ ctx.addIssue({
9808
+ code: z15.ZodIssueCode.custom,
9809
+ path: ["runSettings", "resourcePools"],
9810
+ message: "runSettings.resourcePools must match resourcePools when both are provided"
9811
+ });
9812
+ }
9813
+ });
9814
+ var agenticAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9815
+ type: z15.literal("agentic").describe("Agentic agent type - autonomous AI agent with tool calling capabilities."),
9816
+ model: agentModelConfigSchema.describe("LLM model configuration for this agentic agent.")
9817
+ }).describe("Agentic agent configuration. Uses an LLM to autonomously decide which tools to call to accomplish tasks.");
9818
+ var codeAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9819
+ type: z15.literal("code").describe("Code agent type - executes predefined code instead of LLM-driven decisions."),
9820
+ language: z15.enum(codeLanguages).default("typescript").describe("Programming language for the agent code. Currently only TypeScript is supported.")
9821
+ }).describe("Code agent configuration. Executes predefined TypeScript code instead of using LLM-driven decision making.");
9822
+ var extractAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9823
+ type: z15.literal("extract").describe("Extract agent type - specialized for structured data extraction."),
9824
+ model: agentModelConfigSchema.describe("LLM model configuration for this extract agent.")
9825
+ }).describe("Extract agent configuration. Specialized for extracting structured data from files according to a defined output schema.");
9826
+ var OutcomePayloadSchema = z15.object({
9827
+ id: z15.string().min(1).describe("Unique identifier for the outcome."),
9828
+ input: z15.record(z15.string(), z15.unknown()).describe("Input data for the outcome. Maps parameter keys to values."),
9829
+ preview: z15.string().describe("Rendered text representation of the outcome.")
9830
+ });
9831
+ var branchAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9832
+ type: z15.literal("branch").describe("Branch agent type - makes decisions to route to different agents."),
9833
+ model: agentModelConfigSchema.describe("LLM model configuration for this branch agent."),
9834
+ conditionsAndOutcomes: z15.object({
9835
+ if: z15.array(z15.object({
9836
+ caseName: z15.string().describe("Name of the condition case."),
9837
+ condition: z15.string().min(1).describe("Condition to evaluate."),
9838
+ outcome: z15.array(OutcomePayloadSchema).describe("Outcomes to return if the condition is met.")
9839
+ })).min(1).describe("Conditions and outcomes for the branch agent."),
9840
+ else: z15.array(OutcomePayloadSchema).min(1).describe("Outcomes to return if the condition is not met.")
9841
+ }).describe("Conditions and outcomes for the branch agent, including a fallback outcome.")
9842
+ }).describe("Branch agent configuration. Makes decisions about which agent to call next based on the current context.");
9843
+ var draftBranchAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9844
+ type: z15.literal("branch").describe("Branch agent draft configuration. Allows incomplete conditions and outcomes while the agent is still being authored."),
9845
+ model: agentModelConfigSchema.describe("LLM model configuration for this branch agent."),
9846
+ conditionsAndOutcomes: z15.object({
9847
+ if: z15.array(z15.object({
9848
+ caseName: z15.string().describe("Name of the condition case."),
9849
+ condition: z15.string().describe("Condition to evaluate. Draft saves may include an empty placeholder while the user is still editing."),
9850
+ outcome: z15.array(OutcomePayloadSchema).describe("Outcomes to return if the condition is met.")
9851
+ })).describe("Draft branch conditions and outcomes."),
9852
+ else: z15.array(OutcomePayloadSchema).describe("Draft fallback outcomes for the branch agent. May be empty while the branch is still being configured.")
9853
+ }).describe("Draft conditions and outcomes for the branch agent, including an optional fallback outcome while editing.")
9854
+ }).describe("Branch agent draft configuration. More permissive than the authored branch schema so incomplete draft branches can be saved.");
9855
+ var METHODS_WITH_BODY = new Set(ApiMethodsWithBody);
9856
+ var apiAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9857
+ type: z15.literal("api").describe("API agent type - makes HTTP requests to external APIs."),
9858
+ method: z15.enum(NangoSupportedMethods).describe("HTTP method for the API request (GET, POST, PUT, PATCH, DELETE)."),
9859
+ url: z15.string().describe("URL for the API endpoint. Can include placeholders like {paramName} for dynamic values from inputs."),
9860
+ headers: z15.array(z15.object({ key: z15.string(), value: z15.string() })).optional().describe("HTTP headers to include in the request. Values can include placeholders."),
9861
+ queryParams: z15.array(z15.object({ key: z15.string(), value: z15.string() })).optional().describe("Query parameters to append to the URL. Values can include placeholders."),
9862
+ body: z15.unknown().optional().describe("Request body for POST/PUT/PATCH requests. Can include placeholders for dynamic values."),
9863
+ bodyType: z15.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."),
9864
+ outputJmesPath: z15.string().optional().describe("JMESPath expression to extract specific data from the API response before returning it."),
9865
+ cacheResponse: apiResponseCacheConfigSchema.describe("Response cache configuration for this API agent. TTL is measured in seconds."),
9866
+ authentication: z15.discriminatedUnion("type", [
9867
+ z15.object({
9868
+ type: z15.literal("nangoConnection").describe("Authentication via Nango integration."),
9869
+ providerConfigKey: z15.string().describe('The provider config key for the integration (e.g., "github", "slack").'),
9870
+ poolId: brandedStringValidator("resourcePoolId").optional().describe("ID of the resource pool containing authentication credentials.")
9871
+ }),
9872
+ z15.object({
9873
+ type: z15.literal("customHost").describe("Authentication via 1Password credentials for custom host."),
9874
+ poolId: brandedStringValidator("resourcePoolId").optional().describe("ID of the resource pool containing 1Password authentication.")
9875
+ })
9876
+ ]).optional().describe("Authentication configuration for the API request. Uses credentials from a resource pool.")
9877
+ }).refine((data) => !(data.body !== void 0 && !METHODS_WITH_BODY.has(data.method)), {
9878
+ message: "Body is not supported for this method",
9879
+ path: ["body"]
9880
+ }).refine((data) => !(data.bodyType !== void 0 && !METHODS_WITH_BODY.has(data.method)), {
9881
+ message: "Body type is not supported for this method",
9882
+ path: ["bodyType"]
9883
+ }).refine((data) => isValidApiMultipartFormDataBody({
9884
+ bodyType: data.bodyType,
9885
+ body: data.body
9886
+ }), {
9887
+ message: "Multipart form-data body must be an array of { key, type?, value } fields",
9888
+ path: ["body"]
9889
+ }).refine((data) => isValidApiFormUrlEncodedBody({
9890
+ bodyType: data.bodyType,
9891
+ body: data.body
9892
+ }), {
9893
+ message: "Form URL-encoded body must be an array of { key, value } fields",
9894
+ path: ["body"]
9895
+ }).describe("API agent configuration. Makes HTTP requests to external APIs without LLM decision making. Supports authentication via Nango connections.");
9896
+ var agentConfigSchemaUnion = z15.discriminatedUnion("type", [
9897
+ agenticAgentConfigSchema,
9898
+ codeAgentConfigSchema,
9899
+ extractAgentConfigSchema,
9900
+ branchAgentConfigSchema,
9901
+ apiAgentConfigSchema
9902
+ ]).describe("Agent configuration discriminated by type. Types: agentic (LLM-driven), code (predefined code), extract (data extraction), branch (routing decisions), api (HTTP requests).");
9903
+ var agentConfigSchema = z15.preprocess((data) => {
9904
+ if (typeof data === "object" && data !== null && !("type" in data)) {
9905
+ return { ...data, type: "agentic" };
9906
+ }
9907
+ return data;
9908
+ }, agentConfigSchemaUnion).describe("Agent configuration. Defines the agent type, environment, available tools, model settings, and behavior options. If type is omitted, defaults to agentic.");
9909
+ var draftAgentConfigSchemaUnion = z15.discriminatedUnion("type", [
9910
+ agenticAgentConfigSchema,
9911
+ codeAgentConfigSchema,
9912
+ extractAgentConfigSchema,
9913
+ draftBranchAgentConfigSchema,
9914
+ apiAgentConfigSchema
9915
+ ]).describe("Draft agent configuration discriminated by type. Uses a more permissive branch schema so incomplete branches can be saved before publish-time validation.");
9916
+ var draftAgentConfigSchema = z15.preprocess((data) => {
9917
+ if (typeof data === "object" && data !== null && !("type" in data)) {
9918
+ return { ...data, type: "agentic" };
9919
+ }
9920
+ return data;
9921
+ }, draftAgentConfigSchemaUnion).describe("Draft agent configuration. Matches authored validation for most agent types, but allows incomplete branch agents during draft saves.");
9922
+ var DEFAULT_AGENT_CONFIG = agentConfigSchema.parse({});
9923
+
9924
+ // ../common/dist/src/zod-schemas/automation-run-config.schema.js
9925
+ import { z as z16 } from "zod";
9926
+ var automationRunResolvedRunSettingsSchema = z16.object({
9927
+ environmentOptions: environmentOptionsSchema.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."),
9928
+ 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."),
9929
+ skipBrowserDebuggerPauses: z16.boolean().optional().describe("Canonical run-settings-owned browser session startup setting snapshotted onto the automation run when it starts in runSettings mode.")
9930
+ });
9931
+ var CONSISTENCY_CHECK_COUNT_MAX = 50;
9932
+ var automationRunConfigSchema = z16.object({
9933
+ approvalMode: z16.enum(["HUMAN_APPROVAL", "OFF"]).default("OFF"),
9934
+ consistencyCheckCount: z16.number().int().nonnegative().max(CONSISTENCY_CHECK_COUNT_MAX).nullable().default(null),
9935
+ settingsSourceAgentId: z16.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."),
9936
+ startInTakeOverMode: z16.boolean().default(false).describe("When true, create and prepare the remote session, then pause until a human manually starts the agent."),
9937
+ 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."),
9938
+ resolvedRunSettingsSource: z16.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.")
9939
+ });
9940
+ var automationRunStartConfigSchema = automationRunConfigSchema.omit({
9941
+ resolvedRunSettings: true,
9942
+ resolvedRunSettingsSource: true
9943
+ });
9944
+
9945
+ // ../mcp-registry/src/operation-specs.ts
9946
+ import { z as z17 } from "zod";
9947
+
9948
+ // ../mcp-registry/src/operation-spec.ts
9949
+ function stripLeadingGraphqlComments(document) {
9950
+ return document.replace(/^(?:\s*#.*\n)+/u, "").trimStart();
9951
+ }
9952
+ function assertDocumentMatchesOperation({
9953
+ document,
9954
+ kind,
9955
+ operationName
9956
+ }) {
9957
+ const normalizedDocument = stripLeadingGraphqlComments(document);
9958
+ const match = /^(?<actualKind>query|mutation)\s+(?<actualOperationName>[_A-Za-z][_0-9A-Za-z]*)/u.exec(
9959
+ normalizedDocument
9960
+ );
9961
+ const actualKind = match?.groups?.["actualKind"];
9962
+ const actualOperationName = match?.groups?.["actualOperationName"];
9963
+ if (!actualKind || !actualOperationName) {
9964
+ throw new Error(
9965
+ `Operation "${operationName}" is missing a top-level GraphQL ${kind} definition.`
9966
+ );
9967
+ }
9968
+ if (actualKind !== kind || actualOperationName !== operationName) {
9969
+ throw new Error(
9970
+ `Operation "${operationName}" does not match its GraphQL document (${actualKind} ${actualOperationName}).`
9971
+ );
9972
+ }
9973
+ }
9974
+ function createOperationSpec(spec) {
9975
+ assertDocumentMatchesOperation(spec);
9976
+ return spec;
9977
+ }
9978
+
9979
+ // ../mcp-registry/src/operation-specs.ts
9980
+ function stringOption({
9981
+ description,
9982
+ flagName,
9983
+ inputKey,
9984
+ required = false
9985
+ }) {
9986
+ return {
9987
+ description,
9988
+ flagName,
9989
+ inputKey,
9990
+ required,
9991
+ valueType: "string"
9992
+ };
9993
+ }
9994
+ function numberOption({
9995
+ description,
9996
+ flagName,
9997
+ inputKey,
9998
+ required = false
9999
+ }) {
10000
+ return {
10001
+ description,
10002
+ flagName,
10003
+ inputKey,
10004
+ required,
10005
+ valueType: "number"
10006
+ };
7541
10007
  }
7542
10008
  function booleanOption({
7543
10009
  description,
@@ -7581,11 +10047,12 @@ function jsonOption({
7581
10047
  valueType: "json"
7582
10048
  };
7583
10049
  }
7584
- var jsonObjectSchema = z2.record(z2.string(), z2.unknown());
10050
+ var jsonObjectSchema = z17.record(z17.string(), z17.unknown());
7585
10051
  var agentBrowserProviderOptionsSelection = ` browserbase {
7586
10052
  advancedStealth
7587
10053
  contextId
7588
10054
  extensionId
10055
+ enablePdfViewer
7589
10056
  instanceSize
7590
10057
  blockAds
7591
10058
  solveCaptchas
@@ -7608,6 +10075,7 @@ var agentBrowserProviderOptionsSelection = ` browserbase {
7608
10075
  }
7609
10076
  }
7610
10077
  hyperbrowser {
10078
+ solveCaptchas
7611
10079
  viewport {
7612
10080
  width
7613
10081
  height
@@ -7671,8 +10139,8 @@ var operationSpecs = [
7671
10139
  createOperationSpec({
7672
10140
  operationName: "GetAgents",
7673
10141
  kind: "query",
7674
- inputSchema: z2.object({
7675
- ids: z2.array(z2.string().min(1)).min(1)
10142
+ inputSchema: z17.object({
10143
+ ids: z17.array(z17.string().min(1)).min(1)
7676
10144
  }),
7677
10145
  cli: {
7678
10146
  name: "get-agents",
@@ -7720,6 +10188,10 @@ ${agentLimitationsSelection}
7720
10188
  systemPrompt
7721
10189
  additionalSystemPrompt
7722
10190
  ignoreUnstableSessionState
10191
+ resourcePools {
10192
+ id
10193
+ type
10194
+ }
7723
10195
  }
7724
10196
  childAgentIds
7725
10197
  }
@@ -7728,9 +10200,9 @@ ${agentLimitationsSelection}
7728
10200
  createOperationSpec({
7729
10201
  operationName: "GetAgentVersion",
7730
10202
  kind: "query",
7731
- inputSchema: z2.object({
7732
- agentId: z2.string().min(1),
7733
- versionId: z2.string().min(1)
10203
+ inputSchema: z17.object({
10204
+ agentId: z17.string().min(1),
10205
+ versionId: z17.string().min(1)
7734
10206
  }),
7735
10207
  cli: {
7736
10208
  name: "get-agent-version",
@@ -7792,8 +10264,8 @@ ${agentLimitationsSelection}
7792
10264
  createOperationSpec({
7793
10265
  operationName: "GetAgentVersions",
7794
10266
  kind: "query",
7795
- inputSchema: z2.object({
7796
- agentId: z2.string().min(1)
10267
+ inputSchema: z17.object({
10268
+ agentId: z17.string().min(1)
7797
10269
  }),
7798
10270
  cli: {
7799
10271
  name: "get-agent-versions",
@@ -7827,10 +10299,10 @@ query GetAgentVersions($agentId: ID!) {
7827
10299
  createOperationSpec({
7828
10300
  operationName: "DiffAgentVersion",
7829
10301
  kind: "query",
7830
- inputSchema: z2.object({
7831
- agentId: z2.string().min(1),
7832
- versionId: z2.string().min(1),
7833
- compareVersionId: z2.string().min(1).optional()
10302
+ inputSchema: z17.object({
10303
+ agentId: z17.string().min(1),
10304
+ versionId: z17.string().min(1),
10305
+ compareVersionId: z17.string().min(1).optional()
7834
10306
  }),
7835
10307
  cli: {
7836
10308
  name: "diff-agent-version",
@@ -7884,8 +10356,8 @@ query DiffAgentVersion(
7884
10356
  createOperationSpec({
7885
10357
  operationName: "GetAgentRun",
7886
10358
  kind: "query",
7887
- inputSchema: z2.object({
7888
- id: z2.string().min(1)
10359
+ inputSchema: z17.object({
10360
+ id: z17.string().min(1)
7889
10361
  }),
7890
10362
  cli: {
7891
10363
  name: "get-agent-run",
@@ -7921,8 +10393,8 @@ query GetAgentRun($id: ID!) {
7921
10393
  createOperationSpec({
7922
10394
  operationName: "GetAutomationAgents",
7923
10395
  kind: "query",
7924
- inputSchema: z2.object({
7925
- ids: z2.array(z2.string().min(1)).min(1)
10396
+ inputSchema: z17.object({
10397
+ ids: z17.array(z17.string().min(1)).min(1)
7926
10398
  }),
7927
10399
  cli: {
7928
10400
  name: "get-automation-agents",
@@ -7960,13 +10432,154 @@ query GetAutomationAgents($ids: [ID!]!) {
7960
10432
  childAgentIds
7961
10433
  }
7962
10434
  }
10435
+ }`
10436
+ }),
10437
+ createOperationSpec({
10438
+ operationName: "GetAutomationDiffFromPublished",
10439
+ kind: "query",
10440
+ inputSchema: z17.object({
10441
+ automationId: z17.string().min(1)
10442
+ }),
10443
+ cli: {
10444
+ name: "get-automation-diff-from-published",
10445
+ path: ["automations", "diff-from-published"],
10446
+ description: "Fetch draft-vs-published automation JSON Patch.",
10447
+ resultKey: "automationDiffFromPublished",
10448
+ options: [
10449
+ stringOption({
10450
+ inputKey: "automationId",
10451
+ flagName: "automation-id",
10452
+ description: "Automation ID.",
10453
+ required: true
10454
+ })
10455
+ ]
10456
+ },
10457
+ mcp: { fileName: "automationDiffFromPublished.graphql" },
10458
+ document: `# Query JSON Patch changes from published automation JSON to draft automation JSON
10459
+ query GetAutomationDiffFromPublished($automationId: ID!) {
10460
+ automationDiffFromPublished(automationId: $automationId) {
10461
+ automationId
10462
+ automationName
10463
+ mode
10464
+ draftVersionId
10465
+ publishedVersionId
10466
+ hasChanges
10467
+ changes
10468
+ }
10469
+ }`
10470
+ }),
10471
+ createOperationSpec({
10472
+ operationName: "GetAutomationDiffVersions",
10473
+ kind: "query",
10474
+ inputSchema: z17.object({
10475
+ baseVersionId: z17.string().min(1),
10476
+ targetVersionId: z17.string().min(1)
10477
+ }),
10478
+ cli: {
10479
+ name: "get-automation-diff-versions",
10480
+ path: ["automations", "diff-versions"],
10481
+ description: "Fetch automation JSON Patch between two saved versions.",
10482
+ resultKey: "automationDiffVersions",
10483
+ options: [
10484
+ stringOption({
10485
+ inputKey: "baseVersionId",
10486
+ flagName: "base-version-id",
10487
+ description: "Older automation version ID to compare from.",
10488
+ required: true
10489
+ }),
10490
+ stringOption({
10491
+ inputKey: "targetVersionId",
10492
+ flagName: "target-version-id",
10493
+ description: "Newer automation version ID to compare to.",
10494
+ required: true
10495
+ })
10496
+ ]
10497
+ },
10498
+ mcp: { fileName: "automationDiffVersions.graphql" },
10499
+ document: `# Query JSON Patch changes between two normalized automation JSON payloads
10500
+ query GetAutomationDiffVersions($baseVersionId: ID!, $targetVersionId: ID!) {
10501
+ automationDiffVersions(baseVersionId: $baseVersionId, targetVersionId: $targetVersionId) {
10502
+ baseAutomationId
10503
+ baseAutomationName
10504
+ baseVersionId
10505
+ targetAutomationId
10506
+ targetAutomationName
10507
+ targetVersionId
10508
+ mode
10509
+ hasChanges
10510
+ changes
10511
+ }
10512
+ }`
10513
+ }),
10514
+ createOperationSpec({
10515
+ operationName: "GetAutomationVersionJson",
10516
+ kind: "query",
10517
+ inputSchema: z17.object({
10518
+ versionId: z17.string().min(1),
10519
+ paths: z17.array(z17.string().min(1)).optional(),
10520
+ format: z17.enum(["normalized", "export"]).optional()
10521
+ }),
10522
+ cli: {
10523
+ name: "get-automation-version-json",
10524
+ path: ["automations", "versions", "get-json"],
10525
+ description: "Fetch one saved automation version as normalized automation JSON by default. Pass --format export for raw import/export JSON.",
10526
+ resultKey: "automationVersionJson",
10527
+ options: [
10528
+ stringOption({
10529
+ inputKey: "versionId",
10530
+ flagName: "version-id",
10531
+ description: "Saved automation version ID.",
10532
+ required: true
10533
+ }),
10534
+ stringOption({
10535
+ inputKey: "format",
10536
+ flagName: "format",
10537
+ description: "Optional output format: normalized or export."
10538
+ }),
10539
+ stringArrayOption({
10540
+ inputKey: "paths",
10541
+ flagName: "paths",
10542
+ description: "Optional comma-separated JSON Pointer paths to fetch from normalized automation JSON."
10543
+ })
10544
+ ]
10545
+ },
10546
+ mcp: { fileName: "automationVersionJson.graphql" },
10547
+ document: `# Query one saved automation version as normalized automation JSON by default, or raw import/export JSON with format: export
10548
+ query GetAutomationVersionJson($versionId: ID!, $paths: [String!], $format: String) {
10549
+ automationVersionJson(versionId: $versionId, paths: $paths, format: $format)
10550
+ }`
10551
+ }),
10552
+ createOperationSpec({
10553
+ operationName: "GetAutomationVersionJsonSkeleton",
10554
+ kind: "query",
10555
+ inputSchema: z17.object({
10556
+ versionId: z17.string().min(1)
10557
+ }),
10558
+ cli: {
10559
+ name: "get-automation-version-json-skeleton",
10560
+ path: ["automations", "versions", "get-skeleton"],
10561
+ description: "Fetch one saved automation version as compact normalized automation JSON skeleton.",
10562
+ resultKey: "automationVersionJsonSkeleton",
10563
+ options: [
10564
+ stringOption({
10565
+ inputKey: "versionId",
10566
+ flagName: "version-id",
10567
+ description: "Saved automation version ID.",
10568
+ required: true
10569
+ })
10570
+ ]
10571
+ },
10572
+ mcp: { fileName: "automationVersionJsonSkeleton.graphql" },
10573
+ document: `# Query one saved automation version as compact normalized automation JSON skeleton
10574
+ query GetAutomationVersionJsonSkeleton($versionId: ID!) {
10575
+ automationVersionJsonSkeleton(versionId: $versionId)
7963
10576
  }`
7964
10577
  }),
7965
10578
  createOperationSpec({
7966
10579
  operationName: "GetAutomationRun",
7967
10580
  kind: "query",
7968
- inputSchema: z2.object({
7969
- id: z2.string().min(1)
10581
+ inputSchema: z17.object({
10582
+ id: z17.string().min(1)
7970
10583
  }),
7971
10584
  cli: {
7972
10585
  name: "get-automation-run",
@@ -8006,8 +10619,8 @@ query GetAutomationRun($id: ID!) {
8006
10619
  createOperationSpec({
8007
10620
  operationName: "GetAutomationRunAgentRuns",
8008
10621
  kind: "query",
8009
- inputSchema: z2.object({
8010
- automationRunId: z2.string().min(1)
10622
+ inputSchema: z17.object({
10623
+ automationRunId: z17.string().min(1)
8011
10624
  }),
8012
10625
  cli: {
8013
10626
  name: "get-automation-run-agent-runs",
@@ -8043,11 +10656,11 @@ query GetAutomationRunAgentRuns($automationRunId: ID!) {
8043
10656
  createOperationSpec({
8044
10657
  operationName: "GetAutomationRunIterations",
8045
10658
  kind: "query",
8046
- inputSchema: z2.object({
8047
- automationRunId: z2.string().min(1),
8048
- agentRunId: z2.string().min(1).optional(),
8049
- limit: z2.number().int().positive().optional(),
8050
- reverse: z2.boolean().optional()
10659
+ inputSchema: z17.object({
10660
+ automationRunId: z17.string().min(1),
10661
+ agentRunId: z17.string().min(1).optional(),
10662
+ limit: z17.number().int().positive().optional(),
10663
+ reverse: z17.boolean().optional()
8051
10664
  }),
8052
10665
  cli: {
8053
10666
  name: "get-automation-run-iterations",
@@ -8116,12 +10729,12 @@ query GetAutomationRunIterations(
8116
10729
  createOperationSpec({
8117
10730
  operationName: "GetAutomationRuns",
8118
10731
  kind: "query",
8119
- inputSchema: z2.object({
8120
- automationId: z2.string().min(1),
8121
- status: z2.array(z2.string().min(1)).optional(),
8122
- invocationType: z2.array(z2.string().min(1)).optional(),
8123
- limit: z2.number().int().positive().optional(),
8124
- page: z2.number().int().positive().optional()
10732
+ inputSchema: z17.object({
10733
+ automationId: z17.string().min(1),
10734
+ status: z17.array(z17.string().min(1)).optional(),
10735
+ invocationType: z17.array(z17.string().min(1)).optional(),
10736
+ limit: z17.number().int().positive().optional(),
10737
+ page: z17.number().int().positive().optional()
8125
10738
  }),
8126
10739
  cli: {
8127
10740
  name: "get-automation-runs",
@@ -8190,8 +10803,8 @@ query GetAutomationRuns(
8190
10803
  createOperationSpec({
8191
10804
  operationName: "ListAutomations",
8192
10805
  kind: "query",
8193
- inputSchema: z2.object({
8194
- limit: z2.number().positive().optional(),
10806
+ inputSchema: z17.object({
10807
+ limit: z17.number().positive().optional(),
8195
10808
  order: jsonObjectSchema.optional(),
8196
10809
  where: jsonObjectSchema.optional()
8197
10810
  }),
@@ -8242,8 +10855,8 @@ query ListAutomations(
8242
10855
  createOperationSpec({
8243
10856
  operationName: "GetAutomations",
8244
10857
  kind: "query",
8245
- inputSchema: z2.object({
8246
- ids: z2.array(z2.string().min(1)).min(1)
10858
+ inputSchema: z17.object({
10859
+ ids: z17.array(z17.string().min(1)).min(1)
8247
10860
  }),
8248
10861
  cli: {
8249
10862
  name: "get-automations",
@@ -8260,8 +10873,10 @@ query ListAutomations(
8260
10873
  ]
8261
10874
  },
8262
10875
  mcp: { fileName: "automations.graphql" },
8263
- document: `# Query to fetch automations with flat fields only (no nested objects)
8264
- # Excludes config and agents for MCP tool simplicity
10876
+ document: `# Query to fetch automations with flat fields + sharedInputSchema.
10877
+ # sharedInputSchema is critical for cloning/migration and can't be inferred
10878
+ # from agents alone, so it's included by default in the composite read.
10879
+ # Other config fields (schedules, proxies, auth) stay excluded for simplicity.
8265
10880
  query GetAutomations($ids: [ID!]!) {
8266
10881
  automations(ids: $ids) {
8267
10882
  id
@@ -8273,124 +10888,628 @@ query GetAutomations($ids: [ID!]!) {
8273
10888
  lastSavedAt
8274
10889
  publishedVersionId
8275
10890
  draftVersionId
10891
+ config {
10892
+ sharedInputSchema {
10893
+ key
10894
+ value {
10895
+ schema
10896
+ sourceAgentId
10897
+ sourceLocation
10898
+ }
10899
+ }
10900
+ }
10901
+ }
10902
+ }`
10903
+ }),
10904
+ createOperationSpec({
10905
+ operationName: "GetAvailableCommands",
10906
+ kind: "query",
10907
+ inputSchema: z17.object({
10908
+ env: z17.string().min(1)
10909
+ }),
10910
+ cli: {
10911
+ name: "get-available-commands",
10912
+ path: ["catalog", "commands"],
10913
+ description: "Fetch available command definitions by environment.",
10914
+ resultKey: "availableCommands",
10915
+ options: [
10916
+ stringOption({
10917
+ inputKey: "env",
10918
+ flagName: "env",
10919
+ description: "Environment name.",
10920
+ required: true
10921
+ })
10922
+ ]
10923
+ },
10924
+ mcp: { fileName: "availableCommands.graphql" },
10925
+ document: `# Query to fetch available command definitions by environment
10926
+ query GetAvailableCommands($env: AvailableCommandsEnv!) {
10927
+ availableCommands(env: $env) {
10928
+ id
10929
+ description
10930
+ inputSchema
10931
+ }
10932
+ }`
10933
+ }),
10934
+ createOperationSpec({
10935
+ operationName: "GetAvailableModels",
10936
+ kind: "query",
10937
+ inputSchema: z17.object({
10938
+ agentId: z17.string().min(1)
10939
+ }),
10940
+ cli: {
10941
+ name: "get-available-models",
10942
+ path: ["catalog", "models"],
10943
+ description: "Fetch available model definitions for an agent.",
10944
+ resultKey: "availableModels",
10945
+ options: [
10946
+ stringOption({
10947
+ inputKey: "agentId",
10948
+ flagName: "agent-id",
10949
+ description: "Agent ID.",
10950
+ required: true
10951
+ })
10952
+ ]
10953
+ },
10954
+ mcp: { fileName: "availableModels.graphql" },
10955
+ document: `# Query to fetch available model definitions and pools for a specific agent
10956
+ query GetAvailableModels($agentId: String!) {
10957
+ availableModels(agentId: $agentId) {
10958
+ availableModelPools {
10959
+ name
10960
+ poolId
10961
+ models {
10962
+ id
10963
+ name
10964
+ description
10965
+ status
10966
+ provider
10967
+ }
10968
+ }
10969
+ allAvailableModels {
10970
+ id
10971
+ name
10972
+ description
10973
+ status
10974
+ provider
10975
+ }
10976
+ }
10977
+ }`
10978
+ }),
10979
+ createOperationSpec({
10980
+ operationName: "GetAvailableTools",
10981
+ kind: "query",
10982
+ inputSchema: z17.object({
10983
+ env: z17.string().min(1),
10984
+ automationId: z17.string().min(1).optional()
10985
+ }),
10986
+ cli: {
10987
+ name: "get-available-tools",
10988
+ path: ["catalog", "tools"],
10989
+ description: "Fetch available tool definitions by environment.",
10990
+ resultKey: "availableTools",
10991
+ options: [
10992
+ stringOption({
10993
+ inputKey: "env",
10994
+ flagName: "env",
10995
+ description: "Environment name.",
10996
+ required: true
10997
+ }),
10998
+ stringOption({
10999
+ inputKey: "automationId",
11000
+ flagName: "automation-id",
11001
+ description: "Optional automation ID."
11002
+ })
11003
+ ]
11004
+ },
11005
+ mcp: { fileName: "availableTools.graphql" },
11006
+ document: `# Query to fetch available tool definitions by environment
11007
+ query GetAvailableTools($env: AvailableCommandsEnv!, $automationId: String) {
11008
+ availableTools(env: $env, automationId: $automationId) {
11009
+ id
11010
+ description
11011
+ inputSchema
11012
+ }
11013
+ }`
11014
+ }),
11015
+ createOperationSpec({
11016
+ operationName: "GetFeatureFlagsContext",
11017
+ kind: "query",
11018
+ inputSchema: z17.object({
11019
+ flagKeys: z17.array(z17.string().min(1)).min(1).max(100).optional()
11020
+ }),
11021
+ cli: {
11022
+ name: "get-feature-flags-context",
11023
+ path: ["feature-flags", "context"],
11024
+ description: "Fetch current LaunchDarkly feature flag values for the selected org and current user.",
11025
+ resultKey: "featureFlagsContext",
11026
+ options: [
11027
+ stringArrayOption({
11028
+ inputKey: "flagKeys",
11029
+ flagName: "flag-keys",
11030
+ description: "Optional feature flag keys."
11031
+ })
11032
+ ]
11033
+ },
11034
+ mcp: { fileName: "featureFlagsContext.graphql" },
11035
+ document: `# Query to fetch current LaunchDarkly feature flag context
11036
+ query GetFeatureFlagsContext($flagKeys: [String!]) {
11037
+ featureFlagsContext(flagKeys: $flagKeys) {
11038
+ evaluatedAt
11039
+ organizationId
11040
+ contexts {
11041
+ organization {
11042
+ flags
11043
+ }
11044
+ user {
11045
+ id
11046
+ email
11047
+ flags
11048
+ }
11049
+ }
11050
+ }
11051
+ }`
11052
+ }),
11053
+ createOperationSpec({
11054
+ operationName: "GetAutomationWorkbenchCredentials",
11055
+ kind: "query",
11056
+ inputSchema: z17.object({}),
11057
+ cli: {
11058
+ name: "get-automation-workbench-credentials",
11059
+ path: ["workbench", "credentials"],
11060
+ description: "Fetch organization credential metadata for automation authoring. Secret values are never returned.",
11061
+ resultKey: "automationWorkbenchCredentials",
11062
+ options: []
11063
+ },
11064
+ mcp: { fileName: "automationWorkbenchCredentials.graphql" },
11065
+ document: `# Query organization credential metadata for automation authoring.
11066
+ # Secret values are never returned.
11067
+ query GetAutomationWorkbenchCredentials {
11068
+ automationWorkbenchCredentials {
11069
+ id
11070
+ type
11071
+ description
11072
+ hostname
11073
+ providerConfigKey
11074
+ availableFactors
11075
+ }
11076
+ }`
11077
+ }),
11078
+ createOperationSpec({
11079
+ operationName: "GetAutomationWorkbenchDiagnostics",
11080
+ kind: "query",
11081
+ inputSchema: z17.object({
11082
+ draftAutomationId: z17.string().min(1)
11083
+ }),
11084
+ cli: {
11085
+ name: "get-automation-workbench-diagnostics",
11086
+ path: ["workbench", "diagnostics"],
11087
+ description: "Fetch a compact draft automation graph plus workbench diagnostics.",
11088
+ resultKey: "automationWorkbenchDiagnostics",
11089
+ options: [
11090
+ stringOption({
11091
+ inputKey: "draftAutomationId",
11092
+ flagName: "draft-automation-id",
11093
+ description: "Draft automation ID.",
11094
+ required: true
11095
+ })
11096
+ ]
11097
+ },
11098
+ mcp: { fileName: "automationWorkbenchDiagnostics.graphql" },
11099
+ document: `# Query automation workbench diagnostics for a draft automation.
11100
+ query GetAutomationWorkbenchDiagnostics($draftAutomationId: ID!) {
11101
+ automationWorkbenchDiagnostics(draftAutomationId: $draftAutomationId) {
11102
+ summary {
11103
+ draftAutomationId
11104
+ name
11105
+ agentCount
11106
+ authenticationCount
11107
+ edgeCount
11108
+ rootAgentIds
11109
+ agents {
11110
+ id
11111
+ name
11112
+ type
11113
+ kind
11114
+ description
11115
+ instructions
11116
+ isTrigger
11117
+ childAgentIds
11118
+ parentAgentIds
11119
+ tools
11120
+ sharedInputKeys
11121
+ sharedOutputKeys
11122
+ referencedAgentIds
11123
+ }
11124
+ sharedInputSourceByKey {
11125
+ key
11126
+ sourceAgentId
11127
+ sourceLocation
11128
+ }
11129
+ }
11130
+ issues {
11131
+ severity
11132
+ code
11133
+ message
11134
+ agentId
11135
+ path
11136
+ relatedAgentIds
11137
+ }
8276
11138
  }
8277
11139
  }`
8278
11140
  }),
8279
11141
  createOperationSpec({
8280
- operationName: "GetAvailableCommands",
11142
+ operationName: "GetAutomationWorkbenchRunTrace",
8281
11143
  kind: "query",
8282
- inputSchema: z2.object({
8283
- env: z2.string().min(1)
11144
+ inputSchema: z17.object({
11145
+ automationRunId: z17.string().min(1),
11146
+ agentRunId: z17.string().min(1).optional(),
11147
+ limit: z17.number().int().positive().optional(),
11148
+ reverse: z17.boolean().optional()
8284
11149
  }),
8285
11150
  cli: {
8286
- name: "get-available-commands",
8287
- path: ["catalog", "commands"],
8288
- description: "Fetch available command definitions by environment.",
8289
- resultKey: "availableCommands",
11151
+ name: "get-automation-workbench-run-trace",
11152
+ path: ["workbench", "run-trace"],
11153
+ description: "Fetch a projected run trace with agent runs, child runs, iterations, and terminal blame.",
11154
+ resultKey: "automationWorkbenchRunTrace",
8290
11155
  options: [
8291
11156
  stringOption({
8292
- inputKey: "env",
8293
- flagName: "env",
8294
- description: "Environment name.",
11157
+ inputKey: "automationRunId",
11158
+ flagName: "automation-run-id",
11159
+ description: "Automation run ID.",
8295
11160
  required: true
11161
+ }),
11162
+ stringOption({
11163
+ inputKey: "agentRunId",
11164
+ flagName: "agent-run-id",
11165
+ description: "Optional agent run ID to focus iterations."
11166
+ }),
11167
+ numberOption({
11168
+ inputKey: "limit",
11169
+ flagName: "limit",
11170
+ description: "Maximum number of iterations to return."
11171
+ }),
11172
+ booleanOption({
11173
+ inputKey: "reverse",
11174
+ flagName: "reverse",
11175
+ description: "Return newest iterations first."
8296
11176
  })
8297
11177
  ]
8298
11178
  },
8299
- mcp: { fileName: "availableCommands.graphql" },
8300
- document: `# Query to fetch available command definitions by environment
8301
- query GetAvailableCommands($env: AvailableCommandsEnv!) {
8302
- availableCommands(env: $env) {
11179
+ mcp: { fileName: "automationWorkbenchRunTrace.graphql" },
11180
+ document: `# Query a compact run trace for workbench debug loops.
11181
+ query GetAutomationWorkbenchRunTrace(
11182
+ $automationRunId: ID!
11183
+ $agentRunId: ID
11184
+ $limit: Int
11185
+ $reverse: Boolean
11186
+ ) {
11187
+ automationWorkbenchRunTrace(
11188
+ automationRunId: $automationRunId
11189
+ agentRunId: $agentRunId
11190
+ limit: $limit
11191
+ reverse: $reverse
11192
+ ) {
8303
11193
  id
8304
- description
8305
- inputSchema
11194
+ automationId
11195
+ status
11196
+ statusDetail
11197
+ summary
11198
+ debugUrl
11199
+ startedAt
11200
+ finishedAt
11201
+ truncated
11202
+ terminal {
11203
+ status
11204
+ detail
11205
+ lastNodeId
11206
+ blameNodeId
11207
+ }
11208
+ agentRuns {
11209
+ id
11210
+ agentId
11211
+ agentVersionId
11212
+ agentName
11213
+ parentAgentRunId
11214
+ status
11215
+ statusDetail
11216
+ iterations {
11217
+ id
11218
+ sequence
11219
+ agentRunId
11220
+ tMs
11221
+ durationMs
11222
+ llmDurationMs
11223
+ reasoning
11224
+ reasoningStatus
11225
+ toolCall {
11226
+ toolCallId
11227
+ toolName
11228
+ targetAgentId
11229
+ targetAgentName
11230
+ targetAgentIds
11231
+ targetAgentNames
11232
+ }
11233
+ toolResult {
11234
+ status
11235
+ message
11236
+ }
11237
+ screenshotUrl
11238
+ errorMessage
11239
+ }
11240
+ childRuns {
11241
+ id
11242
+ agentId
11243
+ agentVersionId
11244
+ agentName
11245
+ parentAgentRunId
11246
+ status
11247
+ statusDetail
11248
+ iterations {
11249
+ id
11250
+ sequence
11251
+ agentRunId
11252
+ tMs
11253
+ durationMs
11254
+ llmDurationMs
11255
+ reasoning
11256
+ reasoningStatus
11257
+ toolCall {
11258
+ toolCallId
11259
+ toolName
11260
+ targetAgentId
11261
+ targetAgentName
11262
+ targetAgentIds
11263
+ targetAgentNames
11264
+ }
11265
+ toolResult {
11266
+ status
11267
+ message
11268
+ }
11269
+ screenshotUrl
11270
+ errorMessage
11271
+ }
11272
+ }
11273
+ }
8306
11274
  }
8307
11275
  }`
8308
11276
  }),
8309
11277
  createOperationSpec({
8310
- operationName: "GetAvailableModels",
11278
+ operationName: "GetAutomationWorkbenchAwaitRunCompletion",
8311
11279
  kind: "query",
8312
- inputSchema: z2.object({
8313
- agentId: z2.string().min(1)
11280
+ inputSchema: z17.object({
11281
+ automationRunId: z17.string().min(1),
11282
+ timeoutMs: z17.number().int().min(1e3).max(6e4).optional(),
11283
+ sinceSequence: z17.number().int().min(0).optional(),
11284
+ agentRunId: z17.string().min(1).optional(),
11285
+ limit: z17.number().int().positive().optional(),
11286
+ reverse: z17.boolean().optional()
8314
11287
  }),
8315
11288
  cli: {
8316
- name: "get-available-models",
8317
- path: ["catalog", "models"],
8318
- description: "Fetch available model definitions for an agent.",
8319
- resultKey: "availableModels",
11289
+ name: "await-automation-workbench-run-completion",
11290
+ path: ["workbench", "await"],
11291
+ description: "Long-poll: block until the run is terminal/paused or timeout elapses, then return the projected trace plus poll stats.",
11292
+ resultKey: "automationWorkbenchAwaitRunCompletion",
8320
11293
  options: [
8321
11294
  stringOption({
8322
- inputKey: "agentId",
8323
- flagName: "agent-id",
8324
- description: "Agent ID.",
11295
+ inputKey: "automationRunId",
11296
+ flagName: "automation-run-id",
11297
+ description: "Automation run ID to wait on.",
8325
11298
  required: true
11299
+ }),
11300
+ numberOption({
11301
+ inputKey: "timeoutMs",
11302
+ flagName: "timeout-ms",
11303
+ description: "Server-side wait cap, in ms. Clamped to [1000, 60000]. Defaults to 30000."
11304
+ }),
11305
+ numberOption({
11306
+ inputKey: "sinceSequence",
11307
+ flagName: "since-sequence",
11308
+ description: "Wake also when any iteration with sequence > sinceSequence appears (incremental polling)."
11309
+ }),
11310
+ stringOption({
11311
+ inputKey: "agentRunId",
11312
+ flagName: "agent-run-id",
11313
+ description: "Optional agent run ID to focus iterations."
11314
+ }),
11315
+ numberOption({
11316
+ inputKey: "limit",
11317
+ flagName: "limit",
11318
+ description: "Maximum iterations to return per agent run."
11319
+ }),
11320
+ booleanOption({
11321
+ inputKey: "reverse",
11322
+ flagName: "reverse",
11323
+ description: "Return newest iterations first."
8326
11324
  })
8327
11325
  ]
8328
11326
  },
8329
- mcp: { fileName: "availableModels.graphql" },
8330
- document: `# Query to fetch available model definitions and pools for a specific agent
8331
- query GetAvailableModels($agentId: String!) {
8332
- availableModels(agentId: $agentId) {
8333
- availableModelPools {
8334
- name
8335
- poolId
8336
- models {
11327
+ mcp: { fileName: "automationWorkbenchAwaitRunCompletion.graphql" },
11328
+ document: `# Long-poll for run completion. Server holds the request open until the run
11329
+ # reaches a terminal/paused state or timeout elapses, then returns the same
11330
+ # projected trace shape as automationWorkbenchRunTrace plus poll stats.
11331
+ query GetAutomationWorkbenchAwaitRunCompletion(
11332
+ $automationRunId: ID!
11333
+ $timeoutMs: Int
11334
+ $sinceSequence: Int
11335
+ $agentRunId: ID
11336
+ $limit: Int
11337
+ $reverse: Boolean
11338
+ ) {
11339
+ automationWorkbenchAwaitRunCompletion(
11340
+ automationRunId: $automationRunId
11341
+ timeoutMs: $timeoutMs
11342
+ sinceSequence: $sinceSequence
11343
+ agentRunId: $agentRunId
11344
+ limit: $limit
11345
+ reverse: $reverse
11346
+ ) {
11347
+ reachedTerminal
11348
+ reachedSinceSequence
11349
+ pollCount
11350
+ elapsedMs
11351
+ trace {
11352
+ id
11353
+ automationId
11354
+ status
11355
+ statusDetail
11356
+ summary
11357
+ debugUrl
11358
+ startedAt
11359
+ finishedAt
11360
+ truncated
11361
+ terminal {
11362
+ status
11363
+ detail
11364
+ lastNodeId
11365
+ blameNodeId
11366
+ }
11367
+ agentRuns {
8337
11368
  id
8338
- name
8339
- description
11369
+ agentId
11370
+ agentVersionId
11371
+ agentName
11372
+ parentAgentRunId
8340
11373
  status
8341
- provider
11374
+ statusDetail
11375
+ iterations {
11376
+ id
11377
+ sequence
11378
+ agentRunId
11379
+ tMs
11380
+ durationMs
11381
+ llmDurationMs
11382
+ reasoning
11383
+ reasoningStatus
11384
+ toolCall {
11385
+ toolCallId
11386
+ toolName
11387
+ targetAgentId
11388
+ targetAgentName
11389
+ targetAgentIds
11390
+ targetAgentNames
11391
+ }
11392
+ toolResult {
11393
+ status
11394
+ message
11395
+ }
11396
+ screenshotUrl
11397
+ errorMessage
11398
+ }
11399
+ childRuns {
11400
+ id
11401
+ agentId
11402
+ agentVersionId
11403
+ agentName
11404
+ parentAgentRunId
11405
+ status
11406
+ statusDetail
11407
+ iterations {
11408
+ id
11409
+ sequence
11410
+ agentRunId
11411
+ tMs
11412
+ durationMs
11413
+ llmDurationMs
11414
+ reasoning
11415
+ reasoningStatus
11416
+ toolCall {
11417
+ toolCallId
11418
+ toolName
11419
+ targetAgentId
11420
+ targetAgentName
11421
+ targetAgentIds
11422
+ targetAgentNames
11423
+ }
11424
+ toolResult {
11425
+ status
11426
+ message
11427
+ }
11428
+ screenshotUrl
11429
+ errorMessage
11430
+ }
11431
+ }
8342
11432
  }
8343
11433
  }
8344
- allAvailableModels {
8345
- id
8346
- name
8347
- description
8348
- status
8349
- provider
8350
- }
8351
11434
  }
8352
11435
  }`
8353
11436
  }),
8354
11437
  createOperationSpec({
8355
- operationName: "GetAvailableTools",
11438
+ operationName: "GetAutomationWorkbenchSchemaSuggestions",
8356
11439
  kind: "query",
8357
- inputSchema: z2.object({
8358
- env: z2.string().min(1),
8359
- automationId: z2.string().min(1).optional()
11440
+ inputSchema: z17.object({
11441
+ automationRunId: z17.string().min(1),
11442
+ draftAutomationId: z17.string().min(1).optional(),
11443
+ minConfidence: z17.number().min(0).max(1).optional(),
11444
+ includeSensitive: z17.boolean().optional()
8360
11445
  }),
8361
11446
  cli: {
8362
- name: "get-available-tools",
8363
- path: ["catalog", "tools"],
8364
- description: "Fetch available tool definitions by environment.",
8365
- resultKey: "availableTools",
11447
+ name: "get-automation-workbench-schema-suggestions",
11448
+ path: ["workbench", "schema-suggestions"],
11449
+ description: "Heuristic suggestions for schema fields the agent observed on browser pages but were not declared in the input schema.",
11450
+ resultKey: "automationWorkbenchSchemaSuggestions",
8366
11451
  options: [
8367
11452
  stringOption({
8368
- inputKey: "env",
8369
- flagName: "env",
8370
- description: "Environment name.",
11453
+ inputKey: "automationRunId",
11454
+ flagName: "automation-run-id",
11455
+ description: "Automation run to analyze.",
8371
11456
  required: true
8372
11457
  }),
8373
11458
  stringOption({
8374
- inputKey: "automationId",
8375
- flagName: "automation-id",
8376
- description: "Optional automation ID."
11459
+ inputKey: "draftAutomationId",
11460
+ flagName: "draft-automation-id",
11461
+ description: "Optional draft automation ID. Defaults to the run's automationId."
11462
+ }),
11463
+ numberOption({
11464
+ inputKey: "minConfidence",
11465
+ flagName: "min-confidence",
11466
+ description: "Suggestions below this 0..1 confidence score are filtered out. Default 0.6."
11467
+ }),
11468
+ booleanOption({
11469
+ inputKey: "includeSensitive",
11470
+ flagName: "include-sensitive",
11471
+ description: "Include suggestions for fields whose label looks like PII (SSN, password, card number). Default false."
8377
11472
  })
8378
11473
  ]
8379
11474
  },
8380
- mcp: { fileName: "availableTools.graphql" },
8381
- document: `# Query to fetch available tool definitions by environment
8382
- query GetAvailableTools($env: AvailableCommandsEnv!, $automationId: String) {
8383
- availableTools(env: $env, automationId: $automationId) {
8384
- id
8385
- description
8386
- inputSchema
11475
+ mcp: { fileName: "automationWorkbenchSchemaSuggestions.graphql" },
11476
+ document: `# Heuristic schema-coverage suggestions: form fields observed on the page that
11477
+ # are not declared in any input schema, returned with evidence for verification.
11478
+ query GetAutomationWorkbenchSchemaSuggestions(
11479
+ $automationRunId: ID!
11480
+ $draftAutomationId: ID
11481
+ $minConfidence: Float
11482
+ $includeSensitive: Boolean
11483
+ ) {
11484
+ automationWorkbenchSchemaSuggestions(
11485
+ automationRunId: $automationRunId
11486
+ draftAutomationId: $draftAutomationId
11487
+ minConfidence: $minConfidence
11488
+ includeSensitive: $includeSensitive
11489
+ ) {
11490
+ kind
11491
+ fieldName
11492
+ fieldLabel
11493
+ fieldType
11494
+ fieldDescription
11495
+ required
11496
+ confidence
11497
+ reason
11498
+ evidence {
11499
+ iterationId
11500
+ agentRunId
11501
+ agentName
11502
+ markId
11503
+ fieldText
11504
+ screenshotUrl
11505
+ }
8387
11506
  }
8388
11507
  }`
8389
11508
  }),
8390
11509
  createOperationSpec({
8391
11510
  operationName: "CreateAutomation",
8392
11511
  kind: "mutation",
8393
- inputSchema: z2.object({
11512
+ inputSchema: z17.object({
8394
11513
  input: jsonObjectSchema
8395
11514
  }),
8396
11515
  cli: {
@@ -8427,7 +11546,7 @@ mutation CreateAutomation($input: CreateAutomationInput!) {
8427
11546
  createOperationSpec({
8428
11547
  operationName: "GetGraphqlSchema",
8429
11548
  kind: "query",
8430
- inputSchema: z2.object({}),
11549
+ inputSchema: z17.object({}),
8431
11550
  cli: {
8432
11551
  name: "get-graphql-schema",
8433
11552
  path: ["graphql", "schema"],
@@ -8448,8 +11567,8 @@ query GetGraphqlSchema {
8448
11567
  createOperationSpec({
8449
11568
  operationName: "PauseAutomationRun",
8450
11569
  kind: "mutation",
8451
- inputSchema: z2.object({
8452
- automationRunId: z2.string().min(1)
11570
+ inputSchema: z17.object({
11571
+ automationRunId: z17.string().min(1)
8453
11572
  }),
8454
11573
  cli: {
8455
11574
  name: "pause-automation-run",
@@ -8474,10 +11593,10 @@ mutation PauseAutomationRun($automationRunId: ID!) {
8474
11593
  createOperationSpec({
8475
11594
  operationName: "RerunAutomation",
8476
11595
  kind: "mutation",
8477
- inputSchema: z2.object({
8478
- automationRunId: z2.string().min(1),
8479
- additionalPrompt: z2.string().min(1).optional(),
8480
- idempotencyKey: z2.string().min(1)
11596
+ inputSchema: z17.object({
11597
+ automationRunId: z17.string().min(1),
11598
+ additionalPrompt: z17.string().min(1).optional(),
11599
+ idempotencyKey: z17.string().min(1)
8481
11600
  }),
8482
11601
  cli: {
8483
11602
  name: "rerun-automation",
@@ -8525,9 +11644,9 @@ mutation RerunAutomation(
8525
11644
  createOperationSpec({
8526
11645
  operationName: "ResumeAutomationRun",
8527
11646
  kind: "mutation",
8528
- inputSchema: z2.object({
8529
- automationRunId: z2.string().min(1),
8530
- message: z2.string().min(1).optional()
11647
+ inputSchema: z17.object({
11648
+ automationRunId: z17.string().min(1),
11649
+ message: z17.string().min(1).optional()
8531
11650
  }),
8532
11651
  cli: {
8533
11652
  name: "resume-automation-run",
@@ -8557,12 +11676,14 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
8557
11676
  createOperationSpec({
8558
11677
  operationName: "RunDraftAutomation",
8559
11678
  kind: "mutation",
8560
- inputSchema: z2.object({
8561
- draftAutomationId: z2.string().min(1),
8562
- agentId: z2.string().min(1),
8563
- idempotencyKey: z2.string().min(1),
8564
- input: z2.unknown().optional(),
8565
- additionalPrompt: z2.string().min(1).optional()
11679
+ inputSchema: z17.object({
11680
+ draftAutomationId: z17.string().min(1),
11681
+ agentId: z17.string().min(1),
11682
+ idempotencyKey: z17.string().min(1),
11683
+ input: z17.unknown().optional(),
11684
+ config: automationRunStartConfigSchema.partial().passthrough().optional(),
11685
+ additionalPrompt: z17.string().min(1).optional(),
11686
+ consistencyCheckCount: z17.number().int().optional()
8566
11687
  }),
8567
11688
  cli: {
8568
11689
  name: "run-draft-automation",
@@ -8593,10 +11714,20 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
8593
11714
  flagName: "input-json",
8594
11715
  description: "Optional JSON input payload."
8595
11716
  }),
11717
+ jsonOption({
11718
+ inputKey: "config",
11719
+ flagName: "config-json",
11720
+ description: 'Optional run config payload, for example {"startInTakeOverMode":true,"approvalMode":"HUMAN_APPROVAL","consistencyCheckCount":3}.'
11721
+ }),
8596
11722
  stringOption({
8597
11723
  inputKey: "additionalPrompt",
8598
11724
  flagName: "additional-prompt",
8599
11725
  description: "Optional prompt appended to the run."
11726
+ }),
11727
+ numberOption({
11728
+ inputKey: "consistencyCheckCount",
11729
+ flagName: "consistency-check-count",
11730
+ description: "Optional consistency-check copy count for draft iteration runs."
8600
11731
  })
8601
11732
  ]
8602
11733
  },
@@ -8608,14 +11739,18 @@ mutation RunDraftAutomation(
8608
11739
  $agentId: ID!
8609
11740
  $idempotencyKey: String!
8610
11741
  $input: JSON
11742
+ $config: AutomationRunConfigInput
8611
11743
  $additionalPrompt: String
11744
+ $consistencyCheckCount: Int
8612
11745
  ) {
8613
11746
  runDraftAutomation(
8614
11747
  draftAutomationId: $draftAutomationId
8615
11748
  agentId: $agentId
8616
11749
  idempotencyKey: $idempotencyKey
8617
11750
  input: $input
11751
+ config: $config
8618
11752
  additionalPrompt: $additionalPrompt
11753
+ consistencyCheckCount: $consistencyCheckCount
8619
11754
  ) {
8620
11755
  automationRunId
8621
11756
  workflowId
@@ -8626,8 +11761,8 @@ mutation RunDraftAutomation(
8626
11761
  createOperationSpec({
8627
11762
  operationName: "StopAutomationRun",
8628
11763
  kind: "mutation",
8629
- inputSchema: z2.object({
8630
- automationRunId: z2.string().min(1)
11764
+ inputSchema: z17.object({
11765
+ automationRunId: z17.string().min(1)
8631
11766
  }),
8632
11767
  cli: {
8633
11768
  name: "stop-automation-run",
@@ -8647,13 +11782,211 @@ mutation RunDraftAutomation(
8647
11782
  document: `# Mutation to stop an automation run
8648
11783
  mutation StopAutomationRun($automationRunId: ID!) {
8649
11784
  stopAutomationRun(automationRunId: $automationRunId)
11785
+ }`
11786
+ }),
11787
+ createOperationSpec({
11788
+ operationName: "PreviewAutomationPatch",
11789
+ kind: "mutation",
11790
+ inputSchema: z17.object({
11791
+ draftAutomationId: z17.string().min(1),
11792
+ expectedLastSavedAt: z17.string().optional(),
11793
+ operations: z17.array(z17.unknown()).min(1)
11794
+ }),
11795
+ cli: {
11796
+ name: "preview-automation-patch",
11797
+ path: ["workbench", "patch", "preview"],
11798
+ description: "Preview semantic workbench patch operations without saving the draft.",
11799
+ resultKey: "previewAutomationPatch",
11800
+ options: [
11801
+ stringOption({
11802
+ inputKey: "draftAutomationId",
11803
+ flagName: "draft-automation-id",
11804
+ description: "Draft automation ID.",
11805
+ required: true
11806
+ }),
11807
+ jsonOption({
11808
+ inputKey: "operations",
11809
+ flagName: "operations-json",
11810
+ description: "Automation patch operations array using AutomationWorkbenchPatchOperationInput oneOf shape.",
11811
+ required: true
11812
+ })
11813
+ ]
11814
+ },
11815
+ mcp: { fileName: "previewAutomationPatch.graphql" },
11816
+ document: `# Preview semantic automation patch operations without writing.
11817
+ mutation PreviewAutomationPatch(
11818
+ $draftAutomationId: ID!
11819
+ $operations: [AutomationWorkbenchPatchOperationInput!]!
11820
+ ) {
11821
+ previewAutomationPatch(
11822
+ draftAutomationId: $draftAutomationId
11823
+ operations: $operations
11824
+ ) {
11825
+ draftAutomationId
11826
+ applied
11827
+ updateInput
11828
+ before {
11829
+ name
11830
+ agentCount
11831
+ edgeCount
11832
+ rootAgentIds
11833
+ agents {
11834
+ id
11835
+ name
11836
+ type
11837
+ kind
11838
+ tools
11839
+ childAgentIds
11840
+ parentAgentIds
11841
+ sharedInputKeys
11842
+ sharedOutputKeys
11843
+ }
11844
+ sharedInputSourceByKey {
11845
+ key
11846
+ sourceAgentId
11847
+ sourceLocation
11848
+ }
11849
+ }
11850
+ after {
11851
+ name
11852
+ agentCount
11853
+ edgeCount
11854
+ rootAgentIds
11855
+ agents {
11856
+ id
11857
+ name
11858
+ type
11859
+ kind
11860
+ tools
11861
+ childAgentIds
11862
+ parentAgentIds
11863
+ sharedInputKeys
11864
+ sharedOutputKeys
11865
+ }
11866
+ sharedInputSourceByKey {
11867
+ key
11868
+ sourceAgentId
11869
+ sourceLocation
11870
+ }
11871
+ }
11872
+ issues {
11873
+ severity
11874
+ code
11875
+ message
11876
+ agentId
11877
+ path
11878
+ relatedAgentIds
11879
+ }
11880
+ }
11881
+ }`
11882
+ }),
11883
+ createOperationSpec({
11884
+ operationName: "ApplyAutomationPatch",
11885
+ kind: "mutation",
11886
+ inputSchema: z17.object({
11887
+ draftAutomationId: z17.string().min(1),
11888
+ operations: z17.array(z17.unknown()).min(1)
11889
+ }),
11890
+ cli: {
11891
+ name: "apply-automation-patch",
11892
+ path: ["workbench", "patch", "apply"],
11893
+ description: "Apply semantic workbench patch operations through the versioned save path.",
11894
+ resultKey: "applyAutomationPatch",
11895
+ options: [
11896
+ stringOption({
11897
+ inputKey: "draftAutomationId",
11898
+ flagName: "draft-automation-id",
11899
+ description: "Draft automation ID.",
11900
+ required: true
11901
+ }),
11902
+ jsonOption({
11903
+ inputKey: "operations",
11904
+ flagName: "operations-json",
11905
+ description: "Automation patch operations array using AutomationWorkbenchPatchOperationInput oneOf shape.",
11906
+ required: true
11907
+ }),
11908
+ stringOption({
11909
+ inputKey: "expectedLastSavedAt",
11910
+ flagName: "expected-last-saved-at",
11911
+ description: "Optional optimistic concurrency guard timestamp."
11912
+ })
11913
+ ]
11914
+ },
11915
+ mcp: { fileName: "applyAutomationPatch.graphql" },
11916
+ document: `# Apply semantic automation patch operations through the versioned save path.
11917
+ mutation ApplyAutomationPatch(
11918
+ $draftAutomationId: ID!
11919
+ $operations: [AutomationWorkbenchPatchOperationInput!]!
11920
+ $expectedLastSavedAt: String
11921
+ ) {
11922
+ applyAutomationPatch(
11923
+ draftAutomationId: $draftAutomationId
11924
+ operations: $operations
11925
+ expectedLastSavedAt: $expectedLastSavedAt
11926
+ ) {
11927
+ draftAutomationId
11928
+ applied
11929
+ updateInput
11930
+ before {
11931
+ name
11932
+ agentCount
11933
+ edgeCount
11934
+ rootAgentIds
11935
+ agents {
11936
+ id
11937
+ name
11938
+ type
11939
+ kind
11940
+ tools
11941
+ childAgentIds
11942
+ parentAgentIds
11943
+ sharedInputKeys
11944
+ sharedOutputKeys
11945
+ }
11946
+ sharedInputSourceByKey {
11947
+ key
11948
+ sourceAgentId
11949
+ sourceLocation
11950
+ }
11951
+ }
11952
+ after {
11953
+ name
11954
+ agentCount
11955
+ edgeCount
11956
+ rootAgentIds
11957
+ agents {
11958
+ id
11959
+ name
11960
+ type
11961
+ kind
11962
+ tools
11963
+ childAgentIds
11964
+ parentAgentIds
11965
+ sharedInputKeys
11966
+ sharedOutputKeys
11967
+ }
11968
+ sharedInputSourceByKey {
11969
+ key
11970
+ sourceAgentId
11971
+ sourceLocation
11972
+ }
11973
+ }
11974
+ issues {
11975
+ severity
11976
+ code
11977
+ message
11978
+ agentId
11979
+ path
11980
+ relatedAgentIds
11981
+ }
11982
+ }
8650
11983
  }`
8651
11984
  }),
8652
11985
  createOperationSpec({
8653
11986
  operationName: "UpdateAutomationById",
8654
11987
  kind: "mutation",
8655
- inputSchema: z2.object({
8656
- id: z2.string().min(1),
11988
+ inputSchema: z17.object({
11989
+ id: z17.string().min(1),
8657
11990
  input: jsonObjectSchema
8658
11991
  }),
8659
11992
  cli: {
@@ -8694,58 +12027,58 @@ mutation UpdateAutomationById($id: ID!, $input: UpdateAutomationInput!) {
8694
12027
  import { Command as Command2, InvalidArgumentError as InvalidArgumentError2, Option as Option2 } from "commander";
8695
12028
 
8696
12029
  // src/api.ts
8697
- import { z as z3 } from "zod";
12030
+ import { z as z18 } from "zod";
8698
12031
  var OTTO_AUTHORIZATION_HEADER_NAME = "X-Otto-Authorization";
8699
12032
  var OTTO_AUTHORIZATION_ISSUER = "magical:otto";
8700
- var workosOrganizationsResponseSchema = z3.object({
8701
- organizations: z3.array(
8702
- z3.object({
8703
- id: z3.string().min(1),
8704
- name: z3.string().min(1),
8705
- primaryDomain: z3.string().nullable().optional()
12033
+ var workosOrganizationsResponseSchema = z18.object({
12034
+ organizations: z18.array(
12035
+ z18.object({
12036
+ id: z18.string().min(1),
12037
+ name: z18.string().min(1),
12038
+ primaryDomain: z18.string().nullable().optional()
8706
12039
  })
8707
12040
  ),
8708
- success: z3.boolean()
12041
+ success: z18.boolean()
8709
12042
  });
8710
- var workosUserSchema = z3.object({
8711
- email: z3.string().nullable(),
8712
- id: z3.string().min(1)
12043
+ var workosUserSchema = z18.object({
12044
+ email: z18.string().nullable(),
12045
+ id: z18.string().min(1)
8713
12046
  });
8714
- var nangoIntegrationWireSchema = z3.object({
12047
+ var nangoIntegrationWireSchema = z18.object({
8715
12048
  // eslint-disable-next-line @typescript-eslint/naming-convention -- mirrors Nango REST payload
8716
- unique_key: z3.string().min(1)
12049
+ unique_key: z18.string().min(1)
8717
12050
  }).passthrough().transform((data) => ({
8718
12051
  ...data,
8719
12052
  uniqueKey: data.unique_key
8720
12053
  }));
8721
- var nangoIntegrationsResponseSchema = z3.array(nangoIntegrationWireSchema);
8722
- var organizationAuthenticationSchema = z3.object({
8723
- id: z3.string().min(1),
8724
- type: z3.string().min(1),
8725
- connectionId: z3.string().nullable().optional(),
8726
- providerConfigKey: z3.string().nullable().optional(),
8727
- description: z3.string().nullable().optional(),
8728
- hostname: z3.string().nullable().optional()
12054
+ var nangoIntegrationsResponseSchema = z18.array(nangoIntegrationWireSchema);
12055
+ var organizationAuthenticationSchema = z18.object({
12056
+ id: z18.string().min(1),
12057
+ type: z18.string().min(1),
12058
+ connectionId: z18.string().nullable().optional(),
12059
+ providerConfigKey: z18.string().nullable().optional(),
12060
+ description: z18.string().nullable().optional(),
12061
+ hostname: z18.string().nullable().optional()
8729
12062
  }).passthrough();
8730
- var organizationAuthenticationsResponseSchema = z3.object({
8731
- authentications: z3.array(organizationAuthenticationSchema),
8732
- success: z3.boolean()
8733
- });
8734
- var graphQlResponseSchema = z3.object({
8735
- data: z3.record(z3.string(), z3.unknown()).optional(),
8736
- errors: z3.array(
8737
- z3.object({
8738
- message: z3.string().min(1)
12063
+ var organizationAuthenticationsResponseSchema = z18.object({
12064
+ authentications: z18.array(organizationAuthenticationSchema),
12065
+ success: z18.boolean()
12066
+ });
12067
+ var graphQlResponseSchema = z18.object({
12068
+ data: z18.record(z18.string(), z18.unknown()).optional(),
12069
+ errors: z18.array(
12070
+ z18.object({
12071
+ message: z18.string().min(1)
8739
12072
  })
8740
12073
  ).optional()
8741
12074
  });
8742
- var apiErrorResponseSchema = z3.object({
8743
- errors: z3.array(
8744
- z3.object({
8745
- message: z3.string().min(1)
12075
+ var apiErrorResponseSchema = z18.object({
12076
+ errors: z18.array(
12077
+ z18.object({
12078
+ message: z18.string().min(1)
8746
12079
  })
8747
12080
  ).optional(),
8748
- message: z3.string().min(1).optional()
12081
+ message: z18.string().min(1).optional()
8749
12082
  });
8750
12083
  function getApiErrorDetail(responseBody) {
8751
12084
  const parsedResponse = apiErrorResponseSchema.safeParse(responseBody);
@@ -9032,10 +12365,10 @@ function requireWorkosClientId(config) {
9032
12365
  // src/settings.ts
9033
12366
  import { mkdir, readFile, rm, writeFile } from "fs/promises";
9034
12367
  import path2 from "path";
9035
- import { z as z4 } from "zod";
9036
- var cliSettingsSchema = z4.object({
9037
- env: z4.object({
9038
- baseUrl: z4.url().optional()
12368
+ import { z as z19 } from "zod";
12369
+ var cliSettingsSchema = z19.object({
12370
+ env: z19.object({
12371
+ baseUrl: z19.url().optional()
9039
12372
  }).default({})
9040
12373
  });
9041
12374
  function createEmptyCliSettings() {
@@ -9278,22 +12611,6 @@ function resolveOpenCommand(url) {
9278
12611
 
9279
12612
  // src/program-session.ts
9280
12613
  import { readFile as readFile2, rm as rm2 } from "fs/promises";
9281
-
9282
- // ../common/dist/src/stdlib/url.utils.js
9283
- var import_handlebars = __toESM(require_lib(), 1);
9284
- function safeUrlConstructor(url, baseUrl) {
9285
- try {
9286
- return Ok(baseUrl ? new URL(url, baseUrl) : new URL(url));
9287
- } catch {
9288
- return Err({
9289
- type: "invalid-url",
9290
- message: `Invalid URL`,
9291
- url
9292
- });
9293
- }
9294
- }
9295
-
9296
- // src/program-session.ts
9297
12614
  async function withOrgScopedAccessToken({
9298
12615
  dependencies,
9299
12616
  organizationId,
@@ -9653,24 +12970,24 @@ ${formatExamples("Examples", [
9653
12970
  // src/state.ts
9654
12971
  import { mkdir as mkdir2, readFile as readFile3, rm as rm3, writeFile as writeFile2 } from "fs/promises";
9655
12972
  import path4 from "path";
9656
- import { z as z5 } from "zod";
9657
- var cliAccountSchema = z5.object({
9658
- clientId: z5.string().min(1),
9659
- email: z5.string().nullable(),
9660
- userId: z5.string().min(1)
9661
- });
9662
- var cliOrganizationSchema = z5.object({
9663
- id: z5.string().min(1),
9664
- name: z5.string().min(1),
9665
- primaryDomain: z5.string().nullable().default(null)
9666
- });
9667
- var cliStateSchema = z5.object({
12973
+ import { z as z20 } from "zod";
12974
+ var cliAccountSchema = z20.object({
12975
+ clientId: z20.string().min(1),
12976
+ email: z20.string().nullable(),
12977
+ userId: z20.string().min(1)
12978
+ });
12979
+ var cliOrganizationSchema = z20.object({
12980
+ id: z20.string().min(1),
12981
+ name: z20.string().min(1),
12982
+ primaryDomain: z20.string().nullable().default(null)
12983
+ });
12984
+ var cliStateSchema = z20.object({
9668
12985
  account: cliAccountSchema,
9669
- defaultOrgId: z5.string().nullable(),
9670
- lastUsedOrgId: z5.string().nullable(),
9671
- organizations: z5.array(cliOrganizationSchema)
12986
+ defaultOrgId: z20.string().nullable(),
12987
+ lastUsedOrgId: z20.string().nullable(),
12988
+ organizations: z20.array(cliOrganizationSchema)
9672
12989
  });
9673
- var refreshTokenFileSchema = z5.record(z5.string(), z5.string());
12990
+ var refreshTokenFileSchema = z20.record(z20.string(), z20.string());
9674
12991
  function createFileStateStore(stateFilePath) {
9675
12992
  return {
9676
12993
  async clear() {
@@ -9783,37 +13100,37 @@ if (typeof cliPackageVersion !== "string" || cliPackageVersion.length === 0) {
9783
13100
  var CLI_VERSION = cliPackageVersion;
9784
13101
 
9785
13102
  // src/workos-auth.ts
9786
- import { z as z6 } from "zod";
13103
+ import { z as z21 } from "zod";
9787
13104
  var DEFAULT_DEVICE_POLL_INTERVAL_SECONDS = 5;
9788
13105
  function buildFormHeaders() {
9789
13106
  const headers = new Headers();
9790
13107
  headers.set("content-type", "application/x-www-form-urlencoded");
9791
13108
  return headers;
9792
13109
  }
9793
- var deviceAuthorizationSchema = z6.object({
9794
- device_code: z6.string().min(1),
9795
- expires_in: z6.number().int().positive().optional(),
9796
- interval: z6.number().int().positive().optional(),
9797
- user_code: z6.string().min(1),
9798
- verification_uri: z6.url(),
9799
- verification_uri_complete: z6.url().optional()
9800
- });
9801
- var tokenResponseSchema = z6.object({
9802
- access_token: z6.string().min(1),
9803
- expires_in: z6.number().int().positive().optional(),
9804
- refresh_token: z6.string().min(1),
9805
- token_type: z6.string().optional()
9806
- });
9807
- var tokenErrorSchema = z6.object({
9808
- error: z6.string().min(1),
9809
- error_description: z6.string().optional()
9810
- });
9811
- var accessTokenClaimsSchema = z6.object({
9812
- exp: z6.number().int().positive().optional(),
9813
- iss: z6.string().min(1).optional(),
9814
- org_id: z6.string().min(1).optional(),
9815
- sid: z6.string().min(1).optional(),
9816
- sub: z6.string().min(1)
13110
+ var deviceAuthorizationSchema = z21.object({
13111
+ device_code: z21.string().min(1),
13112
+ expires_in: z21.number().int().positive().optional(),
13113
+ interval: z21.number().int().positive().optional(),
13114
+ user_code: z21.string().min(1),
13115
+ verification_uri: z21.url(),
13116
+ verification_uri_complete: z21.url().optional()
13117
+ });
13118
+ var tokenResponseSchema = z21.object({
13119
+ access_token: z21.string().min(1),
13120
+ expires_in: z21.number().int().positive().optional(),
13121
+ refresh_token: z21.string().min(1),
13122
+ token_type: z21.string().optional()
13123
+ });
13124
+ var tokenErrorSchema = z21.object({
13125
+ error: z21.string().min(1),
13126
+ error_description: z21.string().optional()
13127
+ });
13128
+ var accessTokenClaimsSchema = z21.object({
13129
+ exp: z21.number().int().positive().optional(),
13130
+ iss: z21.string().min(1).optional(),
13131
+ org_id: z21.string().min(1).optional(),
13132
+ sid: z21.string().min(1).optional(),
13133
+ sub: z21.string().min(1)
9817
13134
  });
9818
13135
  function createWorkosAuthClient({
9819
13136
  fetchFn = fetch,