@swmansion/argent 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -102,12 +102,12 @@ var require_code = __commonJS({
102
102
  exports._ = _;
103
103
  var plus = new _Code("+");
104
104
  function str(strs, ...args) {
105
- const expr = [safeStringify(strs[0])];
105
+ const expr = [safeStringify2(strs[0])];
106
106
  let i = 0;
107
107
  while (i < args.length) {
108
108
  expr.push(plus);
109
109
  addCodeArg(expr, args[i]);
110
- expr.push(plus, safeStringify(strs[++i]));
110
+ expr.push(plus, safeStringify2(strs[++i]));
111
111
  }
112
112
  optimize(expr);
113
113
  return new _Code(expr);
@@ -159,16 +159,16 @@ var require_code = __commonJS({
159
159
  }
160
160
  exports.strConcat = strConcat;
161
161
  function interpolate(x) {
162
- 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);
163
163
  }
164
164
  function stringify(x) {
165
- return new _Code(safeStringify(x));
165
+ return new _Code(safeStringify2(x));
166
166
  }
167
167
  exports.stringify = stringify;
168
- function safeStringify(x) {
168
+ function safeStringify2(x) {
169
169
  return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
170
170
  }
171
- exports.safeStringify = safeStringify;
171
+ exports.safeStringify = safeStringify2;
172
172
  function getProperty(key) {
173
173
  return typeof key == "string" && exports.IDENTIFIER.test(key) ? new _Code(`.${key}`) : _`[${key}]`;
174
174
  }
@@ -1201,8 +1201,8 @@ var require_util = __commonJS({
1201
1201
  })(Type || (exports.Type = Type = {}));
1202
1202
  function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
1203
1203
  if (dataProp instanceof codegen_1.Name) {
1204
- const isNumber = dataPropType === Type.Num;
1205
- 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")`;
1206
1206
  }
1207
1207
  return jsPropertySyntax ? (0, codegen_1.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
1208
1208
  }
@@ -2794,11 +2794,11 @@ var require_validate = __commonJS({
2794
2794
  jsonPointer = $data;
2795
2795
  data = names_1.default.rootData;
2796
2796
  } else {
2797
- const matches = RELATIVE_JSON_POINTER.exec($data);
2798
- if (!matches)
2797
+ const matches2 = RELATIVE_JSON_POINTER.exec($data);
2798
+ if (!matches2)
2799
2799
  throw new Error(`Invalid JSON-pointer: ${$data}`);
2800
- const up = +matches[1];
2801
- jsonPointer = matches[2];
2800
+ const up = +matches2[1];
2801
+ jsonPointer = matches2[2];
2802
2802
  if (jsonPointer === "#") {
2803
2803
  if (up >= dataLevel)
2804
2804
  throw new Error(errorMsg("property/index", up));
@@ -3229,8 +3229,8 @@ var require_utils = __commonJS({
3229
3229
  }
3230
3230
  return ind;
3231
3231
  }
3232
- function removeDotSegments(path6) {
3233
- let input = path6;
3232
+ function removeDotSegments(path9) {
3233
+ let input = path9;
3234
3234
  const output = [];
3235
3235
  let nextSlash = -1;
3236
3236
  let len = 0;
@@ -3482,8 +3482,8 @@ var require_schemes = __commonJS({
3482
3482
  wsComponent.secure = void 0;
3483
3483
  }
3484
3484
  if (wsComponent.resourceName) {
3485
- const [path6, query] = wsComponent.resourceName.split("?");
3486
- wsComponent.path = path6 && path6 !== "/" ? path6 : void 0;
3485
+ const [path9, query] = wsComponent.resourceName.split("?");
3486
+ wsComponent.path = path9 && path9 !== "/" ? path9 : void 0;
3487
3487
  wsComponent.query = query;
3488
3488
  wsComponent.resourceName = void 0;
3489
3489
  }
@@ -3495,11 +3495,11 @@ var require_schemes = __commonJS({
3495
3495
  urnComponent.error = "URN can not be parsed";
3496
3496
  return urnComponent;
3497
3497
  }
3498
- const matches = urnComponent.path.match(URN_REG);
3499
- if (matches) {
3498
+ const matches2 = urnComponent.path.match(URN_REG);
3499
+ if (matches2) {
3500
3500
  const scheme = options.scheme || urnComponent.scheme || "urn";
3501
- urnComponent.nid = matches[1].toLowerCase();
3502
- urnComponent.nss = matches[2];
3501
+ urnComponent.nid = matches2[1].toLowerCase();
3502
+ urnComponent.nss = matches2[2];
3503
3503
  const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`;
3504
3504
  const schemeHandler = getSchemeHandler(urnScheme);
3505
3505
  urnComponent.path = void 0;
@@ -3648,49 +3648,49 @@ var require_fast_uri = __commonJS({
3648
3648
  schemelessOptions.skipEscape = true;
3649
3649
  return serialize(resolved, schemelessOptions);
3650
3650
  }
3651
- function resolveComponent(base, relative, options, skipNormalization) {
3651
+ function resolveComponent(base, relative2, options, skipNormalization) {
3652
3652
  const target = {};
3653
3653
  if (!skipNormalization) {
3654
3654
  base = parse3(serialize(base, options), options);
3655
- relative = parse3(serialize(relative, options), options);
3655
+ relative2 = parse3(serialize(relative2, options), options);
3656
3656
  }
3657
3657
  options = options || {};
3658
- if (!options.tolerant && relative.scheme) {
3659
- target.scheme = relative.scheme;
3660
- target.userinfo = relative.userinfo;
3661
- target.host = relative.host;
3662
- target.port = relative.port;
3663
- target.path = removeDotSegments(relative.path || "");
3664
- 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;
3665
3665
  } else {
3666
- if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
3667
- target.userinfo = relative.userinfo;
3668
- target.host = relative.host;
3669
- target.port = relative.port;
3670
- target.path = removeDotSegments(relative.path || "");
3671
- 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;
3672
3672
  } else {
3673
- if (!relative.path) {
3673
+ if (!relative2.path) {
3674
3674
  target.path = base.path;
3675
- if (relative.query !== void 0) {
3676
- target.query = relative.query;
3675
+ if (relative2.query !== void 0) {
3676
+ target.query = relative2.query;
3677
3677
  } else {
3678
3678
  target.query = base.query;
3679
3679
  }
3680
3680
  } else {
3681
- if (relative.path[0] === "/") {
3682
- target.path = removeDotSegments(relative.path);
3681
+ if (relative2.path[0] === "/") {
3682
+ target.path = removeDotSegments(relative2.path);
3683
3683
  } else {
3684
3684
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
3685
- target.path = "/" + relative.path;
3685
+ target.path = "/" + relative2.path;
3686
3686
  } else if (!base.path) {
3687
- target.path = relative.path;
3687
+ target.path = relative2.path;
3688
3688
  } else {
3689
- 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;
3690
3690
  }
3691
3691
  target.path = removeDotSegments(target.path);
3692
3692
  }
3693
- target.query = relative.query;
3693
+ target.query = relative2.query;
3694
3694
  }
3695
3695
  target.userinfo = base.userinfo;
3696
3696
  target.host = base.host;
@@ -3698,7 +3698,7 @@ var require_fast_uri = __commonJS({
3698
3698
  }
3699
3699
  target.scheme = base.scheme;
3700
3700
  }
3701
- target.fragment = relative.fragment;
3701
+ target.fragment = relative2.fragment;
3702
3702
  return target;
3703
3703
  }
3704
3704
  function equal(uriA, uriB, options) {
@@ -3769,8 +3769,8 @@ var require_fast_uri = __commonJS({
3769
3769
  return uriTokens.join("");
3770
3770
  }
3771
3771
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
3772
- function getParseError(parsed, matches) {
3773
- 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] !== "/") {
3774
3774
  return 'URI path must start with "/" when authority is present.';
3775
3775
  }
3776
3776
  if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
@@ -3798,19 +3798,19 @@ var require_fast_uri = __commonJS({
3798
3798
  uri = "//" + uri;
3799
3799
  }
3800
3800
  }
3801
- const matches = uri.match(URI_PARSE);
3802
- if (matches) {
3803
- parsed.scheme = matches[1];
3804
- parsed.userinfo = matches[3];
3805
- parsed.host = matches[4];
3806
- parsed.port = parseInt(matches[5], 10);
3807
- parsed.path = matches[6] || "";
3808
- parsed.query = matches[7];
3809
- 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];
3810
3810
  if (isNaN(parsed.port)) {
3811
- parsed.port = matches[5];
3811
+ parsed.port = matches2[5];
3812
3812
  }
3813
- const parseError = getParseError(parsed, matches);
3813
+ const parseError = getParseError(parsed, matches2);
3814
3814
  if (parseError !== void 0) {
3815
3815
  parsed.error = parsed.error || parseError;
3816
3816
  malformedAuthorityOrPort = true;
@@ -6261,7 +6261,7 @@ var require_discriminator = __commonJS({
6261
6261
  error: error2,
6262
6262
  code(cxt) {
6263
6263
  const { gen, data, schema, parentSchema, it } = cxt;
6264
- const { oneOf } = parentSchema;
6264
+ const { oneOf: oneOf2 } = parentSchema;
6265
6265
  if (!it.opts.discriminator) {
6266
6266
  throw new Error("discriminator: requires discriminator option");
6267
6267
  }
@@ -6270,7 +6270,7 @@ var require_discriminator = __commonJS({
6270
6270
  throw new Error("discriminator: requires propertyName");
6271
6271
  if (schema.mapping)
6272
6272
  throw new Error("discriminator: mapping is not supported");
6273
- if (!oneOf)
6273
+ if (!oneOf2)
6274
6274
  throw new Error("discriminator: requires oneOf keyword");
6275
6275
  const valid = gen.let("valid", false);
6276
6276
  const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(tagName)}`);
@@ -6298,8 +6298,8 @@ var require_discriminator = __commonJS({
6298
6298
  const oneOfMapping = {};
6299
6299
  const topRequired = hasRequired(parentSchema);
6300
6300
  let tagRequired = true;
6301
- for (let i = 0; i < oneOf.length; i++) {
6302
- let sch = oneOf[i];
6301
+ for (let i = 0; i < oneOf2.length; i++) {
6302
+ let sch = oneOf2[i];
6303
6303
  if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) {
6304
6304
  const ref = sch.$ref;
6305
6305
  sch = compile_1.resolveRef.call(it.self, it.schemaEnv.root, it.baseId, ref);
@@ -6650,12 +6650,12 @@ var require_formats = __commonJS({
6650
6650
  var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
6651
6651
  var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
6652
6652
  function date3(str) {
6653
- const matches = DATE.exec(str);
6654
- if (!matches)
6653
+ const matches2 = DATE.exec(str);
6654
+ if (!matches2)
6655
6655
  return false;
6656
- const year = +matches[1];
6657
- const month = +matches[2];
6658
- const day = +matches[3];
6656
+ const year = +matches2[1];
6657
+ const month = +matches2[2];
6658
+ const day = +matches2[3];
6659
6659
  return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && isLeapYear(year) ? 29 : DAYS[month]);
6660
6660
  }
6661
6661
  function compareDate(d1, d2) {
@@ -6670,16 +6670,16 @@ var require_formats = __commonJS({
6670
6670
  var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
6671
6671
  function getTime(strictTimeZone) {
6672
6672
  return function time3(str) {
6673
- const matches = TIME.exec(str);
6674
- if (!matches)
6673
+ const matches2 = TIME.exec(str);
6674
+ if (!matches2)
6675
6675
  return false;
6676
- const hr = +matches[1];
6677
- const min = +matches[2];
6678
- const sec = +matches[3];
6679
- const tz = matches[4];
6680
- const tzSign = matches[5] === "-" ? -1 : 1;
6681
- const tzH = +(matches[6] || 0);
6682
- 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);
6683
6683
  if (tzH > 23 || tzM > 59 || strictTimeZone && !tz)
6684
6684
  return false;
6685
6685
  if (hr <= 23 && min <= 59 && sec < 60)
@@ -6876,12 +6876,12 @@ var require_dist = __commonJS({
6876
6876
  throw new Error(`Unknown format "${name}"`);
6877
6877
  return f;
6878
6878
  };
6879
- function addFormats(ajv, list, fs4, exportName) {
6879
+ function addFormats(ajv, list, fs8, exportName) {
6880
6880
  var _a3;
6881
6881
  var _b;
6882
6882
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
6883
6883
  for (const f of list)
6884
- ajv.addFormat(f, fs4[f]);
6884
+ ajv.addFormat(f, fs8[f]);
6885
6885
  }
6886
6886
  module.exports = exports = formatsPlugin;
6887
6887
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -6891,8 +6891,8 @@ var require_dist = __commonJS({
6891
6891
 
6892
6892
  // ../argent-mcp/src/mcp-server.ts
6893
6893
  import { appendFile, mkdir as mkdir5 } from "node:fs/promises";
6894
- import { dirname as dirname3 } from "node:path";
6895
- import { homedir as homedir4 } from "node:os";
6894
+ import { dirname as dirname4 } from "node:path";
6895
+ import { homedir as homedir5 } from "node:os";
6896
6896
 
6897
6897
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
6898
6898
  import process3 from "node:process";
@@ -7137,10 +7137,10 @@ function mergeDefs(...defs) {
7137
7137
  function cloneDef(schema) {
7138
7138
  return mergeDefs(schema._zod.def);
7139
7139
  }
7140
- function getElementAtPath(obj, path6) {
7141
- if (!path6)
7140
+ function getElementAtPath(obj, path9) {
7141
+ if (!path9)
7142
7142
  return obj;
7143
- return path6.reduce((acc, key) => acc?.[key], obj);
7143
+ return path9.reduce((acc, key) => acc?.[key], obj);
7144
7144
  }
7145
7145
  function promiseAllObject(promisesObj) {
7146
7146
  const keys = Object.keys(promisesObj);
@@ -7549,11 +7549,11 @@ function explicitlyAborted(x, startIndex = 0) {
7549
7549
  }
7550
7550
  return false;
7551
7551
  }
7552
- function prefixIssues(path6, issues) {
7552
+ function prefixIssues(path9, issues) {
7553
7553
  return issues.map((iss) => {
7554
7554
  var _a3;
7555
7555
  (_a3 = iss).path ?? (_a3.path = []);
7556
- iss.path.unshift(path6);
7556
+ iss.path.unshift(path9);
7557
7557
  return iss;
7558
7558
  });
7559
7559
  }
@@ -7700,16 +7700,16 @@ function flattenError(error2, mapper = (issue2) => issue2.message) {
7700
7700
  }
7701
7701
  function formatError(error2, mapper = (issue2) => issue2.message) {
7702
7702
  const fieldErrors = { _errors: [] };
7703
- const processError = (error3, path6 = []) => {
7703
+ const processError = (error3, path9 = []) => {
7704
7704
  for (const issue2 of error3.issues) {
7705
7705
  if (issue2.code === "invalid_union" && issue2.errors.length) {
7706
- issue2.errors.map((issues) => processError({ issues }, [...path6, ...issue2.path]));
7706
+ issue2.errors.map((issues) => processError({ issues }, [...path9, ...issue2.path]));
7707
7707
  } else if (issue2.code === "invalid_key") {
7708
- processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
7708
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
7709
7709
  } else if (issue2.code === "invalid_element") {
7710
- processError({ issues: issue2.issues }, [...path6, ...issue2.path]);
7710
+ processError({ issues: issue2.issues }, [...path9, ...issue2.path]);
7711
7711
  } else {
7712
- const fullpath = [...path6, ...issue2.path];
7712
+ const fullpath = [...path9, ...issue2.path];
7713
7713
  if (fullpath.length === 0) {
7714
7714
  fieldErrors._errors.push(mapper(issue2));
7715
7715
  } else {
@@ -7822,10 +7822,10 @@ var ksuid = /^[A-Za-z0-9]{27}$/;
7822
7822
  var nanoid = /^[a-zA-Z0-9_-]{21}$/;
7823
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)?)?)$/;
7824
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})$/;
7825
- var uuid = (version2) => {
7826
- if (!version2)
7825
+ var uuid = (version3) => {
7826
+ if (!version3)
7827
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)$/;
7828
- 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})$`);
7829
7829
  };
7830
7830
  var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
7831
7831
  var _emoji = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
@@ -8952,13 +8952,13 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
8952
8952
  }
8953
8953
  return propValues;
8954
8954
  });
8955
- const isObject2 = isObject;
8955
+ const isObject3 = isObject;
8956
8956
  const catchall = def.catchall;
8957
8957
  let value;
8958
8958
  inst._zod.parse = (payload, ctx) => {
8959
8959
  value ?? (value = _normalized.value);
8960
8960
  const input = payload.value;
8961
- if (!isObject2(input)) {
8961
+ if (!isObject3(input)) {
8962
8962
  payload.issues.push({
8963
8963
  expected: "object",
8964
8964
  code: "invalid_type",
@@ -9085,7 +9085,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9085
9085
  return (payload, ctx) => fn(shape, payload, ctx);
9086
9086
  };
9087
9087
  let fastpass;
9088
- const isObject2 = isObject;
9088
+ const isObject3 = isObject;
9089
9089
  const jit = !globalConfig.jitless;
9090
9090
  const allowsEval2 = allowsEval;
9091
9091
  const fastEnabled = jit && allowsEval2.value;
@@ -9094,7 +9094,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9094
9094
  inst._zod.parse = (payload, ctx) => {
9095
9095
  value ?? (value = _normalized.value);
9096
9096
  const input = payload.value;
9097
- if (!isObject2(input)) {
9097
+ if (!isObject3(input)) {
9098
9098
  payload.issues.push({
9099
9099
  expected: "object",
9100
9100
  code: "invalid_type",
@@ -10356,12 +10356,12 @@ function _uppercase(params) {
10356
10356
  });
10357
10357
  }
10358
10358
  // @__NO_SIDE_EFFECTS__
10359
- function _includes(includes, params) {
10359
+ function _includes(includes2, params) {
10360
10360
  return new $ZodCheckIncludes({
10361
10361
  check: "string_format",
10362
10362
  format: "includes",
10363
10363
  ...normalizeParams(params),
10364
- includes
10364
+ includes: includes2
10365
10365
  });
10366
10366
  }
10367
10367
  // @__NO_SIDE_EFFECTS__
@@ -15927,6 +15927,2617 @@ function getDeviceIdFromArgs(args) {
15927
15927
  return void 0;
15928
15928
  }
15929
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
+ VEGA_CLI_COMMAND_FAILED: "VEGA_CLI_COMMAND_FAILED",
17554
+ VEGA_INPUT_UNAVAILABLE: "VEGA_INPUT_UNAVAILABLE",
17555
+ ANDROID_ADB_NOT_FOUND: "ANDROID_ADB_NOT_FOUND",
17556
+ ANDROID_EMULATOR_NOT_FOUND: "ANDROID_EMULATOR_NOT_FOUND",
17557
+ ANDROID_ADB_COMMAND_FAILED: "ANDROID_ADB_COMMAND_FAILED",
17558
+ ANDROID_ADB_BOOT_TERMINAL_STATE: "ANDROID_ADB_BOOT_TERMINAL_STATE",
17559
+ ANDROID_ADB_BOOT_TIMEOUT: "ANDROID_ADB_BOOT_TIMEOUT",
17560
+ SIMULATOR_NETWORK_TIMEOUT: "SIMULATOR_NETWORK_TIMEOUT",
17561
+ SIMULATOR_NETWORK_CONNECTION_REFUSED: "SIMULATOR_NETWORK_CONNECTION_REFUSED",
17562
+ SIMULATOR_NETWORK_CONNECTION_RESET: "SIMULATOR_NETWORK_CONNECTION_RESET",
17563
+ SIMULATOR_NETWORK_ERROR: "SIMULATOR_NETWORK_ERROR",
17564
+ SIMULATOR_NON_JSON_RESPONSE: "SIMULATOR_NON_JSON_RESPONSE",
17565
+ SIMULATOR_HTTP_ERROR_RESPONSE: "SIMULATOR_HTTP_ERROR_RESPONSE",
17566
+ SIMULATOR_MISSING_RESPONSE_FIELDS: "SIMULATOR_MISSING_RESPONSE_FIELDS",
17567
+ SIMULATOR_SERVER_FACTORY_OPTIONS_MISSING: "SIMULATOR_SERVER_FACTORY_OPTIONS_MISSING",
17568
+ SIMULATOR_SERVER_DEVICE_ID_INVALID: "SIMULATOR_SERVER_DEVICE_ID_INVALID",
17569
+ SIMULATOR_SERVER_READY_EXITED: "SIMULATOR_SERVER_READY_EXITED",
17570
+ SIMULATOR_SERVER_READY_TIMEOUT: "SIMULATOR_SERVER_READY_TIMEOUT",
17571
+ SIMULATOR_SERVER_PROCESS_ERROR: "SIMULATOR_SERVER_PROCESS_ERROR",
17572
+ SIMULATOR_SERVER_TERMINATED: "SIMULATOR_SERVER_TERMINATED",
17573
+ AX_QUERY_TIMEOUT: "AX_QUERY_TIMEOUT",
17574
+ AX_DAEMON_READY_TIMEOUT: "AX_DAEMON_READY_TIMEOUT",
17575
+ AX_DAEMON_EXITED_BEFORE_READY: "AX_DAEMON_EXITED_BEFORE_READY",
17576
+ AX_DAEMON_PROCESS_ERROR: "AX_DAEMON_PROCESS_ERROR",
17577
+ AX_FACTORY_OPTIONS_MISSING: "AX_FACTORY_OPTIONS_MISSING",
17578
+ AX_WRONG_PLATFORM: "AX_WRONG_PLATFORM",
17579
+ AX_DEVICE_ID_INVALID: "AX_DEVICE_ID_INVALID",
17580
+ AX_DESCRIBE_ERROR: "AX_DESCRIBE_ERROR",
17581
+ AX_QUERY_FAILED: "AX_QUERY_FAILED",
17582
+ ANDROID_LAUNCH_ACTIVITY_RESOLVE_FAILED: "ANDROID_LAUNCH_ACTIVITY_RESOLVE_FAILED",
17583
+ ANDROID_LAUNCH_AM_START_FAILED: "ANDROID_LAUNCH_AM_START_FAILED",
17584
+ ANDROID_OPEN_URL_FAILED: "ANDROID_OPEN_URL_FAILED",
17585
+ ANDROID_REINSTALL_INSTALL_FAILED: "ANDROID_REINSTALL_INSTALL_FAILED",
17586
+ ANDROID_RESTART_FAILED: "ANDROID_RESTART_FAILED",
17587
+ IOS_LAUNCH_SIMCTL_FAILED: "IOS_LAUNCH_SIMCTL_FAILED",
17588
+ IOS_OPEN_URL_FAILED: "IOS_OPEN_URL_FAILED",
17589
+ IOS_REINSTALL_INSTALL_FAILED: "IOS_REINSTALL_INSTALL_FAILED",
17590
+ IOS_RESTART_LAUNCH_FAILED: "IOS_RESTART_LAUNCH_FAILED",
17591
+ NATIVE_DEVTOOLS_DESCRIBE_ERROR: "NATIVE_DEVTOOLS_DESCRIBE_ERROR",
17592
+ NATIVE_DEVTOOLS_VIEW_AT_POINT_ERROR: "NATIVE_DEVTOOLS_VIEW_AT_POINT_ERROR",
17593
+ NATIVE_DEVTOOLS_USER_INTERACTABLE_VIEW_AT_POINT_ERROR: "NATIVE_DEVTOOLS_USER_INTERACTABLE_VIEW_AT_POINT_ERROR",
17594
+ NATIVE_DEVTOOLS_FIND_VIEWS_ERROR: "NATIVE_DEVTOOLS_FIND_VIEWS_ERROR",
17595
+ NATIVE_DEVTOOLS_FACTORY_OPTIONS_MISSING: "NATIVE_DEVTOOLS_FACTORY_OPTIONS_MISSING",
17596
+ NATIVE_DEVTOOLS_WRONG_PLATFORM: "NATIVE_DEVTOOLS_WRONG_PLATFORM",
17597
+ NATIVE_DEVTOOLS_NOT_CONNECTED: "NATIVE_DEVTOOLS_NOT_CONNECTED",
17598
+ NATIVE_DEVTOOLS_RPC_TIMEOUT: "NATIVE_DEVTOOLS_RPC_TIMEOUT",
17599
+ NATIVE_DEVTOOLS_RPC_ERROR: "NATIVE_DEVTOOLS_RPC_ERROR",
17600
+ NATIVE_DEVTOOLS_SERVICE_DISPOSED: "NATIVE_DEVTOOLS_SERVICE_DISPOSED",
17601
+ NATIVE_TARGET_NO_CONNECTED_APPS: "NATIVE_TARGET_NO_CONNECTED_APPS",
17602
+ NATIVE_TARGET_SINGLE_APP_NOT_FOREGROUND: "NATIVE_TARGET_SINGLE_APP_NOT_FOREGROUND",
17603
+ NATIVE_TARGET_MULTIPLE_APPS_AMBIGUOUS: "NATIVE_TARGET_MULTIPLE_APPS_AMBIGUOUS",
17604
+ ANDROID_DEVTOOLS_ADB_NOT_FOUND: "ANDROID_DEVTOOLS_ADB_NOT_FOUND",
17605
+ ANDROID_DEVTOOLS_ADB_FORWARD_UNEXPECTED: "ANDROID_DEVTOOLS_ADB_FORWARD_UNEXPECTED",
17606
+ ANDROID_DEVTOOLS_HELPER_EXITED_BEFORE_READY: "ANDROID_DEVTOOLS_HELPER_EXITED_BEFORE_READY",
17607
+ ANDROID_DEVTOOLS_HELPER_PROCESS_ERROR: "ANDROID_DEVTOOLS_HELPER_PROCESS_ERROR",
17608
+ ANDROID_DEVTOOLS_HELPER_READY_TIMEOUT: "ANDROID_DEVTOOLS_HELPER_READY_TIMEOUT",
17609
+ ANDROID_DEVTOOLS_FACTORY_OPTIONS_MISSING: "ANDROID_DEVTOOLS_FACTORY_OPTIONS_MISSING",
17610
+ ANDROID_DEVTOOLS_WRONG_PLATFORM: "ANDROID_DEVTOOLS_WRONG_PLATFORM",
17611
+ ANDROID_DEVTOOLS_DEVICE_ID_INVALID: "ANDROID_DEVTOOLS_DEVICE_ID_INVALID",
17612
+ ANDROID_DEVTOOLS_HELPER_TERMINATED: "ANDROID_DEVTOOLS_HELPER_TERMINATED",
17613
+ ANDROID_DEVTOOLS_RPC_CLIENT_CLOSED: "ANDROID_DEVTOOLS_RPC_CLIENT_CLOSED",
17614
+ ANDROID_DEVTOOLS_RPC_ERROR: "ANDROID_DEVTOOLS_RPC_ERROR",
17615
+ ANDROID_DEVTOOLS_RPC_TIMEOUT: "ANDROID_DEVTOOLS_RPC_TIMEOUT",
17616
+ ANDROID_DEVTOOLS_SOCKET_CLOSED: "ANDROID_DEVTOOLS_SOCKET_CLOSED",
17617
+ ANDROID_SCREEN_SIZE_PARSE_FAILED: "ANDROID_SCREEN_SIZE_PARSE_FAILED",
17618
+ ANDROID_SCREEN_SIZE_NON_POSITIVE: "ANDROID_SCREEN_SIZE_NON_POSITIVE",
17619
+ ANDROID_UIAUTOMATOR_PARSE_FAILED: "ANDROID_UIAUTOMATOR_PARSE_FAILED",
17620
+ DEBUGGER_METRO_NOT_RUNNING: "DEBUGGER_METRO_NOT_RUNNING",
17621
+ DEBUGGER_METRO_PROJECT_ROOT_MISSING: "DEBUGGER_METRO_PROJECT_ROOT_MISSING",
17622
+ DEBUGGER_METRO_NO_TARGETS: "DEBUGGER_METRO_NO_TARGETS",
17623
+ DEBUGGER_CDP_RUNTIME_EXCEPTION: "DEBUGGER_CDP_RUNTIME_EXCEPTION",
17624
+ DEBUGGER_CDP_BINDING_TIMEOUT: "DEBUGGER_CDP_BINDING_TIMEOUT",
17625
+ DEBUGGER_CDP_PROTOCOL_ERROR: "DEBUGGER_CDP_PROTOCOL_ERROR",
17626
+ DEBUGGER_RELOAD_FAILED: "DEBUGGER_RELOAD_FAILED",
17627
+ JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED: "JS_RUNTIME_CONSOLE_SERVER_BIND_FAILED",
17628
+ JS_RUNTIME_PAYLOAD_INVALID: "JS_RUNTIME_PAYLOAD_INVALID",
17629
+ JS_RUNTIME_PAYLOAD_DEVICE_MISSING: "JS_RUNTIME_PAYLOAD_DEVICE_MISSING",
17630
+ JS_RUNTIME_PAYLOAD_PORT_INVALID: "JS_RUNTIME_PAYLOAD_PORT_INVALID",
17631
+ JS_RUNTIME_CDP_DISCONNECTED: "JS_RUNTIME_CDP_DISCONNECTED",
17632
+ NETWORK_INSPECTOR_CDP_DISCONNECTED: "NETWORK_INSPECTOR_CDP_DISCONNECTED",
17633
+ REACT_PROFILER_NO_ACTIVE_SESSION: "REACT_PROFILER_NO_ACTIVE_SESSION",
17634
+ REACT_PROFILER_CDP_CONNECTION_LOST: "REACT_PROFILER_CDP_CONNECTION_LOST",
17635
+ REACT_PROFILER_NO_CPU_PROFILE: "REACT_PROFILER_NO_CPU_PROFILE",
17636
+ REACT_PROFILER_RUNTIME_EXCEPTION: "REACT_PROFILER_RUNTIME_EXCEPTION",
17637
+ REACT_PROFILER_NO_RUNTIME_DATA: "REACT_PROFILER_NO_RUNTIME_DATA",
17638
+ REACT_PROFILER_SESSION_PAYLOAD_INVALID: "REACT_PROFILER_SESSION_PAYLOAD_INVALID",
17639
+ REACT_PROFILER_SESSION_PAYLOAD_DEVICE_MISSING: "REACT_PROFILER_SESSION_PAYLOAD_DEVICE_MISSING",
17640
+ REACT_PROFILER_SESSION_CDP_DISCONNECTED: "REACT_PROFILER_SESSION_CDP_DISCONNECTED",
17641
+ REACT_PROFILER_CDP_NOT_CONNECTED: "REACT_PROFILER_CDP_NOT_CONNECTED",
17642
+ REACT_PROFILER_STATE_READ_FAILED: "REACT_PROFILER_STATE_READ_FAILED",
17643
+ REACT_PROFILER_DEVTOOLS_HOOK_MISSING: "REACT_PROFILER_DEVTOOLS_HOOK_MISSING",
17644
+ REACT_PROFILER_DEVTOOLS_BACKEND_ATTACH_FAILED: "REACT_PROFILER_DEVTOOLS_BACKEND_ATTACH_FAILED",
17645
+ REACT_PROFILER_DEVTOOLS_BACKEND_BOOTSTRAP_FAILED: "REACT_PROFILER_DEVTOOLS_BACKEND_BOOTSTRAP_FAILED",
17646
+ REACT_PROFILER_DEVTOOLS_RENDERER_MISSING: "REACT_PROFILER_DEVTOOLS_RENDERER_MISSING",
17647
+ REACT_PROFILER_START_FAILED: "REACT_PROFILER_START_FAILED",
17648
+ REACT_PROFILER_START_VERIFY_FAILED: "REACT_PROFILER_START_VERIFY_FAILED",
17649
+ REACT_PROFILER_HOOK_ERROR: "REACT_PROFILER_HOOK_ERROR",
17650
+ REACT_PROFILER_ANALYZE_NO_DATA: "REACT_PROFILER_ANALYZE_NO_DATA",
17651
+ NATIVE_PROFILER_FACTORY_OPTIONS_MISSING: "NATIVE_PROFILER_FACTORY_OPTIONS_MISSING",
17652
+ NATIVE_PROFILER_WRONG_PLATFORM: "NATIVE_PROFILER_WRONG_PLATFORM",
17653
+ NATIVE_PROFILER_APP_PROCESS_LIST_FAILED: "NATIVE_PROFILER_APP_PROCESS_LIST_FAILED",
17654
+ NATIVE_PROFILER_APP_LIST_FAILED: "NATIVE_PROFILER_APP_LIST_FAILED",
17655
+ NATIVE_PROFILER_NO_RUNNING_APPS: "NATIVE_PROFILER_NO_RUNNING_APPS",
17656
+ NATIVE_PROFILER_NO_RUNNING_USER_APPS: "NATIVE_PROFILER_NO_RUNNING_USER_APPS",
17657
+ NATIVE_PROFILER_MULTIPLE_RUNNING_USER_APPS: "NATIVE_PROFILER_MULTIPLE_RUNNING_USER_APPS",
17658
+ NATIVE_PROFILER_SESSION_ALREADY_RUNNING: "NATIVE_PROFILER_SESSION_ALREADY_RUNNING",
17659
+ NATIVE_PROFILER_XCTRACE_NO_PID: "NATIVE_PROFILER_XCTRACE_NO_PID",
17660
+ NATIVE_PROFILER_XCTRACE_PROCESS_NOT_FOUND: "NATIVE_PROFILER_XCTRACE_PROCESS_NOT_FOUND",
17661
+ NATIVE_PROFILER_XCTRACE_READY_EXITED: "NATIVE_PROFILER_XCTRACE_READY_EXITED",
17662
+ NATIVE_PROFILER_XCTRACE_PROCESS_ERROR: "NATIVE_PROFILER_XCTRACE_PROCESS_ERROR",
17663
+ NATIVE_PROFILER_XCTRACE_READY_TIMEOUT: "NATIVE_PROFILER_XCTRACE_READY_TIMEOUT",
17664
+ NATIVE_PROFILER_NO_ACTIVE_SESSION: "NATIVE_PROFILER_NO_ACTIVE_SESSION",
17665
+ FLOW_PROJECT_ROOT_REQUIRED: "FLOW_PROJECT_ROOT_REQUIRED",
17666
+ FLOW_NO_ACTIVE_RECORDING: "FLOW_NO_ACTIVE_RECORDING",
17667
+ FLOW_FILE_INVALID: "FLOW_FILE_INVALID",
17668
+ FLOW_ENTRY_UNRECOGNIZED: "FLOW_ENTRY_UNRECOGNIZED",
17669
+ PROFILER_QUERY_MODE_INVALID: "PROFILER_QUERY_MODE_INVALID",
17670
+ PROFILER_QUERY_REQUIRED_PARAM_MISSING: "PROFILER_QUERY_REQUIRED_PARAM_MISSING",
17671
+ PROFILER_DATA_NOT_LOADED: "PROFILER_DATA_NOT_LOADED",
17672
+ PROFILER_NATIVE_TRACE_MISSING: "PROFILER_NATIVE_TRACE_MISSING",
17673
+ BOOT_DEVICE_TARGET_SELECTION_INVALID: "BOOT_DEVICE_TARGET_SELECTION_INVALID",
17674
+ BOOT_IOS_UNSUPPORTED_HOST: "BOOT_IOS_UNSUPPORTED_HOST",
17675
+ BOOT_ANDROID_NO_AVDS: "BOOT_ANDROID_NO_AVDS",
17676
+ BOOT_ANDROID_AVD_NOT_FOUND: "BOOT_ANDROID_AVD_NOT_FOUND",
17677
+ BOOT_ANDROID_ADB_UNAVAILABLE: "BOOT_ANDROID_ADB_UNAVAILABLE",
17678
+ BOOT_ANDROID_GPU_MODE_INVALID: "BOOT_ANDROID_GPU_MODE_INVALID",
17679
+ BOOT_ANDROID_ADB_REGISTER_TIMEOUT: "BOOT_ANDROID_ADB_REGISTER_TIMEOUT",
17680
+ BOOT_ANDROID_HOT_BOOT_FRAME_UNUSABLE: "BOOT_ANDROID_HOT_BOOT_FRAME_UNUSABLE",
17681
+ BOOT_ANDROID_FIRST_FRAME_TIMEOUT: "BOOT_ANDROID_FIRST_FRAME_TIMEOUT",
17682
+ BOOT_ANDROID_PACKAGE_MANAGER_UNAVAILABLE: "BOOT_ANDROID_PACKAGE_MANAGER_UNAVAILABLE",
17683
+ BOOT_ANDROID_COLD_BOOT_FAILED: "BOOT_ANDROID_COLD_BOOT_FAILED"
17684
+ };
17685
+
17686
+ // ../registry/src/errors.ts
17687
+ var FAILURE_AREAS = ["cli", "http", "registry", "tool_server", "installer"];
17688
+ var FAILURE_KINDS = [
17689
+ "validation",
17690
+ "not_found",
17691
+ "dependency_missing",
17692
+ "unsupported",
17693
+ "not_implemented",
17694
+ "timeout",
17695
+ "network",
17696
+ "subprocess",
17697
+ "crash",
17698
+ "unknown"
17699
+ ];
17700
+ var FAILURE_COMMANDS = [
17701
+ "adb",
17702
+ "emulator",
17703
+ "vega",
17704
+ "xcrun_simctl",
17705
+ "xctrace",
17706
+ "native_devtools",
17707
+ "android_devtools",
17708
+ "ax_service",
17709
+ "simulator_server",
17710
+ "cdp",
17711
+ "npm",
17712
+ "npx",
17713
+ "unknown"
17714
+ ];
17715
+ var FAILURE_SIGNAL_NAMES = [
17716
+ "SIGABRT",
17717
+ "SIGHUP",
17718
+ "SIGINT",
17719
+ "SIGKILL",
17720
+ "SIGQUIT",
17721
+ "SIGTERM"
17722
+ ];
17723
+ var FAILURE_SPAWN_CODES = ["EACCES", "ENOENT", "EPERM", "ETIMEDOUT"];
17724
+ var NETWORK_FAILURES = [
17725
+ "timeout",
17726
+ "connection_refused",
17727
+ "connection_reset",
17728
+ "invalid_response",
17729
+ "other"
17730
+ ];
17731
+ var FALLBACK_SIGNAL = {
17732
+ error_code: FAILURE_CODES.ARGENT_UNCLASSIFIED_FAILURE,
17733
+ failure_stage: "unclassified",
17734
+ failure_area: "registry",
17735
+ error_kind: "unknown"
17736
+ };
17737
+ var FAILURE_SIGNAL_NAME_SET = new Set(FAILURE_SIGNAL_NAMES);
17738
+ var FAILURE_SPAWN_CODE_SET = new Set(FAILURE_SPAWN_CODES);
17739
+
17740
+ // ../registry/src/registry.ts
17741
+ import { randomUUID as randomUUID2 } from "node:crypto";
17742
+
17743
+ // ../telemetry/src/events.ts
17744
+ var PLATFORMS = ["ios", "android", "chromium", "vega"];
17745
+
17746
+ // ../telemetry/src/ai-identity.ts
17747
+ var AI_CLIENTS = [
17748
+ "codex",
17749
+ "claude_code",
17750
+ "cursor",
17751
+ "gemini",
17752
+ "vscode",
17753
+ "windsurf",
17754
+ "zed",
17755
+ "opencode",
17756
+ "copilot",
17757
+ "other"
17758
+ ];
17759
+ var RUNTIME_CLIENT_PATTERNS = [
17760
+ [/^codex-mcp-client\b/, "codex"],
17761
+ [/^claude-code\b/, "claude_code"],
17762
+ [/^cursor\b/, "cursor"],
17763
+ [/^gemini-cli-mcp-client\b/, "gemini"],
17764
+ [/^visual studio code\b/, "vscode"],
17765
+ [/^code - oss\b/, "vscode"],
17766
+ [/^windsurf\b/, "windsurf"],
17767
+ [/^zed\b/, "zed"],
17768
+ [/^opencode\b/, "opencode"],
17769
+ [/^github-copilot-developer\b/, "copilot"]
17770
+ ];
17771
+ function canonicalizeAiClient(value) {
17772
+ if (typeof value !== "string") return void 0;
17773
+ const lower = value.trim().toLowerCase();
17774
+ if (!lower) return void 0;
17775
+ for (const [pattern, slug] of RUNTIME_CLIENT_PATTERNS) {
17776
+ if (pattern.test(lower)) return slug;
17777
+ }
17778
+ return void 0;
17779
+ }
17780
+
17781
+ // ../telemetry/src/sanitize.ts
17782
+ var oneOf = (opts) => (v) => typeof v === "string" && opts.includes(v) ? v : void 0;
17783
+ var matches = (re, max = 80) => (v) => typeof v === "string" && v.length <= max && re.test(v) ? v : void 0;
17784
+ var finiteNonNeg = (max = 2 ** 31) => (v) => typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= max ? v : void 0;
17785
+ var bool = (v) => typeof v === "boolean" ? v : void 0;
17786
+ var arrayOf = (elem, maxLen = 16) => (v) => {
17787
+ if (!Array.isArray(v)) return void 0;
17788
+ if (v.length > maxLen) return void 0;
17789
+ const out = [];
17790
+ for (const e of v) {
17791
+ const cleaned = elem(e);
17792
+ if (cleaned === void 0) return void 0;
17793
+ out.push(cleaned);
17794
+ }
17795
+ return out;
17796
+ };
17797
+ var TOOL_NAME = matches(/^[a-z][a-z0-9_-]{0,63}$/, 64);
17798
+ var PLATFORM = oneOf(PLATFORMS);
17799
+ var UUID = matches(
17800
+ /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,
17801
+ 36
17802
+ );
17803
+ var PACKAGE_MANAGER = oneOf(["npm", "yarn", "pnpm", "bun", "unknown"]);
17804
+ var PACKAGE_ACTION_TRIGGER = oneOf(["init", "update", "mcp_update"]);
17805
+ var PACKAGE_ACTION = oneOf([
17806
+ "fresh_install",
17807
+ "already_installed",
17808
+ "init_triggered_update",
17809
+ "no_update",
17810
+ "update_skipped",
17811
+ "update_failed",
17812
+ "standalone_update",
17813
+ "standalone_install",
17814
+ "mcp_update"
17815
+ ]);
17816
+ var ADAPTER_NAME = matches(/^[a-z][a-z0-9-]{0,63}$/, 64);
17817
+ var COUNT = finiteNonNeg();
17818
+ var DURATION_MS = finiteNonNeg();
17819
+ var MAJOR_VERSION = finiteNonNeg(9999);
17820
+ var FAILURE_CODE_VALUES = new Set(Object.values(FAILURE_CODES));
17821
+ var ERROR_CODE = (v) => typeof v === "string" && FAILURE_CODE_VALUES.has(v) ? v : void 0;
17822
+ var FAILURE_STAGE = matches(/^[a-z][a-z0-9_]{1,79}$/, 80);
17823
+ var FAILURE_AREA = oneOf(FAILURE_AREAS);
17824
+ var ERROR_KIND = oneOf(FAILURE_KINDS);
17825
+ var FAILURE_COMMAND = oneOf(FAILURE_COMMANDS);
17826
+ var FAILURE_EXIT_CODE = finiteNonNeg(255);
17827
+ var FAILURE_SIGNAL_NAME = oneOf(FAILURE_SIGNAL_NAMES);
17828
+ var FAILURE_SPAWN_CODE = oneOf(FAILURE_SPAWN_CODES);
17829
+ var NETWORK_FAILURE = oneOf(NETWORK_FAILURES);
17830
+ var AI_CLIENT = oneOf(AI_CLIENTS);
17831
+ var AI_TELEMETRY = {
17832
+ ai_client: AI_CLIENT
17833
+ };
17834
+ var FAILURE_SIGNAL = {
17835
+ error_code: ERROR_CODE,
17836
+ failure_stage: FAILURE_STAGE,
17837
+ failure_area: FAILURE_AREA,
17838
+ error_kind: ERROR_KIND,
17839
+ failure_command: FAILURE_COMMAND,
17840
+ failure_exit_code: FAILURE_EXIT_CODE,
17841
+ failure_signal: FAILURE_SIGNAL_NAME,
17842
+ failure_spawn_code: FAILURE_SPAWN_CODE,
17843
+ network_failure: NETWORK_FAILURE
17844
+ };
17845
+ var ALLOWED = {
17846
+ "installation:cli_init_start": {
17847
+ package_manager: PACKAGE_MANAGER,
17848
+ is_non_interactive: bool
17849
+ },
17850
+ "installation:cli_init_complete": {
17851
+ duration_ms: DURATION_MS,
17852
+ is_success: bool,
17853
+ editors_configured_count: COUNT,
17854
+ ...FAILURE_SIGNAL
17855
+ },
17856
+ "installation:cli_init_cancel": {
17857
+ step: oneOf(["global_install", "editors", "scope", "skills", "allowlist"])
17858
+ },
17859
+ "installation:global_install_decision": {
17860
+ // `from_tar` is intentionally absent; the installer skips that dev path.
17861
+ decision: oneOf(["install", "cancel", "already_installed"])
17862
+ },
17863
+ "installation:update_decision": {
17864
+ from_major: MAJOR_VERSION,
17865
+ to_major: MAJOR_VERSION,
17866
+ decision: oneOf(["update", "skip", "no_update"])
17867
+ },
17868
+ "installation:editors_select": {
17869
+ editors: arrayOf(ADAPTER_NAME),
17870
+ detected_editor_count: COUNT,
17871
+ scope: oneOf(["local", "global", "custom"])
17872
+ },
17873
+ "installation:allowlist_decision": {
17874
+ is_enabled: bool
17875
+ },
17876
+ "installation:skill_install": {
17877
+ method: oneOf(["default", "interactive", "manual"]),
17878
+ is_online: bool,
17879
+ has_offline_cache: bool,
17880
+ outcome: oneOf(["success", "failure", "skipped"])
17881
+ },
17882
+ "installation:skill_refresh_result": {
17883
+ is_success: bool,
17884
+ scope_count: COUNT,
17885
+ synced_count: COUNT,
17886
+ pruned_count: COUNT,
17887
+ failed_count: COUNT,
17888
+ ...FAILURE_SIGNAL
17889
+ },
17890
+ "installation:package_action": {
17891
+ trigger: PACKAGE_ACTION_TRIGGER,
17892
+ action: PACKAGE_ACTION,
17893
+ is_success: bool,
17894
+ duration_ms: DURATION_MS,
17895
+ ...FAILURE_SIGNAL
17896
+ },
17897
+ "installation:cli_update_start": {},
17898
+ "installation:cli_update_complete": {
17899
+ duration_ms: DURATION_MS
17900
+ },
17901
+ "installation:cli_update_fail": {
17902
+ duration_ms: DURATION_MS,
17903
+ ...FAILURE_SIGNAL
17904
+ },
17905
+ "installation:cli_uninstall_start": {},
17906
+ "installation:cli_uninstall_complete": {
17907
+ has_pruned_content: bool,
17908
+ has_uninstalled_package: bool,
17909
+ ...FAILURE_SIGNAL
17910
+ },
17911
+ "tool:invoke": {
17912
+ tool: TOOL_NAME,
17913
+ tool_invocation_id: UUID,
17914
+ platform: PLATFORM,
17915
+ ...AI_TELEMETRY
17916
+ },
17917
+ "tool:complete": {
17918
+ tool: TOOL_NAME,
17919
+ tool_invocation_id: UUID,
17920
+ platform: PLATFORM,
17921
+ duration_ms: DURATION_MS,
17922
+ ...AI_TELEMETRY
17923
+ },
17924
+ "tool:fail": {
17925
+ tool: TOOL_NAME,
17926
+ tool_invocation_id: UUID,
17927
+ platform: PLATFORM,
17928
+ duration_ms: DURATION_MS,
17929
+ ...FAILURE_SIGNAL,
17930
+ ...AI_TELEMETRY
17931
+ },
17932
+ "cli:run_fail": {
17933
+ tool: TOOL_NAME,
17934
+ duration_ms: DURATION_MS,
17935
+ ...FAILURE_SIGNAL
17936
+ },
17937
+ "toolserver:start": {},
17938
+ "toolserver:stop": {
17939
+ reason: oneOf(["idle", "signal", "crash"]),
17940
+ uptime_ms: DURATION_MS,
17941
+ total_tool_calls: COUNT,
17942
+ ...FAILURE_SIGNAL
17943
+ }
17944
+ };
17945
+
17946
+ // ../telemetry/src/base-props.ts
17947
+ import { randomUUID as randomUUID3 } from "node:crypto";
17948
+
17949
+ // ../../node_modules/ci-info/vendors.json
17950
+ var vendors_default = [
17951
+ {
17952
+ name: "Agola CI",
17953
+ constant: "AGOLA",
17954
+ env: "AGOLA_GIT_REF",
17955
+ pr: "AGOLA_PULL_REQUEST_ID"
17956
+ },
17957
+ {
17958
+ name: "Alpic",
17959
+ constant: "ALPIC",
17960
+ env: "ALPIC_HOST"
17961
+ },
17962
+ {
17963
+ name: "Appcircle",
17964
+ constant: "APPCIRCLE",
17965
+ env: "AC_APPCIRCLE",
17966
+ pr: {
17967
+ env: "AC_GIT_PR",
17968
+ ne: "false"
17969
+ }
17970
+ },
17971
+ {
17972
+ name: "AppVeyor",
17973
+ constant: "APPVEYOR",
17974
+ env: "APPVEYOR",
17975
+ pr: "APPVEYOR_PULL_REQUEST_NUMBER"
17976
+ },
17977
+ {
17978
+ name: "AWS CodeBuild",
17979
+ constant: "CODEBUILD",
17980
+ env: "CODEBUILD_BUILD_ARN",
17981
+ pr: {
17982
+ env: "CODEBUILD_WEBHOOK_EVENT",
17983
+ any: [
17984
+ "PULL_REQUEST_CREATED",
17985
+ "PULL_REQUEST_UPDATED",
17986
+ "PULL_REQUEST_REOPENED"
17987
+ ]
17988
+ }
17989
+ },
17990
+ {
17991
+ name: "Azure Pipelines",
17992
+ constant: "AZURE_PIPELINES",
17993
+ env: "TF_BUILD",
17994
+ pr: {
17995
+ BUILD_REASON: "PullRequest"
17996
+ }
17997
+ },
17998
+ {
17999
+ name: "Bamboo",
18000
+ constant: "BAMBOO",
18001
+ env: "bamboo_planKey"
18002
+ },
18003
+ {
18004
+ name: "Bitbucket Pipelines",
18005
+ constant: "BITBUCKET",
18006
+ env: "BITBUCKET_COMMIT",
18007
+ pr: "BITBUCKET_PR_ID"
18008
+ },
18009
+ {
18010
+ name: "Bitrise",
18011
+ constant: "BITRISE",
18012
+ env: "BITRISE_IO",
18013
+ pr: "BITRISE_PULL_REQUEST"
18014
+ },
18015
+ {
18016
+ name: "Buddy",
18017
+ constant: "BUDDY",
18018
+ env: "BUDDY_WORKSPACE_ID",
18019
+ pr: "BUDDY_EXECUTION_PULL_REQUEST_ID"
18020
+ },
18021
+ {
18022
+ name: "Buildkite",
18023
+ constant: "BUILDKITE",
18024
+ env: "BUILDKITE",
18025
+ pr: {
18026
+ env: "BUILDKITE_PULL_REQUEST",
18027
+ ne: "false"
18028
+ }
18029
+ },
18030
+ {
18031
+ name: "CircleCI",
18032
+ constant: "CIRCLE",
18033
+ env: "CIRCLECI",
18034
+ pr: "CIRCLE_PULL_REQUEST"
18035
+ },
18036
+ {
18037
+ name: "Cirrus CI",
18038
+ constant: "CIRRUS",
18039
+ env: "CIRRUS_CI",
18040
+ pr: "CIRRUS_PR"
18041
+ },
18042
+ {
18043
+ name: "Cloudflare Pages",
18044
+ constant: "CLOUDFLARE_PAGES",
18045
+ env: "CF_PAGES"
18046
+ },
18047
+ {
18048
+ name: "Cloudflare Workers",
18049
+ constant: "CLOUDFLARE_WORKERS",
18050
+ env: "WORKERS_CI"
18051
+ },
18052
+ {
18053
+ name: "Codefresh",
18054
+ constant: "CODEFRESH",
18055
+ env: "CF_BUILD_ID",
18056
+ pr: {
18057
+ any: [
18058
+ "CF_PULL_REQUEST_NUMBER",
18059
+ "CF_PULL_REQUEST_ID"
18060
+ ]
18061
+ }
18062
+ },
18063
+ {
18064
+ name: "Codemagic",
18065
+ constant: "CODEMAGIC",
18066
+ env: "CM_BUILD_ID",
18067
+ pr: "CM_PULL_REQUEST"
18068
+ },
18069
+ {
18070
+ name: "Codeship",
18071
+ constant: "CODESHIP",
18072
+ env: {
18073
+ CI_NAME: "codeship"
18074
+ }
18075
+ },
18076
+ {
18077
+ name: "Drone",
18078
+ constant: "DRONE",
18079
+ env: "DRONE",
18080
+ pr: {
18081
+ DRONE_BUILD_EVENT: "pull_request"
18082
+ }
18083
+ },
18084
+ {
18085
+ name: "dsari",
18086
+ constant: "DSARI",
18087
+ env: "DSARI"
18088
+ },
18089
+ {
18090
+ name: "Earthly",
18091
+ constant: "EARTHLY",
18092
+ env: "EARTHLY_CI"
18093
+ },
18094
+ {
18095
+ name: "Expo Application Services",
18096
+ constant: "EAS",
18097
+ env: "EAS_BUILD"
18098
+ },
18099
+ {
18100
+ name: "Gerrit",
18101
+ constant: "GERRIT",
18102
+ env: "GERRIT_PROJECT"
18103
+ },
18104
+ {
18105
+ name: "Gitea Actions",
18106
+ constant: "GITEA_ACTIONS",
18107
+ env: "GITEA_ACTIONS"
18108
+ },
18109
+ {
18110
+ name: "GitHub Actions",
18111
+ constant: "GITHUB_ACTIONS",
18112
+ env: "GITHUB_ACTIONS",
18113
+ pr: {
18114
+ GITHUB_EVENT_NAME: "pull_request"
18115
+ }
18116
+ },
18117
+ {
18118
+ name: "GitLab CI",
18119
+ constant: "GITLAB",
18120
+ env: "GITLAB_CI",
18121
+ pr: "CI_MERGE_REQUEST_ID"
18122
+ },
18123
+ {
18124
+ name: "GoCD",
18125
+ constant: "GOCD",
18126
+ env: "GO_PIPELINE_LABEL"
18127
+ },
18128
+ {
18129
+ name: "Google Cloud Build",
18130
+ constant: "GOOGLE_CLOUD_BUILD",
18131
+ env: "BUILDER_OUTPUT"
18132
+ },
18133
+ {
18134
+ name: "Harness CI",
18135
+ constant: "HARNESS",
18136
+ env: "HARNESS_BUILD_ID"
18137
+ },
18138
+ {
18139
+ name: "Heroku",
18140
+ constant: "HEROKU",
18141
+ env: {
18142
+ env: "NODE",
18143
+ includes: "/app/.heroku/node/bin/node"
18144
+ }
18145
+ },
18146
+ {
18147
+ name: "Hudson",
18148
+ constant: "HUDSON",
18149
+ env: "HUDSON_URL"
18150
+ },
18151
+ {
18152
+ name: "Jenkins",
18153
+ constant: "JENKINS",
18154
+ env: [
18155
+ "JENKINS_URL",
18156
+ "BUILD_ID"
18157
+ ],
18158
+ pr: {
18159
+ any: [
18160
+ "ghprbPullId",
18161
+ "CHANGE_ID"
18162
+ ]
18163
+ }
18164
+ },
18165
+ {
18166
+ name: "LayerCI",
18167
+ constant: "LAYERCI",
18168
+ env: "LAYERCI",
18169
+ pr: "LAYERCI_PULL_REQUEST"
18170
+ },
18171
+ {
18172
+ name: "Magnum CI",
18173
+ constant: "MAGNUM",
18174
+ env: "MAGNUM"
18175
+ },
18176
+ {
18177
+ name: "Netlify CI",
18178
+ constant: "NETLIFY",
18179
+ env: "NETLIFY",
18180
+ pr: {
18181
+ env: "PULL_REQUEST",
18182
+ ne: "false"
18183
+ }
18184
+ },
18185
+ {
18186
+ name: "Nevercode",
18187
+ constant: "NEVERCODE",
18188
+ env: "NEVERCODE",
18189
+ pr: {
18190
+ env: "NEVERCODE_PULL_REQUEST",
18191
+ ne: "false"
18192
+ }
18193
+ },
18194
+ {
18195
+ name: "Prow",
18196
+ constant: "PROW",
18197
+ env: "PROW_JOB_ID"
18198
+ },
18199
+ {
18200
+ name: "ReleaseHub",
18201
+ constant: "RELEASEHUB",
18202
+ env: "RELEASE_BUILD_ID"
18203
+ },
18204
+ {
18205
+ name: "Render",
18206
+ constant: "RENDER",
18207
+ env: "RENDER",
18208
+ pr: {
18209
+ IS_PULL_REQUEST: "true"
18210
+ }
18211
+ },
18212
+ {
18213
+ name: "Sail CI",
18214
+ constant: "SAIL",
18215
+ env: "SAILCI",
18216
+ pr: "SAIL_PULL_REQUEST_NUMBER"
18217
+ },
18218
+ {
18219
+ name: "Screwdriver",
18220
+ constant: "SCREWDRIVER",
18221
+ env: "SCREWDRIVER",
18222
+ pr: {
18223
+ env: "SD_PULL_REQUEST",
18224
+ ne: "false"
18225
+ }
18226
+ },
18227
+ {
18228
+ name: "Semaphore",
18229
+ constant: "SEMAPHORE",
18230
+ env: "SEMAPHORE",
18231
+ pr: "PULL_REQUEST_NUMBER"
18232
+ },
18233
+ {
18234
+ name: "Sourcehut",
18235
+ constant: "SOURCEHUT",
18236
+ env: {
18237
+ CI_NAME: "sourcehut"
18238
+ }
18239
+ },
18240
+ {
18241
+ name: "Strider CD",
18242
+ constant: "STRIDER",
18243
+ env: "STRIDER"
18244
+ },
18245
+ {
18246
+ name: "TaskCluster",
18247
+ constant: "TASKCLUSTER",
18248
+ env: [
18249
+ "TASK_ID",
18250
+ "RUN_ID"
18251
+ ]
18252
+ },
18253
+ {
18254
+ name: "TeamCity",
18255
+ constant: "TEAMCITY",
18256
+ env: "TEAMCITY_VERSION"
18257
+ },
18258
+ {
18259
+ name: "Travis CI",
18260
+ constant: "TRAVIS",
18261
+ env: "TRAVIS",
18262
+ pr: {
18263
+ env: "TRAVIS_PULL_REQUEST",
18264
+ ne: "false"
18265
+ }
18266
+ },
18267
+ {
18268
+ name: "Vela",
18269
+ constant: "VELA",
18270
+ env: "VELA",
18271
+ pr: {
18272
+ VELA_PULL_REQUEST: "1"
18273
+ }
18274
+ },
18275
+ {
18276
+ name: "Vercel",
18277
+ constant: "VERCEL",
18278
+ env: {
18279
+ any: [
18280
+ "NOW_BUILDER",
18281
+ "VERCEL"
18282
+ ]
18283
+ },
18284
+ pr: "VERCEL_GIT_PULL_REQUEST_ID"
18285
+ },
18286
+ {
18287
+ name: "Visual Studio App Center",
18288
+ constant: "APPCENTER",
18289
+ env: "APPCENTER_BUILD_ID"
18290
+ },
18291
+ {
18292
+ name: "Woodpecker",
18293
+ constant: "WOODPECKER",
18294
+ env: {
18295
+ CI: "woodpecker"
18296
+ },
18297
+ pr: {
18298
+ CI_BUILD_EVENT: "pull_request"
18299
+ }
18300
+ },
18301
+ {
18302
+ name: "Xcode Cloud",
18303
+ constant: "XCODE_CLOUD",
18304
+ env: "CI_XCODE_PROJECT",
18305
+ pr: "CI_PULL_REQUEST_NUMBER"
18306
+ },
18307
+ {
18308
+ name: "Xcode Server",
18309
+ constant: "XCODE_SERVER",
18310
+ env: "XCS"
18311
+ }
18312
+ ];
18313
+
18314
+ // ../telemetry/src/ci-detect.ts
18315
+ var _CI_VENDOR_COUNT_FOR_TEST = vendors_default.length;
18316
+
18317
+ // ../telemetry/src/base-props.ts
18318
+ var SESSION_ID2 = randomUUID3();
18319
+
18320
+ // ../telemetry/src/identity.ts
18321
+ import * as crypto from "node:crypto";
18322
+ import * as fs2 from "node:fs";
18323
+ import * as path5 from "node:path";
18324
+
18325
+ // ../telemetry/src/paths.ts
18326
+ import * as os from "node:os";
18327
+ import * as path4 from "node:path";
18328
+ function nonEmpty(value) {
18329
+ if (value == void 0) return null;
18330
+ const trimmed = value.trim();
18331
+ return trimmed === "" ? null : value;
18332
+ }
18333
+ function argentHomeDir() {
18334
+ const home = process.platform === "win32" ? nonEmpty(process.env.USERPROFILE) ?? os.homedir() : nonEmpty(process.env.HOME) ?? os.homedir();
18335
+ return path4.join(home, ".argent");
18336
+ }
18337
+ function configFilePath() {
18338
+ return path4.join(argentHomeDir(), "config.json");
18339
+ }
18340
+
18341
+ // ../telemetry/src/consent.ts
18342
+ import * as fs4 from "node:fs";
18343
+
18344
+ // ../telemetry/src/config-file.ts
18345
+ import * as crypto2 from "node:crypto";
18346
+ import * as fs3 from "node:fs";
18347
+ import * as path6 from "node:path";
18348
+ function readConfigObject() {
18349
+ try {
18350
+ const raw = fs3.readFileSync(configFilePath(), "utf8");
18351
+ const json = JSON.parse(raw);
18352
+ if (json && typeof json === "object") {
18353
+ return json;
18354
+ }
18355
+ } catch {
18356
+ }
18357
+ return {};
18358
+ }
18359
+ var LOCK_STALE_MS = 1e4;
18360
+ var LOCK_MAX_WAIT_MS = 2e3;
18361
+ var LOCK_RETRY_MS = 25;
18362
+ function sleepSync(ms) {
18363
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
18364
+ }
18365
+ function acquireConfigLock() {
18366
+ const lockPath = configFilePath() + ".lock";
18367
+ const deadline = Date.now() + LOCK_MAX_WAIT_MS;
18368
+ for (; ; ) {
18369
+ try {
18370
+ const fd = fs3.openSync(lockPath, "wx", 384);
18371
+ try {
18372
+ fs3.writeSync(fd, `${process.pid}
18373
+ `);
18374
+ } catch {
18375
+ }
18376
+ return { fd, lockPath };
18377
+ } catch (err) {
18378
+ if (err.code !== "EEXIST") return null;
18379
+ try {
18380
+ if (Date.now() - fs3.statSync(lockPath).mtimeMs > LOCK_STALE_MS) {
18381
+ fs3.unlinkSync(lockPath);
18382
+ continue;
18383
+ }
18384
+ } catch {
18385
+ }
18386
+ if (Date.now() >= deadline) return null;
18387
+ sleepSync(LOCK_RETRY_MS);
18388
+ }
18389
+ }
18390
+ }
18391
+ function releaseConfigLock(lock) {
18392
+ try {
18393
+ fs3.closeSync(lock.fd);
18394
+ } catch {
18395
+ }
18396
+ try {
18397
+ fs3.unlinkSync(lock.lockPath);
18398
+ } catch {
18399
+ }
18400
+ }
18401
+ function updateConfig(mutate) {
18402
+ fs3.mkdirSync(argentHomeDir(), { recursive: true });
18403
+ const lock = acquireConfigLock();
18404
+ try {
18405
+ const next = readConfigObject();
18406
+ mutate(next);
18407
+ const finalPath = configFilePath();
18408
+ const tmpPath = path6.join(argentHomeDir(), `.config.tmp.${process.pid}.${crypto2.randomUUID()}`);
18409
+ const fd = fs3.openSync(tmpPath, "wx", 384);
18410
+ try {
18411
+ fs3.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
18412
+ fs3.fsyncSync(fd);
18413
+ } finally {
18414
+ fs3.closeSync(fd);
18415
+ }
18416
+ try {
18417
+ fs3.renameSync(tmpPath, finalPath);
18418
+ } catch (err) {
18419
+ try {
18420
+ fs3.unlinkSync(tmpPath);
18421
+ } catch {
18422
+ }
18423
+ throw err;
18424
+ }
18425
+ } finally {
18426
+ if (lock) releaseConfigLock(lock);
18427
+ }
18428
+ }
18429
+
18430
+ // ../telemetry/src/consent.ts
18431
+ var cache = { current: null };
18432
+ var sessionOverride = null;
18433
+ function readConfigOverride() {
18434
+ let stats;
18435
+ try {
18436
+ stats = fs4.lstatSync(configFilePath());
18437
+ } catch (err) {
18438
+ if (err.code === "ENOENT") {
18439
+ cache.current = { mtimeMs: null, fingerprint: null, enabledOverride: null };
18440
+ return null;
18441
+ }
18442
+ cache.current = { mtimeMs: null, fingerprint: null, enabledOverride: null };
18443
+ return null;
18444
+ }
18445
+ if (!stats.isFile()) {
18446
+ cache.current = { mtimeMs: null, fingerprint: null, enabledOverride: null };
18447
+ return null;
18448
+ }
18449
+ const fingerprint = `${stats.dev}:${stats.ino}:${stats.size}`;
18450
+ const mtimeMs = stats.mtimeMs;
18451
+ if (cache.current && cache.current.fingerprint === fingerprint && cache.current.mtimeMs === mtimeMs) {
18452
+ return cache.current.enabledOverride;
18453
+ }
18454
+ let parsedEnabled = null;
18455
+ try {
18456
+ const raw = fs4.readFileSync(configFilePath(), "utf8");
18457
+ const json = JSON.parse(raw);
18458
+ if (json && typeof json === "object") {
18459
+ const t = json.telemetry;
18460
+ if (t && typeof t === "object") {
18461
+ const enabled = t.enabled;
18462
+ if (typeof enabled === "boolean") parsedEnabled = enabled;
18463
+ }
18464
+ }
18465
+ } catch {
18466
+ }
18467
+ cache.current = { mtimeMs, fingerprint, enabledOverride: parsedEnabled };
18468
+ return parsedEnabled;
18469
+ }
18470
+ function parseFalsy(value) {
18471
+ if (value === void 0) return false;
18472
+ const v = value.trim().toLowerCase();
18473
+ return v === "0" || v === "false" || v === "no" || v === "off";
18474
+ }
18475
+ function isDoNotTrackSet(value) {
18476
+ if (value === void 0 || value.trim() === "") return false;
18477
+ return !parseFalsy(value);
18478
+ }
18479
+ function getConsentState(env = process.env) {
18480
+ if (isDoNotTrackSet(env.DO_NOT_TRACK)) {
18481
+ return {
18482
+ enabled: false,
18483
+ source: { source: "env_do_not_track", detail: `DO_NOT_TRACK=${env.DO_NOT_TRACK}` }
18484
+ };
18485
+ }
18486
+ const argentEnv = env.ARGENT_TELEMETRY;
18487
+ if (parseFalsy(argentEnv)) {
18488
+ return {
18489
+ enabled: false,
18490
+ source: { source: "env_argent_telemetry", detail: `ARGENT_TELEMETRY=${argentEnv}` }
18491
+ };
18492
+ }
18493
+ if (sessionOverride !== null) {
18494
+ return { enabled: sessionOverride, source: { source: "session_override" } };
18495
+ }
18496
+ const persisted = readConfigOverride();
18497
+ if (persisted === false) {
18498
+ return { enabled: false, source: { source: "config_file", detail: "config.json" } };
18499
+ }
18500
+ if (persisted === true) {
18501
+ return { enabled: true, source: { source: "config_file", detail: "config.json" } };
18502
+ }
18503
+ return { enabled: true, source: { source: "default" } };
18504
+ }
18505
+ function isEnabled(env = process.env) {
18506
+ return getConsentState(env).enabled;
18507
+ }
18508
+
18509
+ // ../telemetry/src/debug.ts
18510
+ import * as fs5 from "node:fs";
18511
+
18512
+ // ../telemetry/src/notice.ts
18513
+ var TELEMETRY_OPT_OUT_COMMAND = "argent telemetry disable";
18514
+ var TELEMETRY_DETAILS_URL = "https://swmansion.com/legal/argent/privacy-notice/";
18515
+ var FIRST_RUN_NOTICE_BODY_LINES = [
18516
+ "Argent collects anonymous usage data to help us improve the tool. We never",
18517
+ "collect your source code, file paths, tool inputs, or error contents."
18518
+ ];
18519
+ var FIRST_RUN_NOTICE = [
18520
+ ...FIRST_RUN_NOTICE_BODY_LINES,
18521
+ `Opt out anytime: ${TELEMETRY_OPT_OUT_COMMAND}`,
18522
+ `Details: ${TELEMETRY_DETAILS_URL}`
18523
+ ].join("\n");
18524
+ function hasShownFirstRunNotice() {
18525
+ const notices = readConfigObject().notices;
18526
+ if (notices && typeof notices === "object") {
18527
+ return notices.first_run_shown === true;
18528
+ }
18529
+ return false;
18530
+ }
18531
+ function markFirstRunNoticeShown() {
18532
+ updateConfig((config2) => {
18533
+ const noticesBlock = typeof config2.notices === "object" && config2.notices ? config2.notices : {};
18534
+ config2.notices = { ...noticesBlock, first_run_shown: true };
18535
+ });
18536
+ }
18537
+ function shouldShowFirstRunNotice() {
18538
+ return isEnabled() && !hasShownFirstRunNotice();
18539
+ }
18540
+
15930
18541
  // ../argent-mcp/src/content.ts
15931
18542
  import { readFile as readFile5 } from "node:fs/promises";
15932
18543
  var PNG_SIGNATURE = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
@@ -16059,34 +18670,34 @@ async function flowRunToMcpContent(result, ctx) {
16059
18670
  }
16060
18671
 
16061
18672
  // ../configuration-core/src/flags.ts
16062
- import * as fs2 from "node:fs";
16063
- import * as path4 from "node:path";
16064
- import { homedir as homedir3 } from "node:os";
18673
+ import * as fs6 from "node:fs";
18674
+ import * as path7 from "node:path";
18675
+ import { homedir as homedir4 } from "node:os";
16065
18676
  var PROJECT_MARKERS = [".argent", ".git", "package.json"];
16066
18677
  function resolveProjectRoot(startDir) {
16067
- const initial = path4.resolve(startDir);
18678
+ const initial = path7.resolve(startDir);
16068
18679
  let current = initial;
16069
18680
  while (true) {
16070
18681
  for (const marker of PROJECT_MARKERS) {
16071
- if (fs2.existsSync(path4.join(current, marker))) return current;
18682
+ if (fs6.existsSync(path7.join(current, marker))) return current;
16072
18683
  }
16073
- const parent = path4.dirname(current);
18684
+ const parent = path7.dirname(current);
16074
18685
  if (parent === current) return initial;
16075
18686
  current = parent;
16076
18687
  }
16077
18688
  }
16078
18689
  function getFlagsPath(scope, options = {}) {
16079
- const home = options.homeDir ?? homedir3();
18690
+ const home = options.homeDir ?? homedir4();
16080
18691
  if (scope === "global") {
16081
- return path4.join(home, ".argent", "flags.json");
18692
+ return path7.join(home, ".argent", "flags.json");
16082
18693
  }
16083
18694
  const cwd = options.cwd ?? process.cwd();
16084
- return path4.join(resolveProjectRoot(cwd), ".argent", "flags.json");
18695
+ return path7.join(resolveProjectRoot(cwd), ".argent", "flags.json");
16085
18696
  }
16086
18697
  function readFlagsFile(filePath) {
16087
18698
  let raw;
16088
18699
  try {
16089
- raw = fs2.readFileSync(filePath, "utf8");
18700
+ raw = fs6.readFileSync(filePath, "utf8");
16090
18701
  } catch {
16091
18702
  return {};
16092
18703
  }
@@ -16194,12 +18805,12 @@ function toMcpTool(t) {
16194
18805
  }
16195
18806
 
16196
18807
  // ../argent-mcp/src/installed-version.ts
16197
- import * as fs3 from "node:fs";
16198
- import * as path5 from "node:path";
18808
+ import * as fs7 from "node:fs";
18809
+ import * as path8 from "node:path";
16199
18810
  function getInstalledVersion() {
16200
18811
  try {
16201
- const pkgPath = path5.resolve(import.meta.dirname, "..", "package.json");
16202
- const pkg = JSON.parse(fs3.readFileSync(pkgPath, "utf8"));
18812
+ const pkgPath = path8.resolve(import.meta.dirname, "..", "package.json");
18813
+ const pkg = JSON.parse(fs7.readFileSync(pkgPath, "utf8"));
16203
18814
  return pkg.version ?? "unknown";
16204
18815
  } catch {
16205
18816
  return "unknown";
@@ -16237,6 +18848,11 @@ async function fetchWithReconnect(getUrl, reconnect, config2) {
16237
18848
  throw lastError;
16238
18849
  }
16239
18850
  async function startMcpServer(options) {
18851
+ if (shouldShowFirstRunNotice()) {
18852
+ process.stderr.write(`[argent] ${FIRST_RUN_NOTICE}
18853
+ `);
18854
+ markFirstRunNoticeShown();
18855
+ }
16240
18856
  const autoScreenshotOn = autoScreenshotEnabled();
16241
18857
  let TOOLS_URL;
16242
18858
  let AUTH_TOKEN;
@@ -16258,6 +18874,13 @@ async function startMcpServer(options) {
16258
18874
  function authHeader() {
16259
18875
  return AUTH_TOKEN ? { Authorization: `Bearer ${AUTH_TOKEN}` } : {};
16260
18876
  }
18877
+ function aiClientHeaders() {
18878
+ const rawName = server.getClientVersion()?.name?.trim() || void 0;
18879
+ const aiClient = canonicalizeAiClient(rawName);
18880
+ if (aiClient) return { "X-Argent-AI-Client": aiClient };
18881
+ if (rawName) return { "X-Argent-AI-Client": "other" };
18882
+ return {};
18883
+ }
16261
18884
  let reconnectPromise = null;
16262
18885
  async function reconnect() {
16263
18886
  if (await isRemoteRouted()) return;
@@ -16271,12 +18894,12 @@ async function startMcpServer(options) {
16271
18894
  }
16272
18895
  return reconnectPromise;
16273
18896
  }
16274
- const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? `${homedir4()}/.argent/mcp-calls.log`;
18897
+ const LOG_FILE2 = process.env.ARGENT_MCP_LOG ?? `${homedir5()}/.argent/mcp-calls.log`;
16275
18898
  let logDirReady = false;
16276
18899
  async function spyLog(entry) {
16277
18900
  try {
16278
18901
  if (!logDirReady) {
16279
- await mkdir5(dirname3(LOG_FILE2), { recursive: true });
18902
+ await mkdir5(dirname4(LOG_FILE2), { recursive: true });
16280
18903
  logDirReady = true;
16281
18904
  }
16282
18905
  await appendFile(LOG_FILE2, JSON.stringify(entry) + "\n");
@@ -16305,7 +18928,7 @@ async function startMcpServer(options) {
16305
18928
  const res = await fetchWithReconnect(() => `${TOOLS_URL}/tools/${name}`, reconnect, {
16306
18929
  init: {
16307
18930
  method: "POST",
16308
- headers: { "Content-Type": "application/json", ...authHeader() },
18931
+ headers: { "Content-Type": "application/json", ...authHeader(), ...aiClientHeaders() },
16309
18932
  body: JSON.stringify(finalArgs ?? {})
16310
18933
  },
16311
18934
  fetchTimeoutMs: meta2?.longRunning ? null : FETCH_TIMEOUT_MS
@@ -16454,3 +19077,15 @@ async function startMcpServer(options) {
16454
19077
  export {
16455
19078
  startMcpServer
16456
19079
  };
19080
+ /*! Bundled license information:
19081
+
19082
+ @posthog/core/dist/vendor/uuidv7.mjs:
19083
+ (*! For license information please see uuidv7.mjs.LICENSE.txt *)
19084
+ (**
19085
+ * uuidv7: An experimental implementation of the proposed UUID Version 7
19086
+ *
19087
+ * @license Apache-2.0
19088
+ * @copyright 2021-2023 LiosK
19089
+ * @packageDocumentation
19090
+ *)
19091
+ */