@getmagical/cli 0.1.16 → 0.1.17

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) {
@@ -3658,7 +3818,7 @@ var require_base64_vlq = __commonJS({
3658
3818
  });
3659
3819
 
3660
3820
  // ../../node_modules/source-map/lib/util.js
3661
- var require_util = __commonJS({
3821
+ var require_util2 = __commonJS({
3662
3822
  "../../node_modules/source-map/lib/util.js"(exports) {
3663
3823
  "use strict";
3664
3824
  function getArg(aArgs, aName, aDefaultValue) {
@@ -3806,8 +3966,8 @@ var require_util = __commonJS({
3806
3966
  var obj = /* @__PURE__ */ Object.create(null);
3807
3967
  return !("__proto__" in obj);
3808
3968
  })();
3809
- function identity(s) {
3810
- return s;
3969
+ function identity(s2) {
3970
+ return s2;
3811
3971
  }
3812
3972
  function toSetString(aStr) {
3813
3973
  if (isProtoString(aStr)) {
@@ -3823,19 +3983,19 @@ var require_util = __commonJS({
3823
3983
  return aStr;
3824
3984
  }
3825
3985
  exports.fromSetString = supportsNullProto ? identity : fromSetString;
3826
- function isProtoString(s) {
3827
- if (!s) {
3986
+ function isProtoString(s2) {
3987
+ if (!s2) {
3828
3988
  return false;
3829
3989
  }
3830
- var length = s.length;
3990
+ var length = s2.length;
3831
3991
  if (length < 9) {
3832
3992
  return false;
3833
3993
  }
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) {
3994
+ 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
3995
  return false;
3836
3996
  }
3837
3997
  for (var i = length - 10; i >= 0; i--) {
3838
- if (s.charCodeAt(i) !== 36) {
3998
+ if (s2.charCodeAt(i) !== 36) {
3839
3999
  return false;
3840
4000
  }
3841
4001
  }
@@ -3963,7 +4123,7 @@ var require_util = __commonJS({
3963
4123
  var require_array_set = __commonJS({
3964
4124
  "../../node_modules/source-map/lib/array-set.js"(exports) {
3965
4125
  "use strict";
3966
- var util = require_util();
4126
+ var util = require_util2();
3967
4127
  var has = Object.prototype.hasOwnProperty;
3968
4128
  var hasNativeMap = typeof Map !== "undefined";
3969
4129
  function ArraySet() {
@@ -4034,7 +4194,7 @@ var require_array_set = __commonJS({
4034
4194
  var require_mapping_list = __commonJS({
4035
4195
  "../../node_modules/source-map/lib/mapping-list.js"(exports) {
4036
4196
  "use strict";
4037
- var util = require_util();
4197
+ var util = require_util2();
4038
4198
  function generatedPositionAfter(mappingA, mappingB) {
4039
4199
  var lineA = mappingA.generatedLine;
4040
4200
  var lineB = mappingB.generatedLine;
@@ -4075,7 +4235,7 @@ var require_source_map_generator = __commonJS({
4075
4235
  "../../node_modules/source-map/lib/source-map-generator.js"(exports) {
4076
4236
  "use strict";
4077
4237
  var base64VLQ = require_base64_vlq();
4078
- var util = require_util();
4238
+ var util = require_util2();
4079
4239
  var ArraySet = require_array_set().ArraySet;
4080
4240
  var MappingList = require_mapping_list().MappingList;
4081
4241
  function SourceMapGenerator(aArgs) {
@@ -4444,7 +4604,7 @@ var require_quick_sort = __commonJS({
4444
4604
  var require_source_map_consumer = __commonJS({
4445
4605
  "../../node_modules/source-map/lib/source-map-consumer.js"(exports) {
4446
4606
  "use strict";
4447
- var util = require_util();
4607
+ var util = require_util2();
4448
4608
  var binarySearch = require_binary_search();
4449
4609
  var ArraySet = require_array_set().ArraySet;
4450
4610
  var base64VLQ = require_base64_vlq();
@@ -4591,8 +4751,8 @@ var require_source_map_consumer = __commonJS({
4591
4751
  });
4592
4752
  this._names = ArraySet.fromArray(names.map(String), true);
4593
4753
  this._sources = ArraySet.fromArray(sources, true);
4594
- this._absoluteSources = this._sources.toArray().map(function(s) {
4595
- return util.computeSourceURL(sourceRoot, s, aSourceMapURL);
4754
+ this._absoluteSources = this._sources.toArray().map(function(s2) {
4755
+ return util.computeSourceURL(sourceRoot, s2, aSourceMapURL);
4596
4756
  });
4597
4757
  this.sourceRoot = sourceRoot;
4598
4758
  this.sourcesContent = sourcesContent;
@@ -4629,8 +4789,8 @@ var require_source_map_consumer = __commonJS({
4629
4789
  );
4630
4790
  smc.file = aSourceMap._file;
4631
4791
  smc._sourceMapURL = aSourceMapURL;
4632
- smc._absoluteSources = smc._sources.toArray().map(function(s) {
4633
- return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL);
4792
+ smc._absoluteSources = smc._sources.toArray().map(function(s2) {
4793
+ return util.computeSourceURL(smc.sourceRoot, s2, aSourceMapURL);
4634
4794
  });
4635
4795
  var generatedMappings = aSourceMap._mappings.toArray().slice();
4636
4796
  var destGeneratedMappings = smc.__generatedMappings = [];
@@ -4897,11 +5057,11 @@ var require_source_map_consumer = __commonJS({
4897
5057
  line: -1,
4898
5058
  column: 0
4899
5059
  };
4900
- this._sections = sections.map(function(s) {
4901
- if (s.url) {
5060
+ this._sections = sections.map(function(s2) {
5061
+ if (s2.url) {
4902
5062
  throw new Error("Support for url field in sections not implemented.");
4903
5063
  }
4904
- var offset = util.getArg(s, "offset");
5064
+ var offset = util.getArg(s2, "offset");
4905
5065
  var offsetLine = util.getArg(offset, "line");
4906
5066
  var offsetColumn = util.getArg(offset, "column");
4907
5067
  if (offsetLine < lastOffset.line || offsetLine === lastOffset.line && offsetColumn < lastOffset.column) {
@@ -4915,7 +5075,7 @@ var require_source_map_consumer = __commonJS({
4915
5075
  generatedLine: offsetLine + 1,
4916
5076
  generatedColumn: offsetColumn + 1
4917
5077
  },
4918
- consumer: new SourceMapConsumer(util.getArg(s, "map"), aSourceMapURL)
5078
+ consumer: new SourceMapConsumer(util.getArg(s2, "map"), aSourceMapURL)
4919
5079
  };
4920
5080
  });
4921
5081
  }
@@ -4965,8 +5125,8 @@ var require_source_map_consumer = __commonJS({
4965
5125
  });
4966
5126
  };
4967
5127
  IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = function IndexedSourceMapConsumer_hasContentsOfAllSources() {
4968
- return this._sections.every(function(s) {
4969
- return s.consumer.hasContentsOfAllSources();
5128
+ return this._sections.every(function(s2) {
5129
+ return s2.consumer.hasContentsOfAllSources();
4970
5130
  });
4971
5131
  };
4972
5132
  IndexedSourceMapConsumer.prototype.sourceContentFor = function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
@@ -5047,7 +5207,7 @@ var require_source_node = __commonJS({
5047
5207
  "../../node_modules/source-map/lib/source-node.js"(exports) {
5048
5208
  "use strict";
5049
5209
  var SourceMapGenerator = require_source_map_generator().SourceMapGenerator;
5050
- var util = require_util();
5210
+ var util = require_util2();
5051
5211
  var REGEX_NEWLINE = /(\r?\n)/;
5052
5212
  var NEWLINE_CODE = 10;
5053
5213
  var isSourceNode = "$$$isSourceNode$$$";
@@ -6564,7 +6724,7 @@ var require_printer = __commonJS({
6564
6724
  });
6565
6725
 
6566
6726
  // ../../node_modules/handlebars/lib/index.js
6567
- var require_lib = __commonJS({
6727
+ var require_lib2 = __commonJS({
6568
6728
  "../../node_modules/handlebars/lib/index.js"(exports, module) {
6569
6729
  "use strict";
6570
6730
  var handlebars = require_handlebars()["default"];
@@ -7476,98 +7636,2350 @@ function safeJsonParse(json) {
7476
7636
  }
7477
7637
  }
7478
7638
 
7479
- // ../mcp-registry/src/operation-specs.ts
7480
- import { z as z2 } from "zod";
7639
+ // ../common/dist/src/constants/tool-declarations.js
7640
+ import { z as z10 } from "zod";
7481
7641
 
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.`
7642
+ // ../common/dist/src/zod-schemas/model-config.schema.js
7643
+ import { z as z5 } from "zod";
7644
+
7645
+ // ../common/dist/src/utils/zod.util.js
7646
+ var import_ts_essentials2 = __toESM(require_dist(), 1);
7647
+ import { z as z4, ZodObject } from "zod";
7648
+
7649
+ // ../../node_modules/zodex/dist/esm/index.js
7650
+ import { z as z2 } from "zod";
7651
+ import { z as z22 } from "zod";
7652
+ var STRING_KINDS = /* @__PURE__ */ new Set([
7653
+ "url",
7654
+ "emoji",
7655
+ "nanoid",
7656
+ "cuid",
7657
+ "cuid2",
7658
+ "ulid",
7659
+ "date",
7660
+ "duration",
7661
+ "base64",
7662
+ "base64url",
7663
+ "guid",
7664
+ "xid",
7665
+ "ksuid",
7666
+ "json_string",
7667
+ "e164",
7668
+ "jwt",
7669
+ "ipv4",
7670
+ "ipv6",
7671
+ "cidrv4",
7672
+ "cidrv6",
7673
+ "e164"
7674
+ // "uuidv8", // In docs only
7675
+ // "ascii", // In docs only
7676
+ // "utf8", // In docs only
7677
+ // "lowercase", // Doesn't appear to have enough data to serialize
7678
+ // "uppercase", // Doesn't appear to have enough data to serialize
7679
+ ]);
7680
+ var getCustomChecksAndErrors = (def, opts) => {
7681
+ let customChecks = null;
7682
+ if ("checks" in opts && opts.checks) {
7683
+ customChecks = def.checks?.filter((check) => {
7684
+ const chk = check._zod.def.check;
7685
+ return chk == "custom";
7686
+ }).map((check) => {
7687
+ const name = Object.entries(
7688
+ /* c8 ignore next -- TS doesn't catch */
7689
+ opts.checks || {}
7690
+ ).find(([, checkFunc]) => {
7691
+ return checkFunc === check._zod.check;
7692
+ })?.[0];
7693
+ if (name) {
7694
+ return { name };
7695
+ }
7696
+ return null;
7697
+ }).filter(Boolean);
7698
+ }
7699
+ let customError;
7700
+ if ("error" in def) {
7701
+ const key = Object.entries(opts.errors ?? {}).find(([, func]) => {
7702
+ return func === def.error;
7703
+ })?.[0];
7704
+ customError = typeof key == "string" ? { key } : (
7705
+ // Not supplying an issue should not be a problem for regular
7706
+ // wrapped string errors
7707
+ def.error()
7500
7708
  );
7501
7709
  }
7502
- if (actualKind !== kind || actualOperationName !== operationName) {
7503
- throw new Error(
7504
- `Operation "${operationName}" does not match its GraphQL document (${actualKind} ${actualOperationName}).`
7710
+ return Object.assign(
7711
+ customChecks ? { checks: customChecks } : {},
7712
+ customError ? { error: customError } : {}
7713
+ );
7714
+ };
7715
+ var s = zerializeRefs;
7716
+ var zerializers = {
7717
+ optional: (def, opts) => ({
7718
+ ...s(def.innerType, opts, true),
7719
+ isOptional: true
7720
+ }),
7721
+ nullable: (def, opts) => ({
7722
+ ...s(def.innerType, opts, true),
7723
+ isNullable: true
7724
+ }),
7725
+ default: (def, opts) => ({
7726
+ ...s(def.innerType, opts, true),
7727
+ defaultValue: def.innerType._zod.def.type === "bigint" ? String(def.defaultValue) : def.innerType._zod.def.type === "date" ? def.defaultValue.getTime() : def.defaultValue
7728
+ }),
7729
+ number: (def, opts) => {
7730
+ const checks = def.checks?.reduce((o, check) => {
7731
+ const chk = check._zod.def.check;
7732
+ const format = check._zod.def.format;
7733
+ return {
7734
+ ...o,
7735
+ ...chk == "greater_than" ? {
7736
+ min: check._zod.def.value,
7737
+ ...check._zod.def.inclusive ? { minInclusive: true } : {}
7738
+ } : chk == "less_than" ? {
7739
+ max: check._zod.def.value,
7740
+ ...check._zod.def.inclusive ? { maxInclusive: true } : {}
7741
+ } : chk == "multiple_of" ? {
7742
+ multipleOf: check._zod.def.value
7743
+ /* c8 ignore next 2 -- Guard */
7744
+ } : {}
7745
+ };
7746
+ }, {});
7747
+ return Object.assign(
7748
+ {
7749
+ type: "number",
7750
+ ...checks,
7751
+ ...getCustomChecksAndErrors(def, opts),
7752
+ // Check is on `def` itself
7753
+ ..."check" in def && def.check === "number_format" && "format" in def ? { format: def.format } : {}
7754
+ },
7755
+ def.coerce ? { coerce: true } : {}
7756
+ );
7757
+ },
7758
+ template_literal: (def, opts) => {
7759
+ const parts = def.parts.map((part, idx) => {
7760
+ if (typeof part == "string") {
7761
+ return part;
7762
+ }
7763
+ return s(part, {
7764
+ ...opts,
7765
+ currentPath: [...opts.currentPath, "parts", String(idx)]
7766
+ });
7767
+ });
7768
+ return {
7769
+ type: "templateLiteral",
7770
+ parts,
7771
+ ...def.format ? { format: def.format } : {}
7772
+ };
7773
+ },
7774
+ string: (def, opts) => {
7775
+ const checks = def.checks?.reduce((o, check) => {
7776
+ const chk = check._zod.def.check;
7777
+ const format2 = check._zod.def.format;
7778
+ return {
7779
+ ...o,
7780
+ ...chk == "min_length" ? { min: check._zod.def.minimum } : chk == "max_length" ? { max: check._zod.def.maximum } : chk == "length_equals" ? {
7781
+ length: check._zod.def.length
7782
+ } : (
7783
+ // Any way around this?
7784
+ 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 } : (
7785
+ // No apparent check
7786
+ // : chk == "string_format" && format == "trim"
7787
+ // ? { trim: true }
7788
+ chk == "string_format" && format2 == "starts_with" ? {
7789
+ startsWith: check._zod.def.prefix
7790
+ } : chk == "string_format" && format2 == "ends_with" ? {
7791
+ endsWith: check._zod.def.suffix
7792
+ } : chk == "string_format" && format2 == "includes" ? {
7793
+ includes: check._zod.def.includes,
7794
+ position: check._zod.def.position
7795
+ } : chk == "string_format" && format2 == "regex" ? {
7796
+ regex: check._zod.def.pattern.source,
7797
+ ...check._zod.def.pattern.flags ? {
7798
+ flags: check._zod.def.pattern.flags
7799
+ } : {}
7800
+ /* c8 ignore next 2 -- Guard */
7801
+ } : {}
7802
+ )
7803
+ )
7804
+ };
7805
+ }, {});
7806
+ const format = "format" in def && def.format;
7807
+ return Object.assign(
7808
+ {
7809
+ type: "string",
7810
+ ...checks,
7811
+ ...getCustomChecksAndErrors(def, opts),
7812
+ // Check is on `def` itself
7813
+ ...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" ? {
7814
+ kind: "uuid",
7815
+ ..."version" in def ? { version: def.version } : {}
7816
+ } : format == "jwt" ? {
7817
+ kind: "jwt",
7818
+ ..."alg" in def ? { algorithm: def.alg } : {}
7819
+ } : format == "email" ? {
7820
+ kind: "email",
7821
+ ..."pattern" in def && def.pattern && typeof def.pattern == "object" && "source" in def.pattern && "flags" in def.pattern && def.pattern.source !== z22.regexes.email.source ? {
7822
+ pattern: def.pattern.source,
7823
+ flags: def.pattern.flags
7824
+ } : {}
7825
+ } : "format" in def && STRING_KINDS.has(format) || format == "datetime" || format == "time" ? {
7826
+ kind: format,
7827
+ ..."precision" in def && def.precision ? {
7828
+ precision: def.precision
7829
+ } : {},
7830
+ ..."offset" in def && def.offset ? {
7831
+ offset: def.offset
7832
+ } : {},
7833
+ ..."local" in def && def.local ? {
7834
+ local: def.local
7835
+ } : {}
7836
+ } : {}
7837
+ },
7838
+ def.coerce ? { coerce: true } : {}
7839
+ );
7840
+ },
7841
+ boolean: (def) => Object.assign({ type: "boolean" }, def.coerce ? { coerce: true } : {}),
7842
+ nan: () => ({ type: "nan" }),
7843
+ symbol: () => ({ type: "symbol" }),
7844
+ bigint: (def, opts) => {
7845
+ const checks = def.checks?.reduce((o, check) => {
7846
+ const chk = check._zod.def.check;
7847
+ return {
7848
+ ...o,
7849
+ ...chk == "greater_than" ? {
7850
+ min: String(
7851
+ check._zod.def.value
7852
+ ),
7853
+ ...check._zod.def.inclusive ? { minInclusive: true } : {}
7854
+ } : chk == "less_than" ? {
7855
+ max: String(
7856
+ check._zod.def.value
7857
+ ),
7858
+ ...check._zod.def.inclusive ? { maxInclusive: true } : {}
7859
+ } : chk == "multiple_of" ? {
7860
+ multipleOf: String(
7861
+ check._zod.def.value
7862
+ )
7863
+ /* c8 ignore next 2 -- Guard */
7864
+ } : {}
7865
+ };
7866
+ }, {});
7867
+ return Object.assign(
7868
+ {
7869
+ type: "bigInt",
7870
+ ...checks,
7871
+ ...getCustomChecksAndErrors(def, opts),
7872
+ // Check is on `def` itself
7873
+ ..."check" in def && def.check === "bigint_format" && "format" in def ? { format: def.format } : {}
7874
+ },
7875
+ def.coerce ? { coerce: true } : {}
7876
+ );
7877
+ },
7878
+ file: (def) => {
7879
+ const checks = def.checks?.reduce((o, check) => {
7880
+ const chk = check._zod.def.check;
7881
+ return {
7882
+ ...o,
7883
+ ...chk == "min_size" ? {
7884
+ min: check._zod.def.minimum
7885
+ } : chk == "max_size" ? {
7886
+ max: check._zod.def.maximum
7887
+ } : chk == "mime_type" ? {
7888
+ mime: check._zod.def.mime
7889
+ /* c8 ignore next 2 -- Guard */
7890
+ } : {}
7891
+ };
7892
+ }, {});
7893
+ return {
7894
+ type: "file",
7895
+ ...checks
7896
+ };
7897
+ },
7898
+ date: (def, opts) => {
7899
+ const checks = def.checks?.reduce((o, check) => {
7900
+ const chk = check._zod.def.check;
7901
+ return {
7902
+ ...o,
7903
+ ...chk == "greater_than" ? {
7904
+ min: check._zod.def.value.getTime()
7905
+ // ...((check as z.core.$ZodCheckLessThan<Date>)._zod.def.inclusive
7906
+ // ? { minInclusive: true }
7907
+ // : {}),
7908
+ } : chk == "less_than" ? {
7909
+ max: check._zod.def.value.getTime()
7910
+ // ...((check as z.core.$ZodCheckLessThan<Date>)._zod.def.inclusive
7911
+ // ? { maxInclusive: true }
7912
+ // : {}),
7913
+ } : (
7914
+ /* c8 ignore next -- Guard */
7915
+ {}
7916
+ )
7917
+ };
7918
+ }, {});
7919
+ return Object.assign(
7920
+ { type: "date", ...checks, ...getCustomChecksAndErrors(def, opts) },
7921
+ def.coerce ? { coerce: true } : {}
7922
+ );
7923
+ },
7924
+ undefined: () => ({ type: "undefined" }),
7925
+ null: () => ({ type: "null" }),
7926
+ any: () => ({ type: "any" }),
7927
+ unknown: () => ({ type: "unknown" }),
7928
+ never: () => ({ type: "never" }),
7929
+ void: () => ({ type: "void" }),
7930
+ literal: (def) => ({ type: "literal", values: def.values }),
7931
+ tuple: (def, opts) => ({
7932
+ type: "tuple",
7933
+ ...getCustomChecksAndErrors(def, opts),
7934
+ items: def.items.map((item, idx) => {
7935
+ const result = s(item, {
7936
+ ...opts,
7937
+ currentPath: [...opts.currentPath, "items", String(idx)]
7938
+ });
7939
+ return result;
7940
+ }),
7941
+ ...def.rest ? {
7942
+ rest: s(def.rest, {
7943
+ ...opts,
7944
+ currentPath: [...opts.currentPath, "rest"]
7945
+ })
7946
+ } : {}
7947
+ }),
7948
+ set: (def, opts) => {
7949
+ const checks = def.checks?.reduce((o, check) => {
7950
+ const chk = check._zod.def.check;
7951
+ return {
7952
+ ...o,
7953
+ ...chk == "min_size" ? {
7954
+ minSize: check._zod.def.minimum
7955
+ } : chk == "max_size" ? {
7956
+ maxSize: check._zod.def.maximum
7957
+ } : chk == "size_equals" ? {
7958
+ minSize: check._zod.def.size,
7959
+ maxSize: check._zod.def.size
7960
+ /* c8 ignore next 2 -- Guard */
7961
+ } : {}
7962
+ };
7963
+ }, {});
7964
+ return {
7965
+ type: "set",
7966
+ value: s(def.valueType, {
7967
+ ...opts,
7968
+ currentPath: [...opts.currentPath, "value"]
7969
+ }),
7970
+ ...getCustomChecksAndErrors(def, opts),
7971
+ ...checks
7972
+ };
7973
+ },
7974
+ array: (def, opts) => {
7975
+ const checks = def.checks?.reduce((o, check) => {
7976
+ const chk = check._zod.def.check;
7977
+ return {
7978
+ ...o,
7979
+ ...chk == "min_length" ? { minLength: check._zod.def.minimum } : chk == "max_length" ? {
7980
+ maxLength: check._zod.def.maximum
7981
+ } : chk == "length_equals" ? {
7982
+ minLength: check._zod.def.length,
7983
+ maxLength: check._zod.def.length
7984
+ /* c8 ignore next 2 -- Guard */
7985
+ } : {}
7986
+ };
7987
+ }, {});
7988
+ return {
7989
+ type: "array",
7990
+ element: s(def.element, {
7991
+ ...opts,
7992
+ currentPath: [...opts.currentPath, "element"]
7993
+ }),
7994
+ ...getCustomChecksAndErrors(def, opts),
7995
+ ...checks
7996
+ };
7997
+ },
7998
+ object: (def, opts) => {
7999
+ return {
8000
+ type: "object",
8001
+ ...getCustomChecksAndErrors(def, opts),
8002
+ ...!def.catchall ? {} : {
8003
+ catchall: s(def.catchall, {
8004
+ ...opts,
8005
+ currentPath: [...opts.currentPath, "catchall"]
8006
+ })
8007
+ },
8008
+ properties: Object.fromEntries(
8009
+ Object.entries(def.shape).map(([key, schema]) => [
8010
+ key,
8011
+ s(schema, {
8012
+ ...opts,
8013
+ currentPath: [...opts.currentPath, "properties", key]
8014
+ })
8015
+ ])
8016
+ )
8017
+ };
8018
+ },
8019
+ record: (def, opts) => ({
8020
+ type: "record",
8021
+ ...getCustomChecksAndErrors(def, opts),
8022
+ key: s(def.keyType, {
8023
+ ...opts,
8024
+ currentPath: [...opts.currentPath, "key"]
8025
+ }),
8026
+ value: s(def.valueType, {
8027
+ ...opts,
8028
+ currentPath: [...opts.currentPath, "value"]
8029
+ })
8030
+ }),
8031
+ map: (def, opts) => ({
8032
+ type: "map",
8033
+ ...getCustomChecksAndErrors(def, opts),
8034
+ key: s(def.keyType, {
8035
+ ...opts,
8036
+ currentPath: [...opts.currentPath, "key"]
8037
+ }),
8038
+ value: s(def.valueType, {
8039
+ ...opts,
8040
+ currentPath: [...opts.currentPath, "value"]
8041
+ })
8042
+ }),
8043
+ enum: (def) => ({ type: "enum", values: def.entries }),
8044
+ union: (def, opts) => {
8045
+ return {
8046
+ type: "discriminator" in def ? "discriminatedUnion" : "union",
8047
+ ..."discriminator" in def ? {
8048
+ discriminator: def.discriminator
8049
+ } : {},
8050
+ ...getCustomChecksAndErrors(def, opts),
8051
+ options: def.options.map((opt, idx) => {
8052
+ const result = s(opt, {
8053
+ ...opts,
8054
+ currentPath: [...opts.currentPath, "options", String(idx)]
8055
+ });
8056
+ return result;
8057
+ })
8058
+ };
8059
+ },
8060
+ intersection: (def, opts) => ({
8061
+ type: "intersection",
8062
+ ...getCustomChecksAndErrors(def, opts),
8063
+ left: s(def.left, {
8064
+ ...opts,
8065
+ currentPath: [...opts.currentPath, "left"]
8066
+ }),
8067
+ right: s(def.right, {
8068
+ ...opts,
8069
+ currentPath: [...opts.currentPath, "right"]
8070
+ })
8071
+ }),
8072
+ promise: (def, opts) => ({
8073
+ type: "promise",
8074
+ value: s(def.innerType, {
8075
+ ...opts,
8076
+ currentPath: [...opts.currentPath, "value"]
8077
+ })
8078
+ }),
8079
+ lazy: (def, opts) => {
8080
+ const getter = def.getter();
8081
+ return s(
8082
+ getter,
8083
+ opts,
8084
+ // official equivalent for `isOptional`
8085
+ getter.safeParse(void 0).success || // official equivalent for `isNullable`
8086
+ getter.safeParse(null).success
7505
8087
  );
8088
+ },
8089
+ transform: (def, opts) => {
8090
+ let name = null;
8091
+ if ("transforms" in opts && opts.transforms) {
8092
+ for (const [transformName, transformItem] of Object.entries(
8093
+ opts.transforms
8094
+ )) {
8095
+ if (def.type === "transform" && transformItem === def.transform) {
8096
+ name = transformName;
8097
+ break;
8098
+ }
8099
+ }
8100
+ }
8101
+ return {
8102
+ type: "transform",
8103
+ name
8104
+ // inner: s(def.out, {
8105
+ // ...opts,
8106
+ // currentPath: [...opts.currentPath, "inner"],
8107
+ // }),
8108
+ };
8109
+ },
8110
+ pipe: (def, opts) => {
8111
+ if (!("transforms" in opts)) {
8112
+ return s(def.out, opts);
8113
+ }
8114
+ return {
8115
+ type: "pipe",
8116
+ ...getCustomChecksAndErrors(def, opts),
8117
+ inner: s(def.in, opts),
8118
+ outer: s(def.out, opts)
8119
+ };
8120
+ },
8121
+ catch: (def, opts) => {
8122
+ const catchValue = def.catchValue({
8123
+ value: null,
8124
+ issues: [],
8125
+ // No errors to report, so just add an empty set
8126
+ /* c8 ignore next 3 -- Unused */
8127
+ get error() {
8128
+ return new z22.ZodError([]);
8129
+ },
8130
+ // We don't have any input yet, so just provide `undefined`
8131
+ input: void 0
8132
+ });
8133
+ return {
8134
+ type: "catch",
8135
+ value: catchValue,
8136
+ innerType: s(def.innerType, opts)
8137
+ };
8138
+ },
8139
+ readonly: (def, opts) => ({
8140
+ ...s(def.innerType, opts, true),
8141
+ readonly: true
8142
+ })
8143
+ };
8144
+ function zerializeRefs(schema, opts, wrapReferences) {
8145
+ if (opts.seenObjects.has(schema)) {
8146
+ return wrapReferences ? {
8147
+ type: "union",
8148
+ options: [{ $ref: opts.seenObjects.get(schema) }],
8149
+ ...typeof schema.description === "string" ? {
8150
+ description: schema.description
8151
+ } : {}
8152
+ } : { $ref: opts.seenObjects.get(schema) };
7506
8153
  }
8154
+ const {
8155
+ _zod: { def }
8156
+ } = schema;
8157
+ const objectPath = "#" + (opts.currentPath.length ? "/" + opts.currentPath.join("/") : "");
8158
+ opts.seenObjects.set(schema, objectPath);
8159
+ const zer = zerializers[def.type](def, opts);
8160
+ if (typeof schema.description === "string") {
8161
+ zer.description = schema.description;
8162
+ }
8163
+ return zer;
7507
8164
  }
7508
- function createOperationSpec(spec) {
7509
- assertDocumentMatchesOperation(spec);
7510
- return spec;
8165
+ function zerialize(schema, opts = {}) {
8166
+ if (!opts.currentPath) {
8167
+ opts.currentPath = [];
8168
+ }
8169
+ if (!opts.seenObjects) {
8170
+ opts.seenObjects = /* @__PURE__ */ new WeakMap();
8171
+ }
8172
+ return zerializeRefs(schema, opts);
7511
8173
  }
7512
8174
 
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
- };
7527
- }
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
- };
8175
+ // ../common/dist/src/stdlib/object.util.js
8176
+ var import_es6 = __toESM(require_es6(), 1);
8177
+ function isDeepEqualAndSameType(a, b) {
8178
+ return (0, import_es6.default)(a, b);
7541
8179
  }
7542
- function booleanOption({
7543
- description,
7544
- flagName,
7545
- inputKey
7546
- }) {
7547
- return {
7548
- description,
7549
- flagName,
7550
- inputKey,
7551
- valueType: "boolean"
7552
- };
8180
+
8181
+ // ../common/dist/src/stdlib/string.util.js
8182
+ var import_json_stringify_deterministic = __toESM(require_lib(), 1);
8183
+ import { z as z3 } from "zod";
8184
+ function brandString(value) {
8185
+ return value;
8186
+ }
8187
+ var entityMap = {
8188
+ /* eslint-disable @typescript-eslint/naming-convention */
8189
+ "&#x27;": "'",
8190
+ "&#39;": "'",
8191
+ "&quot;": '"',
8192
+ "&amp;": "&",
8193
+ "&lt;": "<",
8194
+ "&gt;": ">",
8195
+ "&nbsp;": " "
8196
+ /* eslint-enable @typescript-eslint/naming-convention */
8197
+ };
8198
+ var entityRegex = new RegExp(Object.keys(entityMap).join("|"), "gu");
8199
+
8200
+ // ../common/dist/src/utils/zod.util.js
8201
+ function brandedStringValidator(_brand) {
8202
+ return z4.string().transform((val) => brandString(val));
8203
+ }
8204
+ var emptySchema = zerialize(z4.object({}));
8205
+
8206
+ // ../common/dist/src/zod-schemas/model-config.schema.js
8207
+ var magicalBaseModels = [
8208
+ "gemini-2.5-flash",
8209
+ "gemini-3-pro-preview",
8210
+ "o3",
8211
+ "gpt-4o",
8212
+ "gpt-5-mini",
8213
+ "gpt-5.4"
8214
+ ];
8215
+ var DEFAULT_MODEL = "gemini-2.5-flash";
8216
+ var modelOptionsSchema = z5.object({
8217
+ 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."),
8218
+ 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.")
8219
+ });
8220
+ var modelIdSchema = brandedStringValidator("modelId").or(z5.enum(magicalBaseModels));
8221
+ var baseModelConfigSchema = z5.object({
8222
+ id: modelIdSchema.default(DEFAULT_MODEL)
8223
+ }).extend(modelOptionsSchema.shape);
8224
+ var fallbackModelConfigSchema = z5.object({
8225
+ ...baseModelConfigSchema.shape,
8226
+ useAfterAttempt: z5.number().min(1).describe("Number of failed attempts with the primary model before switching to this fallback model.")
8227
+ }).describe("Configuration for a fallback model to use after primary failures.");
8228
+ var modelConfigSchema = z5.union([
8229
+ modelIdSchema.default(DEFAULT_MODEL),
8230
+ z5.object({
8231
+ ...baseModelConfigSchema.shape,
8232
+ 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.")
8233
+ }).describe("Full model configuration with options and fallbacks.")
8234
+ ]).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) => {
8235
+ if (typeof data === "string") {
8236
+ return { id: data };
8237
+ }
8238
+ return data;
8239
+ });
8240
+ var agentSingleModelConfigSchema = z5.object({
8241
+ type: z5.literal("single-model"),
8242
+ ...baseModelConfigSchema.shape,
8243
+ 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.")
8244
+ }).describe("Agent model configuration for selecting a single model directly.");
8245
+ var agentModelPoolConfigSchema = z5.object({
8246
+ type: z5.literal("model-pool"),
8247
+ poolId: brandedStringValidator("resourcePoolId").describe("Resource pool ID containing candidate models. The highest-priority model is primary."),
8248
+ ...modelOptionsSchema.shape,
8249
+ fallbackModels: z5.array(fallbackModelConfigSchema).optional().describe("Optional explicit fallback list. If omitted, fallbacks are derived from remaining models in the pool by priority.")
8250
+ }).describe("Agent model configuration for selecting models from a resource pool.");
8251
+ var agentModelConfigSchema = z5.preprocess((data) => {
8252
+ if (typeof data === "string") {
8253
+ return {
8254
+ type: "single-model",
8255
+ id: data
8256
+ };
8257
+ }
8258
+ if (typeof data === "object" && data !== null && !("type" in data)) {
8259
+ return {
8260
+ type: "single-model",
8261
+ ...data
8262
+ };
8263
+ }
8264
+ return data;
8265
+ }, z5.discriminatedUnion("type", [
8266
+ agentSingleModelConfigSchema,
8267
+ agentModelPoolConfigSchema
8268
+ ])).default({
8269
+ type: "single-model",
8270
+ id: DEFAULT_MODEL
8271
+ }).describe("Agent LLM model configuration. Supports direct model selection (single-model) and model-pool selection with priority-based fallback behavior.");
8272
+
8273
+ // ../common/dist/src/zod-schemas/browser-provider-options.schema.js
8274
+ import { z as z6 } from "zod";
8275
+ var viewportSizeSchema = z6.object({
8276
+ width: z6.number().min(800).max(3840).describe("Viewport width in pixels. Must be between 800 and 3840."),
8277
+ height: z6.number().min(600).max(2160).describe("Viewport height in pixels. Must be between 600 and 2160.")
8278
+ }).describe("Viewport dimensions in pixels. A 16:9 aspect ratio is recommended for optimal LLM performance.");
8279
+ var BROWSER_DEFAULT_VIEWPORT = {
8280
+ width: 1366,
8281
+ height: 768
8282
+ };
8283
+ var browserProviderOptionsSchema = z6.object({
8284
+ browserbase: z6.object({
8285
+ advancedStealth: z6.boolean().default(false).optional().describe("Enable advanced stealth mode to better avoid bot detection."),
8286
+ contextId: z6.string().min(1).optional().describe("Browserbase context ID for session persistence across runs."),
8287
+ extensionId: z6.string().min(1).optional().describe("Browser extension ID to load in the session."),
8288
+ enablePdfViewer: z6.boolean().optional().describe("Display PDFs in the browser instead of auto-downloading them."),
8289
+ instanceSize: z6.enum(["small", "medium", "large"]).optional().describe("Browser instance size. Larger instances have more resources but cost more. Beta feature."),
8290
+ blockAds: z6.boolean().optional().describe("Block ads when rendering pages in the session."),
8291
+ solveCaptchas: z6.boolean().default(true).optional().describe("Automatically solve CAPTCHAs in the background when encountered."),
8292
+ viewport: viewportSizeSchema.optional()
8293
+ }).optional().describe("Configuration options specific to the Browserbase provider."),
8294
+ agentCore: z6.object({
8295
+ viewport: viewportSizeSchema.optional(),
8296
+ enableWebBotAuth: z6.boolean().default(false).optional().describe("Enable WebBot authentication flow.")
8297
+ }).optional().describe("Configuration options specific to the AgentCore provider."),
8298
+ local: z6.object({
8299
+ viewport: viewportSizeSchema.optional()
8300
+ }).optional().describe("Configuration options for local browser execution (development only)."),
8301
+ hyperbrowser: z6.object({
8302
+ viewport: viewportSizeSchema.optional()
8303
+ }).optional().describe("Configuration options specific to the Hyperbrowser provider."),
8304
+ steel: z6.object({
8305
+ extensionIds: z6.array(z6.string().min(1)).optional().describe("List of browser extension IDs to load in the session."),
8306
+ region: z6.enum(["iad", "ord", "lax"]).optional().describe("Steel data center region. Options: iad (Virginia), ord (Chicago), lax (Los Angeles)."),
8307
+ solveCaptcha: z6.boolean().default(true).optional().describe("Automatically solve CAPTCHAs when encountered."),
8308
+ viewport: viewportSizeSchema.optional()
8309
+ }).optional().describe("Configuration options specific to the Steel provider.")
8310
+ }).describe("Provider-specific browser configuration options. Only the options for the selected browserProvider are used.");
8311
+
8312
+ // ../../node_modules/uuid/dist-node/stringify.js
8313
+ var byteToHex = [];
8314
+ for (let i = 0; i < 256; ++i) {
8315
+ byteToHex.push((i + 256).toString(16).slice(1));
8316
+ }
8317
+ function unsafeStringify(arr, offset = 0) {
8318
+ 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();
8319
+ }
8320
+
8321
+ // ../../node_modules/uuid/dist-node/rng.js
8322
+ var rnds8 = new Uint8Array(16);
8323
+ function rng() {
8324
+ return crypto.getRandomValues(rnds8);
8325
+ }
8326
+
8327
+ // ../../node_modules/uuid/dist-node/v4.js
8328
+ function v4(options, buf, offset) {
8329
+ if (!buf && !options && crypto.randomUUID) {
8330
+ return crypto.randomUUID();
8331
+ }
8332
+ return _v4(options, buf, offset);
8333
+ }
8334
+ function _v4(options, buf, offset) {
8335
+ options = options || {};
8336
+ const rnds = options.random ?? options.rng?.() ?? rng();
8337
+ if (rnds.length < 16) {
8338
+ throw new Error("Random bytes length must be >= 16");
8339
+ }
8340
+ rnds[6] = rnds[6] & 15 | 64;
8341
+ rnds[8] = rnds[8] & 63 | 128;
8342
+ if (buf) {
8343
+ offset = offset || 0;
8344
+ if (offset < 0 || offset + 16 > buf.length) {
8345
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
8346
+ }
8347
+ for (let i = 0; i < 16; ++i) {
8348
+ buf[offset + i] = rnds[i];
8349
+ }
8350
+ return buf;
8351
+ }
8352
+ return unsafeStringify(rnds);
8353
+ }
8354
+ var v4_default = v4;
8355
+
8356
+ // ../common/dist/src/stdlib/uuid.utils.js
8357
+ function uuidV4Branded() {
8358
+ return v4_default();
7553
8359
  }
7554
- function stringArrayOption({
7555
- description,
7556
- flagName,
7557
- inputKey,
7558
- required = false
7559
- }) {
7560
- return {
7561
- description,
7562
- flagName,
7563
- inputKey,
7564
- required,
7565
- valueHint: "comma-separated",
7566
- valueType: "string-array"
7567
- };
8360
+
8361
+ // ../common/dist/src/stdlib/url.utils.js
8362
+ var import_handlebars = __toESM(require_lib2(), 1);
8363
+ var HANDLEBARS_TEMPLATE_REGEX = /\{\{\{?[\s\S]*?\}\}\}?/u;
8364
+ var HANDLEBARS_TEMPLATE_GLOBAL_REGEX = /\{\{\{?[\s\S]*?\}\}\}?/gu;
8365
+ var LEADING_HANDLEBARS_TEMPLATE_REGEX = /^(?:\{\{\{?[\s\S]*?\}\}\}?)/u;
8366
+ var URL_TEMPLATE_PLACEHOLDER_VALUE = "handlebars-template-value";
8367
+ var LEADING_URL_TEMPLATE_PLACEHOLDER_VALUE = "https://handlebars-template.example";
8368
+ function safeUrlConstructor(url, baseUrl) {
8369
+ try {
8370
+ return Ok(baseUrl ? new URL(url, baseUrl) : new URL(url));
8371
+ } catch {
8372
+ return Err({
8373
+ type: "invalid-url",
8374
+ message: `Invalid URL`,
8375
+ url
8376
+ });
8377
+ }
7568
8378
  }
7569
- function jsonOption({
7570
- description,
8379
+ function isValidUrl(url) {
8380
+ try {
8381
+ new URL(url);
8382
+ return true;
8383
+ } catch {
8384
+ return false;
8385
+ }
8386
+ }
8387
+ function isHandlebarsTemplateString(value) {
8388
+ return HANDLEBARS_TEMPLATE_REGEX.test(value);
8389
+ }
8390
+ function isValidHandlebarsTemplateString(template) {
8391
+ try {
8392
+ import_handlebars.default.parse(template);
8393
+ return true;
8394
+ } catch {
8395
+ return false;
8396
+ }
8397
+ }
8398
+ function isValidUrlOrHandlebarsTemplateString(value) {
8399
+ if (!isHandlebarsTemplateString(value)) {
8400
+ return isValidUrl(value);
8401
+ }
8402
+ if (!isValidHandlebarsTemplateString(value)) {
8403
+ return false;
8404
+ }
8405
+ if (isValidUrl(replaceHandlebarsTemplates(value))) {
8406
+ return true;
8407
+ }
8408
+ const leadingHandlebarsTemplate = getLeadingHandlebarsTemplate(value);
8409
+ if (!leadingHandlebarsTemplate) {
8410
+ return false;
8411
+ }
8412
+ return isValidUrl(replaceHandlebarsTemplates(value.replace(leadingHandlebarsTemplate, LEADING_URL_TEMPLATE_PLACEHOLDER_VALUE)));
8413
+ }
8414
+ function getLeadingHandlebarsTemplate(value) {
8415
+ const leadingHandlebarsTemplate = LEADING_HANDLEBARS_TEMPLATE_REGEX.exec(value)?.[0];
8416
+ if (!leadingHandlebarsTemplate) {
8417
+ return void 0;
8418
+ }
8419
+ return leadingHandlebarsTemplate;
8420
+ }
8421
+ function replaceHandlebarsTemplates(value) {
8422
+ return value.replaceAll(HANDLEBARS_TEMPLATE_GLOBAL_REGEX, URL_TEMPLATE_PLACEHOLDER_VALUE);
8423
+ }
8424
+
8425
+ // ../common/dist/src/stdlib/state-machine.util.js
8426
+ var StateMachine = class {
8427
+ states;
8428
+ forwardTransitions;
8429
+ reverseTransitions;
8430
+ constructor({ states, transitions }) {
8431
+ this.states = Object.freeze([...states]);
8432
+ const forward = {};
8433
+ for (const state of this.states) {
8434
+ const toStates = transitions[state] ?? [];
8435
+ const deduped = dedupePreservingOrder(toStates);
8436
+ forward[state] = Object.freeze(deduped);
8437
+ }
8438
+ this.forwardTransitions = Object.freeze(forward);
8439
+ const reverse = {};
8440
+ for (const s2 of this.states) {
8441
+ const sources = this.states.filter((src) => this.forwardTransitions[src].includes(s2));
8442
+ reverse[s2] = Object.freeze(sources);
8443
+ }
8444
+ this.reverseTransitions = Object.freeze(reverse);
8445
+ }
8446
+ /** Returns the full set of states registered in this machine. */
8447
+ getAllStates() {
8448
+ return this.states;
8449
+ }
8450
+ /** Returns the allowed target states for a given source state. */
8451
+ getAllowedTargets(from) {
8452
+ return this.forwardTransitions[from];
8453
+ }
8454
+ /** Returns the allowed source states for a given target state. */
8455
+ getAllowedSources(to) {
8456
+ return this.reverseTransitions[to];
8457
+ }
8458
+ /** Checks if a transition from `from` to `to` is allowed. */
8459
+ isTransitionAllowed(from, to) {
8460
+ return this.forwardTransitions[from].includes(to);
8461
+ }
8462
+ };
8463
+ function dedupePreservingOrder(values) {
8464
+ const seen = /* @__PURE__ */ new Set();
8465
+ const result = [];
8466
+ for (const v of values) {
8467
+ if (!seen.has(v)) {
8468
+ seen.add(v);
8469
+ result.push(v);
8470
+ }
8471
+ }
8472
+ return result;
8473
+ }
8474
+
8475
+ // ../common/dist/src/models/websocket/actions/scroll.js
8476
+ import { z as z7 } from "zod";
8477
+ var scrollDataSchema = z7.object({
8478
+ direction: z7.enum(["UP", "DOWN", "LEFT", "RIGHT"]),
8479
+ length: z7.number().min(1).describe("The number of pixels to scroll by. Must be positive and at least 1.")
8480
+ });
8481
+ var ScrollEvent;
8482
+ (function(ScrollEvent2) {
8483
+ let Request;
8484
+ (function(Request2) {
8485
+ function create({ direction, length, agentId, sessionId }) {
8486
+ return {
8487
+ id: uuidV4Branded(),
8488
+ agentId,
8489
+ sessionId,
8490
+ type: "scroll",
8491
+ direction: "request",
8492
+ data: {
8493
+ direction,
8494
+ length
8495
+ }
8496
+ };
8497
+ }
8498
+ Request2.create = create;
8499
+ })(Request = ScrollEvent2.Request || (ScrollEvent2.Request = {}));
8500
+ let Response;
8501
+ (function(Response2) {
8502
+ function create({ id, agentId, sessionId, response }) {
8503
+ return {
8504
+ id,
8505
+ agentId,
8506
+ sessionId,
8507
+ direction: "response",
8508
+ type: "scroll-response",
8509
+ response
8510
+ };
8511
+ }
8512
+ Response2.create = create;
8513
+ })(Response = ScrollEvent2.Response || (ScrollEvent2.Response = {}));
8514
+ })(ScrollEvent || (ScrollEvent = {}));
8515
+
8516
+ // ../common/dist/src/models/websocket/actions/press.js
8517
+ import { z as z8 } from "zod";
8518
+ var PressEvent;
8519
+ (function(PressEvent2) {
8520
+ let Request;
8521
+ (function(Request2) {
8522
+ function create({ keys, sessionId, agentId }) {
8523
+ return {
8524
+ id: uuidV4Branded(),
8525
+ agentId,
8526
+ sessionId,
8527
+ type: "press",
8528
+ direction: "request",
8529
+ data: {
8530
+ keys
8531
+ }
8532
+ };
8533
+ }
8534
+ Request2.create = create;
8535
+ })(Request = PressEvent2.Request || (PressEvent2.Request = {}));
8536
+ let Response;
8537
+ (function(Response2) {
8538
+ function create({ id, agentId, sessionId, response }) {
8539
+ return {
8540
+ id,
8541
+ agentId,
8542
+ sessionId,
8543
+ direction: "response",
8544
+ type: "press-response",
8545
+ response
8546
+ };
8547
+ }
8548
+ Response2.create = create;
8549
+ })(Response = PressEvent2.Response || (PressEvent2.Response = {}));
8550
+ })(PressEvent || (PressEvent = {}));
8551
+ var Keys = [
8552
+ // Modifiers
8553
+ "Alt",
8554
+ "CapsLock",
8555
+ "Control",
8556
+ "Fn",
8557
+ "Shift",
8558
+ "Meta",
8559
+ // Whitespace keys
8560
+ "Enter",
8561
+ "Tab",
8562
+ "Space",
8563
+ // Navigation keys
8564
+ "ArrowUp",
8565
+ "ArrowDown",
8566
+ "ArrowLeft",
8567
+ "ArrowRight",
8568
+ "Home",
8569
+ "End",
8570
+ "PageUp",
8571
+ "PageDown",
8572
+ // Editing keys
8573
+ "Backspace",
8574
+ "Delete",
8575
+ // UI keys
8576
+ "Escape",
8577
+ "Pause",
8578
+ "Play",
8579
+ // Function keys
8580
+ "F1",
8581
+ "F2",
8582
+ "F3",
8583
+ "F4",
8584
+ "F5",
8585
+ "F6",
8586
+ "F7",
8587
+ "F8",
8588
+ "F9",
8589
+ "F10",
8590
+ "F11",
8591
+ "F12",
8592
+ "F13",
8593
+ "F14",
8594
+ "F15",
8595
+ "F16",
8596
+ "F17",
8597
+ "F18",
8598
+ "F19",
8599
+ "F20",
8600
+ // Alphanumerics (case-sensitive)
8601
+ "A",
8602
+ "a",
8603
+ "B",
8604
+ "b",
8605
+ "C",
8606
+ "c",
8607
+ "D",
8608
+ "d",
8609
+ "E",
8610
+ "e",
8611
+ "F",
8612
+ "f",
8613
+ "G",
8614
+ "g",
8615
+ "H",
8616
+ "h",
8617
+ "I",
8618
+ "i",
8619
+ "J",
8620
+ "j",
8621
+ "K",
8622
+ "k",
8623
+ "L",
8624
+ "l",
8625
+ "M",
8626
+ "m",
8627
+ "N",
8628
+ "n",
8629
+ "O",
8630
+ "o",
8631
+ "P",
8632
+ "p",
8633
+ "Q",
8634
+ "q",
8635
+ "R",
8636
+ "r",
8637
+ "S",
8638
+ "s",
8639
+ "T",
8640
+ "t",
8641
+ "U",
8642
+ "u",
8643
+ "V",
8644
+ "v",
8645
+ "W",
8646
+ "w",
8647
+ "X",
8648
+ "x",
8649
+ "Y",
8650
+ "y",
8651
+ "Z",
8652
+ "z",
8653
+ "0",
8654
+ "1",
8655
+ "2",
8656
+ "3",
8657
+ "4",
8658
+ "5",
8659
+ "6",
8660
+ "7",
8661
+ "8",
8662
+ "9",
8663
+ // Punctuation
8664
+ "Minus",
8665
+ "Equal",
8666
+ "BracketLeft",
8667
+ "BracketRight",
8668
+ "Backslash",
8669
+ "Semicolon",
8670
+ "Quote",
8671
+ "Comma",
8672
+ "Period",
8673
+ "Slash",
8674
+ "Backquote",
8675
+ // System keys
8676
+ "Insert",
8677
+ "PrintScreen"
8678
+ ];
8679
+ var pressDataSchema = z8.object({
8680
+ keys: z8.array(z8.enum(Keys))
8681
+ });
8682
+
8683
+ // ../common/dist/src/models/websocket/actions/report-stop.js
8684
+ import { z as z9 } from "zod";
8685
+ var reportStopDataSchema = z9.object({
8686
+ status: z9.enum(["success", "fail"]).describe("Whether the instructions were completed successfully or not"),
8687
+ 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.')
8688
+ });
8689
+
8690
+ // ../common/dist/src/constants/tool-declarations.js
8691
+ var COMMON_PARAMETERS_KEY = "metadata";
8692
+ 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.`;
8693
+ var DEFAULT_COMMON_PARAMETERS = z10.object({
8694
+ 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."),
8695
+ step: z10.coerce.string().regex(/^[\dA-Za-z]+(?:\.[\dA-Za-z]+)*$/u, {
8696
+ message: 'Step must follow the format of numbers separated by periods (e.g., "1", "1.2", "2.3.1")'
8697
+ }).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`),
8698
+ isRetry: z10.boolean().default(false).describe("Indicates whether this tool call is a retry of the previous step.")
8699
+ }).describe(COMMON_PARAMETERS_DESCRIPTION);
8700
+ var scrollToTextPositionEnum = z10.enum(["start", "center", "end"]);
8701
+ var agentToolSchema = z10.object({
8702
+ agentId: z10.string(),
8703
+ args: z10.unknown().optional()
8704
+ });
8705
+ var baseToolDeclarations = {
8706
+ clickFill: {
8707
+ id: "clickFill",
8708
+ 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.',
8709
+ parameters: z10.object({
8710
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8711
+ marker: markerSchema("The marker of the input field to fill."),
8712
+ text: z10.string().describe("The text to fill the marker with")
8713
+ })
8714
+ },
8715
+ click: {
8716
+ id: "click",
8717
+ 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.',
8718
+ parameters: z10.object({
8719
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8720
+ marker: markerSchema("The marker of the element to click."),
8721
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).describe("The type of click to perform")
8722
+ })
8723
+ },
8724
+ multiClick: {
8725
+ id: "multiClick",
8726
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
8727
+ parameters: z10.object({
8728
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8729
+ markers: z10.array(markerSchema("The marker of the element to click.")).min(1)
8730
+ })
8731
+ },
8732
+ clickAndConfirm: {
8733
+ id: "clickAndConfirm",
8734
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
8735
+ parameters: z10.object({
8736
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8737
+ marker: markerSchema("The marker of the element to click."),
8738
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).describe("The type of click to perform"),
8739
+ promptMessage: z10.string().min(1).describe("The prompt message to respond to.")
8740
+ })
8741
+ },
8742
+ copy: {
8743
+ id: "copy",
8744
+ description: "Copy given text to the clipboard.",
8745
+ parameters: z10.object({
8746
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8747
+ text: z10.string().describe("The text to copy to the clipboard.")
8748
+ })
8749
+ },
8750
+ downloadFile: {
8751
+ id: "downloadFile",
8752
+ description: "Download a file in the browser by clicking on something",
8753
+ parameters: z10.object({
8754
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8755
+ marker: markerSchema("The marker to click on the page to initiate the download"),
8756
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).describe("The type of click to perform")
8757
+ })
8758
+ },
8759
+ downloadNextDocumentRequest: {
8760
+ id: "downloadNextDocumentRequest",
8761
+ 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.",
8762
+ parameters: z10.object({
8763
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8764
+ marker: markerSchema("The marker of the element that triggers the new page").optional(),
8765
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).optional().describe("The type of click to perform"),
8766
+ url: z10.url().optional().describe("The url to navigate to that triggers the new page"),
8767
+ extension: z10.string().describe("The extension of the downloaded document")
8768
+ })
8769
+ },
8770
+ downloadNextNetworkRequest: {
8771
+ id: "downloadNextNetworkRequest",
8772
+ description: "Download the next network request by listening for a specific content type and resource type",
8773
+ parameters: z10.object({
8774
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8775
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).describe("The type of click to perform"),
8776
+ extension: z10.string().describe("The extension of the downloaded document"),
8777
+ contentType: z10.string().describe("The content type of the network request"),
8778
+ // The actual tool is using an enum for the resourceType
8779
+ resourceType: z10.string().describe("The resource type of the network request"),
8780
+ urlPattern: z10.string().min(1).optional().describe("An optional regular expression pattern to match against the request URL")
8781
+ })
8782
+ },
8783
+ printToPDF: {
8784
+ id: "printToPDF",
8785
+ description: "Print the current page to a PDF file",
8786
+ parameters: z10.object({
8787
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
8788
+ })
8789
+ },
8790
+ printFrameToPDF: {
8791
+ id: "printFrameToPDF",
8792
+ description: "Print the selected frame to a PDF file",
8793
+ parameters: z10.object({
8794
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8795
+ frameSelector: z10.string().describe("The selector of the frame to print")
8796
+ })
8797
+ },
8798
+ printFocusedFrameToPDF: {
8799
+ id: "printFocusedFrameToPDF",
8800
+ description: "Print the focused frame to a PDF file",
8801
+ parameters: z10.object({
8802
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
8803
+ })
8804
+ },
8805
+ capturePrintOutput: {
8806
+ id: "capturePrintOutput",
8807
+ description: "Capture the next printed content triggered by clicking an element, then save it as a PDF",
8808
+ parameters: z10.object({
8809
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8810
+ marker: markerSchema("The marker of the element that triggers the print request"),
8811
+ clickType: z10.enum(["LEFT", "RIGHT", "MIDDLE", "DOUBLE", "TRIPLE"]).optional().describe("The type of click to perform")
8812
+ })
8813
+ },
8814
+ drag: {
8815
+ id: "drag",
8816
+ 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.',
8817
+ parameters: z10.object({
8818
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8819
+ from: markerSchema("The marker to drag from").optional(),
8820
+ to: markerSchema("The marker to drag to")
8821
+ })
8822
+ },
8823
+ extractInfoFromFile: {
8824
+ id: "extractInfoFromFile",
8825
+ description: "Extract information from a previously downloaded file using specific prompts. Provide the file URL using `s3://{key}` and clearly defined extraction instructions.",
8826
+ parameters: z10.object({
8827
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8828
+ filePath: z10.string().describe("The URI to the file, starting with s3://"),
8829
+ extractions: z10.array(z10.object({
8830
+ name: z10.string().describe("The name of the extraction"),
8831
+ prompt: z10.string().describe("Instructions on how to find")
8832
+ }))
8833
+ })
8834
+ },
8835
+ getDropdownOptions: {
8836
+ id: "getDropdownOptions",
8837
+ description: "Get dropdown option labels of a `<select>` dropdown element",
8838
+ parameters: z10.object({
8839
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8840
+ marker: markerSchema("The marker of the `<select>` dropdown to get option labels from")
8841
+ })
8842
+ },
8843
+ /**
8844
+ * Playwright will lose track of this position between workflow activities because we create a
8845
+ * new Playwright client each time. The webpage will still think the cursor is at the previous
8846
+ * location but some Playwright methods rely on its own cached last position which will be reset
8847
+ * to 0,0. See AGT-658 for details.
8848
+ */
8849
+ move: {
8850
+ id: "move",
8851
+ 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.`,
8852
+ parameters: z10.object({
8853
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8854
+ marker: markerSchema("The marker to move the mouse to")
8855
+ })
8856
+ },
8857
+ paste: {
8858
+ id: "paste",
8859
+ description: "Paste text from the clipboard.",
8860
+ parameters: z10.object({
8861
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
8862
+ })
8863
+ },
8864
+ pressKeys: {
8865
+ id: "pressKeys",
8866
+ description: "Press given keys",
8867
+ parameters: z10.object({
8868
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8869
+ ...pressDataSchema.shape
8870
+ })
8871
+ },
8872
+ reportStop: {
8873
+ id: "reportStop",
8874
+ 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.",
8875
+ parameters: z10.object({
8876
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8877
+ ...reportStopDataSchema.shape
8878
+ })
8879
+ },
8880
+ scroll: {
8881
+ id: "scroll",
8882
+ 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",
8883
+ parameters: z10.object({
8884
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8885
+ ...scrollDataSchema.shape,
8886
+ // The previous mouse/cursor position is lost between workflow activities because we create a
8887
+ // new Playwright client each time. See AGT-658 for details.
8888
+ marker: z10.union([
8889
+ 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."),
8890
+ z10.enum(["body"]).describe('Specify the string "body" to scroll the top frame if there is no relevant marker.')
8891
+ ])
8892
+ })
8893
+ },
8894
+ scrollToText: {
8895
+ id: "scrollToText",
8896
+ 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.",
8897
+ parameters: z10.object({
8898
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8899
+ text: z10.string().describe("The text to find and scroll to"),
8900
+ scrollPosition: scrollToTextPositionEnum.optional().describe("The position the text should be relative to its scrollable container."),
8901
+ instance: z10.number().int().min(1).default(1).describe("If there are multiple matching elements, indicate which occurrence the agent should be scrolled to.")
8902
+ })
8903
+ },
8904
+ scrollToPattern: {
8905
+ id: "scrollToPattern",
8906
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
8907
+ parameters: z10.object({
8908
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8909
+ pattern: z10.string().min(1).describe("The regular expression to match."),
8910
+ flags: z10.string().regex(/^[dgimsuvy]*$/u, {
8911
+ message: "Flags can only contain valid RegExp flag characters: d, g, i, m, s, u, v, y"
8912
+ }).describe('The flags to use for the regular expression. Defaults to "iu" if not specified.').default("iu"),
8913
+ scrollPosition: scrollToTextPositionEnum.optional().describe("The position the text should be relative to its scrollable container."),
8914
+ instance: z10.number().int().min(1).default(1).describe("If there are multiple matching elements, indicate which occurrence the agent should be scrolled to.")
8915
+ })
8916
+ },
8917
+ selectDropdownOptions: {
8918
+ id: "selectDropdownOptions",
8919
+ description: "Select dropdown options with the given label text, replacing existing selections.",
8920
+ parameters: z10.object({
8921
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8922
+ marker: markerSchema("The marker of the `<select>` dropdown to change"),
8923
+ labels: z10.array(z10.string().describe("The label text of the dropdown option to select"))
8924
+ })
8925
+ },
8926
+ type: {
8927
+ id: "type",
8928
+ description: "Type in the currently focused element with the given text",
8929
+ parameters: z10.object({
8930
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8931
+ text: z10.string().describe("The text to type")
8932
+ })
8933
+ },
8934
+ getNDCFromMedication: {
8935
+ id: "getNDCFromMedication",
8936
+ 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.",
8937
+ parameters: z10.object({
8938
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8939
+ roa: z10.string().describe("The route of administration of the medication"),
8940
+ name: z10.string().describe("The name of the medication"),
8941
+ supply: z10.string().describe("The supply of the medication"),
8942
+ quantity: z10.string().describe("The quantity of the medication"),
8943
+ strength: z10.string().describe("The strength of the medication")
8944
+ })
8945
+ },
8946
+ navigateTo: {
8947
+ id: "navigateTo",
8948
+ description: "Navigate the browser to the specified URL. Use this when explicitly instructed to navigate to a URL.",
8949
+ parameters: z10.object({
8950
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8951
+ url: z10.url().describe("The URL to navigate to")
8952
+ })
8953
+ },
8954
+ navigateToLinkFromNewTab: {
8955
+ id: "navigateToLinkFromNewTab",
8956
+ 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.",
8957
+ parameters: z10.object({
8958
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8959
+ marker: markerSchema("The item to click on which opens in a new tab.")
8960
+ })
8961
+ },
8962
+ listTabs: {
8963
+ id: "listTabs",
8964
+ description: "List all open tabs in the browser session, including each tab ID, URL, and whether it is active.",
8965
+ parameters: z10.object({
8966
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
8967
+ })
8968
+ },
8969
+ openNewTab: {
8970
+ id: "openNewTab",
8971
+ description: "Open a new browser tab, navigate it to the provided URL, and switch the active tab to it.",
8972
+ parameters: z10.object({
8973
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8974
+ url: z10.url().describe("The URL to open in a new tab and navigate to.")
8975
+ })
8976
+ },
8977
+ switchToTab: {
8978
+ id: "switchToTab",
8979
+ description: "Switch the active browser tab to the tab ID returned by listTabs.",
8980
+ parameters: z10.object({
8981
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8982
+ tabId: z10.string().min(1).describe("The ID of the tab to activate.")
8983
+ })
8984
+ },
8985
+ closeTabs: {
8986
+ id: "closeTabs",
8987
+ description: "Close one or more tabs by ID. At least one tab must remain open after closing.",
8988
+ parameters: z10.object({
8989
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8990
+ tabIds: z10.array(z10.string().min(1)).min(1).describe("A list of tab IDs to close.")
8991
+ })
8992
+ },
8993
+ uploadFile: {
8994
+ id: "uploadFile",
8995
+ description: "Upload a file to a file input element in the browser. The filePath must be an S3 URI like s3://{key}",
8996
+ parameters: z10.object({
8997
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
8998
+ filePath: z10.string().describe("The URI to the file to upload like s3://{key}, it should be a valid URI to a file"),
8999
+ marker: markerSchema("The marker of the element to upload the file to")
9000
+ })
9001
+ },
9002
+ uploadScreenshot: {
9003
+ id: "uploadScreenshot",
9004
+ 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.",
9005
+ parameters: z10.object({
9006
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9007
+ 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."),
9008
+ marker: markerSchema("Optional marker of the element to capture instead of the full screenshot.").optional(),
9009
+ boundingBox: z10.object({
9010
+ x: z10.number().int().min(0).describe("The left edge of the bounding box in screenshot coordinates."),
9011
+ y: z10.number().int().min(0).describe("The top edge of the bounding box in screenshot coordinates."),
9012
+ width: z10.number().int().positive().describe("The width of the bounding box in screenshot pixels."),
9013
+ height: z10.number().int().positive().describe("The height of the bounding box in screenshot pixels.")
9014
+ }).optional().describe("Optional bounding box in screenshot coordinates for capturing only part of the current screenshot.")
9015
+ })
9016
+ },
9017
+ wait: {
9018
+ id: "wait",
9019
+ 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.",
9020
+ parameters: z10.object({
9021
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9022
+ seconds: z10.number().min(1).describe("The number of seconds to wait (must be at least 1)")
9023
+ })
9024
+ },
9025
+ notepad: {
9026
+ id: "notepad",
9027
+ 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.",
9028
+ parameters: z10.object({
9029
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9030
+ text: z10.string().describe("The text to write to the notepad")
9031
+ })
9032
+ },
9033
+ setCheckpointId: {
9034
+ id: "setCheckpointId",
9035
+ 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.",
9036
+ parameters: z10.object({
9037
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9038
+ name: z10.string().describe('The identifier name/type (e.g., "patientId", "email", "orderId")'),
9039
+ value: z10.string().describe('The identifier value (e.g., "12345", "user@example.com", "ORD-789")')
9040
+ })
9041
+ },
9042
+ checkpoint: {
9043
+ id: "checkpoint",
9044
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9045
+ parameters: z10.object({
9046
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9047
+ })
9048
+ },
9049
+ requestHumanIntervention: {
9050
+ id: "requestHumanIntervention",
9051
+ description: "Request intervention from a human. This tool should only be used when you are stuck and need to ask a human for help.",
9052
+ parameters: z10.object({
9053
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9054
+ 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."),
9055
+ 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.")
9056
+ })
9057
+ },
9058
+ /**
9059
+ * Should only be used in cases where markers are not being chosen correctly.
9060
+ * Updating the system and user prompts should be the first resort.
9061
+ */
9062
+ somFilter: {
9063
+ id: "somFilter",
9064
+ description: "IMPORTANT: DO NOT USE THIS TOOL. You are only allowed to use this tool if user specifically asks you to use it.",
9065
+ parameters: z10.object({
9066
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9067
+ includeMarks: z10.object({
9068
+ tagNames: z10.array(z10.string()),
9069
+ additionalLegendAttributes: z10.array(z10.string()).optional()
9070
+ }).describe("The marker tagNames to include").optional(),
9071
+ excludeMarks: z10.object({
9072
+ tagNames: z10.array(z10.string())
9073
+ }).describe("The marker tagNames to exclude").optional(),
9074
+ clearFilters: z10.boolean().default(false).describe("Whether to clear current som filter")
9075
+ })
9076
+ },
9077
+ fillCredential: {
9078
+ id: "fillCredential",
9079
+ 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.**",
9080
+ parameters: z10.object({
9081
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9082
+ marker: markerSchema("The marker to fill the credential into"),
9083
+ credential: z10.object({
9084
+ id: z10.string(),
9085
+ type: z10.enum([
9086
+ "email",
9087
+ "username",
9088
+ "password",
9089
+ "authenticatorCode",
9090
+ "phoneAuthenticatorCode"
9091
+ ]),
9092
+ args: z10.record(z10.string(), z10.unknown())
9093
+ })
9094
+ })
9095
+ },
9096
+ readRemoteFile: {
9097
+ id: "readRemoteFile",
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
+ listRemoteFiles: {
9104
+ id: "listRemoteFiles",
9105
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9106
+ parameters: z10.object({
9107
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9108
+ })
9109
+ },
9110
+ writeRemoteFile: {
9111
+ id: "writeRemoteFile",
9112
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9113
+ parameters: z10.object({
9114
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9115
+ })
9116
+ },
9117
+ writeRemoteFileFromStorage: {
9118
+ id: "writeRemoteFileFromStorage",
9119
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9120
+ parameters: z10.object({
9121
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9122
+ })
9123
+ },
9124
+ reloadPage: {
9125
+ id: "experimental_reloadPage",
9126
+ description: "Reload the current page.",
9127
+ parameters: z10.object({
9128
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9129
+ })
9130
+ },
9131
+ navigateBack: {
9132
+ id: "navigateBack",
9133
+ description: "Navigate the browser to the previous page in the history.",
9134
+ parameters: z10.object({
9135
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9136
+ })
9137
+ },
9138
+ getCurrentUrl: {
9139
+ id: "getCurrentUrl",
9140
+ description: "Get the current URL of the web page. Returns the full URL including protocol, domain, path, and query parameters.",
9141
+ parameters: z10.object({
9142
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9143
+ })
9144
+ },
9145
+ getSelectedText: {
9146
+ id: "getSelectedText",
9147
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9148
+ parameters: z10.object({
9149
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9150
+ })
9151
+ },
9152
+ notify: {
9153
+ id: "notify",
9154
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9155
+ parameters: z10.object({
9156
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9157
+ })
9158
+ },
9159
+ readDownloadedFile: {
9160
+ id: "readDownloadedFile",
9161
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9162
+ parameters: z10.object({
9163
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9164
+ })
9165
+ },
9166
+ fillCredentialsAndSubmit: {
9167
+ id: "fillCredentialsAndSubmit",
9168
+ description: "This object is deprecated, only adding here to satisfy the DB type check",
9169
+ parameters: z10.object({
9170
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS
9171
+ })
9172
+ },
9173
+ callSpecializedAgent: {
9174
+ id: "callSpecializedAgent",
9175
+ description: "Call a specialized agent to complete a task.",
9176
+ parameters: z10.object({
9177
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9178
+ agent: agentToolSchema
9179
+ })
9180
+ },
9181
+ queueAgents: {
9182
+ id: "queueAgents",
9183
+ 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.",
9184
+ parameters: z10.object({
9185
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9186
+ idempotencyKey: z10.string().optional(),
9187
+ 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."),
9188
+ queueItems: z10.array(agentToolSchema)
9189
+ })
9190
+ },
9191
+ callAPI: {
9192
+ id: "callAPI",
9193
+ description: "Call an API to complete a task.",
9194
+ parameters: z10.object({
9195
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9196
+ api: z10.unknown()
9197
+ })
9198
+ },
9199
+ generateObject: {
9200
+ id: "generateObject",
9201
+ description: "Generate an object using the AI.",
9202
+ parameters: z10.object({
9203
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9204
+ model: modelConfigSchema,
9205
+ prompt: z10.string().describe("The prompt to use for the generation."),
9206
+ successMessage: z10.string().optional().describe("The success message to use for the generation."),
9207
+ schema: z10.custom().describe("The output schema to use for the generation."),
9208
+ fileAssets: z10.array(z10.string()).optional().describe("The file assets to use for the generation.")
9209
+ })
9210
+ }
9211
+ };
9212
+ var triggerAgentToolDeclarations = {
9213
+ queueAgents: {
9214
+ id: "queueAgents",
9215
+ 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.",
9216
+ parameters: z10.object({
9217
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9218
+ 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."),
9219
+ runTime: z10.string().datetime({
9220
+ local: false
9221
+ }).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."),
9222
+ 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."),
9223
+ queueItems: z10.array(agentToolSchema)
9224
+ })
9225
+ },
9226
+ callSpecializedAgent: {
9227
+ id: "callSpecializedAgent",
9228
+ description: "Call a specialized agent to complete a task.",
9229
+ parameters: z10.object({
9230
+ [COMMON_PARAMETERS_KEY]: DEFAULT_COMMON_PARAMETERS,
9231
+ agent: agentToolSchema
9232
+ })
9233
+ }
9234
+ };
9235
+ var baseToolNames = Object.keys(baseToolDeclarations);
9236
+ var triggerAgentToolNames = Object.keys(triggerAgentToolDeclarations);
9237
+ var allToolNames = [
9238
+ ...baseToolNames,
9239
+ ...triggerAgentToolNames
9240
+ ];
9241
+ function markerSchema(description) {
9242
+ return z10.string().describe(`${description}
9243
+ MUST match this regex: /^[A-NP-Z][1-9]$/`);
9244
+ }
9245
+
9246
+ // ../common/dist/src/zod-schemas/agent-config.schema.js
9247
+ import { z as z15 } from "zod";
9248
+
9249
+ // ../common/dist/src/zod-schemas/api-request-body.schema.js
9250
+ import { z as z11 } from "zod";
9251
+ var ApiRequestBodyTypes = [
9252
+ "json",
9253
+ "multipartFormData",
9254
+ "formUrlEncoded"
9255
+ ];
9256
+ var ApiMethodsWithBody = ["POST", "PUT", "PATCH", "DELETE"];
9257
+ var ApiMultipartFormDataFieldTypes = ["text", "file"];
9258
+ var apiMultipartFormDataFieldSchema = z11.object({
9259
+ key: z11.string().describe("Form field name."),
9260
+ 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."),
9261
+ value: z11.string().describe("Form field value.")
9262
+ }).describe("A multipart form-data field. Defaults to a text field when type is omitted.");
9263
+ var apiMultipartFormDataBodySchema = z11.array(apiMultipartFormDataFieldSchema).describe("Multipart form-data body represented as an array of typed form-data fields.");
9264
+ var apiFormUrlEncodedFieldSchema = z11.object({
9265
+ key: z11.string().describe("Form field name."),
9266
+ value: z11.string().describe("Form field value.")
9267
+ }).describe("A form URL-encoded field.");
9268
+ var apiFormUrlEncodedBodySchema = z11.array(apiFormUrlEncodedFieldSchema).describe("Form URL-encoded body represented as an array of key/value fields.");
9269
+ function isValidApiMultipartFormDataBody({ bodyType, body }) {
9270
+ if (bodyType !== "multipartFormData" || body === void 0) {
9271
+ return true;
9272
+ }
9273
+ return apiMultipartFormDataBodySchema.safeParse(body).success;
9274
+ }
9275
+ function isValidApiFormUrlEncodedBody({ bodyType, body }) {
9276
+ if (bodyType !== "formUrlEncoded" || body === void 0) {
9277
+ return true;
9278
+ }
9279
+ return apiFormUrlEncodedBodySchema.safeParse(body).success;
9280
+ }
9281
+
9282
+ // ../common/dist/src/zod-schemas/api-tool.schema.js
9283
+ import { z as z12 } from "zod";
9284
+
9285
+ // ../common/dist/src/zod-schemas/enums.js
9286
+ var IdentifierTypes = {
9287
+ password: "password",
9288
+ username: "username",
9289
+ email: "email",
9290
+ authenticatorCode: "authenticatorCode",
9291
+ otp: "otp"
9292
+ };
9293
+ var RunStatuses = {
9294
+ queued: "QUEUED",
9295
+ running: "RUNNING",
9296
+ complete: "COMPLETE",
9297
+ pausedAsInstructed: "PAUSED_AS_INSTRUCTED",
9298
+ // Deprecated: use PAUSED status
9299
+ pausedForTestConfirmation: "PAUSED_FOR_TEST_CONFIRMATION",
9300
+ incompleteDueToError: "INCOMPLETE_DUE_TO_ERROR",
9301
+ manuallyStopped: "MANUALLY_STOPPED",
9302
+ pausedDueToUnforeseenBlocker: "PAUSED_DUE_TO_UNFORESEEN_BLOCKER",
9303
+ inconsistentResults: "INCONSISTENT_RESULTS",
9304
+ paused: "PAUSED"
9305
+ };
9306
+ var RUNNING_STATUSES = /* @__PURE__ */ new Set([
9307
+ RunStatuses.queued,
9308
+ RunStatuses.running,
9309
+ RunStatuses.pausedAsInstructed,
9310
+ RunStatuses.pausedDueToUnforeseenBlocker,
9311
+ RunStatuses.paused
9312
+ ]);
9313
+ var PAUSED_STATUSES = /* @__PURE__ */ new Set([
9314
+ RunStatuses.pausedAsInstructed,
9315
+ RunStatuses.pausedDueToUnforeseenBlocker,
9316
+ RunStatuses.paused
9317
+ ]);
9318
+ var STOPPED_STATUSES = /* @__PURE__ */ new Set([
9319
+ RunStatuses.complete,
9320
+ RunStatuses.incompleteDueToError,
9321
+ RunStatuses.manuallyStopped,
9322
+ RunStatuses.inconsistentResults
9323
+ ]);
9324
+ var RunStatusStateMachine = new StateMachine({
9325
+ states: Object.values(RunStatuses),
9326
+ transitions: {
9327
+ [RunStatuses.queued]: [
9328
+ RunStatuses.running,
9329
+ RunStatuses.incompleteDueToError,
9330
+ RunStatuses.manuallyStopped
9331
+ ],
9332
+ [RunStatuses.running]: [
9333
+ RunStatuses.pausedAsInstructed,
9334
+ RunStatuses.pausedDueToUnforeseenBlocker,
9335
+ RunStatuses.paused,
9336
+ RunStatuses.incompleteDueToError,
9337
+ RunStatuses.manuallyStopped,
9338
+ RunStatuses.complete,
9339
+ RunStatuses.inconsistentResults
9340
+ ],
9341
+ [RunStatuses.pausedAsInstructed]: [
9342
+ RunStatuses.running,
9343
+ RunStatuses.incompleteDueToError,
9344
+ RunStatuses.manuallyStopped,
9345
+ /*
9346
+ * Handles race condition: If agent tries to pause at the same time (i.e. before we handle the
9347
+ * user set pause in the DB) we want to show the agent's pause message over the
9348
+ * non-descriptive one given when the automation is paused by the user.
9349
+ */
9350
+ RunStatuses.pausedDueToUnforeseenBlocker,
9351
+ /*
9352
+ * Handles race condition: If agent requests confirmation while user pauses, allow the agent
9353
+ * to set PAUSED status (with statusDetail) to provide context about what needs confirmation.
9354
+ */
9355
+ RunStatuses.paused,
9356
+ /*
9357
+ * The agent will complete its current action before it is paused, that action could be
9358
+ * reportStop, which would cause the automation to be marked as complete.
9359
+ */
9360
+ RunStatuses.complete
9361
+ ],
9362
+ [RunStatuses.pausedDueToUnforeseenBlocker]: [
9363
+ RunStatuses.running,
9364
+ RunStatuses.incompleteDueToError,
9365
+ RunStatuses.manuallyStopped
9366
+ ],
9367
+ [RunStatuses.paused]: [
9368
+ RunStatuses.running,
9369
+ RunStatuses.incompleteDueToError,
9370
+ RunStatuses.manuallyStopped
9371
+ ],
9372
+ [RunStatuses.incompleteDueToError]: [],
9373
+ [RunStatuses.manuallyStopped]: [],
9374
+ [RunStatuses.complete]: [],
9375
+ [RunStatuses.inconsistentResults]: []
9376
+ }
9377
+ });
9378
+ var BrowserProviderNames = {
9379
+ local: "local",
9380
+ browserbase: "browserbase",
9381
+ agentcore: "agentcore",
9382
+ hyperbrowser: "hyperbrowser",
9383
+ steel: "steel"
9384
+ };
9385
+ var VoiceProviderNames = {
9386
+ vapi: "vapi"
9387
+ };
9388
+ var EvalRunStatuses = {
9389
+ queued: "QUEUED",
9390
+ running: "RUNNING",
9391
+ complete: "COMPLETE",
9392
+ failed: "FAILED",
9393
+ cancelled: "CANCELLED"
9394
+ };
9395
+ var EVAL_RUNNING_STATUSES = /* @__PURE__ */ new Set([
9396
+ EvalRunStatuses.queued,
9397
+ EvalRunStatuses.running
9398
+ ]);
9399
+ var EVAL_STOPPED_STATUSES = /* @__PURE__ */ new Set([
9400
+ EvalRunStatuses.complete,
9401
+ EvalRunStatuses.failed,
9402
+ EvalRunStatuses.cancelled
9403
+ ]);
9404
+ var EvalRunStatusStateMachine = new StateMachine({
9405
+ states: Object.values(EvalRunStatuses),
9406
+ transitions: {
9407
+ [EvalRunStatuses.queued]: [
9408
+ EvalRunStatuses.running,
9409
+ EvalRunStatuses.failed,
9410
+ EvalRunStatuses.cancelled
9411
+ ],
9412
+ [EvalRunStatuses.running]: [
9413
+ EvalRunStatuses.complete,
9414
+ EvalRunStatuses.failed,
9415
+ EvalRunStatuses.cancelled
9416
+ ],
9417
+ [EvalRunStatuses.complete]: [],
9418
+ [EvalRunStatuses.failed]: [],
9419
+ [EvalRunStatuses.cancelled]: []
9420
+ }
9421
+ });
9422
+ var ErrorCategorizations = {
9423
+ toolCallFailed: "TOOL_CALL_FAILED",
9424
+ noToolInStep: "NO_TOOL_IN_STEP",
9425
+ pageLoadingIssue: "PAGE_LOADING_ISSUE",
9426
+ captchaBlocker: "CAPTCHA_BLOCKER",
9427
+ loginCredentialsRequired: "LOGIN_CREDENTIALS_REQUIRED",
9428
+ serverError: "SERVER_ERROR",
9429
+ elementNotFound: "ELEMENT_NOT_FOUND",
9430
+ sessionError: "SESSION_ERROR",
9431
+ dataExtractionIssue: "DATA_EXTRACTION_ISSUE",
9432
+ authenticationFailed: "AUTHENTICATION_FAILED",
9433
+ navigationIssue: "NAVIGATION_ISSUE",
9434
+ unstablePageState: "UNSTABLE_PAGE_STATE",
9435
+ other: "OTHER",
9436
+ // Step-following analysis categories
9437
+ repeatAction: "REPEAT_ACTION",
9438
+ stepSkipped: "STEP_SKIPPED",
9439
+ unexpectedDeviation: "UNEXPECTED_DEVIATION",
9440
+ attemptedRecovery: "ATTEMPTED_RECOVERY",
9441
+ unusualPath: "UNUSUAL_PATH"
9442
+ };
9443
+ var STEP_FOLLOWING_CATEGORIZATIONS = /* @__PURE__ */ new Set([
9444
+ ErrorCategorizations.repeatAction,
9445
+ ErrorCategorizations.stepSkipped,
9446
+ ErrorCategorizations.unexpectedDeviation,
9447
+ ErrorCategorizations.attemptedRecovery,
9448
+ ErrorCategorizations.unusualPath
9449
+ ]);
9450
+ var ERROR_CATEGORIZATION_LIST = [
9451
+ ...Object.values(ErrorCategorizations).filter((category) => category !== ErrorCategorizations.other && category !== ErrorCategorizations.attemptedRecovery && category !== ErrorCategorizations.unusualPath),
9452
+ ErrorCategorizations.other
9453
+ ];
9454
+ var ERROR_CATEGORIZATION_DESCRIPTIONS = {
9455
+ [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.",
9456
+ [ErrorCategorizations.noToolInStep]: 'No tool is mentioned in the instructions for this step. Common phrases: "no tool", "missing tool", "tool not specified".',
9457
+ [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".',
9458
+ [ErrorCategorizations.captchaBlocker]: 'CAPTCHA or reCAPTCHA challenge appeared and requires human intervention to solve. Common phrases: "CAPTCHA", "reCAPTCHA", "challenge", "verification required".',
9459
+ [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".',
9460
+ [ErrorCategorizations.serverError]: 'Server or service errors. Common: "500", "502", "503", "504", "service unavailable", "internal server error".',
9461
+ [ErrorCategorizations.sessionError]: 'Browser/remote session or connection failures Common: "browserType.connectOverCDP", "connection timeout", "browserbase", "session disconnected".',
9462
+ [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.).',
9463
+ [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).',
9464
+ [ErrorCategorizations.authenticationFailed]: 'Authentication or login attempt failed. Common phrases: "authentication failed", "login failed", "invalid credentials", "locked account", "expired session", "2FA required".',
9465
+ [ErrorCategorizations.navigationIssue]: 'Navigation problem. Common phrases: "wrong page", "redirect issue", "URL error", "cannot reach site", "SSL error", "navigation failed".',
9466
+ [ErrorCategorizations.unstablePageState]: 'Page changed unexpectedly between decision and execution. Common: "markers moved", "page state changed", "unstable session state", "screenshot inconsistency".',
9467
+ [ErrorCategorizations.other]: "Other types of errors not covered above",
9468
+ [ErrorCategorizations.repeatAction]: "Agent repeated an action that caused critical real-world side effects (e.g., duplicate submissions, repeated sends).",
9469
+ [ErrorCategorizations.stepSkipped]: "Agent skipped a required step, causing missed real-world effects or derailing positioning for future steps.",
9470
+ [ErrorCategorizations.unexpectedDeviation]: "Agent performed an unauthorized action that caused critical impact (e.g., submitted unplanned data, took destructive actions).",
9471
+ [ErrorCategorizations.attemptedRecovery]: "Agent deviated from instructions but was performing valid recovery (e.g., navigating back, re-logging in, retracing steps).",
9472
+ [ErrorCategorizations.unusualPath]: "Agent took a different path than instructed but with no critical impact and no clear recovery intent."
9473
+ };
9474
+ var ERROR_CATEGORIZATION_LABEL = {
9475
+ [ErrorCategorizations.toolCallFailed]: "Tool call failed",
9476
+ [ErrorCategorizations.noToolInStep]: "No tool in step",
9477
+ [ErrorCategorizations.pageLoadingIssue]: "Page loading issue",
9478
+ [ErrorCategorizations.captchaBlocker]: "Captcha blocker",
9479
+ [ErrorCategorizations.loginCredentialsRequired]: "Login credentials required",
9480
+ [ErrorCategorizations.serverError]: "Server error",
9481
+ [ErrorCategorizations.sessionError]: "Session error",
9482
+ [ErrorCategorizations.unstablePageState]: "Unstable page state",
9483
+ [ErrorCategorizations.elementNotFound]: "Element not found",
9484
+ [ErrorCategorizations.dataExtractionIssue]: "Data extraction issue",
9485
+ [ErrorCategorizations.authenticationFailed]: "Authentication failed",
9486
+ [ErrorCategorizations.navigationIssue]: "Navigation issue",
9487
+ [ErrorCategorizations.other]: "Other",
9488
+ [ErrorCategorizations.repeatAction]: "Repeat action",
9489
+ [ErrorCategorizations.stepSkipped]: "Step skipped",
9490
+ [ErrorCategorizations.unexpectedDeviation]: "Unexpected deviation",
9491
+ [ErrorCategorizations.attemptedRecovery]: "Attempted recovery",
9492
+ [ErrorCategorizations.unusualPath]: "Unusual path"
9493
+ };
9494
+
9495
+ // ../common/dist/src/zod-schemas/api-tool.schema.js
9496
+ var methodsWithBody = new Set(ApiMethodsWithBody);
9497
+ var SECONDS_PER_DAY = 24 * 60 * 60;
9498
+ var API_RESPONSE_CACHE_DEFAULT_TTL_DAYS = 7;
9499
+ var API_RESPONSE_CACHE_DEFAULT_TTL_SECONDS = API_RESPONSE_CACHE_DEFAULT_TTL_DAYS * SECONDS_PER_DAY;
9500
+ var defaultApiResponseCacheConfig = {
9501
+ enabled: false,
9502
+ ttl: API_RESPONSE_CACHE_DEFAULT_TTL_SECONDS
9503
+ };
9504
+ var apiResponseCacheConfigObjectSchema = z12.object({
9505
+ enabled: z12.boolean().default(defaultApiResponseCacheConfig.enabled).describe("Whether API response caching is enabled for this request."),
9506
+ ttl: z12.number().int().positive().default(defaultApiResponseCacheConfig.ttl).describe("Time-to-live for cached successful API responses, measured in seconds.")
9507
+ });
9508
+ 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.");
9509
+ var apiToolSchema = z12.object({
9510
+ name: z12.string().describe("Unique name for the API tool."),
9511
+ description: z12.string().describe("Description of what the API tool does. Shown to the agent to help it decide when to use this tool."),
9512
+ inputSchema: z12.custom().optional().describe("JSON schema (in serialized Zod format) defining the input parameters for the API call."),
9513
+ authInputs: z12.array(z12.object({
9514
+ key: z12.string().describe("Parameter key where the auth value will be injected."),
9515
+ value: z12.object({
9516
+ authId: z12.string().describe("ID of the authentication credential to use."),
9517
+ factor: z12.enum(IdentifierTypes).optional().describe("Type of authentication factor.")
9518
+ })
9519
+ })).optional().describe("Authentication inputs to inject into the API call. Maps parameter keys to saved credentials."),
9520
+ type: z12.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]).describe("HTTP method for the API call."),
9521
+ url: z12.string().describe("URL template for the API endpoint. Can include placeholders like {paramName} for dynamic values."),
9522
+ headers: z12.record(z12.string(), z12.string()).optional().describe("HTTP headers to include in the request. Values can include placeholders."),
9523
+ queryParams: z12.record(z12.string(), z12.string()).optional().describe("Query parameters to include in the URL. Values can include placeholders."),
9524
+ body: z12.unknown().optional().describe("Request body template. Can include placeholders for dynamic values."),
9525
+ 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."),
9526
+ outputJmesPath: z12.string().optional().describe("JMESPath expression to extract specific data from the API response before returning it to the agent."),
9527
+ cacheResponse: apiResponseCacheConfigSchema
9528
+ }).refine((data) => !(data.bodyType !== void 0 && !methodsWithBody.has(data.type)), {
9529
+ message: "Body type is not supported for this method",
9530
+ path: ["bodyType"]
9531
+ }).refine((data) => isValidApiMultipartFormDataBody({
9532
+ bodyType: data.bodyType,
9533
+ body: data.body
9534
+ }), {
9535
+ message: "Multipart form-data body must be an array of { key, type?, value } fields",
9536
+ path: ["body"]
9537
+ }).refine((data) => isValidApiFormUrlEncodedBody({
9538
+ bodyType: data.bodyType,
9539
+ body: data.body
9540
+ }), {
9541
+ message: "Form URL-encoded body must be an array of { key, value } fields",
9542
+ path: ["body"]
9543
+ }).describe("Custom API tool definition. Allows agents to make HTTP requests to external APIs.");
9544
+
9545
+ // ../common/dist/src/zod-schemas/run-limitation.schema.js
9546
+ import { z as z13 } from "zod";
9547
+ var MAX_BROWSER_SESSION_DURATION_SECONDS = 6 * 60 * 60;
9548
+ var BROWSER_TERMINATION_BUFFER_SECONDS = 60;
9549
+ var MAX_AUTOMATION_DURATION_SECONDS = MAX_BROWSER_SESSION_DURATION_SECONDS - BROWSER_TERMINATION_BUFFER_SECONDS;
9550
+ var MAX_AUTOMATION_TOOL_CALLS = 500;
9551
+ var MAX_AGENT_TOOL_CALLS = 50;
9552
+ 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.");
9553
+ var baseRunLimitationSchema = z13.object({
9554
+ maxDurationSeconds: maxDurationSecondsSchema,
9555
+ maxToolCalls: z13.number().optional().describe("Maximum number of tool calls allowed. The run will pause with MAX_TOOL_CALLS_REACHED when exceeded."),
9556
+ 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.")
9557
+ });
9558
+ var automationRunLimitationSchema = baseRunLimitationSchema.extend({
9559
+ maxToolCalls: z13.number().optional().default(MAX_AUTOMATION_TOOL_CALLS).describe("Maximum number of tool calls allowed across all agents in the automation.")
9560
+ }).optional().default({
9561
+ maxDurationSeconds: MAX_AUTOMATION_DURATION_SECONDS,
9562
+ maxToolCalls: MAX_AUTOMATION_TOOL_CALLS
9563
+ }).describe("Resource limits for the automation run.");
9564
+ var agentRunLimitationSchema = baseRunLimitationSchema.extend({
9565
+ maxToolCalls: z13.number().optional().default(MAX_AGENT_TOOL_CALLS).describe("Maximum number of tool calls allowed for this agent.")
9566
+ }).optional().default({
9567
+ maxDurationSeconds: MAX_AUTOMATION_DURATION_SECONDS,
9568
+ maxToolCalls: MAX_AGENT_TOOL_CALLS
9569
+ }).describe("Resource limits for the agent run.");
9570
+
9571
+ // ../common/dist/src/zod-schemas/voice-provider-options.schema.js
9572
+ import { z as z14 } from "zod";
9573
+ var voiceParticipantSchema = z14.object({
9574
+ 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."),
9575
+ name: z14.string().min(1).optional().describe("Display name to associate with this call participant.")
9576
+ }).describe("Default voice call participant settings.");
9577
+ var vapiVoiceProviderOptionsSchema = z14.object({
9578
+ assistantId: z14.string().min(1).optional().describe("Existing Vapi assistant ID to start or hand off the call to."),
9579
+ assistant: z14.record(z14.string(), z14.unknown()).optional().describe("Inline Vapi assistant definition used when an explicit assistantId is not provided."),
9580
+ assistantOverrides: z14.record(z14.string(), z14.unknown()).optional().describe("Runtime assistant override payload forwarded to Vapi when starting or handing off a call."),
9581
+ caller: voiceParticipantSchema.optional().describe("Default caller settings for outbound calls."),
9582
+ callee: voiceParticipantSchema.optional().describe("Default callee settings for outbound calls."),
9583
+ phoneNumberId: z14.string().min(1).optional().describe("Vapi phone number ID used to originate outbound calls."),
9584
+ enableDtmf: z14.boolean().optional().describe("Whether the call should support DTMF input.")
9585
+ }).describe("Configuration options specific to the Vapi voice provider.");
9586
+ var voiceProviderOptionsSchema = z14.object({
9587
+ vapi: vapiVoiceProviderOptionsSchema.optional().describe("Configuration options specific to the Vapi provider.")
9588
+ }).describe("Provider-specific voice configuration options. Only the options for the selected voiceProvider are used.");
9589
+
9590
+ // ../common/dist/src/zod-schemas/agent-config.schema.js
9591
+ var NangoSupportedMethods = [
9592
+ "GET",
9593
+ "POST",
9594
+ "PUT",
9595
+ "PATCH",
9596
+ "DELETE"
9597
+ ];
9598
+ var startingUrlSchema = z15.string().refine(isValidUrlOrHandlebarsTemplateString, {
9599
+ message: "Starting URL must be a valid URL or Handlebars template"
9600
+ }).optional();
9601
+ var browserSOMEnvironmentOptionsSchema = z15.object({
9602
+ environment: z15.literal("browser").describe("Browser environment using Set of Marks (SOM) for element identification."),
9603
+ maxMediaToIncludeInMemory: z15.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
9604
+ saveAuthCookiesAfterRun: z15.boolean().optional().describe("Whether to save authentication cookies after the run completes for reuse in future runs."),
9605
+ 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."),
9606
+ 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."),
9607
+ browserProviderOptions: browserProviderOptionsSchema.optional().describe("Provider-specific configuration options for the browser.")
9608
+ }).describe("Browser environment configuration using Set of Marks (SOM) for element identification. This is the recommended browser mode for most use cases.");
9609
+ var browserCoordinatesEnvironmentOptionsSchema = z15.object({
9610
+ environment: z15.literal("browserCoordinates").describe("Browser environment using coordinate-based interactions instead of SOM."),
9611
+ maxMediaToIncludeInMemory: z15.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
9612
+ saveAuthCookiesAfterRun: z15.boolean().optional().describe("Whether to save authentication cookies after the run completes for reuse in future runs."),
9613
+ 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."),
9614
+ 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."),
9615
+ browserProviderOptions: browserProviderOptionsSchema.optional().describe("Provider-specific configuration options for the browser.")
9616
+ }).describe("Browser environment configuration using coordinate-based interactions. Use for scenarios where SOM-based identification is insufficient.");
9617
+ var guacamoleEnvironmentOptionsSchema = z15.object({
9618
+ environment: z15.literal("desktop").describe("Desktop environment using Guacamole for remote desktop access."),
9619
+ browserProvider: z15.nativeEnum(BrowserProviderNames).default(BrowserProviderNames.browserbase).describe("Browser provider to use to connect to Guacamole."),
9620
+ browserProviderOptions: browserProviderOptionsSchema.optional().describe("Provider-specific configuration options."),
9621
+ maxMediaToIncludeInMemory: z15.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
9622
+ startingUrl: startingUrlSchema.describe("Initial URL for the Guacamole connection. Accepts a valid URL or a Handlebars template with agent inputs."),
9623
+ useCopyPasteForTyping: z15.boolean().default(false).optional().describe("Use copy-paste instead of keystroke simulation for text input. Can improve reliability in some desktop applications.")
9624
+ }).describe("Desktop environment configuration using Guacamole for remote desktop automation.");
9625
+ var desktopAppEnvironmentOptionsSchema = z15.object({
9626
+ environment: z15.literal("desktopApp").describe("Native application environment for mobile or desktop app automation."),
9627
+ maxMediaToIncludeInMemory: z15.number().min(1).optional().describe("Maximum number of screenshots/media items to keep in the agent memory context."),
9628
+ 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.`)
9629
+ }).describe("Native application environment configuration for automating mobile or desktop applications.");
9630
+ var minimalEnvironmentOptionsSchema = z15.object({
9631
+ environment: z15.literal("minimal").describe("Minimal environment without browser or desktop capabilities. Use for non-UI agents.")
9632
+ }).describe("Minimal environment configuration for agents that do not require browser or desktop access (e.g., API-only agents).");
9633
+ var voiceEnvironmentOptionsSchema = z15.object({
9634
+ environment: z15.literal("voice").describe("Hosted voice environment for live phone or audio conversations."),
9635
+ 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."),
9636
+ voiceProviderOptions: voiceProviderOptionsSchema.optional().describe("Provider-specific configuration options for voice runtime.")
9637
+ }).describe("Voice environment configuration for hosted conversational runtimes such as Vapi.");
9638
+ var environmentOptionsSchema = z15.discriminatedUnion("environment", [
9639
+ browserSOMEnvironmentOptionsSchema,
9640
+ browserCoordinatesEnvironmentOptionsSchema,
9641
+ guacamoleEnvironmentOptionsSchema,
9642
+ desktopAppEnvironmentOptionsSchema,
9643
+ voiceEnvironmentOptionsSchema,
9644
+ minimalEnvironmentOptionsSchema
9645
+ ]).describe("Environment configuration for the agent. Determines the execution context.");
9646
+ var environmentNames = [
9647
+ "browser",
9648
+ "browserCoordinates",
9649
+ "desktop",
9650
+ "desktopApp",
9651
+ "voice",
9652
+ "minimal"
9653
+ ];
9654
+ var environmentNamesSchema = z15.enum(environmentNames).describe("Available environment types: browser (SOM-based), browserCoordinates (coordinate-based), desktop (Guacamole), desktopApp, voice, or minimal.");
9655
+ var DEFAULT_ENVIRONMENT_OPTION = environmentOptionsSchema.parse({
9656
+ environment: "browser"
9657
+ });
9658
+ var resourcePoolReferenceSchema = z15.object({
9659
+ id: z15.string().uuid().describe("Unique identifier of the resource pool."),
9660
+ type: z15.enum([
9661
+ "commandGenerated",
9662
+ "proxy",
9663
+ "apiAuthentication",
9664
+ "desktopAppAuthentication"
9665
+ ]).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).")
9666
+ });
9667
+ var resourcePoolsSchema = z15.array(resourcePoolReferenceSchema).max(5, "Only five resource pools per starting agent are currently supported").optional();
9668
+ var agentRunSettingsSchema = z15.object({
9669
+ 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."),
9670
+ 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."),
9671
+ 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.")
9672
+ });
9673
+ var remoteFileConnectionSchema = z15.object({
9674
+ description: z15.string().describe("Human-readable description of this remote file connection."),
9675
+ host: z15.string().describe("Hostname or IP address of the remote server."),
9676
+ port: z15.number().describe("Port number for the connection (e.g., 22 for SFTP)."),
9677
+ protocol: z15.enum(["sftp"]).describe("Protocol to use for the connection. Currently only SFTP is supported."),
9678
+ opItemId: z15.string().describe("1Password item ID containing the credentials."),
9679
+ opVaultId: z15.string().describe("1Password vault ID containing the item.")
9680
+ }).describe("Remote file connection configuration for SFTP access. Credentials are stored securely in 1Password.");
9681
+ 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.");
9682
+ var codeLanguages = ["typescript"];
9683
+ var windowsAbsolutePathPattern = /^[A-Za-z]:[\\/]/u;
9684
+ function hasControlCharacter(value) {
9685
+ for (const character of value) {
9686
+ const codePoint = character.codePointAt(0);
9687
+ if (codePoint !== void 0 && (codePoint <= 31 || codePoint === 127)) {
9688
+ return true;
9689
+ }
9690
+ }
9691
+ return false;
9692
+ }
9693
+ function isNormalizedRepoPath(path7) {
9694
+ if (path7 === "/") {
9695
+ return true;
9696
+ }
9697
+ if (path7.length === 0 || path7.startsWith("/") || path7.startsWith("\\") || path7.includes("\\") || hasControlCharacter(path7) || windowsAbsolutePathPattern.test(path7)) {
9698
+ return false;
9699
+ }
9700
+ return path7.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== ".." && segment !== ".git");
9701
+ }
9702
+ var knowledgeBasePluginPermissionSchema = z15.object({
9703
+ path: z15.string().min(1).refine(isNormalizedRepoPath, {
9704
+ message: "Path must be a normalized repository-relative path."
9705
+ }).describe("Repository path the knowledge base plugin can access."),
9706
+ access: z15.enum(["read", "write"]).describe("Access level for the path. Write access also grants reads.")
9707
+ }).describe("Path-scoped permission for the knowledge base runtime plugin.");
9708
+ var knowledgeBaseConfigSchema = z15.object({
9709
+ enabled: z15.boolean().default(false).describe("Explicit rollout switch for the knowledge base runtime plugin."),
9710
+ permissions: z15.array(knowledgeBasePluginPermissionSchema).min(1).describe("Repository paths the knowledge base plugin can access. Write grants read and write access.")
9711
+ }).describe("Configuration for the knowledge base runtime plugin.");
9712
+ var agentPluginsConfigSchema = z15.object({
9713
+ knowledgeBase: knowledgeBaseConfigSchema.optional().describe("Enables the knowledge base runtime plugin.")
9714
+ }).optional().describe("Runtime plugins enabled for this agent. Plugin tools are not controlled by the built-in tools allow-list.");
9715
+ var baseAgentConfigFieldsSchema = z15.object({
9716
+ apiTools: z15.array(apiToolSchema).optional().describe("Custom API tools available to this agent. Each tool defines an HTTP endpoint the agent can call."),
9717
+ remoteFileConnections: z15.array(remoteFileConnectionSchema).optional().describe("Remote file server connections for SFTP operations. Enables agents to read/write files on remote servers."),
9718
+ 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."),
9719
+ 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."),
9720
+ knowledgeBase: z15.object({
9721
+ namespace: z15.string().describe("Vector database namespace for knowledge retrieval."),
9722
+ k: z15.number().describe("Number of results to retrieve from the knowledge base per query.")
9723
+ }).optional().describe("Knowledge base configuration for RAG (Retrieval-Augmented Generation). Enables the agent to query a vector database."),
9724
+ plugins: agentPluginsConfigSchema,
9725
+ 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."),
9726
+ environmentOptions: environmentOptionsSchema.optional().default(DEFAULT_ENVIRONMENT_OPTION).describe("Environment configuration for the agent. Default is browser with SOM."),
9727
+ 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."),
9728
+ 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."),
9729
+ limitations: agentRunLimitationSchema.describe("Resource limits for this agent, including maximum duration and tool call limits."),
9730
+ 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."),
9731
+ idempotencySettings: z15.object({
9732
+ include: z15.array(z15.string()).optional().describe("Input field names to include in the idempotency key. If specified, only these fields are used."),
9733
+ exclude: z15.array(z15.string()).optional().describe("Input field names to exclude from the idempotency key. Ignored if include is specified."),
9734
+ workflowIdReusePolicy: workflowIdReusePolicySchema.optional().default("ALLOW_DUPLICATE").describe("Policy for reusing Temporal workflow IDs.")
9735
+ }).optional().describe("Idempotency settings for preventing duplicate runs. Controls which input fields contribute to the unique run identifier."),
9736
+ 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."),
9737
+ waitUponQueueing: z15.boolean().optional().default(false).describe("If true, wait for queued child agents to complete before proceeding."),
9738
+ 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."),
9739
+ checkpoint: z15.object({
9740
+ name: z15.string().describe("Name for the checkpoint, used for filtering and identification."),
9741
+ screenshot: z15.boolean().optional().default(false).describe("Whether to capture a screenshot when creating the checkpoint.")
9742
+ }).optional().describe("Checkpoint configuration. When set, agent iterations are recorded as checkpoints for auditing and debugging."),
9743
+ 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."),
9744
+ additionalSystemPrompt: z15.string().optional().describe("Additional instructions appended to the system prompt for this agent. Combined with automation-level additionalSystemPrompt."),
9745
+ // Backlinking metadata for imported agents
9746
+ importedFrom: z15.object({
9747
+ automationId: brandedStringValidator("draftAutomationId").describe("ID of the source automation from which this agent was imported."),
9748
+ originalAgentId: brandedStringValidator("agentId").describe("Original agent ID in the source automation.")
9749
+ }).optional().describe("Metadata for agents imported from another automation. Used for traceability and updates."),
9750
+ ignoreUnstableSessionState: z15.boolean().optional().describe("When true, skips screenshot consistency checks before tool execution. Overrides the automation-level ignoreUnstableSessionState setting.")
9751
+ }).superRefine((config, ctx) => {
9752
+ if (config.resourcePools !== void 0 && config.runSettings?.resourcePools !== void 0 && !isDeepEqualAndSameType(config.resourcePools, config.runSettings.resourcePools)) {
9753
+ ctx.addIssue({
9754
+ code: z15.ZodIssueCode.custom,
9755
+ path: ["runSettings", "resourcePools"],
9756
+ message: "runSettings.resourcePools must match resourcePools when both are provided"
9757
+ });
9758
+ }
9759
+ });
9760
+ var agenticAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9761
+ type: z15.literal("agentic").describe("Agentic agent type - autonomous AI agent with tool calling capabilities."),
9762
+ model: agentModelConfigSchema.describe("LLM model configuration for this agentic agent.")
9763
+ }).describe("Agentic agent configuration. Uses an LLM to autonomously decide which tools to call to accomplish tasks.");
9764
+ var codeAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9765
+ type: z15.literal("code").describe("Code agent type - executes predefined code instead of LLM-driven decisions."),
9766
+ language: z15.enum(codeLanguages).default("typescript").describe("Programming language for the agent code. Currently only TypeScript is supported.")
9767
+ }).describe("Code agent configuration. Executes predefined TypeScript code instead of using LLM-driven decision making.");
9768
+ var extractAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9769
+ type: z15.literal("extract").describe("Extract agent type - specialized for structured data extraction."),
9770
+ model: agentModelConfigSchema.describe("LLM model configuration for this extract agent.")
9771
+ }).describe("Extract agent configuration. Specialized for extracting structured data from files according to a defined output schema.");
9772
+ var OutcomePayloadSchema = z15.object({
9773
+ id: z15.string().min(1).describe("Unique identifier for the outcome."),
9774
+ input: z15.record(z15.string(), z15.unknown()).describe("Input data for the outcome. Maps parameter keys to values."),
9775
+ preview: z15.string().describe("Rendered text representation of the outcome.")
9776
+ });
9777
+ var branchAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9778
+ type: z15.literal("branch").describe("Branch agent type - makes decisions to route to different agents."),
9779
+ model: agentModelConfigSchema.describe("LLM model configuration for this branch agent."),
9780
+ conditionsAndOutcomes: z15.object({
9781
+ if: z15.array(z15.object({
9782
+ caseName: z15.string().describe("Name of the condition case."),
9783
+ condition: z15.string().min(1).describe("Condition to evaluate."),
9784
+ outcome: z15.array(OutcomePayloadSchema).describe("Outcomes to return if the condition is met.")
9785
+ })).min(1).describe("Conditions and outcomes for the branch agent."),
9786
+ else: z15.array(OutcomePayloadSchema).min(1).describe("Outcomes to return if the condition is not met.")
9787
+ }).describe("Conditions and outcomes for the branch agent, including a fallback outcome.")
9788
+ }).describe("Branch agent configuration. Makes decisions about which agent to call next based on the current context.");
9789
+ var draftBranchAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9790
+ type: z15.literal("branch").describe("Branch agent draft configuration. Allows incomplete conditions and outcomes while the agent is still being authored."),
9791
+ model: agentModelConfigSchema.describe("LLM model configuration for this branch agent."),
9792
+ conditionsAndOutcomes: z15.object({
9793
+ if: z15.array(z15.object({
9794
+ caseName: z15.string().describe("Name of the condition case."),
9795
+ condition: z15.string().describe("Condition to evaluate. Draft saves may include an empty placeholder while the user is still editing."),
9796
+ outcome: z15.array(OutcomePayloadSchema).describe("Outcomes to return if the condition is met.")
9797
+ })).describe("Draft branch conditions and outcomes."),
9798
+ else: z15.array(OutcomePayloadSchema).describe("Draft fallback outcomes for the branch agent. May be empty while the branch is still being configured.")
9799
+ }).describe("Draft conditions and outcomes for the branch agent, including an optional fallback outcome while editing.")
9800
+ }).describe("Branch agent draft configuration. More permissive than the authored branch schema so incomplete draft branches can be saved.");
9801
+ var METHODS_WITH_BODY = new Set(ApiMethodsWithBody);
9802
+ var apiAgentConfigSchema = baseAgentConfigFieldsSchema.safeExtend({
9803
+ type: z15.literal("api").describe("API agent type - makes HTTP requests to external APIs."),
9804
+ method: z15.enum(NangoSupportedMethods).describe("HTTP method for the API request (GET, POST, PUT, PATCH, DELETE)."),
9805
+ url: z15.string().describe("URL for the API endpoint. Can include placeholders like {paramName} for dynamic values from inputs."),
9806
+ headers: z15.array(z15.object({ key: z15.string(), value: z15.string() })).optional().describe("HTTP headers to include in the request. Values can include placeholders."),
9807
+ queryParams: z15.array(z15.object({ key: z15.string(), value: z15.string() })).optional().describe("Query parameters to append to the URL. Values can include placeholders."),
9808
+ body: z15.unknown().optional().describe("Request body for POST/PUT/PATCH requests. Can include placeholders for dynamic values."),
9809
+ 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."),
9810
+ outputJmesPath: z15.string().optional().describe("JMESPath expression to extract specific data from the API response before returning it."),
9811
+ cacheResponse: apiResponseCacheConfigSchema.describe("Response cache configuration for this API agent. TTL is measured in seconds."),
9812
+ authentication: z15.discriminatedUnion("type", [
9813
+ z15.object({
9814
+ type: z15.literal("nangoConnection").describe("Authentication via Nango integration."),
9815
+ providerConfigKey: z15.string().describe('The provider config key for the integration (e.g., "github", "slack").'),
9816
+ poolId: brandedStringValidator("resourcePoolId").optional().describe("ID of the resource pool containing authentication credentials.")
9817
+ }),
9818
+ z15.object({
9819
+ type: z15.literal("customHost").describe("Authentication via 1Password credentials for custom host."),
9820
+ poolId: brandedStringValidator("resourcePoolId").optional().describe("ID of the resource pool containing 1Password authentication.")
9821
+ })
9822
+ ]).optional().describe("Authentication configuration for the API request. Uses credentials from a resource pool.")
9823
+ }).refine((data) => !(data.body !== void 0 && !METHODS_WITH_BODY.has(data.method)), {
9824
+ message: "Body is not supported for this method",
9825
+ path: ["body"]
9826
+ }).refine((data) => !(data.bodyType !== void 0 && !METHODS_WITH_BODY.has(data.method)), {
9827
+ message: "Body type is not supported for this method",
9828
+ path: ["bodyType"]
9829
+ }).refine((data) => isValidApiMultipartFormDataBody({
9830
+ bodyType: data.bodyType,
9831
+ body: data.body
9832
+ }), {
9833
+ message: "Multipart form-data body must be an array of { key, type?, value } fields",
9834
+ path: ["body"]
9835
+ }).refine((data) => isValidApiFormUrlEncodedBody({
9836
+ bodyType: data.bodyType,
9837
+ body: data.body
9838
+ }), {
9839
+ message: "Form URL-encoded body must be an array of { key, value } fields",
9840
+ path: ["body"]
9841
+ }).describe("API agent configuration. Makes HTTP requests to external APIs without LLM decision making. Supports authentication via Nango connections.");
9842
+ var agentConfigSchemaUnion = z15.discriminatedUnion("type", [
9843
+ agenticAgentConfigSchema,
9844
+ codeAgentConfigSchema,
9845
+ extractAgentConfigSchema,
9846
+ branchAgentConfigSchema,
9847
+ apiAgentConfigSchema
9848
+ ]).describe("Agent configuration discriminated by type. Types: agentic (LLM-driven), code (predefined code), extract (data extraction), branch (routing decisions), api (HTTP requests).");
9849
+ var agentConfigSchema = z15.preprocess((data) => {
9850
+ if (typeof data === "object" && data !== null && !("type" in data)) {
9851
+ return { ...data, type: "agentic" };
9852
+ }
9853
+ return data;
9854
+ }, agentConfigSchemaUnion).describe("Agent configuration. Defines the agent type, environment, available tools, model settings, and behavior options. If type is omitted, defaults to agentic.");
9855
+ var draftAgentConfigSchemaUnion = z15.discriminatedUnion("type", [
9856
+ agenticAgentConfigSchema,
9857
+ codeAgentConfigSchema,
9858
+ extractAgentConfigSchema,
9859
+ draftBranchAgentConfigSchema,
9860
+ apiAgentConfigSchema
9861
+ ]).describe("Draft agent configuration discriminated by type. Uses a more permissive branch schema so incomplete branches can be saved before publish-time validation.");
9862
+ var draftAgentConfigSchema = z15.preprocess((data) => {
9863
+ if (typeof data === "object" && data !== null && !("type" in data)) {
9864
+ return { ...data, type: "agentic" };
9865
+ }
9866
+ return data;
9867
+ }, draftAgentConfigSchemaUnion).describe("Draft agent configuration. Matches authored validation for most agent types, but allows incomplete branch agents during draft saves.");
9868
+ var DEFAULT_AGENT_CONFIG = agentConfigSchema.parse({});
9869
+
9870
+ // ../common/dist/src/zod-schemas/automation-run-config.schema.js
9871
+ import { z as z16 } from "zod";
9872
+ var automationRunResolvedRunSettingsSchema = z16.object({
9873
+ 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."),
9874
+ 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."),
9875
+ skipBrowserDebuggerPauses: z16.boolean().optional().describe("Canonical run-settings-owned browser session startup setting snapshotted onto the automation run when it starts in runSettings mode.")
9876
+ });
9877
+ var CONSISTENCY_CHECK_COUNT_MAX = 50;
9878
+ var automationRunConfigSchema = z16.object({
9879
+ approvalMode: z16.enum(["HUMAN_APPROVAL", "OFF"]).default("OFF"),
9880
+ consistencyCheckCount: z16.number().int().nonnegative().max(CONSISTENCY_CHECK_COUNT_MAX).nullable().default(null),
9881
+ 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."),
9882
+ startInTakeOverMode: z16.boolean().default(false).describe("When true, create and prepare the remote session, then pause until a human manually starts the agent."),
9883
+ 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."),
9884
+ 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.")
9885
+ });
9886
+ var automationRunStartConfigSchema = automationRunConfigSchema.omit({
9887
+ resolvedRunSettings: true,
9888
+ resolvedRunSettingsSource: true
9889
+ });
9890
+
9891
+ // ../mcp-registry/src/operation-specs.ts
9892
+ import { z as z17 } from "zod";
9893
+
9894
+ // ../mcp-registry/src/operation-spec.ts
9895
+ function stripLeadingGraphqlComments(document) {
9896
+ return document.replace(/^(?:\s*#.*\n)+/u, "").trimStart();
9897
+ }
9898
+ function assertDocumentMatchesOperation({
9899
+ document,
9900
+ kind,
9901
+ operationName
9902
+ }) {
9903
+ const normalizedDocument = stripLeadingGraphqlComments(document);
9904
+ const match = /^(?<actualKind>query|mutation)\s+(?<actualOperationName>[_A-Za-z][_0-9A-Za-z]*)/u.exec(
9905
+ normalizedDocument
9906
+ );
9907
+ const actualKind = match?.groups?.["actualKind"];
9908
+ const actualOperationName = match?.groups?.["actualOperationName"];
9909
+ if (!actualKind || !actualOperationName) {
9910
+ throw new Error(
9911
+ `Operation "${operationName}" is missing a top-level GraphQL ${kind} definition.`
9912
+ );
9913
+ }
9914
+ if (actualKind !== kind || actualOperationName !== operationName) {
9915
+ throw new Error(
9916
+ `Operation "${operationName}" does not match its GraphQL document (${actualKind} ${actualOperationName}).`
9917
+ );
9918
+ }
9919
+ }
9920
+ function createOperationSpec(spec) {
9921
+ assertDocumentMatchesOperation(spec);
9922
+ return spec;
9923
+ }
9924
+
9925
+ // ../mcp-registry/src/operation-specs.ts
9926
+ function stringOption({
9927
+ description,
9928
+ flagName,
9929
+ inputKey,
9930
+ required = false
9931
+ }) {
9932
+ return {
9933
+ description,
9934
+ flagName,
9935
+ inputKey,
9936
+ required,
9937
+ valueType: "string"
9938
+ };
9939
+ }
9940
+ function numberOption({
9941
+ description,
9942
+ flagName,
9943
+ inputKey,
9944
+ required = false
9945
+ }) {
9946
+ return {
9947
+ description,
9948
+ flagName,
9949
+ inputKey,
9950
+ required,
9951
+ valueType: "number"
9952
+ };
9953
+ }
9954
+ function booleanOption({
9955
+ description,
9956
+ flagName,
9957
+ inputKey
9958
+ }) {
9959
+ return {
9960
+ description,
9961
+ flagName,
9962
+ inputKey,
9963
+ valueType: "boolean"
9964
+ };
9965
+ }
9966
+ function stringArrayOption({
9967
+ description,
9968
+ flagName,
9969
+ inputKey,
9970
+ required = false
9971
+ }) {
9972
+ return {
9973
+ description,
9974
+ flagName,
9975
+ inputKey,
9976
+ required,
9977
+ valueHint: "comma-separated",
9978
+ valueType: "string-array"
9979
+ };
9980
+ }
9981
+ function jsonOption({
9982
+ description,
7571
9983
  flagName,
7572
9984
  inputKey,
7573
9985
  required = false
@@ -7581,11 +9993,12 @@ function jsonOption({
7581
9993
  valueType: "json"
7582
9994
  };
7583
9995
  }
7584
- var jsonObjectSchema = z2.record(z2.string(), z2.unknown());
9996
+ var jsonObjectSchema = z17.record(z17.string(), z17.unknown());
7585
9997
  var agentBrowserProviderOptionsSelection = ` browserbase {
7586
9998
  advancedStealth
7587
9999
  contextId
7588
10000
  extensionId
10001
+ enablePdfViewer
7589
10002
  instanceSize
7590
10003
  blockAds
7591
10004
  solveCaptchas
@@ -7671,8 +10084,8 @@ var operationSpecs = [
7671
10084
  createOperationSpec({
7672
10085
  operationName: "GetAgents",
7673
10086
  kind: "query",
7674
- inputSchema: z2.object({
7675
- ids: z2.array(z2.string().min(1)).min(1)
10087
+ inputSchema: z17.object({
10088
+ ids: z17.array(z17.string().min(1)).min(1)
7676
10089
  }),
7677
10090
  cli: {
7678
10091
  name: "get-agents",
@@ -7720,6 +10133,10 @@ ${agentLimitationsSelection}
7720
10133
  systemPrompt
7721
10134
  additionalSystemPrompt
7722
10135
  ignoreUnstableSessionState
10136
+ resourcePools {
10137
+ id
10138
+ type
10139
+ }
7723
10140
  }
7724
10141
  childAgentIds
7725
10142
  }
@@ -7728,9 +10145,9 @@ ${agentLimitationsSelection}
7728
10145
  createOperationSpec({
7729
10146
  operationName: "GetAgentVersion",
7730
10147
  kind: "query",
7731
- inputSchema: z2.object({
7732
- agentId: z2.string().min(1),
7733
- versionId: z2.string().min(1)
10148
+ inputSchema: z17.object({
10149
+ agentId: z17.string().min(1),
10150
+ versionId: z17.string().min(1)
7734
10151
  }),
7735
10152
  cli: {
7736
10153
  name: "get-agent-version",
@@ -7792,8 +10209,8 @@ ${agentLimitationsSelection}
7792
10209
  createOperationSpec({
7793
10210
  operationName: "GetAgentVersions",
7794
10211
  kind: "query",
7795
- inputSchema: z2.object({
7796
- agentId: z2.string().min(1)
10212
+ inputSchema: z17.object({
10213
+ agentId: z17.string().min(1)
7797
10214
  }),
7798
10215
  cli: {
7799
10216
  name: "get-agent-versions",
@@ -7827,10 +10244,10 @@ query GetAgentVersions($agentId: ID!) {
7827
10244
  createOperationSpec({
7828
10245
  operationName: "DiffAgentVersion",
7829
10246
  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()
10247
+ inputSchema: z17.object({
10248
+ agentId: z17.string().min(1),
10249
+ versionId: z17.string().min(1),
10250
+ compareVersionId: z17.string().min(1).optional()
7834
10251
  }),
7835
10252
  cli: {
7836
10253
  name: "diff-agent-version",
@@ -7884,8 +10301,8 @@ query DiffAgentVersion(
7884
10301
  createOperationSpec({
7885
10302
  operationName: "GetAgentRun",
7886
10303
  kind: "query",
7887
- inputSchema: z2.object({
7888
- id: z2.string().min(1)
10304
+ inputSchema: z17.object({
10305
+ id: z17.string().min(1)
7889
10306
  }),
7890
10307
  cli: {
7891
10308
  name: "get-agent-run",
@@ -7921,8 +10338,8 @@ query GetAgentRun($id: ID!) {
7921
10338
  createOperationSpec({
7922
10339
  operationName: "GetAutomationAgents",
7923
10340
  kind: "query",
7924
- inputSchema: z2.object({
7925
- ids: z2.array(z2.string().min(1)).min(1)
10341
+ inputSchema: z17.object({
10342
+ ids: z17.array(z17.string().min(1)).min(1)
7926
10343
  }),
7927
10344
  cli: {
7928
10345
  name: "get-automation-agents",
@@ -7960,13 +10377,67 @@ query GetAutomationAgents($ids: [ID!]!) {
7960
10377
  childAgentIds
7961
10378
  }
7962
10379
  }
10380
+ }`
10381
+ }),
10382
+ createOperationSpec({
10383
+ operationName: "GetAutomationDiffFromPublished",
10384
+ kind: "query",
10385
+ inputSchema: z17.object({
10386
+ automationId: z17.string().min(1),
10387
+ draftVersionId: z17.string().min(1).optional(),
10388
+ publishedVersionId: z17.string().min(1).optional()
10389
+ }),
10390
+ cli: {
10391
+ name: "get-automation-diff-from-published",
10392
+ path: ["automations", "diff-from-published"],
10393
+ description: "Fetch draft-vs-published automation change scope.",
10394
+ resultKey: "automationDiffFromPublished",
10395
+ options: [
10396
+ stringOption({
10397
+ inputKey: "automationId",
10398
+ flagName: "automation-id",
10399
+ description: "Automation ID.",
10400
+ required: true
10401
+ }),
10402
+ stringOption({
10403
+ inputKey: "draftVersionId",
10404
+ flagName: "draft-version-id",
10405
+ description: "Draft automation version ID to compare from."
10406
+ }),
10407
+ stringOption({
10408
+ inputKey: "publishedVersionId",
10409
+ flagName: "published-version-id",
10410
+ description: "Published automation version ID to compare against."
10411
+ })
10412
+ ]
10413
+ },
10414
+ mcp: { fileName: "automationDiffFromPublished.graphql" },
10415
+ document: `# Query deterministic draft-vs-published agent and field changes
10416
+ query GetAutomationDiffFromPublished($automationId: ID!, $draftVersionId: ID, $publishedVersionId: ID) {
10417
+ automationDiffFromPublished(automationId: $automationId, draftVersionId: $draftVersionId, publishedVersionId: $publishedVersionId) {
10418
+ automationId
10419
+ automationName
10420
+ mode
10421
+ publishedAutomationId
10422
+ hasChanges
10423
+ changedAgents {
10424
+ agentId
10425
+ agentName
10426
+ changeTypes
10427
+ changedFields
10428
+ changes {
10429
+ type
10430
+ field
10431
+ }
10432
+ }
10433
+ }
7963
10434
  }`
7964
10435
  }),
7965
10436
  createOperationSpec({
7966
10437
  operationName: "GetAutomationRun",
7967
10438
  kind: "query",
7968
- inputSchema: z2.object({
7969
- id: z2.string().min(1)
10439
+ inputSchema: z17.object({
10440
+ id: z17.string().min(1)
7970
10441
  }),
7971
10442
  cli: {
7972
10443
  name: "get-automation-run",
@@ -8006,8 +10477,8 @@ query GetAutomationRun($id: ID!) {
8006
10477
  createOperationSpec({
8007
10478
  operationName: "GetAutomationRunAgentRuns",
8008
10479
  kind: "query",
8009
- inputSchema: z2.object({
8010
- automationRunId: z2.string().min(1)
10480
+ inputSchema: z17.object({
10481
+ automationRunId: z17.string().min(1)
8011
10482
  }),
8012
10483
  cli: {
8013
10484
  name: "get-automation-run-agent-runs",
@@ -8043,11 +10514,11 @@ query GetAutomationRunAgentRuns($automationRunId: ID!) {
8043
10514
  createOperationSpec({
8044
10515
  operationName: "GetAutomationRunIterations",
8045
10516
  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()
10517
+ inputSchema: z17.object({
10518
+ automationRunId: z17.string().min(1),
10519
+ agentRunId: z17.string().min(1).optional(),
10520
+ limit: z17.number().int().positive().optional(),
10521
+ reverse: z17.boolean().optional()
8051
10522
  }),
8052
10523
  cli: {
8053
10524
  name: "get-automation-run-iterations",
@@ -8116,12 +10587,12 @@ query GetAutomationRunIterations(
8116
10587
  createOperationSpec({
8117
10588
  operationName: "GetAutomationRuns",
8118
10589
  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()
10590
+ inputSchema: z17.object({
10591
+ automationId: z17.string().min(1),
10592
+ status: z17.array(z17.string().min(1)).optional(),
10593
+ invocationType: z17.array(z17.string().min(1)).optional(),
10594
+ limit: z17.number().int().positive().optional(),
10595
+ page: z17.number().int().positive().optional()
8125
10596
  }),
8126
10597
  cli: {
8127
10598
  name: "get-automation-runs",
@@ -8190,8 +10661,8 @@ query GetAutomationRuns(
8190
10661
  createOperationSpec({
8191
10662
  operationName: "ListAutomations",
8192
10663
  kind: "query",
8193
- inputSchema: z2.object({
8194
- limit: z2.number().positive().optional(),
10664
+ inputSchema: z17.object({
10665
+ limit: z17.number().positive().optional(),
8195
10666
  order: jsonObjectSchema.optional(),
8196
10667
  where: jsonObjectSchema.optional()
8197
10668
  }),
@@ -8242,8 +10713,8 @@ query ListAutomations(
8242
10713
  createOperationSpec({
8243
10714
  operationName: "GetAutomations",
8244
10715
  kind: "query",
8245
- inputSchema: z2.object({
8246
- ids: z2.array(z2.string().min(1)).min(1)
10716
+ inputSchema: z17.object({
10717
+ ids: z17.array(z17.string().min(1)).min(1)
8247
10718
  }),
8248
10719
  cli: {
8249
10720
  name: "get-automations",
@@ -8260,8 +10731,10 @@ query ListAutomations(
8260
10731
  ]
8261
10732
  },
8262
10733
  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
10734
+ document: `# Query to fetch automations with flat fields + sharedInputSchema.
10735
+ # sharedInputSchema is critical for cloning/migration and can't be inferred
10736
+ # from agents alone, so it's included by default in the composite read.
10737
+ # Other config fields (schedules, proxies, auth) stay excluded for simplicity.
8265
10738
  query GetAutomations($ids: [ID!]!) {
8266
10739
  automations(ids: $ids) {
8267
10740
  id
@@ -8273,124 +10746,628 @@ query GetAutomations($ids: [ID!]!) {
8273
10746
  lastSavedAt
8274
10747
  publishedVersionId
8275
10748
  draftVersionId
10749
+ config {
10750
+ sharedInputSchema {
10751
+ key
10752
+ value {
10753
+ schema
10754
+ sourceAgentId
10755
+ sourceLocation
10756
+ }
10757
+ }
10758
+ }
10759
+ }
10760
+ }`
10761
+ }),
10762
+ createOperationSpec({
10763
+ operationName: "GetAvailableCommands",
10764
+ kind: "query",
10765
+ inputSchema: z17.object({
10766
+ env: z17.string().min(1)
10767
+ }),
10768
+ cli: {
10769
+ name: "get-available-commands",
10770
+ path: ["catalog", "commands"],
10771
+ description: "Fetch available command definitions by environment.",
10772
+ resultKey: "availableCommands",
10773
+ options: [
10774
+ stringOption({
10775
+ inputKey: "env",
10776
+ flagName: "env",
10777
+ description: "Environment name.",
10778
+ required: true
10779
+ })
10780
+ ]
10781
+ },
10782
+ mcp: { fileName: "availableCommands.graphql" },
10783
+ document: `# Query to fetch available command definitions by environment
10784
+ query GetAvailableCommands($env: AvailableCommandsEnv!) {
10785
+ availableCommands(env: $env) {
10786
+ id
10787
+ description
10788
+ inputSchema
10789
+ }
10790
+ }`
10791
+ }),
10792
+ createOperationSpec({
10793
+ operationName: "GetAvailableModels",
10794
+ kind: "query",
10795
+ inputSchema: z17.object({
10796
+ agentId: z17.string().min(1)
10797
+ }),
10798
+ cli: {
10799
+ name: "get-available-models",
10800
+ path: ["catalog", "models"],
10801
+ description: "Fetch available model definitions for an agent.",
10802
+ resultKey: "availableModels",
10803
+ options: [
10804
+ stringOption({
10805
+ inputKey: "agentId",
10806
+ flagName: "agent-id",
10807
+ description: "Agent ID.",
10808
+ required: true
10809
+ })
10810
+ ]
10811
+ },
10812
+ mcp: { fileName: "availableModels.graphql" },
10813
+ document: `# Query to fetch available model definitions and pools for a specific agent
10814
+ query GetAvailableModels($agentId: String!) {
10815
+ availableModels(agentId: $agentId) {
10816
+ availableModelPools {
10817
+ name
10818
+ poolId
10819
+ models {
10820
+ id
10821
+ name
10822
+ description
10823
+ status
10824
+ provider
10825
+ }
10826
+ }
10827
+ allAvailableModels {
10828
+ id
10829
+ name
10830
+ description
10831
+ status
10832
+ provider
10833
+ }
10834
+ }
10835
+ }`
10836
+ }),
10837
+ createOperationSpec({
10838
+ operationName: "GetAvailableTools",
10839
+ kind: "query",
10840
+ inputSchema: z17.object({
10841
+ env: z17.string().min(1),
10842
+ automationId: z17.string().min(1).optional()
10843
+ }),
10844
+ cli: {
10845
+ name: "get-available-tools",
10846
+ path: ["catalog", "tools"],
10847
+ description: "Fetch available tool definitions by environment.",
10848
+ resultKey: "availableTools",
10849
+ options: [
10850
+ stringOption({
10851
+ inputKey: "env",
10852
+ flagName: "env",
10853
+ description: "Environment name.",
10854
+ required: true
10855
+ }),
10856
+ stringOption({
10857
+ inputKey: "automationId",
10858
+ flagName: "automation-id",
10859
+ description: "Optional automation ID."
10860
+ })
10861
+ ]
10862
+ },
10863
+ mcp: { fileName: "availableTools.graphql" },
10864
+ document: `# Query to fetch available tool definitions by environment
10865
+ query GetAvailableTools($env: AvailableCommandsEnv!, $automationId: String) {
10866
+ availableTools(env: $env, automationId: $automationId) {
10867
+ id
10868
+ description
10869
+ inputSchema
10870
+ }
10871
+ }`
10872
+ }),
10873
+ createOperationSpec({
10874
+ operationName: "GetFeatureFlagsContext",
10875
+ kind: "query",
10876
+ inputSchema: z17.object({
10877
+ flagKeys: z17.array(z17.string().min(1)).min(1).max(100).optional()
10878
+ }),
10879
+ cli: {
10880
+ name: "get-feature-flags-context",
10881
+ path: ["feature-flags", "context"],
10882
+ description: "Fetch current LaunchDarkly feature flag values for the selected org and current user.",
10883
+ resultKey: "featureFlagsContext",
10884
+ options: [
10885
+ stringArrayOption({
10886
+ inputKey: "flagKeys",
10887
+ flagName: "flag-keys",
10888
+ description: "Optional feature flag keys."
10889
+ })
10890
+ ]
10891
+ },
10892
+ mcp: { fileName: "featureFlagsContext.graphql" },
10893
+ document: `# Query to fetch current LaunchDarkly feature flag context
10894
+ query GetFeatureFlagsContext($flagKeys: [String!]) {
10895
+ featureFlagsContext(flagKeys: $flagKeys) {
10896
+ evaluatedAt
10897
+ organizationId
10898
+ contexts {
10899
+ organization {
10900
+ flags
10901
+ }
10902
+ user {
10903
+ id
10904
+ email
10905
+ flags
10906
+ }
10907
+ }
10908
+ }
10909
+ }`
10910
+ }),
10911
+ createOperationSpec({
10912
+ operationName: "GetAutomationWorkbenchCredentials",
10913
+ kind: "query",
10914
+ inputSchema: z17.object({}),
10915
+ cli: {
10916
+ name: "get-automation-workbench-credentials",
10917
+ path: ["workbench", "credentials"],
10918
+ description: "Fetch organization credential metadata for automation authoring. Secret values are never returned.",
10919
+ resultKey: "automationWorkbenchCredentials",
10920
+ options: []
10921
+ },
10922
+ mcp: { fileName: "automationWorkbenchCredentials.graphql" },
10923
+ document: `# Query organization credential metadata for automation authoring.
10924
+ # Secret values are never returned.
10925
+ query GetAutomationWorkbenchCredentials {
10926
+ automationWorkbenchCredentials {
10927
+ id
10928
+ type
10929
+ description
10930
+ hostname
10931
+ providerConfigKey
10932
+ availableFactors
10933
+ }
10934
+ }`
10935
+ }),
10936
+ createOperationSpec({
10937
+ operationName: "GetAutomationWorkbenchDiagnostics",
10938
+ kind: "query",
10939
+ inputSchema: z17.object({
10940
+ draftAutomationId: z17.string().min(1)
10941
+ }),
10942
+ cli: {
10943
+ name: "get-automation-workbench-diagnostics",
10944
+ path: ["workbench", "diagnostics"],
10945
+ description: "Fetch a compact draft automation graph plus workbench diagnostics.",
10946
+ resultKey: "automationWorkbenchDiagnostics",
10947
+ options: [
10948
+ stringOption({
10949
+ inputKey: "draftAutomationId",
10950
+ flagName: "draft-automation-id",
10951
+ description: "Draft automation ID.",
10952
+ required: true
10953
+ })
10954
+ ]
10955
+ },
10956
+ mcp: { fileName: "automationWorkbenchDiagnostics.graphql" },
10957
+ document: `# Query automation workbench diagnostics for a draft automation.
10958
+ query GetAutomationWorkbenchDiagnostics($draftAutomationId: ID!) {
10959
+ automationWorkbenchDiagnostics(draftAutomationId: $draftAutomationId) {
10960
+ summary {
10961
+ draftAutomationId
10962
+ name
10963
+ agentCount
10964
+ authenticationCount
10965
+ edgeCount
10966
+ rootAgentIds
10967
+ agents {
10968
+ id
10969
+ name
10970
+ type
10971
+ kind
10972
+ description
10973
+ instructions
10974
+ isTrigger
10975
+ childAgentIds
10976
+ parentAgentIds
10977
+ tools
10978
+ sharedInputKeys
10979
+ sharedOutputKeys
10980
+ referencedAgentIds
10981
+ }
10982
+ sharedInputSourceByKey {
10983
+ key
10984
+ sourceAgentId
10985
+ sourceLocation
10986
+ }
10987
+ }
10988
+ issues {
10989
+ severity
10990
+ code
10991
+ message
10992
+ agentId
10993
+ path
10994
+ relatedAgentIds
10995
+ }
8276
10996
  }
8277
10997
  }`
8278
10998
  }),
8279
10999
  createOperationSpec({
8280
- operationName: "GetAvailableCommands",
11000
+ operationName: "GetAutomationWorkbenchRunTrace",
8281
11001
  kind: "query",
8282
- inputSchema: z2.object({
8283
- env: z2.string().min(1)
11002
+ inputSchema: z17.object({
11003
+ automationRunId: z17.string().min(1),
11004
+ agentRunId: z17.string().min(1).optional(),
11005
+ limit: z17.number().int().positive().optional(),
11006
+ reverse: z17.boolean().optional()
8284
11007
  }),
8285
11008
  cli: {
8286
- name: "get-available-commands",
8287
- path: ["catalog", "commands"],
8288
- description: "Fetch available command definitions by environment.",
8289
- resultKey: "availableCommands",
11009
+ name: "get-automation-workbench-run-trace",
11010
+ path: ["workbench", "run-trace"],
11011
+ description: "Fetch a projected run trace with agent runs, child runs, iterations, and terminal blame.",
11012
+ resultKey: "automationWorkbenchRunTrace",
8290
11013
  options: [
8291
11014
  stringOption({
8292
- inputKey: "env",
8293
- flagName: "env",
8294
- description: "Environment name.",
11015
+ inputKey: "automationRunId",
11016
+ flagName: "automation-run-id",
11017
+ description: "Automation run ID.",
8295
11018
  required: true
11019
+ }),
11020
+ stringOption({
11021
+ inputKey: "agentRunId",
11022
+ flagName: "agent-run-id",
11023
+ description: "Optional agent run ID to focus iterations."
11024
+ }),
11025
+ numberOption({
11026
+ inputKey: "limit",
11027
+ flagName: "limit",
11028
+ description: "Maximum number of iterations to return."
11029
+ }),
11030
+ booleanOption({
11031
+ inputKey: "reverse",
11032
+ flagName: "reverse",
11033
+ description: "Return newest iterations first."
8296
11034
  })
8297
11035
  ]
8298
11036
  },
8299
- mcp: { fileName: "availableCommands.graphql" },
8300
- document: `# Query to fetch available command definitions by environment
8301
- query GetAvailableCommands($env: AvailableCommandsEnv!) {
8302
- availableCommands(env: $env) {
11037
+ mcp: { fileName: "automationWorkbenchRunTrace.graphql" },
11038
+ document: `# Query a compact run trace for workbench debug loops.
11039
+ query GetAutomationWorkbenchRunTrace(
11040
+ $automationRunId: ID!
11041
+ $agentRunId: ID
11042
+ $limit: Int
11043
+ $reverse: Boolean
11044
+ ) {
11045
+ automationWorkbenchRunTrace(
11046
+ automationRunId: $automationRunId
11047
+ agentRunId: $agentRunId
11048
+ limit: $limit
11049
+ reverse: $reverse
11050
+ ) {
8303
11051
  id
8304
- description
8305
- inputSchema
11052
+ automationId
11053
+ status
11054
+ statusDetail
11055
+ summary
11056
+ debugUrl
11057
+ startedAt
11058
+ finishedAt
11059
+ truncated
11060
+ terminal {
11061
+ status
11062
+ detail
11063
+ lastNodeId
11064
+ blameNodeId
11065
+ }
11066
+ agentRuns {
11067
+ id
11068
+ agentId
11069
+ agentVersionId
11070
+ agentName
11071
+ parentAgentRunId
11072
+ status
11073
+ statusDetail
11074
+ iterations {
11075
+ id
11076
+ sequence
11077
+ agentRunId
11078
+ tMs
11079
+ durationMs
11080
+ llmDurationMs
11081
+ reasoning
11082
+ reasoningStatus
11083
+ toolCall {
11084
+ toolCallId
11085
+ toolName
11086
+ targetAgentId
11087
+ targetAgentName
11088
+ targetAgentIds
11089
+ targetAgentNames
11090
+ }
11091
+ toolResult {
11092
+ status
11093
+ message
11094
+ }
11095
+ screenshotUrl
11096
+ errorMessage
11097
+ }
11098
+ childRuns {
11099
+ id
11100
+ agentId
11101
+ agentVersionId
11102
+ agentName
11103
+ parentAgentRunId
11104
+ status
11105
+ statusDetail
11106
+ iterations {
11107
+ id
11108
+ sequence
11109
+ agentRunId
11110
+ tMs
11111
+ durationMs
11112
+ llmDurationMs
11113
+ reasoning
11114
+ reasoningStatus
11115
+ toolCall {
11116
+ toolCallId
11117
+ toolName
11118
+ targetAgentId
11119
+ targetAgentName
11120
+ targetAgentIds
11121
+ targetAgentNames
11122
+ }
11123
+ toolResult {
11124
+ status
11125
+ message
11126
+ }
11127
+ screenshotUrl
11128
+ errorMessage
11129
+ }
11130
+ }
11131
+ }
8306
11132
  }
8307
11133
  }`
8308
11134
  }),
8309
11135
  createOperationSpec({
8310
- operationName: "GetAvailableModels",
11136
+ operationName: "GetAutomationWorkbenchAwaitRunCompletion",
8311
11137
  kind: "query",
8312
- inputSchema: z2.object({
8313
- agentId: z2.string().min(1)
11138
+ inputSchema: z17.object({
11139
+ automationRunId: z17.string().min(1),
11140
+ timeoutMs: z17.number().int().min(1e3).max(6e4).optional(),
11141
+ sinceSequence: z17.number().int().min(0).optional(),
11142
+ agentRunId: z17.string().min(1).optional(),
11143
+ limit: z17.number().int().positive().optional(),
11144
+ reverse: z17.boolean().optional()
8314
11145
  }),
8315
11146
  cli: {
8316
- name: "get-available-models",
8317
- path: ["catalog", "models"],
8318
- description: "Fetch available model definitions for an agent.",
8319
- resultKey: "availableModels",
11147
+ name: "await-automation-workbench-run-completion",
11148
+ path: ["workbench", "await"],
11149
+ description: "Long-poll: block until the run is terminal/paused or timeout elapses, then return the projected trace plus poll stats.",
11150
+ resultKey: "automationWorkbenchAwaitRunCompletion",
8320
11151
  options: [
8321
11152
  stringOption({
8322
- inputKey: "agentId",
8323
- flagName: "agent-id",
8324
- description: "Agent ID.",
11153
+ inputKey: "automationRunId",
11154
+ flagName: "automation-run-id",
11155
+ description: "Automation run ID to wait on.",
8325
11156
  required: true
11157
+ }),
11158
+ numberOption({
11159
+ inputKey: "timeoutMs",
11160
+ flagName: "timeout-ms",
11161
+ description: "Server-side wait cap, in ms. Clamped to [1000, 60000]. Defaults to 30000."
11162
+ }),
11163
+ numberOption({
11164
+ inputKey: "sinceSequence",
11165
+ flagName: "since-sequence",
11166
+ description: "Wake also when any iteration with sequence > sinceSequence appears (incremental polling)."
11167
+ }),
11168
+ stringOption({
11169
+ inputKey: "agentRunId",
11170
+ flagName: "agent-run-id",
11171
+ description: "Optional agent run ID to focus iterations."
11172
+ }),
11173
+ numberOption({
11174
+ inputKey: "limit",
11175
+ flagName: "limit",
11176
+ description: "Maximum iterations to return per agent run."
11177
+ }),
11178
+ booleanOption({
11179
+ inputKey: "reverse",
11180
+ flagName: "reverse",
11181
+ description: "Return newest iterations first."
8326
11182
  })
8327
11183
  ]
8328
11184
  },
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 {
11185
+ mcp: { fileName: "automationWorkbenchAwaitRunCompletion.graphql" },
11186
+ document: `# Long-poll for run completion. Server holds the request open until the run
11187
+ # reaches a terminal/paused state or timeout elapses, then returns the same
11188
+ # projected trace shape as automationWorkbenchRunTrace plus poll stats.
11189
+ query GetAutomationWorkbenchAwaitRunCompletion(
11190
+ $automationRunId: ID!
11191
+ $timeoutMs: Int
11192
+ $sinceSequence: Int
11193
+ $agentRunId: ID
11194
+ $limit: Int
11195
+ $reverse: Boolean
11196
+ ) {
11197
+ automationWorkbenchAwaitRunCompletion(
11198
+ automationRunId: $automationRunId
11199
+ timeoutMs: $timeoutMs
11200
+ sinceSequence: $sinceSequence
11201
+ agentRunId: $agentRunId
11202
+ limit: $limit
11203
+ reverse: $reverse
11204
+ ) {
11205
+ reachedTerminal
11206
+ reachedSinceSequence
11207
+ pollCount
11208
+ elapsedMs
11209
+ trace {
11210
+ id
11211
+ automationId
11212
+ status
11213
+ statusDetail
11214
+ summary
11215
+ debugUrl
11216
+ startedAt
11217
+ finishedAt
11218
+ truncated
11219
+ terminal {
11220
+ status
11221
+ detail
11222
+ lastNodeId
11223
+ blameNodeId
11224
+ }
11225
+ agentRuns {
8337
11226
  id
8338
- name
8339
- description
11227
+ agentId
11228
+ agentVersionId
11229
+ agentName
11230
+ parentAgentRunId
8340
11231
  status
8341
- provider
11232
+ statusDetail
11233
+ iterations {
11234
+ id
11235
+ sequence
11236
+ agentRunId
11237
+ tMs
11238
+ durationMs
11239
+ llmDurationMs
11240
+ reasoning
11241
+ reasoningStatus
11242
+ toolCall {
11243
+ toolCallId
11244
+ toolName
11245
+ targetAgentId
11246
+ targetAgentName
11247
+ targetAgentIds
11248
+ targetAgentNames
11249
+ }
11250
+ toolResult {
11251
+ status
11252
+ message
11253
+ }
11254
+ screenshotUrl
11255
+ errorMessage
11256
+ }
11257
+ childRuns {
11258
+ id
11259
+ agentId
11260
+ agentVersionId
11261
+ agentName
11262
+ parentAgentRunId
11263
+ status
11264
+ statusDetail
11265
+ iterations {
11266
+ id
11267
+ sequence
11268
+ agentRunId
11269
+ tMs
11270
+ durationMs
11271
+ llmDurationMs
11272
+ reasoning
11273
+ reasoningStatus
11274
+ toolCall {
11275
+ toolCallId
11276
+ toolName
11277
+ targetAgentId
11278
+ targetAgentName
11279
+ targetAgentIds
11280
+ targetAgentNames
11281
+ }
11282
+ toolResult {
11283
+ status
11284
+ message
11285
+ }
11286
+ screenshotUrl
11287
+ errorMessage
11288
+ }
11289
+ }
8342
11290
  }
8343
11291
  }
8344
- allAvailableModels {
8345
- id
8346
- name
8347
- description
8348
- status
8349
- provider
8350
- }
8351
11292
  }
8352
11293
  }`
8353
11294
  }),
8354
11295
  createOperationSpec({
8355
- operationName: "GetAvailableTools",
11296
+ operationName: "GetAutomationWorkbenchSchemaSuggestions",
8356
11297
  kind: "query",
8357
- inputSchema: z2.object({
8358
- env: z2.string().min(1),
8359
- automationId: z2.string().min(1).optional()
11298
+ inputSchema: z17.object({
11299
+ automationRunId: z17.string().min(1),
11300
+ draftAutomationId: z17.string().min(1).optional(),
11301
+ minConfidence: z17.number().min(0).max(1).optional(),
11302
+ includeSensitive: z17.boolean().optional()
8360
11303
  }),
8361
11304
  cli: {
8362
- name: "get-available-tools",
8363
- path: ["catalog", "tools"],
8364
- description: "Fetch available tool definitions by environment.",
8365
- resultKey: "availableTools",
11305
+ name: "get-automation-workbench-schema-suggestions",
11306
+ path: ["workbench", "schema-suggestions"],
11307
+ description: "Heuristic suggestions for schema fields the agent observed on browser pages but were not declared in the input schema.",
11308
+ resultKey: "automationWorkbenchSchemaSuggestions",
8366
11309
  options: [
8367
11310
  stringOption({
8368
- inputKey: "env",
8369
- flagName: "env",
8370
- description: "Environment name.",
11311
+ inputKey: "automationRunId",
11312
+ flagName: "automation-run-id",
11313
+ description: "Automation run to analyze.",
8371
11314
  required: true
8372
11315
  }),
8373
11316
  stringOption({
8374
- inputKey: "automationId",
8375
- flagName: "automation-id",
8376
- description: "Optional automation ID."
11317
+ inputKey: "draftAutomationId",
11318
+ flagName: "draft-automation-id",
11319
+ description: "Optional draft automation ID. Defaults to the run's automationId."
11320
+ }),
11321
+ numberOption({
11322
+ inputKey: "minConfidence",
11323
+ flagName: "min-confidence",
11324
+ description: "Suggestions below this 0..1 confidence score are filtered out. Default 0.6."
11325
+ }),
11326
+ booleanOption({
11327
+ inputKey: "includeSensitive",
11328
+ flagName: "include-sensitive",
11329
+ description: "Include suggestions for fields whose label looks like PII (SSN, password, card number). Default false."
8377
11330
  })
8378
11331
  ]
8379
11332
  },
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
11333
+ mcp: { fileName: "automationWorkbenchSchemaSuggestions.graphql" },
11334
+ document: `# Heuristic schema-coverage suggestions: form fields observed on the page that
11335
+ # are not declared in any input schema, returned with evidence for verification.
11336
+ query GetAutomationWorkbenchSchemaSuggestions(
11337
+ $automationRunId: ID!
11338
+ $draftAutomationId: ID
11339
+ $minConfidence: Float
11340
+ $includeSensitive: Boolean
11341
+ ) {
11342
+ automationWorkbenchSchemaSuggestions(
11343
+ automationRunId: $automationRunId
11344
+ draftAutomationId: $draftAutomationId
11345
+ minConfidence: $minConfidence
11346
+ includeSensitive: $includeSensitive
11347
+ ) {
11348
+ kind
11349
+ fieldName
11350
+ fieldLabel
11351
+ fieldType
11352
+ fieldDescription
11353
+ required
11354
+ confidence
11355
+ reason
11356
+ evidence {
11357
+ iterationId
11358
+ agentRunId
11359
+ agentName
11360
+ markId
11361
+ fieldText
11362
+ screenshotUrl
11363
+ }
8387
11364
  }
8388
11365
  }`
8389
11366
  }),
8390
11367
  createOperationSpec({
8391
11368
  operationName: "CreateAutomation",
8392
11369
  kind: "mutation",
8393
- inputSchema: z2.object({
11370
+ inputSchema: z17.object({
8394
11371
  input: jsonObjectSchema
8395
11372
  }),
8396
11373
  cli: {
@@ -8427,7 +11404,7 @@ mutation CreateAutomation($input: CreateAutomationInput!) {
8427
11404
  createOperationSpec({
8428
11405
  operationName: "GetGraphqlSchema",
8429
11406
  kind: "query",
8430
- inputSchema: z2.object({}),
11407
+ inputSchema: z17.object({}),
8431
11408
  cli: {
8432
11409
  name: "get-graphql-schema",
8433
11410
  path: ["graphql", "schema"],
@@ -8448,8 +11425,8 @@ query GetGraphqlSchema {
8448
11425
  createOperationSpec({
8449
11426
  operationName: "PauseAutomationRun",
8450
11427
  kind: "mutation",
8451
- inputSchema: z2.object({
8452
- automationRunId: z2.string().min(1)
11428
+ inputSchema: z17.object({
11429
+ automationRunId: z17.string().min(1)
8453
11430
  }),
8454
11431
  cli: {
8455
11432
  name: "pause-automation-run",
@@ -8474,10 +11451,10 @@ mutation PauseAutomationRun($automationRunId: ID!) {
8474
11451
  createOperationSpec({
8475
11452
  operationName: "RerunAutomation",
8476
11453
  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)
11454
+ inputSchema: z17.object({
11455
+ automationRunId: z17.string().min(1),
11456
+ additionalPrompt: z17.string().min(1).optional(),
11457
+ idempotencyKey: z17.string().min(1)
8481
11458
  }),
8482
11459
  cli: {
8483
11460
  name: "rerun-automation",
@@ -8525,9 +11502,9 @@ mutation RerunAutomation(
8525
11502
  createOperationSpec({
8526
11503
  operationName: "ResumeAutomationRun",
8527
11504
  kind: "mutation",
8528
- inputSchema: z2.object({
8529
- automationRunId: z2.string().min(1),
8530
- message: z2.string().min(1).optional()
11505
+ inputSchema: z17.object({
11506
+ automationRunId: z17.string().min(1),
11507
+ message: z17.string().min(1).optional()
8531
11508
  }),
8532
11509
  cli: {
8533
11510
  name: "resume-automation-run",
@@ -8557,12 +11534,14 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
8557
11534
  createOperationSpec({
8558
11535
  operationName: "RunDraftAutomation",
8559
11536
  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()
11537
+ inputSchema: z17.object({
11538
+ draftAutomationId: z17.string().min(1),
11539
+ agentId: z17.string().min(1),
11540
+ idempotencyKey: z17.string().min(1),
11541
+ input: z17.unknown().optional(),
11542
+ config: automationRunStartConfigSchema.partial().passthrough().optional(),
11543
+ additionalPrompt: z17.string().min(1).optional(),
11544
+ consistencyCheckCount: z17.number().int().optional()
8566
11545
  }),
8567
11546
  cli: {
8568
11547
  name: "run-draft-automation",
@@ -8593,10 +11572,20 @@ mutation ResumeAutomationRun($automationRunId: ID!, $message: String) {
8593
11572
  flagName: "input-json",
8594
11573
  description: "Optional JSON input payload."
8595
11574
  }),
11575
+ jsonOption({
11576
+ inputKey: "config",
11577
+ flagName: "config-json",
11578
+ description: 'Optional run config payload, for example {"startInTakeOverMode":true,"approvalMode":"HUMAN_APPROVAL","consistencyCheckCount":3}.'
11579
+ }),
8596
11580
  stringOption({
8597
11581
  inputKey: "additionalPrompt",
8598
11582
  flagName: "additional-prompt",
8599
11583
  description: "Optional prompt appended to the run."
11584
+ }),
11585
+ numberOption({
11586
+ inputKey: "consistencyCheckCount",
11587
+ flagName: "consistency-check-count",
11588
+ description: "Optional consistency-check copy count for draft iteration runs."
8600
11589
  })
8601
11590
  ]
8602
11591
  },
@@ -8608,14 +11597,18 @@ mutation RunDraftAutomation(
8608
11597
  $agentId: ID!
8609
11598
  $idempotencyKey: String!
8610
11599
  $input: JSON
11600
+ $config: AutomationRunConfigInput
8611
11601
  $additionalPrompt: String
11602
+ $consistencyCheckCount: Int
8612
11603
  ) {
8613
11604
  runDraftAutomation(
8614
11605
  draftAutomationId: $draftAutomationId
8615
11606
  agentId: $agentId
8616
11607
  idempotencyKey: $idempotencyKey
8617
11608
  input: $input
11609
+ config: $config
8618
11610
  additionalPrompt: $additionalPrompt
11611
+ consistencyCheckCount: $consistencyCheckCount
8619
11612
  ) {
8620
11613
  automationRunId
8621
11614
  workflowId
@@ -8626,8 +11619,8 @@ mutation RunDraftAutomation(
8626
11619
  createOperationSpec({
8627
11620
  operationName: "StopAutomationRun",
8628
11621
  kind: "mutation",
8629
- inputSchema: z2.object({
8630
- automationRunId: z2.string().min(1)
11622
+ inputSchema: z17.object({
11623
+ automationRunId: z17.string().min(1)
8631
11624
  }),
8632
11625
  cli: {
8633
11626
  name: "stop-automation-run",
@@ -8647,13 +11640,211 @@ mutation RunDraftAutomation(
8647
11640
  document: `# Mutation to stop an automation run
8648
11641
  mutation StopAutomationRun($automationRunId: ID!) {
8649
11642
  stopAutomationRun(automationRunId: $automationRunId)
11643
+ }`
11644
+ }),
11645
+ createOperationSpec({
11646
+ operationName: "PreviewAutomationPatch",
11647
+ kind: "mutation",
11648
+ inputSchema: z17.object({
11649
+ draftAutomationId: z17.string().min(1),
11650
+ expectedLastSavedAt: z17.string().optional(),
11651
+ operations: z17.array(z17.unknown()).min(1)
11652
+ }),
11653
+ cli: {
11654
+ name: "preview-automation-patch",
11655
+ path: ["workbench", "patch", "preview"],
11656
+ description: "Preview semantic workbench patch operations without saving the draft.",
11657
+ resultKey: "previewAutomationPatch",
11658
+ options: [
11659
+ stringOption({
11660
+ inputKey: "draftAutomationId",
11661
+ flagName: "draft-automation-id",
11662
+ description: "Draft automation ID.",
11663
+ required: true
11664
+ }),
11665
+ jsonOption({
11666
+ inputKey: "operations",
11667
+ flagName: "operations-json",
11668
+ description: "Automation patch operations array using AutomationWorkbenchPatchOperationInput oneOf shape.",
11669
+ required: true
11670
+ })
11671
+ ]
11672
+ },
11673
+ mcp: { fileName: "previewAutomationPatch.graphql" },
11674
+ document: `# Preview semantic automation patch operations without writing.
11675
+ mutation PreviewAutomationPatch(
11676
+ $draftAutomationId: ID!
11677
+ $operations: [AutomationWorkbenchPatchOperationInput!]!
11678
+ ) {
11679
+ previewAutomationPatch(
11680
+ draftAutomationId: $draftAutomationId
11681
+ operations: $operations
11682
+ ) {
11683
+ draftAutomationId
11684
+ applied
11685
+ updateInput
11686
+ before {
11687
+ name
11688
+ agentCount
11689
+ edgeCount
11690
+ rootAgentIds
11691
+ agents {
11692
+ id
11693
+ name
11694
+ type
11695
+ kind
11696
+ tools
11697
+ childAgentIds
11698
+ parentAgentIds
11699
+ sharedInputKeys
11700
+ sharedOutputKeys
11701
+ }
11702
+ sharedInputSourceByKey {
11703
+ key
11704
+ sourceAgentId
11705
+ sourceLocation
11706
+ }
11707
+ }
11708
+ after {
11709
+ name
11710
+ agentCount
11711
+ edgeCount
11712
+ rootAgentIds
11713
+ agents {
11714
+ id
11715
+ name
11716
+ type
11717
+ kind
11718
+ tools
11719
+ childAgentIds
11720
+ parentAgentIds
11721
+ sharedInputKeys
11722
+ sharedOutputKeys
11723
+ }
11724
+ sharedInputSourceByKey {
11725
+ key
11726
+ sourceAgentId
11727
+ sourceLocation
11728
+ }
11729
+ }
11730
+ issues {
11731
+ severity
11732
+ code
11733
+ message
11734
+ agentId
11735
+ path
11736
+ relatedAgentIds
11737
+ }
11738
+ }
11739
+ }`
11740
+ }),
11741
+ createOperationSpec({
11742
+ operationName: "ApplyAutomationPatch",
11743
+ kind: "mutation",
11744
+ inputSchema: z17.object({
11745
+ draftAutomationId: z17.string().min(1),
11746
+ operations: z17.array(z17.unknown()).min(1)
11747
+ }),
11748
+ cli: {
11749
+ name: "apply-automation-patch",
11750
+ path: ["workbench", "patch", "apply"],
11751
+ description: "Apply semantic workbench patch operations through the versioned save path.",
11752
+ resultKey: "applyAutomationPatch",
11753
+ options: [
11754
+ stringOption({
11755
+ inputKey: "draftAutomationId",
11756
+ flagName: "draft-automation-id",
11757
+ description: "Draft automation ID.",
11758
+ required: true
11759
+ }),
11760
+ jsonOption({
11761
+ inputKey: "operations",
11762
+ flagName: "operations-json",
11763
+ description: "Automation patch operations array using AutomationWorkbenchPatchOperationInput oneOf shape.",
11764
+ required: true
11765
+ }),
11766
+ stringOption({
11767
+ inputKey: "expectedLastSavedAt",
11768
+ flagName: "expected-last-saved-at",
11769
+ description: "Optional optimistic concurrency guard timestamp."
11770
+ })
11771
+ ]
11772
+ },
11773
+ mcp: { fileName: "applyAutomationPatch.graphql" },
11774
+ document: `# Apply semantic automation patch operations through the versioned save path.
11775
+ mutation ApplyAutomationPatch(
11776
+ $draftAutomationId: ID!
11777
+ $operations: [AutomationWorkbenchPatchOperationInput!]!
11778
+ $expectedLastSavedAt: String
11779
+ ) {
11780
+ applyAutomationPatch(
11781
+ draftAutomationId: $draftAutomationId
11782
+ operations: $operations
11783
+ expectedLastSavedAt: $expectedLastSavedAt
11784
+ ) {
11785
+ draftAutomationId
11786
+ applied
11787
+ updateInput
11788
+ before {
11789
+ name
11790
+ agentCount
11791
+ edgeCount
11792
+ rootAgentIds
11793
+ agents {
11794
+ id
11795
+ name
11796
+ type
11797
+ kind
11798
+ tools
11799
+ childAgentIds
11800
+ parentAgentIds
11801
+ sharedInputKeys
11802
+ sharedOutputKeys
11803
+ }
11804
+ sharedInputSourceByKey {
11805
+ key
11806
+ sourceAgentId
11807
+ sourceLocation
11808
+ }
11809
+ }
11810
+ after {
11811
+ name
11812
+ agentCount
11813
+ edgeCount
11814
+ rootAgentIds
11815
+ agents {
11816
+ id
11817
+ name
11818
+ type
11819
+ kind
11820
+ tools
11821
+ childAgentIds
11822
+ parentAgentIds
11823
+ sharedInputKeys
11824
+ sharedOutputKeys
11825
+ }
11826
+ sharedInputSourceByKey {
11827
+ key
11828
+ sourceAgentId
11829
+ sourceLocation
11830
+ }
11831
+ }
11832
+ issues {
11833
+ severity
11834
+ code
11835
+ message
11836
+ agentId
11837
+ path
11838
+ relatedAgentIds
11839
+ }
11840
+ }
8650
11841
  }`
8651
11842
  }),
8652
11843
  createOperationSpec({
8653
11844
  operationName: "UpdateAutomationById",
8654
11845
  kind: "mutation",
8655
- inputSchema: z2.object({
8656
- id: z2.string().min(1),
11846
+ inputSchema: z17.object({
11847
+ id: z17.string().min(1),
8657
11848
  input: jsonObjectSchema
8658
11849
  }),
8659
11850
  cli: {
@@ -8694,58 +11885,58 @@ mutation UpdateAutomationById($id: ID!, $input: UpdateAutomationInput!) {
8694
11885
  import { Command as Command2, InvalidArgumentError as InvalidArgumentError2, Option as Option2 } from "commander";
8695
11886
 
8696
11887
  // src/api.ts
8697
- import { z as z3 } from "zod";
11888
+ import { z as z18 } from "zod";
8698
11889
  var OTTO_AUTHORIZATION_HEADER_NAME = "X-Otto-Authorization";
8699
11890
  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()
11891
+ var workosOrganizationsResponseSchema = z18.object({
11892
+ organizations: z18.array(
11893
+ z18.object({
11894
+ id: z18.string().min(1),
11895
+ name: z18.string().min(1),
11896
+ primaryDomain: z18.string().nullable().optional()
8706
11897
  })
8707
11898
  ),
8708
- success: z3.boolean()
11899
+ success: z18.boolean()
8709
11900
  });
8710
- var workosUserSchema = z3.object({
8711
- email: z3.string().nullable(),
8712
- id: z3.string().min(1)
11901
+ var workosUserSchema = z18.object({
11902
+ email: z18.string().nullable(),
11903
+ id: z18.string().min(1)
8713
11904
  });
8714
- var nangoIntegrationWireSchema = z3.object({
11905
+ var nangoIntegrationWireSchema = z18.object({
8715
11906
  // eslint-disable-next-line @typescript-eslint/naming-convention -- mirrors Nango REST payload
8716
- unique_key: z3.string().min(1)
11907
+ unique_key: z18.string().min(1)
8717
11908
  }).passthrough().transform((data) => ({
8718
11909
  ...data,
8719
11910
  uniqueKey: data.unique_key
8720
11911
  }));
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()
11912
+ var nangoIntegrationsResponseSchema = z18.array(nangoIntegrationWireSchema);
11913
+ var organizationAuthenticationSchema = z18.object({
11914
+ id: z18.string().min(1),
11915
+ type: z18.string().min(1),
11916
+ connectionId: z18.string().nullable().optional(),
11917
+ providerConfigKey: z18.string().nullable().optional(),
11918
+ description: z18.string().nullable().optional(),
11919
+ hostname: z18.string().nullable().optional()
8729
11920
  }).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)
11921
+ var organizationAuthenticationsResponseSchema = z18.object({
11922
+ authentications: z18.array(organizationAuthenticationSchema),
11923
+ success: z18.boolean()
11924
+ });
11925
+ var graphQlResponseSchema = z18.object({
11926
+ data: z18.record(z18.string(), z18.unknown()).optional(),
11927
+ errors: z18.array(
11928
+ z18.object({
11929
+ message: z18.string().min(1)
8739
11930
  })
8740
11931
  ).optional()
8741
11932
  });
8742
- var apiErrorResponseSchema = z3.object({
8743
- errors: z3.array(
8744
- z3.object({
8745
- message: z3.string().min(1)
11933
+ var apiErrorResponseSchema = z18.object({
11934
+ errors: z18.array(
11935
+ z18.object({
11936
+ message: z18.string().min(1)
8746
11937
  })
8747
11938
  ).optional(),
8748
- message: z3.string().min(1).optional()
11939
+ message: z18.string().min(1).optional()
8749
11940
  });
8750
11941
  function getApiErrorDetail(responseBody) {
8751
11942
  const parsedResponse = apiErrorResponseSchema.safeParse(responseBody);
@@ -9032,10 +12223,10 @@ function requireWorkosClientId(config) {
9032
12223
  // src/settings.ts
9033
12224
  import { mkdir, readFile, rm, writeFile } from "fs/promises";
9034
12225
  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()
12226
+ import { z as z19 } from "zod";
12227
+ var cliSettingsSchema = z19.object({
12228
+ env: z19.object({
12229
+ baseUrl: z19.url().optional()
9039
12230
  }).default({})
9040
12231
  });
9041
12232
  function createEmptyCliSettings() {
@@ -9278,22 +12469,6 @@ function resolveOpenCommand(url) {
9278
12469
 
9279
12470
  // src/program-session.ts
9280
12471
  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
12472
  async function withOrgScopedAccessToken({
9298
12473
  dependencies,
9299
12474
  organizationId,
@@ -9653,24 +12828,24 @@ ${formatExamples("Examples", [
9653
12828
  // src/state.ts
9654
12829
  import { mkdir as mkdir2, readFile as readFile3, rm as rm3, writeFile as writeFile2 } from "fs/promises";
9655
12830
  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({
12831
+ import { z as z20 } from "zod";
12832
+ var cliAccountSchema = z20.object({
12833
+ clientId: z20.string().min(1),
12834
+ email: z20.string().nullable(),
12835
+ userId: z20.string().min(1)
12836
+ });
12837
+ var cliOrganizationSchema = z20.object({
12838
+ id: z20.string().min(1),
12839
+ name: z20.string().min(1),
12840
+ primaryDomain: z20.string().nullable().default(null)
12841
+ });
12842
+ var cliStateSchema = z20.object({
9668
12843
  account: cliAccountSchema,
9669
- defaultOrgId: z5.string().nullable(),
9670
- lastUsedOrgId: z5.string().nullable(),
9671
- organizations: z5.array(cliOrganizationSchema)
12844
+ defaultOrgId: z20.string().nullable(),
12845
+ lastUsedOrgId: z20.string().nullable(),
12846
+ organizations: z20.array(cliOrganizationSchema)
9672
12847
  });
9673
- var refreshTokenFileSchema = z5.record(z5.string(), z5.string());
12848
+ var refreshTokenFileSchema = z20.record(z20.string(), z20.string());
9674
12849
  function createFileStateStore(stateFilePath) {
9675
12850
  return {
9676
12851
  async clear() {
@@ -9783,37 +12958,37 @@ if (typeof cliPackageVersion !== "string" || cliPackageVersion.length === 0) {
9783
12958
  var CLI_VERSION = cliPackageVersion;
9784
12959
 
9785
12960
  // src/workos-auth.ts
9786
- import { z as z6 } from "zod";
12961
+ import { z as z21 } from "zod";
9787
12962
  var DEFAULT_DEVICE_POLL_INTERVAL_SECONDS = 5;
9788
12963
  function buildFormHeaders() {
9789
12964
  const headers = new Headers();
9790
12965
  headers.set("content-type", "application/x-www-form-urlencoded");
9791
12966
  return headers;
9792
12967
  }
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)
12968
+ var deviceAuthorizationSchema = z21.object({
12969
+ device_code: z21.string().min(1),
12970
+ expires_in: z21.number().int().positive().optional(),
12971
+ interval: z21.number().int().positive().optional(),
12972
+ user_code: z21.string().min(1),
12973
+ verification_uri: z21.url(),
12974
+ verification_uri_complete: z21.url().optional()
12975
+ });
12976
+ var tokenResponseSchema = z21.object({
12977
+ access_token: z21.string().min(1),
12978
+ expires_in: z21.number().int().positive().optional(),
12979
+ refresh_token: z21.string().min(1),
12980
+ token_type: z21.string().optional()
12981
+ });
12982
+ var tokenErrorSchema = z21.object({
12983
+ error: z21.string().min(1),
12984
+ error_description: z21.string().optional()
12985
+ });
12986
+ var accessTokenClaimsSchema = z21.object({
12987
+ exp: z21.number().int().positive().optional(),
12988
+ iss: z21.string().min(1).optional(),
12989
+ org_id: z21.string().min(1).optional(),
12990
+ sid: z21.string().min(1).optional(),
12991
+ sub: z21.string().min(1)
9817
12992
  });
9818
12993
  function createWorkosAuthClient({
9819
12994
  fetchFn = fetch,