@swmansion/argent 0.11.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +13 -8
  2. package/bin/argent-android-devtools-0.1.0.apk +0 -0
  3. package/bin/argent-simulator-server.cjs +11 -3
  4. package/bin/darwin/ax-service +0 -0
  5. package/bin/darwin/resources/android/LICENSE.txt +186 -0
  6. package/bin/darwin/resources/android/README.md +11 -0
  7. package/bin/darwin/resources/android/arm64-v8a/libscreen-sharing-agent.so +0 -0
  8. package/bin/darwin/resources/android/armeabi-v7a/libscreen-sharing-agent.so +0 -0
  9. package/bin/darwin/resources/android/screen-sharing-agent.jar +0 -0
  10. package/bin/darwin/resources/android/x86_64/libscreen-sharing-agent.so +0 -0
  11. package/bin/darwin/simulator-server +0 -0
  12. package/bin/linux/resources/android/LICENSE.txt +186 -0
  13. package/bin/linux/resources/android/README.md +11 -0
  14. package/bin/linux/resources/android/arm64-v8a/libscreen-sharing-agent.so +0 -0
  15. package/bin/linux/resources/android/armeabi-v7a/libscreen-sharing-agent.so +0 -0
  16. package/bin/linux/resources/android/screen-sharing-agent.jar +0 -0
  17. package/bin/linux/resources/android/x86_64/libscreen-sharing-agent.so +0 -0
  18. package/bin/linux/simulator-server +0 -0
  19. package/bin/linux-arm64/resources/android/LICENSE.txt +186 -0
  20. package/bin/linux-arm64/resources/android/README.md +11 -0
  21. package/bin/linux-arm64/resources/android/arm64-v8a/libscreen-sharing-agent.so +0 -0
  22. package/bin/linux-arm64/resources/android/armeabi-v7a/libscreen-sharing-agent.so +0 -0
  23. package/bin/linux-arm64/resources/android/screen-sharing-agent.jar +0 -0
  24. package/bin/linux-arm64/resources/android/x86_64/libscreen-sharing-agent.so +0 -0
  25. package/bin/linux-arm64/simulator-server +0 -0
  26. package/dist/cli-cmds.mjs +7345 -762
  27. package/dist/cli.js +3 -3
  28. package/dist/cli.js.map +1 -1
  29. package/dist/installer.mjs +9741 -2815
  30. package/dist/mcp-server.mjs +2925 -150
  31. package/dist/preview-ui/index.html +4500 -645
  32. package/dist/preview-ui/theme.css +231 -0
  33. package/dist/preview-window/main.cjs +182 -0
  34. package/dist/tool-server.cjs +98829 -56347
  35. package/dylibs/libArgentInjectionBootstrap.dylib +0 -0
  36. package/dylibs/libKeyboardPatch.dylib +0 -0
  37. package/dylibs/libNativeDevtoolsIos.dylib +0 -0
  38. package/package.json +14 -7
  39. package/rules/argent.md +23 -2
  40. package/scripts/postinstall.cjs +6 -2
  41. package/skills/argent-device-interact/SKILL.md +36 -28
  42. package/skills/argent-lens/SKILL.md +101 -0
  43. package/skills/argent-metro-debugger/SKILL.md +18 -16
  44. package/skills/argent-native-profiler/SKILL.md +3 -3
  45. package/skills/argent-react-native-app-workflow/SKILL.md +8 -8
@@ -6,7 +6,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __commonJS = (cb, mod) => function __require() {
9
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ try {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ } catch (e) {
12
+ throw mod = 0, e;
13
+ }
10
14
  };
11
15
  var __export = (target, all) => {
12
16
  for (var name in all)
@@ -98,12 +102,12 @@ var require_code = __commonJS({
98
102
  exports._ = _;
99
103
  var plus = new _Code("+");
100
104
  function str(strs, ...args) {
101
- const expr = [safeStringify(strs[0])];
105
+ const expr = [safeStringify2(strs[0])];
102
106
  let i = 0;
103
107
  while (i < args.length) {
104
108
  expr.push(plus);
105
109
  addCodeArg(expr, args[i]);
106
- expr.push(plus, safeStringify(strs[++i]));
110
+ expr.push(plus, safeStringify2(strs[++i]));
107
111
  }
108
112
  optimize(expr);
109
113
  return new _Code(expr);
@@ -155,16 +159,16 @@ var require_code = __commonJS({
155
159
  }
156
160
  exports.strConcat = strConcat;
157
161
  function interpolate(x) {
158
- return typeof x == "number" || typeof x == "boolean" || x === null ? x : safeStringify(Array.isArray(x) ? x.join(",") : x);
162
+ return typeof x == "number" || typeof x == "boolean" || x === null ? x : safeStringify2(Array.isArray(x) ? x.join(",") : x);
159
163
  }
160
164
  function stringify(x) {
161
- return new _Code(safeStringify(x));
165
+ return new _Code(safeStringify2(x));
162
166
  }
163
167
  exports.stringify = stringify;
164
- function safeStringify(x) {
168
+ function safeStringify2(x) {
165
169
  return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
166
170
  }
167
- exports.safeStringify = safeStringify;
171
+ exports.safeStringify = safeStringify2;
168
172
  function getProperty(key) {
169
173
  return typeof key == "string" && exports.IDENTIFIER.test(key) ? new _Code(`.${key}`) : _`[${key}]`;
170
174
  }
@@ -1197,8 +1201,8 @@ var require_util = __commonJS({
1197
1201
  })(Type || (exports.Type = Type = {}));
1198
1202
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
1199
1203
  if (dataProp instanceof codegen_1.Name) {
1200
- const isNumber = dataPropType === Type.Num;
1201
- return jsPropertySyntax ? isNumber ? (0, codegen_1._)`"[" + ${dataProp} + "]"` : (0, codegen_1._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1._)`"/" + ${dataProp}` : (0, codegen_1._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
1204
+ const isNumber2 = dataPropType === Type.Num;
1205
+ return jsPropertySyntax ? isNumber2 ? (0, codegen_1._)`"[" + ${dataProp} + "]"` : (0, codegen_1._)`"['" + ${dataProp} + "']"` : isNumber2 ? (0, codegen_1._)`"/" + ${dataProp}` : (0, codegen_1._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
1202
1206
  }
1203
1207
  return jsPropertySyntax ? (0, codegen_1.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
1204
1208
  }
@@ -2790,11 +2794,11 @@ var require_validate = __commonJS({
2790
2794
  jsonPointer = $data;
2791
2795
  data = names_1.default.rootData;
2792
2796
  } else {
2793
- const matches = RELATIVE_JSON_POINTER.exec($data);
2794
- if (!matches)
2797
+ const matches2 = RELATIVE_JSON_POINTER.exec($data);
2798
+ if (!matches2)
2795
2799
  throw new Error(`Invalid JSON-pointer: ${$data}`);
2796
- const up = +matches[1];
2797
- jsonPointer = matches[2];
2800
+ const up = +matches2[1];
2801
+ jsonPointer = matches2[2];
2798
2802
  if (jsonPointer === "#") {
2799
2803
  if (up >= dataLevel)
2800
2804
  throw new Error(errorMsg("property/index", up));
@@ -2980,7 +2984,7 @@ var require_compile = __commonJS({
2980
2984
  const schOrFunc = root.refs[ref];
2981
2985
  if (schOrFunc)
2982
2986
  return schOrFunc;
2983
- let _sch = resolve2.call(this, root, ref);
2987
+ let _sch = resolve3.call(this, root, ref);
2984
2988
  if (_sch === void 0) {
2985
2989
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
2986
2990
  const { schemaId } = this.opts;
@@ -3007,7 +3011,7 @@ var require_compile = __commonJS({
3007
3011
  function sameSchemaEnv(s1, s2) {
3008
3012
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
3009
3013
  }
3010
- function resolve2(root, ref) {
3014
+ function resolve3(root, ref) {
3011
3015
  let sch;
3012
3016
  while (typeof (sch = this.refs[ref]) == "string")
3013
3017
  ref = sch;
@@ -3225,8 +3229,8 @@ var require_utils = __commonJS({
3225
3229
  }
3226
3230
  return ind;
3227
3231
  }
3228
- function removeDotSegments(path4) {
3229
- let input = path4;
3232
+ function removeDotSegments(path9) {
3233
+ let input = path9;
3230
3234
  const output = [];
3231
3235
  let nextSlash = -1;
3232
3236
  let len = 0;
@@ -3478,8 +3482,8 @@ var require_schemes = __commonJS({
3478
3482
  wsComponent.secure = void 0;
3479
3483
  }
3480
3484
  if (wsComponent.resourceName) {
3481
- const [path4, query] = wsComponent.resourceName.split("?");
3482
- wsComponent.path = path4 && path4 !== "/" ? path4 : void 0;
3485
+ const [path9, query] = wsComponent.resourceName.split("?");
3486
+ wsComponent.path = path9 && path9 !== "/" ? path9 : void 0;
3483
3487
  wsComponent.query = query;
3484
3488
  wsComponent.resourceName = void 0;
3485
3489
  }
@@ -3491,11 +3495,11 @@ var require_schemes = __commonJS({
3491
3495
  urnComponent.error = "URN can not be parsed";
3492
3496
  return urnComponent;
3493
3497
  }
3494
- const matches = urnComponent.path.match(URN_REG);
3495
- if (matches) {
3498
+ const matches2 = urnComponent.path.match(URN_REG);
3499
+ if (matches2) {
3496
3500
  const scheme = options.scheme || urnComponent.scheme || "urn";
3497
- urnComponent.nid = matches[1].toLowerCase();
3498
- urnComponent.nss = matches[2];
3501
+ urnComponent.nid = matches2[1].toLowerCase();
3502
+ urnComponent.nss = matches2[2];
3499
3503
  const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`;
3500
3504
  const schemeHandler = getSchemeHandler(urnScheme);
3501
3505
  urnComponent.path = void 0;
@@ -3638,55 +3642,55 @@ var require_fast_uri = __commonJS({
3638
3642
  }
3639
3643
  return uri;
3640
3644
  }
3641
- function resolve2(baseURI, relativeURI, options) {
3645
+ function resolve3(baseURI, relativeURI, options) {
3642
3646
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3643
3647
  const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
3644
3648
  schemelessOptions.skipEscape = true;
3645
3649
  return serialize(resolved, schemelessOptions);
3646
3650
  }
3647
- function resolveComponent(base, relative, options, skipNormalization) {
3651
+ function resolveComponent(base, relative2, options, skipNormalization) {
3648
3652
  const target = {};
3649
3653
  if (!skipNormalization) {
3650
3654
  base = parse3(serialize(base, options), options);
3651
- relative = parse3(serialize(relative, options), options);
3655
+ relative2 = parse3(serialize(relative2, options), options);
3652
3656
  }
3653
3657
  options = options || {};
3654
- if (!options.tolerant && relative.scheme) {
3655
- target.scheme = relative.scheme;
3656
- target.userinfo = relative.userinfo;
3657
- target.host = relative.host;
3658
- target.port = relative.port;
3659
- target.path = removeDotSegments(relative.path || "");
3660
- target.query = relative.query;
3658
+ if (!options.tolerant && relative2.scheme) {
3659
+ target.scheme = relative2.scheme;
3660
+ target.userinfo = relative2.userinfo;
3661
+ target.host = relative2.host;
3662
+ target.port = relative2.port;
3663
+ target.path = removeDotSegments(relative2.path || "");
3664
+ target.query = relative2.query;
3661
3665
  } else {
3662
- if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
3663
- target.userinfo = relative.userinfo;
3664
- target.host = relative.host;
3665
- target.port = relative.port;
3666
- target.path = removeDotSegments(relative.path || "");
3667
- target.query = relative.query;
3666
+ if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
3667
+ target.userinfo = relative2.userinfo;
3668
+ target.host = relative2.host;
3669
+ target.port = relative2.port;
3670
+ target.path = removeDotSegments(relative2.path || "");
3671
+ target.query = relative2.query;
3668
3672
  } else {
3669
- if (!relative.path) {
3673
+ if (!relative2.path) {
3670
3674
  target.path = base.path;
3671
- if (relative.query !== void 0) {
3672
- target.query = relative.query;
3675
+ if (relative2.query !== void 0) {
3676
+ target.query = relative2.query;
3673
3677
  } else {
3674
3678
  target.query = base.query;
3675
3679
  }
3676
3680
  } else {
3677
- if (relative.path[0] === "/") {
3678
- target.path = removeDotSegments(relative.path);
3681
+ if (relative2.path[0] === "/") {
3682
+ target.path = removeDotSegments(relative2.path);
3679
3683
  } else {
3680
3684
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
3681
- target.path = "/" + relative.path;
3685
+ target.path = "/" + relative2.path;
3682
3686
  } else if (!base.path) {
3683
- target.path = relative.path;
3687
+ target.path = relative2.path;
3684
3688
  } else {
3685
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
3689
+ target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
3686
3690
  }
3687
3691
  target.path = removeDotSegments(target.path);
3688
3692
  }
3689
- target.query = relative.query;
3693
+ target.query = relative2.query;
3690
3694
  }
3691
3695
  target.userinfo = base.userinfo;
3692
3696
  target.host = base.host;
@@ -3694,7 +3698,7 @@ var require_fast_uri = __commonJS({
3694
3698
  }
3695
3699
  target.scheme = base.scheme;
3696
3700
  }
3697
- target.fragment = relative.fragment;
3701
+ target.fragment = relative2.fragment;
3698
3702
  return target;
3699
3703
  }
3700
3704
  function equal(uriA, uriB, options) {
@@ -3765,8 +3769,8 @@ var require_fast_uri = __commonJS({
3765
3769
  return uriTokens.join("");
3766
3770
  }
3767
3771
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
3768
- function getParseError(parsed, matches) {
3769
- if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
3772
+ function getParseError(parsed, matches2) {
3773
+ if (matches2[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
3770
3774
  return 'URI path must start with "/" when authority is present.';
3771
3775
  }
3772
3776
  if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
@@ -3794,19 +3798,19 @@ var require_fast_uri = __commonJS({
3794
3798
  uri = "//" + uri;
3795
3799
  }
3796
3800
  }
3797
- const matches = uri.match(URI_PARSE);
3798
- if (matches) {
3799
- parsed.scheme = matches[1];
3800
- parsed.userinfo = matches[3];
3801
- parsed.host = matches[4];
3802
- parsed.port = parseInt(matches[5], 10);
3803
- parsed.path = matches[6] || "";
3804
- parsed.query = matches[7];
3805
- parsed.fragment = matches[8];
3801
+ const matches2 = uri.match(URI_PARSE);
3802
+ if (matches2) {
3803
+ parsed.scheme = matches2[1];
3804
+ parsed.userinfo = matches2[3];
3805
+ parsed.host = matches2[4];
3806
+ parsed.port = parseInt(matches2[5], 10);
3807
+ parsed.path = matches2[6] || "";
3808
+ parsed.query = matches2[7];
3809
+ parsed.fragment = matches2[8];
3806
3810
  if (isNaN(parsed.port)) {
3807
- parsed.port = matches[5];
3811
+ parsed.port = matches2[5];
3808
3812
  }
3809
- const parseError = getParseError(parsed, matches);
3813
+ const parseError = getParseError(parsed, matches2);
3810
3814
  if (parseError !== void 0) {
3811
3815
  parsed.error = parsed.error || parseError;
3812
3816
  malformedAuthorityOrPort = true;
@@ -3896,7 +3900,7 @@ var require_fast_uri = __commonJS({
3896
3900
  var fastUri = {
3897
3901
  SCHEMES,
3898
3902
  normalize,
3899
- resolve: resolve2,
3903
+ resolve: resolve3,
3900
3904
  resolveComponent,
3901
3905
  equal,
3902
3906
  serialize,
@@ -6257,7 +6261,7 @@ var require_discriminator = __commonJS({
6257
6261
  error: error2,
6258
6262
  code(cxt) {
6259
6263
  const { gen, data, schema, parentSchema, it } = cxt;
6260
- const { oneOf } = parentSchema;
6264
+ const { oneOf: oneOf2 } = parentSchema;
6261
6265
  if (!it.opts.discriminator) {
6262
6266
  throw new Error("discriminator: requires discriminator option");
6263
6267
  }
@@ -6266,7 +6270,7 @@ var require_discriminator = __commonJS({
6266
6270
  throw new Error("discriminator: requires propertyName");
6267
6271
  if (schema.mapping)
6268
6272
  throw new Error("discriminator: mapping is not supported");
6269
- if (!oneOf)
6273
+ if (!oneOf2)
6270
6274
  throw new Error("discriminator: requires oneOf keyword");
6271
6275
  const valid = gen.let("valid", false);
6272
6276
  const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(tagName)}`);
@@ -6294,8 +6298,8 @@ var require_discriminator = __commonJS({
6294
6298
  const oneOfMapping = {};
6295
6299
  const topRequired = hasRequired(parentSchema);
6296
6300
  let tagRequired = true;
6297
- for (let i = 0; i < oneOf.length; i++) {
6298
- let sch = oneOf[i];
6301
+ for (let i = 0; i < oneOf2.length; i++) {
6302
+ let sch = oneOf2[i];
6299
6303
  if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) {
6300
6304
  const ref = sch.$ref;
6301
6305
  sch = compile_1.resolveRef.call(it.self, it.schemaEnv.root, it.baseId, ref);
@@ -6646,12 +6650,12 @@ var require_formats = __commonJS({
6646
6650
  var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
6647
6651
  var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
6648
6652
  function date3(str) {
6649
- const matches = DATE.exec(str);
6650
- if (!matches)
6653
+ const matches2 = DATE.exec(str);
6654
+ if (!matches2)
6651
6655
  return false;
6652
- const year = +matches[1];
6653
- const month = +matches[2];
6654
- const day = +matches[3];
6656
+ const year = +matches2[1];
6657
+ const month = +matches2[2];
6658
+ const day = +matches2[3];
6655
6659
  return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && isLeapYear(year) ? 29 : DAYS[month]);
6656
6660
  }
6657
6661
  function compareDate(d1, d2) {
@@ -6666,16 +6670,16 @@ var require_formats = __commonJS({
6666
6670
  var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
6667
6671
  function getTime(strictTimeZone) {
6668
6672
  return function time3(str) {
6669
- const matches = TIME.exec(str);
6670
- if (!matches)
6673
+ const matches2 = TIME.exec(str);
6674
+ if (!matches2)
6671
6675
  return false;
6672
- const hr = +matches[1];
6673
- const min = +matches[2];
6674
- const sec = +matches[3];
6675
- const tz = matches[4];
6676
- const tzSign = matches[5] === "-" ? -1 : 1;
6677
- const tzH = +(matches[6] || 0);
6678
- const tzM = +(matches[7] || 0);
6676
+ const hr = +matches2[1];
6677
+ const min = +matches2[2];
6678
+ const sec = +matches2[3];
6679
+ const tz = matches2[4];
6680
+ const tzSign = matches2[5] === "-" ? -1 : 1;
6681
+ const tzH = +(matches2[6] || 0);
6682
+ const tzM = +(matches2[7] || 0);
6679
6683
  if (tzH > 23 || tzM > 59 || strictTimeZone && !tz)
6680
6684
  return false;
6681
6685
  if (hr <= 23 && min <= 59 && sec < 60)
@@ -6872,12 +6876,12 @@ var require_dist = __commonJS({
6872
6876
  throw new Error(`Unknown format "${name}"`);
6873
6877
  return f;
6874
6878
  };
6875
- function addFormats(ajv, list, fs3, exportName) {
6879
+ function addFormats(ajv, list, fs8, exportName) {
6876
6880
  var _a3;
6877
6881
  var _b;
6878
6882
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
6879
6883
  for (const f of list)
6880
- ajv.addFormat(f, fs3[f]);
6884
+ ajv.addFormat(f, fs8[f]);
6881
6885
  }
6882
6886
  module.exports = exports = formatsPlugin;
6883
6887
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -6886,9 +6890,9 @@ var require_dist = __commonJS({
6886
6890
  });
6887
6891
 
6888
6892
  // ../argent-mcp/src/mcp-server.ts
6889
- import { appendFile, mkdir as mkdir4 } from "node:fs/promises";
6890
- import { dirname as dirname2 } from "node:path";
6891
- import { homedir as homedir4 } from "node:os";
6893
+ import { appendFile, mkdir as mkdir5 } from "node:fs/promises";
6894
+ import { dirname as dirname4 } from "node:path";
6895
+ import { homedir as homedir5 } from "node:os";
6892
6896
 
6893
6897
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
6894
6898
  import process3 from "node:process";
@@ -7133,10 +7137,10 @@ function mergeDefs(...defs) {
7133
7137
  function cloneDef(schema) {
7134
7138
  return mergeDefs(schema._zod.def);
7135
7139
  }
7136
- function getElementAtPath(obj, path4) {
7137
- if (!path4)
7140
+ function getElementAtPath(obj, path9) {
7141
+ if (!path9)
7138
7142
  return obj;
7139
- return path4.reduce((acc, key) => acc?.[key], obj);
7143
+ return path9.reduce((acc, key) => acc?.[key], obj);
7140
7144
  }
7141
7145
  function promiseAllObject(promisesObj) {
7142
7146
  const keys = Object.keys(promisesObj);
@@ -7545,11 +7549,11 @@ function explicitlyAborted(x, startIndex = 0) {
7545
7549
  }
7546
7550
  return false;
7547
7551
  }
7548
- function prefixIssues(path4, issues) {
7552
+ function prefixIssues(path9, issues) {
7549
7553
  return issues.map((iss) => {
7550
7554
  var _a3;
7551
7555
  (_a3 = iss).path ?? (_a3.path = []);
7552
- iss.path.unshift(path4);
7556
+ iss.path.unshift(path9);
7553
7557
  return iss;
7554
7558
  });
7555
7559
  }
@@ -7696,16 +7700,16 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
7696
7700
  }
7697
7701
  function formatError(error2, mapper = (issue2) => issue2.message) {
7698
7702
  const fieldErrors = { _errors: [] };
7699
- const processError = (error3, path4 = []) => {
7703
+ const processError = (error3, path9 = []) => {
7700
7704
  for (const issue2 of error3.issues) {
7701
7705
  if (issue2.code === "invalid_union" && issue2.errors.length) {
7702
- issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
7706
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
7703
7707
  } else if (issue2.code === "invalid_key") {
7704
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
7708
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
7705
7709
  } else if (issue2.code === "invalid_element") {
7706
- processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
7710
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
7707
7711
  } else {
7708
- const fullpath = [...path4, ...issue2.path];
7712
+ const fullpath = [...path9, ...issue2.path];
7709
7713
  if (fullpath.length === 0) {
7710
7714
  fieldErrors._errors.push(mapper(issue2));
7711
7715
  } else {
@@ -7818,10 +7822,10 @@ var ksuid = /^[A-Za-z0-9]{27}$/;
7818
7822
  var nanoid = /^[a-zA-Z0-9_-]{21}$/;
7819
7823
  var duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
7820
7824
  var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
7821
- var uuid = (version2) => {
7822
- if (!version2)
7825
+ var uuid = (version3) => {
7826
+ if (!version3)
7823
7827
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
7824
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
7828
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version3}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
7825
7829
  };
7826
7830
  var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
7827
7831
  var _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
@@ -8948,13 +8952,13 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
8948
8952
  }
8949
8953
  return propValues;
8950
8954
  });
8951
- const isObject2 = isObject;
8955
+ const isObject3 = isObject;
8952
8956
  const catchall = def.catchall;
8953
8957
  let value;
8954
8958
  inst._zod.parse = (payload, ctx) => {
8955
8959
  value ?? (value = _normalized.value);
8956
8960
  const input = payload.value;
8957
- if (!isObject2(input)) {
8961
+ if (!isObject3(input)) {
8958
8962
  payload.issues.push({
8959
8963
  expected: "object",
8960
8964
  code: "invalid_type",
@@ -9081,7 +9085,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9081
9085
  return (payload, ctx) => fn(shape, payload, ctx);
9082
9086
  };
9083
9087
  let fastpass;
9084
- const isObject2 = isObject;
9088
+ const isObject3 = isObject;
9085
9089
  const jit = !globalConfig.jitless;
9086
9090
  const allowsEval2 = allowsEval;
9087
9091
  const fastEnabled = jit && allowsEval2.value;
@@ -9090,7 +9094,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9090
9094
  inst._zod.parse = (payload, ctx) => {
9091
9095
  value ?? (value = _normalized.value);
9092
9096
  const input = payload.value;
9093
- if (!isObject2(input)) {
9097
+ if (!isObject3(input)) {
9094
9098
  payload.issues.push({
9095
9099
  expected: "object",
9096
9100
  code: "invalid_type",
@@ -10352,12 +10356,12 @@ function _uppercase(params) {
10352
10356
  });
10353
10357
  }
10354
10358
  // @__NO_SIDE_EFFECTS__
10355
- function _includes(includes, params) {
10359
+ function _includes(includes2, params) {
10356
10360
  return new $ZodCheckIncludes({
10357
10361
  check: "string_format",
10358
10362
  format: "includes",
10359
10363
  ...normalizeParams(params),
10360
- includes
10364
+ includes: includes2
10361
10365
  });
10362
10366
  }
10363
10367
  // @__NO_SIDE_EFFECTS__
@@ -13697,12 +13701,12 @@ var StdioServerTransport = class {
13697
13701
  this.onclose?.();
13698
13702
  }
13699
13703
  send(message) {
13700
- return new Promise((resolve2) => {
13704
+ return new Promise((resolve3) => {
13701
13705
  const json = serializeMessage(message);
13702
13706
  if (this._stdout.write(json)) {
13703
- resolve2();
13707
+ resolve3();
13704
13708
  } else {
13705
- this._stdout.once("drain", resolve2);
13709
+ this._stdout.once("drain", resolve3);
13706
13710
  }
13707
13711
  });
13708
13712
  }
@@ -14300,7 +14304,7 @@ var Protocol = class {
14300
14304
  return;
14301
14305
  }
14302
14306
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
14303
- await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
14307
+ await new Promise((resolve3) => setTimeout(resolve3, pollInterval));
14304
14308
  options?.signal?.throwIfAborted();
14305
14309
  }
14306
14310
  } catch (error2) {
@@ -14317,7 +14321,7 @@ var Protocol = class {
14317
14321
  */
14318
14322
  request(request, resultSchema, options) {
14319
14323
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
14320
- return new Promise((resolve2, reject) => {
14324
+ return new Promise((resolve3, reject) => {
14321
14325
  const earlyReject = (error2) => {
14322
14326
  reject(error2);
14323
14327
  };
@@ -14395,7 +14399,7 @@ var Protocol = class {
14395
14399
  if (!parseResult.success) {
14396
14400
  reject(parseResult.error);
14397
14401
  } else {
14398
- resolve2(parseResult.data);
14402
+ resolve3(parseResult.data);
14399
14403
  }
14400
14404
  } catch (error2) {
14401
14405
  reject(error2);
@@ -14656,12 +14660,12 @@ var Protocol = class {
14656
14660
  }
14657
14661
  } catch {
14658
14662
  }
14659
- return new Promise((resolve2, reject) => {
14663
+ return new Promise((resolve3, reject) => {
14660
14664
  if (signal.aborted) {
14661
14665
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
14662
14666
  return;
14663
14667
  }
14664
- const timeoutId = setTimeout(resolve2, interval);
14668
+ const timeoutId = setTimeout(resolve3, interval);
14665
14669
  signal.addEventListener("abort", () => {
14666
14670
  clearTimeout(timeoutId);
14667
14671
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -15483,7 +15487,7 @@ function generateToken() {
15483
15487
  return randomBytes(AUTH_TOKEN_BYTES).toString("hex");
15484
15488
  }
15485
15489
  function findFreePort() {
15486
- return new Promise((resolve2, reject) => {
15490
+ return new Promise((resolve3, reject) => {
15487
15491
  const srv = net.createServer();
15488
15492
  srv.listen(0, "127.0.0.1", () => {
15489
15493
  const addr = srv.address();
@@ -15494,7 +15498,7 @@ function findFreePort() {
15494
15498
  const port = addr.port;
15495
15499
  srv.close((err) => {
15496
15500
  if (err) reject(err);
15497
- else resolve2(port);
15501
+ else resolve3(port);
15498
15502
  });
15499
15503
  });
15500
15504
  srv.on("error", reject);
@@ -15536,7 +15540,7 @@ async function isToolsServerHealthy(port, host = "127.0.0.1", timeoutMs = 2e3, t
15536
15540
  }
15537
15541
  }
15538
15542
  function spawnToolsServer(paths, port, options = {}) {
15539
- return new Promise((resolve2, reject) => {
15543
+ return new Promise((resolve3, reject) => {
15540
15544
  let logFd;
15541
15545
  try {
15542
15546
  fs.mkdirSync(STATE_DIR, { recursive: true });
@@ -15568,7 +15572,7 @@ function spawnToolsServer(paths, port, options = {}) {
15568
15572
  const actualPort = parseInt(match[1], 10);
15569
15573
  rl.close();
15570
15574
  child.stdout?.resume();
15571
- settle(() => resolve2({ port: actualPort, pid }));
15575
+ settle(() => resolve3({ port: actualPort, pid }));
15572
15576
  }
15573
15577
  });
15574
15578
  child.on("error", (err) => {
@@ -15699,8 +15703,100 @@ async function isRemoteRouted() {
15699
15703
  return url !== null;
15700
15704
  }
15701
15705
 
15706
+ // ../argent-tools-client/src/file-inputs.ts
15707
+ import { mkdir as mkdir3, stat, writeFile as writeFile3 } from "node:fs/promises";
15708
+ import { readFile as readFile3 } from "node:fs/promises";
15709
+ import * as path3 from "node:path";
15710
+ var FILE_INPUT_MARKER = "__argentFileInput";
15711
+ var CLIENT_FILE_MARKER = "__argentClientFile";
15712
+ var MAX_CONTENT_BYTES = 32 * 1024 * 1024;
15713
+ function interpolatePath(template, args) {
15714
+ let missing = false;
15715
+ const out = template.replace(/\$\{([A-Za-z0-9_]+)\}/g, (_m, name) => {
15716
+ const v = args[name];
15717
+ if (typeof v !== "string" || v.length === 0) {
15718
+ missing = true;
15719
+ return "";
15720
+ }
15721
+ return v;
15722
+ });
15723
+ return missing ? null : out;
15724
+ }
15725
+ async function prepareFileInputs(specs, args, opts) {
15726
+ if (!specs || specs.length === 0 || typeof args !== "object" || args === null) {
15727
+ return args;
15728
+ }
15729
+ const record2 = args;
15730
+ let out = null;
15731
+ for (const spec of specs) {
15732
+ if (spec.target in record2 && typeof record2[spec.target] !== "string") continue;
15733
+ const filePath = interpolatePath(spec.path, record2);
15734
+ if (filePath === null) continue;
15735
+ if (spec.target in record2 && record2[spec.target] !== filePath) continue;
15736
+ const wire = { [FILE_INPUT_MARKER]: true, path: filePath };
15737
+ if (spec.kind === "file") {
15738
+ try {
15739
+ const st = await stat(filePath);
15740
+ if (st.isFile()) {
15741
+ wire.size = st.size;
15742
+ wire.mtimeMs = st.mtimeMs;
15743
+ if (opts.includeContent && st.size <= MAX_CONTENT_BYTES) {
15744
+ wire.content = (await readFile3(filePath)).toString("base64");
15745
+ } else if (opts.includeContent) {
15746
+ wire.contentOmitted = "size-limit";
15747
+ }
15748
+ }
15749
+ } catch {
15750
+ }
15751
+ }
15752
+ out = out ?? { ...record2 };
15753
+ out[spec.target] = wire;
15754
+ }
15755
+ return out ?? args;
15756
+ }
15757
+ function isAllowedClientFilePath(p) {
15758
+ if (!path3.isAbsolute(p)) return false;
15759
+ const segments = p.split(/[\\/]+/);
15760
+ if (segments.includes("..")) return false;
15761
+ const file = segments[segments.length - 1] ?? "";
15762
+ if (!/^[A-Za-z0-9_-]+\.yaml$/.test(file)) return false;
15763
+ return segments[segments.length - 3] === ".argent" && segments[segments.length - 2] === "flows";
15764
+ }
15765
+ function isClientFileDirective(value) {
15766
+ return !!value && typeof value === "object" && value[CLIENT_FILE_MARKER] === true && typeof value.path === "string" && typeof value.content === "string";
15767
+ }
15768
+ async function applyClientFileDirectives(result) {
15769
+ const written = [];
15770
+ async function walk(value) {
15771
+ if (isClientFileDirective(value)) {
15772
+ if (!isAllowedClientFilePath(value.path)) return null;
15773
+ try {
15774
+ await mkdir3(path3.dirname(value.path), { recursive: true });
15775
+ await writeFile3(value.path, value.content, "utf8");
15776
+ written.push(value.path);
15777
+ return value.path;
15778
+ } catch {
15779
+ return null;
15780
+ }
15781
+ }
15782
+ if (Array.isArray(value)) {
15783
+ return Promise.all(value.map(walk));
15784
+ }
15785
+ if (value && typeof value === "object") {
15786
+ const out = {};
15787
+ for (const [k, v] of Object.entries(value)) {
15788
+ out[k] = await walk(v);
15789
+ }
15790
+ return out;
15791
+ }
15792
+ return value;
15793
+ }
15794
+ const rewritten = await walk(result);
15795
+ return { result: rewritten, written };
15796
+ }
15797
+
15702
15798
  // ../argent-tools-client/src/artifacts.ts
15703
- import { mkdir as mkdir3, readFile as readFile3, rm, stat, writeFile as writeFile3 } from "node:fs/promises";
15799
+ import { mkdir as mkdir4, readFile as readFile4, rm, stat as stat2, writeFile as writeFile4 } from "node:fs/promises";
15704
15800
  import { tmpdir } from "node:os";
15705
15801
  import { basename, join as join3 } from "node:path";
15706
15802
  import { createHash } from "node:crypto";
@@ -15739,7 +15835,7 @@ function artifactDir(deviceId) {
15739
15835
  async function resolveLocalFile(handle) {
15740
15836
  if (!handle.hostPath) return null;
15741
15837
  try {
15742
- const st = await stat(handle.hostPath);
15838
+ const st = await stat2(handle.hostPath);
15743
15839
  if (handle.archive) {
15744
15840
  return st.isDirectory() ? handle.hostPath : null;
15745
15841
  }
@@ -15756,7 +15852,7 @@ async function resolveLocalFile(handle) {
15756
15852
  async function downloadAndExtractArchive(handle, data, dir) {
15757
15853
  const tarball = join3(dir, `${sanitizeSegment(handle.filename)}.tar.gz`);
15758
15854
  try {
15759
- await writeFile3(tarball, data);
15855
+ await writeFile4(tarball, data);
15760
15856
  await execFileAsync("tar", ["-xzf", tarball, "-C", dir]);
15761
15857
  return join3(dir, handle.filename);
15762
15858
  } catch {
@@ -15774,7 +15870,7 @@ async function materializeArtifacts(result, ctx) {
15774
15870
  let dirReady = false;
15775
15871
  async function ensureDir() {
15776
15872
  if (!dirReady) {
15777
- await mkdir3(dir, { recursive: true });
15873
+ await mkdir4(dir, { recursive: true });
15778
15874
  dirReady = true;
15779
15875
  }
15780
15876
  }
@@ -15783,7 +15879,7 @@ async function materializeArtifacts(result, ctx) {
15783
15879
  const localPath = await resolveLocalFile(value);
15784
15880
  if (localPath) {
15785
15881
  if (value.mimeType.startsWith("image/")) {
15786
- images.push({ localPath, data: await readFile3(localPath), mimeType: value.mimeType });
15882
+ images.push({ localPath, data: await readFile4(localPath), mimeType: value.mimeType });
15787
15883
  }
15788
15884
  return localPath;
15789
15885
  }
@@ -15799,7 +15895,7 @@ async function materializeArtifacts(result, ctx) {
15799
15895
  }
15800
15896
  if (value.size > 0 && data.length !== value.size) return null;
15801
15897
  const downloadedPath = join3(dir, sanitizeSegment(value.filename));
15802
- await writeFile3(downloadedPath, data);
15898
+ await writeFile4(downloadedPath, data);
15803
15899
  if (value.mimeType.startsWith("image/")) {
15804
15900
  images.push({ localPath: downloadedPath, data, mimeType: value.mimeType });
15805
15901
  }
@@ -15831,8 +15927,2617 @@ function getDeviceIdFromArgs(args) {
15831
15927
  return void 0;
15832
15928
  }
15833
15929
 
15930
+ // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
15931
+ import { dirname as dirname2, posix, sep } from "path";
15932
+ function createModulerModifier() {
15933
+ const getModuleFromFileName = createGetModuleFromFilename();
15934
+ return async (frames) => {
15935
+ for (const frame of frames) frame.module = getModuleFromFileName(frame.filename);
15936
+ return frames;
15937
+ };
15938
+ }
15939
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname2(process.argv[1]) : process.cwd(), isWindows = "\\" === sep) {
15940
+ const normalizedBase = isWindows ? normalizeWindowsPath(basePath) : basePath;
15941
+ return (filename) => {
15942
+ if (!filename) return;
15943
+ const normalizedFilename = isWindows ? normalizeWindowsPath(filename) : filename;
15944
+ let { dir, base: file, ext } = posix.parse(normalizedFilename);
15945
+ if (".js" === ext || ".mjs" === ext || ".cjs" === ext) file = file.slice(0, -1 * ext.length);
15946
+ const decodedFile = decodeURIComponent(file);
15947
+ if (!dir) dir = ".";
15948
+ const n = dir.lastIndexOf("/node_modules");
15949
+ if (n > -1) return `${dir.slice(n + 14).replace(/\//g, ".")}:${decodedFile}`;
15950
+ if (dir.startsWith(normalizedBase)) {
15951
+ const moduleName = dir.slice(normalizedBase.length + 1).replace(/\//g, ".");
15952
+ return moduleName ? `${moduleName}:${decodedFile}` : decodedFile;
15953
+ }
15954
+ return decodedFile;
15955
+ };
15956
+ }
15957
+ function normalizeWindowsPath(path9) {
15958
+ return path9.replace(/^[A-Z]:/, "").replace(/\\/g, "/");
15959
+ }
15960
+
15961
+ // ../../node_modules/@posthog/core/dist/utils/type-utils.mjs
15962
+ var nativeIsArray = Array.isArray;
15963
+ var ObjProto = Object.prototype;
15964
+ var type_utils_hasOwnProperty = ObjProto.hasOwnProperty;
15965
+ var type_utils_toString = ObjProto.toString;
15966
+ var isArray = nativeIsArray || function(obj) {
15967
+ return "[object Array]" === type_utils_toString.call(obj);
15968
+ };
15969
+ var isObject2 = (x) => x === Object(x) && !isArray(x);
15970
+ var isUndefined = (x) => void 0 === x;
15971
+ var isString = (x) => "[object String]" == type_utils_toString.call(x);
15972
+ var isEmptyString = (x) => isString(x) && 0 === x.trim().length;
15973
+ var isNumber = (x) => "[object Number]" == type_utils_toString.call(x) && x === x;
15974
+ var isPlainError = (x) => x instanceof Error;
15975
+ function isPrimitive(value) {
15976
+ return null === value || "object" != typeof value;
15977
+ }
15978
+ function isBuiltin(candidate, className) {
15979
+ return Object.prototype.toString.call(candidate) === `[object ${className}]`;
15980
+ }
15981
+ function isErrorEvent(event) {
15982
+ return isBuiltin(event, "ErrorEvent");
15983
+ }
15984
+ function isEvent(candidate) {
15985
+ return "undefined" != typeof Event && isInstanceOf(candidate, Event);
15986
+ }
15987
+ function isInstanceOf(candidate, base) {
15988
+ try {
15989
+ return candidate instanceof base;
15990
+ } catch {
15991
+ return false;
15992
+ }
15993
+ }
15994
+
15995
+ // ../../node_modules/@posthog/core/dist/utils/number-utils.mjs
15996
+ function clampToRange(value, min, max, logger, fallbackValue) {
15997
+ if (min > max) {
15998
+ logger.warn("min cannot be greater than max.");
15999
+ min = max;
16000
+ }
16001
+ if (isNumber(value)) if (value > max) {
16002
+ logger.warn(" cannot be greater than max: " + max + ". Using max value instead.");
16003
+ return max;
16004
+ } else {
16005
+ if (!(value < min)) return value;
16006
+ logger.warn(" cannot be less than min: " + min + ". Using min value instead.");
16007
+ return min;
16008
+ }
16009
+ logger.warn(" must be a number. using max or fallback. max: " + max + ", fallback: " + fallbackValue);
16010
+ return clampToRange(fallbackValue || max, min, max, logger);
16011
+ }
16012
+
16013
+ // ../../node_modules/@posthog/core/dist/utils/bucketed-rate-limiter.mjs
16014
+ var ONE_DAY_IN_MS = 864e5;
16015
+ var BucketedRateLimiter = class {
16016
+ constructor(options) {
16017
+ this._buckets = {};
16018
+ this._onBucketRateLimited = options._onBucketRateLimited;
16019
+ this._bucketSize = clampToRange(options.bucketSize, 0, 100, options._logger);
16020
+ this._refillRate = clampToRange(options.refillRate, 0, this._bucketSize, options._logger);
16021
+ this._refillInterval = clampToRange(options.refillInterval, 0, ONE_DAY_IN_MS, options._logger);
16022
+ }
16023
+ _applyRefill(bucket, now) {
16024
+ const elapsedMs = now - bucket.lastAccess;
16025
+ const refillIntervals = Math.floor(elapsedMs / this._refillInterval);
16026
+ if (refillIntervals > 0) {
16027
+ const tokensToAdd = refillIntervals * this._refillRate;
16028
+ bucket.tokens = Math.min(bucket.tokens + tokensToAdd, this._bucketSize);
16029
+ bucket.lastAccess = bucket.lastAccess + refillIntervals * this._refillInterval;
16030
+ }
16031
+ }
16032
+ consumeRateLimit(key) {
16033
+ const now = Date.now();
16034
+ const keyStr = String(key);
16035
+ let bucket = this._buckets[keyStr];
16036
+ if (bucket) this._applyRefill(bucket, now);
16037
+ else {
16038
+ bucket = {
16039
+ tokens: this._bucketSize,
16040
+ lastAccess: now
16041
+ };
16042
+ this._buckets[keyStr] = bucket;
16043
+ }
16044
+ if (0 === bucket.tokens) return true;
16045
+ bucket.tokens--;
16046
+ if (0 === bucket.tokens) this._onBucketRateLimited?.(key);
16047
+ return 0 === bucket.tokens;
16048
+ }
16049
+ stop() {
16050
+ this._buckets = {};
16051
+ }
16052
+ };
16053
+
16054
+ // ../../node_modules/@posthog/core/dist/utils/user-agent-utils.mjs
16055
+ var MOBILE = "Mobile";
16056
+ var IOS = "iOS";
16057
+ var ANDROID = "Android";
16058
+ var TABLET = "Tablet";
16059
+ var ANDROID_TABLET = ANDROID + " " + TABLET;
16060
+ var APPLE = "Apple";
16061
+ var APPLE_WATCH = APPLE + " Watch";
16062
+ var SAFARI = "Safari";
16063
+ var BLACKBERRY = "BlackBerry";
16064
+ var SAMSUNG = "Samsung";
16065
+ var SAMSUNG_BROWSER = SAMSUNG + "Browser";
16066
+ var SAMSUNG_INTERNET = SAMSUNG + " Internet";
16067
+ var CHROME = "Chrome";
16068
+ var CHROME_OS = CHROME + " OS";
16069
+ var CHROME_IOS = CHROME + " " + IOS;
16070
+ var INTERNET_EXPLORER = "Internet Explorer";
16071
+ var INTERNET_EXPLORER_MOBILE = INTERNET_EXPLORER + " " + MOBILE;
16072
+ var OPERA = "Opera";
16073
+ var OPERA_MINI = OPERA + " Mini";
16074
+ var EDGE = "Edge";
16075
+ var MICROSOFT_EDGE = "Microsoft " + EDGE;
16076
+ var FIREFOX = "Firefox";
16077
+ var FIREFOX_IOS = FIREFOX + " " + IOS;
16078
+ var NINTENDO = "Nintendo";
16079
+ var PLAYSTATION = "PlayStation";
16080
+ var XBOX = "Xbox";
16081
+ var ANDROID_MOBILE = ANDROID + " " + MOBILE;
16082
+ var MOBILE_SAFARI = MOBILE + " " + SAFARI;
16083
+ var WINDOWS = "Windows";
16084
+ var WINDOWS_PHONE = WINDOWS + " Phone";
16085
+ var GENERIC = "Generic";
16086
+ var GENERIC_MOBILE = GENERIC + " " + MOBILE.toLowerCase();
16087
+ var GENERIC_TABLET = GENERIC + " " + TABLET.toLowerCase();
16088
+ var KONQUEROR = "Konqueror";
16089
+ var OCULUS_BROWSER = "Oculus Browser";
16090
+ var BROWSER_VERSION_REGEX_SUFFIX = "(\\d+(\\.\\d+)?)";
16091
+ var DEFAULT_BROWSER_VERSION_REGEX = new RegExp("Version/" + BROWSER_VERSION_REGEX_SUFFIX);
16092
+ var XBOX_REGEX = new RegExp(XBOX, "i");
16093
+ var PLAYSTATION_REGEX = new RegExp(PLAYSTATION + " \\w+", "i");
16094
+ var NINTENDO_REGEX = new RegExp(NINTENDO + " \\w+", "i");
16095
+ var BLACKBERRY_REGEX = new RegExp(BLACKBERRY + "|PlayBook|BB10", "i");
16096
+ var windowsVersionMap = {
16097
+ "NT3.51": "NT 3.11",
16098
+ "NT4.0": "NT 4.0",
16099
+ "5.0": "2000",
16100
+ "5.1": "XP",
16101
+ "5.2": "XP",
16102
+ "6.0": "Vista",
16103
+ "6.1": "7",
16104
+ "6.2": "8",
16105
+ "6.3": "8.1",
16106
+ "6.4": "10",
16107
+ "10.0": "10"
16108
+ };
16109
+ var versionRegexes = {
16110
+ [INTERNET_EXPLORER_MOBILE]: [
16111
+ new RegExp("rv:" + BROWSER_VERSION_REGEX_SUFFIX)
16112
+ ],
16113
+ [MICROSOFT_EDGE]: [
16114
+ new RegExp(EDGE + "?\\/" + BROWSER_VERSION_REGEX_SUFFIX)
16115
+ ],
16116
+ [CHROME]: [
16117
+ new RegExp("(" + CHROME + "|CrMo)\\/" + BROWSER_VERSION_REGEX_SUFFIX)
16118
+ ],
16119
+ [CHROME_IOS]: [
16120
+ new RegExp("CriOS\\/" + BROWSER_VERSION_REGEX_SUFFIX)
16121
+ ],
16122
+ "UC Browser": [
16123
+ new RegExp("(UCBrowser|UCWEB)\\/" + BROWSER_VERSION_REGEX_SUFFIX)
16124
+ ],
16125
+ [SAFARI]: [
16126
+ DEFAULT_BROWSER_VERSION_REGEX
16127
+ ],
16128
+ [MOBILE_SAFARI]: [
16129
+ DEFAULT_BROWSER_VERSION_REGEX
16130
+ ],
16131
+ [OPERA]: [
16132
+ new RegExp("(" + OPERA + "|OPR)\\/" + BROWSER_VERSION_REGEX_SUFFIX)
16133
+ ],
16134
+ [FIREFOX]: [
16135
+ new RegExp(FIREFOX + "\\/" + BROWSER_VERSION_REGEX_SUFFIX)
16136
+ ],
16137
+ [FIREFOX_IOS]: [
16138
+ new RegExp("FxiOS\\/" + BROWSER_VERSION_REGEX_SUFFIX)
16139
+ ],
16140
+ [KONQUEROR]: [
16141
+ new RegExp("Konqueror[:/]?" + BROWSER_VERSION_REGEX_SUFFIX, "i")
16142
+ ],
16143
+ [BLACKBERRY]: [
16144
+ new RegExp(BLACKBERRY + " " + BROWSER_VERSION_REGEX_SUFFIX),
16145
+ DEFAULT_BROWSER_VERSION_REGEX
16146
+ ],
16147
+ [ANDROID_MOBILE]: [
16148
+ new RegExp("android\\s" + BROWSER_VERSION_REGEX_SUFFIX, "i")
16149
+ ],
16150
+ [SAMSUNG_INTERNET]: [
16151
+ new RegExp(SAMSUNG_BROWSER + "\\/" + BROWSER_VERSION_REGEX_SUFFIX)
16152
+ ],
16153
+ [OCULUS_BROWSER]: [
16154
+ new RegExp("OculusBrowser\\/" + BROWSER_VERSION_REGEX_SUFFIX)
16155
+ ],
16156
+ [INTERNET_EXPLORER]: [
16157
+ new RegExp("(rv:|MSIE )" + BROWSER_VERSION_REGEX_SUFFIX)
16158
+ ],
16159
+ Mozilla: [
16160
+ new RegExp("rv:" + BROWSER_VERSION_REGEX_SUFFIX)
16161
+ ]
16162
+ };
16163
+ var osMatchers = [
16164
+ [
16165
+ new RegExp(XBOX + "; " + XBOX + " (.*?)[);]", "i"),
16166
+ (match) => [
16167
+ XBOX,
16168
+ match && match[1] || ""
16169
+ ]
16170
+ ],
16171
+ [
16172
+ new RegExp(NINTENDO, "i"),
16173
+ [
16174
+ NINTENDO,
16175
+ ""
16176
+ ]
16177
+ ],
16178
+ [
16179
+ new RegExp(PLAYSTATION, "i"),
16180
+ [
16181
+ PLAYSTATION,
16182
+ ""
16183
+ ]
16184
+ ],
16185
+ [
16186
+ BLACKBERRY_REGEX,
16187
+ [
16188
+ BLACKBERRY,
16189
+ ""
16190
+ ]
16191
+ ],
16192
+ [
16193
+ new RegExp(WINDOWS, "i"),
16194
+ (_, user_agent) => {
16195
+ if (/Phone/.test(user_agent) || /WPDesktop/.test(user_agent)) return [
16196
+ WINDOWS_PHONE,
16197
+ ""
16198
+ ];
16199
+ if (new RegExp(MOBILE).test(user_agent) && !/IEMobile\b/.test(user_agent)) return [
16200
+ WINDOWS + " " + MOBILE,
16201
+ ""
16202
+ ];
16203
+ const match = /Windows NT ([0-9.]+)/i.exec(user_agent);
16204
+ if (match && match[1]) {
16205
+ const version3 = match[1];
16206
+ let osVersion = windowsVersionMap[version3] || "";
16207
+ if (/arm/i.test(user_agent)) osVersion = "RT";
16208
+ return [
16209
+ WINDOWS,
16210
+ osVersion
16211
+ ];
16212
+ }
16213
+ return [
16214
+ WINDOWS,
16215
+ ""
16216
+ ];
16217
+ }
16218
+ ],
16219
+ [
16220
+ /((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,
16221
+ (match) => {
16222
+ if (match && match[3]) {
16223
+ const versionParts = [
16224
+ match[3],
16225
+ match[4],
16226
+ match[5] || "0"
16227
+ ];
16228
+ return [
16229
+ IOS,
16230
+ versionParts.join(".")
16231
+ ];
16232
+ }
16233
+ return [
16234
+ IOS,
16235
+ ""
16236
+ ];
16237
+ }
16238
+ ],
16239
+ [
16240
+ /(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,
16241
+ (match) => {
16242
+ let version3 = "";
16243
+ if (match && match.length >= 3) version3 = isUndefined(match[2]) ? match[3] : match[2];
16244
+ return [
16245
+ "watchOS",
16246
+ version3
16247
+ ];
16248
+ }
16249
+ ],
16250
+ [
16251
+ new RegExp("(" + ANDROID + " (\\d+)\\.(\\d+)\\.?(\\d+)?|" + ANDROID + ")", "i"),
16252
+ (match) => {
16253
+ if (match && match[2]) {
16254
+ const versionParts = [
16255
+ match[2],
16256
+ match[3],
16257
+ match[4] || "0"
16258
+ ];
16259
+ return [
16260
+ ANDROID,
16261
+ versionParts.join(".")
16262
+ ];
16263
+ }
16264
+ return [
16265
+ ANDROID,
16266
+ ""
16267
+ ];
16268
+ }
16269
+ ],
16270
+ [
16271
+ /Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,
16272
+ (match) => {
16273
+ const result = [
16274
+ "Mac OS X",
16275
+ ""
16276
+ ];
16277
+ if (match && match[1]) {
16278
+ const versionParts = [
16279
+ match[1],
16280
+ match[2],
16281
+ match[3] || "0"
16282
+ ];
16283
+ result[1] = versionParts.join(".");
16284
+ }
16285
+ return result;
16286
+ }
16287
+ ],
16288
+ [
16289
+ /Mac/i,
16290
+ [
16291
+ "Mac OS X",
16292
+ ""
16293
+ ]
16294
+ ],
16295
+ [
16296
+ /CrOS/,
16297
+ [
16298
+ CHROME_OS,
16299
+ ""
16300
+ ]
16301
+ ],
16302
+ [
16303
+ /Linux|debian/i,
16304
+ [
16305
+ "Linux",
16306
+ ""
16307
+ ]
16308
+ ]
16309
+ ];
16310
+
16311
+ // ../../node_modules/@posthog/core/dist/utils/index.mjs
16312
+ var isError = (x) => x instanceof Error;
16313
+
16314
+ // ../../node_modules/@posthog/core/dist/logs/logs-utils.mjs
16315
+ var OTLP_SEVERITY_MAP = {
16316
+ trace: {
16317
+ text: "TRACE",
16318
+ number: 1
16319
+ },
16320
+ debug: {
16321
+ text: "DEBUG",
16322
+ number: 5
16323
+ },
16324
+ info: {
16325
+ text: "INFO",
16326
+ number: 9
16327
+ },
16328
+ warn: {
16329
+ text: "WARN",
16330
+ number: 13
16331
+ },
16332
+ error: {
16333
+ text: "ERROR",
16334
+ number: 17
16335
+ },
16336
+ fatal: {
16337
+ text: "FATAL",
16338
+ number: 21
16339
+ }
16340
+ };
16341
+ var DEFAULT_OTLP_SEVERITY = OTLP_SEVERITY_MAP.info;
16342
+
16343
+ // ../../node_modules/@posthog/core/dist/error-tracking/index.mjs
16344
+ var error_tracking_exports = {};
16345
+ __export(error_tracking_exports, {
16346
+ DEFAULT_EXCEPTION_STEPS_CONFIG: () => DEFAULT_EXCEPTION_STEPS_CONFIG,
16347
+ DOMExceptionCoercer: () => DOMExceptionCoercer,
16348
+ EXCEPTION_STEP_INTERNAL_FIELDS: () => EXCEPTION_STEP_INTERNAL_FIELDS,
16349
+ ErrorCoercer: () => ErrorCoercer,
16350
+ ErrorEventCoercer: () => ErrorEventCoercer,
16351
+ ErrorPropertiesBuilder: () => ErrorPropertiesBuilder,
16352
+ EventCoercer: () => EventCoercer,
16353
+ ExceptionStepsBuffer: () => ExceptionStepsBuffer,
16354
+ ObjectCoercer: () => ObjectCoercer,
16355
+ PrimitiveCoercer: () => PrimitiveCoercer,
16356
+ PromiseRejectionEventCoercer: () => PromiseRejectionEventCoercer,
16357
+ ReduceableCache: () => ReduceableCache,
16358
+ StringCoercer: () => StringCoercer,
16359
+ chromeStackLineParser: () => chromeStackLineParser,
16360
+ createDefaultStackParser: () => createDefaultStackParser,
16361
+ createStackParser: () => createStackParser,
16362
+ geckoStackLineParser: () => geckoStackLineParser,
16363
+ getUtf8ByteLength: () => getUtf8ByteLength,
16364
+ nodeStackLineParser: () => nodeStackLineParser,
16365
+ opera10StackLineParser: () => opera10StackLineParser,
16366
+ opera11StackLineParser: () => opera11StackLineParser,
16367
+ resolveExceptionStepsConfig: () => resolveExceptionStepsConfig,
16368
+ reverseAndStripFrames: () => reverseAndStripFrames,
16369
+ stripReservedExceptionStepFields: () => stripReservedExceptionStepFields,
16370
+ winjsStackLineParser: () => winjsStackLineParser
16371
+ });
16372
+
16373
+ // ../../node_modules/@posthog/core/dist/error-tracking/chunk-ids.mjs
16374
+ var parsedStackResults;
16375
+ var lastKeysCount;
16376
+ var cachedFilenameChunkIds;
16377
+ function getFilenameToChunkIdMap(stackParser) {
16378
+ const chunkIdMap = globalThis._posthogChunkIds;
16379
+ if (!chunkIdMap) return;
16380
+ const chunkIdKeys = Object.keys(chunkIdMap);
16381
+ if (cachedFilenameChunkIds && chunkIdKeys.length === lastKeysCount) return cachedFilenameChunkIds;
16382
+ lastKeysCount = chunkIdKeys.length;
16383
+ cachedFilenameChunkIds = chunkIdKeys.reduce((acc, stackKey) => {
16384
+ if (!parsedStackResults) parsedStackResults = {};
16385
+ const result = parsedStackResults[stackKey];
16386
+ if (result) acc[result[0]] = result[1];
16387
+ else {
16388
+ const parsedStack = stackParser(stackKey);
16389
+ for (let i = parsedStack.length - 1; i >= 0; i--) {
16390
+ const stackFrame = parsedStack[i];
16391
+ const filename = stackFrame?.filename;
16392
+ const chunkId = chunkIdMap[stackKey];
16393
+ if (filename && chunkId) {
16394
+ acc[filename] = chunkId;
16395
+ parsedStackResults[stackKey] = [
16396
+ filename,
16397
+ chunkId
16398
+ ];
16399
+ break;
16400
+ }
16401
+ }
16402
+ }
16403
+ return acc;
16404
+ }, {});
16405
+ return cachedFilenameChunkIds;
16406
+ }
16407
+
16408
+ // ../../node_modules/@posthog/core/dist/error-tracking/error-properties-builder.mjs
16409
+ var MAX_CAUSE_RECURSION = 4;
16410
+ var ErrorPropertiesBuilder = class {
16411
+ constructor(coercers, stackParser, modifiers = []) {
16412
+ this.coercers = coercers;
16413
+ this.stackParser = stackParser;
16414
+ this.modifiers = modifiers;
16415
+ }
16416
+ buildFromUnknown(input, hint = {}) {
16417
+ const providedMechanism = hint && hint.mechanism;
16418
+ const mechanism = providedMechanism || {
16419
+ handled: true,
16420
+ type: "generic"
16421
+ };
16422
+ const coercingContext = this.buildCoercingContext(mechanism, hint, 0);
16423
+ const exceptionWithCause = coercingContext.apply(input);
16424
+ const parsingContext = this.buildParsingContext(hint);
16425
+ const exceptionWithStack = this.parseStacktrace(exceptionWithCause, parsingContext);
16426
+ const exceptionList = this.convertToExceptionList(exceptionWithStack, mechanism);
16427
+ return {
16428
+ $exception_list: exceptionList,
16429
+ $exception_level: "error"
16430
+ };
16431
+ }
16432
+ async modifyFrames(exceptionList) {
16433
+ for (const exc of exceptionList) if (exc.stacktrace && exc.stacktrace.frames && isArray(exc.stacktrace.frames)) exc.stacktrace.frames = await this.applyModifiers(exc.stacktrace.frames);
16434
+ return exceptionList;
16435
+ }
16436
+ coerceFallback(ctx) {
16437
+ return {
16438
+ type: "Error",
16439
+ value: "Unknown error",
16440
+ stack: ctx.syntheticException?.stack,
16441
+ synthetic: true
16442
+ };
16443
+ }
16444
+ parseStacktrace(err, ctx) {
16445
+ let cause;
16446
+ if (null != err.cause) cause = this.parseStacktrace(err.cause, ctx);
16447
+ let stack;
16448
+ if ("" != err.stack && null != err.stack) stack = this.applyChunkIds(this.stackParser(err.stack, err.synthetic ? ctx.skipFirstLines : 0), ctx.chunkIdMap);
16449
+ return {
16450
+ ...err,
16451
+ cause,
16452
+ stack
16453
+ };
16454
+ }
16455
+ applyChunkIds(frames, chunkIdMap) {
16456
+ return frames.map((frame) => {
16457
+ if (frame.filename && chunkIdMap) frame.chunk_id = chunkIdMap[frame.filename];
16458
+ return frame;
16459
+ });
16460
+ }
16461
+ applyCoercers(input, ctx) {
16462
+ for (const adapter of this.coercers) if (adapter.match(input)) return adapter.coerce(input, ctx);
16463
+ return this.coerceFallback(ctx);
16464
+ }
16465
+ async applyModifiers(frames) {
16466
+ let newFrames = frames;
16467
+ for (const modifier of this.modifiers) newFrames = await modifier(newFrames);
16468
+ return newFrames;
16469
+ }
16470
+ convertToExceptionList(exceptionWithStack, mechanism) {
16471
+ const currentException = {
16472
+ type: exceptionWithStack.type,
16473
+ value: exceptionWithStack.value,
16474
+ mechanism: {
16475
+ type: mechanism.type ?? "generic",
16476
+ handled: mechanism.handled ?? true,
16477
+ synthetic: exceptionWithStack.synthetic ?? false
16478
+ }
16479
+ };
16480
+ if (exceptionWithStack.stack) currentException.stacktrace = {
16481
+ type: "raw",
16482
+ frames: exceptionWithStack.stack
16483
+ };
16484
+ const exceptionList = [
16485
+ currentException
16486
+ ];
16487
+ if (null != exceptionWithStack.cause) exceptionList.push(...this.convertToExceptionList(exceptionWithStack.cause, {
16488
+ ...mechanism,
16489
+ handled: true
16490
+ }));
16491
+ return exceptionList;
16492
+ }
16493
+ buildParsingContext(hint) {
16494
+ const context = {
16495
+ chunkIdMap: getFilenameToChunkIdMap(this.stackParser),
16496
+ skipFirstLines: hint.skipFirstLines ?? 1
16497
+ };
16498
+ return context;
16499
+ }
16500
+ buildCoercingContext(mechanism, hint, depth = 0) {
16501
+ const coerce = (input, depth2) => {
16502
+ if (!(depth2 <= MAX_CAUSE_RECURSION)) return;
16503
+ {
16504
+ const ctx = this.buildCoercingContext(mechanism, hint, depth2);
16505
+ return this.applyCoercers(input, ctx);
16506
+ }
16507
+ };
16508
+ const context = {
16509
+ ...hint,
16510
+ syntheticException: 0 == depth ? hint.syntheticException : void 0,
16511
+ mechanism,
16512
+ apply: (input) => coerce(input, depth),
16513
+ next: (input) => coerce(input, depth + 1)
16514
+ };
16515
+ return context;
16516
+ }
16517
+ };
16518
+
16519
+ // ../../node_modules/@posthog/core/dist/error-tracking/parsers/base.mjs
16520
+ var UNKNOWN_FUNCTION = "?";
16521
+ function createFrame(platform, filename, func, lineno, colno) {
16522
+ const frame = {
16523
+ platform,
16524
+ filename,
16525
+ function: "<anonymous>" === func ? UNKNOWN_FUNCTION : func,
16526
+ in_app: true
16527
+ };
16528
+ if (!isUndefined(lineno)) frame.lineno = lineno;
16529
+ if (!isUndefined(colno)) frame.colno = colno;
16530
+ return frame;
16531
+ }
16532
+
16533
+ // ../../node_modules/@posthog/core/dist/error-tracking/parsers/safari.mjs
16534
+ var extractSafariExtensionDetails = (func, filename) => {
16535
+ const isSafariExtension = -1 !== func.indexOf("safari-extension");
16536
+ const isSafariWebExtension = -1 !== func.indexOf("safari-web-extension");
16537
+ return isSafariExtension || isSafariWebExtension ? [
16538
+ -1 !== func.indexOf("@") ? func.split("@")[0] : UNKNOWN_FUNCTION,
16539
+ isSafariExtension ? `safari-extension:${filename}` : `safari-web-extension:${filename}`
16540
+ ] : [
16541
+ func,
16542
+ filename
16543
+ ];
16544
+ };
16545
+
16546
+ // ../../node_modules/@posthog/core/dist/error-tracking/parsers/chrome.mjs
16547
+ var chromeRegexNoFnName = /^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i;
16548
+ var chromeRegex = /^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
16549
+ var chromeEvalRegex = /\((\S*)(?::(\d+))(?::(\d+))\)/;
16550
+ var chromeStackLineParser = (line, platform) => {
16551
+ const noFnParts = chromeRegexNoFnName.exec(line);
16552
+ if (noFnParts) {
16553
+ const [, filename, line2, col] = noFnParts;
16554
+ return createFrame(platform, filename, UNKNOWN_FUNCTION, +line2, +col);
16555
+ }
16556
+ const parts = chromeRegex.exec(line);
16557
+ if (parts) {
16558
+ const isEval = parts[2] && 0 === parts[2].indexOf("eval");
16559
+ if (isEval) {
16560
+ const subMatch = chromeEvalRegex.exec(parts[2]);
16561
+ if (subMatch) {
16562
+ parts[2] = subMatch[1];
16563
+ parts[3] = subMatch[2];
16564
+ parts[4] = subMatch[3];
16565
+ }
16566
+ }
16567
+ const [func, filename] = extractSafariExtensionDetails(parts[1] || UNKNOWN_FUNCTION, parts[2]);
16568
+ return createFrame(platform, filename, func, parts[3] ? +parts[3] : void 0, parts[4] ? +parts[4] : void 0);
16569
+ }
16570
+ };
16571
+
16572
+ // ../../node_modules/@posthog/core/dist/error-tracking/parsers/gecko.mjs
16573
+ var geckoREgex = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i;
16574
+ var geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
16575
+ var geckoStackLineParser = (line, platform) => {
16576
+ const parts = geckoREgex.exec(line);
16577
+ if (parts) {
16578
+ const isEval = parts[3] && parts[3].indexOf(" > eval") > -1;
16579
+ if (isEval) {
16580
+ const subMatch = geckoEvalRegex.exec(parts[3]);
16581
+ if (subMatch) {
16582
+ parts[1] = parts[1] || "eval";
16583
+ parts[3] = subMatch[1];
16584
+ parts[4] = subMatch[2];
16585
+ parts[5] = "";
16586
+ }
16587
+ }
16588
+ let filename = parts[3];
16589
+ let func = parts[1] || UNKNOWN_FUNCTION;
16590
+ [func, filename] = extractSafariExtensionDetails(func, filename);
16591
+ return createFrame(platform, filename, func, parts[4] ? +parts[4] : void 0, parts[5] ? +parts[5] : void 0);
16592
+ }
16593
+ };
16594
+
16595
+ // ../../node_modules/@posthog/core/dist/error-tracking/parsers/winjs.mjs
16596
+ var winjsRegex = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:[-a-z]+):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
16597
+ var winjsStackLineParser = (line, platform) => {
16598
+ const parts = winjsRegex.exec(line);
16599
+ return parts ? createFrame(platform, parts[2], parts[1] || UNKNOWN_FUNCTION, +parts[3], parts[4] ? +parts[4] : void 0) : void 0;
16600
+ };
16601
+
16602
+ // ../../node_modules/@posthog/core/dist/error-tracking/parsers/opera.mjs
16603
+ var opera10Regex = / line (\d+).*script (?:in )?(\S+)(?:: in function (\S+))?$/i;
16604
+ var opera10StackLineParser = (line, platform) => {
16605
+ const parts = opera10Regex.exec(line);
16606
+ return parts ? createFrame(platform, parts[2], parts[3] || UNKNOWN_FUNCTION, +parts[1]) : void 0;
16607
+ };
16608
+ var opera11Regex = / line (\d+), column (\d+)\s*(?:in (?:<anonymous function: ([^>]+)>|([^)]+))\(.*\))? in (.*):\s*$/i;
16609
+ var opera11StackLineParser = (line, platform) => {
16610
+ const parts = opera11Regex.exec(line);
16611
+ return parts ? createFrame(platform, parts[5], parts[3] || parts[4] || UNKNOWN_FUNCTION, +parts[1], +parts[2]) : void 0;
16612
+ };
16613
+
16614
+ // ../../node_modules/@posthog/core/dist/error-tracking/parsers/node.mjs
16615
+ var FILENAME_MATCH = /^\s*[-]{4,}$/;
16616
+ var FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
16617
+ var nodeStackLineParser = (line, platform) => {
16618
+ const lineMatch = line.match(FULL_MATCH);
16619
+ if (lineMatch) {
16620
+ let object3;
16621
+ let method;
16622
+ let functionName;
16623
+ let typeName;
16624
+ let methodName;
16625
+ if (lineMatch[1]) {
16626
+ functionName = lineMatch[1];
16627
+ let methodStart = functionName.lastIndexOf(".");
16628
+ if ("." === functionName[methodStart - 1]) methodStart--;
16629
+ if (methodStart > 0) {
16630
+ object3 = functionName.slice(0, methodStart);
16631
+ method = functionName.slice(methodStart + 1);
16632
+ const objectEnd = object3.indexOf(".Module");
16633
+ if (objectEnd > 0) {
16634
+ functionName = functionName.slice(objectEnd + 1);
16635
+ object3 = object3.slice(0, objectEnd);
16636
+ }
16637
+ }
16638
+ typeName = void 0;
16639
+ }
16640
+ if (method) {
16641
+ typeName = object3;
16642
+ methodName = method;
16643
+ }
16644
+ if ("<anonymous>" === method) {
16645
+ methodName = void 0;
16646
+ functionName = void 0;
16647
+ }
16648
+ if (void 0 === functionName) {
16649
+ methodName = methodName || UNKNOWN_FUNCTION;
16650
+ functionName = typeName ? `${typeName}.${methodName}` : methodName;
16651
+ }
16652
+ let filename = lineMatch[2]?.startsWith("file://") ? lineMatch[2].slice(7) : lineMatch[2];
16653
+ const isNative = "native" === lineMatch[5];
16654
+ if (filename?.match(/\/[A-Z]:/)) filename = filename.slice(1);
16655
+ if (!filename && lineMatch[5] && !isNative) filename = lineMatch[5];
16656
+ return {
16657
+ filename: filename ? decodeURI(filename) : void 0,
16658
+ module: void 0,
16659
+ function: functionName,
16660
+ lineno: _parseIntOrUndefined(lineMatch[3]),
16661
+ colno: _parseIntOrUndefined(lineMatch[4]),
16662
+ in_app: filenameIsInApp(filename || "", isNative),
16663
+ platform
16664
+ };
16665
+ }
16666
+ if (line.match(FILENAME_MATCH)) return {
16667
+ filename: line,
16668
+ platform
16669
+ };
16670
+ };
16671
+ function filenameIsInApp(filename, isNative = false) {
16672
+ const isInternal = isNative || filename && !filename.startsWith("/") && !filename.match(/^[A-Z]:/) && !filename.startsWith(".") && !filename.match(/^[a-zA-Z]([a-zA-Z0-9.\-+])*:\/\//);
16673
+ return !isInternal && void 0 !== filename && !filename.includes("node_modules/");
16674
+ }
16675
+ function _parseIntOrUndefined(input) {
16676
+ return parseInt(input || "", 10) || void 0;
16677
+ }
16678
+
16679
+ // ../../node_modules/@posthog/core/dist/error-tracking/parsers/index.mjs
16680
+ var WEBPACK_ERROR_REGEXP = /\(error: (.*)\)/;
16681
+ var STACKTRACE_FRAME_LIMIT = 50;
16682
+ function reverseAndStripFrames(stack) {
16683
+ if (!stack.length) return [];
16684
+ const localStack = Array.from(stack);
16685
+ localStack.reverse();
16686
+ return localStack.slice(0, STACKTRACE_FRAME_LIMIT).map((frame) => ({
16687
+ ...frame,
16688
+ filename: frame.filename || getLastStackFrame(localStack).filename,
16689
+ function: frame.function || UNKNOWN_FUNCTION
16690
+ }));
16691
+ }
16692
+ function getLastStackFrame(arr) {
16693
+ return arr[arr.length - 1] || {};
16694
+ }
16695
+ function createDefaultStackParser() {
16696
+ return createStackParser("web:javascript", chromeStackLineParser, geckoStackLineParser);
16697
+ }
16698
+ function createStackParser(platform, ...parsers) {
16699
+ return (stack, skipFirstLines = 0) => {
16700
+ const frames = [];
16701
+ const lines = stack.split("\n");
16702
+ for (let i = skipFirstLines; i < lines.length; i++) {
16703
+ const line = lines[i];
16704
+ if (line.length > 1024) continue;
16705
+ const cleanedLine = WEBPACK_ERROR_REGEXP.test(line) ? line.replace(WEBPACK_ERROR_REGEXP, "$1") : line;
16706
+ if (!cleanedLine.match(/\S*Error: /)) {
16707
+ for (const parser of parsers) {
16708
+ const frame = parser(cleanedLine, platform);
16709
+ if (frame) {
16710
+ frames.push(frame);
16711
+ break;
16712
+ }
16713
+ }
16714
+ if (frames.length >= STACKTRACE_FRAME_LIMIT) break;
16715
+ }
16716
+ }
16717
+ return reverseAndStripFrames(frames);
16718
+ };
16719
+ }
16720
+
16721
+ // ../../node_modules/@posthog/core/dist/error-tracking/coercers/dom-exception-coercer.mjs
16722
+ var DOMExceptionCoercer = class {
16723
+ match(err) {
16724
+ return this.isDOMException(err) || this.isDOMError(err);
16725
+ }
16726
+ coerce(err, ctx) {
16727
+ const hasStack = isString(err.stack);
16728
+ return {
16729
+ type: this.getType(err),
16730
+ value: this.getValue(err),
16731
+ stack: hasStack ? err.stack : void 0,
16732
+ cause: err.cause ? ctx.next(err.cause) : void 0,
16733
+ synthetic: false
16734
+ };
16735
+ }
16736
+ getType(candidate) {
16737
+ return this.isDOMError(candidate) ? "DOMError" : "DOMException";
16738
+ }
16739
+ getValue(err) {
16740
+ const name = err.name || (this.isDOMError(err) ? "DOMError" : "DOMException");
16741
+ const message = err.message ? `${name}: ${err.message}` : name;
16742
+ return message;
16743
+ }
16744
+ isDOMException(err) {
16745
+ return isBuiltin(err, "DOMException");
16746
+ }
16747
+ isDOMError(err) {
16748
+ return isBuiltin(err, "DOMError");
16749
+ }
16750
+ };
16751
+
16752
+ // ../../node_modules/@posthog/core/dist/error-tracking/coercers/error-coercer.mjs
16753
+ var ErrorCoercer = class {
16754
+ match(err) {
16755
+ return isPlainError(err);
16756
+ }
16757
+ coerce(err, ctx) {
16758
+ return {
16759
+ type: this.getType(err),
16760
+ value: this.getMessage(err, ctx),
16761
+ stack: this.getStack(err),
16762
+ cause: err.cause ? ctx.next(err.cause) : void 0,
16763
+ synthetic: false
16764
+ };
16765
+ }
16766
+ getType(err) {
16767
+ return err.name || err.constructor.name;
16768
+ }
16769
+ getMessage(err, _ctx) {
16770
+ const message = err.message;
16771
+ if (message.error && "string" == typeof message.error.message) return String(message.error.message);
16772
+ return String(message);
16773
+ }
16774
+ getStack(err) {
16775
+ return err.stacktrace || err.stack || void 0;
16776
+ }
16777
+ };
16778
+
16779
+ // ../../node_modules/@posthog/core/dist/error-tracking/coercers/error-event-coercer.mjs
16780
+ var ErrorEventCoercer = class {
16781
+ constructor() {
16782
+ }
16783
+ match(err) {
16784
+ return isErrorEvent(err) && void 0 != err.error;
16785
+ }
16786
+ coerce(err, ctx) {
16787
+ const exceptionLike = ctx.apply(err.error);
16788
+ if (!exceptionLike) return {
16789
+ type: "ErrorEvent",
16790
+ value: err.message,
16791
+ stack: ctx.syntheticException?.stack,
16792
+ synthetic: true
16793
+ };
16794
+ return exceptionLike;
16795
+ }
16796
+ };
16797
+
16798
+ // ../../node_modules/@posthog/core/dist/error-tracking/coercers/string-coercer.mjs
16799
+ var ERROR_TYPES_PATTERN = /^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;
16800
+ var StringCoercer = class {
16801
+ match(input) {
16802
+ return "string" == typeof input;
16803
+ }
16804
+ coerce(input, ctx) {
16805
+ const [type, value] = this.getInfos(input);
16806
+ return {
16807
+ type: type ?? "Error",
16808
+ value: value ?? input,
16809
+ stack: ctx.syntheticException?.stack,
16810
+ synthetic: true
16811
+ };
16812
+ }
16813
+ getInfos(candidate) {
16814
+ let type = "Error";
16815
+ let value = candidate;
16816
+ const groups = candidate.match(ERROR_TYPES_PATTERN);
16817
+ if (groups) {
16818
+ type = groups[1];
16819
+ value = groups[2];
16820
+ }
16821
+ return [
16822
+ type,
16823
+ value
16824
+ ];
16825
+ }
16826
+ };
16827
+
16828
+ // ../../node_modules/@posthog/core/dist/error-tracking/types.mjs
16829
+ var severityLevels = [
16830
+ "fatal",
16831
+ "error",
16832
+ "warning",
16833
+ "log",
16834
+ "info",
16835
+ "debug"
16836
+ ];
16837
+
16838
+ // ../../node_modules/@posthog/core/dist/error-tracking/coercers/utils.mjs
16839
+ function extractExceptionKeysForMessage(err, maxLength = 40) {
16840
+ const keys = Object.keys(err);
16841
+ keys.sort();
16842
+ if (!keys.length) return "[object has no keys]";
16843
+ for (let i = keys.length; i > 0; i--) {
16844
+ const serialized = keys.slice(0, i).join(", ");
16845
+ if (!(serialized.length > maxLength)) {
16846
+ if (i === keys.length) return serialized;
16847
+ return serialized.length <= maxLength ? serialized : `${serialized.slice(0, maxLength)}...`;
16848
+ }
16849
+ }
16850
+ return "";
16851
+ }
16852
+
16853
+ // ../../node_modules/@posthog/core/dist/error-tracking/coercers/object-coercer.mjs
16854
+ var ObjectCoercer = class {
16855
+ match(candidate) {
16856
+ return "object" == typeof candidate && null !== candidate;
16857
+ }
16858
+ coerce(candidate, ctx) {
16859
+ const errorProperty = this.getErrorPropertyFromObject(candidate);
16860
+ if (errorProperty) return ctx.apply(errorProperty);
16861
+ return {
16862
+ type: this.getType(candidate),
16863
+ value: this.getValue(candidate),
16864
+ stack: ctx.syntheticException?.stack,
16865
+ level: this.isSeverityLevel(candidate.level) ? candidate.level : "error",
16866
+ synthetic: true
16867
+ };
16868
+ }
16869
+ getType(err) {
16870
+ return isEvent(err) ? err.constructor.name : "Error";
16871
+ }
16872
+ getValue(err) {
16873
+ if ("name" in err && "string" == typeof err.name) {
16874
+ let message = `'${err.name}' captured as exception`;
16875
+ if ("message" in err && "string" == typeof err.message) message += ` with message: '${err.message}'`;
16876
+ return message;
16877
+ }
16878
+ if ("message" in err && "string" == typeof err.message) return err.message;
16879
+ const className = this.getObjectClassName(err);
16880
+ const keys = extractExceptionKeysForMessage(err);
16881
+ return `${className && "Object" !== className ? `'${className}'` : "Object"} captured as exception with keys: ${keys}`;
16882
+ }
16883
+ isSeverityLevel(x) {
16884
+ return isString(x) && !isEmptyString(x) && severityLevels.indexOf(x) >= 0;
16885
+ }
16886
+ getErrorPropertyFromObject(obj) {
16887
+ for (const prop in obj) if (Object.prototype.hasOwnProperty.call(obj, prop)) {
16888
+ const value = obj[prop];
16889
+ if (isError(value)) return value;
16890
+ }
16891
+ }
16892
+ getObjectClassName(obj) {
16893
+ try {
16894
+ const prototype = Object.getPrototypeOf(obj);
16895
+ return prototype ? prototype.constructor.name : void 0;
16896
+ } catch (e) {
16897
+ return;
16898
+ }
16899
+ }
16900
+ };
16901
+
16902
+ // ../../node_modules/@posthog/core/dist/error-tracking/coercers/event-coercer.mjs
16903
+ var EventCoercer = class {
16904
+ match(err) {
16905
+ return isEvent(err);
16906
+ }
16907
+ coerce(evt, ctx) {
16908
+ const constructorName = evt.constructor.name;
16909
+ return {
16910
+ type: constructorName,
16911
+ value: `${constructorName} captured as exception with keys: ${extractExceptionKeysForMessage(evt)}`,
16912
+ stack: ctx.syntheticException?.stack,
16913
+ synthetic: true
16914
+ };
16915
+ }
16916
+ };
16917
+
16918
+ // ../../node_modules/@posthog/core/dist/error-tracking/coercers/primitive-coercer.mjs
16919
+ var PrimitiveCoercer = class {
16920
+ match(candidate) {
16921
+ return isPrimitive(candidate);
16922
+ }
16923
+ coerce(value, ctx) {
16924
+ return {
16925
+ type: "Error",
16926
+ value: `Primitive value captured as exception: ${String(value)}`,
16927
+ stack: ctx.syntheticException?.stack,
16928
+ synthetic: true
16929
+ };
16930
+ }
16931
+ };
16932
+
16933
+ // ../../node_modules/@posthog/core/dist/error-tracking/coercers/promise-rejection-event.mjs
16934
+ var PromiseRejectionEventCoercer = class {
16935
+ match(err) {
16936
+ return isBuiltin(err, "PromiseRejectionEvent") || this.isCustomEventWrappingRejection(err);
16937
+ }
16938
+ isCustomEventWrappingRejection(err) {
16939
+ if (!isEvent(err)) return false;
16940
+ try {
16941
+ const detail = err.detail;
16942
+ return null != detail && "object" == typeof detail && "reason" in detail;
16943
+ } catch {
16944
+ return false;
16945
+ }
16946
+ }
16947
+ coerce(err, ctx) {
16948
+ const reason = this.getUnhandledRejectionReason(err);
16949
+ if (isPrimitive(reason)) return {
16950
+ type: "UnhandledRejection",
16951
+ value: `Non-Error promise rejection captured with value: ${String(reason)}`,
16952
+ stack: ctx.syntheticException?.stack,
16953
+ synthetic: true
16954
+ };
16955
+ return ctx.apply(reason);
16956
+ }
16957
+ getUnhandledRejectionReason(error2) {
16958
+ try {
16959
+ if ("reason" in error2) return error2.reason;
16960
+ if ("detail" in error2 && null != error2.detail && "object" == typeof error2.detail && "reason" in error2.detail) return error2.detail.reason;
16961
+ } catch {
16962
+ }
16963
+ return error2;
16964
+ }
16965
+ };
16966
+
16967
+ // ../../node_modules/@posthog/core/dist/error-tracking/utils.mjs
16968
+ var ReduceableCache = class {
16969
+ constructor(_maxSize2) {
16970
+ this._maxSize = _maxSize2;
16971
+ this._cache = /* @__PURE__ */ new Map();
16972
+ }
16973
+ get(key) {
16974
+ const value = this._cache.get(key);
16975
+ if (void 0 === value) return;
16976
+ this._cache.delete(key);
16977
+ this._cache.set(key, value);
16978
+ return value;
16979
+ }
16980
+ set(key, value) {
16981
+ this._cache.set(key, value);
16982
+ }
16983
+ reduce() {
16984
+ while (this._cache.size >= this._maxSize) {
16985
+ const value = this._cache.keys().next().value;
16986
+ if (value) this._cache.delete(value);
16987
+ }
16988
+ }
16989
+ };
16990
+
16991
+ // ../../node_modules/@posthog/core/dist/error-tracking/exception-steps.mjs
16992
+ var EXCEPTION_STEP_INTERNAL_FIELDS = {
16993
+ MESSAGE: "$message",
16994
+ TIMESTAMP: "$timestamp"
16995
+ };
16996
+ var RESERVED_EXCEPTION_STEP_KEYS = /* @__PURE__ */ new Set([
16997
+ EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE,
16998
+ EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP
16999
+ ]);
17000
+ var DEFAULT_EXCEPTION_STEPS_CONFIG = {
17001
+ enabled: true,
17002
+ max_bytes: 32768
17003
+ };
17004
+ function resolveExceptionStepsConfig(config2) {
17005
+ if (!config2) return {
17006
+ ...DEFAULT_EXCEPTION_STEPS_CONFIG
17007
+ };
17008
+ return {
17009
+ enabled: config2.enabled ?? DEFAULT_EXCEPTION_STEPS_CONFIG.enabled,
17010
+ max_bytes: normalizePositiveInteger(config2.max_bytes, DEFAULT_EXCEPTION_STEPS_CONFIG.max_bytes)
17011
+ };
17012
+ }
17013
+ function stripReservedExceptionStepFields(properties) {
17014
+ if (!properties) return {
17015
+ sanitizedProperties: {},
17016
+ droppedKeys: []
17017
+ };
17018
+ const droppedKeys = [];
17019
+ const sanitizedProperties = Object.keys(properties).reduce((acc, key) => {
17020
+ if (RESERVED_EXCEPTION_STEP_KEYS.has(key)) {
17021
+ droppedKeys.push(key);
17022
+ return acc;
17023
+ }
17024
+ acc[key] = properties[key];
17025
+ return acc;
17026
+ }, {});
17027
+ return {
17028
+ sanitizedProperties,
17029
+ droppedKeys
17030
+ };
17031
+ }
17032
+ var ExceptionStepsBuffer = class {
17033
+ constructor(config2) {
17034
+ this._entries = [];
17035
+ this._totalBytes = 0;
17036
+ this._config = resolveExceptionStepsConfig(config2);
17037
+ }
17038
+ setConfig(config2) {
17039
+ this._config = resolveExceptionStepsConfig(config2);
17040
+ this._trimToMaxBytes();
17041
+ }
17042
+ add(step) {
17043
+ const serialized = normalizeAndSerializeStep(step);
17044
+ if (!serialized) return;
17045
+ const bytes = getUtf8ByteLength(serialized.json);
17046
+ if (bytes > this._config.max_bytes) return;
17047
+ this._entries.push({
17048
+ step: serialized.step,
17049
+ bytes
17050
+ });
17051
+ this._totalBytes += bytes;
17052
+ this._trimToMaxBytes();
17053
+ }
17054
+ getAttachable() {
17055
+ return this._entries.map((e) => e.step);
17056
+ }
17057
+ clear() {
17058
+ this._entries = [];
17059
+ this._totalBytes = 0;
17060
+ }
17061
+ size() {
17062
+ return this._entries.length;
17063
+ }
17064
+ _trimToMaxBytes() {
17065
+ while (this._totalBytes > this._config.max_bytes && this._entries.length > 0) {
17066
+ const evicted = this._entries.shift();
17067
+ if (evicted) this._totalBytes -= evicted.bytes;
17068
+ }
17069
+ }
17070
+ };
17071
+ function normalizePositiveInteger(input, fallback) {
17072
+ if (!isNumber(input) || input === 1 / 0 || input === -1 / 0) return fallback;
17073
+ const normalized = Math.floor(input);
17074
+ if (normalized < 0) return fallback;
17075
+ return normalized;
17076
+ }
17077
+ function normalizeAndSerializeStep(step) {
17078
+ const json = safeStringify(step);
17079
+ if (!json) return;
17080
+ try {
17081
+ const parsed = JSON.parse(json);
17082
+ if (!isObject2(parsed)) return;
17083
+ const parsedStep = parsed;
17084
+ const message = parsedStep[EXCEPTION_STEP_INTERNAL_FIELDS.MESSAGE];
17085
+ const timestamp = parsedStep[EXCEPTION_STEP_INTERNAL_FIELDS.TIMESTAMP];
17086
+ if (!isString(message) || 0 === message.trim().length) return;
17087
+ if (!isString(timestamp) && !isNumber(timestamp)) return;
17088
+ return {
17089
+ step: parsedStep,
17090
+ json
17091
+ };
17092
+ } catch {
17093
+ return;
17094
+ }
17095
+ }
17096
+ function safeStringify(value) {
17097
+ const seen = /* @__PURE__ */ new WeakSet();
17098
+ try {
17099
+ return JSON.stringify(value, (_key, replacementValue) => {
17100
+ if ("bigint" == typeof replacementValue) return replacementValue.toString();
17101
+ if ("function" == typeof replacementValue || "symbol" == typeof replacementValue) return;
17102
+ if (replacementValue instanceof Date) return replacementValue.toISOString();
17103
+ if (replacementValue instanceof Error) return {
17104
+ name: replacementValue.name,
17105
+ message: replacementValue.message,
17106
+ stack: replacementValue.stack
17107
+ };
17108
+ if (replacementValue && "object" == typeof replacementValue) {
17109
+ if (seen.has(replacementValue)) return "[Circular]";
17110
+ seen.add(replacementValue);
17111
+ }
17112
+ return replacementValue;
17113
+ });
17114
+ } catch {
17115
+ return;
17116
+ }
17117
+ }
17118
+ function getUtf8ByteLength(value) {
17119
+ if ("undefined" != typeof TextEncoder) return new TextEncoder().encode(value).length;
17120
+ const encoded = encodeURIComponent(value);
17121
+ let byteLength = 0;
17122
+ for (let i = 0; i < encoded.length; i++) if ("%" === encoded[i]) {
17123
+ byteLength += 1;
17124
+ i += 2;
17125
+ } else byteLength += 1;
17126
+ return byteLength;
17127
+ }
17128
+
17129
+ // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
17130
+ import { createReadStream } from "node:fs";
17131
+ import { createInterface as createInterface2 } from "node:readline";
17132
+ var LRU_FILE_CONTENTS_CACHE = new error_tracking_exports.ReduceableCache(25);
17133
+ var LRU_FILE_CONTENTS_FS_READ_FAILED = new error_tracking_exports.ReduceableCache(20);
17134
+ var DEFAULT_LINES_OF_CONTEXT = 7;
17135
+ var MAX_CONTEXTLINES_COLNO = 1e3;
17136
+ var MAX_CONTEXTLINES_LINENO = 1e4;
17137
+ async function addSourceContext(frames) {
17138
+ const filesToLines = {};
17139
+ for (let i = frames.length - 1; i >= 0; i--) {
17140
+ const frame = frames[i];
17141
+ const filename = frame?.filename;
17142
+ if (!frame || "string" != typeof filename || "number" != typeof frame.lineno || shouldSkipContextLinesForFile(filename) || shouldSkipContextLinesForFrame(frame)) continue;
17143
+ const filesToLinesOutput = filesToLines[filename];
17144
+ if (!filesToLinesOutput) filesToLines[filename] = [];
17145
+ filesToLines[filename].push(frame.lineno);
17146
+ }
17147
+ const files = Object.keys(filesToLines);
17148
+ if (0 == files.length) return frames;
17149
+ const readlinePromises = [];
17150
+ for (const file of files) {
17151
+ if (LRU_FILE_CONTENTS_FS_READ_FAILED.get(file)) continue;
17152
+ const filesToLineRanges = filesToLines[file];
17153
+ if (!filesToLineRanges) continue;
17154
+ filesToLineRanges.sort((a, b) => a - b);
17155
+ const ranges = makeLineReaderRanges(filesToLineRanges);
17156
+ if (ranges.every((r) => rangeExistsInContentCache(file, r))) continue;
17157
+ const cache2 = emplace(LRU_FILE_CONTENTS_CACHE, file, {});
17158
+ readlinePromises.push(getContextLinesFromFile(file, ranges, cache2));
17159
+ }
17160
+ await Promise.all(readlinePromises).catch(() => {
17161
+ });
17162
+ if (frames && frames.length > 0) addSourceContextToFrames(frames, LRU_FILE_CONTENTS_CACHE);
17163
+ LRU_FILE_CONTENTS_CACHE.reduce();
17164
+ return frames;
17165
+ }
17166
+ function getContextLinesFromFile(path9, ranges, output) {
17167
+ return new Promise((resolve3) => {
17168
+ const stream = createReadStream(path9);
17169
+ const lineReaded = createInterface2({
17170
+ input: stream
17171
+ });
17172
+ function destroyStreamAndResolve() {
17173
+ stream.destroy();
17174
+ resolve3();
17175
+ }
17176
+ let lineNumber = 0;
17177
+ let currentRangeIndex = 0;
17178
+ const range = ranges[currentRangeIndex];
17179
+ if (void 0 === range) return void destroyStreamAndResolve();
17180
+ let rangeStart = range[0];
17181
+ let rangeEnd = range[1];
17182
+ function onStreamError() {
17183
+ LRU_FILE_CONTENTS_FS_READ_FAILED.set(path9, 1);
17184
+ lineReaded.close();
17185
+ lineReaded.removeAllListeners();
17186
+ destroyStreamAndResolve();
17187
+ }
17188
+ stream.on("error", onStreamError);
17189
+ lineReaded.on("error", onStreamError);
17190
+ lineReaded.on("close", destroyStreamAndResolve);
17191
+ lineReaded.on("line", (line) => {
17192
+ lineNumber++;
17193
+ if (lineNumber < rangeStart) return;
17194
+ output[lineNumber] = snipLine(line, 0);
17195
+ if (lineNumber >= rangeEnd) {
17196
+ if (currentRangeIndex === ranges.length - 1) {
17197
+ lineReaded.close();
17198
+ lineReaded.removeAllListeners();
17199
+ return;
17200
+ }
17201
+ currentRangeIndex++;
17202
+ const range2 = ranges[currentRangeIndex];
17203
+ if (void 0 === range2) {
17204
+ lineReaded.close();
17205
+ lineReaded.removeAllListeners();
17206
+ return;
17207
+ }
17208
+ rangeStart = range2[0];
17209
+ rangeEnd = range2[1];
17210
+ }
17211
+ });
17212
+ });
17213
+ }
17214
+ function addSourceContextToFrames(frames, cache2) {
17215
+ for (const frame of frames) if (frame.filename && void 0 === frame.context_line && "number" == typeof frame.lineno) {
17216
+ const contents = cache2.get(frame.filename);
17217
+ if (void 0 === contents) continue;
17218
+ addContextToFrame(frame.lineno, frame, contents);
17219
+ }
17220
+ }
17221
+ function addContextToFrame(lineno, frame, contents) {
17222
+ if (void 0 === frame.lineno || void 0 === contents) return;
17223
+ frame.pre_context = [];
17224
+ for (let i = makeRangeStart(lineno); i < lineno; i++) {
17225
+ const line = contents[i];
17226
+ if (void 0 === line) return void clearLineContext(frame);
17227
+ frame.pre_context.push(line);
17228
+ }
17229
+ if (void 0 === contents[lineno]) return void clearLineContext(frame);
17230
+ frame.context_line = contents[lineno];
17231
+ const end = makeRangeEnd(lineno);
17232
+ frame.post_context = [];
17233
+ for (let i = lineno + 1; i <= end; i++) {
17234
+ const line = contents[i];
17235
+ if (void 0 === line) break;
17236
+ frame.post_context.push(line);
17237
+ }
17238
+ }
17239
+ function clearLineContext(frame) {
17240
+ delete frame.pre_context;
17241
+ delete frame.context_line;
17242
+ delete frame.post_context;
17243
+ }
17244
+ function shouldSkipContextLinesForFile(path9) {
17245
+ return path9.startsWith("node:") || path9.endsWith(".min.js") || path9.endsWith(".min.cjs") || path9.endsWith(".min.mjs") || path9.startsWith("data:");
17246
+ }
17247
+ function shouldSkipContextLinesForFrame(frame) {
17248
+ if (void 0 !== frame.lineno && frame.lineno > MAX_CONTEXTLINES_LINENO) return true;
17249
+ if (void 0 !== frame.colno && frame.colno > MAX_CONTEXTLINES_COLNO) return true;
17250
+ return false;
17251
+ }
17252
+ function rangeExistsInContentCache(file, range) {
17253
+ const contents = LRU_FILE_CONTENTS_CACHE.get(file);
17254
+ if (void 0 === contents) return false;
17255
+ for (let i = range[0]; i <= range[1]; i++) if (void 0 === contents[i]) return false;
17256
+ return true;
17257
+ }
17258
+ function makeLineReaderRanges(lines) {
17259
+ if (!lines.length) return [];
17260
+ let i = 0;
17261
+ const line = lines[0];
17262
+ if ("number" != typeof line) return [];
17263
+ let current = makeContextRange(line);
17264
+ const out = [];
17265
+ while (true) {
17266
+ if (i === lines.length - 1) {
17267
+ out.push(current);
17268
+ break;
17269
+ }
17270
+ const next = lines[i + 1];
17271
+ if ("number" != typeof next) break;
17272
+ if (next <= current[1]) current[1] = next + DEFAULT_LINES_OF_CONTEXT;
17273
+ else {
17274
+ out.push(current);
17275
+ current = makeContextRange(next);
17276
+ }
17277
+ i++;
17278
+ }
17279
+ return out;
17280
+ }
17281
+ function makeContextRange(line) {
17282
+ return [
17283
+ makeRangeStart(line),
17284
+ makeRangeEnd(line)
17285
+ ];
17286
+ }
17287
+ function makeRangeStart(line) {
17288
+ return Math.max(1, line - DEFAULT_LINES_OF_CONTEXT);
17289
+ }
17290
+ function makeRangeEnd(line) {
17291
+ return line + DEFAULT_LINES_OF_CONTEXT;
17292
+ }
17293
+ function emplace(map, key, contents) {
17294
+ const value = map.get(key);
17295
+ if (void 0 === value) {
17296
+ map.set(key, contents);
17297
+ return contents;
17298
+ }
17299
+ return value;
17300
+ }
17301
+ function snipLine(line, colno) {
17302
+ let newLine = line;
17303
+ const lineLength = newLine.length;
17304
+ if (lineLength <= 150) return newLine;
17305
+ if (colno > lineLength) colno = lineLength;
17306
+ let start = Math.max(colno - 60, 0);
17307
+ if (start < 5) start = 0;
17308
+ let end = Math.min(start + 140, lineLength);
17309
+ if (end > lineLength - 5) end = lineLength;
17310
+ if (end === lineLength) start = Math.max(end - 140, 0);
17311
+ newLine = newLine.slice(start, end);
17312
+ if (start > 0) newLine = `...${newLine}`;
17313
+ if (end < lineLength) newLine += "...";
17314
+ return newLine;
17315
+ }
17316
+
17317
+ // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/relative-path.node.mjs
17318
+ import { isAbsolute as isAbsolute2, relative, sep as sep2 } from "path";
17319
+ function createRelativePathModifier(basePath = process.cwd()) {
17320
+ const isWindows = "\\" === sep2;
17321
+ const toUnix = (p) => isWindows ? p.replace(/\\/g, "/") : p;
17322
+ const normalizedBase = toUnix(basePath);
17323
+ return async (frames) => {
17324
+ for (const frame of frames) if (!(!frame.filename || frame.filename.startsWith("node:") || frame.filename.startsWith("data:"))) {
17325
+ if (isAbsolute2(frame.filename)) frame.filename = toUnix(relative(normalizedBase, toUnix(frame.filename)));
17326
+ }
17327
+ return frames;
17328
+ };
17329
+ }
17330
+
17331
+ // ../../node_modules/posthog-node/dist/extensions/error-tracking/autocapture.mjs
17332
+ function makeUncaughtExceptionHandler(captureFn, onFatalFn) {
17333
+ let calledFatalError = false;
17334
+ return Object.assign((error2) => {
17335
+ const userProvidedListenersCount = global.process.listeners("uncaughtException").filter((listener) => "domainUncaughtExceptionClear" !== listener.name && true !== listener._posthogErrorHandler).length;
17336
+ const processWouldExit = 0 === userProvidedListenersCount;
17337
+ captureFn(error2, {
17338
+ mechanism: {
17339
+ type: "onuncaughtexception",
17340
+ handled: false
17341
+ }
17342
+ });
17343
+ if (!calledFatalError && processWouldExit) {
17344
+ calledFatalError = true;
17345
+ onFatalFn(error2);
17346
+ }
17347
+ }, {
17348
+ _posthogErrorHandler: true
17349
+ });
17350
+ }
17351
+ function addUncaughtExceptionListener(captureFn, onFatalFn) {
17352
+ globalThis.process?.on("uncaughtException", makeUncaughtExceptionHandler(captureFn, onFatalFn));
17353
+ }
17354
+ function addUnhandledRejectionListener(captureFn) {
17355
+ globalThis.process?.on("unhandledRejection", (reason) => captureFn(reason, {
17356
+ mechanism: {
17357
+ type: "onunhandledrejection",
17358
+ handled: false
17359
+ }
17360
+ }));
17361
+ }
17362
+
17363
+ // ../../node_modules/posthog-node/dist/extensions/error-tracking/index.mjs
17364
+ var SHUTDOWN_TIMEOUT = 2e3;
17365
+ var ErrorTracking = class _ErrorTracking {
17366
+ constructor(client, options, _logger) {
17367
+ this.client = client;
17368
+ this._exceptionAutocaptureEnabled = options.enableExceptionAutocapture || false;
17369
+ this._logger = _logger;
17370
+ this._rateLimiter = new BucketedRateLimiter({
17371
+ refillRate: 1,
17372
+ bucketSize: 10,
17373
+ refillInterval: 1e4,
17374
+ _logger: this._logger
17375
+ });
17376
+ this.startAutocaptureIfEnabled();
17377
+ }
17378
+ static isPreviouslyCapturedError(x) {
17379
+ return isObject2(x) && "__posthog_previously_captured_error" in x && true === x.__posthog_previously_captured_error;
17380
+ }
17381
+ static async buildEventMessage(error2, hint, distinctId, additionalProperties) {
17382
+ const properties = {
17383
+ ...additionalProperties
17384
+ };
17385
+ const exceptionProperties = this.errorPropertiesBuilder.buildFromUnknown(error2, hint);
17386
+ exceptionProperties.$exception_list = await this.errorPropertiesBuilder.modifyFrames(exceptionProperties.$exception_list);
17387
+ return {
17388
+ event: "$exception",
17389
+ distinctId,
17390
+ properties: {
17391
+ ...exceptionProperties,
17392
+ ...properties
17393
+ },
17394
+ _originatedFromCaptureException: true
17395
+ };
17396
+ }
17397
+ startAutocaptureIfEnabled() {
17398
+ if (this.isEnabled()) {
17399
+ addUncaughtExceptionListener(this.onException.bind(this), this.onFatalError.bind(this));
17400
+ addUnhandledRejectionListener(this.onException.bind(this));
17401
+ }
17402
+ }
17403
+ onException(exception, hint) {
17404
+ this.client.addPendingPromise((async () => {
17405
+ if (!_ErrorTracking.isPreviouslyCapturedError(exception)) {
17406
+ const eventMessage = await _ErrorTracking.buildEventMessage(exception, hint);
17407
+ const exceptionProperties = eventMessage.properties;
17408
+ const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? "Exception";
17409
+ const isRateLimited = this._rateLimiter.consumeRateLimit(exceptionType);
17410
+ if (isRateLimited) return void this._logger.info("Skipping exception capture because of client rate limiting.", {
17411
+ exception: exceptionType
17412
+ });
17413
+ return this.client.capture(eventMessage);
17414
+ }
17415
+ })());
17416
+ }
17417
+ async onFatalError(exception) {
17418
+ console.error(exception);
17419
+ await this.client.shutdown(SHUTDOWN_TIMEOUT);
17420
+ process.exit(1);
17421
+ }
17422
+ isEnabled() {
17423
+ return !this.client.isDisabled && this._exceptionAutocaptureEnabled;
17424
+ }
17425
+ shutdown() {
17426
+ this._rateLimiter.stop();
17427
+ }
17428
+ };
17429
+
17430
+ // ../../node_modules/posthog-node/dist/extensions/context/context.mjs
17431
+ import { AsyncLocalStorage } from "node:async_hooks";
17432
+
17433
+ // ../../node_modules/posthog-node/dist/extensions/sentry-integration.mjs
17434
+ var NAME = "posthog-node";
17435
+ function createEventProcessor(_posthog, { organization, projectId, prefix, severityAllowList = [
17436
+ "error"
17437
+ ], sendExceptionsToPostHog = true } = {}) {
17438
+ return (event) => {
17439
+ const shouldProcessLevel = "*" === severityAllowList || severityAllowList.includes(event.level);
17440
+ if (!shouldProcessLevel) return event;
17441
+ if (!event.tags) event.tags = {};
17442
+ const userId = event.tags[PostHogSentryIntegration.POSTHOG_ID_TAG];
17443
+ if (void 0 === userId) return event;
17444
+ const uiHost = _posthog.options.host ?? "https://us.i.posthog.com";
17445
+ const personUrl = new URL(`/project/${_posthog.apiKey}/person/${userId}`, uiHost).toString();
17446
+ event.tags["PostHog Person URL"] = personUrl;
17447
+ const exceptions = event.exception?.values || [];
17448
+ const exceptionList = exceptions.map((exception) => ({
17449
+ ...exception,
17450
+ stacktrace: exception.stacktrace ? {
17451
+ ...exception.stacktrace,
17452
+ type: "raw",
17453
+ frames: (exception.stacktrace.frames || []).map((frame) => ({
17454
+ ...frame,
17455
+ platform: "node:javascript"
17456
+ }))
17457
+ } : void 0
17458
+ }));
17459
+ const properties = {
17460
+ $exception_message: exceptions[0]?.value || event.message,
17461
+ $exception_type: exceptions[0]?.type,
17462
+ $exception_level: event.level,
17463
+ $exception_list: exceptionList,
17464
+ $sentry_event_id: event.event_id,
17465
+ $sentry_exception: event.exception,
17466
+ $sentry_exception_message: exceptions[0]?.value || event.message,
17467
+ $sentry_exception_type: exceptions[0]?.type,
17468
+ $sentry_tags: event.tags
17469
+ };
17470
+ if (organization && projectId) properties["$sentry_url"] = (prefix || "https://sentry.io/organizations/") + organization + "/issues/?project=" + projectId + "&query=" + event.event_id;
17471
+ if (sendExceptionsToPostHog) _posthog.capture({
17472
+ event: "$exception",
17473
+ distinctId: userId,
17474
+ properties
17475
+ });
17476
+ return event;
17477
+ };
17478
+ }
17479
+ var PostHogSentryIntegration = class {
17480
+ static #_ = this.POSTHOG_ID_TAG = "posthog_distinct_id";
17481
+ constructor(_posthog, organization, prefix, severityAllowList, sendExceptionsToPostHog) {
17482
+ this.name = NAME;
17483
+ this.name = NAME;
17484
+ this.setupOnce = function(addGlobalEventProcessor, getCurrentHub) {
17485
+ const projectId = getCurrentHub()?.getClient()?.getDsn()?.projectId;
17486
+ addGlobalEventProcessor(createEventProcessor(_posthog, {
17487
+ organization,
17488
+ projectId,
17489
+ prefix,
17490
+ severityAllowList,
17491
+ sendExceptionsToPostHog: sendExceptionsToPostHog ?? true
17492
+ }));
17493
+ };
17494
+ }
17495
+ };
17496
+
17497
+ // ../../node_modules/posthog-node/dist/entrypoints/index.node.mjs
17498
+ ErrorTracking.errorPropertiesBuilder = new error_tracking_exports.ErrorPropertiesBuilder([
17499
+ new error_tracking_exports.EventCoercer(),
17500
+ new error_tracking_exports.ErrorCoercer(),
17501
+ new error_tracking_exports.ObjectCoercer(),
17502
+ new error_tracking_exports.StringCoercer(),
17503
+ new error_tracking_exports.PrimitiveCoercer()
17504
+ ], error_tracking_exports.createStackParser("node:javascript", error_tracking_exports.nodeStackLineParser), [
17505
+ createModulerModifier(),
17506
+ addSourceContext,
17507
+ createRelativePathModifier()
17508
+ ]);
17509
+
17510
+ // ../registry/src/artifacts.ts
17511
+ import { stat as stat3 } from "node:fs/promises";
17512
+ import { randomUUID } from "node:crypto";
17513
+ import { basename as basename2, extname } from "node:path";
17514
+
17515
+ // ../registry/src/failure-codes.ts
17516
+ var FAILURE_CODES = {
17517
+ ARGENT_UNCLASSIFIED_FAILURE: "ARGENT_UNCLASSIFIED_FAILURE",
17518
+ REGISTRY_SERVICE_NOT_FOUND: "REGISTRY_SERVICE_NOT_FOUND",
17519
+ REGISTRY_SERVICE_INITIALIZATION_FAILED: "REGISTRY_SERVICE_INITIALIZATION_FAILED",
17520
+ REGISTRY_TOOL_NOT_FOUND: "REGISTRY_TOOL_NOT_FOUND",
17521
+ REGISTRY_TOOL_EXECUTION_FAILED: "REGISTRY_TOOL_EXECUTION_FAILED",
17522
+ REGISTRY_TOOL_FAILURE_UNCLASSIFIED: "REGISTRY_TOOL_FAILURE_UNCLASSIFIED",
17523
+ HTTP_TOOL_NOT_FOUND: "HTTP_TOOL_NOT_FOUND",
17524
+ HTTP_ZOD_VALIDATION_FAILED: "HTTP_ZOD_VALIDATION_FAILED",
17525
+ HTTP_CAPABILITY_UNSUPPORTED_OPERATION: "HTTP_CAPABILITY_UNSUPPORTED_OPERATION",
17526
+ HTTP_DEVICE_RESOLUTION_FAILED: "HTTP_DEVICE_RESOLUTION_FAILED",
17527
+ HTTP_DEPENDENCY_PREFLIGHT_MISSING: "HTTP_DEPENDENCY_PREFLIGHT_MISSING",
17528
+ CLI_RUN_TOOL_NOT_FOUND: "CLI_RUN_TOOL_NOT_FOUND",
17529
+ CLI_RUN_FLAG_PARSE_FAILED: "CLI_RUN_FLAG_PARSE_FAILED",
17530
+ CLI_RUN_ARGS_NOT_OBJECT: "CLI_RUN_ARGS_NOT_OBJECT",
17531
+ CLI_RUN_ARGS_JSON_INVALID: "CLI_RUN_ARGS_JSON_INVALID",
17532
+ CLI_RUN_TOOL_CALL_FAILED: "CLI_RUN_TOOL_CALL_FAILED",
17533
+ CLI_RUN_SAVE_IMAGE_FAILED: "CLI_RUN_SAVE_IMAGE_FAILED",
17534
+ TOOL_CAPABILITY_UNSUPPORTED_OPERATION: "TOOL_CAPABILITY_UNSUPPORTED_OPERATION",
17535
+ TOOL_PLATFORM_NOT_IMPLEMENTED: "TOOL_PLATFORM_NOT_IMPLEMENTED",
17536
+ TOOL_DEPENDENCY_MISSING: "TOOL_DEPENDENCY_MISSING",
17537
+ TOOLSERVER_UNHANDLED_REJECTION: "TOOLSERVER_UNHANDLED_REJECTION",
17538
+ TOOLSERVER_UNCAUGHT_EXCEPTION: "TOOLSERVER_UNCAUGHT_EXCEPTION",
17539
+ INSTALL_GLOBAL_PACKAGE_FAILED: "INSTALL_GLOBAL_PACKAGE_FAILED",
17540
+ INSTALL_FROM_TAR_PACKAGE_FAILED: "INSTALL_FROM_TAR_PACKAGE_FAILED",
17541
+ INSTALL_INIT_TRIGGERED_UPDATE_FAILED: "INSTALL_INIT_TRIGGERED_UPDATE_FAILED",
17542
+ INSTALL_SKILLS_REFRESH_FAILED: "INSTALL_SKILLS_REFRESH_FAILED",
17543
+ INSTALL_UNCLASSIFIED_FAILED: "INSTALL_UNCLASSIFIED_FAILED",
17544
+ UPDATE_INSTALLED_VERSION_DETECT_FAILED: "UPDATE_INSTALLED_VERSION_DETECT_FAILED",
17545
+ UPDATE_INVALID_TARGET_VERSION: "UPDATE_INVALID_TARGET_VERSION",
17546
+ UPDATE_REGISTRY_CHECK_FAILED: "UPDATE_REGISTRY_CHECK_FAILED",
17547
+ UPDATE_TOOLSERVER_STOP_FAILED: "UPDATE_TOOLSERVER_STOP_FAILED",
17548
+ UPDATE_PACKAGE_ACTION_FAILED: "UPDATE_PACKAGE_ACTION_FAILED",
17549
+ UPDATE_UNCLASSIFIED_FAILED: "UPDATE_UNCLASSIFIED_FAILED",
17550
+ UNINSTALL_TOOLSERVER_STOP_FAILED: "UNINSTALL_TOOLSERVER_STOP_FAILED",
17551
+ UNINSTALL_PACKAGE_ACTION_FAILED: "UNINSTALL_PACKAGE_ACTION_FAILED",
17552
+ UNINSTALL_UNCLASSIFIED_FAILED: "UNINSTALL_UNCLASSIFIED_FAILED",
17553
+ ANDROID_ADB_NOT_FOUND: "ANDROID_ADB_NOT_FOUND",
17554
+ ANDROID_EMULATOR_NOT_FOUND: "ANDROID_EMULATOR_NOT_FOUND",
17555
+ ANDROID_ADB_COMMAND_FAILED: "ANDROID_ADB_COMMAND_FAILED",
17556
+ ANDROID_ADB_BOOT_TERMINAL_STATE: "ANDROID_ADB_BOOT_TERMINAL_STATE",
17557
+ ANDROID_ADB_BOOT_TIMEOUT: "ANDROID_ADB_BOOT_TIMEOUT",
17558
+ SIMULATOR_NETWORK_TIMEOUT: "SIMULATOR_NETWORK_TIMEOUT",
17559
+ SIMULATOR_NETWORK_CONNECTION_REFUSED: "SIMULATOR_NETWORK_CONNECTION_REFUSED",
17560
+ SIMULATOR_NETWORK_CONNECTION_RESET: "SIMULATOR_NETWORK_CONNECTION_RESET",
17561
+ SIMULATOR_NETWORK_ERROR: "SIMULATOR_NETWORK_ERROR",
17562
+ SIMULATOR_NON_JSON_RESPONSE: "SIMULATOR_NON_JSON_RESPONSE",
17563
+ SIMULATOR_HTTP_ERROR_RESPONSE: "SIMULATOR_HTTP_ERROR_RESPONSE",
17564
+ SIMULATOR_MISSING_RESPONSE_FIELDS: "SIMULATOR_MISSING_RESPONSE_FIELDS",
17565
+ SIMULATOR_SERVER_FACTORY_OPTIONS_MISSING: "SIMULATOR_SERVER_FACTORY_OPTIONS_MISSING",
17566
+ SIMULATOR_SERVER_DEVICE_ID_INVALID: "SIMULATOR_SERVER_DEVICE_ID_INVALID",
17567
+ SIMULATOR_SERVER_READY_EXITED: "SIMULATOR_SERVER_READY_EXITED",
17568
+ SIMULATOR_SERVER_READY_TIMEOUT: "SIMULATOR_SERVER_READY_TIMEOUT",
17569
+ SIMULATOR_SERVER_PROCESS_ERROR: "SIMULATOR_SERVER_PROCESS_ERROR",
17570
+ SIMULATOR_SERVER_TERMINATED: "SIMULATOR_SERVER_TERMINATED",
17571
+ AX_QUERY_TIMEOUT: "AX_QUERY_TIMEOUT",
17572
+ AX_DAEMON_READY_TIMEOUT: "AX_DAEMON_READY_TIMEOUT",
17573
+ AX_DAEMON_EXITED_BEFORE_READY: "AX_DAEMON_EXITED_BEFORE_READY",
17574
+ AX_DAEMON_PROCESS_ERROR: "AX_DAEMON_PROCESS_ERROR",
17575
+ AX_FACTORY_OPTIONS_MISSING: "AX_FACTORY_OPTIONS_MISSING",
17576
+ AX_WRONG_PLATFORM: "AX_WRONG_PLATFORM",
17577
+ AX_DEVICE_ID_INVALID: "AX_DEVICE_ID_INVALID",
17578
+ AX_DESCRIBE_ERROR: "AX_DESCRIBE_ERROR",
17579
+ AX_QUERY_FAILED: "AX_QUERY_FAILED",
17580
+ ANDROID_LAUNCH_ACTIVITY_RESOLVE_FAILED: "ANDROID_LAUNCH_ACTIVITY_RESOLVE_FAILED",
17581
+ ANDROID_LAUNCH_AM_START_FAILED: "ANDROID_LAUNCH_AM_START_FAILED",
17582
+ ANDROID_OPEN_URL_FAILED: "ANDROID_OPEN_URL_FAILED",
17583
+ ANDROID_REINSTALL_INSTALL_FAILED: "ANDROID_REINSTALL_INSTALL_FAILED",
17584
+ ANDROID_RESTART_FAILED: "ANDROID_RESTART_FAILED",
17585
+ IOS_LAUNCH_SIMCTL_FAILED: "IOS_LAUNCH_SIMCTL_FAILED",
17586
+ IOS_OPEN_URL_FAILED: "IOS_OPEN_URL_FAILED",
17587
+ IOS_REINSTALL_INSTALL_FAILED: "IOS_REINSTALL_INSTALL_FAILED",
17588
+ IOS_RESTART_LAUNCH_FAILED: "IOS_RESTART_LAUNCH_FAILED",
17589
+ NATIVE_DEVTOOLS_DESCRIBE_ERROR: "NATIVE_DEVTOOLS_DESCRIBE_ERROR",
17590
+ NATIVE_DEVTOOLS_VIEW_AT_POINT_ERROR: "NATIVE_DEVTOOLS_VIEW_AT_POINT_ERROR",
17591
+ NATIVE_DEVTOOLS_USER_INTERACTABLE_VIEW_AT_POINT_ERROR: "NATIVE_DEVTOOLS_USER_INTERACTABLE_VIEW_AT_POINT_ERROR",
17592
+ NATIVE_DEVTOOLS_FIND_VIEWS_ERROR: "NATIVE_DEVTOOLS_FIND_VIEWS_ERROR",
17593
+ NATIVE_DEVTOOLS_FACTORY_OPTIONS_MISSING: "NATIVE_DEVTOOLS_FACTORY_OPTIONS_MISSING",
17594
+ NATIVE_DEVTOOLS_WRONG_PLATFORM: "NATIVE_DEVTOOLS_WRONG_PLATFORM",
17595
+ NATIVE_DEVTOOLS_NOT_CONNECTED: "NATIVE_DEVTOOLS_NOT_CONNECTED",
17596
+ NATIVE_DEVTOOLS_RPC_TIMEOUT: "NATIVE_DEVTOOLS_RPC_TIMEOUT",
17597
+ NATIVE_DEVTOOLS_RPC_ERROR: "NATIVE_DEVTOOLS_RPC_ERROR",
17598
+ NATIVE_DEVTOOLS_SERVICE_DISPOSED: "NATIVE_DEVTOOLS_SERVICE_DISPOSED",
17599
+ NATIVE_TARGET_NO_CONNECTED_APPS: "NATIVE_TARGET_NO_CONNECTED_APPS",
17600
+ NATIVE_TARGET_SINGLE_APP_NOT_FOREGROUND: "NATIVE_TARGET_SINGLE_APP_NOT_FOREGROUND",
17601
+ NATIVE_TARGET_MULTIPLE_APPS_AMBIGUOUS: "NATIVE_TARGET_MULTIPLE_APPS_AMBIGUOUS",
17602
+ ANDROID_DEVTOOLS_ADB_NOT_FOUND: "ANDROID_DEVTOOLS_ADB_NOT_FOUND",
17603
+ ANDROID_DEVTOOLS_ADB_FORWARD_UNEXPECTED: "ANDROID_DEVTOOLS_ADB_FORWARD_UNEXPECTED",
17604
+ ANDROID_DEVTOOLS_HELPER_EXITED_BEFORE_READY: "ANDROID_DEVTOOLS_HELPER_EXITED_BEFORE_READY",
17605
+ ANDROID_DEVTOOLS_HELPER_PROCESS_ERROR: "ANDROID_DEVTOOLS_HELPER_PROCESS_ERROR",
17606
+ ANDROID_DEVTOOLS_HELPER_READY_TIMEOUT: "ANDROID_DEVTOOLS_HELPER_READY_TIMEOUT",
17607
+ ANDROID_DEVTOOLS_FACTORY_OPTIONS_MISSING: "ANDROID_DEVTOOLS_FACTORY_OPTIONS_MISSING",
17608
+ ANDROID_DEVTOOLS_WRONG_PLATFORM: "ANDROID_DEVTOOLS_WRONG_PLATFORM",
17609
+ ANDROID_DEVTOOLS_DEVICE_ID_INVALID: "ANDROID_DEVTOOLS_DEVICE_ID_INVALID",
17610
+ ANDROID_DEVTOOLS_HELPER_TERMINATED: "ANDROID_DEVTOOLS_HELPER_TERMINATED",
17611
+ ANDROID_DEVTOOLS_RPC_CLIENT_CLOSED: "ANDROID_DEVTOOLS_RPC_CLIENT_CLOSED",
17612
+ ANDROID_DEVTOOLS_RPC_ERROR: "ANDROID_DEVTOOLS_RPC_ERROR",
17613
+ ANDROID_DEVTOOLS_RPC_TIMEOUT: "ANDROID_DEVTOOLS_RPC_TIMEOUT",
17614
+ ANDROID_DEVTOOLS_SOCKET_CLOSED: "ANDROID_DEVTOOLS_SOCKET_CLOSED",
17615
+ ANDROID_SCREEN_SIZE_PARSE_FAILED: "ANDROID_SCREEN_SIZE_PARSE_FAILED",
17616
+ ANDROID_SCREEN_SIZE_NON_POSITIVE: "ANDROID_SCREEN_SIZE_NON_POSITIVE",
17617
+ ANDROID_UIAUTOMATOR_PARSE_FAILED: "ANDROID_UIAUTOMATOR_PARSE_FAILED",
17618
+ DEBUGGER_METRO_NOT_RUNNING: "DEBUGGER_METRO_NOT_RUNNING",
17619
+ DEBUGGER_METRO_PROJECT_ROOT_MISSING: "DEBUGGER_METRO_PROJECT_ROOT_MISSING",
17620
+ DEBUGGER_METRO_NO_TARGETS: "DEBUGGER_METRO_NO_TARGETS",
17621
+ DEBUGGER_CDP_RUNTIME_EXCEPTION: "DEBUGGER_CDP_RUNTIME_EXCEPTION",
17622
+ DEBUGGER_CDP_BINDING_TIMEOUT: "DEBUGGER_CDP_BINDING_TIMEOUT",
17623
+ DEBUGGER_CDP_PROTOCOL_ERROR: "DEBUGGER_CDP_PROTOCOL_ERROR",
17624
+ DEBUGGER_RELOAD_FAILED: "DEBUGGER_RELOAD_FAILED",
17625
+ JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED: "JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED",
17626
+ JS_RUNTIME_PAYLOAD_INVALID: "JS_RUNTIME_PAYLOAD_INVALID",
17627
+ JS_RUNTIME_PAYLOAD_DEVICE_MISSING: "JS_RUNTIME_PAYLOAD_DEVICE_MISSING",
17628
+ JS_RUNTIME_PAYLOAD_PORT_INVALID: "JS_RUNTIME_PAYLOAD_PORT_INVALID",
17629
+ JS_RUNTIME_CDP_DISCONNECTED: "JS_RUNTIME_CDP_DISCONNECTED",
17630
+ NETWORK_INSPECTOR_CDP_DISCONNECTED: "NETWORK_INSPECTOR_CDP_DISCONNECTED",
17631
+ REACT_PROFILER_NO_ACTIVE_SESSION: "REACT_PROFILER_NO_ACTIVE_SESSION",
17632
+ REACT_PROFILER_CDP_CONNECTION_LOST: "REACT_PROFILER_CDP_CONNECTION_LOST",
17633
+ REACT_PROFILER_NO_CPU_PROFILE: "REACT_PROFILER_NO_CPU_PROFILE",
17634
+ REACT_PROFILER_RUNTIME_EXCEPTION: "REACT_PROFILER_RUNTIME_EXCEPTION",
17635
+ REACT_PROFILER_NO_RUNTIME_DATA: "REACT_PROFILER_NO_RUNTIME_DATA",
17636
+ REACT_PROFILER_SESSION_PAYLOAD_INVALID: "REACT_PROFILER_SESSION_PAYLOAD_INVALID",
17637
+ REACT_PROFILER_SESSION_PAYLOAD_DEVICE_MISSING: "REACT_PROFILER_SESSION_PAYLOAD_DEVICE_MISSING",
17638
+ REACT_PROFILER_SESSION_CDP_DISCONNECTED: "REACT_PROFILER_SESSION_CDP_DISCONNECTED",
17639
+ REACT_PROFILER_CDP_NOT_CONNECTED: "REACT_PROFILER_CDP_NOT_CONNECTED",
17640
+ REACT_PROFILER_STATE_READ_FAILED: "REACT_PROFILER_STATE_READ_FAILED",
17641
+ REACT_PROFILER_DEVTOOLS_HOOK_MISSING: "REACT_PROFILER_DEVTOOLS_HOOK_MISSING",
17642
+ REACT_PROFILER_DEVTOOLS_BACKEND_ATTACH_FAILED: "REACT_PROFILER_DEVTOOLS_BACKEND_ATTACH_FAILED",
17643
+ REACT_PROFILER_DEVTOOLS_BACKEND_BOOTSTRAP_FAILED: "REACT_PROFILER_DEVTOOLS_BACKEND_BOOTSTRAP_FAILED",
17644
+ REACT_PROFILER_DEVTOOLS_RENDERER_MISSING: "REACT_PROFILER_DEVTOOLS_RENDERER_MISSING",
17645
+ REACT_PROFILER_START_FAILED: "REACT_PROFILER_START_FAILED",
17646
+ REACT_PROFILER_START_VERIFY_FAILED: "REACT_PROFILER_START_VERIFY_FAILED",
17647
+ REACT_PROFILER_HOOK_ERROR: "REACT_PROFILER_HOOK_ERROR",
17648
+ REACT_PROFILER_ANALYZE_NO_DATA: "REACT_PROFILER_ANALYZE_NO_DATA",
17649
+ NATIVE_PROFILER_FACTORY_OPTIONS_MISSING: "NATIVE_PROFILER_FACTORY_OPTIONS_MISSING",
17650
+ NATIVE_PROFILER_WRONG_PLATFORM: "NATIVE_PROFILER_WRONG_PLATFORM",
17651
+ NATIVE_PROFILER_APP_PROCESS_LIST_FAILED: "NATIVE_PROFILER_APP_PROCESS_LIST_FAILED",
17652
+ NATIVE_PROFILER_APP_LIST_FAILED: "NATIVE_PROFILER_APP_LIST_FAILED",
17653
+ NATIVE_PROFILER_NO_RUNNING_APPS: "NATIVE_PROFILER_NO_RUNNING_APPS",
17654
+ NATIVE_PROFILER_NO_RUNNING_USER_APPS: "NATIVE_PROFILER_NO_RUNNING_USER_APPS",
17655
+ NATIVE_PROFILER_MULTIPLE_RUNNING_USER_APPS: "NATIVE_PROFILER_MULTIPLE_RUNNING_USER_APPS",
17656
+ NATIVE_PROFILER_SESSION_ALREADY_RUNNING: "NATIVE_PROFILER_SESSION_ALREADY_RUNNING",
17657
+ NATIVE_PROFILER_XCTRACE_NO_PID: "NATIVE_PROFILER_XCTRACE_NO_PID",
17658
+ NATIVE_PROFILER_XCTRACE_PROCESS_NOT_FOUND: "NATIVE_PROFILER_XCTRACE_PROCESS_NOT_FOUND",
17659
+ NATIVE_PROFILER_XCTRACE_READY_EXITED: "NATIVE_PROFILER_XCTRACE_READY_EXITED",
17660
+ NATIVE_PROFILER_XCTRACE_PROCESS_ERROR: "NATIVE_PROFILER_XCTRACE_PROCESS_ERROR",
17661
+ NATIVE_PROFILER_XCTRACE_READY_TIMEOUT: "NATIVE_PROFILER_XCTRACE_READY_TIMEOUT",
17662
+ NATIVE_PROFILER_NO_ACTIVE_SESSION: "NATIVE_PROFILER_NO_ACTIVE_SESSION",
17663
+ FLOW_PROJECT_ROOT_REQUIRED: "FLOW_PROJECT_ROOT_REQUIRED",
17664
+ FLOW_NO_ACTIVE_RECORDING: "FLOW_NO_ACTIVE_RECORDING",
17665
+ FLOW_FILE_INVALID: "FLOW_FILE_INVALID",
17666
+ FLOW_ENTRY_UNRECOGNIZED: "FLOW_ENTRY_UNRECOGNIZED",
17667
+ PROFILER_QUERY_MODE_INVALID: "PROFILER_QUERY_MODE_INVALID",
17668
+ PROFILER_QUERY_REQUIRED_PARAM_MISSING: "PROFILER_QUERY_REQUIRED_PARAM_MISSING",
17669
+ PROFILER_DATA_NOT_LOADED: "PROFILER_DATA_NOT_LOADED",
17670
+ PROFILER_NATIVE_TRACE_MISSING: "PROFILER_NATIVE_TRACE_MISSING",
17671
+ BOOT_DEVICE_TARGET_SELECTION_INVALID: "BOOT_DEVICE_TARGET_SELECTION_INVALID",
17672
+ BOOT_IOS_UNSUPPORTED_HOST: "BOOT_IOS_UNSUPPORTED_HOST",
17673
+ BOOT_ANDROID_NO_AVDS: "BOOT_ANDROID_NO_AVDS",
17674
+ BOOT_ANDROID_AVD_NOT_FOUND: "BOOT_ANDROID_AVD_NOT_FOUND",
17675
+ BOOT_ANDROID_ADB_UNAVAILABLE: "BOOT_ANDROID_ADB_UNAVAILABLE",
17676
+ BOOT_ANDROID_GPU_MODE_INVALID: "BOOT_ANDROID_GPU_MODE_INVALID",
17677
+ BOOT_ANDROID_ADB_REGISTER_TIMEOUT: "BOOT_ANDROID_ADB_REGISTER_TIMEOUT",
17678
+ BOOT_ANDROID_HOT_BOOT_FRAME_UNUSABLE: "BOOT_ANDROID_HOT_BOOT_FRAME_UNUSABLE",
17679
+ BOOT_ANDROID_FIRST_FRAME_TIMEOUT: "BOOT_ANDROID_FIRST_FRAME_TIMEOUT",
17680
+ BOOT_ANDROID_PACKAGE_MANAGER_UNAVAILABLE: "BOOT_ANDROID_PACKAGE_MANAGER_UNAVAILABLE",
17681
+ BOOT_ANDROID_COLD_BOOT_FAILED: "BOOT_ANDROID_COLD_BOOT_FAILED"
17682
+ };
17683
+
17684
+ // ../registry/src/errors.ts
17685
+ var FAILURE_AREAS = ["cli", "http", "registry", "tool_server", "installer"];
17686
+ var FAILURE_KINDS = [
17687
+ "validation",
17688
+ "not_found",
17689
+ "dependency_missing",
17690
+ "unsupported",
17691
+ "not_implemented",
17692
+ "timeout",
17693
+ "network",
17694
+ "subprocess",
17695
+ "crash",
17696
+ "unknown"
17697
+ ];
17698
+ var FAILURE_COMMANDS = [
17699
+ "adb",
17700
+ "emulator",
17701
+ "xcrun_simctl",
17702
+ "xctrace",
17703
+ "native_devtools",
17704
+ "android_devtools",
17705
+ "ax_service",
17706
+ "simulator_server",
17707
+ "cdp",
17708
+ "npm",
17709
+ "npx",
17710
+ "unknown"
17711
+ ];
17712
+ var FAILURE_SIGNAL_NAMES = [
17713
+ "SIGABRT",
17714
+ "SIGHUP",
17715
+ "SIGINT",
17716
+ "SIGKILL",
17717
+ "SIGQUIT",
17718
+ "SIGTERM"
17719
+ ];
17720
+ var FAILURE_SPAWN_CODES = ["EACCES", "ENOENT", "EPERM", "ETIMEDOUT"];
17721
+ var NETWORK_FAILURES = [
17722
+ "timeout",
17723
+ "connection_refused",
17724
+ "connection_reset",
17725
+ "invalid_response",
17726
+ "other"
17727
+ ];
17728
+ var FALLBACK_SIGNAL = {
17729
+ error_code: FAILURE_CODES.ARGENT_UNCLASSIFIED_FAILURE,
17730
+ failure_stage: "unclassified",
17731
+ failure_area: "registry",
17732
+ error_kind: "unknown"
17733
+ };
17734
+ var FAILURE_SIGNAL_NAME_SET = new Set(FAILURE_SIGNAL_NAMES);
17735
+ var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
17736
+
17737
+ // ../registry/src/registry.ts
17738
+ import { randomUUID as randomUUID2 } from "node:crypto";
17739
+
17740
+ // ../telemetry/src/events.ts
17741
+ var PLATFORMS = ["ios", "android", "chromium"];
17742
+
17743
+ // ../telemetry/src/ai-identity.ts
17744
+ var AI_CLIENTS = [
17745
+ "codex",
17746
+ "claude_code",
17747
+ "cursor",
17748
+ "gemini",
17749
+ "vscode",
17750
+ "windsurf",
17751
+ "zed",
17752
+ "opencode",
17753
+ "copilot",
17754
+ "other"
17755
+ ];
17756
+ var RUNTIME_CLIENT_PATTERNS = [
17757
+ [/^codex-mcp-client\b/, "codex"],
17758
+ [/^claude-code\b/, "claude_code"],
17759
+ [/^cursor\b/, "cursor"],
17760
+ [/^gemini-cli-mcp-client\b/, "gemini"],
17761
+ [/^visual studio code\b/, "vscode"],
17762
+ [/^code - oss\b/, "vscode"],
17763
+ [/^windsurf\b/, "windsurf"],
17764
+ [/^zed\b/, "zed"],
17765
+ [/^opencode\b/, "opencode"],
17766
+ [/^github-copilot-developer\b/, "copilot"]
17767
+ ];
17768
+ function canonicalizeAiClient(value) {
17769
+ if (typeof value !== "string") return void 0;
17770
+ const lower = value.trim().toLowerCase();
17771
+ if (!lower) return void 0;
17772
+ for (const [pattern, slug] of RUNTIME_CLIENT_PATTERNS) {
17773
+ if (pattern.test(lower)) return slug;
17774
+ }
17775
+ return void 0;
17776
+ }
17777
+
17778
+ // ../telemetry/src/sanitize.ts
17779
+ var oneOf = (opts) => (v) => typeof v === "string" && opts.includes(v) ? v : void 0;
17780
+ var matches = (re, max = 80) => (v) => typeof v === "string" && v.length <= max && re.test(v) ? v : void 0;
17781
+ var finiteNonNeg = (max = 2 ** 31) => (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= max ? v : void 0;
17782
+ var bool = (v) => typeof v === "boolean" ? v : void 0;
17783
+ var arrayOf = (elem, maxLen = 16) => (v) => {
17784
+ if (!Array.isArray(v)) return void 0;
17785
+ if (v.length > maxLen) return void 0;
17786
+ const out = [];
17787
+ for (const e of v) {
17788
+ const cleaned = elem(e);
17789
+ if (cleaned === void 0) return void 0;
17790
+ out.push(cleaned);
17791
+ }
17792
+ return out;
17793
+ };
17794
+ var TOOL_NAME = matches(/^[a-z][a-z0-9_-]{0,63}$/, 64);
17795
+ var PLATFORM = oneOf(PLATFORMS);
17796
+ var UUID = matches(
17797
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,
17798
+ 36
17799
+ );
17800
+ var PACKAGE_MANAGER = oneOf(["npm", "yarn", "pnpm", "bun", "unknown"]);
17801
+ var PACKAGE_ACTION_TRIGGER = oneOf(["init", "update", "mcp_update"]);
17802
+ var PACKAGE_ACTION = oneOf([
17803
+ "fresh_install",
17804
+ "already_installed",
17805
+ "init_triggered_update",
17806
+ "no_update",
17807
+ "update_skipped",
17808
+ "update_failed",
17809
+ "standalone_update",
17810
+ "standalone_install",
17811
+ "mcp_update"
17812
+ ]);
17813
+ var ADAPTER_NAME = matches(/^[a-z][a-z0-9-]{0,63}$/, 64);
17814
+ var COUNT = finiteNonNeg();
17815
+ var DURATION_MS = finiteNonNeg();
17816
+ var MAJOR_VERSION = finiteNonNeg(9999);
17817
+ var FAILURE_CODE_VALUES = new Set(Object.values(FAILURE_CODES));
17818
+ var ERROR_CODE = (v) => typeof v === "string" && FAILURE_CODE_VALUES.has(v) ? v : void 0;
17819
+ var FAILURE_STAGE = matches(/^[a-z][a-z0-9_]{1,79}$/, 80);
17820
+ var FAILURE_AREA = oneOf(FAILURE_AREAS);
17821
+ var ERROR_KIND = oneOf(FAILURE_KINDS);
17822
+ var FAILURE_COMMAND = oneOf(FAILURE_COMMANDS);
17823
+ var FAILURE_EXIT_CODE = finiteNonNeg(255);
17824
+ var FAILURE_SIGNAL_NAME = oneOf(FAILURE_SIGNAL_NAMES);
17825
+ var FAILURE_SPAWN_CODE = oneOf(FAILURE_SPAWN_CODES);
17826
+ var NETWORK_FAILURE = oneOf(NETWORK_FAILURES);
17827
+ var AI_CLIENT = oneOf(AI_CLIENTS);
17828
+ var AI_TELEMETRY = {
17829
+ ai_client: AI_CLIENT
17830
+ };
17831
+ var FAILURE_SIGNAL = {
17832
+ error_code: ERROR_CODE,
17833
+ failure_stage: FAILURE_STAGE,
17834
+ failure_area: FAILURE_AREA,
17835
+ error_kind: ERROR_KIND,
17836
+ failure_command: FAILURE_COMMAND,
17837
+ failure_exit_code: FAILURE_EXIT_CODE,
17838
+ failure_signal: FAILURE_SIGNAL_NAME,
17839
+ failure_spawn_code: FAILURE_SPAWN_CODE,
17840
+ network_failure: NETWORK_FAILURE
17841
+ };
17842
+ var ALLOWED = {
17843
+ "installation:cli_init_start": {
17844
+ package_manager: PACKAGE_MANAGER,
17845
+ is_non_interactive: bool
17846
+ },
17847
+ "installation:cli_init_complete": {
17848
+ duration_ms: DURATION_MS,
17849
+ is_success: bool,
17850
+ editors_configured_count: COUNT,
17851
+ ...FAILURE_SIGNAL
17852
+ },
17853
+ "installation:cli_init_cancel": {
17854
+ step: oneOf(["global_install", "editors", "scope", "skills", "allowlist"])
17855
+ },
17856
+ "installation:global_install_decision": {
17857
+ // `from_tar` is intentionally absent; the installer skips that dev path.
17858
+ decision: oneOf(["install", "cancel", "already_installed"])
17859
+ },
17860
+ "installation:update_decision": {
17861
+ from_major: MAJOR_VERSION,
17862
+ to_major: MAJOR_VERSION,
17863
+ decision: oneOf(["update", "skip", "no_update"])
17864
+ },
17865
+ "installation:editors_select": {
17866
+ editors: arrayOf(ADAPTER_NAME),
17867
+ detected_editor_count: COUNT,
17868
+ scope: oneOf(["local", "global", "custom"])
17869
+ },
17870
+ "installation:allowlist_decision": {
17871
+ is_enabled: bool
17872
+ },
17873
+ "installation:skill_install": {
17874
+ method: oneOf(["default", "interactive", "manual"]),
17875
+ is_online: bool,
17876
+ has_offline_cache: bool,
17877
+ outcome: oneOf(["success", "failure", "skipped"])
17878
+ },
17879
+ "installation:skill_refresh_result": {
17880
+ is_success: bool,
17881
+ scope_count: COUNT,
17882
+ synced_count: COUNT,
17883
+ pruned_count: COUNT,
17884
+ failed_count: COUNT,
17885
+ ...FAILURE_SIGNAL
17886
+ },
17887
+ "installation:package_action": {
17888
+ trigger: PACKAGE_ACTION_TRIGGER,
17889
+ action: PACKAGE_ACTION,
17890
+ is_success: bool,
17891
+ duration_ms: DURATION_MS,
17892
+ ...FAILURE_SIGNAL
17893
+ },
17894
+ "installation:cli_update_start": {},
17895
+ "installation:cli_update_complete": {
17896
+ duration_ms: DURATION_MS
17897
+ },
17898
+ "installation:cli_update_fail": {
17899
+ duration_ms: DURATION_MS,
17900
+ ...FAILURE_SIGNAL
17901
+ },
17902
+ "installation:cli_uninstall_start": {},
17903
+ "installation:cli_uninstall_complete": {
17904
+ has_pruned_content: bool,
17905
+ has_uninstalled_package: bool,
17906
+ ...FAILURE_SIGNAL
17907
+ },
17908
+ "tool:invoke": {
17909
+ tool: TOOL_NAME,
17910
+ tool_invocation_id: UUID,
17911
+ platform: PLATFORM,
17912
+ ...AI_TELEMETRY
17913
+ },
17914
+ "tool:complete": {
17915
+ tool: TOOL_NAME,
17916
+ tool_invocation_id: UUID,
17917
+ platform: PLATFORM,
17918
+ duration_ms: DURATION_MS,
17919
+ ...AI_TELEMETRY
17920
+ },
17921
+ "tool:fail": {
17922
+ tool: TOOL_NAME,
17923
+ tool_invocation_id: UUID,
17924
+ platform: PLATFORM,
17925
+ duration_ms: DURATION_MS,
17926
+ ...FAILURE_SIGNAL,
17927
+ ...AI_TELEMETRY
17928
+ },
17929
+ "cli:run_fail": {
17930
+ tool: TOOL_NAME,
17931
+ duration_ms: DURATION_MS,
17932
+ ...FAILURE_SIGNAL
17933
+ },
17934
+ "toolserver:start": {},
17935
+ "toolserver:stop": {
17936
+ reason: oneOf(["idle", "signal", "crash"]),
17937
+ uptime_ms: DURATION_MS,
17938
+ total_tool_calls: COUNT,
17939
+ ...FAILURE_SIGNAL
17940
+ },
17941
+ "telemetry:opt_out": {}
17942
+ };
17943
+
17944
+ // ../telemetry/src/base-props.ts
17945
+ import { randomUUID as randomUUID3 } from "node:crypto";
17946
+
17947
+ // ../../node_modules/ci-info/vendors.json
17948
+ var vendors_default = [
17949
+ {
17950
+ name: "Agola CI",
17951
+ constant: "AGOLA",
17952
+ env: "AGOLA_GIT_REF",
17953
+ pr: "AGOLA_PULL_REQUEST_ID"
17954
+ },
17955
+ {
17956
+ name: "Alpic",
17957
+ constant: "ALPIC",
17958
+ env: "ALPIC_HOST"
17959
+ },
17960
+ {
17961
+ name: "Appcircle",
17962
+ constant: "APPCIRCLE",
17963
+ env: "AC_APPCIRCLE",
17964
+ pr: {
17965
+ env: "AC_GIT_PR",
17966
+ ne: "false"
17967
+ }
17968
+ },
17969
+ {
17970
+ name: "AppVeyor",
17971
+ constant: "APPVEYOR",
17972
+ env: "APPVEYOR",
17973
+ pr: "APPVEYOR_PULL_REQUEST_NUMBER"
17974
+ },
17975
+ {
17976
+ name: "AWS CodeBuild",
17977
+ constant: "CODEBUILD",
17978
+ env: "CODEBUILD_BUILD_ARN",
17979
+ pr: {
17980
+ env: "CODEBUILD_WEBHOOK_EVENT",
17981
+ any: [
17982
+ "PULL_REQUEST_CREATED",
17983
+ "PULL_REQUEST_UPDATED",
17984
+ "PULL_REQUEST_REOPENED"
17985
+ ]
17986
+ }
17987
+ },
17988
+ {
17989
+ name: "Azure Pipelines",
17990
+ constant: "AZURE_PIPELINES",
17991
+ env: "TF_BUILD",
17992
+ pr: {
17993
+ BUILD_REASON: "PullRequest"
17994
+ }
17995
+ },
17996
+ {
17997
+ name: "Bamboo",
17998
+ constant: "BAMBOO",
17999
+ env: "bamboo_planKey"
18000
+ },
18001
+ {
18002
+ name: "Bitbucket Pipelines",
18003
+ constant: "BITBUCKET",
18004
+ env: "BITBUCKET_COMMIT",
18005
+ pr: "BITBUCKET_PR_ID"
18006
+ },
18007
+ {
18008
+ name: "Bitrise",
18009
+ constant: "BITRISE",
18010
+ env: "BITRISE_IO",
18011
+ pr: "BITRISE_PULL_REQUEST"
18012
+ },
18013
+ {
18014
+ name: "Buddy",
18015
+ constant: "BUDDY",
18016
+ env: "BUDDY_WORKSPACE_ID",
18017
+ pr: "BUDDY_EXECUTION_PULL_REQUEST_ID"
18018
+ },
18019
+ {
18020
+ name: "Buildkite",
18021
+ constant: "BUILDKITE",
18022
+ env: "BUILDKITE",
18023
+ pr: {
18024
+ env: "BUILDKITE_PULL_REQUEST",
18025
+ ne: "false"
18026
+ }
18027
+ },
18028
+ {
18029
+ name: "CircleCI",
18030
+ constant: "CIRCLE",
18031
+ env: "CIRCLECI",
18032
+ pr: "CIRCLE_PULL_REQUEST"
18033
+ },
18034
+ {
18035
+ name: "Cirrus CI",
18036
+ constant: "CIRRUS",
18037
+ env: "CIRRUS_CI",
18038
+ pr: "CIRRUS_PR"
18039
+ },
18040
+ {
18041
+ name: "Cloudflare Pages",
18042
+ constant: "CLOUDFLARE_PAGES",
18043
+ env: "CF_PAGES"
18044
+ },
18045
+ {
18046
+ name: "Cloudflare Workers",
18047
+ constant: "CLOUDFLARE_WORKERS",
18048
+ env: "WORKERS_CI"
18049
+ },
18050
+ {
18051
+ name: "Codefresh",
18052
+ constant: "CODEFRESH",
18053
+ env: "CF_BUILD_ID",
18054
+ pr: {
18055
+ any: [
18056
+ "CF_PULL_REQUEST_NUMBER",
18057
+ "CF_PULL_REQUEST_ID"
18058
+ ]
18059
+ }
18060
+ },
18061
+ {
18062
+ name: "Codemagic",
18063
+ constant: "CODEMAGIC",
18064
+ env: "CM_BUILD_ID",
18065
+ pr: "CM_PULL_REQUEST"
18066
+ },
18067
+ {
18068
+ name: "Codeship",
18069
+ constant: "CODESHIP",
18070
+ env: {
18071
+ CI_NAME: "codeship"
18072
+ }
18073
+ },
18074
+ {
18075
+ name: "Drone",
18076
+ constant: "DRONE",
18077
+ env: "DRONE",
18078
+ pr: {
18079
+ DRONE_BUILD_EVENT: "pull_request"
18080
+ }
18081
+ },
18082
+ {
18083
+ name: "dsari",
18084
+ constant: "DSARI",
18085
+ env: "DSARI"
18086
+ },
18087
+ {
18088
+ name: "Earthly",
18089
+ constant: "EARTHLY",
18090
+ env: "EARTHLY_CI"
18091
+ },
18092
+ {
18093
+ name: "Expo Application Services",
18094
+ constant: "EAS",
18095
+ env: "EAS_BUILD"
18096
+ },
18097
+ {
18098
+ name: "Gerrit",
18099
+ constant: "GERRIT",
18100
+ env: "GERRIT_PROJECT"
18101
+ },
18102
+ {
18103
+ name: "Gitea Actions",
18104
+ constant: "GITEA_ACTIONS",
18105
+ env: "GITEA_ACTIONS"
18106
+ },
18107
+ {
18108
+ name: "GitHub Actions",
18109
+ constant: "GITHUB_ACTIONS",
18110
+ env: "GITHUB_ACTIONS",
18111
+ pr: {
18112
+ GITHUB_EVENT_NAME: "pull_request"
18113
+ }
18114
+ },
18115
+ {
18116
+ name: "GitLab CI",
18117
+ constant: "GITLAB",
18118
+ env: "GITLAB_CI",
18119
+ pr: "CI_MERGE_REQUEST_ID"
18120
+ },
18121
+ {
18122
+ name: "GoCD",
18123
+ constant: "GOCD",
18124
+ env: "GO_PIPELINE_LABEL"
18125
+ },
18126
+ {
18127
+ name: "Google Cloud Build",
18128
+ constant: "GOOGLE_CLOUD_BUILD",
18129
+ env: "BUILDER_OUTPUT"
18130
+ },
18131
+ {
18132
+ name: "Harness CI",
18133
+ constant: "HARNESS",
18134
+ env: "HARNESS_BUILD_ID"
18135
+ },
18136
+ {
18137
+ name: "Heroku",
18138
+ constant: "HEROKU",
18139
+ env: {
18140
+ env: "NODE",
18141
+ includes: "/app/.heroku/node/bin/node"
18142
+ }
18143
+ },
18144
+ {
18145
+ name: "Hudson",
18146
+ constant: "HUDSON",
18147
+ env: "HUDSON_URL"
18148
+ },
18149
+ {
18150
+ name: "Jenkins",
18151
+ constant: "JENKINS",
18152
+ env: [
18153
+ "JENKINS_URL",
18154
+ "BUILD_ID"
18155
+ ],
18156
+ pr: {
18157
+ any: [
18158
+ "ghprbPullId",
18159
+ "CHANGE_ID"
18160
+ ]
18161
+ }
18162
+ },
18163
+ {
18164
+ name: "LayerCI",
18165
+ constant: "LAYERCI",
18166
+ env: "LAYERCI",
18167
+ pr: "LAYERCI_PULL_REQUEST"
18168
+ },
18169
+ {
18170
+ name: "Magnum CI",
18171
+ constant: "MAGNUM",
18172
+ env: "MAGNUM"
18173
+ },
18174
+ {
18175
+ name: "Netlify CI",
18176
+ constant: "NETLIFY",
18177
+ env: "NETLIFY",
18178
+ pr: {
18179
+ env: "PULL_REQUEST",
18180
+ ne: "false"
18181
+ }
18182
+ },
18183
+ {
18184
+ name: "Nevercode",
18185
+ constant: "NEVERCODE",
18186
+ env: "NEVERCODE",
18187
+ pr: {
18188
+ env: "NEVERCODE_PULL_REQUEST",
18189
+ ne: "false"
18190
+ }
18191
+ },
18192
+ {
18193
+ name: "Prow",
18194
+ constant: "PROW",
18195
+ env: "PROW_JOB_ID"
18196
+ },
18197
+ {
18198
+ name: "ReleaseHub",
18199
+ constant: "RELEASEHUB",
18200
+ env: "RELEASE_BUILD_ID"
18201
+ },
18202
+ {
18203
+ name: "Render",
18204
+ constant: "RENDER",
18205
+ env: "RENDER",
18206
+ pr: {
18207
+ IS_PULL_REQUEST: "true"
18208
+ }
18209
+ },
18210
+ {
18211
+ name: "Sail CI",
18212
+ constant: "SAIL",
18213
+ env: "SAILCI",
18214
+ pr: "SAIL_PULL_REQUEST_NUMBER"
18215
+ },
18216
+ {
18217
+ name: "Screwdriver",
18218
+ constant: "SCREWDRIVER",
18219
+ env: "SCREWDRIVER",
18220
+ pr: {
18221
+ env: "SD_PULL_REQUEST",
18222
+ ne: "false"
18223
+ }
18224
+ },
18225
+ {
18226
+ name: "Semaphore",
18227
+ constant: "SEMAPHORE",
18228
+ env: "SEMAPHORE",
18229
+ pr: "PULL_REQUEST_NUMBER"
18230
+ },
18231
+ {
18232
+ name: "Sourcehut",
18233
+ constant: "SOURCEHUT",
18234
+ env: {
18235
+ CI_NAME: "sourcehut"
18236
+ }
18237
+ },
18238
+ {
18239
+ name: "Strider CD",
18240
+ constant: "STRIDER",
18241
+ env: "STRIDER"
18242
+ },
18243
+ {
18244
+ name: "TaskCluster",
18245
+ constant: "TASKCLUSTER",
18246
+ env: [
18247
+ "TASK_ID",
18248
+ "RUN_ID"
18249
+ ]
18250
+ },
18251
+ {
18252
+ name: "TeamCity",
18253
+ constant: "TEAMCITY",
18254
+ env: "TEAMCITY_VERSION"
18255
+ },
18256
+ {
18257
+ name: "Travis CI",
18258
+ constant: "TRAVIS",
18259
+ env: "TRAVIS",
18260
+ pr: {
18261
+ env: "TRAVIS_PULL_REQUEST",
18262
+ ne: "false"
18263
+ }
18264
+ },
18265
+ {
18266
+ name: "Vela",
18267
+ constant: "VELA",
18268
+ env: "VELA",
18269
+ pr: {
18270
+ VELA_PULL_REQUEST: "1"
18271
+ }
18272
+ },
18273
+ {
18274
+ name: "Vercel",
18275
+ constant: "VERCEL",
18276
+ env: {
18277
+ any: [
18278
+ "NOW_BUILDER",
18279
+ "VERCEL"
18280
+ ]
18281
+ },
18282
+ pr: "VERCEL_GIT_PULL_REQUEST_ID"
18283
+ },
18284
+ {
18285
+ name: "Visual Studio App Center",
18286
+ constant: "APPCENTER",
18287
+ env: "APPCENTER_BUILD_ID"
18288
+ },
18289
+ {
18290
+ name: "Woodpecker",
18291
+ constant: "WOODPECKER",
18292
+ env: {
18293
+ CI: "woodpecker"
18294
+ },
18295
+ pr: {
18296
+ CI_BUILD_EVENT: "pull_request"
18297
+ }
18298
+ },
18299
+ {
18300
+ name: "Xcode Cloud",
18301
+ constant: "XCODE_CLOUD",
18302
+ env: "CI_XCODE_PROJECT",
18303
+ pr: "CI_PULL_REQUEST_NUMBER"
18304
+ },
18305
+ {
18306
+ name: "Xcode Server",
18307
+ constant: "XCODE_SERVER",
18308
+ env: "XCS"
18309
+ }
18310
+ ];
18311
+
18312
+ // ../telemetry/src/ci-detect.ts
18313
+ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
18314
+
18315
+ // ../telemetry/src/base-props.ts
18316
+ var SESSION_ID2 = randomUUID3();
18317
+
18318
+ // ../telemetry/src/identity.ts
18319
+ import * as crypto from "node:crypto";
18320
+ import * as fs2 from "node:fs";
18321
+ import * as path5 from "node:path";
18322
+
18323
+ // ../telemetry/src/paths.ts
18324
+ import * as os from "node:os";
18325
+ import * as path4 from "node:path";
18326
+ function nonEmpty(value) {
18327
+ if (value == void 0) return null;
18328
+ const trimmed = value.trim();
18329
+ return trimmed === "" ? null : value;
18330
+ }
18331
+ function argentHomeDir() {
18332
+ const home = process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
18333
+ return path4.join(home, ".argent");
18334
+ }
18335
+ function configFilePath() {
18336
+ return path4.join(argentHomeDir(), "config.json");
18337
+ }
18338
+
18339
+ // ../telemetry/src/consent.ts
18340
+ import * as fs4 from "node:fs";
18341
+
18342
+ // ../telemetry/src/config-file.ts
18343
+ import * as crypto2 from "node:crypto";
18344
+ import * as fs3 from "node:fs";
18345
+ import * as path6 from "node:path";
18346
+ function readConfigObject() {
18347
+ try {
18348
+ const raw = fs3.readFileSync(configFilePath(), "utf8");
18349
+ const json = JSON.parse(raw);
18350
+ if (json && typeof json === "object") {
18351
+ return json;
18352
+ }
18353
+ } catch {
18354
+ }
18355
+ return {};
18356
+ }
18357
+ var LOCK_STALE_MS = 1e4;
18358
+ var LOCK_MAX_WAIT_MS = 2e3;
18359
+ var LOCK_RETRY_MS = 25;
18360
+ function sleepSync(ms) {
18361
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
18362
+ }
18363
+ function acquireConfigLock() {
18364
+ const lockPath = configFilePath() + ".lock";
18365
+ const deadline = Date.now() + LOCK_MAX_WAIT_MS;
18366
+ for (; ; ) {
18367
+ try {
18368
+ const fd = fs3.openSync(lockPath, "wx", 384);
18369
+ try {
18370
+ fs3.writeSync(fd, `${process.pid}
18371
+ `);
18372
+ } catch {
18373
+ }
18374
+ return { fd, lockPath };
18375
+ } catch (err) {
18376
+ if (err.code !== "EEXIST") return null;
18377
+ try {
18378
+ if (Date.now() - fs3.statSync(lockPath).mtimeMs > LOCK_STALE_MS) {
18379
+ fs3.unlinkSync(lockPath);
18380
+ continue;
18381
+ }
18382
+ } catch {
18383
+ }
18384
+ if (Date.now() >= deadline) return null;
18385
+ sleepSync(LOCK_RETRY_MS);
18386
+ }
18387
+ }
18388
+ }
18389
+ function releaseConfigLock(lock) {
18390
+ try {
18391
+ fs3.closeSync(lock.fd);
18392
+ } catch {
18393
+ }
18394
+ try {
18395
+ fs3.unlinkSync(lock.lockPath);
18396
+ } catch {
18397
+ }
18398
+ }
18399
+ function updateConfig(mutate) {
18400
+ fs3.mkdirSync(argentHomeDir(), { recursive: true });
18401
+ const lock = acquireConfigLock();
18402
+ try {
18403
+ const next = readConfigObject();
18404
+ mutate(next);
18405
+ const finalPath = configFilePath();
18406
+ const tmpPath = path6.join(argentHomeDir(), `.config.tmp.${process.pid}.${crypto2.randomUUID()}`);
18407
+ const fd = fs3.openSync(tmpPath, "wx", 384);
18408
+ try {
18409
+ fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
18410
+ fs3.fsyncSync(fd);
18411
+ } finally {
18412
+ fs3.closeSync(fd);
18413
+ }
18414
+ try {
18415
+ fs3.renameSync(tmpPath, finalPath);
18416
+ } catch (err) {
18417
+ try {
18418
+ fs3.unlinkSync(tmpPath);
18419
+ } catch {
18420
+ }
18421
+ throw err;
18422
+ }
18423
+ } finally {
18424
+ if (lock) releaseConfigLock(lock);
18425
+ }
18426
+ }
18427
+
18428
+ // ../telemetry/src/consent.ts
18429
+ var cache = { current: null };
18430
+ var sessionOverride = null;
18431
+ function readConfigOverride() {
18432
+ let stats;
18433
+ try {
18434
+ stats = fs4.lstatSync(configFilePath());
18435
+ } catch (err) {
18436
+ if (err.code === "ENOENT") {
18437
+ cache.current = { mtimeMs: null, fingerprint: null, enabledOverride: null };
18438
+ return null;
18439
+ }
18440
+ cache.current = { mtimeMs: null, fingerprint: null, enabledOverride: null };
18441
+ return null;
18442
+ }
18443
+ if (!stats.isFile()) {
18444
+ cache.current = { mtimeMs: null, fingerprint: null, enabledOverride: null };
18445
+ return null;
18446
+ }
18447
+ const fingerprint = `${stats.dev}:${stats.ino}:${stats.size}`;
18448
+ const mtimeMs = stats.mtimeMs;
18449
+ if (cache.current && cache.current.fingerprint === fingerprint && cache.current.mtimeMs === mtimeMs) {
18450
+ return cache.current.enabledOverride;
18451
+ }
18452
+ let parsedEnabled = null;
18453
+ try {
18454
+ const raw = fs4.readFileSync(configFilePath(), "utf8");
18455
+ const json = JSON.parse(raw);
18456
+ if (json && typeof json === "object") {
18457
+ const t = json.telemetry;
18458
+ if (t && typeof t === "object") {
18459
+ const enabled = t.enabled;
18460
+ if (typeof enabled === "boolean") parsedEnabled = enabled;
18461
+ }
18462
+ }
18463
+ } catch {
18464
+ }
18465
+ cache.current = { mtimeMs, fingerprint, enabledOverride: parsedEnabled };
18466
+ return parsedEnabled;
18467
+ }
18468
+ function parseFalsy(value) {
18469
+ if (value === void 0) return false;
18470
+ const v = value.trim().toLowerCase();
18471
+ return v === "0" || v === "false" || v === "no" || v === "off";
18472
+ }
18473
+ function isDoNotTrackSet(value) {
18474
+ if (value === void 0 || value.trim() === "") return false;
18475
+ return !parseFalsy(value);
18476
+ }
18477
+ function getConsentState(env = process.env) {
18478
+ if (isDoNotTrackSet(env.DO_NOT_TRACK)) {
18479
+ return {
18480
+ enabled: false,
18481
+ source: { source: "env_do_not_track", detail: `DO_NOT_TRACK=${env.DO_NOT_TRACK}` }
18482
+ };
18483
+ }
18484
+ const argentEnv = env.ARGENT_TELEMETRY;
18485
+ if (parseFalsy(argentEnv)) {
18486
+ return {
18487
+ enabled: false,
18488
+ source: { source: "env_argent_telemetry", detail: `ARGENT_TELEMETRY=${argentEnv}` }
18489
+ };
18490
+ }
18491
+ if (sessionOverride !== null) {
18492
+ return { enabled: sessionOverride, source: { source: "session_override" } };
18493
+ }
18494
+ const persisted = readConfigOverride();
18495
+ if (persisted === false) {
18496
+ return { enabled: false, source: { source: "config_file", detail: "config.json" } };
18497
+ }
18498
+ if (persisted === true) {
18499
+ return { enabled: true, source: { source: "config_file", detail: "config.json" } };
18500
+ }
18501
+ return { enabled: true, source: { source: "default" } };
18502
+ }
18503
+ function isEnabled(env = process.env) {
18504
+ return getConsentState(env).enabled;
18505
+ }
18506
+
18507
+ // ../telemetry/src/debug.ts
18508
+ import * as fs5 from "node:fs";
18509
+
18510
+ // ../telemetry/src/notice.ts
18511
+ var TELEMETRY_OPT_OUT_COMMAND = "argent telemetry disable";
18512
+ var TELEMETRY_DETAILS_URL = "https://swmansion.com/legal/argent/privacy-notice/";
18513
+ var FIRST_RUN_NOTICE_BODY_LINES = [
18514
+ "Argent collects anonymous usage data to help us improve the tool. We never",
18515
+ "collect your source code, file paths, tool inputs, or error contents."
18516
+ ];
18517
+ var FIRST_RUN_NOTICE = [
18518
+ ...FIRST_RUN_NOTICE_BODY_LINES,
18519
+ `Opt out anytime: ${TELEMETRY_OPT_OUT_COMMAND}`,
18520
+ `Details: ${TELEMETRY_DETAILS_URL}`
18521
+ ].join("\n");
18522
+ function hasShownFirstRunNotice() {
18523
+ const notices = readConfigObject().notices;
18524
+ if (notices && typeof notices === "object") {
18525
+ return notices.first_run_shown === true;
18526
+ }
18527
+ return false;
18528
+ }
18529
+ function markFirstRunNoticeShown() {
18530
+ updateConfig((config2) => {
18531
+ const noticesBlock = typeof config2.notices === "object" && config2.notices ? config2.notices : {};
18532
+ config2.notices = { ...noticesBlock, first_run_shown: true };
18533
+ });
18534
+ }
18535
+ function shouldShowFirstRunNotice() {
18536
+ return isEnabled() && !hasShownFirstRunNotice();
18537
+ }
18538
+
15834
18539
  // ../argent-mcp/src/content.ts
15835
- import { readFile as readFile4 } from "node:fs/promises";
18540
+ import { readFile as readFile5 } from "node:fs/promises";
15836
18541
  var PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
15837
18542
  function imageBlock(data, mimeType) {
15838
18543
  return { type: "image", data: data.toString("base64"), mimeType };
@@ -15898,15 +18603,34 @@ function isScreenshotDiffResult(value) {
15898
18603
  if (!isRecord(value)) return false;
15899
18604
  return typeof value.summary === "string";
15900
18605
  }
15901
- async function screenshotDiffToMcpContent(result) {
18606
+ async function screenshotDiffToMcpContent(result, ctx) {
15902
18607
  const blocks = [];
15903
- if (typeof result.contextDiffPath === "string") {
15904
- const buf = await readFile4(result.contextDiffPath);
15905
- blocks.push({
15906
- type: "image",
15907
- data: buf.toString("base64"),
15908
- mimeType: "image/png"
15909
- });
18608
+ let contextDiffPath = result.contextDiffPath;
18609
+ let materializedImages = [];
18610
+ if (ctx) {
18611
+ const { result: rewritten, images } = await materializeArtifacts(result, ctx);
18612
+ contextDiffPath = rewritten.contextDiffPath;
18613
+ materializedImages = images;
18614
+ }
18615
+ if (typeof contextDiffPath === "string") {
18616
+ const fromMaterializer = materializedImages.find((img) => img.localPath === contextDiffPath);
18617
+ if (fromMaterializer) {
18618
+ blocks.push({
18619
+ type: "image",
18620
+ data: fromMaterializer.data.toString("base64"),
18621
+ mimeType: fromMaterializer.mimeType
18622
+ });
18623
+ } else {
18624
+ try {
18625
+ const buf = await readFile5(contextDiffPath);
18626
+ blocks.push({
18627
+ type: "image",
18628
+ data: buf.toString("base64"),
18629
+ mimeType: "image/png"
18630
+ });
18631
+ } catch {
18632
+ }
18633
+ }
15910
18634
  }
15911
18635
  blocks.push({ type: "text", text: result.summary });
15912
18636
  return blocks;
@@ -15944,34 +18668,34 @@ async function flowRunToMcpContent(result, ctx) {
15944
18668
  }
15945
18669
 
15946
18670
  // ../configuration-core/src/flags.ts
15947
- import * as fs2 from "node:fs";
15948
- import * as path3 from "node:path";
15949
- import { homedir as homedir3 } from "node:os";
18671
+ import * as fs6 from "node:fs";
18672
+ import * as path7 from "node:path";
18673
+ import { homedir as homedir4 } from "node:os";
15950
18674
  var PROJECT_MARKERS = [".argent", ".git", "package.json"];
15951
18675
  function resolveProjectRoot(startDir) {
15952
- const initial = path3.resolve(startDir);
18676
+ const initial = path7.resolve(startDir);
15953
18677
  let current = initial;
15954
18678
  while (true) {
15955
18679
  for (const marker of PROJECT_MARKERS) {
15956
- if (fs2.existsSync(path3.join(current, marker))) return current;
18680
+ if (fs6.existsSync(path7.join(current, marker))) return current;
15957
18681
  }
15958
- const parent = path3.dirname(current);
18682
+ const parent = path7.dirname(current);
15959
18683
  if (parent === current) return initial;
15960
18684
  current = parent;
15961
18685
  }
15962
18686
  }
15963
18687
  function getFlagsPath(scope, options = {}) {
15964
- const home = options.homeDir ?? homedir3();
18688
+ const home = options.homeDir ?? homedir4();
15965
18689
  if (scope === "global") {
15966
- return path3.join(home, ".argent", "flags.json");
18690
+ return path7.join(home, ".argent", "flags.json");
15967
18691
  }
15968
18692
  const cwd = options.cwd ?? process.cwd();
15969
- return path3.join(resolveProjectRoot(cwd), ".argent", "flags.json");
18693
+ return path7.join(resolveProjectRoot(cwd), ".argent", "flags.json");
15970
18694
  }
15971
18695
  function readFlagsFile(filePath) {
15972
18696
  let raw;
15973
18697
  try {
15974
- raw = fs2.readFileSync(filePath, "utf8");
18698
+ raw = fs6.readFileSync(filePath, "utf8");
15975
18699
  } catch {
15976
18700
  return {};
15977
18701
  }
@@ -16005,6 +18729,8 @@ function isFlagEnabled(name, options = {}) {
16005
18729
  var AUTO_SCREENSHOT_TOOLS = /* @__PURE__ */ new Set([
16006
18730
  "gesture-tap",
16007
18731
  "gesture-swipe",
18732
+ "gesture-scroll",
18733
+ "gesture-drag",
16008
18734
  "gesture-custom",
16009
18735
  "gesture-pinch",
16010
18736
  "gesture-rotate",
@@ -16022,6 +18748,8 @@ var AUTO_SCREENSHOT_DELAY_MS_BY_TOOL = {
16022
18748
  "restart-app": 3e3,
16023
18749
  "open-url": 2e3,
16024
18750
  "gesture-swipe": 1500,
18751
+ "gesture-scroll": 1500,
18752
+ "gesture-drag": 1500,
16025
18753
  "gesture-custom": 1500,
16026
18754
  "gesture-tap": 1500,
16027
18755
  "gesture-pinch": 1500,
@@ -16074,6 +18802,19 @@ function toMcpTool(t) {
16074
18802
  };
16075
18803
  }
16076
18804
 
18805
+ // ../argent-mcp/src/installed-version.ts
18806
+ import * as fs7 from "node:fs";
18807
+ import * as path8 from "node:path";
18808
+ function getInstalledVersion() {
18809
+ try {
18810
+ const pkgPath = path8.resolve(import.meta.dirname, "..", "package.json");
18811
+ const pkg = JSON.parse(fs7.readFileSync(pkgPath, "utf8"));
18812
+ return pkg.version ?? "unknown";
18813
+ } catch {
18814
+ return "unknown";
18815
+ }
18816
+ }
18817
+
16077
18818
  // ../argent-mcp/src/mcp-server.ts
16078
18819
  var MAX_RETRIES = 4;
16079
18820
  var EXP_BACKOFF_BASE = 250;
@@ -16105,6 +18846,11 @@ async function fetchWithReconnect(getUrl, reconnect, config2) {
16105
18846
  throw lastError;
16106
18847
  }
16107
18848
  async function startMcpServer(options) {
18849
+ if (shouldShowFirstRunNotice()) {
18850
+ process.stderr.write(`[argent] ${FIRST_RUN_NOTICE}
18851
+ `);
18852
+ markFirstRunNoticeShown();
18853
+ }
16108
18854
  const autoScreenshotOn = autoScreenshotEnabled();
16109
18855
  let TOOLS_URL;
16110
18856
  let AUTH_TOKEN;
@@ -16126,6 +18872,13 @@ async function startMcpServer(options) {
16126
18872
  function authHeader() {
16127
18873
  return AUTH_TOKEN ? { Authorization: `Bearer ${AUTH_TOKEN}` } : {};
16128
18874
  }
18875
+ function aiClientHeaders() {
18876
+ const rawName = server.getClientVersion()?.name?.trim() || void 0;
18877
+ const aiClient = canonicalizeAiClient(rawName);
18878
+ if (aiClient) return { "X-Argent-AI-Client": aiClient };
18879
+ if (rawName) return { "X-Argent-AI-Client": "other" };
18880
+ return {};
18881
+ }
16129
18882
  let reconnectPromise = null;
16130
18883
  async function reconnect() {
16131
18884
  if (await isRemoteRouted()) return;
@@ -16139,12 +18892,12 @@ async function startMcpServer(options) {
16139
18892
  }
16140
18893
  return reconnectPromise;
16141
18894
  }
16142
- const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? `${homedir4()}/.argent/mcp-calls.log`;
18895
+ const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? `${homedir5()}/.argent/mcp-calls.log`;
16143
18896
  let logDirReady = false;
16144
18897
  async function spyLog(entry) {
16145
18898
  try {
16146
18899
  if (!logDirReady) {
16147
- await mkdir4(dirname2(LOG_FILE2), { recursive: true });
18900
+ await mkdir5(dirname4(LOG_FILE2), { recursive: true });
16148
18901
  logDirReady = true;
16149
18902
  }
16150
18903
  await appendFile(LOG_FILE2, JSON.stringify(entry) + "\n");
@@ -16161,23 +18914,33 @@ async function startMcpServer(options) {
16161
18914
  async function callTool(name, args) {
16162
18915
  const tools = await fetchTools();
16163
18916
  const meta2 = tools.find((t) => t.name === name);
18917
+ let finalArgs = args;
18918
+ if (meta2?.fileInputs?.length) {
18919
+ finalArgs = await prepareFileInputs(meta2.fileInputs, args ?? {}, {
18920
+ // `resolved` is the startup routing decision that picked TOOLS_URL —
18921
+ // an external target means this process may not share the server's
18922
+ // filesystem, so file bytes must ride along.
18923
+ includeContent: resolved.url !== null
18924
+ });
18925
+ }
16164
18926
  const res = await fetchWithReconnect(() => `${TOOLS_URL}/tools/${name}`, reconnect, {
16165
18927
  init: {
16166
18928
  method: "POST",
16167
- headers: { "Content-Type": "application/json", ...authHeader() },
16168
- body: JSON.stringify(args ?? {})
18929
+ headers: { "Content-Type": "application/json", ...authHeader(), ...aiClientHeaders() },
18930
+ body: JSON.stringify(finalArgs ?? {})
16169
18931
  },
16170
18932
  fetchTimeoutMs: meta2?.longRunning ? null : FETCH_TIMEOUT_MS
16171
18933
  });
16172
18934
  const json = await res.json();
16173
18935
  if (!res.ok) throw new Error(json.error ?? json.message ?? res.statusText);
16174
- return { result: json.data, outputHint: meta2?.outputHint, note: json.note };
18936
+ const { result: data } = await applyClientFileDirectives(json.data);
18937
+ return { result: data, outputHint: meta2?.outputHint, note: json.note };
16175
18938
  }
16176
18939
  const server = new Server(
16177
- { name: "argent", version: "0.5.3" },
18940
+ { name: "argent", version: getInstalledVersion() },
16178
18941
  {
16179
18942
  capabilities: { tools: {} },
16180
- instructions: "Argent \u2014 iOS Simulator and Android Emulator control for interacting, testing, profiling and debugging mobile applications. Always use discovery tools (describe / debugger-component-tree / screenshot) before tapping \u2014 never guess coordinates. On session end: call stop-all-simulator-servers and perform any necessary cleanup. Full guidance is in the argent rule loaded from .claude/rules/argent.md."
18943
+ instructions: "Argent \u2014 iOS Simulator, Android Emulator, and Chromium app control for interacting, testing, profiling and debugging mobile and Chromium applications. Always use discovery tools (describe / debugger-component-tree / screenshot) before tapping \u2014 never guess coordinates. On session end: call stop-all-simulator-servers and perform any necessary cleanup. Full guidance is in the argent rule loaded from .claude/rules/argent.md."
16181
18944
  }
16182
18945
  );
16183
18946
  server.setRequestHandler(ListToolsRequestSchema, async () => {
@@ -16224,7 +18987,7 @@ async function startMcpServer(options) {
16224
18987
  if (params.name === "flow-execute" && result && typeof result === "object" && "flow" in result && "steps" in result) {
16225
18988
  content = await flowRunToMcpContent(result, ctx);
16226
18989
  } else if (params.name === "screenshot-diff" && isScreenshotDiffResult(result)) {
16227
- content = await screenshotDiffToMcpContent(result);
18990
+ content = await screenshotDiffToMcpContent(result, ctx);
16228
18991
  } else {
16229
18992
  content = await toMcpContent(result, outputHint, ctx, params.arguments);
16230
18993
  }
@@ -16312,3 +19075,15 @@ async function startMcpServer(options) {
16312
19075
  export {
16313
19076
  startMcpServer
16314
19077
  };
19078
+ /*! Bundled license information:
19079
+
19080
+ @posthog/core/dist/vendor/uuidv7.mjs:
19081
+ (*! For license information please see uuidv7.mjs.LICENSE.txt *)
19082
+ (**
19083
+ * uuidv7: An experimental implementation of the proposed UUID Version 7
19084
+ *
19085
+ * @license Apache-2.0
19086
+ * @copyright 2021-2023 LiosK
19087
+ * @packageDocumentation
19088
+ *)
19089
+ */