@chrischall/hellofresh-mcp 0.4.0 → 0.5.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.
package/dist/bundle.js CHANGED
@@ -199,8 +199,8 @@ var require_util = __commonJS({
199
199
  const end = source.endsWith("$") ? source.length - 1 : source.length;
200
200
  return source.slice(start, end);
201
201
  }
202
- function floatSafeRemainder2(val, step) {
203
- const ratio = val / step;
202
+ function floatSafeRemainder2(val, step2) {
203
+ const ratio = val / step2;
204
204
  const roundedRatio = Math.round(ratio);
205
205
  const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
206
206
  if (Math.abs(ratio - roundedRatio) < tolerance)
@@ -320,14 +320,14 @@ var require_util = __commonJS({
320
320
  }
321
321
  function randomString2(length = 10) {
322
322
  const chars = "abcdefghijklmnopqrstuvwxyz";
323
- let str = "";
323
+ let str2 = "";
324
324
  for (let i = 0; i < length; i++) {
325
- str += chars[Math.floor(Math.random() * chars.length)];
325
+ str2 += chars[Math.floor(Math.random() * chars.length)];
326
326
  }
327
- return str;
327
+ return str2;
328
328
  }
329
- function esc2(str) {
330
- return JSON.stringify(str);
329
+ function esc2(str2) {
330
+ return JSON.stringify(str2);
331
331
  }
332
332
  function slugify2(input2) {
333
333
  return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
@@ -442,8 +442,8 @@ var require_util = __commonJS({
442
442
  "symbol",
443
443
  "undefined"
444
444
  ]);
445
- function escapeRegex2(str) {
446
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
445
+ function escapeRegex2(str2) {
446
+ return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
447
447
  }
448
448
  function clone2(inst, def, params) {
449
449
  const cl = new inst._zod.constr(def ?? inst._zod.def);
@@ -709,13 +709,13 @@ var require_util = __commonJS({
709
709
  return "unknown";
710
710
  }
711
711
  var highSurrogate2 = /[\uD800-\uDBFF]/;
712
- function codePointLength2(str) {
713
- const units = str.length;
714
- if (!highSurrogate2.test(str))
712
+ function codePointLength2(str2) {
713
+ const units = str2.length;
714
+ if (!highSurrogate2.test(str2))
715
715
  return units;
716
716
  let count = units;
717
717
  for (let i = 0; i < units - 1; i++) {
718
- if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
718
+ if ((str2.charCodeAt(i) & 64512) === 55296 && (str2.charCodeAt(i + 1) & 64512) === 56320) {
719
719
  count--;
720
720
  i++;
721
721
  }
@@ -3741,9 +3741,9 @@ var require_schemas = __commonJS({
3741
3741
  return payload;
3742
3742
  }
3743
3743
  const value = input2?.[def.discriminator];
3744
- const opt = disc.value.get(value);
3745
- if (opt && (value !== void 0 || ctx.direction !== "backward")) {
3746
- return opt._zod.run(payload, ctx);
3744
+ const opt2 = disc.value.get(value);
3745
+ if (opt2 && (value !== void 0 || ctx.direction !== "backward")) {
3746
+ return opt2._zod.run(payload, ctx);
3747
3747
  }
3748
3748
  if (def.unionFallback || ctx.direction === "backward") {
3749
3749
  return _super(payload, ctx);
@@ -16569,9 +16569,9 @@ ${code2}
16569
16569
  if (options.length === 1) {
16570
16570
  return generateCheck2(doc, ctx, options[0], accessor);
16571
16571
  }
16572
- const allLiterals = options.every((opt) => opt._zod.def.type === "literal" && !opt._zod.def.checks?.length);
16572
+ const allLiterals = options.every((opt2) => opt2._zod.def.type === "literal" && !opt2._zod.def.checks?.length);
16573
16573
  if (allLiterals) {
16574
- const values = new Set(options.flatMap((opt) => opt._zod.def.values));
16574
+ const values = new Set(options.flatMap((opt2) => opt2._zod.def.values));
16575
16575
  const valuesConst = addConstant2(ctx, values);
16576
16576
  doc.write(`if (!${valuesConst}.has(${accessor})) return INVALID;`);
16577
16577
  return accessor;
@@ -16579,14 +16579,14 @@ ${code2}
16579
16579
  const outputVar = newVar2(ctx);
16580
16580
  doc.write(`let ${outputVar};`);
16581
16581
  for (let i = 0; i < options.length; i++) {
16582
- const opt = options[i];
16582
+ const opt2 = options[i];
16583
16583
  if (i === 0) {
16584
16584
  doc.write(`${outputVar} = (() => {`);
16585
16585
  } else {
16586
16586
  doc.write(`if (${outputVar} === INVALID) ${outputVar} = (() => {`);
16587
16587
  }
16588
16588
  doc.indented((d) => {
16589
- const branchOutput = generateCheck2(d, ctx, opt, accessor);
16589
+ const branchOutput = generateCheck2(d, ctx, opt2, accessor);
16590
16590
  d.write(`return ${branchOutput};`);
16591
16591
  });
16592
16592
  doc.write(`})();`);
@@ -22795,9 +22795,9 @@ var require_visit = __commonJS({
22795
22795
  const oldOptions = def.options;
22796
22796
  let changed = false;
22797
22797
  const newOptions = [];
22798
- for (const opt of oldOptions) {
22799
- const mapped = run(opt);
22800
- if (mapped !== opt)
22798
+ for (const opt2 of oldOptions) {
22799
+ const mapped = run(opt2);
22800
+ if (mapped !== opt2)
22801
22801
  changed = true;
22802
22802
  newOptions.push(mapped);
22803
22803
  }
@@ -23450,9 +23450,9 @@ function redactValues(text, values, opts = {}) {
23450
23450
  return out;
23451
23451
  }
23452
23452
  function truncateErrorMessage(text, max = DEFAULT_ERROR_MESSAGE_MAX, opts = {}) {
23453
- const str = text === null || text === void 0 ? "" : String(text);
23453
+ const str2 = text === null || text === void 0 ? "" : String(text);
23454
23454
  const cap = Math.max(ERROR_REDACTION_INPUT_MAX, max);
23455
- const capped = str.length > cap ? str.slice(0, cap) : str;
23455
+ const capped = str2.length > cap ? str2.slice(0, cap) : str2;
23456
23456
  const scrubbed = opts.values !== void 0 ? redactValues(capped, opts.values, opts.placeholder !== void 0 ? { placeholder: opts.placeholder } : {}) : capped;
23457
23457
  const redacted = redactSecrets(scrubbed);
23458
23458
  if (redacted.length <= max)
@@ -23746,8 +23746,8 @@ function cleanRegex(source) {
23746
23746
  const end = source.endsWith("$") ? source.length - 1 : source.length;
23747
23747
  return source.slice(start, end);
23748
23748
  }
23749
- function floatSafeRemainder(val, step) {
23750
- const ratio = val / step;
23749
+ function floatSafeRemainder(val, step2) {
23750
+ const ratio = val / step2;
23751
23751
  const roundedRatio = Math.round(ratio);
23752
23752
  const tolerance = 4 * Number.EPSILON * Math.max(Math.abs(ratio), 1);
23753
23753
  if (Math.abs(ratio - roundedRatio) < tolerance)
@@ -23866,14 +23866,14 @@ function promiseAllObject(promisesObj) {
23866
23866
  }
23867
23867
  function randomString(length = 10) {
23868
23868
  const chars = "abcdefghijklmnopqrstuvwxyz";
23869
- let str = "";
23869
+ let str2 = "";
23870
23870
  for (let i = 0; i < length; i++) {
23871
- str += chars[Math.floor(Math.random() * chars.length)];
23871
+ str2 += chars[Math.floor(Math.random() * chars.length)];
23872
23872
  }
23873
- return str;
23873
+ return str2;
23874
23874
  }
23875
- function esc(str) {
23876
- return JSON.stringify(str);
23875
+ function esc(str2) {
23876
+ return JSON.stringify(str2);
23877
23877
  }
23878
23878
  function slugify(input2) {
23879
23879
  return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
@@ -23917,8 +23917,8 @@ function numKeys(data) {
23917
23917
  }
23918
23918
  return keyCount;
23919
23919
  }
23920
- function escapeRegex(str) {
23921
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23920
+ function escapeRegex(str2) {
23921
+ return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23922
23922
  }
23923
23923
  function clone(inst, def, params) {
23924
23924
  const cl = new inst._zod.constr(def ?? inst._zod.def);
@@ -24172,13 +24172,13 @@ function getSizableOrigin(input2) {
24172
24172
  return "file";
24173
24173
  return "unknown";
24174
24174
  }
24175
- function codePointLength(str) {
24176
- const units = str.length;
24177
- if (!highSurrogate.test(str))
24175
+ function codePointLength(str2) {
24176
+ const units = str2.length;
24177
+ if (!highSurrogate.test(str2))
24178
24178
  return units;
24179
24179
  let count = units;
24180
24180
  for (let i = 0; i < units - 1; i++) {
24181
- if ((str.charCodeAt(i) & 64512) === 55296 && (str.charCodeAt(i + 1) & 64512) === 56320) {
24181
+ if ((str2.charCodeAt(i) & 64512) === 55296 && (str2.charCodeAt(i + 1) & 64512) === 56320) {
24182
24182
  count--;
24183
24183
  i++;
24184
24184
  }
@@ -27354,9 +27354,9 @@ var init_schemas = __esm({
27354
27354
  return payload;
27355
27355
  }
27356
27356
  const value = input2?.[def.discriminator];
27357
- const opt = disc.value.get(value);
27358
- if (opt && (value !== void 0 || ctx.direction !== "backward")) {
27359
- return opt._zod.run(payload, ctx);
27357
+ const opt2 = disc.value.get(value);
27358
+ if (opt2 && (value !== void 0 || ctx.direction !== "backward")) {
27359
+ return opt2._zod.run(payload, ctx);
27360
27360
  }
27361
27361
  if (def.unionFallback || ctx.direction === "backward") {
27362
27362
  return _super(payload, ctx);
@@ -37698,9 +37698,9 @@ function generateUnionCheck(doc, ctx, schema, accessor) {
37698
37698
  if (options.length === 1) {
37699
37699
  return generateCheck(doc, ctx, options[0], accessor);
37700
37700
  }
37701
- const allLiterals = options.every((opt) => opt._zod.def.type === "literal" && !opt._zod.def.checks?.length);
37701
+ const allLiterals = options.every((opt2) => opt2._zod.def.type === "literal" && !opt2._zod.def.checks?.length);
37702
37702
  if (allLiterals) {
37703
- const values = new Set(options.flatMap((opt) => opt._zod.def.values));
37703
+ const values = new Set(options.flatMap((opt2) => opt2._zod.def.values));
37704
37704
  const valuesConst = addConstant(ctx, values);
37705
37705
  doc.write(`if (!${valuesConst}.has(${accessor})) return INVALID;`);
37706
37706
  return accessor;
@@ -37708,14 +37708,14 @@ function generateUnionCheck(doc, ctx, schema, accessor) {
37708
37708
  const outputVar = newVar(ctx);
37709
37709
  doc.write(`let ${outputVar};`);
37710
37710
  for (let i = 0; i < options.length; i++) {
37711
- const opt = options[i];
37711
+ const opt2 = options[i];
37712
37712
  if (i === 0) {
37713
37713
  doc.write(`${outputVar} = (() => {`);
37714
37714
  } else {
37715
37715
  doc.write(`if (${outputVar} === INVALID) ${outputVar} = (() => {`);
37716
37716
  }
37717
37717
  doc.indented((d) => {
37718
- const branchOutput = generateCheck(d, ctx, opt, accessor);
37718
+ const branchOutput = generateCheck(d, ctx, opt2, accessor);
37719
37719
  d.write(`return ${branchOutput};`);
37720
37720
  });
37721
37721
  doc.write(`})();`);
@@ -43578,9 +43578,9 @@ function visit(schema, fnOrHandlers) {
43578
43578
  const oldOptions = def.options;
43579
43579
  let changed = false;
43580
43580
  const newOptions = [];
43581
- for (const opt of oldOptions) {
43582
- const mapped = run(opt);
43583
- if (mapped !== opt)
43581
+ for (const opt2 of oldOptions) {
43582
+ const mapped = run(opt2);
43583
+ if (mapped !== opt2)
43584
43584
  changed = true;
43585
43585
  newOptions.push(mapped);
43586
43586
  }
@@ -61992,7 +61992,7 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
61992
61992
  }
61993
61993
  exports._ = _;
61994
61994
  const plus = new _Code("+");
61995
- function str(strs, ...args) {
61995
+ function str2(strs, ...args) {
61996
61996
  const expr = [safeStringify(strs[0])];
61997
61997
  let i = 0;
61998
61998
  while (i < args.length) {
@@ -62003,7 +62003,7 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
62003
62003
  optimize(expr);
62004
62004
  return new _Code(expr);
62005
62005
  }
62006
- exports.str = str;
62006
+ exports.str = str2;
62007
62007
  function addCodeArg(code2, arg) {
62008
62008
  if (arg instanceof _Code) code2.push(...arg._items);
62009
62009
  else if (arg instanceof Name) code2.push(arg);
@@ -62036,7 +62036,7 @@ var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
62036
62036
  if (typeof b == "string" && b[0] === '"' && !(a instanceof Name)) return `"${a}${b.slice(1)}`;
62037
62037
  }
62038
62038
  function strConcat(c1, c2) {
62039
- return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str`${c1}${c2}`;
62039
+ return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str2`${c1}${c2}`;
62040
62040
  }
62041
62041
  exports.strConcat = strConcat;
62042
62042
  function interpolate(x) {
@@ -62915,21 +62915,21 @@ var require_util2 = /* @__PURE__ */ __commonJSMin(((exports) => {
62915
62915
  return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
62916
62916
  }
62917
62917
  exports.schemaRefOrVal = schemaRefOrVal;
62918
- function unescapeFragment(str) {
62919
- return unescapeJsonPointer(decodeURIComponent(str));
62918
+ function unescapeFragment(str2) {
62919
+ return unescapeJsonPointer(decodeURIComponent(str2));
62920
62920
  }
62921
62921
  exports.unescapeFragment = unescapeFragment;
62922
- function escapeFragment(str) {
62923
- return encodeURIComponent(escapeJsonPointer(str));
62922
+ function escapeFragment(str2) {
62923
+ return encodeURIComponent(escapeJsonPointer(str2));
62924
62924
  }
62925
62925
  exports.escapeFragment = escapeFragment;
62926
- function escapeJsonPointer(str) {
62927
- if (typeof str == "number") return `${str}`;
62928
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
62926
+ function escapeJsonPointer(str2) {
62927
+ if (typeof str2 == "number") return `${str2}`;
62928
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
62929
62929
  }
62930
62930
  exports.escapeJsonPointer = escapeJsonPointer;
62931
- function unescapeJsonPointer(str) {
62932
- return str.replace(/~1/g, "/").replace(/~0/g, "~");
62931
+ function unescapeJsonPointer(str2) {
62932
+ return str2.replace(/~1/g, "/").replace(/~0/g, "~");
62933
62933
  }
62934
62934
  exports.unescapeJsonPointer = unescapeJsonPointer;
62935
62935
  function eachItem(xs, f) {
@@ -63815,8 +63815,8 @@ var require_json_schema_traverse = /* @__PURE__ */ __commonJSMin(((exports, modu
63815
63815
  post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
63816
63816
  }
63817
63817
  }
63818
- function escapeJsonPtr(str) {
63819
- return str.replace(/~/g, "~0").replace(/\//g, "~1");
63818
+ function escapeJsonPtr(str2) {
63819
+ return str2.replace(/~/g, "~0").replace(/\//g, "~1");
63820
63820
  }
63821
63821
  }));
63822
63822
  var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
@@ -64761,9 +64761,9 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
64761
64761
  isIPV6: true
64762
64762
  };
64763
64763
  }
64764
- function findToken(str, token) {
64764
+ function findToken(str2, token) {
64765
64765
  let ind = 0;
64766
- for (let i = 0; i < str.length; i++) if (str[i] === token) ind++;
64766
+ for (let i = 0; i < str2.length; i++) if (str2[i] === token) ind++;
64767
64767
  return ind;
64768
64768
  }
64769
64769
  function removeDotSegments(path) {
@@ -65578,7 +65578,7 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
65578
65578
  const util_1 = require_util2();
65579
65579
  const $dataRefSchema = require_data();
65580
65580
  const uri_1 = require_uri();
65581
- const defaultRegExp = (str, flags) => new RegExp(str, flags);
65581
+ const defaultRegExp = (str2, flags) => new RegExp(str2, flags);
65582
65582
  defaultRegExp.code = "new RegExp";
65583
65583
  const META_IGNORE_OPTIONS = [
65584
65584
  "removeAdditional",
@@ -65983,8 +65983,8 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
65983
65983
  exports.default = Ajv2;
65984
65984
  function checkOptions(checkOpts, options, msg, log = "error") {
65985
65985
  for (const key in checkOpts) {
65986
- const opt = key;
65987
- if (opt in options) this.logger[log](`${msg}: option ${key}. ${checkOpts[opt]}`);
65986
+ const opt2 = key;
65987
+ if (opt2 in options) this.logger[log](`${msg}: option ${key}. ${checkOpts[opt2]}`);
65988
65988
  }
65989
65989
  }
65990
65990
  function getSchEnv(keyRef) {
@@ -66017,7 +66017,7 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
66017
66017
  }
66018
66018
  function getMetaSchemaOptions() {
66019
66019
  const metaOpts = { ...this.opts };
66020
- for (const opt of META_IGNORE_OPTIONS) delete metaOpts[opt];
66020
+ for (const opt2 of META_IGNORE_OPTIONS) delete metaOpts[opt2];
66021
66021
  return metaOpts;
66022
66022
  }
66023
66023
  const noLogs = {
@@ -66284,16 +66284,16 @@ var require_multipleOf = /* @__PURE__ */ __commonJSMin(((exports) => {
66284
66284
  }));
66285
66285
  var require_ucs2length = /* @__PURE__ */ __commonJSMin(((exports) => {
66286
66286
  Object.defineProperty(exports, "__esModule", { value: true });
66287
- function ucs2length(str) {
66288
- const len = str.length;
66287
+ function ucs2length(str2) {
66288
+ const len = str2.length;
66289
66289
  let length = 0;
66290
66290
  let pos = 0;
66291
66291
  let value;
66292
66292
  while (pos < len) {
66293
66293
  length++;
66294
- value = str.charCodeAt(pos++);
66294
+ value = str2.charCodeAt(pos++);
66295
66295
  if (value >= 55296 && value <= 56319 && pos < len) {
66296
- value = str.charCodeAt(pos);
66296
+ value = str2.charCodeAt(pos);
66297
66297
  if ((value & 64512) === 56320) pos++;
66298
66298
  }
66299
66299
  }
@@ -69004,8 +69004,8 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
69004
69004
  30,
69005
69005
  31
69006
69006
  ];
69007
- function date5(str) {
69008
- const matches = DATE.exec(str);
69007
+ function date5(str2) {
69008
+ const matches = DATE.exec(str2);
69009
69009
  if (!matches) return false;
69010
69010
  const year = +matches[1];
69011
69011
  const month = +matches[2];
@@ -69020,8 +69020,8 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
69020
69020
  }
69021
69021
  const TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
69022
69022
  function getTime(strictTimeZone) {
69023
- return function time3(str) {
69024
- const matches = TIME.exec(str);
69023
+ return function time3(str2) {
69024
+ const matches = TIME.exec(str2);
69025
69025
  if (!matches) return false;
69026
69026
  const hr = +matches[1];
69027
69027
  const min = +matches[2];
@@ -69058,8 +69058,8 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
69058
69058
  const DATE_TIME_SEPARATOR = /t|\s/i;
69059
69059
  function getDateTime(strictTimeZone) {
69060
69060
  const time3 = getTime(strictTimeZone);
69061
- return function date_time(str) {
69062
- const dateTime = str.split(DATE_TIME_SEPARATOR);
69061
+ return function date_time(str2) {
69062
+ const dateTime = str2.split(DATE_TIME_SEPARATOR);
69063
69063
  return dateTime.length === 2 && date5(dateTime[0]) && time3(dateTime[1]);
69064
69064
  };
69065
69065
  }
@@ -69080,13 +69080,13 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
69080
69080
  }
69081
69081
  const NOT_URI_FRAGMENT = /\/|:/;
69082
69082
  const URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
69083
- function uri(str) {
69084
- return NOT_URI_FRAGMENT.test(str) && URI.test(str);
69083
+ function uri(str2) {
69084
+ return NOT_URI_FRAGMENT.test(str2) && URI.test(str2);
69085
69085
  }
69086
69086
  const BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;
69087
- function byte(str) {
69087
+ function byte(str2) {
69088
69088
  BYTE.lastIndex = 0;
69089
- return BYTE.test(str);
69089
+ return BYTE.test(str2);
69090
69090
  }
69091
69091
  const MIN_INT32 = -(2 ** 31);
69092
69092
  const MAX_INT32 = 2 ** 31 - 1;
@@ -69100,10 +69100,10 @@ var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
69100
69100
  return true;
69101
69101
  }
69102
69102
  const Z_ANCHOR = /[^\\]\\Z/;
69103
- function regex(str) {
69104
- if (Z_ANCHOR.test(str)) return false;
69103
+ function regex(str2) {
69104
+ if (Z_ANCHOR.test(str2)) return false;
69105
69105
  try {
69106
- new RegExp(str);
69106
+ new RegExp(str2);
69107
69107
  return true;
69108
69108
  } catch (e) {
69109
69109
  return false;
@@ -73267,6 +73267,12 @@ var HelloFreshClient = class {
73267
73267
  route: `/api/subscriptions/{id}/delivery_dates/${week}`
73268
73268
  });
73269
73269
  }
73270
+ /** A box's carrier tracking, by the public id at the end of the delivery's `tracking.tracking_link`. */
73271
+ getTracking(publicId) {
73272
+ return this.request("GET", apiPath`/scm/tracking-ids/track/public-id/${publicId}`, {
73273
+ route: "/scm/tracking-ids/track/public-id/{id}"
73274
+ });
73275
+ }
73270
73276
  getProductOptions(subscriptionId) {
73271
73277
  return this.request("GET", apiPath`/api/subscriptions/${subscriptionId}/product_options`, {
73272
73278
  route: "/api/subscriptions/{id}/product_options"
@@ -73650,6 +73656,47 @@ function projectDelivery(d) {
73650
73656
  oneOffDaySlots: (d.availableOneOffOptions ?? []).map((o) => ({ handle: o.handle, deliveryDate: o.deliveryDate }))
73651
73657
  };
73652
73658
  }
73659
+ function trackingPublicId(t) {
73660
+ const m = /^https:\/\/www\.hellofresh\.com\/delivery-tracking\/([0-9a-f-]{8,64})\/?$/i.exec(t?.tracking_link ?? "");
73661
+ return m?.[1];
73662
+ }
73663
+ var opt = (key, value) => value === void 0 || value === null || value === "" ? {} : { [key]: value };
73664
+ var step = (s) => ({
73665
+ ...opt("status", s.status),
73666
+ ...opt("statusDetail", s.status_detail),
73667
+ ...opt("at", s.datetime),
73668
+ ...opt("message", s.message)
73669
+ });
73670
+ function projectTracking(raw) {
73671
+ const boxes = (raw.boxes ?? []).filter((b) => !!b && typeof b === "object");
73672
+ return {
73673
+ boxes: boxes.map((b) => {
73674
+ const last = b.last_status ?? {};
73675
+ const photos = Array.isArray(b.proof_of_delivery_photo_urls) ? b.proof_of_delivery_photo_urls.length : 0;
73676
+ const history = (b.statuses ?? []).filter((s) => !!s && typeof s === "object").map(step);
73677
+ const lastAt = Date.parse(last.datetime ?? "");
73678
+ const newer = history.filter((h) => Date.parse(h.at ?? "") > (Number.isNaN(lastAt) ? -Infinity : lastAt)).sort((a, z5) => Date.parse(z5.at) - Date.parse(a.at))[0];
73679
+ return {
73680
+ ...opt("carrier", b.carrier),
73681
+ ...opt("trackingCode", b.tracking_code),
73682
+ ...opt("status", last.status),
73683
+ ...opt("statusDetail", last.status_detail),
73684
+ ...opt("internalStatus", b.internal_status ?? last.internal_status),
73685
+ ...opt("internalStatusDetail", b.internal_status_detail ?? last.internal_status_detail),
73686
+ ...opt("statusMessage", last.message),
73687
+ ...opt("statusAt", last.datetime),
73688
+ ...opt("estimatedDelivery", last.est_delivery_time),
73689
+ ...opt("carrierTrackingUrl", b.carrier_tracking_url ?? b.public_url),
73690
+ ...opt("trackingUrl", b.hf_tracking_url),
73691
+ ...opt("deliveryDate", b.delivery_date),
73692
+ delivered: last.status === "delivered" || newer?.status === "delivered",
73693
+ ...newer ? { latestEvent: newer } : {},
73694
+ ...photos > 0 ? { proofOfDeliveryPhotos: photos } : {},
73695
+ history
73696
+ };
73697
+ })
73698
+ };
73699
+ }
73653
73700
  var QUICK_TAGS = /* @__PURE__ */ new Set(["quick", "easy-prep"]);
73654
73701
  var QUICK_MINUTES = 30;
73655
73702
  function isSeafoodCategory(category) {
@@ -74435,7 +74482,7 @@ function registerGated(server, def) {
74435
74482
  def.name,
74436
74483
  {
74437
74484
  description: `${def.description} ${CONFIRM_FLOW_SENTENCE} ${CONFIRM_INJECTION_RULE}`,
74438
- annotations: toolAnnotations({ title: def.title, readOnly: false, destructive: def.destructive, idempotent: true, openWorld: true }),
74485
+ annotations: toolAnnotations({ title: def.title, readOnly: false, destructive: def.destructive, idempotent: def.idempotent ?? true, openWorld: true }),
74439
74486
  _meta: def.meta,
74440
74487
  inputSchema: external_exports.object({ ...def.input, confirmToken: confirmTokenParam })
74441
74488
  },
@@ -75531,6 +75578,20 @@ function applyFilters(meals, f) {
75531
75578
  }
75532
75579
  function registerReadTools(server, deps2) {
75533
75580
  const { client } = deps2;
75581
+ const readTracking = async (raw, full) => {
75582
+ const publicId = trackingPublicId(raw.tracking);
75583
+ if (!publicId) return {};
75584
+ const read = await attempt(async () => projectTracking(await client.getTracking(publicId)));
75585
+ if (!read.ok || read.value.boxes.length === 0) {
75586
+ return {
75587
+ tracking: { trackingCode: raw.tracking?.tracking_code || void 0, trackingUrl: raw.tracking?.tracking_link },
75588
+ trackingError: read.ok ? "HelloFresh returned no tracked box for this delivery." : read.reason
75589
+ };
75590
+ }
75591
+ const [first, ...more] = read.value.boxes;
75592
+ const shape = (b) => full ? b : { ...b, history: void 0 };
75593
+ return { tracking: shape(first), ...more.length > 0 ? { moreBoxes: more.map(shape) } : {} };
75594
+ };
75534
75595
  const now = deps2.now ?? Date.now;
75535
75596
  server.registerTool(
75536
75597
  "hf_get_subscription",
@@ -75628,7 +75689,7 @@ function registerReadTools(server, deps2) {
75628
75689
  server.registerTool(
75629
75690
  "hf_get_delivery",
75630
75691
  {
75631
- description: "Read one HelloFresh delivery week: delivery date and slot, meal-pick cutoff, status, box size, the meals currently picked (with any premium upcharge), allowed actions, alternative delivery days, and the box price \u2014 HelloFresh\u2019s own checkout total plus the picked meals\u2019 premium upcharge, or a labelled local estimate when that cannot be read.",
75692
+ description: "Read one HelloFresh delivery week: delivery date and slot, meal-pick cutoff, status, box size, the meals currently picked (with any premium upcharge), allowed actions, alternative delivery days, the box price \u2014 HelloFresh\u2019s own checkout total plus the picked meals\u2019 premium upcharge, or a labelled local estimate when that cannot be read \u2014 and, once the box is labelled, its carrier tracking: carrier, tracking code, live status (e.g. delayed / shortage, delivered) and, in the full view, the status history.",
75632
75693
  annotations: readOnly4("HelloFresh: get delivery"),
75633
75694
  _meta: LOOKUP,
75634
75695
  inputSchema: external_exports.object({
@@ -75642,10 +75703,12 @@ function registerReadTools(server, deps2) {
75642
75703
  },
75643
75704
  async ({ week, box_number, next_box_number, view }) => {
75644
75705
  const account = await loadAccount(client);
75645
- const delivery = projectDelivery(await client.getDelivery(account.subscriptionId, week));
75706
+ const raw = await client.getDelivery(account.subscriptionId, week);
75707
+ const delivery = projectDelivery(raw);
75646
75708
  const menu = delivery.status === "skipped" ? void 0 : await attempt(() => readMenu(client, account, delivery, week));
75647
75709
  const selected = menu?.ok ? menu.value.selected : void 0;
75648
75710
  const full = resolveView(view, HF_VIEWS) === "full";
75711
+ const tracking = await readTracking(raw, full);
75649
75712
  let boxNumberNote;
75650
75713
  const fallbackBoxNumber = async () => {
75651
75714
  if (box_number !== void 0) return box_number;
@@ -75667,7 +75730,8 @@ function registerReadTools(server, deps2) {
75667
75730
  ...selected ? { selection: selected.map(compactSelection) } : {},
75668
75731
  ...menu && !menu.ok ? { selectionError: menu.reason } : {},
75669
75732
  ...price ? { price } : {},
75670
- ...boxNumberNote ? { boxNumberNote } : {}
75733
+ ...boxNumberNote ? { boxNumberNote } : {},
75734
+ ...tracking
75671
75735
  });
75672
75736
  }
75673
75737
  );
@@ -75770,6 +75834,459 @@ function registerReadTools(server, deps2) {
75770
75834
  );
75771
75835
  }
75772
75836
 
75837
+ // src/tools/support.ts
75838
+ init_zod();
75839
+ import { randomUUID } from "node:crypto";
75840
+
75841
+ // src/support.ts
75842
+ var SIERRA_API = "https://eu.sierra.chat/-/api";
75843
+ var SIERRA_AGENT_KEY = "rEVzK9YBnPzNiWEBnPzNic4p0Ya-JWIRjGNmiP8amMI";
75844
+ var SUPPORT_SERVICE = "HelloFresh support chat";
75845
+ var ENTRY_REASON = "unknown-from_chat_now_button";
75846
+ var CHAT_LOCALE = "en-US";
75847
+ var DEFAULT_TIME_ZONE = "America/New_York";
75848
+ var TURN_TIMEOUT_MS = 9e4;
75849
+ var WINDOW_TOKEN_QUERY = "query embedChatRefreshWindowTokenQuery($token:String!$userIdentityToken:String$windowId:String){embedBotByToken(token:$token fullscreen:false userIdentityToken:$userIdentityToken windowId:$windowId){__typename ...on EmbedBot{windowToken}...on Node{__isNode:__typename id}}}";
75850
+ function parseChatStream(text) {
75851
+ const frames2 = [];
75852
+ for (const m of text.matchAll(/BOT_CHAT_EVENT_BEGIN([\s\S]*?)BOT_CHAT_EVENT_END/g)) {
75853
+ try {
75854
+ const value = JSON.parse(m[1]);
75855
+ if (value && typeof value === "object" && !Array.isArray(value)) frames2.push(value);
75856
+ } catch {
75857
+ }
75858
+ }
75859
+ return frames2;
75860
+ }
75861
+ var META_KEYS = /* @__PURE__ */ new Set(["timestamp", "idempotencyKey", "tags", "encryptedFullRedactionMode", "eventId", "agentInvocationId"]);
75862
+ var SPEAKER = { USER: "user", AGENT: "bot", HUMAN_AGENT: "human_agent" };
75863
+ var str = (v) => typeof v === "string" && v !== "" ? v : void 0;
75864
+ function linksOf(attachments) {
75865
+ if (!Array.isArray(attachments)) return void 0;
75866
+ const links = attachments.flatMap((a) => {
75867
+ const data = a?.data;
75868
+ const url4 = str(data?.path);
75869
+ return url4 && /^https:\/\//.test(url4) ? [{ ...str(data?.label) ? { label: str(data?.label) } : {}, url: url4 }] : [];
75870
+ });
75871
+ return links.length > 0 ? links : void 0;
75872
+ }
75873
+ function projectEvents(raw) {
75874
+ const out = [];
75875
+ for (const e of raw) {
75876
+ if (!e || typeof e !== "object" || Array.isArray(e)) continue;
75877
+ const ev = e;
75878
+ const kind = Object.keys(ev).find((k) => !META_KEYS.has(k));
75879
+ if (!kind) continue;
75880
+ const base = { ...str(ev.timestamp) ? { at: str(ev.timestamp) } : {}, ...str(ev.eventId) ? { id: str(ev.eventId) } : {} };
75881
+ if (kind === "message") {
75882
+ const m = ev.message;
75883
+ const text = str(m?.text);
75884
+ if (!m || !text || m.isProgressIndicator === true) continue;
75885
+ const from = SPEAKER[String(m.author)];
75886
+ const links = linksOf(m.attachments);
75887
+ out.push({
75888
+ kind,
75889
+ ...from ? { from } : {},
75890
+ ...from === "human_agent" && str(m.displayName) ? { name: str(m.displayName) } : {},
75891
+ text,
75892
+ ...base,
75893
+ ...links ? { links } : {}
75894
+ });
75895
+ continue;
75896
+ }
75897
+ if (kind === "humanAgentParticipation") {
75898
+ const type = ev.humanAgentParticipation?.type;
75899
+ out.push({ kind: type === "JOIN" ? "agentJoined" : type === "LEAVE" ? "agentLeft" : kind, ...base });
75900
+ continue;
75901
+ }
75902
+ if (kind === "humanAgentTyping") continue;
75903
+ const detail = kind === "queueInfo" ? ev.queueInfo : void 0;
75904
+ out.push({ kind, ...base, ...detail !== void 0 ? { detail } : {} });
75905
+ }
75906
+ return out;
75907
+ }
75908
+ var stateEvents = (frame) => {
75909
+ const events = frame.state?.events;
75910
+ return Array.isArray(events) ? events : void 0;
75911
+ };
75912
+ function readTurn(frames2) {
75913
+ const turn = {};
75914
+ for (const f of frames2) {
75915
+ if (typeof f.conversationID === "string") turn.conversationID = f.conversationID;
75916
+ if (typeof f.encryptionKey === "string") turn.encryptionKey = f.encryptionKey;
75917
+ if (f.type === "state") {
75918
+ const events = stateEvents(f);
75919
+ if (events) turn.events = projectEvents(events);
75920
+ }
75921
+ }
75922
+ return turn;
75923
+ }
75924
+ function chatRequestBody(r) {
75925
+ const clientEvent = r.event.type === "start" ? { type: "start", idempotencyKey: r.idempotencyKey } : { type: "message", message: { content: r.event.text }, idempotencyKey: r.idempotencyKey, idempotencyReplayResponse: true };
75926
+ return {
75927
+ token: SIERRA_AGENT_KEY,
75928
+ releaseHash: "production",
75929
+ ...r.conversation ? { conversationID: r.conversation.conversationID, encryptionKey: r.conversation.encryptionKey } : {},
75930
+ clientEvent,
75931
+ userMessageText: r.event.type === "message" ? r.event.text : "",
75932
+ memory: r.memory,
75933
+ locale: CHAT_LOCALE,
75934
+ timeZone: r.timeZone ?? DEFAULT_TIME_ZONE,
75935
+ userMessageIndex: 0,
75936
+ windowId: r.windowId
75937
+ };
75938
+ }
75939
+ function livePollBody(r) {
75940
+ return {
75941
+ token: SIERRA_AGENT_KEY,
75942
+ releaseHash: "production",
75943
+ conversationID: r.conversation.conversationID,
75944
+ encryptionKey: r.conversation.encryptionKey,
75945
+ memory: r.memory,
75946
+ locale: CHAT_LOCALE,
75947
+ timeZone: r.timeZone ?? DEFAULT_TIME_ZONE,
75948
+ windowId: r.windowId
75949
+ };
75950
+ }
75951
+ var SierraChat = class {
75952
+ fetchImpl;
75953
+ redact;
75954
+ timeoutMs;
75955
+ constructor(opts) {
75956
+ this.fetchImpl = opts.fetchImpl;
75957
+ this.redact = opts.redact ?? ((t) => t);
75958
+ this.timeoutMs = opts.timeoutMs ?? TURN_TIMEOUT_MS;
75959
+ }
75960
+ /** A window token for `windowId` (the `x-window-token` every chat call carries). */
75961
+ async windowToken(windowId) {
75962
+ const res = await this.post("/graphql", "application/json", {
75963
+ query: WINDOW_TOKEN_QUERY,
75964
+ variables: { token: SIERRA_AGENT_KEY, userIdentityToken: null, windowId }
75965
+ });
75966
+ const text = await res.text();
75967
+ let token;
75968
+ try {
75969
+ token = JSON.parse(text).data?.embedBotByToken?.windowToken;
75970
+ } catch {
75971
+ }
75972
+ if (typeof token !== "string" || token === "") {
75973
+ throw new McpToolError(`${SUPPORT_SERVICE} did not issue a window token (HTTP ${res.status}).`, { kind: "http", status: res.status });
75974
+ }
75975
+ return token;
75976
+ }
75977
+ /** One client event; the reply streams back in the same response. */
75978
+ async turn(body, windowToken) {
75979
+ const res = await this.post("/chat", "text/plain", body, { "x-window-token": windowToken });
75980
+ const text = await res.text();
75981
+ const frames2 = parseChatStream(text);
75982
+ if (frames2.length === 0) {
75983
+ throw new McpToolError(`${SUPPORT_SERVICE} answered HTTP ${res.status} with no chat events.`, { kind: "http", status: res.status });
75984
+ }
75985
+ return readTurn(frames2);
75986
+ }
75987
+ /** Wait up to `waitMs` for new live-agent events. Running out of time is "nothing new". */
75988
+ async poll(body, windowToken, waitMs) {
75989
+ let res;
75990
+ try {
75991
+ res = await this.post("/chat/live/poll", "text/plain", body, { "x-window-token": windowToken }, waitMs, true);
75992
+ } catch (err) {
75993
+ if (err instanceof WaitElapsed) return { status: "nothing_new" };
75994
+ throw err;
75995
+ }
75996
+ if (res.status === 204) return { status: "nothing_new" };
75997
+ let parsed;
75998
+ try {
75999
+ parsed = JSON.parse(await res.text());
76000
+ } catch {
76001
+ throw new McpToolError(`${SUPPORT_SERVICE}'s live poll answered something that is not JSON.`, { kind: "http", status: res.status });
76002
+ }
76003
+ const se = parsed.streamEvent;
76004
+ const events = Array.isArray(se?.state?.events) ? projectEvents(se.state.events) : [];
76005
+ return {
76006
+ status: "events",
76007
+ events,
76008
+ isDelta: se?.isDelta === true,
76009
+ ...typeof se?.stateCursor === "string" ? { stateCursor: se.stateCursor } : {}
76010
+ };
76011
+ }
76012
+ async post(path, contentType, body, extraHeaders = {}, timeoutMs = this.timeoutMs, waitIsNormal = false) {
76013
+ const signal = AbortSignal.timeout(timeoutMs);
76014
+ let res;
76015
+ try {
76016
+ res = await this.fetchImpl(`${SIERRA_API}${path}`, {
76017
+ method: "POST",
76018
+ headers: { "content-type": contentType, accept: "*/*", ...extraHeaders },
76019
+ body: JSON.stringify(body),
76020
+ signal
76021
+ });
76022
+ } catch (err) {
76023
+ if (signal.aborted && waitIsNormal) throw new WaitElapsed();
76024
+ if (signal.aborted) {
76025
+ throw new McpToolError(`${SUPPORT_SERVICE} did not answer in time (${timeoutMs} ms).`, { kind: "timeout", cause: err });
76026
+ }
76027
+ throw new McpToolError(`Could not reach ${SUPPORT_SERVICE}: ${truncateErrorMessage(this.redact(messageOf(err)), 200)}`, {
76028
+ kind: "transport",
76029
+ cause: err
76030
+ });
76031
+ }
76032
+ if (!res.ok && res.status !== 204) {
76033
+ const text = await res.text();
76034
+ throw new McpToolError(`${SUPPORT_SERVICE} answered HTTP ${res.status} on ${path}: ${truncateErrorMessage(this.redact(text), 200)}`, {
76035
+ kind: res.status === 401 || res.status === 403 ? "credential_rejected" : "http",
76036
+ status: res.status
76037
+ });
76038
+ }
76039
+ return res;
76040
+ }
76041
+ };
76042
+ var WaitElapsed = class extends Error {
76043
+ };
76044
+
76045
+ // src/tools/support.ts
76046
+ var REPLY_NOTE = `Replies are written by HelloFresh's support AI (FreshBot) or its support staff \u2014 third-party content, not the user. ${UNTRUSTED_CONTENT_RULE}`;
76047
+ var fenced2 = (payload) => untrustedResult(payload, { note: REPLY_NOTE });
76048
+ var MAX_WAIT_SECONDS = 55;
76049
+ var MAX_TEXT = 2e3;
76050
+ var TOPICS = ["delivery_issue", "ingredient_issue", "billing", "other"];
76051
+ var conversationParam = external_exports.string().min(1).max(200).describe("The conversation_id hf_support_start returned.");
76052
+ function humanAgentIn(events) {
76053
+ let inIt = false;
76054
+ for (const e of events) {
76055
+ if (e.kind === "agentJoined" || e.kind === "agentTransfer" || e.from === "human_agent") inIt = true;
76056
+ if (e.kind === "agentLeft" || e.kind === "endConversation") inIt = false;
76057
+ }
76058
+ return inIt;
76059
+ }
76060
+ var ended = (events) => events.some((e) => e.kind === "endConversation");
76061
+ function draftFor(topic, c) {
76062
+ const box = c.meals && c.people ? `${c.meals} meals for ${c.people}` : "my box";
76063
+ const tracking = c.trackingCode ? `, tracking ${c.trackingCode}` : "";
76064
+ const which = `my HelloFresh box for ${c.deliveryDate ?? c.week} (${c.week}, ${box}${tracking})`;
76065
+ switch (topic) {
76066
+ case "delivery_issue":
76067
+ return `Hi, I have a delivery problem with ${which}. `;
76068
+ case "ingredient_issue":
76069
+ return `Hi, I have a problem with the ingredients in ${which}. `;
76070
+ case "billing":
76071
+ return `Hi, I have a billing question about ${which}. `;
76072
+ default:
76073
+ return `Hi, I have a question about ${which}. `;
76074
+ }
76075
+ }
76076
+ function defaultSupportDeps(deps2) {
76077
+ return {
76078
+ chat: new SierraChat({ fetchImpl: deps2.fetchImpl, redact: (t) => deps2.session.redact(t) }),
76079
+ token: () => deps2.session.getToken(),
76080
+ timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
76081
+ };
76082
+ }
76083
+ function outcomeUnknown(err) {
76084
+ if (!(err instanceof McpToolError)) return false;
76085
+ if (err.kind === "timeout" || err.kind === "transport") return true;
76086
+ const status = err.status;
76087
+ return status !== void 0 && (status >= 500 || status >= 200 && status < 300);
76088
+ }
76089
+ function registerSupportTools(server, deps2) {
76090
+ const { client } = deps2;
76091
+ const support = deps2.support ?? defaultSupportDeps(deps2);
76092
+ const timeZone = support.timeZone ?? DEFAULT_TIME_ZONE;
76093
+ const conversations = /* @__PURE__ */ new Map();
76094
+ const memoryOf = async (customerId) => ({
76095
+ variables: { MARKET_CODE: "US", MARKET_LOCALE: "en-US", CUSTOMER_ID: customerId, ENTRY_REASON },
76096
+ secrets: { CUSTOMER_JWT: await support.token() }
76097
+ });
76098
+ const conversationOf = (id) => {
76099
+ const c = conversations.get(id);
76100
+ if (!c) {
76101
+ throw new McpToolError(`No open support conversation "${id}" in this session.`, {
76102
+ hint: "Conversations live only as long as this server process: start one with hf_support_start."
76103
+ });
76104
+ }
76105
+ return c;
76106
+ };
76107
+ const turn = async (c, event) => {
76108
+ const body = async () => chatRequestBody({ event, conversation: c.keys, memory: await memoryOf(c.customerId), windowId: c.windowId, idempotencyKey: randomUUID(), timeZone });
76109
+ const first = await body();
76110
+ try {
76111
+ return await support.chat.turn(first, c.windowToken);
76112
+ } catch (err) {
76113
+ if (!(err instanceof McpToolError) || err.status !== 401 && err.status !== 403) throw err;
76114
+ c.windowToken = await support.chat.windowToken(c.windowId);
76115
+ return support.chat.turn(await body(), c.windowToken);
76116
+ }
76117
+ };
76118
+ const describe3 = (text) => `${text} ${UNTRUSTED_DESCRIPTION_SUFFIX}`;
76119
+ server.registerTool(
76120
+ "hf_support_start",
76121
+ {
76122
+ description: describe3(
76123
+ "Open a HelloFresh customer-support chat about a delivery week (a box not delivered, late, damaged, wrong or missing ingredients, billing). It is HelloFresh\u2019s own website chat: an AI assistant (FreshBot) that can hand over to a person. Opening it sends NO message \u2014 it returns FreshBot\u2019s greeting, the week\u2019s delivery date, box size and carrier tracking, and a drafted first message. Show the user the draft, edit it with them, then send it with hf_support_send; read later replies with hf_support_read."
76124
+ ),
76125
+ annotations: toolAnnotations({ title: "HelloFresh: start a support chat", readOnly: false, destructive: false, idempotent: false, openWorld: true }),
76126
+ _meta: foodMeta("send", { aliases: ["hellofresh support", "contact hellofresh", "hellofresh customer service", "box not delivered", "missing box"] }),
76127
+ inputSchema: external_exports.object({
76128
+ week: weekParam,
76129
+ topic: external_exports.enum(TOPICS).default("delivery_issue").describe("What it is about (shapes the drafted first message only).")
76130
+ })
76131
+ },
76132
+ async ({ week, topic }) => {
76133
+ const account = await loadAccount(client);
76134
+ const customerId = account.subscription.customer?.uuid;
76135
+ if (!customerId) throw new McpToolError("HelloFresh did not return the customer id the support chat needs.");
76136
+ const raw = await client.getDelivery(account.subscriptionId, week);
76137
+ const delivery = projectDelivery(raw);
76138
+ const publicId = trackingPublicId(raw.tracking);
76139
+ const tracked = publicId ? await attempt(async () => projectTracking(await client.getTracking(publicId)).boxes[0]) : void 0;
76140
+ const box = tracked?.ok ? tracked.value : void 0;
76141
+ const trackingCode = box?.trackingCode ?? (raw.tracking?.tracking_code || void 0);
76142
+ const windowId = randomUUID();
76143
+ const windowToken = await support.chat.windowToken(windowId);
76144
+ const memory = await memoryOf(customerId);
76145
+ const started = await support.chat.turn(
76146
+ chatRequestBody({ event: { type: "start" }, memory, windowId, idempotencyKey: randomUUID(), timeZone }),
76147
+ windowToken
76148
+ );
76149
+ if (!started.conversationID || !started.encryptionKey) {
76150
+ throw new McpToolError("The HelloFresh support chat did not open a conversation (no conversation id in its answer).");
76151
+ }
76152
+ const c = {
76153
+ keys: { conversationID: started.conversationID, encryptionKey: started.encryptionKey },
76154
+ customerId,
76155
+ windowId,
76156
+ windowToken,
76157
+ week,
76158
+ topic,
76159
+ events: started.events ?? []
76160
+ };
76161
+ conversations.set(started.conversationID, c);
76162
+ const context = {
76163
+ week,
76164
+ deliveryDate: dateOf(delivery.deliveryDate),
76165
+ deliverySlot: delivery.deliveryName,
76166
+ status: delivery.status,
76167
+ meals: delivery.meals,
76168
+ people: delivery.servings,
76169
+ ...box?.carrier ? { carrier: box.carrier } : {},
76170
+ ...trackingCode ? { trackingCode } : {},
76171
+ ...box?.status ? { trackingStatus: box.statusDetail ? `${box.status} (${box.statusDetail})` : box.status } : {},
76172
+ ...box?.statusAt ? { trackingStatusAt: box.statusAt } : {}
76173
+ };
76174
+ return fenced2({
76175
+ conversation_id: started.conversationID,
76176
+ sent: false,
76177
+ replies: c.events,
76178
+ context,
76179
+ draft: draftFor(topic, { deliveryDate: context.deliveryDate, week, meals: delivery.meals, people: delivery.servings, trackingCode }),
76180
+ next: "Nothing has been sent. Show the user the draft and finish it with them, then hf_support_send {conversation_id, text}."
76181
+ });
76182
+ }
76183
+ );
76184
+ registerGated(server, {
76185
+ name: "hf_support_send",
76186
+ title: "HelloFresh: send a support chat message",
76187
+ description: describe3(
76188
+ "Send one message in a HelloFresh support chat opened with hf_support_start. The preview shows the exact text; after confirmation it is sent, checked against the transcript HelloFresh streams back, and the reply (FreshBot, or a person once one has taken over) is returned. A message cannot be unsent."
76189
+ ),
76190
+ destructive: false,
76191
+ idempotent: false,
76192
+ meta: foodMeta("send", { aliases: ["message hellofresh support", "reply to hellofresh", "tell hellofresh"] }),
76193
+ input: {
76194
+ conversation_id: conversationParam,
76195
+ text: external_exports.string().trim().min(1).max(MAX_TEXT).describe("The exact message to send (the user\u2019s words).")
76196
+ },
76197
+ async plan({ conversation_id, text }) {
76198
+ const c = conversationOf(conversation_id);
76199
+ if (ended(c.events)) throw new McpToolError("This support conversation has ended. Start a new one with hf_support_start.");
76200
+ return {
76201
+ gate: {
76202
+ action: "hellofresh.support.message",
76203
+ summary: `Send this message to HelloFresh support (${c.week} conversation)`,
76204
+ account: void 0,
76205
+ target: conversation_id,
76206
+ payload: { text },
76207
+ willSend: { to: "HelloFresh support chat (FreshBot AI; a person may take over)", text },
76208
+ preview: { endpoint: `POST ${SIERRA_API}/chat`, week: c.week }
76209
+ },
76210
+ state: { c, text }
76211
+ };
76212
+ },
76213
+ async execute({ c, text }) {
76214
+ const before = c.events.length;
76215
+ let got;
76216
+ try {
76217
+ got = await turn(c, { type: "message", text });
76218
+ } catch (err) {
76219
+ if (!outcomeUnknown(err)) throw err;
76220
+ return fenced2({
76221
+ status: "unknown",
76222
+ conversation_id: c.keys.conversationID,
76223
+ warning: `The support chat did not confirm the message (${messageOf(err)}), so it may have been delivered. Check with hf_support_read before sending it again; do not repeat it blindly.`
76224
+ });
76225
+ }
76226
+ if (got.events) c.events = got.events;
76227
+ let at = -1;
76228
+ for (let i = c.events.length - 1; i >= 0; i--) {
76229
+ if (c.events[i].from === "user" && c.events[i].text?.trim() === text.trim()) {
76230
+ at = i;
76231
+ break;
76232
+ }
76233
+ }
76234
+ const verified = at >= 0;
76235
+ const replies = verified ? c.events.slice(at + 1) : c.events.slice(before);
76236
+ return fenced2({
76237
+ status: verified ? "verified" : "unverified",
76238
+ conversation_id: c.keys.conversationID,
76239
+ sent: text,
76240
+ replies,
76241
+ humanAgent: humanAgentIn(c.events),
76242
+ ...ended(c.events) ? { ended: true } : {},
76243
+ ...verified ? {} : { warning: "HelloFresh answered, but its transcript does not show the message. Check with hf_support_read before sending it again." }
76244
+ });
76245
+ }
76246
+ });
76247
+ server.registerTool(
76248
+ "hf_support_read",
76249
+ {
76250
+ description: describe3(
76251
+ "Read a HelloFresh support chat opened with hf_support_start: each event labelled from user / bot (FreshBot, the AI) / human_agent (a person, with their display name), plus agent hand-over, queue and end events. `since` (an ISO time or event id) returns only what came after it. `wait_seconds` long-polls for new messages \u2014 that only helps once a person has taken over; FreshBot answers inside hf_support_send."
76252
+ ),
76253
+ annotations: toolAnnotations({ title: "HelloFresh: read a support chat", readOnly: true, idempotent: true, openWorld: true }),
76254
+ _meta: foodMeta("lookup", { aliases: ["hellofresh support replies", "did hellofresh reply"] }),
76255
+ inputSchema: external_exports.object({
76256
+ conversation_id: conversationParam,
76257
+ since: external_exports.string().min(1).max(100).optional().describe("Only events after this ISO timestamp or event id."),
76258
+ wait_seconds: external_exports.number().int().min(0).max(MAX_WAIT_SECONDS).default(0).describe("Wait up to this long for new messages from a person.")
76259
+ })
76260
+ },
76261
+ async ({ conversation_id, since, wait_seconds }) => {
76262
+ const c = conversationOf(conversation_id);
76263
+ let polled;
76264
+ if (wait_seconds > 0) {
76265
+ const body = { ...livePollBody({ conversation: c.keys, memory: await memoryOf(c.customerId), windowId: c.windowId, timeZone }), ...c.stateCursor ? { stateCursor: c.stateCursor } : {} };
76266
+ const got = await support.chat.poll(body, c.windowToken, wait_seconds * 1e3);
76267
+ polled = got.status;
76268
+ if (got.status === "events") {
76269
+ c.events = got.isDelta ? [...c.events, ...got.events] : got.events;
76270
+ if (got.stateCursor) c.stateCursor = got.stateCursor;
76271
+ }
76272
+ }
76273
+ let events = c.events;
76274
+ if (since) {
76275
+ const byId = events.findIndex((e) => e.id === since);
76276
+ events = byId >= 0 ? events.slice(byId + 1) : events.filter((e) => (e.at ?? "") > since);
76277
+ }
76278
+ return fenced2({
76279
+ conversation_id,
76280
+ week: c.week,
76281
+ events,
76282
+ humanAgent: humanAgentIn(c.events),
76283
+ ...ended(c.events) ? { ended: true } : {},
76284
+ ...polled ? { polled } : {}
76285
+ });
76286
+ }
76287
+ );
76288
+ }
76289
+
75773
76290
  // src/tools/writes/plan.ts
75774
76291
  init_zod();
75775
76292
  function registerPlanWrites(server, deps2) {
@@ -76179,7 +76696,8 @@ var TOOL_REGISTRARS = [
76179
76696
  registerPlannerTools,
76180
76697
  registerCookingTools,
76181
76698
  registerFavoriteTools,
76182
- registerPromoTools
76699
+ registerPromoTools,
76700
+ registerSupportTools
76183
76701
  ];
76184
76702
 
76185
76703
  // node_modules/@chrischall/mcp-utils/dist/session/index.js
@@ -76196,7 +76714,7 @@ init_edge_block();
76196
76714
  var LOGIN_PAGE_SCAN_MAX = 512 * 1024;
76197
76715
 
76198
76716
  // node_modules/@chrischall/mcp-utils/dist/session/file-lock.js
76199
- import { randomUUID } from "node:crypto";
76717
+ import { randomUUID as randomUUID2 } from "node:crypto";
76200
76718
  import { closeSync as closeSync2, existsSync, linkSync, mkdirSync as mkdirSync3, openSync as openSync2, readFileSync as readFileSync3, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2, writeSync as writeSync2 } from "node:fs";
76201
76719
  import { dirname } from "node:path";
76202
76720
  var DEFAULT_POLL_MS = 25;
@@ -76217,7 +76735,7 @@ function holderAlive(lockPath) {
76217
76735
  }
76218
76736
  }
76219
76737
  function createLockFile(lockPath, owner) {
76220
- const staging = `${lockPath}.${randomUUID()}.tmp`;
76738
+ const staging = `${lockPath}.${randomUUID2()}.tmp`;
76221
76739
  let linked = false;
76222
76740
  try {
76223
76741
  writeFileSync2(staging, owner, { mode: 384, flag: "wx" });
@@ -76279,7 +76797,7 @@ function prepare(lockPath) {
76279
76797
  mkdirSync3(dirname(lockPath), { recursive: true, mode: 448 });
76280
76798
  } catch {
76281
76799
  }
76282
- return `${process.pid}:${randomUUID()}`;
76800
+ return `${process.pid}:${randomUUID2()}`;
76283
76801
  }
76284
76802
  async function withFileLock(lockPath, fn, opts = {}) {
76285
76803
  const staleMs = opts.staleMs ?? 6e4;
@@ -76457,7 +76975,7 @@ function createSessionCache(env = process.env) {
76457
76975
  }
76458
76976
 
76459
76977
  // src/version.ts
76460
- var VERSION = "0.4.0";
76978
+ var VERSION = "0.5.0";
76461
76979
 
76462
76980
  // src/index.ts
76463
76981
  var bridge = createHelloFreshBridge({ port: readWsPort(), version: VERSION });