@skilder-ai/runtime 0.8.9 → 0.8.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -20514,8 +20514,8 @@ var require_quick_format_unescaped = __commonJS({
20514
20514
  return '"[Circular]"';
20515
20515
  }
20516
20516
  }
20517
- module2.exports = format;
20518
- function format(f2, args, opts) {
20517
+ module2.exports = format2;
20518
+ function format2(f2, args, opts) {
20519
20519
  var ss = opts && opts.stringify || tryStringify;
20520
20520
  var offset = 1;
20521
20521
  if (typeof f2 === "object" && f2 !== null) {
@@ -22019,7 +22019,7 @@ var require_tools = __commonJS({
22019
22019
  "../../node_modules/.pnpm/pino@10.1.0/node_modules/pino/lib/tools.js"(exports2, module2) {
22020
22020
  "use strict";
22021
22021
  var diagChan = require("node:diagnostics_channel");
22022
- var format = require_quick_format_unescaped();
22022
+ var format2 = require_quick_format_unescaped();
22023
22023
  var { mapHttpRequest, mapHttpResponse } = require_pino_std_serializers();
22024
22024
  var SonicBoom = require_sonic_boom();
22025
22025
  var onExit = require_on_exit_leak_free();
@@ -22071,13 +22071,13 @@ var require_tools = __commonJS({
22071
22071
  if (typeof this[msgPrefixSym] === "string" && msg !== void 0 && msg !== null) {
22072
22072
  msg = this[msgPrefixSym] + msg;
22073
22073
  }
22074
- this[writeSym](o, format(msg, formatParams, this[formatOptsSym]), level);
22074
+ this[writeSym](o, format2(msg, formatParams, this[formatOptsSym]), level);
22075
22075
  } else {
22076
22076
  let msg = o === void 0 ? n3.shift() : o;
22077
22077
  if (typeof this[msgPrefixSym] === "string" && msg !== void 0 && msg !== null) {
22078
22078
  msg = this[msgPrefixSym] + msg;
22079
22079
  }
22080
- this[writeSym](null, format(msg, n3, this[formatOptsSym]), level);
22080
+ this[writeSym](null, format2(msg, n3, this[formatOptsSym]), level);
22081
22081
  }
22082
22082
  }
22083
22083
  }
@@ -22119,14 +22119,14 @@ var require_tools = __commonJS({
22119
22119
  const end = this[endSym];
22120
22120
  const chindings = this[chindingsSym];
22121
22121
  const serializers = this[serializersSym];
22122
- const formatters = this[formattersSym];
22122
+ const formatters2 = this[formattersSym];
22123
22123
  const messageKey = this[messageKeySym];
22124
22124
  const errorKey = this[errorKeySym];
22125
22125
  let data = this[lsCacheSym][num] + time3;
22126
22126
  data = data + chindings;
22127
22127
  let value;
22128
- if (formatters.log) {
22129
- obj = formatters.log(obj);
22128
+ if (formatters2.log) {
22129
+ obj = formatters2.log(obj);
22130
22130
  }
22131
22131
  const wildcardStringifier = stringifiers[wildcardFirstSym];
22132
22132
  let propStr = "";
@@ -22659,14 +22659,14 @@ var require_proto = __commonJS({
22659
22659
  throw Error("missing bindings for child Pino");
22660
22660
  }
22661
22661
  const serializers = this[serializersSym];
22662
- const formatters = this[formattersSym];
22662
+ const formatters2 = this[formattersSym];
22663
22663
  const instance = Object.create(this);
22664
22664
  if (options == null) {
22665
22665
  if (instance[formattersSym].bindings !== resetChildingsFormatter) {
22666
22666
  instance[formattersSym] = buildFormatters(
22667
- formatters.level,
22667
+ formatters2.level,
22668
22668
  resetChildingsFormatter,
22669
- formatters.log
22669
+ formatters2.log
22670
22670
  );
22671
22671
  }
22672
22672
  instance[chindingsSym] = asChindings(instance, bindings2);
@@ -22697,15 +22697,15 @@ var require_proto = __commonJS({
22697
22697
  if (options.hasOwnProperty("formatters")) {
22698
22698
  const { level, bindings: chindings, log } = options.formatters;
22699
22699
  instance[formattersSym] = buildFormatters(
22700
- level || formatters.level,
22700
+ level || formatters2.level,
22701
22701
  chindings || resetChildingsFormatter,
22702
- log || formatters.log
22702
+ log || formatters2.log
22703
22703
  );
22704
22704
  } else {
22705
22705
  instance[formattersSym] = buildFormatters(
22706
- formatters.level,
22706
+ formatters2.level,
22707
22707
  resetChildingsFormatter,
22708
- formatters.log
22708
+ formatters2.log
22709
22709
  );
22710
22710
  }
22711
22711
  if (options.hasOwnProperty("customLevels") === true) {
@@ -23665,7 +23665,7 @@ var require_pino = __commonJS({
23665
23665
  mixin,
23666
23666
  mixinMergeStrategy,
23667
23667
  useOnlyCustomLevels,
23668
- formatters,
23668
+ formatters: formatters2,
23669
23669
  hooks,
23670
23670
  depthLimit,
23671
23671
  edgeLimit,
@@ -23677,9 +23677,9 @@ var require_pino = __commonJS({
23677
23677
  maximumBreadth: edgeLimit
23678
23678
  });
23679
23679
  const allFormatters = buildFormatters(
23680
- formatters.level,
23681
- formatters.bindings,
23682
- formatters.log
23680
+ formatters2.level,
23681
+ formatters2.bindings,
23682
+ formatters2.log
23683
23683
  );
23684
23684
  const stringifyFn = stringify.bind({
23685
23685
  [stringifySafeSym]: stringifySafe
@@ -41248,8 +41248,8 @@ var require_scope = __commonJS({
41248
41248
  return `${prefix}${ng.index++}`;
41249
41249
  }
41250
41250
  _nameGroup(prefix) {
41251
- var _a51, _b40;
41252
- if (((_b40 = (_a51 = this._parent) === null || _a51 === void 0 ? void 0 : _a51._prefixes) === null || _b40 === void 0 ? void 0 : _b40.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) {
41251
+ var _a51, _b41;
41252
+ if (((_b41 = (_a51 = this._parent) === null || _a51 === void 0 ? void 0 : _a51._prefixes) === null || _b41 === void 0 ? void 0 : _b41.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) {
41253
41253
  throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
41254
41254
  }
41255
41255
  return this._names[prefix] = { prefix, index: 0 };
@@ -41710,17 +41710,17 @@ var require_codegen = __commonJS({
41710
41710
  return code;
41711
41711
  }
41712
41712
  optimizeNodes() {
41713
- var _a51, _b40;
41713
+ var _a51, _b41;
41714
41714
  super.optimizeNodes();
41715
41715
  (_a51 = this.catch) === null || _a51 === void 0 ? void 0 : _a51.optimizeNodes();
41716
- (_b40 = this.finally) === null || _b40 === void 0 ? void 0 : _b40.optimizeNodes();
41716
+ (_b41 = this.finally) === null || _b41 === void 0 ? void 0 : _b41.optimizeNodes();
41717
41717
  return this;
41718
41718
  }
41719
41719
  optimizeNames(names, constants2) {
41720
- var _a51, _b40;
41720
+ var _a51, _b41;
41721
41721
  super.optimizeNames(names, constants2);
41722
41722
  (_a51 = this.catch) === null || _a51 === void 0 ? void 0 : _a51.optimizeNames(names, constants2);
41723
- (_b40 = this.finally) === null || _b40 === void 0 ? void 0 : _b40.optimizeNames(names, constants2);
41723
+ (_b41 = this.finally) === null || _b41 === void 0 ? void 0 : _b41.optimizeNames(names, constants2);
41724
41724
  return this;
41725
41725
  }
41726
41726
  get names() {
@@ -44938,11 +44938,11 @@ var require_core2 = __commonJS({
44938
44938
  };
44939
44939
  var MAX_EXPRESSION = 200;
44940
44940
  function requiredOptions(o) {
44941
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _j2, _k3, _l, _m, _o2, _p2, _q2, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
44941
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _j2, _k3, _l, _m, _o2, _p2, _q2, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
44942
44942
  const s = o.strict;
44943
44943
  const _optz = (_a51 = o.code) === null || _a51 === void 0 ? void 0 : _a51.optimize;
44944
44944
  const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
44945
- const regExp = (_c11 = (_b40 = o.code) === null || _b40 === void 0 ? void 0 : _b40.regExp) !== null && _c11 !== void 0 ? _c11 : defaultRegExp;
44945
+ const regExp = (_c12 = (_b41 = o.code) === null || _b41 === void 0 ? void 0 : _b41.regExp) !== null && _c12 !== void 0 ? _c12 : defaultRegExp;
44946
44946
  const uriResolver = (_d8 = o.uriResolver) !== null && _d8 !== void 0 ? _d8 : uri_1.default;
44947
44947
  return {
44948
44948
  strictSchema: (_f3 = (_e7 = o.strictSchema) !== null && _e7 !== void 0 ? _e7 : s) !== null && _f3 !== void 0 ? _f3 : true,
@@ -45240,10 +45240,10 @@ var require_core2 = __commonJS({
45240
45240
  return this;
45241
45241
  }
45242
45242
  // Add format
45243
- addFormat(name21, format) {
45244
- if (typeof format == "string")
45245
- format = new RegExp(format);
45246
- this.formats[name21] = format;
45243
+ addFormat(name21, format2) {
45244
+ if (typeof format2 == "string")
45245
+ format2 = new RegExp(format2);
45246
+ this.formats[name21] = format2;
45247
45247
  return this;
45248
45248
  }
45249
45249
  errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
@@ -45361,9 +45361,9 @@ var require_core2 = __commonJS({
45361
45361
  }
45362
45362
  function addInitialFormats() {
45363
45363
  for (const name21 in this.opts.formats) {
45364
- const format = this.opts.formats[name21];
45365
- if (format)
45366
- this.addFormat(name21, format);
45364
+ const format2 = this.opts.formats[name21];
45365
+ if (format2)
45366
+ this.addFormat(name21, format2);
45367
45367
  }
45368
45368
  }
45369
45369
  function addInitialKeywords(defs) {
@@ -47037,18 +47037,18 @@ var require_format = __commonJS({
47037
47037
  });
47038
47038
  const fDef = gen.const("fDef", (0, codegen_1._)`${fmts}[${schemaCode}]`);
47039
47039
  const fType = gen.let("fType");
47040
- const format = gen.let("format");
47041
- gen.if((0, codegen_1._)`typeof ${fDef} == "object" && !(${fDef} instanceof RegExp)`, () => gen.assign(fType, (0, codegen_1._)`${fDef}.type || "string"`).assign(format, (0, codegen_1._)`${fDef}.validate`), () => gen.assign(fType, (0, codegen_1._)`"string"`).assign(format, fDef));
47040
+ const format2 = gen.let("format");
47041
+ gen.if((0, codegen_1._)`typeof ${fDef} == "object" && !(${fDef} instanceof RegExp)`, () => gen.assign(fType, (0, codegen_1._)`${fDef}.type || "string"`).assign(format2, (0, codegen_1._)`${fDef}.validate`), () => gen.assign(fType, (0, codegen_1._)`"string"`).assign(format2, fDef));
47042
47042
  cxt.fail$data((0, codegen_1.or)(unknownFmt(), invalidFmt()));
47043
47043
  function unknownFmt() {
47044
47044
  if (opts.strictSchema === false)
47045
47045
  return codegen_1.nil;
47046
- return (0, codegen_1._)`${schemaCode} && !${format}`;
47046
+ return (0, codegen_1._)`${schemaCode} && !${format2}`;
47047
47047
  }
47048
47048
  function invalidFmt() {
47049
- const callFormat = schemaEnv.$async ? (0, codegen_1._)`(${fDef}.async ? await ${format}(${data}) : ${format}(${data}))` : (0, codegen_1._)`${format}(${data})`;
47050
- const validData = (0, codegen_1._)`(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${data}))`;
47051
- return (0, codegen_1._)`${format} && ${format} !== true && ${fType} === ${ruleType} && !${validData}`;
47049
+ const callFormat = schemaEnv.$async ? (0, codegen_1._)`(${fDef}.async ? await ${format2}(${data}) : ${format2}(${data}))` : (0, codegen_1._)`${format2}(${data})`;
47050
+ const validData = (0, codegen_1._)`(typeof ${format2} == "function" ? ${callFormat} : ${format2}.test(${data}))`;
47051
+ return (0, codegen_1._)`${format2} && ${format2} !== true && ${fType} === ${ruleType} && !${validData}`;
47052
47052
  }
47053
47053
  }
47054
47054
  function validateFormat() {
@@ -47059,7 +47059,7 @@ var require_format = __commonJS({
47059
47059
  }
47060
47060
  if (formatDef === true)
47061
47061
  return;
47062
- const [fmtType, format, fmtRef] = getFormat(formatDef);
47062
+ const [fmtType, format2, fmtRef] = getFormat(formatDef);
47063
47063
  if (fmtType === ruleType)
47064
47064
  cxt.pass(validCondition());
47065
47065
  function unknownFormat() {
@@ -47086,7 +47086,7 @@ var require_format = __commonJS({
47086
47086
  throw new Error("async format in sync schema");
47087
47087
  return (0, codegen_1._)`await ${fmtRef}(${data})`;
47088
47088
  }
47089
- return typeof format == "function" ? (0, codegen_1._)`${fmtRef}(${data})` : (0, codegen_1._)`${fmtRef}.test(${data})`;
47089
+ return typeof format2 == "function" ? (0, codegen_1._)`${fmtRef}(${data})` : (0, codegen_1._)`${fmtRef}.test(${data})`;
47090
47090
  }
47091
47091
  }
47092
47092
  }
@@ -47101,8 +47101,8 @@ var require_format2 = __commonJS({
47101
47101
  "use strict";
47102
47102
  Object.defineProperty(exports2, "__esModule", { value: true });
47103
47103
  var format_1 = require_format();
47104
- var format = [format_1.default];
47105
- exports2.default = format;
47104
+ var format2 = [format_1.default];
47105
+ exports2.default = format2;
47106
47106
  }
47107
47107
  });
47108
47108
 
@@ -47744,17 +47744,17 @@ var require_limit = __commonJS({
47744
47744
  cxt.fail$data((0, codegen_1.or)((0, codegen_1._)`typeof ${fmt} != "object"`, (0, codegen_1._)`${fmt} instanceof RegExp`, (0, codegen_1._)`typeof ${fmt}.compare != "function"`, compareCode(fmt)));
47745
47745
  }
47746
47746
  function validateFormat() {
47747
- const format = fCxt.schema;
47748
- const fmtDef = self2.formats[format];
47747
+ const format2 = fCxt.schema;
47748
+ const fmtDef = self2.formats[format2];
47749
47749
  if (!fmtDef || fmtDef === true)
47750
47750
  return;
47751
47751
  if (typeof fmtDef != "object" || fmtDef instanceof RegExp || typeof fmtDef.compare != "function") {
47752
- throw new Error(`"${keyword}": format "${format}" does not define "compare" function`);
47752
+ throw new Error(`"${keyword}": format "${format2}" does not define "compare" function`);
47753
47753
  }
47754
47754
  const fmt = gen.scopeValue("formats", {
47755
- key: format,
47755
+ key: format2,
47756
47756
  ref: fmtDef,
47757
- code: opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(format)}` : void 0
47757
+ code: opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(format2)}` : void 0
47758
47758
  });
47759
47759
  cxt.fail$data(compareCode(fmt));
47760
47760
  }
@@ -47803,8 +47803,8 @@ var require_dist2 = __commonJS({
47803
47803
  };
47804
47804
  function addFormats(ajv, list, fs5, exportName) {
47805
47805
  var _a51;
47806
- var _b40;
47807
- (_a51 = (_b40 = ajv.opts.code).formats) !== null && _a51 !== void 0 ? _a51 : _b40.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
47806
+ var _b41;
47807
+ (_a51 = (_b41 = ajv.opts.code).formats) !== null && _a51 !== void 0 ? _a51 : _b41.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
47808
47808
  for (const f2 of list)
47809
47809
  ajv.addFormat(f2, fs5[f2]);
47810
47810
  }
@@ -47933,7 +47933,7 @@ var require_Subscription = __commonJS({
47933
47933
  this._finalizers = null;
47934
47934
  }
47935
47935
  Subscription2.prototype.unsubscribe = function() {
47936
- var e_1, _a51, e_2, _b40;
47936
+ var e_1, _a51, e_2, _b41;
47937
47937
  var errors;
47938
47938
  if (!this.closed) {
47939
47939
  this.closed = true;
@@ -47988,7 +47988,7 @@ var require_Subscription = __commonJS({
47988
47988
  e_2 = { error: e_2_1 };
47989
47989
  } finally {
47990
47990
  try {
47991
- if (_finalizers_1_1 && !_finalizers_1_1.done && (_b40 = _finalizers_1.return)) _b40.call(_finalizers_1);
47991
+ if (_finalizers_1_1 && !_finalizers_1_1.done && (_b41 = _finalizers_1.return)) _b41.call(_finalizers_1);
47992
47992
  } finally {
47993
47993
  if (e_2) throw e_2.error;
47994
47994
  }
@@ -49037,15 +49037,15 @@ var require_Subject = __commonJS({
49037
49037
  _this.currentObservers = Array.from(_this.observers);
49038
49038
  }
49039
49039
  try {
49040
- for (var _b40 = __values(_this.currentObservers), _c11 = _b40.next(); !_c11.done; _c11 = _b40.next()) {
49041
- var observer = _c11.value;
49040
+ for (var _b41 = __values(_this.currentObservers), _c12 = _b41.next(); !_c12.done; _c12 = _b41.next()) {
49041
+ var observer = _c12.value;
49042
49042
  observer.next(value);
49043
49043
  }
49044
49044
  } catch (e_1_1) {
49045
49045
  e_1 = { error: e_1_1 };
49046
49046
  } finally {
49047
49047
  try {
49048
- if (_c11 && !_c11.done && (_a51 = _b40.return)) _a51.call(_b40);
49048
+ if (_c12 && !_c12.done && (_a51 = _b41.return)) _a51.call(_b41);
49049
49049
  } finally {
49050
49050
  if (e_1) throw e_1.error;
49051
49051
  }
@@ -49142,20 +49142,20 @@ var require_Subject = __commonJS({
49142
49142
  return _this;
49143
49143
  }
49144
49144
  AnonymousSubject2.prototype.next = function(value) {
49145
- var _a51, _b40;
49146
- (_b40 = (_a51 = this.destination) === null || _a51 === void 0 ? void 0 : _a51.next) === null || _b40 === void 0 ? void 0 : _b40.call(_a51, value);
49145
+ var _a51, _b41;
49146
+ (_b41 = (_a51 = this.destination) === null || _a51 === void 0 ? void 0 : _a51.next) === null || _b41 === void 0 ? void 0 : _b41.call(_a51, value);
49147
49147
  };
49148
49148
  AnonymousSubject2.prototype.error = function(err) {
49149
- var _a51, _b40;
49150
- (_b40 = (_a51 = this.destination) === null || _a51 === void 0 ? void 0 : _a51.error) === null || _b40 === void 0 ? void 0 : _b40.call(_a51, err);
49149
+ var _a51, _b41;
49150
+ (_b41 = (_a51 = this.destination) === null || _a51 === void 0 ? void 0 : _a51.error) === null || _b41 === void 0 ? void 0 : _b41.call(_a51, err);
49151
49151
  };
49152
49152
  AnonymousSubject2.prototype.complete = function() {
49153
- var _a51, _b40;
49154
- (_b40 = (_a51 = this.destination) === null || _a51 === void 0 ? void 0 : _a51.complete) === null || _b40 === void 0 ? void 0 : _b40.call(_a51);
49153
+ var _a51, _b41;
49154
+ (_b41 = (_a51 = this.destination) === null || _a51 === void 0 ? void 0 : _a51.complete) === null || _b41 === void 0 ? void 0 : _b41.call(_a51);
49155
49155
  };
49156
49156
  AnonymousSubject2.prototype._subscribe = function(subscriber) {
49157
- var _a51, _b40;
49158
- return (_b40 = (_a51 = this.source) === null || _a51 === void 0 ? void 0 : _a51.subscribe(subscriber)) !== null && _b40 !== void 0 ? _b40 : Subscription_1.EMPTY_SUBSCRIPTION;
49157
+ var _a51, _b41;
49158
+ return (_b41 = (_a51 = this.source) === null || _a51 === void 0 ? void 0 : _a51.subscribe(subscriber)) !== null && _b41 !== void 0 ? _b41 : Subscription_1.EMPTY_SUBSCRIPTION;
49159
49159
  };
49160
49160
  return AnonymousSubject2;
49161
49161
  })(Subject);
@@ -50614,29 +50614,29 @@ var require_isReadableStreamLike = __commonJS({
50614
50614
  function readableStreamLikeToAsyncGenerator(readableStream) {
50615
50615
  return __asyncGenerator(this, arguments, function readableStreamLikeToAsyncGenerator_1() {
50616
50616
  var reader, _a51, value, done;
50617
- return __generator(this, function(_b40) {
50618
- switch (_b40.label) {
50617
+ return __generator(this, function(_b41) {
50618
+ switch (_b41.label) {
50619
50619
  case 0:
50620
50620
  reader = readableStream.getReader();
50621
- _b40.label = 1;
50621
+ _b41.label = 1;
50622
50622
  case 1:
50623
- _b40.trys.push([1, , 9, 10]);
50624
- _b40.label = 2;
50623
+ _b41.trys.push([1, , 9, 10]);
50624
+ _b41.label = 2;
50625
50625
  case 2:
50626
50626
  if (false) return [3, 8];
50627
50627
  return [4, __await(reader.read())];
50628
50628
  case 3:
50629
- _a51 = _b40.sent(), value = _a51.value, done = _a51.done;
50629
+ _a51 = _b41.sent(), value = _a51.value, done = _a51.done;
50630
50630
  if (!done) return [3, 5];
50631
50631
  return [4, __await(void 0)];
50632
50632
  case 4:
50633
- return [2, _b40.sent()];
50633
+ return [2, _b41.sent()];
50634
50634
  case 5:
50635
50635
  return [4, __await(value)];
50636
50636
  case 6:
50637
- return [4, _b40.sent()];
50637
+ return [4, _b41.sent()];
50638
50638
  case 7:
50639
- _b40.sent();
50639
+ _b41.sent();
50640
50640
  return [3, 2];
50641
50641
  case 8:
50642
50642
  return [3, 10];
@@ -50900,37 +50900,37 @@ var require_innerFrom = __commonJS({
50900
50900
  var e_2, _a51;
50901
50901
  return __awaiter(this, void 0, void 0, function() {
50902
50902
  var value, e_2_1;
50903
- return __generator(this, function(_b40) {
50904
- switch (_b40.label) {
50903
+ return __generator(this, function(_b41) {
50904
+ switch (_b41.label) {
50905
50905
  case 0:
50906
- _b40.trys.push([0, 5, 6, 11]);
50906
+ _b41.trys.push([0, 5, 6, 11]);
50907
50907
  asyncIterable_1 = __asyncValues(asyncIterable);
50908
- _b40.label = 1;
50908
+ _b41.label = 1;
50909
50909
  case 1:
50910
50910
  return [4, asyncIterable_1.next()];
50911
50911
  case 2:
50912
- if (!(asyncIterable_1_1 = _b40.sent(), !asyncIterable_1_1.done)) return [3, 4];
50912
+ if (!(asyncIterable_1_1 = _b41.sent(), !asyncIterable_1_1.done)) return [3, 4];
50913
50913
  value = asyncIterable_1_1.value;
50914
50914
  subscriber.next(value);
50915
50915
  if (subscriber.closed) {
50916
50916
  return [2];
50917
50917
  }
50918
- _b40.label = 3;
50918
+ _b41.label = 3;
50919
50919
  case 3:
50920
50920
  return [3, 1];
50921
50921
  case 4:
50922
50922
  return [3, 11];
50923
50923
  case 5:
50924
- e_2_1 = _b40.sent();
50924
+ e_2_1 = _b41.sent();
50925
50925
  e_2 = { error: e_2_1 };
50926
50926
  return [3, 11];
50927
50927
  case 6:
50928
- _b40.trys.push([6, , 9, 10]);
50928
+ _b41.trys.push([6, , 9, 10]);
50929
50929
  if (!(asyncIterable_1_1 && !asyncIterable_1_1.done && (_a51 = asyncIterable_1.return))) return [3, 8];
50930
50930
  return [4, _a51.call(asyncIterable_1)];
50931
50931
  case 7:
50932
- _b40.sent();
50933
- _b40.label = 8;
50932
+ _b41.sent();
50933
+ _b41.label = 8;
50934
50934
  case 8:
50935
50935
  return [3, 10];
50936
50936
  case 9:
@@ -51339,12 +51339,12 @@ var require_Notification = __commonJS({
51339
51339
  })();
51340
51340
  exports2.Notification = Notification;
51341
51341
  function observeNotification(notification, observer) {
51342
- var _a51, _b40, _c11;
51342
+ var _a51, _b41, _c12;
51343
51343
  var _d8 = notification, kind = _d8.kind, value = _d8.value, error48 = _d8.error;
51344
51344
  if (typeof kind !== "string") {
51345
51345
  throw new TypeError('Invalid notification, missing "kind"');
51346
51346
  }
51347
- kind === "N" ? (_a51 = observer.next) === null || _a51 === void 0 ? void 0 : _a51.call(observer, value) : kind === "E" ? (_b40 = observer.error) === null || _b40 === void 0 ? void 0 : _b40.call(observer, error48) : (_c11 = observer.complete) === null || _c11 === void 0 ? void 0 : _c11.call(observer);
51347
+ kind === "N" ? (_a51 = observer.next) === null || _a51 === void 0 ? void 0 : _a51.call(observer, value) : kind === "E" ? (_b41 = observer.error) === null || _b41 === void 0 ? void 0 : _b41.call(observer, error48) : (_c12 = observer.complete) === null || _c12 === void 0 ? void 0 : _c12.call(observer);
51348
51348
  }
51349
51349
  exports2.observeNotification = observeNotification;
51350
51350
  }
@@ -51537,7 +51537,7 @@ var require_timeout = __commonJS({
51537
51537
  };
51538
51538
  });
51539
51539
  function timeout2(config2, schedulerArg) {
51540
- var _a51 = isDate_1.isValidDate(config2) ? { first: config2 } : typeof config2 === "number" ? { each: config2 } : config2, first = _a51.first, each = _a51.each, _b40 = _a51.with, _with = _b40 === void 0 ? timeoutErrorFactory : _b40, _c11 = _a51.scheduler, scheduler2 = _c11 === void 0 ? schedulerArg !== null && schedulerArg !== void 0 ? schedulerArg : async_1.asyncScheduler : _c11, _d8 = _a51.meta, meta3 = _d8 === void 0 ? null : _d8;
51540
+ var _a51 = isDate_1.isValidDate(config2) ? { first: config2 } : typeof config2 === "number" ? { each: config2 } : config2, first = _a51.first, each = _a51.each, _b41 = _a51.with, _with = _b41 === void 0 ? timeoutErrorFactory : _b41, _c12 = _a51.scheduler, scheduler2 = _c12 === void 0 ? schedulerArg !== null && schedulerArg !== void 0 ? schedulerArg : async_1.asyncScheduler : _c12, _d8 = _a51.meta, meta3 = _d8 === void 0 ? null : _d8;
51541
51541
  if (first == null && each == null) {
51542
51542
  throw new TypeError("No timeout provided.");
51543
51543
  }
@@ -52378,11 +52378,11 @@ var require_generate = __commonJS({
52378
52378
  var defer_1 = require_defer();
52379
52379
  var scheduleIterable_1 = require_scheduleIterable();
52380
52380
  function generate(initialStateOrOptions, condition, iterate, resultSelectorOrScheduler, scheduler2) {
52381
- var _a51, _b40;
52381
+ var _a51, _b41;
52382
52382
  var resultSelector;
52383
52383
  var initialState;
52384
52384
  if (arguments.length === 1) {
52385
- _a51 = initialStateOrOptions, initialState = _a51.initialState, condition = _a51.condition, iterate = _a51.iterate, _b40 = _a51.resultSelector, resultSelector = _b40 === void 0 ? identity_1.identity : _b40, scheduler2 = _a51.scheduler;
52385
+ _a51 = initialStateOrOptions, initialState = _a51.initialState, condition = _a51.condition, iterate = _a51.iterate, _b41 = _a51.resultSelector, resultSelector = _b41 === void 0 ? identity_1.identity : _b41, scheduler2 = _a51.scheduler;
52386
52386
  } else {
52387
52387
  initialState = initialStateOrOptions;
52388
52388
  if (!resultSelectorOrScheduler || isScheduler_1.isScheduler(resultSelectorOrScheduler)) {
@@ -52998,7 +52998,7 @@ var require_bufferCount = __commonJS({
52998
52998
  var buffers = [];
52999
52999
  var count = 0;
53000
53000
  source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function(value) {
53001
- var e_1, _a51, e_2, _b40;
53001
+ var e_1, _a51, e_2, _b41;
53002
53002
  var toEmit = null;
53003
53003
  if (count++ % startBufferEvery === 0) {
53004
53004
  buffers.push([]);
@@ -53032,7 +53032,7 @@ var require_bufferCount = __commonJS({
53032
53032
  e_2 = { error: e_2_1 };
53033
53033
  } finally {
53034
53034
  try {
53035
- if (toEmit_1_1 && !toEmit_1_1.done && (_b40 = toEmit_1.return)) _b40.call(toEmit_1);
53035
+ if (toEmit_1_1 && !toEmit_1_1.done && (_b41 = toEmit_1.return)) _b41.call(toEmit_1);
53036
53036
  } finally {
53037
53037
  if (e_2) throw e_2.error;
53038
53038
  }
@@ -53089,13 +53089,13 @@ var require_bufferTime = __commonJS({
53089
53089
  var args_1 = require_args();
53090
53090
  var executeSchedule_1 = require_executeSchedule();
53091
53091
  function bufferTime(bufferTimeSpan) {
53092
- var _a51, _b40;
53092
+ var _a51, _b41;
53093
53093
  var otherArgs = [];
53094
53094
  for (var _i = 1; _i < arguments.length; _i++) {
53095
53095
  otherArgs[_i - 1] = arguments[_i];
53096
53096
  }
53097
53097
  var scheduler2 = (_a51 = args_1.popScheduler(otherArgs)) !== null && _a51 !== void 0 ? _a51 : async_1.asyncScheduler;
53098
- var bufferCreationInterval = (_b40 = otherArgs[0]) !== null && _b40 !== void 0 ? _b40 : null;
53098
+ var bufferCreationInterval = (_b41 = otherArgs[0]) !== null && _b41 !== void 0 ? _b41 : null;
53099
53099
  var maxBufferSize = otherArgs[1] || Infinity;
53100
53100
  return lift_1.operate(function(source, subscriber) {
53101
53101
  var bufferRecords = [];
@@ -55119,7 +55119,7 @@ var require_retry = __commonJS({
55119
55119
  count: configOrCount
55120
55120
  };
55121
55121
  }
55122
- var _a51 = config2.count, count = _a51 === void 0 ? Infinity : _a51, delay2 = config2.delay, _b40 = config2.resetOnSuccess, resetOnSuccess = _b40 === void 0 ? false : _b40;
55122
+ var _a51 = config2.count, count = _a51 === void 0 ? Infinity : _a51, delay2 = config2.delay, _b41 = config2.resetOnSuccess, resetOnSuccess = _b41 === void 0 ? false : _b41;
55123
55123
  return count <= 0 ? identity_1.identity : lift_1.operate(function(source, subscriber) {
55124
55124
  var soFar = 0;
55125
55125
  var innerSub;
@@ -55367,7 +55367,7 @@ var require_share = __commonJS({
55367
55367
  }
55368
55368
  var _a51 = options.connector, connector = _a51 === void 0 ? function() {
55369
55369
  return new Subject_1.Subject();
55370
- } : _a51, _b40 = options.resetOnError, resetOnError = _b40 === void 0 ? true : _b40, _c11 = options.resetOnComplete, resetOnComplete = _c11 === void 0 ? true : _c11, _d8 = options.resetOnRefCountZero, resetOnRefCountZero = _d8 === void 0 ? true : _d8;
55370
+ } : _a51, _b41 = options.resetOnError, resetOnError = _b41 === void 0 ? true : _b41, _c12 = options.resetOnComplete, resetOnComplete = _c12 === void 0 ? true : _c12, _d8 = options.resetOnRefCountZero, resetOnRefCountZero = _d8 === void 0 ? true : _d8;
55371
55371
  return function(wrapperSource) {
55372
55372
  var connection;
55373
55373
  var resetConnection;
@@ -55458,11 +55458,11 @@ var require_shareReplay = __commonJS({
55458
55458
  var ReplaySubject_1 = require_ReplaySubject();
55459
55459
  var share_1 = require_share();
55460
55460
  function shareReplay(configOrBufferSize, windowTime, scheduler2) {
55461
- var _a51, _b40, _c11;
55461
+ var _a51, _b41, _c12;
55462
55462
  var bufferSize;
55463
55463
  var refCount = false;
55464
55464
  if (configOrBufferSize && typeof configOrBufferSize === "object") {
55465
- _a51 = configOrBufferSize.bufferSize, bufferSize = _a51 === void 0 ? Infinity : _a51, _b40 = configOrBufferSize.windowTime, windowTime = _b40 === void 0 ? Infinity : _b40, _c11 = configOrBufferSize.refCount, refCount = _c11 === void 0 ? false : _c11, scheduler2 = configOrBufferSize.scheduler;
55465
+ _a51 = configOrBufferSize.bufferSize, bufferSize = _a51 === void 0 ? Infinity : _a51, _b41 = configOrBufferSize.windowTime, windowTime = _b41 === void 0 ? Infinity : _b41, _c12 = configOrBufferSize.refCount, refCount = _c12 === void 0 ? false : _c12, scheduler2 = configOrBufferSize.scheduler;
55466
55466
  } else {
55467
55467
  bufferSize = configOrBufferSize !== null && configOrBufferSize !== void 0 ? configOrBufferSize : Infinity;
55468
55468
  }
@@ -55811,11 +55811,11 @@ var require_tap = __commonJS({
55811
55811
  (_a54 = tapObserver.error) === null || _a54 === void 0 ? void 0 : _a54.call(tapObserver, err);
55812
55812
  subscriber.error(err);
55813
55813
  }, function() {
55814
- var _a54, _b40;
55814
+ var _a54, _b41;
55815
55815
  if (isUnsub) {
55816
55816
  (_a54 = tapObserver.unsubscribe) === null || _a54 === void 0 ? void 0 : _a54.call(tapObserver);
55817
55817
  }
55818
- (_b40 = tapObserver.finalize) === null || _b40 === void 0 ? void 0 : _b40.call(tapObserver);
55818
+ (_b41 = tapObserver.finalize) === null || _b41 === void 0 ? void 0 : _b41.call(tapObserver);
55819
55819
  }));
55820
55820
  }) : identity_1.identity;
55821
55821
  }
@@ -55834,7 +55834,7 @@ var require_throttle = __commonJS({
55834
55834
  var innerFrom_1 = require_innerFrom();
55835
55835
  function throttle(durationSelector, config2) {
55836
55836
  return lift_1.operate(function(source, subscriber) {
55837
- var _a51 = config2 !== null && config2 !== void 0 ? config2 : {}, _b40 = _a51.leading, leading = _b40 === void 0 ? true : _b40, _c11 = _a51.trailing, trailing = _c11 === void 0 ? false : _c11;
55837
+ var _a51 = config2 !== null && config2 !== void 0 ? config2 : {}, _b41 = _a51.leading, leading = _b41 === void 0 ? true : _b41, _c12 = _a51.trailing, trailing = _c12 === void 0 ? false : _c12;
55838
55838
  var hasValue = false;
55839
55839
  var sendValue = null;
55840
55840
  var throttled = null;
@@ -56123,13 +56123,13 @@ var require_windowTime = __commonJS({
56123
56123
  var args_1 = require_args();
56124
56124
  var executeSchedule_1 = require_executeSchedule();
56125
56125
  function windowTime(windowTimeSpan) {
56126
- var _a51, _b40;
56126
+ var _a51, _b41;
56127
56127
  var otherArgs = [];
56128
56128
  for (var _i = 1; _i < arguments.length; _i++) {
56129
56129
  otherArgs[_i - 1] = arguments[_i];
56130
56130
  }
56131
56131
  var scheduler2 = (_a51 = args_1.popScheduler(otherArgs)) !== null && _a51 !== void 0 ? _a51 : async_1.asyncScheduler;
56132
- var windowCreationInterval = (_b40 = otherArgs[0]) !== null && _b40 !== void 0 ? _b40 : null;
56132
+ var windowCreationInterval = (_b41 = otherArgs[0]) !== null && _b41 !== void 0 ? _b41 : null;
56133
56133
  var maxWindowSize = otherArgs[1] || Infinity;
56134
56134
  return lift_1.operate(function(source, subscriber) {
56135
56135
  var windowRecords = [];
@@ -57530,7 +57530,7 @@ var require_queue2 = __commonJS({
57530
57530
  var require_error2 = __commonJS({
57531
57531
  "../../node_modules/.pnpm/@fastify+error@4.2.0/node_modules/@fastify/error/index.js"(exports2, module2) {
57532
57532
  "use strict";
57533
- var { format } = require("node:util");
57533
+ var { format: format2 } = require("node:util");
57534
57534
  function toString() {
57535
57535
  return `${this.name} [${this.code}]: ${this.message}`;
57536
57536
  }
@@ -57556,7 +57556,7 @@ var require_error2 = __commonJS({
57556
57556
  if (lastElement !== -1 && args[lastElement] && typeof args[lastElement] === "object" && "cause" in args[lastElement]) {
57557
57557
  this.cause = args.pop().cause;
57558
57558
  }
57559
- this.message = format(message, ...args);
57559
+ this.message = format2(message, ...args);
57560
57560
  Error.stackTraceLimit && captureStackTrace2 && Error.captureStackTrace(this, FastifyError);
57561
57561
  }
57562
57562
  FastifyError.prototype = Object.create(Base.prototype, {
@@ -58715,7 +58715,7 @@ var require_symbols3 = __commonJS({
58715
58715
  var require_process_warning = __commonJS({
58716
58716
  "../../node_modules/.pnpm/process-warning@5.0.0/node_modules/process-warning/index.js"(exports2, module2) {
58717
58717
  "use strict";
58718
- var { format } = require("node:util");
58718
+ var { format: format2 } = require("node:util");
58719
58719
  function createDeprecation(params) {
58720
58720
  return createWarning({ ...params, name: "DeprecationWarning" });
58721
58721
  }
@@ -58750,11 +58750,11 @@ var require_process_warning = __commonJS({
58750
58750
  warning.format = function(a3, b2, c3) {
58751
58751
  let formatted;
58752
58752
  if (a3 && b2 && c3) {
58753
- formatted = format(message, a3, b2, c3);
58753
+ formatted = format2(message, a3, b2, c3);
58754
58754
  } else if (a3 && b2) {
58755
- formatted = format(message, a3, b2);
58755
+ formatted = format2(message, a3, b2);
58756
58756
  } else if (a3) {
58757
- formatted = format(message, a3);
58757
+ formatted = format2(message, a3);
58758
58758
  } else {
58759
58759
  formatted = message;
58760
58760
  }
@@ -72720,11 +72720,11 @@ var require_util4 = __commonJS({
72720
72720
  });
72721
72721
  };
72722
72722
  exports2.tokenizeClass = (str, regexpStr) => {
72723
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6;
72723
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6;
72724
72724
  let tokens = [], rs, c3;
72725
72725
  const regexp = /\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;
72726
72726
  while ((rs = regexp.exec(str)) !== null) {
72727
- const p2 = (_g6 = (_f3 = (_e7 = (_d8 = (_c11 = (_b40 = (_a51 = rs[1] && sets.words()) !== null && _a51 !== void 0 ? _a51 : rs[2] && sets.ints()) !== null && _b40 !== void 0 ? _b40 : rs[3] && sets.whitespace()) !== null && _c11 !== void 0 ? _c11 : rs[4] && sets.notWords()) !== null && _d8 !== void 0 ? _d8 : rs[5] && sets.notInts()) !== null && _e7 !== void 0 ? _e7 : rs[6] && sets.notWhitespace()) !== null && _f3 !== void 0 ? _f3 : rs[7] && {
72727
+ const p2 = (_g6 = (_f3 = (_e7 = (_d8 = (_c12 = (_b41 = (_a51 = rs[1] && sets.words()) !== null && _a51 !== void 0 ? _a51 : rs[2] && sets.ints()) !== null && _b41 !== void 0 ? _b41 : rs[3] && sets.whitespace()) !== null && _c12 !== void 0 ? _c12 : rs[4] && sets.notWords()) !== null && _d8 !== void 0 ? _d8 : rs[5] && sets.notInts()) !== null && _e7 !== void 0 ? _e7 : rs[6] && sets.notWhitespace()) !== null && _f3 !== void 0 ? _f3 : rs[7] && {
72728
72728
  type: types_1.types.RANGE,
72729
72729
  from: (rs[8] || rs[9]).charCodeAt(0),
72730
72730
  to: (c3 = rs[10]).charCodeAt(c3.length - 1)
@@ -77057,7 +77057,7 @@ var require_dist5 = __commonJS({
77057
77057
  var require_process_warning2 = __commonJS({
77058
77058
  "../../node_modules/.pnpm/process-warning@4.0.1/node_modules/process-warning/index.js"(exports2, module2) {
77059
77059
  "use strict";
77060
- var { format } = require("node:util");
77060
+ var { format: format2 } = require("node:util");
77061
77061
  function createDeprecation(params) {
77062
77062
  return createWarning({ ...params, name: "DeprecationWarning" });
77063
77063
  }
@@ -77092,11 +77092,11 @@ var require_process_warning2 = __commonJS({
77092
77092
  warning.format = function(a3, b2, c3) {
77093
77093
  let formatted;
77094
77094
  if (a3 && b2 && c3) {
77095
- formatted = format(message, a3, b2, c3);
77095
+ formatted = format2(message, a3, b2, c3);
77096
77096
  } else if (a3 && b2) {
77097
- formatted = format(message, a3, b2);
77097
+ formatted = format2(message, a3, b2);
77098
77098
  } else if (a3) {
77099
- formatted = format(message, a3);
77099
+ formatted = format2(message, a3);
77100
77100
  } else {
77101
77101
  formatted = message;
77102
77102
  }
@@ -79977,7 +79977,7 @@ var require_bytes = __commonJS({
79977
79977
  "../../node_modules/.pnpm/bytes@3.1.2/node_modules/bytes/index.js"(exports2, module2) {
79978
79978
  "use strict";
79979
79979
  module2.exports = bytes;
79980
- module2.exports.format = format;
79980
+ module2.exports.format = format2;
79981
79981
  module2.exports.parse = parse3;
79982
79982
  var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
79983
79983
  var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
@@ -79995,11 +79995,11 @@ var require_bytes = __commonJS({
79995
79995
  return parse3(value);
79996
79996
  }
79997
79997
  if (typeof value === "number") {
79998
- return format(value, options);
79998
+ return format2(value, options);
79999
79999
  }
80000
80000
  return null;
80001
80001
  }
80002
- function format(value, options) {
80002
+ function format2(value, options) {
80003
80003
  if (!Number.isFinite(value)) {
80004
80004
  return null;
80005
80005
  }
@@ -80196,8 +80196,8 @@ var require_depd = __commonJS({
80196
80196
  process.emit("deprecation", err);
80197
80197
  return;
80198
80198
  }
80199
- var format = process.stderr.isTTY ? formatColor : formatPlain;
80200
- var output = format.call(this, msg, caller, stack.slice(i2));
80199
+ var format2 = process.stderr.isTTY ? formatColor : formatPlain;
80200
+ var output = format2.call(this, msg, caller, stack.slice(i2));
80201
80201
  process.stderr.write(output + "\n", "utf8");
80202
80202
  }
80203
80203
  function callSiteLocation(callSite) {
@@ -84772,9 +84772,9 @@ var require_content_type = __commonJS({
84772
84772
  var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
84773
84773
  var QUOTE_REGEXP = /([\\"])/g;
84774
84774
  var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
84775
- exports2.format = format;
84775
+ exports2.format = format2;
84776
84776
  exports2.parse = parse3;
84777
- function format(obj) {
84777
+ function format2(obj) {
84778
84778
  if (!obj || typeof obj !== "object") {
84779
84779
  throw new TypeError("argument obj is required");
84780
84780
  }
@@ -87670,7 +87670,7 @@ var OPTIMIZATION_INSIGHTS_TIMEFRAMES = [
87670
87670
  var DEFAULT_OPTIMIZATION_INSIGHTS_LOOKBACK_SECONDS = 30 * 24 * 60 * 60;
87671
87671
 
87672
87672
  // ../common/src/constants.node.ts
87673
- var MCP_CALL_TOOL_TIMEOUT = parseInt(process.env.MCP_CALL_TOOL_TIMEOUT ?? "10000", 10);
87673
+ var MCP_CALL_TOOL_TIMEOUT = parseInt(process.env.MCP_CALL_TOOL_TIMEOUT ?? "60000", 10);
87674
87674
  var DEFAULT_REQUEST_TIMEOUT = parseInt(process.env.DEFAULT_REQUEST_TIMEOUT ?? "10000", 10);
87675
87675
  var SCRIPT_ROUTE_TIMEOUT_MS = 31e4;
87676
87676
 
@@ -88238,8 +88238,8 @@ Error message: ${getErrorMessage(cause)}`,
88238
88238
  cause,
88239
88239
  context: context2
88240
88240
  }) {
88241
- var _a153, _b152, _c11;
88242
- if (_TypeValidationError.isInstance(cause) && cause.value === value && ((_a153 = cause.context) == null ? void 0 : _a153.field) === (context2 == null ? void 0 : context2.field) && ((_b152 = cause.context) == null ? void 0 : _b152.entityName) === (context2 == null ? void 0 : context2.entityName) && ((_c11 = cause.context) == null ? void 0 : _c11.entityId) === (context2 == null ? void 0 : context2.entityId)) {
88241
+ var _a153, _b152, _c12;
88242
+ if (_TypeValidationError.isInstance(cause) && cause.value === value && ((_a153 = cause.context) == null ? void 0 : _a153.field) === (context2 == null ? void 0 : context2.field) && ((_b152 = cause.context) == null ? void 0 : _b152.entityName) === (context2 == null ? void 0 : context2.entityName) && ((_c12 = cause.context) == null ? void 0 : _c12.entityId) === (context2 == null ? void 0 : context2.entityId)) {
88243
88243
  return cause;
88244
88244
  }
88245
88245
  return new _TypeValidationError({ value, cause, context: context2 });
@@ -89605,7 +89605,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
89605
89605
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
89606
89606
  const result = { errors: [] };
89607
89607
  const processError = (error49, path4 = []) => {
89608
- var _a51, _b40;
89608
+ var _a51, _b41;
89609
89609
  for (const issue2 of error49.issues) {
89610
89610
  if (issue2.code === "invalid_union" && issue2.errors.length) {
89611
89611
  issue2.errors.map((issues) => processError({ issues }, issue2.path));
@@ -89630,7 +89630,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
89630
89630
  curr = curr.properties[el];
89631
89631
  } else {
89632
89632
  curr.items ?? (curr.items = []);
89633
- (_b40 = curr.items)[el] ?? (_b40[el] = { errors: [] });
89633
+ (_b41 = curr.items)[el] ?? (_b41[el] = { errors: [] });
89634
89634
  curr = curr.items[el];
89635
89635
  }
89636
89636
  if (terminal) {
@@ -90298,7 +90298,7 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
90298
90298
  };
90299
90299
  });
90300
90300
  var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
90301
- var _a51, _b40;
90301
+ var _a51, _b41;
90302
90302
  $ZodCheck.init(inst, def);
90303
90303
  inst._zod.onattach.push((inst2) => {
90304
90304
  const bag = inst2._zod.bag;
@@ -90324,7 +90324,7 @@ var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat"
90324
90324
  });
90325
90325
  });
90326
90326
  else
90327
- (_b40 = inst._zod).check ?? (_b40.check = () => {
90327
+ (_b41 = inst._zod).check ?? (_b41.check = () => {
90328
90328
  });
90329
90329
  });
90330
90330
  var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
@@ -99129,13 +99129,13 @@ function _stringbool(Classes, _params) {
99129
99129
  return codec2;
99130
99130
  }
99131
99131
  // @__NO_SIDE_EFFECTS__
99132
- function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
99132
+ function _stringFormat(Class2, format2, fnOrRegex, _params = {}) {
99133
99133
  const params = normalizeParams(_params);
99134
99134
  const def = {
99135
99135
  ...normalizeParams(_params),
99136
99136
  check: "string_format",
99137
99137
  type: "string",
99138
- format,
99138
+ format: format2,
99139
99139
  fn: typeof fnOrRegex === "function" ? fnOrRegex : (val) => fnOrRegex.test(val),
99140
99140
  ...params
99141
99141
  };
@@ -99510,16 +99510,16 @@ var formatMap = {
99510
99510
  var stringProcessor = (schema, ctx, _json, _params) => {
99511
99511
  const json3 = _json;
99512
99512
  json3.type = "string";
99513
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
99513
+ const { minimum, maximum, format: format2, patterns, contentEncoding } = schema._zod.bag;
99514
99514
  if (typeof minimum === "number")
99515
99515
  json3.minLength = minimum;
99516
99516
  if (typeof maximum === "number")
99517
99517
  json3.maxLength = maximum;
99518
- if (format) {
99519
- json3.format = formatMap[format] ?? format;
99518
+ if (format2) {
99519
+ json3.format = formatMap[format2] ?? format2;
99520
99520
  if (json3.format === "")
99521
99521
  delete json3.format;
99522
- if (format === "time") {
99522
+ if (format2 === "time") {
99523
99523
  delete json3.format;
99524
99524
  }
99525
99525
  }
@@ -99541,8 +99541,8 @@ var stringProcessor = (schema, ctx, _json, _params) => {
99541
99541
  };
99542
99542
  var numberProcessor = (schema, ctx, _json, _params) => {
99543
99543
  const json3 = _json;
99544
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
99545
- if (typeof format === "string" && format.includes("int"))
99544
+ const { minimum, maximum, format: format2, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
99545
+ if (typeof format2 === "string" && format2.includes("int"))
99546
99546
  json3.type = "integer";
99547
99547
  else
99548
99548
  json3.type = "number";
@@ -100731,8 +100731,8 @@ var ZodCustomStringFormat = /* @__PURE__ */ $constructor("ZodCustomStringFormat"
100731
100731
  $ZodCustomStringFormat.init(inst, def);
100732
100732
  ZodStringFormat.init(inst, def);
100733
100733
  });
100734
- function stringFormat(format, fnOrRegex, _params = {}) {
100735
- return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
100734
+ function stringFormat(format2, fnOrRegex, _params = {}) {
100735
+ return _stringFormat(ZodCustomStringFormat, format2, fnOrRegex, _params);
100736
100736
  }
100737
100737
  function hostname2(_params) {
100738
100738
  return _stringFormat(ZodCustomStringFormat, "hostname", regexes_exports.hostname, _params);
@@ -100742,11 +100742,11 @@ function hex2(_params) {
100742
100742
  }
100743
100743
  function hash(alg, params) {
100744
100744
  const enc = params?.enc ?? "hex";
100745
- const format = `${alg}_${enc}`;
100746
- const regex = regexes_exports[format];
100745
+ const format2 = `${alg}_${enc}`;
100746
+ const regex = regexes_exports[format2];
100747
100747
  if (!regex)
100748
- throw new Error(`Unrecognized hash format: ${format}`);
100749
- return _stringFormat(ZodCustomStringFormat, format, regex, params);
100748
+ throw new Error(`Unrecognized hash format: ${format2}`);
100749
+ return _stringFormat(ZodCustomStringFormat, format2, regex, params);
100750
100750
  }
100751
100751
  var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
100752
100752
  $ZodNumber.init(inst, def);
@@ -101722,52 +101722,52 @@ function convertBaseSchema(schema, ctx) {
101722
101722
  case "string": {
101723
101723
  let stringSchema = z3.string();
101724
101724
  if (schema.format) {
101725
- const format = schema.format;
101726
- if (format === "email") {
101725
+ const format2 = schema.format;
101726
+ if (format2 === "email") {
101727
101727
  stringSchema = stringSchema.check(z3.email());
101728
- } else if (format === "uri" || format === "uri-reference") {
101728
+ } else if (format2 === "uri" || format2 === "uri-reference") {
101729
101729
  stringSchema = stringSchema.check(z3.url());
101730
- } else if (format === "uuid" || format === "guid") {
101730
+ } else if (format2 === "uuid" || format2 === "guid") {
101731
101731
  stringSchema = stringSchema.check(z3.uuid());
101732
- } else if (format === "date-time") {
101732
+ } else if (format2 === "date-time") {
101733
101733
  stringSchema = stringSchema.check(z3.iso.datetime());
101734
- } else if (format === "date") {
101734
+ } else if (format2 === "date") {
101735
101735
  stringSchema = stringSchema.check(z3.iso.date());
101736
- } else if (format === "time") {
101736
+ } else if (format2 === "time") {
101737
101737
  stringSchema = stringSchema.check(z3.iso.time());
101738
- } else if (format === "duration") {
101738
+ } else if (format2 === "duration") {
101739
101739
  stringSchema = stringSchema.check(z3.iso.duration());
101740
- } else if (format === "ipv4") {
101740
+ } else if (format2 === "ipv4") {
101741
101741
  stringSchema = stringSchema.check(z3.ipv4());
101742
- } else if (format === "ipv6") {
101742
+ } else if (format2 === "ipv6") {
101743
101743
  stringSchema = stringSchema.check(z3.ipv6());
101744
- } else if (format === "mac") {
101744
+ } else if (format2 === "mac") {
101745
101745
  stringSchema = stringSchema.check(z3.mac());
101746
- } else if (format === "cidr") {
101746
+ } else if (format2 === "cidr") {
101747
101747
  stringSchema = stringSchema.check(z3.cidrv4());
101748
- } else if (format === "cidr-v6") {
101748
+ } else if (format2 === "cidr-v6") {
101749
101749
  stringSchema = stringSchema.check(z3.cidrv6());
101750
- } else if (format === "base64") {
101750
+ } else if (format2 === "base64") {
101751
101751
  stringSchema = stringSchema.check(z3.base64());
101752
- } else if (format === "base64url") {
101752
+ } else if (format2 === "base64url") {
101753
101753
  stringSchema = stringSchema.check(z3.base64url());
101754
- } else if (format === "e164") {
101754
+ } else if (format2 === "e164") {
101755
101755
  stringSchema = stringSchema.check(z3.e164());
101756
- } else if (format === "jwt") {
101756
+ } else if (format2 === "jwt") {
101757
101757
  stringSchema = stringSchema.check(z3.jwt());
101758
- } else if (format === "emoji") {
101758
+ } else if (format2 === "emoji") {
101759
101759
  stringSchema = stringSchema.check(z3.emoji());
101760
- } else if (format === "nanoid") {
101760
+ } else if (format2 === "nanoid") {
101761
101761
  stringSchema = stringSchema.check(z3.nanoid());
101762
- } else if (format === "cuid") {
101762
+ } else if (format2 === "cuid") {
101763
101763
  stringSchema = stringSchema.check(z3.cuid());
101764
- } else if (format === "cuid2") {
101764
+ } else if (format2 === "cuid2") {
101765
101765
  stringSchema = stringSchema.check(z3.cuid2());
101766
- } else if (format === "ulid") {
101766
+ } else if (format2 === "ulid") {
101767
101767
  stringSchema = stringSchema.check(z3.ulid());
101768
- } else if (format === "xid") {
101768
+ } else if (format2 === "xid") {
101769
101769
  stringSchema = stringSchema.check(z3.xid());
101770
- } else if (format === "ksuid") {
101770
+ } else if (format2 === "ksuid") {
101771
101771
  stringSchema = stringSchema.check(z3.ksuid());
101772
101772
  }
101773
101773
  }
@@ -106386,14 +106386,14 @@ function handleFetchError({
106386
106386
  return error48;
106387
106387
  }
106388
106388
  function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
106389
- var _a210, _b210, _c11;
106389
+ var _a210, _b210, _c12;
106390
106390
  if (globalThisAny.window) {
106391
106391
  return `runtime/browser`;
106392
106392
  }
106393
106393
  if ((_a210 = globalThisAny.navigator) == null ? void 0 : _a210.userAgent) {
106394
106394
  return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
106395
106395
  }
106396
- if ((_c11 = (_b210 = globalThisAny.process) == null ? void 0 : _b210.versions) == null ? void 0 : _c11.node) {
106396
+ if ((_c12 = (_b210 = globalThisAny.process) == null ? void 0 : _b210.versions) == null ? void 0 : _c12.node) {
106397
106397
  return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
106398
106398
  }
106399
106399
  if (globalThisAny.EdgeRuntime) {
@@ -106722,11 +106722,11 @@ function parseAnyDef() {
106722
106722
  return {};
106723
106723
  }
106724
106724
  function parseArrayDef(def, refs) {
106725
- var _a210, _b210, _c11;
106725
+ var _a210, _b210, _c12;
106726
106726
  const res = {
106727
106727
  type: "array"
106728
106728
  };
106729
- if (((_a210 = def.type) == null ? void 0 : _a210._def) && ((_c11 = (_b210 = def.type) == null ? void 0 : _b210._def) == null ? void 0 : _c11.typeName) !== ZodFirstPartyTypeKind2.ZodAny) {
106729
+ if (((_a210 = def.type) == null ? void 0 : _a210._def) && ((_c12 = (_b210 = def.type) == null ? void 0 : _b210._def) == null ? void 0 : _c12.typeName) !== ZodFirstPartyTypeKind2.ZodAny) {
106730
106730
  res.items = parseDef(def.type._def, {
106731
106731
  ...refs,
106732
106732
  currentPath: [...refs.currentPath, "items"]
@@ -107214,7 +107214,7 @@ function stringifyRegExpWithFlags(regex, refs) {
107214
107214
  return pattern;
107215
107215
  }
107216
107216
  function parseRecordDef(def, refs) {
107217
- var _a210, _b210, _c11, _d8, _e7, _f3;
107217
+ var _a210, _b210, _c12, _d8, _e7, _f3;
107218
107218
  const schema = {
107219
107219
  type: "object",
107220
107220
  additionalProperties: (_a210 = parseDef(def.valueType._def, {
@@ -107222,7 +107222,7 @@ function parseRecordDef(def, refs) {
107222
107222
  currentPath: [...refs.currentPath, "additionalProperties"]
107223
107223
  })) != null ? _a210 : refs.allowedAdditionalProperties
107224
107224
  };
107225
- if (((_b210 = def.keyType) == null ? void 0 : _b210._def.typeName) === ZodFirstPartyTypeKind2.ZodString && ((_c11 = def.keyType._def.checks) == null ? void 0 : _c11.length)) {
107225
+ if (((_b210 = def.keyType) == null ? void 0 : _b210._def.typeName) === ZodFirstPartyTypeKind2.ZodString && ((_c12 = def.keyType._def.checks) == null ? void 0 : _c12.length)) {
107226
107226
  const { type: type22, ...keyType } = parseStringDef(def.keyType._def, refs);
107227
107227
  return {
107228
107228
  ...schema,
@@ -109393,7 +109393,7 @@ var SseMCPTransport = class {
109393
109393
  }
109394
109394
  this.abortController = new AbortController();
109395
109395
  const establishConnection = async (triedAuth = false) => {
109396
- var _a310, _b310, _c11, _d8, _e7;
109396
+ var _a310, _b310, _c12, _d8, _e7;
109397
109397
  try {
109398
109398
  const headers = await this.commonHeaders({
109399
109399
  Accept: "text/event-stream"
@@ -109415,7 +109415,7 @@ var SseMCPTransport = class {
109415
109415
  return reject(error48);
109416
109416
  }
109417
109417
  } catch (error48) {
109418
- (_c11 = this.onerror) == null ? void 0 : _c11.call(this, error48);
109418
+ (_c12 = this.onerror) == null ? void 0 : _c12.call(this, error48);
109419
109419
  return reject(error48);
109420
109420
  }
109421
109421
  return establishConnection(true);
@@ -109496,11 +109496,11 @@ var SseMCPTransport = class {
109496
109496
  });
109497
109497
  }
109498
109498
  async close() {
109499
- var _a310, _b310, _c11;
109499
+ var _a310, _b310, _c12;
109500
109500
  this.connected = false;
109501
109501
  (_a310 = this.sseConnection) == null ? void 0 : _a310.close();
109502
109502
  (_b310 = this.abortController) == null ? void 0 : _b310.abort();
109503
- (_c11 = this.onclose) == null ? void 0 : _c11.call(this);
109503
+ (_c12 = this.onclose) == null ? void 0 : _c12.call(this);
109504
109504
  }
109505
109505
  async send(message) {
109506
109506
  if (!this.endpoint || !this.connected) {
@@ -109510,7 +109510,7 @@ var SseMCPTransport = class {
109510
109510
  }
109511
109511
  const endpoint = this.endpoint;
109512
109512
  const attempt = async (triedAuth = false) => {
109513
- var _a310, _b310, _c11, _d8, _e7;
109513
+ var _a310, _b310, _c12, _d8, _e7;
109514
109514
  try {
109515
109515
  const headers = await this.commonHeaders({
109516
109516
  "Content-Type": "application/json"
@@ -109535,7 +109535,7 @@ var SseMCPTransport = class {
109535
109535
  return;
109536
109536
  }
109537
109537
  } catch (error48) {
109538
- (_c11 = this.onerror) == null ? void 0 : _c11.call(this, error48);
109538
+ (_c12 = this.onerror) == null ? void 0 : _c12.call(this, error48);
109539
109539
  return;
109540
109540
  }
109541
109541
  return attempt(true);
@@ -109604,7 +109604,7 @@ var HttpMCPTransport = class {
109604
109604
  void this.openInboundSse();
109605
109605
  }
109606
109606
  async close() {
109607
- var _a310, _b310, _c11;
109607
+ var _a310, _b310, _c12;
109608
109608
  (_a310 = this.inboundSseConnection) == null ? void 0 : _a310.close();
109609
109609
  try {
109610
109610
  if (this.sessionId && this.abortController && !this.abortController.signal.aborted) {
@@ -109618,11 +109618,11 @@ var HttpMCPTransport = class {
109618
109618
  } catch (e2) {
109619
109619
  }
109620
109620
  (_b310 = this.abortController) == null ? void 0 : _b310.abort();
109621
- (_c11 = this.onclose) == null ? void 0 : _c11.call(this);
109621
+ (_c12 = this.onclose) == null ? void 0 : _c12.call(this);
109622
109622
  }
109623
109623
  async send(message) {
109624
109624
  const attempt = async (triedAuth = false) => {
109625
- var _a310, _b310, _c11, _d8, _e7, _f3, _g6;
109625
+ var _a310, _b310, _c12, _d8, _e7, _f3, _g6;
109626
109626
  try {
109627
109627
  const headers = await this.commonHeaders({
109628
109628
  "Content-Type": "application/json",
@@ -109671,7 +109671,7 @@ var HttpMCPTransport = class {
109671
109671
  const error210 = new MCPClientError({
109672
109672
  message: errorMessage
109673
109673
  });
109674
- (_c11 = this.onerror) == null ? void 0 : _c11.call(this, error210);
109674
+ (_c12 = this.onerror) == null ? void 0 : _c12.call(this, error210);
109675
109675
  throw error210;
109676
109676
  }
109677
109677
  const isNotification = !("id" in message);
@@ -109770,7 +109770,7 @@ var HttpMCPTransport = class {
109770
109770
  }
109771
109771
  // Open optional inbound SSE stream; best-effort and resumable
109772
109772
  async openInboundSse(triedAuth = false, resumeToken) {
109773
- var _a310, _b310, _c11, _d8, _e7, _f3;
109773
+ var _a310, _b310, _c12, _d8, _e7, _f3;
109774
109774
  try {
109775
109775
  const headers = await this.commonHeaders({
109776
109776
  Accept: "text/event-stream"
@@ -109800,7 +109800,7 @@ var HttpMCPTransport = class {
109800
109800
  return;
109801
109801
  }
109802
109802
  } catch (error48) {
109803
- (_c11 = this.onerror) == null ? void 0 : _c11.call(this, error48);
109803
+ (_c12 = this.onerror) == null ? void 0 : _c12.call(this, error48);
109804
109804
  return;
109805
109805
  }
109806
109806
  return this.openInboundSse(true, resumeToken);
@@ -110773,7 +110773,7 @@ var import_transport_node = __toESM(require_transport_node(), 1);
110773
110773
  var import_kv = __toESM(require_mod4(), 1);
110774
110774
 
110775
110775
  // ../common/src/services/service.interface.ts
110776
- var Service = class _Service {
110776
+ var LifecycleService = class _LifecycleService {
110777
110777
  constructor() {
110778
110778
  this.consumers = /* @__PURE__ */ new Set();
110779
110779
  this.state = "STOPPED";
@@ -110792,7 +110792,7 @@ var Service = class _Service {
110792
110792
  * Get detailed information about all currently active services
110793
110793
  */
110794
110794
  static getActiveServices() {
110795
- return Array.from(_Service.activeServices).map((service) => ({
110795
+ return Array.from(_LifecycleService.activeServices).map((service) => ({
110796
110796
  name: service.name,
110797
110797
  state: service.state,
110798
110798
  consumers: Array.from(service.consumers)
@@ -110814,11 +110814,11 @@ var Service = class _Service {
110814
110814
  } else if (this.state === "STOPPED") {
110815
110815
  this.consumers.add(consumer);
110816
110816
  this.state = "STARTING";
110817
- _Service.activeServices.add(this);
110817
+ _LifecycleService.activeServices.add(this);
110818
110818
  this.currentPromise = this.initialize().catch((error48) => {
110819
110819
  this.state = "STOPPED";
110820
110820
  this.currentPromise = void 0;
110821
- _Service.activeServices.delete(this);
110821
+ _LifecycleService.activeServices.delete(this);
110822
110822
  throw error48;
110823
110823
  });
110824
110824
  try {
@@ -110826,7 +110826,7 @@ var Service = class _Service {
110826
110826
  } catch (error48) {
110827
110827
  this.state = "STOPPED";
110828
110828
  this.currentPromise = void 0;
110829
- _Service.activeServices.delete(this);
110829
+ _LifecycleService.activeServices.delete(this);
110830
110830
  throw error48;
110831
110831
  }
110832
110832
  this.currentPromise = void 0;
@@ -110855,7 +110855,7 @@ var Service = class _Service {
110855
110855
  }
110856
110856
  if (this.state === "STARTED") {
110857
110857
  this.state = "STOPPING";
110858
- _Service.activeServices.delete(this);
110858
+ _LifecycleService.activeServices.delete(this);
110859
110859
  this.currentPromise = this.shutdown();
110860
110860
  await this.currentPromise;
110861
110861
  this.state = "STOPPED";
@@ -111068,7 +111068,7 @@ var __param2 = function(paramIndex, decorator) {
111068
111068
  var _a19;
111069
111069
  var _b17;
111070
111070
  var NATS_CONNECTION_OPTIONS = "nats.connectionOptions";
111071
- var NatsService = class NatsService2 extends Service {
111071
+ var NatsService = class NatsService2 extends LifecycleService {
111072
111072
  constructor(loggerService, natsConnectionOptions) {
111073
111073
  super();
111074
111074
  this.loggerService = loggerService;
@@ -111118,6 +111118,26 @@ var NatsService = class NatsService2 extends Service {
111118
111118
  isConnected() {
111119
111119
  return this.state === "STARTED" && this.nats !== null && !this.nats.isClosed();
111120
111120
  }
111121
+ /**
111122
+ * Active round-trip probe against NATS. Resolves on flush success, rejects on
111123
+ * timeout or underlying error. Used by readiness checks to detect half-open
111124
+ * connections that `isConnected()` would still report as healthy.
111125
+ */
111126
+ async flush(timeoutMs) {
111127
+ if (!this.nats || this.nats.isClosed()) {
111128
+ throw new Error("Not connected to NATS");
111129
+ }
111130
+ let timer;
111131
+ const timeout2 = new Promise((_3, reject) => {
111132
+ timer = setTimeout(() => reject(new Error(`NATS flush timed out after ${timeoutMs}ms`)), timeoutMs);
111133
+ });
111134
+ try {
111135
+ await Promise.race([this.nats.flush(), timeout2]);
111136
+ } finally {
111137
+ if (timer)
111138
+ clearTimeout(timer);
111139
+ }
111140
+ }
111121
111141
  /**
111122
111142
  * Get the KV manager for use by CacheService.
111123
111143
  * Returns null if not connected.
@@ -111311,44 +111331,44 @@ EncryptionService = __decorate3([
111311
111331
  ], EncryptionService);
111312
111332
 
111313
111333
  // ../common/src/services/ai/ai-provider.types.ts
111314
- var VALID_PROVIDERS = ["infomaniak", "openai", "anthropic", "google", "ollama"];
111315
111334
  var AIProviderError = class extends Error {
111316
- constructor(message, provider) {
111335
+ constructor(message, provider, slug) {
111317
111336
  super(message);
111318
111337
  this.provider = provider;
111338
+ this.slug = slug;
111319
111339
  this.name = "AIProviderError";
111320
111340
  }
111321
111341
  };
111322
111342
  var InvalidAPIKeyError = class extends AIProviderError {
111323
- constructor(provider) {
111324
- super(`Invalid or missing API key for provider '${provider}'`, provider);
111343
+ constructor(provider, slug) {
111344
+ super(`Invalid or missing API key for provider '${slug ?? provider}'`, provider, slug);
111325
111345
  this.name = "InvalidAPIKeyError";
111326
111346
  }
111327
111347
  };
111328
111348
  var MissingProductIdError = class extends AIProviderError {
111329
- constructor(provider) {
111330
- super(`Missing Product ID for provider '${provider}'`, provider);
111349
+ constructor(provider, slug) {
111350
+ super(`Missing Product ID for provider '${slug ?? provider}'`, provider, slug);
111331
111351
  this.name = "MissingProductIdError";
111332
111352
  }
111333
111353
  };
111334
111354
  var RateLimitError = class extends AIProviderError {
111335
- constructor(provider, retryAfter) {
111336
- super(`Rate limit exceeded for provider '${provider}'`, provider);
111355
+ constructor(provider, retryAfter, slug) {
111356
+ super(`Rate limit exceeded for provider '${slug ?? provider}'`, provider, slug);
111337
111357
  this.retryAfter = retryAfter;
111338
111358
  this.name = "RateLimitError";
111339
111359
  }
111340
111360
  };
111341
111361
  var TokenLimitError = class extends AIProviderError {
111342
- constructor(provider, maxTokens) {
111343
- super(`Token limit exceeded for provider '${provider}'`, provider);
111362
+ constructor(provider, maxTokens, slug) {
111363
+ super(`Token limit exceeded for provider '${slug ?? provider}'`, provider, slug);
111344
111364
  this.maxTokens = maxTokens;
111345
111365
  this.name = "TokenLimitError";
111346
111366
  }
111347
111367
  };
111348
111368
  var ModelNotSupportedError = class extends AIProviderError {
111349
- constructor(provider, modelName, reason) {
111350
- const message = reason ? `Model '${modelName}' is not supported: ${reason}` : `Model '${modelName}' does not support this operation for provider '${provider}'`;
111351
- super(message, provider);
111369
+ constructor(provider, modelName, reason, slug) {
111370
+ const message = reason ? `Model '${modelName}' is not supported: ${reason}` : `Model '${modelName}' does not support this operation for provider '${slug ?? provider}'`;
111371
+ super(message, provider, slug);
111352
111372
  this.modelName = modelName;
111353
111373
  this.reason = reason;
111354
111374
  this.name = "ModelNotSupportedError";
@@ -112102,7 +112122,7 @@ var GatewayImageModel = class {
112102
112122
  headers,
112103
112123
  abortSignal
112104
112124
  }) {
112105
- var _a93, _b92, _c11, _d8;
112125
+ var _a93, _b92, _c12, _d8;
112106
112126
  const resolvedHeaders = await resolve2(this.config.headers());
112107
112127
  try {
112108
112128
  const {
@@ -112152,7 +112172,7 @@ var GatewayImageModel = class {
112152
112172
  ...responseBody.usage != null && {
112153
112173
  usage: {
112154
112174
  inputTokens: (_b92 = responseBody.usage.inputTokens) != null ? _b92 : void 0,
112155
- outputTokens: (_c11 = responseBody.usage.outputTokens) != null ? _c11 : void 0,
112175
+ outputTokens: (_c12 = responseBody.usage.outputTokens) != null ? _c12 : void 0,
112156
112176
  totalTokens: (_d8 = responseBody.usage.totalTokens) != null ? _d8 : void 0
112157
112177
  }
112158
112178
  }
@@ -112651,8 +112671,8 @@ function createGatewayProvider(options = {}) {
112651
112671
  });
112652
112672
  };
112653
112673
  const getAvailableModels = async () => {
112654
- var _a103, _b102, _c11;
112655
- const now2 = (_c11 = (_b102 = (_a103 = options._internal) == null ? void 0 : _a103.currentDate) == null ? void 0 : _b102.call(_a103).getTime()) != null ? _c11 : Date.now();
112674
+ var _a103, _b102, _c12;
112675
+ const now2 = (_c12 = (_b102 = (_a103 = options._internal) == null ? void 0 : _a103.currentDate) == null ? void 0 : _b102.call(_a103).getTime()) != null ? _c12 : Date.now();
112656
112676
  if (!pendingMetadata || now2 - lastFetchTime > cacheRefreshMillis) {
112657
112677
  lastFetchTime = now2;
112658
112678
  pendingMetadata = new GatewayFetchMetadata({
@@ -112850,12 +112870,12 @@ function registerGlobal(type22, instance, diag, allowOverride) {
112850
112870
  return true;
112851
112871
  }
112852
112872
  function getGlobal(type22) {
112853
- var _a51, _b40;
112873
+ var _a51, _b41;
112854
112874
  var globalVersion = (_a51 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a51 === void 0 ? void 0 : _a51.version;
112855
112875
  if (!globalVersion || !isCompatible(globalVersion)) {
112856
112876
  return;
112857
112877
  }
112858
- return (_b40 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b40 === void 0 ? void 0 : _b40[type22];
112878
+ return (_b41 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b41 === void 0 ? void 0 : _b41[type22];
112859
112879
  }
112860
112880
  function unregisterGlobal(type22, diag) {
112861
112881
  diag.debug("@opentelemetry/api: Unregistering a global for " + type22 + " v" + VERSION4 + ".");
@@ -113028,7 +113048,7 @@ var DiagAPI = (
113028
113048
  }
113029
113049
  var self2 = this;
113030
113050
  var setLogger = function(logger, optionsOrLogLevel) {
113031
- var _a51, _b40, _c11;
113051
+ var _a51, _b41, _c12;
113032
113052
  if (optionsOrLogLevel === void 0) {
113033
113053
  optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
113034
113054
  }
@@ -113043,9 +113063,9 @@ var DiagAPI = (
113043
113063
  };
113044
113064
  }
113045
113065
  var oldLogger = getGlobal("diag");
113046
- var newLogger = createLogLevelDiagLogger((_b40 = optionsOrLogLevel.logLevel) !== null && _b40 !== void 0 ? _b40 : DiagLogLevel.INFO, logger);
113066
+ var newLogger = createLogLevelDiagLogger((_b41 = optionsOrLogLevel.logLevel) !== null && _b41 !== void 0 ? _b41 : DiagLogLevel.INFO, logger);
113047
113067
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
113048
- var stack = (_c11 = new Error().stack) !== null && _c11 !== void 0 ? _c11 : "<failed to generate stacktrace>";
113068
+ var stack = (_c12 = new Error().stack) !== null && _c12 !== void 0 ? _c12 : "<failed to generate stacktrace>";
113049
113069
  oldLogger.warn("Current logger will be overwritten from " + stack);
113050
113070
  newLogger.warn("Current logger will overwrite one already registered from " + stack);
113051
113071
  }
@@ -114178,8 +114198,8 @@ var dataContentSchema = external_exports.union([
114178
114198
  external_exports.custom(
114179
114199
  // Buffer might not be available in some environments such as CloudFlare:
114180
114200
  (value) => {
114181
- var _a212, _b40;
114182
- return (_b40 = (_a212 = globalThis.Buffer) == null ? void 0 : _a212.isBuffer(value)) != null ? _b40 : false;
114201
+ var _a212, _b41;
114202
+ return (_b41 = (_a212 = globalThis.Buffer) == null ? void 0 : _a212.isBuffer(value)) != null ? _b41 : false;
114183
114203
  },
114184
114204
  { message: "Must be a Buffer" }
114185
114205
  )
@@ -115265,16 +115285,16 @@ function createNullLanguageModelUsage() {
115265
115285
  };
115266
115286
  }
115267
115287
  function addLanguageModelUsage(usage1, usage2) {
115268
- var _a212, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2;
115288
+ var _a212, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2;
115269
115289
  return {
115270
115290
  inputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),
115271
115291
  inputTokenDetails: {
115272
115292
  noCacheTokens: addTokenCounts(
115273
115293
  (_a212 = usage1.inputTokenDetails) == null ? void 0 : _a212.noCacheTokens,
115274
- (_b40 = usage2.inputTokenDetails) == null ? void 0 : _b40.noCacheTokens
115294
+ (_b41 = usage2.inputTokenDetails) == null ? void 0 : _b41.noCacheTokens
115275
115295
  ),
115276
115296
  cacheReadTokens: addTokenCounts(
115277
- (_c11 = usage1.inputTokenDetails) == null ? void 0 : _c11.cacheReadTokens,
115297
+ (_c12 = usage1.inputTokenDetails) == null ? void 0 : _c12.cacheReadTokens,
115278
115298
  (_d8 = usage2.inputTokenDetails) == null ? void 0 : _d8.cacheReadTokens
115279
115299
  ),
115280
115300
  cacheWriteTokens: addTokenCounts(
@@ -115535,8 +115555,8 @@ function collectToolApprovals({
115535
115555
  return { approvedToolApprovals, deniedToolApprovals };
115536
115556
  }
115537
115557
  function now() {
115538
- var _a212, _b40;
115539
- return (_b40 = (_a212 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a212.now()) != null ? _b40 : Date.now();
115558
+ var _a212, _b41;
115559
+ return (_b41 = (_a212 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a212.now()) != null ? _b41 : Date.now();
115540
115560
  }
115541
115561
  async function executeToolCall({
115542
115562
  toolCall,
@@ -116859,7 +116879,7 @@ async function generateText({
116859
116879
  }),
116860
116880
  tracer,
116861
116881
  fn: async (span) => {
116862
- var _a212, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
116882
+ var _a212, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
116863
116883
  const initialMessages = initialPrompt.messages;
116864
116884
  const responseMessages = [];
116865
116885
  const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
@@ -116966,8 +116986,8 @@ async function generateText({
116966
116986
  };
116967
116987
  const promptMessages = await convertToLanguageModelPrompt({
116968
116988
  prompt: {
116969
- system: (_b40 = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b40 : initialPrompt.system,
116970
- messages: (_c11 = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _c11 : stepInputMessages
116989
+ system: (_b41 = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b41 : initialPrompt.system,
116990
+ messages: (_c12 = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _c12 : stepInputMessages
116971
116991
  },
116972
116992
  supportedUrls: await stepModel.supportedUrls,
116973
116993
  download: download2
@@ -117921,7 +117941,7 @@ function processUIMessageStream({
117921
117941
  new TransformStream({
117922
117942
  async transform(chunk, controller) {
117923
117943
  await runUpdateMessageJob(async ({ state, write }) => {
117924
- var _a212, _b40, _c11, _d8;
117944
+ var _a212, _b41, _c12, _d8;
117925
117945
  function getToolInvocation(toolCallId) {
117926
117946
  const toolInvocations = state.message.parts.filter(isToolUIPart);
117927
117947
  const toolInvocation = toolInvocations.find(
@@ -118064,7 +118084,7 @@ function processUIMessageStream({
118064
118084
  });
118065
118085
  }
118066
118086
  textPart.state = "done";
118067
- textPart.providerMetadata = (_b40 = chunk.providerMetadata) != null ? _b40 : textPart.providerMetadata;
118087
+ textPart.providerMetadata = (_b41 = chunk.providerMetadata) != null ? _b41 : textPart.providerMetadata;
118068
118088
  delete state.activeTextParts[chunk.id];
118069
118089
  write();
118070
118090
  break;
@@ -118091,7 +118111,7 @@ function processUIMessageStream({
118091
118111
  });
118092
118112
  }
118093
118113
  reasoningPart.text += chunk.delta;
118094
- reasoningPart.providerMetadata = (_c11 = chunk.providerMetadata) != null ? _c11 : reasoningPart.providerMetadata;
118114
+ reasoningPart.providerMetadata = (_c12 = chunk.providerMetadata) != null ? _c12 : reasoningPart.providerMetadata;
118095
118115
  write();
118096
118116
  break;
118097
118117
  }
@@ -119174,7 +119194,7 @@ var DefaultStreamTextResult = class {
119174
119194
  let activeReasoningContent = {};
119175
119195
  const eventProcessor = new TransformStream({
119176
119196
  async transform(chunk, controller) {
119177
- var _a212, _b40, _c11, _d8;
119197
+ var _a212, _b41, _c12, _d8;
119178
119198
  controller.enqueue(chunk);
119179
119199
  const { part } = chunk;
119180
119200
  if (part.type === "text-delta" || part.type === "reasoning-delta" || part.type === "source" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-input-start" || part.type === "tool-input-delta" || part.type === "raw") {
@@ -119218,7 +119238,7 @@ var DefaultStreamTextResult = class {
119218
119238
  });
119219
119239
  return;
119220
119240
  }
119221
- activeText.providerMetadata = (_b40 = part.providerMetadata) != null ? _b40 : activeText.providerMetadata;
119241
+ activeText.providerMetadata = (_b41 = part.providerMetadata) != null ? _b41 : activeText.providerMetadata;
119222
119242
  delete activeTextContent[part.id];
119223
119243
  }
119224
119244
  if (part.type === "reasoning-start") {
@@ -119242,7 +119262,7 @@ var DefaultStreamTextResult = class {
119242
119262
  return;
119243
119263
  }
119244
119264
  activeReasoning.text += part.text;
119245
- activeReasoning.providerMetadata = (_c11 = part.providerMetadata) != null ? _c11 : activeReasoning.providerMetadata;
119265
+ activeReasoning.providerMetadata = (_c12 = part.providerMetadata) != null ? _c12 : activeReasoning.providerMetadata;
119246
119266
  }
119247
119267
  if (part.type === "reasoning-end") {
119248
119268
  const activeReasoning = activeReasoningContent[part.id];
@@ -119645,7 +119665,7 @@ var DefaultStreamTextResult = class {
119645
119665
  responseMessages,
119646
119666
  usage
119647
119667
  }) {
119648
- var _a212, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i;
119668
+ var _a212, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i;
119649
119669
  const includeRawChunks2 = self2.includeRawChunks;
119650
119670
  const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : void 0;
119651
119671
  let chunkTimeoutId = void 0;
@@ -119690,8 +119710,8 @@ var DefaultStreamTextResult = class {
119690
119710
  };
119691
119711
  const promptMessages = await convertToLanguageModelPrompt({
119692
119712
  prompt: {
119693
- system: (_b40 = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b40 : initialPrompt.system,
119694
- messages: (_c11 = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _c11 : stepInputMessages
119713
+ system: (_b41 = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b41 : initialPrompt.system,
119714
+ messages: (_c12 = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _c12 : stepInputMessages
119695
119715
  },
119696
119716
  supportedUrls: await stepModel.supportedUrls,
119697
119717
  download: download2
@@ -120280,11 +120300,11 @@ var DefaultStreamTextResult = class {
120280
120300
  );
120281
120301
  }
120282
120302
  get elementStream() {
120283
- var _a212, _b40, _c11;
120303
+ var _a212, _b41, _c12;
120284
120304
  const transform2 = (_a212 = this.outputSpecification) == null ? void 0 : _a212.createElementStreamTransform();
120285
120305
  if (transform2 == null) {
120286
120306
  throw new UnsupportedFunctionalityError({
120287
- functionality: `element streams in ${(_c11 = (_b40 = this.outputSpecification) == null ? void 0 : _b40.name) != null ? _c11 : "text"} mode`
120307
+ functionality: `element streams in ${(_c12 = (_b41 = this.outputSpecification) == null ? void 0 : _b41.name) != null ? _c12 : "text"} mode`
120288
120308
  });
120289
120309
  }
120290
120310
  return createAsyncIterableStream(this.teeStream().pipeThrough(transform2));
@@ -120945,7 +120965,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
120945
120965
  };
120946
120966
  }
120947
120967
  function convertOpenAIChatUsage(usage) {
120948
- var _a51, _b40, _c11, _d8, _e7, _f3;
120968
+ var _a51, _b41, _c12, _d8, _e7, _f3;
120949
120969
  if (usage == null) {
120950
120970
  return {
120951
120971
  inputTokens: {
@@ -120963,8 +120983,8 @@ function convertOpenAIChatUsage(usage) {
120963
120983
  };
120964
120984
  }
120965
120985
  const promptTokens = (_a51 = usage.prompt_tokens) != null ? _a51 : 0;
120966
- const completionTokens = (_b40 = usage.completion_tokens) != null ? _b40 : 0;
120967
- const cachedTokens = (_d8 = (_c11 = usage.prompt_tokens_details) == null ? void 0 : _c11.cached_tokens) != null ? _d8 : 0;
120986
+ const completionTokens = (_b41 = usage.completion_tokens) != null ? _b41 : 0;
120987
+ const cachedTokens = (_d8 = (_c12 = usage.prompt_tokens_details) == null ? void 0 : _c12.cached_tokens) != null ? _d8 : 0;
120968
120988
  const reasoningTokens = (_f3 = (_e7 = usage.completion_tokens_details) == null ? void 0 : _e7.reasoning_tokens) != null ? _f3 : 0;
120969
120989
  return {
120970
120990
  inputTokens: {
@@ -121024,7 +121044,7 @@ function convertToOpenAIChatMessages({
121024
121044
  messages.push({
121025
121045
  role: "user",
121026
121046
  content: content.map((part, index) => {
121027
- var _a210, _b40, _c11;
121047
+ var _a210, _b41, _c12;
121028
121048
  switch (part.type) {
121029
121049
  case "text": {
121030
121050
  return { type: "text", text: part.text };
@@ -121037,7 +121057,7 @@ function convertToOpenAIChatMessages({
121037
121057
  image_url: {
121038
121058
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
121039
121059
  // OpenAI specific extension: image detail
121040
- detail: (_b40 = (_a210 = part.providerOptions) == null ? void 0 : _a210.openai) == null ? void 0 : _b40.imageDetail
121060
+ detail: (_b41 = (_a210 = part.providerOptions) == null ? void 0 : _a210.openai) == null ? void 0 : _b41.imageDetail
121041
121061
  }
121042
121062
  };
121043
121063
  } else if (part.mediaType.startsWith("audio/")) {
@@ -121081,7 +121101,7 @@ function convertToOpenAIChatMessages({
121081
121101
  return {
121082
121102
  type: "file",
121083
121103
  file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
121084
- filename: (_c11 = part.filename) != null ? _c11 : `part-${index}.pdf`,
121104
+ filename: (_c12 = part.filename) != null ? _c12 : `part-${index}.pdf`,
121085
121105
  file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
121086
121106
  }
121087
121107
  };
@@ -121527,7 +121547,7 @@ var OpenAIChatLanguageModel = class {
121527
121547
  toolChoice,
121528
121548
  providerOptions
121529
121549
  }) {
121530
- var _a51, _b40, _c11, _d8, _e7;
121550
+ var _a51, _b41, _c12, _d8, _e7;
121531
121551
  const warnings = [];
121532
121552
  const openaiOptions = (_a51 = await parseProviderOptions({
121533
121553
  provider: "openai",
@@ -121535,14 +121555,14 @@ var OpenAIChatLanguageModel = class {
121535
121555
  schema: openaiLanguageModelChatOptions
121536
121556
  })) != null ? _a51 : {};
121537
121557
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
121538
- const isReasoningModel = (_b40 = openaiOptions.forceReasoning) != null ? _b40 : modelCapabilities.isReasoningModel;
121558
+ const isReasoningModel = (_b41 = openaiOptions.forceReasoning) != null ? _b41 : modelCapabilities.isReasoningModel;
121539
121559
  if (topK != null) {
121540
121560
  warnings.push({ type: "unsupported", feature: "topK" });
121541
121561
  }
121542
121562
  const { messages, warnings: messageWarnings } = convertToOpenAIChatMessages(
121543
121563
  {
121544
121564
  prompt,
121545
- systemMessageMode: (_c11 = openaiOptions.systemMessageMode) != null ? _c11 : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
121565
+ systemMessageMode: (_c12 = openaiOptions.systemMessageMode) != null ? _c12 : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode
121546
121566
  }
121547
121567
  );
121548
121568
  warnings.push(...messageWarnings);
@@ -121694,7 +121714,7 @@ var OpenAIChatLanguageModel = class {
121694
121714
  };
121695
121715
  }
121696
121716
  async doGenerate(options) {
121697
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6;
121717
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6;
121698
121718
  const { args: body, warnings } = await this.getArgs(options);
121699
121719
  const {
121700
121720
  responseHeaders,
@@ -121723,12 +121743,12 @@ var OpenAIChatLanguageModel = class {
121723
121743
  for (const toolCall of (_a51 = choice2.message.tool_calls) != null ? _a51 : []) {
121724
121744
  content.push({
121725
121745
  type: "tool-call",
121726
- toolCallId: (_b40 = toolCall.id) != null ? _b40 : generateId(),
121746
+ toolCallId: (_b41 = toolCall.id) != null ? _b41 : generateId(),
121727
121747
  toolName: toolCall.function.name,
121728
121748
  input: toolCall.function.arguments
121729
121749
  });
121730
121750
  }
121731
- for (const annotation of (_c11 = choice2.message.annotations) != null ? _c11 : []) {
121751
+ for (const annotation of (_c12 = choice2.message.annotations) != null ? _c12 : []) {
121732
121752
  content.push({
121733
121753
  type: "source",
121734
121754
  sourceType: "url",
@@ -121805,7 +121825,7 @@ var OpenAIChatLanguageModel = class {
121805
121825
  controller.enqueue({ type: "stream-start", warnings });
121806
121826
  },
121807
121827
  transform(chunk, controller) {
121808
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2;
121828
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2;
121809
121829
  if (options.includeRawChunks) {
121810
121830
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
121811
121831
  }
@@ -121833,9 +121853,9 @@ var OpenAIChatLanguageModel = class {
121833
121853
  if (value.usage != null) {
121834
121854
  usage = value.usage;
121835
121855
  if (((_a51 = value.usage.completion_tokens_details) == null ? void 0 : _a51.accepted_prediction_tokens) != null) {
121836
- providerMetadata.openai.acceptedPredictionTokens = (_b40 = value.usage.completion_tokens_details) == null ? void 0 : _b40.accepted_prediction_tokens;
121856
+ providerMetadata.openai.acceptedPredictionTokens = (_b41 = value.usage.completion_tokens_details) == null ? void 0 : _b41.accepted_prediction_tokens;
121837
121857
  }
121838
- if (((_c11 = value.usage.completion_tokens_details) == null ? void 0 : _c11.rejected_prediction_tokens) != null) {
121858
+ if (((_c12 = value.usage.completion_tokens_details) == null ? void 0 : _c12.rejected_prediction_tokens) != null) {
121839
121859
  providerMetadata.openai.rejectedPredictionTokens = (_d8 = value.usage.completion_tokens_details) == null ? void 0 : _d8.rejected_prediction_tokens;
121840
121860
  }
121841
121861
  }
@@ -121983,7 +122003,7 @@ var OpenAIChatLanguageModel = class {
121983
122003
  }
121984
122004
  };
121985
122005
  function convertOpenAICompletionUsage(usage) {
121986
- var _a51, _b40, _c11, _d8;
122006
+ var _a51, _b41, _c12, _d8;
121987
122007
  if (usage == null) {
121988
122008
  return {
121989
122009
  inputTokens: {
@@ -122001,10 +122021,10 @@ function convertOpenAICompletionUsage(usage) {
122001
122021
  };
122002
122022
  }
122003
122023
  const promptTokens = (_a51 = usage.prompt_tokens) != null ? _a51 : 0;
122004
- const completionTokens = (_b40 = usage.completion_tokens) != null ? _b40 : 0;
122024
+ const completionTokens = (_b41 = usage.completion_tokens) != null ? _b41 : 0;
122005
122025
  return {
122006
122026
  inputTokens: {
122007
- total: (_c11 = usage.prompt_tokens) != null ? _c11 : void 0,
122027
+ total: (_c12 = usage.prompt_tokens) != null ? _c12 : void 0,
122008
122028
  noCache: promptTokens,
122009
122029
  cacheRead: void 0,
122010
122030
  cacheWrite: void 0
@@ -122597,7 +122617,7 @@ var OpenAIImageModel = class {
122597
122617
  headers,
122598
122618
  abortSignal
122599
122619
  }) {
122600
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3;
122620
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3;
122601
122621
  const warnings = [];
122602
122622
  if (aspectRatio != null) {
122603
122623
  warnings.push({
@@ -122609,7 +122629,7 @@ var OpenAIImageModel = class {
122609
122629
  if (seed != null) {
122610
122630
  warnings.push({ type: "unsupported", feature: "seed" });
122611
122631
  }
122612
- const currentDate = (_c11 = (_b40 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
122632
+ const currentDate = (_c12 = (_b41 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : /* @__PURE__ */ new Date();
122613
122633
  if (files != null) {
122614
122634
  const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi({
122615
122635
  url: this.config.url({
@@ -123315,7 +123335,7 @@ var openaiTools = {
123315
123335
  mcp
123316
123336
  };
123317
123337
  function convertOpenAIResponsesUsage(usage) {
123318
- var _a51, _b40, _c11, _d8;
123338
+ var _a51, _b41, _c12, _d8;
123319
123339
  if (usage == null) {
123320
123340
  return {
123321
123341
  inputTokens: {
@@ -123334,8 +123354,8 @@ function convertOpenAIResponsesUsage(usage) {
123334
123354
  }
123335
123355
  const inputTokens = usage.input_tokens;
123336
123356
  const outputTokens = usage.output_tokens;
123337
- const cachedTokens = (_b40 = (_a51 = usage.input_tokens_details) == null ? void 0 : _a51.cached_tokens) != null ? _b40 : 0;
123338
- const reasoningTokens = (_d8 = (_c11 = usage.output_tokens_details) == null ? void 0 : _c11.reasoning_tokens) != null ? _d8 : 0;
123357
+ const cachedTokens = (_b41 = (_a51 = usage.input_tokens_details) == null ? void 0 : _a51.cached_tokens) != null ? _b41 : 0;
123358
+ const reasoningTokens = (_d8 = (_c12 = usage.output_tokens_details) == null ? void 0 : _c12.reasoning_tokens) != null ? _d8 : 0;
123339
123359
  return {
123340
123360
  inputTokens: {
123341
123361
  total: inputTokens,
@@ -123368,7 +123388,7 @@ async function convertToOpenAIResponsesInput({
123368
123388
  hasApplyPatchTool = false,
123369
123389
  customProviderToolNames
123370
123390
  }) {
123371
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
123391
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
123372
123392
  const input = [];
123373
123393
  const warnings = [];
123374
123394
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -123468,7 +123488,7 @@ async function convertToOpenAIResponsesInput({
123468
123488
  break;
123469
123489
  }
123470
123490
  case "tool-call": {
123471
- const id = (_f3 = (_c11 = (_b40 = part.providerOptions) == null ? void 0 : _b40[providerOptionsName]) == null ? void 0 : _c11.itemId) != null ? _f3 : (_e7 = (_d8 = part.providerMetadata) == null ? void 0 : _d8[providerOptionsName]) == null ? void 0 : _e7.itemId;
123491
+ const id = (_f3 = (_c12 = (_b41 = part.providerOptions) == null ? void 0 : _b41[providerOptionsName]) == null ? void 0 : _c12.itemId) != null ? _f3 : (_e7 = (_d8 = part.providerMetadata) == null ? void 0 : _d8[providerOptionsName]) == null ? void 0 : _e7.itemId;
123472
123492
  if (hasConversation && id != null) {
123473
123493
  break;
123474
123494
  }
@@ -125119,13 +125139,13 @@ function mapShellSkills(skills) {
125119
125139
  );
125120
125140
  }
125121
125141
  function extractApprovalRequestIdToToolCallIdMapping(prompt) {
125122
- var _a51, _b40;
125142
+ var _a51, _b41;
125123
125143
  const mapping = {};
125124
125144
  for (const message of prompt) {
125125
125145
  if (message.role !== "assistant") continue;
125126
125146
  for (const part of message.content) {
125127
125147
  if (part.type !== "tool-call") continue;
125128
- const approvalRequestId = (_b40 = (_a51 = part.providerOptions) == null ? void 0 : _a51.openai) == null ? void 0 : _b40.approvalRequestId;
125148
+ const approvalRequestId = (_b41 = (_a51 = part.providerOptions) == null ? void 0 : _a51.openai) == null ? void 0 : _b41.approvalRequestId;
125129
125149
  if (approvalRequestId != null) {
125130
125150
  mapping[approvalRequestId] = part.toolCallId;
125131
125151
  }
@@ -125161,7 +125181,7 @@ var OpenAIResponsesLanguageModel = class {
125161
125181
  toolChoice,
125162
125182
  responseFormat
125163
125183
  }) {
125164
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i;
125184
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i;
125165
125185
  const warnings = [];
125166
125186
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
125167
125187
  if (topK != null) {
@@ -125229,10 +125249,10 @@ var OpenAIResponsesLanguageModel = class {
125229
125249
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
125230
125250
  prompt,
125231
125251
  toolNameMapping,
125232
- systemMessageMode: (_b40 = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _b40 : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
125252
+ systemMessageMode: (_b41 = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _b41 : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
125233
125253
  providerOptionsName,
125234
125254
  fileIdPrefixes: this.config.fileIdPrefixes,
125235
- store: (_c11 = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _c11 : true,
125255
+ store: (_c12 = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _c12 : true,
125236
125256
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
125237
125257
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
125238
125258
  hasShellTool: hasOpenAITool("openai.shell"),
@@ -125389,7 +125409,7 @@ var OpenAIResponsesLanguageModel = class {
125389
125409
  };
125390
125410
  }
125391
125411
  async doGenerate(options) {
125392
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r, _s, _t, _u, _v, _w, _x, _y;
125412
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r, _s, _t, _u, _v, _w, _x, _y;
125393
125413
  const {
125394
125414
  args: body,
125395
125415
  warnings,
@@ -125525,7 +125545,7 @@ var OpenAIResponsesLanguageModel = class {
125525
125545
  }
125526
125546
  case "message": {
125527
125547
  for (const contentPart of part.content) {
125528
- if (((_c11 = (_b40 = options.providerOptions) == null ? void 0 : _b40[providerOptionsName]) == null ? void 0 : _c11.logprobs) && contentPart.logprobs) {
125548
+ if (((_c12 = (_b41 = options.providerOptions) == null ? void 0 : _b41[providerOptionsName]) == null ? void 0 : _c12.logprobs) && contentPart.logprobs) {
125529
125549
  logprobs.push(contentPart.logprobs);
125530
125550
  }
125531
125551
  const providerMetadata2 = {
@@ -125872,7 +125892,7 @@ var OpenAIResponsesLanguageModel = class {
125872
125892
  controller.enqueue({ type: "stream-start", warnings });
125873
125893
  },
125874
125894
  transform(chunk, controller) {
125875
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
125895
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
125876
125896
  if (options.includeRawChunks) {
125877
125897
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
125878
125898
  }
@@ -126050,14 +126070,14 @@ var OpenAIResponsesLanguageModel = class {
126050
126070
  providerMetadata: {
126051
126071
  [providerOptionsName]: {
126052
126072
  itemId: value.item.id,
126053
- reasoningEncryptedContent: (_b40 = value.item.encrypted_content) != null ? _b40 : null
126073
+ reasoningEncryptedContent: (_b41 = value.item.encrypted_content) != null ? _b41 : null
126054
126074
  }
126055
126075
  }
126056
126076
  });
126057
126077
  }
126058
126078
  } else if (isResponseOutputItemDoneChunk(value)) {
126059
126079
  if (value.item.type === "message") {
126060
- const phase = (_c11 = value.item.phase) != null ? _c11 : activeMessagePhase;
126080
+ const phase = (_c12 = value.item.phase) != null ? _c12 : activeMessagePhase;
126061
126081
  activeMessagePhase = void 0;
126062
126082
  controller.enqueue({
126063
126083
  type: "text-end",
@@ -126756,8 +126776,8 @@ var OpenAISpeechModel = class {
126756
126776
  };
126757
126777
  }
126758
126778
  async doGenerate(options) {
126759
- var _a51, _b40, _c11;
126760
- const currentDate = (_c11 = (_b40 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
126779
+ var _a51, _b41, _c12;
126780
+ const currentDate = (_c12 = (_b41 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : /* @__PURE__ */ new Date();
126761
126781
  const { requestBody, warnings } = await this.getArgs(options);
126762
126782
  const {
126763
126783
  value: audio,
@@ -126968,8 +126988,8 @@ var OpenAITranscriptionModel = class {
126968
126988
  };
126969
126989
  }
126970
126990
  async doGenerate(options) {
126971
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2;
126972
- const currentDate = (_c11 = (_b40 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
126991
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2;
126992
+ const currentDate = (_c12 = (_b41 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : /* @__PURE__ */ new Date();
126973
126993
  const { formData, warnings } = await this.getArgs(options);
126974
126994
  const {
126975
126995
  value: response,
@@ -127015,14 +127035,14 @@ var OpenAITranscriptionModel = class {
127015
127035
  };
127016
127036
  var VERSION6 = true ? "3.0.39" : "0.0.0-test";
127017
127037
  function createOpenAI(options = {}) {
127018
- var _a51, _b40;
127038
+ var _a51, _b41;
127019
127039
  const baseURL = (_a51 = withoutTrailingSlash(
127020
127040
  loadOptionalSetting({
127021
127041
  settingValue: options.baseURL,
127022
127042
  environmentVariableName: "OPENAI_BASE_URL"
127023
127043
  })
127024
127044
  )) != null ? _a51 : "https://api.openai.com/v1";
127025
- const providerName = (_b40 = options.name) != null ? _b40 : "openai";
127045
+ const providerName = (_b41 = options.name) != null ? _b41 : "openai";
127026
127046
  const getHeaders = () => withUserAgentSuffix(
127027
127047
  {
127028
127048
  Authorization: `Bearer ${loadApiKey({
@@ -128457,9 +128477,9 @@ function convertAnthropicMessagesUsage({
128457
128477
  usage,
128458
128478
  rawUsage
128459
128479
  }) {
128460
- var _a51, _b40;
128480
+ var _a51, _b41;
128461
128481
  const cacheCreationTokens = (_a51 = usage.cache_creation_input_tokens) != null ? _a51 : 0;
128462
- const cacheReadTokens = (_b40 = usage.cache_read_input_tokens) != null ? _b40 : 0;
128482
+ const cacheReadTokens = (_b41 = usage.cache_read_input_tokens) != null ? _b41 : 0;
128463
128483
  let inputTokens;
128464
128484
  let outputTokens;
128465
128485
  if (usage.iterations && usage.iterations.length > 0) {
@@ -128699,7 +128719,7 @@ async function convertToAnthropicMessagesPrompt({
128699
128719
  cacheControlValidator,
128700
128720
  toolNameMapping
128701
128721
  }) {
128702
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r;
128722
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r;
128703
128723
  const betas = /* @__PURE__ */ new Set();
128704
128724
  const blocks = groupIntoBlocks(prompt);
128705
128725
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -128803,7 +128823,7 @@ async function convertToAnthropicMessagesPrompt({
128803
128823
  media_type: "application/pdf",
128804
128824
  data: convertToBase64(part.data)
128805
128825
  },
128806
- title: (_b40 = metadata.title) != null ? _b40 : part.filename,
128826
+ title: (_b41 = metadata.title) != null ? _b41 : part.filename,
128807
128827
  ...metadata.context && { context: metadata.context },
128808
128828
  ...enableCitations && {
128809
128829
  citations: { enabled: true }
@@ -128827,7 +128847,7 @@ async function convertToAnthropicMessagesPrompt({
128827
128847
  media_type: "text/plain",
128828
128848
  data: convertToString(part.data)
128829
128849
  },
128830
- title: (_c11 = metadata.title) != null ? _c11 : part.filename,
128850
+ title: (_c12 = metadata.title) != null ? _c12 : part.filename,
128831
128851
  ...metadata.context && { context: metadata.context },
128832
128852
  ...enableCitations && {
128833
128853
  citations: { enabled: true }
@@ -129547,8 +129567,8 @@ var AnthropicMessagesLanguageModel = class {
129547
129567
  return dotIndex === -1 ? provider : provider.substring(0, dotIndex);
129548
129568
  }
129549
129569
  get supportedUrls() {
129550
- var _a51, _b40, _c11;
129551
- return (_c11 = (_b40 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : {};
129570
+ var _a51, _b41, _c12;
129571
+ return (_c12 = (_b41 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : {};
129552
129572
  }
129553
129573
  async getArgs({
129554
129574
  userSuppliedBetas,
@@ -129567,7 +129587,7 @@ var AnthropicMessagesLanguageModel = class {
129567
129587
  providerOptions,
129568
129588
  stream
129569
129589
  }) {
129570
- var _a51, _b40, _c11, _d8, _e7, _f3;
129590
+ var _a51, _b41, _c12, _d8, _e7, _f3;
129571
129591
  const warnings = [];
129572
129592
  if (frequencyPenalty != null) {
129573
129593
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -129625,7 +129645,7 @@ var AnthropicMessagesLanguageModel = class {
129625
129645
  isKnownModel
129626
129646
  } = getModelCapabilities(this.modelId);
129627
129647
  const supportsStructuredOutput = ((_a51 = this.config.supportsNativeStructuredOutput) != null ? _a51 : true) && modelSupportsStructuredOutput;
129628
- const structureOutputMode = (_b40 = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _b40 : "auto";
129648
+ const structureOutputMode = (_b41 = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _b41 : "auto";
129629
129649
  const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
129630
129650
  const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
129631
129651
  type: "function",
@@ -129658,7 +129678,7 @@ var AnthropicMessagesLanguageModel = class {
129658
129678
  });
129659
129679
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
129660
129680
  prompt,
129661
- sendReasoning: (_c11 = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _c11 : true,
129681
+ sendReasoning: (_c12 = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _c12 : true,
129662
129682
  warnings,
129663
129683
  cacheControlValidator,
129664
129684
  toolNameMapping
@@ -129923,10 +129943,10 @@ var AnthropicMessagesLanguageModel = class {
129923
129943
  );
129924
129944
  }
129925
129945
  async getBetasFromHeaders(requestHeaders) {
129926
- var _a51, _b40;
129946
+ var _a51, _b41;
129927
129947
  const configHeaders = await resolve2(this.config.headers);
129928
129948
  const configBetaHeader = (_a51 = configHeaders["anthropic-beta"]) != null ? _a51 : "";
129929
- const requestBetaHeader = (_b40 = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b40 : "";
129949
+ const requestBetaHeader = (_b41 = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b41 : "";
129930
129950
  return new Set(
129931
129951
  [
129932
129952
  ...configBetaHeader.toLowerCase().split(","),
@@ -129935,16 +129955,16 @@ var AnthropicMessagesLanguageModel = class {
129935
129955
  );
129936
129956
  }
129937
129957
  buildRequestUrl(isStreaming) {
129938
- var _a51, _b40, _c11;
129939
- return (_c11 = (_b40 = (_a51 = this.config).buildRequestUrl) == null ? void 0 : _b40.call(_a51, this.config.baseURL, isStreaming)) != null ? _c11 : `${this.config.baseURL}/messages`;
129958
+ var _a51, _b41, _c12;
129959
+ return (_c12 = (_b41 = (_a51 = this.config).buildRequestUrl) == null ? void 0 : _b41.call(_a51, this.config.baseURL, isStreaming)) != null ? _c12 : `${this.config.baseURL}/messages`;
129940
129960
  }
129941
129961
  transformRequestBody(args) {
129942
- var _a51, _b40, _c11;
129943
- return (_c11 = (_b40 = (_a51 = this.config).transformRequestBody) == null ? void 0 : _b40.call(_a51, args)) != null ? _c11 : args;
129962
+ var _a51, _b41, _c12;
129963
+ return (_c12 = (_b41 = (_a51 = this.config).transformRequestBody) == null ? void 0 : _b41.call(_a51, args)) != null ? _c12 : args;
129944
129964
  }
129945
129965
  extractCitationDocuments(prompt) {
129946
129966
  const isCitationPart = (part) => {
129947
- var _a51, _b40;
129967
+ var _a51, _b41;
129948
129968
  if (part.type !== "file") {
129949
129969
  return false;
129950
129970
  }
@@ -129953,7 +129973,7 @@ var AnthropicMessagesLanguageModel = class {
129953
129973
  }
129954
129974
  const anthropic2 = (_a51 = part.providerOptions) == null ? void 0 : _a51.anthropic;
129955
129975
  const citationsConfig = anthropic2 == null ? void 0 : anthropic2.citations;
129956
- return (_b40 = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b40 : false;
129976
+ return (_b41 = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b41 : false;
129957
129977
  };
129958
129978
  return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
129959
129979
  var _a51;
@@ -129966,7 +129986,7 @@ var AnthropicMessagesLanguageModel = class {
129966
129986
  });
129967
129987
  }
129968
129988
  async doGenerate(options) {
129969
- var _a51, _b40, _c11, _d8, _e7, _f3;
129989
+ var _a51, _b41, _c12, _d8, _e7, _f3;
129970
129990
  const {
129971
129991
  args,
129972
129992
  warnings,
@@ -130214,7 +130234,7 @@ var AnthropicMessagesLanguageModel = class {
130214
130234
  title: result.title,
130215
130235
  providerMetadata: {
130216
130236
  anthropic: {
130217
- pageAge: (_b40 = result.page_age) != null ? _b40 : null
130237
+ pageAge: (_b41 = result.page_age) != null ? _b41 : null
130218
130238
  }
130219
130239
  }
130220
130240
  });
@@ -130245,7 +130265,7 @@ var AnthropicMessagesLanguageModel = class {
130245
130265
  stdout: part.content.stdout,
130246
130266
  stderr: part.content.stderr,
130247
130267
  return_code: part.content.return_code,
130248
- content: (_c11 = part.content.content) != null ? _c11 : []
130268
+ content: (_c12 = part.content.content) != null ? _c12 : []
130249
130269
  }
130250
130270
  });
130251
130271
  } else if (part.content.type === "code_execution_tool_result_error") {
@@ -130370,7 +130390,7 @@ var AnthropicMessagesLanguageModel = class {
130370
130390
  };
130371
130391
  }
130372
130392
  async doStream(options) {
130373
- var _a51, _b40;
130393
+ var _a51, _b41;
130374
130394
  const {
130375
130395
  args: body,
130376
130396
  warnings,
@@ -130427,7 +130447,7 @@ var AnthropicMessagesLanguageModel = class {
130427
130447
  controller.enqueue({ type: "stream-start", warnings });
130428
130448
  },
130429
130449
  transform(chunk, controller) {
130430
- var _a210, _b210, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
130450
+ var _a210, _b210, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
130431
130451
  if (options.includeRawChunks) {
130432
130452
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
130433
130453
  }
@@ -130671,7 +130691,7 @@ var AnthropicMessagesLanguageModel = class {
130671
130691
  stdout: part.content.stdout,
130672
130692
  stderr: part.content.stderr,
130673
130693
  return_code: part.content.return_code,
130674
- content: (_c11 = part.content.content) != null ? _c11 : []
130694
+ content: (_c12 = part.content.content) != null ? _c12 : []
130675
130695
  }
130676
130696
  });
130677
130697
  } else if (part.content.type === "code_execution_tool_result_error") {
@@ -131099,7 +131119,7 @@ var AnthropicMessagesLanguageModel = class {
131099
131119
  if (((_a51 = result.value) == null ? void 0 : _a51.type) === "raw") {
131100
131120
  result = await firstChunkReader.read();
131101
131121
  }
131102
- if (((_b40 = result.value) == null ? void 0 : _b40.type) === "error") {
131122
+ if (((_b41 = result.value) == null ? void 0 : _b41.type) === "error") {
131103
131123
  const error48 = result.value.error;
131104
131124
  throw new APICallError({
131105
131125
  message: error48.message,
@@ -131728,14 +131748,14 @@ var anthropicTools = {
131728
131748
  toolSearchBm25_20251119
131729
131749
  };
131730
131750
  function createAnthropic(options = {}) {
131731
- var _a51, _b40;
131751
+ var _a51, _b41;
131732
131752
  const baseURL = (_a51 = withoutTrailingSlash(
131733
131753
  loadOptionalSetting({
131734
131754
  settingValue: options.baseURL,
131735
131755
  environmentVariableName: "ANTHROPIC_BASE_URL"
131736
131756
  })
131737
131757
  )) != null ? _a51 : "https://api.anthropic.com/v1";
131738
- const providerName = (_b40 = options.name) != null ? _b40 : "anthropic.messages";
131758
+ const providerName = (_b41 = options.name) != null ? _b41 : "anthropic.messages";
131739
131759
  if (options.apiKey && options.authToken) {
131740
131760
  throw new InvalidArgumentError({
131741
131761
  argument: "apiKey/authToken",
@@ -131956,7 +131976,7 @@ var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema(
131956
131976
  )
131957
131977
  );
131958
131978
  function convertGoogleGenerativeAIUsage(usage) {
131959
- var _a51, _b40, _c11, _d8;
131979
+ var _a51, _b41, _c12, _d8;
131960
131980
  if (usage == null) {
131961
131981
  return {
131962
131982
  inputTokens: {
@@ -131974,8 +131994,8 @@ function convertGoogleGenerativeAIUsage(usage) {
131974
131994
  };
131975
131995
  }
131976
131996
  const promptTokens = (_a51 = usage.promptTokenCount) != null ? _a51 : 0;
131977
- const candidatesTokens = (_b40 = usage.candidatesTokenCount) != null ? _b40 : 0;
131978
- const cachedContentTokens = (_c11 = usage.cachedContentTokenCount) != null ? _c11 : 0;
131997
+ const candidatesTokens = (_b41 = usage.candidatesTokenCount) != null ? _b41 : 0;
131998
+ const cachedContentTokens = (_c12 = usage.cachedContentTokenCount) != null ? _c12 : 0;
131979
131999
  const thoughtsTokens = (_d8 = usage.thoughtsTokenCount) != null ? _d8 : 0;
131980
132000
  return {
131981
132001
  inputTokens: {
@@ -132017,7 +132037,7 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema2, isRoot = true) {
132017
132037
  allOf,
132018
132038
  anyOf,
132019
132039
  oneOf,
132020
- format,
132040
+ format: format2,
132021
132041
  const: constValue,
132022
132042
  minLength,
132023
132043
  enum: enumValues
@@ -132025,7 +132045,7 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema2, isRoot = true) {
132025
132045
  const result = {};
132026
132046
  if (description) result.description = description;
132027
132047
  if (required2) result.required = required2;
132028
- if (format) result.format = format;
132048
+ if (format2) result.format = format2;
132029
132049
  if (constValue !== void 0) {
132030
132050
  result.enum = [constValue];
132031
132051
  }
@@ -132107,12 +132127,12 @@ function isEmptyObjectSchema(jsonSchema2) {
132107
132127
  return jsonSchema2 != null && typeof jsonSchema2 === "object" && jsonSchema2.type === "object" && (jsonSchema2.properties == null || Object.keys(jsonSchema2.properties).length === 0) && !jsonSchema2.additionalProperties;
132108
132128
  }
132109
132129
  function convertToGoogleGenerativeAIMessages(prompt, options) {
132110
- var _a51, _b40, _c11;
132130
+ var _a51, _b41, _c12;
132111
132131
  const systemInstructionParts = [];
132112
132132
  const contents = [];
132113
132133
  let systemMessagesAllowed = true;
132114
132134
  const isGemmaModel = (_a51 = options == null ? void 0 : options.isGemmaModel) != null ? _a51 : false;
132115
- const providerOptionsName = (_b40 = options == null ? void 0 : options.providerOptionsName) != null ? _b40 : "google";
132135
+ const providerOptionsName = (_b41 = options == null ? void 0 : options.providerOptionsName) != null ? _b41 : "google";
132116
132136
  for (const { role, content } of prompt) {
132117
132137
  switch (role) {
132118
132138
  case "system": {
@@ -132251,7 +132271,7 @@ function convertToGoogleGenerativeAIMessages(prompt, options) {
132251
132271
  name: part.toolName,
132252
132272
  response: {
132253
132273
  name: part.toolName,
132254
- content: output.type === "execution-denied" ? (_c11 = output.reason) != null ? _c11 : "Tool execution denied." : output.value
132274
+ content: output.type === "execution-denied" ? (_c12 = output.reason) != null ? _c12 : "Tool execution denied." : output.value
132255
132275
  }
132256
132276
  }
132257
132277
  });
@@ -132632,8 +132652,8 @@ var GoogleGenerativeAILanguageModel = class {
132632
132652
  return this.config.provider;
132633
132653
  }
132634
132654
  get supportedUrls() {
132635
- var _a51, _b40, _c11;
132636
- return (_c11 = (_b40 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : {};
132655
+ var _a51, _b41, _c12;
132656
+ return (_c12 = (_b41 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : {};
132637
132657
  }
132638
132658
  async getArgs({
132639
132659
  prompt,
@@ -132734,7 +132754,7 @@ var GoogleGenerativeAILanguageModel = class {
132734
132754
  };
132735
132755
  }
132736
132756
  async doGenerate(options) {
132737
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2;
132757
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2;
132738
132758
  const { args, warnings, providerOptionsName } = await this.getArgs(options);
132739
132759
  const mergedHeaders = combineHeaders(
132740
132760
  await resolve2(this.config.headers),
@@ -132757,11 +132777,11 @@ var GoogleGenerativeAILanguageModel = class {
132757
132777
  });
132758
132778
  const candidate = response.candidates[0];
132759
132779
  const content = [];
132760
- const parts = (_b40 = (_a51 = candidate.content) == null ? void 0 : _a51.parts) != null ? _b40 : [];
132780
+ const parts = (_b41 = (_a51 = candidate.content) == null ? void 0 : _a51.parts) != null ? _b41 : [];
132761
132781
  const usageMetadata = response.usageMetadata;
132762
132782
  let lastCodeExecutionToolCallId;
132763
132783
  for (const part of parts) {
132764
- if ("executableCode" in part && ((_c11 = part.executableCode) == null ? void 0 : _c11.code)) {
132784
+ if ("executableCode" in part && ((_c12 = part.executableCode) == null ? void 0 : _c12.code)) {
132765
132785
  const toolCallId = this.config.generateId();
132766
132786
  lastCodeExecutionToolCallId = toolCallId;
132767
132787
  content.push({
@@ -132901,7 +132921,7 @@ var GoogleGenerativeAILanguageModel = class {
132901
132921
  controller.enqueue({ type: "stream-start", warnings });
132902
132922
  },
132903
132923
  transform(chunk, controller) {
132904
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2;
132924
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2;
132905
132925
  if (options.includeRawChunks) {
132906
132926
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
132907
132927
  }
@@ -132932,9 +132952,9 @@ var GoogleGenerativeAILanguageModel = class {
132932
132952
  }
132933
132953
  }
132934
132954
  if (content != null) {
132935
- const parts = (_b40 = content.parts) != null ? _b40 : [];
132955
+ const parts = (_b41 = content.parts) != null ? _b41 : [];
132936
132956
  for (const part of parts) {
132937
- if ("executableCode" in part && ((_c11 = part.executableCode) == null ? void 0 : _c11.code)) {
132957
+ if ("executableCode" in part && ((_c12 = part.executableCode) == null ? void 0 : _c12.code)) {
132938
132958
  const toolCallId = generateId3();
132939
132959
  lastCodeExecutionToolCallId = toolCallId;
132940
132960
  controller.enqueue({
@@ -133133,7 +133153,7 @@ function extractSources({
133133
133153
  groundingMetadata,
133134
133154
  generateId: generateId3
133135
133155
  }) {
133136
- var _a51, _b40, _c11, _d8, _e7;
133156
+ var _a51, _b41, _c12, _d8, _e7;
133137
133157
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
133138
133158
  return void 0;
133139
133159
  }
@@ -133156,10 +133176,10 @@ function extractSources({
133156
133176
  sourceType: "url",
133157
133177
  id: generateId3(),
133158
133178
  url: uri,
133159
- title: (_b40 = chunk.retrievedContext.title) != null ? _b40 : void 0
133179
+ title: (_b41 = chunk.retrievedContext.title) != null ? _b41 : void 0
133160
133180
  });
133161
133181
  } else if (uri) {
133162
- const title = (_c11 = chunk.retrievedContext.title) != null ? _c11 : "Unknown Document";
133182
+ const title = (_c12 = chunk.retrievedContext.title) != null ? _c12 : "Unknown Document";
133163
133183
  let mediaType = "application/octet-stream";
133164
133184
  let filename = void 0;
133165
133185
  if (uri.endsWith(".pdf")) {
@@ -133502,7 +133522,7 @@ var GoogleGenerativeAIImageModel = class {
133502
133522
  return this.doGenerateImagen(options);
133503
133523
  }
133504
133524
  async doGenerateImagen(options) {
133505
- var _a51, _b40, _c11;
133525
+ var _a51, _b41, _c12;
133506
133526
  const {
133507
133527
  prompt,
133508
133528
  n: n3 = 1,
@@ -133545,7 +133565,7 @@ var GoogleGenerativeAIImageModel = class {
133545
133565
  providerOptions,
133546
133566
  schema: googleImageModelOptionsSchema
133547
133567
  });
133548
- const currentDate = (_c11 = (_b40 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
133568
+ const currentDate = (_c12 = (_b41 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : /* @__PURE__ */ new Date();
133549
133569
  const parameters = {
133550
133570
  sampleCount: n3
133551
133571
  };
@@ -133590,7 +133610,7 @@ var GoogleGenerativeAIImageModel = class {
133590
133610
  };
133591
133611
  }
133592
133612
  async doGenerateGemini(options) {
133593
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i;
133613
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i;
133594
133614
  const {
133595
133615
  prompt,
133596
133616
  n: n3,
@@ -133650,7 +133670,7 @@ var GoogleGenerativeAIImageModel = class {
133650
133670
  baseURL: this.config.baseURL,
133651
133671
  headers: (_a51 = this.config.headers) != null ? _a51 : {},
133652
133672
  fetch: this.config.fetch,
133653
- generateId: (_b40 = this.config.generateId) != null ? _b40 : generateId
133673
+ generateId: (_b41 = this.config.generateId) != null ? _b41 : generateId
133654
133674
  });
133655
133675
  const result = await languageModel.doGenerate({
133656
133676
  prompt: languageModelPrompt,
@@ -133661,7 +133681,7 @@ var GoogleGenerativeAIImageModel = class {
133661
133681
  imageConfig: aspectRatio ? {
133662
133682
  aspectRatio
133663
133683
  } : void 0,
133664
- ...(_c11 = providerOptions == null ? void 0 : providerOptions.google) != null ? _c11 : {}
133684
+ ...(_c12 = providerOptions == null ? void 0 : providerOptions.google) != null ? _c12 : {}
133665
133685
  }
133666
133686
  },
133667
133687
  headers,
@@ -133726,8 +133746,8 @@ var GoogleGenerativeAIVideoModel = class {
133726
133746
  return 4;
133727
133747
  }
133728
133748
  async doGenerate(options) {
133729
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2;
133730
- const currentDate = (_c11 = (_b40 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
133749
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2;
133750
+ const currentDate = (_c12 = (_b41 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : /* @__PURE__ */ new Date();
133731
133751
  const warnings = [];
133732
133752
  const googleOptions = await parseProviderOptions({
133733
133753
  provider: "google",
@@ -133961,9 +133981,9 @@ var googleVideoModelOptionsSchema = lazySchema(
133961
133981
  )
133962
133982
  );
133963
133983
  function createGoogleGenerativeAI(options = {}) {
133964
- var _a51, _b40;
133984
+ var _a51, _b41;
133965
133985
  const baseURL = (_a51 = withoutTrailingSlash(options.baseURL)) != null ? _a51 : "https://generativelanguage.googleapis.com/v1beta";
133966
- const providerName = (_b40 = options.name) != null ? _b40 : "google.generative-ai";
133986
+ const providerName = (_b41 = options.name) != null ? _b41 : "google.generative-ai";
133967
133987
  const getHeaders = () => withUserAgentSuffix(
133968
133988
  {
133969
133989
  "x-goog-api-key": loadApiKey({
@@ -134304,7 +134324,7 @@ var OllamaCompletionLanguageModel = class {
134304
134324
  };
134305
134325
  }
134306
134326
  async doGenerate(options) {
134307
- var _a51, _b40;
134327
+ var _a51, _b41;
134308
134328
  const { args: body, warnings } = this.getArgs(options);
134309
134329
  const {
134310
134330
  responseHeaders,
@@ -134341,7 +134361,7 @@ var OllamaCompletionLanguageModel = class {
134341
134361
  cacheWrite: void 0
134342
134362
  },
134343
134363
  outputTokens: {
134344
- total: (_b40 = typedResponse.eval_count) != null ? _b40 : 0,
134364
+ total: (_b41 = typedResponse.eval_count) != null ? _b41 : 0,
134345
134365
  text: void 0,
134346
134366
  reasoning: void 0
134347
134367
  }
@@ -134475,13 +134495,13 @@ var ollamaEmbeddingProviderOptions = external_exports.object({
134475
134495
  var OllamaEmbeddingModel = class {
134476
134496
  constructor(modelId, settings, config2) {
134477
134497
  this.specificationVersion = "v3";
134478
- var _a51, _b40;
134498
+ var _a51, _b41;
134479
134499
  this.modelId = modelId;
134480
134500
  this.settings = settings;
134481
134501
  this.config = config2;
134482
134502
  this.provider = config2.provider;
134483
134503
  this.maxEmbeddingsPerCall = (_a51 = settings.maxEmbeddingsPerCall) != null ? _a51 : 2048;
134484
- this.supportsParallelCalls = (_b40 = settings.supportsParallelCalls) != null ? _b40 : true;
134504
+ this.supportsParallelCalls = (_b41 = settings.supportsParallelCalls) != null ? _b41 : true;
134485
134505
  }
134486
134506
  getArgs({
134487
134507
  values
@@ -134502,7 +134522,7 @@ var OllamaEmbeddingModel = class {
134502
134522
  abortSignal,
134503
134523
  providerOptions
134504
134524
  }) {
134505
- var _a51, _b40, _c11;
134525
+ var _a51, _b41, _c12;
134506
134526
  if (this.maxEmbeddingsPerCall && values.length > this.maxEmbeddingsPerCall) {
134507
134527
  throw new TooManyEmbeddingValuesForCallError({
134508
134528
  provider: this.provider,
@@ -134517,8 +134537,8 @@ var OllamaEmbeddingModel = class {
134517
134537
  schema: ollamaEmbeddingProviderOptions
134518
134538
  });
134519
134539
  const dimensions = (_a51 = ollamaOptions == null ? void 0 : ollamaOptions.dimensions) != null ? _a51 : this.settings.dimensions;
134520
- const truncate = (_b40 = ollamaOptions == null ? void 0 : ollamaOptions.truncate) != null ? _b40 : this.settings.truncate;
134521
- const keepAlive = (_c11 = ollamaOptions == null ? void 0 : ollamaOptions.keepAlive) != null ? _c11 : this.settings.keepAlive;
134540
+ const truncate = (_b41 = ollamaOptions == null ? void 0 : ollamaOptions.truncate) != null ? _b41 : this.settings.truncate;
134541
+ const keepAlive = (_c12 = ollamaOptions == null ? void 0 : ollamaOptions.keepAlive) != null ? _c12 : this.settings.keepAlive;
134522
134542
  const body = {
134523
134543
  model: this.modelId,
134524
134544
  input: values
@@ -134603,7 +134623,7 @@ var OllamaResponseProcessor = class {
134603
134623
  };
134604
134624
  }
134605
134625
  extractContent(response) {
134606
- var _a51, _b40, _c11, _d8, _e7;
134626
+ var _a51, _b41, _c12, _d8, _e7;
134607
134627
  const content = [];
134608
134628
  const text2 = response.message.content;
134609
134629
  if (text2 != null && text2.length > 0) {
@@ -134622,7 +134642,7 @@ var OllamaResponseProcessor = class {
134622
134642
  for (const toolCall of (_a51 = response.message.tool_calls) != null ? _a51 : []) {
134623
134643
  content.push({
134624
134644
  type: "tool-call",
134625
- toolCallId: (_e7 = toolCall.id) != null ? _e7 : (_d8 = (_c11 = (_b40 = this.config).generateId) == null ? void 0 : _c11.call(_b40)) != null ? _d8 : generateId(),
134645
+ toolCallId: (_e7 = toolCall.id) != null ? _e7 : (_d8 = (_c12 = (_b41 = this.config).generateId) == null ? void 0 : _c12.call(_b41)) != null ? _d8 : generateId(),
134626
134646
  toolName: toolCall.function.name,
134627
134647
  input: JSON.stringify(toolCall.function.arguments)
134628
134648
  });
@@ -134630,7 +134650,7 @@ var OllamaResponseProcessor = class {
134630
134650
  return content;
134631
134651
  }
134632
134652
  extractUsage(response) {
134633
- var _a51, _b40;
134653
+ var _a51, _b41;
134634
134654
  return {
134635
134655
  inputTokens: {
134636
134656
  total: (_a51 = response.prompt_eval_count) != null ? _a51 : 0,
@@ -134639,7 +134659,7 @@ var OllamaResponseProcessor = class {
134639
134659
  cacheWrite: void 0
134640
134660
  },
134641
134661
  outputTokens: {
134642
- total: (_b40 = response.eval_count) != null ? _b40 : 0,
134662
+ total: (_b41 = response.eval_count) != null ? _b41 : 0,
134643
134663
  text: void 0,
134644
134664
  reasoning: void 0
134645
134665
  }
@@ -134843,7 +134863,7 @@ function convertToOllamaResponsesMessages({
134843
134863
  messages.push({
134844
134864
  role: "user",
134845
134865
  content: content.map((part, index) => {
134846
- var _a51, _b40, _c11;
134866
+ var _a51, _b41, _c12;
134847
134867
  switch (part.type) {
134848
134868
  case "text": {
134849
134869
  return { type: "input_text", text: part.text };
@@ -134855,7 +134875,7 @@ function convertToOllamaResponsesMessages({
134855
134875
  type: "input_image",
134856
134876
  image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
134857
134877
  // Ollama specific extension: image detail
134858
- detail: (_b40 = (_a51 = part.providerOptions) == null ? void 0 : _a51.ollama) == null ? void 0 : _b40.imageDetail
134878
+ detail: (_b41 = (_a51 = part.providerOptions) == null ? void 0 : _a51.ollama) == null ? void 0 : _b41.imageDetail
134859
134879
  };
134860
134880
  } else if (part.mediaType === "application/pdf") {
134861
134881
  if (part.data instanceof URL) {
@@ -134865,7 +134885,7 @@ function convertToOllamaResponsesMessages({
134865
134885
  }
134866
134886
  return {
134867
134887
  type: "input_file",
134868
- filename: (_c11 = part.filename) != null ? _c11 : `part-${index}.pdf`,
134888
+ filename: (_c12 = part.filename) != null ? _c12 : `part-${index}.pdf`,
134869
134889
  file_data: `data:application/pdf;base64,${part.data}`
134870
134890
  };
134871
134891
  } else {
@@ -135099,7 +135119,7 @@ var OllamaRequestBuilder = class {
135099
135119
  responseFormat,
135100
135120
  ollamaOptions
135101
135121
  }) {
135102
- var _a51, _b40;
135122
+ var _a51, _b41;
135103
135123
  return {
135104
135124
  model: modelId,
135105
135125
  messages: convertToOllamaChatMessages({
@@ -135113,7 +135133,7 @@ var OllamaRequestBuilder = class {
135113
135133
  format: responseFormat.schema != null ? responseFormat.schema : "json"
135114
135134
  },
135115
135135
  think: (_a51 = ollamaOptions == null ? void 0 : ollamaOptions.think) != null ? _a51 : false,
135116
- options: (_b40 = ollamaOptions == null ? void 0 : ollamaOptions.options) != null ? _b40 : void 0
135136
+ options: (_b41 = ollamaOptions == null ? void 0 : ollamaOptions.options) != null ? _b41 : void 0
135117
135137
  };
135118
135138
  }
135119
135139
  };
@@ -135256,22 +135276,22 @@ var OllamaStreamProcessor = class {
135256
135276
  }
135257
135277
  }
135258
135278
  processToolCalls(delta, controller) {
135259
- var _a51, _b40, _c11, _d8;
135279
+ var _a51, _b41, _c12, _d8;
135260
135280
  for (const toolCall of (_a51 = delta.tool_calls) != null ? _a51 : []) {
135261
- if (((_b40 = toolCall.function) == null ? void 0 : _b40.name) == null) {
135281
+ if (((_b41 = toolCall.function) == null ? void 0 : _b41.name) == null) {
135262
135282
  throw new InvalidResponseDataError({
135263
135283
  data: toolCall,
135264
135284
  message: `Expected 'function.name' to be a string.`
135265
135285
  });
135266
135286
  }
135267
- if (((_c11 = toolCall.function) == null ? void 0 : _c11.name) != null && ((_d8 = toolCall.function) == null ? void 0 : _d8.arguments) != null) {
135287
+ if (((_c12 = toolCall.function) == null ? void 0 : _c12.name) != null && ((_d8 = toolCall.function) == null ? void 0 : _d8.arguments) != null) {
135268
135288
  this.emitToolCall(toolCall, controller);
135269
135289
  }
135270
135290
  }
135271
135291
  }
135272
135292
  emitToolCall(toolCall, controller) {
135273
- var _a51, _b40, _c11, _d8;
135274
- const id = (_d8 = toolCall.id) != null ? _d8 : (_c11 = (_b40 = (_a51 = this.config).generateId) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : generateId();
135293
+ var _a51, _b41, _c12, _d8;
135294
+ const id = (_d8 = toolCall.id) != null ? _d8 : (_c12 = (_b41 = (_a51 = this.config).generateId) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : generateId();
135275
135295
  controller.enqueue({
135276
135296
  type: "tool-input-start",
135277
135297
  id,
@@ -135392,9 +135412,9 @@ var OllamaResponsesLanguageModel = class {
135392
135412
  }
135393
135413
  };
135394
135414
  function createOllama(options = {}) {
135395
- var _a51, _b40;
135415
+ var _a51, _b41;
135396
135416
  const baseURL = (_a51 = withoutTrailingSlash(options.baseURL)) != null ? _a51 : "http://127.0.0.1:11434/api";
135397
- const providerName = (_b40 = options.name) != null ? _b40 : "ollama";
135417
+ const providerName = (_b41 = options.name) != null ? _b41 : "ollama";
135398
135418
  const getHeaders = () => ({
135399
135419
  "Ollama-Organization": options.organization,
135400
135420
  "Ollama-Project": options.project,
@@ -135452,8 +135472,8 @@ var ollama = createOllama();
135452
135472
 
135453
135473
  // ../../node_modules/.pnpm/@ai-sdk+openai-compatible@1.0.30_zod@4.3.6/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
135454
135474
  function getOpenAIMetadata(message) {
135455
- var _a51, _b40;
135456
- return (_b40 = (_a51 = message == null ? void 0 : message.providerOptions) == null ? void 0 : _a51.openaiCompatible) != null ? _b40 : {};
135475
+ var _a51, _b41;
135476
+ return (_b41 = (_a51 = message == null ? void 0 : message.providerOptions) == null ? void 0 : _a51.openaiCompatible) != null ? _b41 : {};
135457
135477
  }
135458
135478
  function convertToOpenAICompatibleChatMessages(prompt) {
135459
135479
  const messages = [];
@@ -135678,7 +135698,7 @@ var OpenAICompatibleChatLanguageModel = class {
135678
135698
  // type inferred via constructor
135679
135699
  constructor(modelId, config2) {
135680
135700
  this.specificationVersion = "v2";
135681
- var _a51, _b40;
135701
+ var _a51, _b41;
135682
135702
  this.modelId = modelId;
135683
135703
  this.config = config2;
135684
135704
  const errorStructure = (_a51 = config2.errorStructure) != null ? _a51 : defaultOpenAICompatibleErrorStructure;
@@ -135686,7 +135706,7 @@ var OpenAICompatibleChatLanguageModel = class {
135686
135706
  errorStructure.errorSchema
135687
135707
  );
135688
135708
  this.failedResponseHandler = createJsonErrorResponseHandler(errorStructure);
135689
- this.supportsStructuredOutputs = (_b40 = config2.supportsStructuredOutputs) != null ? _b40 : false;
135709
+ this.supportsStructuredOutputs = (_b41 = config2.supportsStructuredOutputs) != null ? _b41 : false;
135690
135710
  }
135691
135711
  get provider() {
135692
135712
  return this.config.provider;
@@ -135695,8 +135715,8 @@ var OpenAICompatibleChatLanguageModel = class {
135695
135715
  return this.config.provider.split(".")[0].trim();
135696
135716
  }
135697
135717
  get supportedUrls() {
135698
- var _a51, _b40, _c11;
135699
- return (_c11 = (_b40 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : {};
135718
+ var _a51, _b41, _c12;
135719
+ return (_c12 = (_b41 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : {};
135700
135720
  }
135701
135721
  async getArgs({
135702
135722
  prompt,
@@ -135713,7 +135733,7 @@ var OpenAICompatibleChatLanguageModel = class {
135713
135733
  toolChoice,
135714
135734
  tools
135715
135735
  }) {
135716
- var _a51, _b40, _c11, _d8;
135736
+ var _a51, _b41, _c12, _d8;
135717
135737
  const warnings = [];
135718
135738
  const compatibleOptions = Object.assign(
135719
135739
  (_a51 = await parseProviderOptions({
@@ -135721,11 +135741,11 @@ var OpenAICompatibleChatLanguageModel = class {
135721
135741
  providerOptions,
135722
135742
  schema: openaiCompatibleProviderOptions
135723
135743
  })) != null ? _a51 : {},
135724
- (_b40 = await parseProviderOptions({
135744
+ (_b41 = await parseProviderOptions({
135725
135745
  provider: this.providerOptionsName,
135726
135746
  providerOptions,
135727
135747
  schema: openaiCompatibleProviderOptions
135728
- })) != null ? _b40 : {}
135748
+ })) != null ? _b41 : {}
135729
135749
  );
135730
135750
  if (topK != null) {
135731
135751
  warnings.push({ type: "unsupported-setting", setting: "topK" });
@@ -135761,7 +135781,7 @@ var OpenAICompatibleChatLanguageModel = class {
135761
135781
  type: "json_schema",
135762
135782
  json_schema: {
135763
135783
  schema: responseFormat.schema,
135764
- name: (_c11 = responseFormat.name) != null ? _c11 : "response",
135784
+ name: (_c12 = responseFormat.name) != null ? _c12 : "response",
135765
135785
  description: responseFormat.description
135766
135786
  }
135767
135787
  } : { type: "json_object" } : void 0,
@@ -135786,7 +135806,7 @@ var OpenAICompatibleChatLanguageModel = class {
135786
135806
  };
135787
135807
  }
135788
135808
  async doGenerate(options) {
135789
- var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2;
135809
+ var _a51, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2;
135790
135810
  const { args, warnings } = await this.getArgs({ ...options });
135791
135811
  const body = JSON.stringify(args);
135792
135812
  const {
@@ -135824,7 +135844,7 @@ var OpenAICompatibleChatLanguageModel = class {
135824
135844
  for (const toolCall of choice2.message.tool_calls) {
135825
135845
  content.push({
135826
135846
  type: "tool-call",
135827
- toolCallId: (_b40 = toolCall.id) != null ? _b40 : generateId(),
135847
+ toolCallId: (_b41 = toolCall.id) != null ? _b41 : generateId(),
135828
135848
  toolName: toolCall.function.name,
135829
135849
  input: toolCall.function.arguments
135830
135850
  });
@@ -135832,7 +135852,7 @@ var OpenAICompatibleChatLanguageModel = class {
135832
135852
  }
135833
135853
  const providerMetadata = {
135834
135854
  [this.providerOptionsName]: {},
135835
- ...await ((_d8 = (_c11 = this.config.metadataExtractor) == null ? void 0 : _c11.extractMetadata) == null ? void 0 : _d8.call(_c11, {
135855
+ ...await ((_d8 = (_c12 = this.config.metadataExtractor) == null ? void 0 : _c12.extractMetadata) == null ? void 0 : _d8.call(_c12, {
135836
135856
  parsedBody: rawResponse
135837
135857
  }))
135838
135858
  };
@@ -135914,7 +135934,7 @@ var OpenAICompatibleChatLanguageModel = class {
135914
135934
  },
135915
135935
  // TODO we lost type safety on Chunk, most likely due to the error schema. MUST FIX
135916
135936
  transform(chunk, controller) {
135917
- var _a210, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
135937
+ var _a210, _b41, _c12, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
135918
135938
  if (options.includeRawChunks) {
135919
135939
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
135920
135940
  }
@@ -136007,7 +136027,7 @@ var OpenAICompatibleChatLanguageModel = class {
136007
136027
  message: `Expected 'id' to be a string.`
136008
136028
  });
136009
136029
  }
136010
- if (((_b40 = toolCallDelta.function) == null ? void 0 : _b40.name) == null) {
136030
+ if (((_b41 = toolCallDelta.function) == null ? void 0 : _b41.name) == null) {
136011
136031
  throw new InvalidResponseDataError({
136012
136032
  data: toolCallDelta,
136013
136033
  message: `Expected 'function.name' to be a string.`
@@ -136023,7 +136043,7 @@ var OpenAICompatibleChatLanguageModel = class {
136023
136043
  type: "function",
136024
136044
  function: {
136025
136045
  name: toolCallDelta.function.name,
136026
- arguments: (_c11 = toolCallDelta.function.arguments) != null ? _c11 : ""
136046
+ arguments: (_c12 = toolCallDelta.function.arguments) != null ? _c12 : ""
136027
136047
  },
136028
136048
  hasFinished: false
136029
136049
  };
@@ -136081,7 +136101,7 @@ var OpenAICompatibleChatLanguageModel = class {
136081
136101
  }
136082
136102
  },
136083
136103
  flush(controller) {
136084
- var _a210, _b40, _c11, _d8, _e7, _f3;
136104
+ var _a210, _b41, _c12, _d8, _e7, _f3;
136085
136105
  if (isActiveReasoning) {
136086
136106
  controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
136087
136107
  }
@@ -136116,8 +136136,8 @@ var OpenAICompatibleChatLanguageModel = class {
136116
136136
  type: "finish",
136117
136137
  finishReason,
136118
136138
  usage: {
136119
- inputTokens: (_b40 = usage.promptTokens) != null ? _b40 : void 0,
136120
- outputTokens: (_c11 = usage.completionTokens) != null ? _c11 : void 0,
136139
+ inputTokens: (_b41 = usage.promptTokens) != null ? _b41 : void 0,
136140
+ outputTokens: (_c12 = usage.completionTokens) != null ? _c12 : void 0,
136121
136141
  totalTokens: (_d8 = usage.totalTokens) != null ? _d8 : void 0,
136122
136142
  reasoningTokens: (_e7 = usage.completionTokensDetails.reasoningTokens) != null ? _e7 : void 0,
136123
136143
  cachedInputTokens: (_f3 = usage.promptTokensDetails.cachedTokens) != null ? _f3 : void 0
@@ -136343,8 +136363,8 @@ var OpenAICompatibleCompletionLanguageModel = class {
136343
136363
  return this.config.provider.split(".")[0].trim();
136344
136364
  }
136345
136365
  get supportedUrls() {
136346
- var _a51, _b40, _c11;
136347
- return (_c11 = (_b40 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : {};
136366
+ var _a51, _b41, _c12;
136367
+ return (_c12 = (_b41 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : {};
136348
136368
  }
136349
136369
  async getArgs({
136350
136370
  prompt,
@@ -136412,7 +136432,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
136412
136432
  };
136413
136433
  }
136414
136434
  async doGenerate(options) {
136415
- var _a51, _b40, _c11, _d8, _e7, _f3;
136435
+ var _a51, _b41, _c12, _d8, _e7, _f3;
136416
136436
  const { args, warnings } = await this.getArgs(options);
136417
136437
  const {
136418
136438
  responseHeaders,
@@ -136440,8 +136460,8 @@ var OpenAICompatibleCompletionLanguageModel = class {
136440
136460
  return {
136441
136461
  content,
136442
136462
  usage: {
136443
- inputTokens: (_b40 = (_a51 = response.usage) == null ? void 0 : _a51.prompt_tokens) != null ? _b40 : void 0,
136444
- outputTokens: (_d8 = (_c11 = response.usage) == null ? void 0 : _c11.completion_tokens) != null ? _d8 : void 0,
136463
+ inputTokens: (_b41 = (_a51 = response.usage) == null ? void 0 : _a51.prompt_tokens) != null ? _b41 : void 0,
136464
+ outputTokens: (_d8 = (_c12 = response.usage) == null ? void 0 : _c12.completion_tokens) != null ? _d8 : void 0,
136445
136465
  totalTokens: (_f3 = (_e7 = response.usage) == null ? void 0 : _e7.total_tokens) != null ? _f3 : void 0
136446
136466
  },
136447
136467
  finishReason: mapOpenAICompatibleFinishReason2(choice2.finish_reason),
@@ -136490,7 +136510,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
136490
136510
  controller.enqueue({ type: "stream-start", warnings });
136491
136511
  },
136492
136512
  transform(chunk, controller) {
136493
- var _a51, _b40, _c11;
136513
+ var _a51, _b41, _c12;
136494
136514
  if (options.includeRawChunks) {
136495
136515
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
136496
136516
  }
@@ -136518,8 +136538,8 @@ var OpenAICompatibleCompletionLanguageModel = class {
136518
136538
  }
136519
136539
  if (value.usage != null) {
136520
136540
  usage.inputTokens = (_a51 = value.usage.prompt_tokens) != null ? _a51 : void 0;
136521
- usage.outputTokens = (_b40 = value.usage.completion_tokens) != null ? _b40 : void 0;
136522
- usage.totalTokens = (_c11 = value.usage.total_tokens) != null ? _c11 : void 0;
136541
+ usage.outputTokens = (_b41 = value.usage.completion_tokens) != null ? _b41 : void 0;
136542
+ usage.totalTokens = (_c12 = value.usage.total_tokens) != null ? _c12 : void 0;
136523
136543
  }
136524
136544
  const choice2 = value.choices[0];
136525
136545
  if ((choice2 == null ? void 0 : choice2.finish_reason) != null) {
@@ -136623,18 +136643,18 @@ var OpenAICompatibleEmbeddingModel = class {
136623
136643
  abortSignal,
136624
136644
  providerOptions
136625
136645
  }) {
136626
- var _a51, _b40, _c11;
136646
+ var _a51, _b41, _c12;
136627
136647
  const compatibleOptions = Object.assign(
136628
136648
  (_a51 = await parseProviderOptions({
136629
136649
  provider: "openai-compatible",
136630
136650
  providerOptions,
136631
136651
  schema: openaiCompatibleEmbeddingProviderOptions
136632
136652
  })) != null ? _a51 : {},
136633
- (_b40 = await parseProviderOptions({
136653
+ (_b41 = await parseProviderOptions({
136634
136654
  provider: this.providerOptionsName,
136635
136655
  providerOptions,
136636
136656
  schema: openaiCompatibleEmbeddingProviderOptions
136637
- })) != null ? _b40 : {}
136657
+ })) != null ? _b41 : {}
136638
136658
  );
136639
136659
  if (values.length > this.maxEmbeddingsPerCall) {
136640
136660
  throw new TooManyEmbeddingValuesForCallError({
@@ -136662,7 +136682,7 @@ var OpenAICompatibleEmbeddingModel = class {
136662
136682
  user: compatibleOptions.user
136663
136683
  },
136664
136684
  failedResponseHandler: createJsonErrorResponseHandler(
136665
- (_c11 = this.config.errorStructure) != null ? _c11 : defaultOpenAICompatibleErrorStructure
136685
+ (_c12 = this.config.errorStructure) != null ? _c12 : defaultOpenAICompatibleErrorStructure
136666
136686
  ),
136667
136687
  successfulResponseHandler: createJsonResponseHandler(
136668
136688
  openaiTextEmbeddingResponseSchema2
@@ -136703,7 +136723,7 @@ var OpenAICompatibleImageModel = class {
136703
136723
  headers,
136704
136724
  abortSignal
136705
136725
  }) {
136706
- var _a51, _b40, _c11, _d8, _e7;
136726
+ var _a51, _b41, _c12, _d8, _e7;
136707
136727
  const warnings = [];
136708
136728
  if (aspectRatio != null) {
136709
136729
  warnings.push({
@@ -136715,7 +136735,7 @@ var OpenAICompatibleImageModel = class {
136715
136735
  if (seed != null) {
136716
136736
  warnings.push({ type: "unsupported-setting", setting: "seed" });
136717
136737
  }
136718
- const currentDate = (_c11 = (_b40 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
136738
+ const currentDate = (_c12 = (_b41 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b41.call(_a51)) != null ? _c12 : /* @__PURE__ */ new Date();
136719
136739
  const { value: response, responseHeaders } = await postJsonToApi({
136720
136740
  url: this.config.url({
136721
136741
  path: "/images/generations",
@@ -137045,8 +137065,8 @@ var InfomaniakTranscriptionModel = class {
137045
137065
  throw new Error(`Transcription timed out after ${maxRetries} attempts`);
137046
137066
  }
137047
137067
  async doGenerate(options) {
137048
- var _a51, _b40, _c11, _d8;
137049
- const currentDate = ((_b40 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b40.call(_a51)) ?? /* @__PURE__ */ new Date();
137068
+ var _a51, _b41, _c12, _d8;
137069
+ const currentDate = ((_b41 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b41.call(_a51)) ?? /* @__PURE__ */ new Date();
137050
137070
  const { formData, warnings } = await this.getArgs(options);
137051
137071
  const { value: batchResponse } = await postFormDataToApi({
137052
137072
  url: this.config.url({
@@ -137068,7 +137088,7 @@ var InfomaniakTranscriptionModel = class {
137068
137088
  const language = result.language != null && result.language in languageMap2 ? languageMap2[result.language] : void 0;
137069
137089
  return {
137070
137090
  text: result.text,
137071
- segments: ((_c11 = result.segments) == null ? void 0 : _c11.map((segment) => ({
137091
+ segments: ((_c12 = result.segments) == null ? void 0 : _c12.map((segment) => ({
137072
137092
  text: segment.text,
137073
137093
  startSecond: segment.start,
137074
137094
  endSecond: segment.end
@@ -137167,7 +137187,13 @@ var DEPRECATED_MODEL_PATTERNS = {
137167
137187
  // Old turbo previews
137168
137188
  "gpt-4-turbo-preview",
137169
137189
  "gpt-4-1106-preview",
137170
- "gpt-4-0125-preview"
137190
+ "gpt-4-0125-preview",
137191
+ "*-image*",
137192
+ "*-transcribe*",
137193
+ "*-search*",
137194
+ "*-translate*",
137195
+ "*-whisper*",
137196
+ "*-audio*"
137171
137197
  ],
137172
137198
  anthropic: [
137173
137199
  // Legacy Claude models
@@ -137180,51 +137206,55 @@ var DEPRECATED_MODEL_PATTERNS = {
137180
137206
  "claude-3-haiku-20240307"
137181
137207
  ],
137182
137208
  google: [
137183
- // Legacy Gemini 1.0 models
137184
- "gemini-1.0",
137185
- "gemini-pro",
137186
- // Legacy name for 1.0
137187
- // Old preview versions
137188
- "gemini-1.5-pro-preview",
137189
- "gemini-1.5-flash-preview"
137209
+ "gemini-embedding",
137210
+ // Filter out all lite variants (weaker tool-calling/orchestration)
137211
+ "*-lite*",
137212
+ "*-image*"
137190
137213
  ],
137191
- infomaniak: [],
137192
- // Swiss-hosted models - no filtering
137193
- ollama: []
137214
+ infomaniak: ["swiss-ai/Apertus-70B-Instruct-2509", "Qwen/Qwen3-Embedding"],
137215
+ "infomaniak-v1": [],
137216
+ ollama: [],
137194
137217
  // No filtering for local models
137218
+ skilder: []
137195
137219
  };
137196
137220
  var PREFERRED_MODEL_PATTERNS = {
137197
- openai: [
137198
- "gpt-5-mini-2025",
137199
- "gpt-5-pro",
137200
- "gpt-5-nano-2025"
137201
- ],
137202
- anthropic: [
137203
- "claude-haiku-4",
137204
- "claude-4",
137205
- "claude-opus-4",
137206
- "sonnet-4-5"
137207
- ],
137208
- google: [
137209
- "gemini-3-mini",
137210
- "gemini-3-pro",
137211
- "gemini-3"
137212
- ],
137213
- infomaniak: [
137214
- "mistral",
137215
- "gpt-oss/120b",
137216
- "apertus"
137217
- ],
137218
- ollama: []
137221
+ openai: ["gpt-5-mini-2025", "gpt-5-pro", "gpt-5-nano-2025"],
137222
+ anthropic: ["claude-opus-4-7", "claude-sonnet-4-6", "claude-haiku-4-5-20251001"],
137223
+ google: ["gemini-2.5-pro", "gemini-2.5-flash", "gemini-3.5-flash"],
137224
+ infomaniak: ["mistralai/Mistral-Small-4-119B-2603", "Qwen/Qwen3.5-122B-A10B-FP8", "moonshotai/Kimi-K2.6"],
137225
+ "infomaniak-v1": ["mistral", "llama3.3", "qwen3"],
137226
+ ollama: [],
137219
137227
  // No prioritization for local models
137228
+ skilder: ["mistralai/Mistral-Small-4-119B-2603", "Qwen/Qwen3.5-122B-A10B-FP8", "moonshotai/Kimi-K2.6"]
137220
137229
  };
137221
137230
 
137222
137231
  // ../common/src/services/ai/ai-provider.utils.ts
137232
+ function parseModelString(modelString) {
137233
+ const slashIndex = modelString.indexOf("/");
137234
+ if (slashIndex === -1) {
137235
+ throw new Error("Invalid model format. Model name cannot be empty");
137236
+ }
137237
+ const slug = modelString.substring(0, slashIndex);
137238
+ const modelName = modelString.substring(slashIndex + 1);
137239
+ if (!slug) {
137240
+ throw new Error("Invalid model format. Provider slug cannot be empty");
137241
+ }
137242
+ if (!modelName) {
137243
+ throw new Error("Invalid model format. Model name cannot be empty");
137244
+ }
137245
+ return { slug, modelName };
137246
+ }
137223
137247
  function isModelDeprecated(provider, modelId) {
137224
137248
  const patterns = DEPRECATED_MODEL_PATTERNS[provider];
137225
137249
  if (!patterns || patterns.length === 0) return false;
137226
- const lowerModelId = modelId.toLowerCase();
137227
- return patterns.some((pattern) => lowerModelId.startsWith(pattern.toLowerCase()));
137250
+ const id = modelId.toLowerCase();
137251
+ return patterns.some((pattern) => {
137252
+ const p2 = pattern.toLowerCase();
137253
+ if (p2.startsWith("*") && p2.endsWith("*")) return id.includes(p2.slice(1, -1));
137254
+ if (p2.startsWith("*")) return id.endsWith(p2.slice(1));
137255
+ if (p2.endsWith("*")) return id.startsWith(p2.slice(0, -1));
137256
+ return id.startsWith(p2);
137257
+ });
137228
137258
  }
137229
137259
  function getModelPreferenceScore(provider, modelId) {
137230
137260
  const patterns = PREFERRED_MODEL_PATTERNS[provider];
@@ -137277,24 +137307,46 @@ var AIProviderService = class AIProviderService2 {
137277
137307
  * Get a model instance for a provider.
137278
137308
  * Uses Vercel AI SDK provider factories directly.
137279
137309
  */
137280
- getProviderModel(provider, modelName, config2) {
137310
+ getProviderModel(provider, modelName, config2, slug) {
137281
137311
  switch (provider) {
137282
- case "infomaniak":
137312
+ case "skilder": {
137283
137313
  if (!config2.apiKey) {
137284
- throw new InvalidAPIKeyError(provider);
137314
+ throw new InvalidAPIKeyError(provider, slug);
137285
137315
  }
137286
137316
  if (!config2.productId) {
137287
- throw new MissingProductIdError(provider);
137317
+ throw new MissingProductIdError(provider, slug);
137288
137318
  }
137289
- if (config2.apiVersion === "v2") {
137290
- const infomaniakV2 = createOpenAICompatible({
137291
- name: "infomaniak-v2",
137292
- baseURL: `${AI_PROVIDER_API_URLS.INFOMANIAK_V2}/${config2.productId}/openai/v1`,
137293
- headers: {
137294
- Authorization: `Bearer ${config2.apiKey}`
137295
- }
137296
- });
137297
- return infomaniakV2.chatModel(modelName);
137319
+ const skilder = createOpenAICompatible({
137320
+ name: "skilder",
137321
+ baseURL: `${AI_PROVIDER_API_URLS.INFOMANIAK_V2}/${config2.productId}/openai/v1`,
137322
+ headers: {
137323
+ Authorization: `Bearer ${config2.apiKey}`
137324
+ }
137325
+ });
137326
+ return skilder.chatModel(modelName);
137327
+ }
137328
+ case "infomaniak": {
137329
+ if (!config2.apiKey) {
137330
+ throw new InvalidAPIKeyError(provider, slug);
137331
+ }
137332
+ if (!config2.productId) {
137333
+ throw new MissingProductIdError(provider, slug);
137334
+ }
137335
+ const infomaniakV2 = createOpenAICompatible({
137336
+ name: "infomaniak-v2",
137337
+ baseURL: `${AI_PROVIDER_API_URLS.INFOMANIAK_V2}/${config2.productId}/openai/v1`,
137338
+ headers: {
137339
+ Authorization: `Bearer ${config2.apiKey}`
137340
+ }
137341
+ });
137342
+ return infomaniakV2.chatModel(modelName);
137343
+ }
137344
+ case "infomaniak-v1":
137345
+ if (!config2.apiKey) {
137346
+ throw new InvalidAPIKeyError(provider, slug);
137347
+ }
137348
+ if (!config2.productId) {
137349
+ throw new MissingProductIdError(provider, slug);
137298
137350
  }
137299
137351
  return createInfomaniak({
137300
137352
  apiKey: config2.apiKey,
@@ -137316,8 +137368,8 @@ var AIProviderService = class AIProviderService2 {
137316
137368
  * Chat with a specific model (sync).
137317
137369
  * Accepts config directly - caller is responsible for providing decrypted config.
137318
137370
  */
137319
- async chat(config2, provider, modelName, message) {
137320
- const model = this.getProviderModel(provider, modelName, config2);
137371
+ async chat(config2, provider, modelName, message, slug) {
137372
+ const model = this.getProviderModel(provider, modelName, config2, slug);
137321
137373
  try {
137322
137374
  const result = await generateText({
137323
137375
  model,
@@ -137325,61 +137377,78 @@ var AIProviderService = class AIProviderService2 {
137325
137377
  });
137326
137378
  return result.text;
137327
137379
  } catch (error48) {
137328
- this.logger.error(`Failed to chat with model ${provider}/${modelName}: ${error48}`);
137329
- const errorMessage = error48 instanceof Error ? error48.message.toLowerCase() : String(error48).toLowerCase();
137330
- if (errorMessage.includes("unauthorized") || errorMessage.includes("invalid api key") || errorMessage.includes("authentication") || errorMessage.includes("401") || errorMessage.includes("403")) {
137331
- throw new InvalidAPIKeyError(provider);
137332
- }
137333
- if (errorMessage.includes("rate limit") || errorMessage.includes("429")) {
137334
- throw new RateLimitError(provider);
137335
- }
137336
- if (errorMessage.includes("token limit") || errorMessage.includes("context length") || errorMessage.includes("maximum context") || errorMessage.includes("too many tokens")) {
137337
- throw new TokenLimitError(provider);
137338
- }
137339
- if (errorMessage.includes("unprocessable") || errorMessage.includes("422") || errorMessage.includes("not supported") || errorMessage.includes("invalid model")) {
137340
- if (provider === "infomaniak") {
137341
- if (modelName.includes("/") && config2.apiVersion !== "v2") {
137342
- throw new ModelNotSupportedError(provider, modelName, "This model requires API v2. Please reconfigure Infomaniak with API version V2 to use beta models.");
137343
- }
137344
- throw new ModelNotSupportedError(provider, modelName, "Model does not support chat completions or may not be available yet.");
137380
+ this.classifyAndThrow(error48, provider, modelName, slug);
137381
+ }
137382
+ }
137383
+ /**
137384
+ * Classify a provider error into a typed AIProviderError subclass and throw it.
137385
+ * Prefers the SDK's structured HTTP status code over substring matching on the message
137386
+ * (matching bare numbers like "403" in the text misclassifies e.g. a model named
137387
+ * "gpt-403-turbo"). Always logs the error structurally — never interpolate the raw error
137388
+ * into the message, as SDK errors can embed the request and leak the API key.
137389
+ */
137390
+ classifyAndThrow(error48, provider, modelName, slug) {
137391
+ this.logger.error({ event: "ai_chat_failed", provider, model: modelName, err: error48 }, "Failed to chat with model");
137392
+ const statusCode = APICallError.isInstance(error48) ? error48.statusCode : void 0;
137393
+ const errorMessage = error48 instanceof Error ? error48.message.toLowerCase() : String(error48).toLowerCase();
137394
+ if (statusCode === 401 || statusCode === 403 || errorMessage.includes("unauthorized") || errorMessage.includes("invalid api key") || errorMessage.includes("authentication")) {
137395
+ throw new InvalidAPIKeyError(provider, slug);
137396
+ }
137397
+ if (statusCode === 429 || errorMessage.includes("rate limit")) {
137398
+ throw new RateLimitError(provider, void 0, slug);
137399
+ }
137400
+ if (errorMessage.includes("token limit") || errorMessage.includes("context length") || errorMessage.includes("maximum context") || errorMessage.includes("too many tokens")) {
137401
+ throw new TokenLimitError(provider, void 0, slug);
137402
+ }
137403
+ if (statusCode === 422 || errorMessage.includes("unprocessable") || errorMessage.includes("not supported") || errorMessage.includes("invalid model")) {
137404
+ if (provider === "infomaniak" || provider === "infomaniak-v1") {
137405
+ if (provider === "infomaniak-v1" && modelName.includes("/")) {
137406
+ throw new ModelNotSupportedError(provider, modelName, "This model requires the Infomaniak v2 (beta) endpoint. Please reconfigure using the Infomaniak (beta) provider to use beta models.", slug);
137345
137407
  }
137346
- throw new ModelNotSupportedError(provider, modelName, "Model does not support chat completions");
137347
- }
137348
- if (error48 instanceof Error) {
137349
- throw new AIProviderError(error48.message, provider);
137408
+ throw new ModelNotSupportedError(provider, modelName, "Model does not support chat completions or may not be available yet.", slug);
137350
137409
  }
137351
- throw error48;
137410
+ throw new ModelNotSupportedError(provider, modelName, "Model does not support chat completions", slug);
137352
137411
  }
137412
+ if (error48 instanceof Error) {
137413
+ throw new AIProviderError(error48.message, provider, slug);
137414
+ }
137415
+ throw error48;
137353
137416
  }
137354
137417
  /**
137355
137418
  * Stream chat with a specific model.
137356
137419
  * Accepts config directly - caller is responsible for providing decrypted config.
137357
137420
  */
137358
- async *stream(config2, provider, modelName, message) {
137359
- const model = this.getProviderModel(provider, modelName, config2);
137360
- const result = streamText({
137361
- model,
137362
- messages: [{ role: "user", content: message }]
137363
- });
137364
- for await (const chunk of result.textStream) {
137365
- yield chunk;
137421
+ async *stream(config2, provider, modelName, message, slug) {
137422
+ const model = this.getProviderModel(provider, modelName, config2, slug);
137423
+ try {
137424
+ const result = streamText({
137425
+ model,
137426
+ messages: [{ role: "user", content: message }]
137427
+ });
137428
+ for await (const chunk of result.textStream) {
137429
+ yield chunk;
137430
+ }
137431
+ } catch (error48) {
137432
+ this.classifyAndThrow(error48, provider, modelName, slug);
137366
137433
  }
137367
137434
  }
137368
137435
  /**
137369
137436
  * List available models from a provider via API call.
137370
137437
  * This makes external HTTP requests to the provider's API.
137371
137438
  */
137372
- async listProviderModels(provider, config2) {
137439
+ async listProviderModels(provider, config2, slug) {
137373
137440
  switch (provider) {
137374
- case "infomaniak": {
137441
+ case "skilder":
137442
+ case "infomaniak":
137443
+ case "infomaniak-v1": {
137375
137444
  if (!config2.apiKey) {
137376
- throw new InvalidAPIKeyError(provider);
137445
+ throw new InvalidAPIKeyError(provider, slug);
137377
137446
  }
137378
137447
  if (!config2.productId) {
137379
- throw new MissingProductIdError(provider);
137448
+ throw new MissingProductIdError(provider, slug);
137380
137449
  }
137381
137450
  try {
137382
- const isV2 = config2.apiVersion === "v2";
137451
+ const isV2 = provider === "infomaniak" || provider === "skilder";
137383
137452
  const modelsUrl = isV2 ? `${AI_PROVIDER_API_URLS.INFOMANIAK_V2}/${config2.productId}/openai/v1/models` : `${AI_PROVIDER_API_URLS.INFOMANIAK}/${config2.productId}/openai/models`;
137384
137453
  const res = await fetch(modelsUrl, {
137385
137454
  headers: {
@@ -137387,27 +137456,28 @@ var AIProviderService = class AIProviderService2 {
137387
137456
  }
137388
137457
  });
137389
137458
  if (res.status === 401 || res.status === 403) {
137390
- throw new InvalidAPIKeyError(provider);
137459
+ throw new InvalidAPIKeyError(provider, slug);
137391
137460
  }
137392
137461
  if (res.status === 429) {
137393
- throw new RateLimitError(provider);
137462
+ throw new RateLimitError(provider, void 0, slug);
137394
137463
  }
137395
137464
  if (!res.ok) {
137396
- throw new AIProviderError(`Infomaniak API error: ${await res.text()}`, provider);
137465
+ throw new AIProviderError(`Infomaniak API error: ${await res.text()}`, provider, slug);
137397
137466
  }
137398
137467
  const data = await res.json();
137399
137468
  const allModels = data.data.map((m2) => m2.id);
137400
- return isV2 ? allModels : allModels.filter((id) => !id.includes("/"));
137469
+ const namespaceFiltered = allModels.filter((id) => id.includes("/") === isV2);
137470
+ return processModels(provider, namespaceFiltered);
137401
137471
  } catch (error48) {
137402
137472
  if (error48 instanceof InvalidAPIKeyError || error48 instanceof MissingProductIdError || error48 instanceof RateLimitError || error48 instanceof AIProviderError) {
137403
137473
  throw error48;
137404
137474
  }
137405
- throw new AIProviderError(error48 instanceof Error ? error48.message : "Unknown error", provider);
137475
+ throw new AIProviderError(error48 instanceof Error ? error48.message : "Unknown error", provider, slug);
137406
137476
  }
137407
137477
  }
137408
137478
  case "openai": {
137409
137479
  if (!config2.apiKey) {
137410
- throw new InvalidAPIKeyError(provider);
137480
+ throw new InvalidAPIKeyError(provider, slug);
137411
137481
  }
137412
137482
  try {
137413
137483
  const res = await fetch(AI_PROVIDER_API_URLS.OPENAI, {
@@ -137416,13 +137486,13 @@ var AIProviderService = class AIProviderService2 {
137416
137486
  }
137417
137487
  });
137418
137488
  if (res.status === 401 || res.status === 403) {
137419
- throw new InvalidAPIKeyError(provider);
137489
+ throw new InvalidAPIKeyError(provider, slug);
137420
137490
  }
137421
137491
  if (res.status === 429) {
137422
- throw new RateLimitError(provider);
137492
+ throw new RateLimitError(provider, void 0, slug);
137423
137493
  }
137424
137494
  if (!res.ok) {
137425
- throw new AIProviderError(`OpenAI API error: ${await res.text()}`, provider);
137495
+ throw new AIProviderError(`OpenAI API error: ${await res.text()}`, provider, slug);
137426
137496
  }
137427
137497
  const data = await res.json();
137428
137498
  const TEXT_MODEL_PREFIXES = ["gpt-", "o1", "o3", "chatgpt"];
@@ -137432,12 +137502,12 @@ var AIProviderService = class AIProviderService2 {
137432
137502
  if (error48 instanceof InvalidAPIKeyError || error48 instanceof RateLimitError || error48 instanceof AIProviderError) {
137433
137503
  throw error48;
137434
137504
  }
137435
- throw new AIProviderError(error48 instanceof Error ? error48.message : "Unknown error", provider);
137505
+ throw new AIProviderError(error48 instanceof Error ? error48.message : "Unknown error", provider, slug);
137436
137506
  }
137437
137507
  }
137438
137508
  case "anthropic": {
137439
137509
  if (!config2.apiKey) {
137440
- throw new InvalidAPIKeyError(provider);
137510
+ throw new InvalidAPIKeyError(provider, slug);
137441
137511
  }
137442
137512
  try {
137443
137513
  const res = await fetch(AI_PROVIDER_API_URLS.ANTHROPIC, {
@@ -137447,13 +137517,13 @@ var AIProviderService = class AIProviderService2 {
137447
137517
  }
137448
137518
  });
137449
137519
  if (res.status === 401 || res.status === 403) {
137450
- throw new InvalidAPIKeyError(provider);
137520
+ throw new InvalidAPIKeyError(provider, slug);
137451
137521
  }
137452
137522
  if (res.status === 429) {
137453
- throw new RateLimitError(provider);
137523
+ throw new RateLimitError(provider, void 0, slug);
137454
137524
  }
137455
137525
  if (!res.ok) {
137456
- throw new AIProviderError(`Anthropic API error: ${await res.text()}`, provider);
137526
+ throw new AIProviderError(`Anthropic API error: ${await res.text()}`, provider, slug);
137457
137527
  }
137458
137528
  const data = await res.json();
137459
137529
  const models = data.data.map((m2) => m2.id);
@@ -137462,24 +137532,24 @@ var AIProviderService = class AIProviderService2 {
137462
137532
  if (error48 instanceof InvalidAPIKeyError || error48 instanceof RateLimitError || error48 instanceof AIProviderError) {
137463
137533
  throw error48;
137464
137534
  }
137465
- throw new AIProviderError(error48 instanceof Error ? error48.message : "Unknown error", provider);
137535
+ throw new AIProviderError(error48 instanceof Error ? error48.message : "Unknown error", provider, slug);
137466
137536
  }
137467
137537
  }
137468
137538
  case "google": {
137469
137539
  if (!config2.apiKey) {
137470
- throw new InvalidAPIKeyError(provider);
137540
+ throw new InvalidAPIKeyError(provider, slug);
137471
137541
  }
137472
137542
  try {
137473
137543
  const host = config2.baseUrl || AI_PROVIDER_API_URLS.GOOGLE;
137474
137544
  const res = await fetch(`${host}/models?key=${config2.apiKey}`);
137475
137545
  if (res.status === 401 || res.status === 403) {
137476
- throw new InvalidAPIKeyError(provider);
137546
+ throw new InvalidAPIKeyError(provider, slug);
137477
137547
  }
137478
137548
  if (res.status === 429) {
137479
- throw new RateLimitError(provider);
137549
+ throw new RateLimitError(provider, void 0, slug);
137480
137550
  }
137481
137551
  if (!res.ok) {
137482
- throw new AIProviderError(`Google Gemini API error: ${await res.text()}`, provider);
137552
+ throw new AIProviderError(`Google Gemini API error: ${await res.text()}`, provider, slug);
137483
137553
  }
137484
137554
  const data = await res.json();
137485
137555
  const models = data.models.map((m2) => m2.name).filter((m2) => m2.includes("gemini")).map((m2) => m2.replace("models/", ""));
@@ -137488,7 +137558,7 @@ var AIProviderService = class AIProviderService2 {
137488
137558
  if (error48 instanceof InvalidAPIKeyError || error48 instanceof RateLimitError || error48 instanceof AIProviderError) {
137489
137559
  throw error48;
137490
137560
  }
137491
- throw new AIProviderError(error48 instanceof Error ? error48.message : "Unknown error", provider);
137561
+ throw new AIProviderError(error48 instanceof Error ? error48.message : "Unknown error", provider, slug);
137492
137562
  }
137493
137563
  }
137494
137564
  case "ollama": {
@@ -137496,7 +137566,7 @@ var AIProviderService = class AIProviderService2 {
137496
137566
  const host = config2.baseUrl || DEFAULT_OLLAMA_BASE_URL;
137497
137567
  const res = await fetch(`${host}/tags`);
137498
137568
  if (!res.ok) {
137499
- throw new AIProviderError(`Ollama API error: ${await res.text()}`, provider);
137569
+ throw new AIProviderError(`Ollama API error: ${await res.text()}`, provider, slug);
137500
137570
  }
137501
137571
  const data = await res.json();
137502
137572
  return data.models.map((m2) => m2.name);
@@ -137504,7 +137574,7 @@ var AIProviderService = class AIProviderService2 {
137504
137574
  if (error48 instanceof AIProviderError) {
137505
137575
  throw error48;
137506
137576
  }
137507
- throw new AIProviderError(error48 instanceof Error ? error48.message : "Unknown error", provider);
137577
+ throw new AIProviderError(error48 instanceof Error ? error48.message : "Unknown error", provider, slug);
137508
137578
  }
137509
137579
  }
137510
137580
  default:
@@ -137512,25 +137582,14 @@ var AIProviderService = class AIProviderService2 {
137512
137582
  }
137513
137583
  }
137514
137584
  /**
137515
- * Parse model string format: "provider/model-name"
137585
+ * Parse model string format: "<slug>/<model-name>".
137586
+ *
137587
+ * The prefix is treated as an AIProviderConfig slug — for quick providers this happens to
137588
+ * equal the AIProviderType id (e.g. `openai`), but for custom providers it's an opaque
137589
+ * per-config slug (e.g. `custom-ab12cd34`). Resolve the live config via findBySlug.
137516
137590
  */
137517
137591
  parseModelString(modelString) {
137518
- const slashIndex = modelString.indexOf("/");
137519
- if (slashIndex === -1) {
137520
- throw new Error("Invalid model format. Model name cannot be empty");
137521
- }
137522
- const provider = modelString.substring(0, slashIndex);
137523
- const modelName = modelString.substring(slashIndex + 1);
137524
- if (!provider) {
137525
- throw new Error("Invalid model format. Provider cannot be empty");
137526
- }
137527
- if (!modelName) {
137528
- throw new Error("Invalid model format. Model name cannot be empty");
137529
- }
137530
- if (!VALID_PROVIDERS.includes(provider)) {
137531
- throw new Error(`Unknown provider: ${provider}`);
137532
- }
137533
- return { provider: provider.toLowerCase(), modelName };
137592
+ return parseModelString(modelString);
137534
137593
  }
137535
137594
  };
137536
137595
  AIProviderService = __decorate4([
@@ -137539,6 +137598,91 @@ AIProviderService = __decorate4([
137539
137598
  __metadata4("design:paramtypes", [typeof (_a25 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a25 : Object])
137540
137599
  ], AIProviderService);
137541
137600
 
137601
+ // ../common/src/services/ai/ai-providers.catalog.ts
137602
+ var AI_PROVIDERS_CATALOG = [
137603
+ {
137604
+ slug: "skilder",
137605
+ name: "Skilder",
137606
+ description: "Platform-managed AI provider \u2014 ready to use, no API key required. Pick the models you want to expose in this workspace.",
137607
+ logoSlug: "skilder",
137608
+ preferredModels: PREFERRED_MODEL_PATTERNS.skilder,
137609
+ apiHost: AI_PROVIDER_API_URLS.INFOMANIAK_V2,
137610
+ apiProviderType: "skilder",
137611
+ platformManaged: true,
137612
+ models: [
137613
+ {
137614
+ id: "mistralai/Mistral-Small-4-119B-2603",
137615
+ inputPricePerMTokens: 2,
137616
+ outputPricePerMTokens: 7
137617
+ },
137618
+ {
137619
+ id: "Qwen/Qwen3.5-122B-A10B-FP8",
137620
+ inputPricePerMTokens: 4,
137621
+ outputPricePerMTokens: 32
137622
+ },
137623
+ {
137624
+ id: "moonshotai/Kimi-K2.6",
137625
+ inputPricePerMTokens: 6,
137626
+ outputPricePerMTokens: 30
137627
+ }
137628
+ ]
137629
+ },
137630
+ {
137631
+ slug: "infomaniak",
137632
+ name: "Infomaniak AI",
137633
+ description: "Swiss-hosted AI via the openai v2 endpoint \u2014 includes Mistral-Small-4-119B, Qwen3.5-122B, Kimi-K2.6, and more.",
137634
+ logoSlug: "infomaniak",
137635
+ preferredModels: PREFERRED_MODEL_PATTERNS.infomaniak,
137636
+ apiHost: AI_PROVIDER_API_URLS.INFOMANIAK_V2,
137637
+ apiProviderType: "infomaniak"
137638
+ },
137639
+ {
137640
+ slug: "infomaniak-v1",
137641
+ name: "Infomaniak AI (v1)",
137642
+ description: "Swiss-hosted AI via the v1 endpoint \u2014 older models.",
137643
+ logoSlug: "infomaniak",
137644
+ preferredModels: PREFERRED_MODEL_PATTERNS["infomaniak-v1"],
137645
+ apiHost: AI_PROVIDER_API_URLS.INFOMANIAK,
137646
+ apiProviderType: "infomaniak-v1"
137647
+ },
137648
+ {
137649
+ slug: "openai",
137650
+ name: "OpenAI",
137651
+ description: "GPT-5 and GPT-4 family models from OpenAI.",
137652
+ logoSlug: "openai",
137653
+ preferredModels: PREFERRED_MODEL_PATTERNS.openai,
137654
+ apiHost: AI_PROVIDER_API_URLS.OPENAI,
137655
+ apiProviderType: "openai"
137656
+ },
137657
+ {
137658
+ slug: "anthropic",
137659
+ name: "Anthropic",
137660
+ description: "Claude models from Anthropic.",
137661
+ logoSlug: "anthropic",
137662
+ preferredModels: PREFERRED_MODEL_PATTERNS.anthropic,
137663
+ apiHost: AI_PROVIDER_API_URLS.ANTHROPIC,
137664
+ apiProviderType: "anthropic"
137665
+ },
137666
+ {
137667
+ slug: "google",
137668
+ name: "Google Gemini",
137669
+ description: "Gemini models from Google.",
137670
+ logoSlug: "google",
137671
+ preferredModels: PREFERRED_MODEL_PATTERNS.google,
137672
+ apiHost: AI_PROVIDER_API_URLS.GOOGLE,
137673
+ apiProviderType: "google"
137674
+ },
137675
+ {
137676
+ slug: "ollama",
137677
+ name: "Ollama",
137678
+ description: "Local models running via an Ollama server on your network.",
137679
+ logoSlug: "ollama",
137680
+ preferredModels: PREFERRED_MODEL_PATTERNS.ollama,
137681
+ apiHost: DEFAULT_OLLAMA_BASE_URL,
137682
+ apiProviderType: "ollama"
137683
+ }
137684
+ ];
137685
+
137542
137686
  // ../common/src/services/cache/cache.constants.ts
137543
137687
  var CACHE_BUCKETS = {
137544
137688
  HEARTBEAT: "heartbeat",
@@ -137546,6 +137690,7 @@ var CACHE_BUCKETS = {
137546
137690
  OAUTH_NONCE: "oauth-nonce",
137547
137691
  OAUTH_INITIATION: "oauth-initiation",
137548
137692
  OAUTH_TRANSFER: "oauth-transfer",
137693
+ OAUTH_SIGNIN_OTC: "oauth-signin-otc",
137549
137694
  RATE_LIMIT_KEY: "rate-limit-key",
137550
137695
  RATE_LIMIT_IP: "rate-limit-ip",
137551
137696
  FASTIFY_RATE_LIMIT: "fastify-rate-limit",
@@ -137562,6 +137707,8 @@ var CACHE_BUCKET_TTLS = {
137562
137707
  // 5 minutes
137563
137708
  OAUTH_TRANSFER: 2 * 60 * 60 * 1e3,
137564
137709
  // 2 hours — holds extracted OAuth data between extract and recreate
137710
+ OAUTH_SIGNIN_OTC: 5 * 60 * 1e3,
137711
+ // 5 minutes — single-use sign-in code exchanged for JWT tokens
137565
137712
  RATE_LIMIT_KEY: 15 * 60 * 1e3,
137566
137713
  // 15 minutes
137567
137714
  RATE_LIMIT_IP: 60 * 60 * 1e3,
@@ -137590,6 +137737,10 @@ function createCacheServiceConfig() {
137590
137737
  name: CACHE_BUCKETS.OAUTH_TRANSFER,
137591
137738
  ttlMs: parseTTL("OAUTH_TRANSFER_CACHE_TTL", CACHE_BUCKET_TTLS.OAUTH_TRANSFER)
137592
137739
  },
137740
+ {
137741
+ name: CACHE_BUCKETS.OAUTH_SIGNIN_OTC,
137742
+ ttlMs: parseTTL("OAUTH_SIGNIN_OTC_CACHE_TTL", CACHE_BUCKET_TTLS.OAUTH_SIGNIN_OTC)
137743
+ },
137593
137744
  {
137594
137745
  name: CACHE_BUCKETS.RATE_LIMIT_KEY,
137595
137746
  ttlMs: parseTTL("RATE_LIMIT_KEY_CACHE_TTL", CACHE_BUCKET_TTLS.RATE_LIMIT_KEY)
@@ -137627,7 +137778,7 @@ var __param4 = function(paramIndex, decorator) {
137627
137778
  };
137628
137779
  var _a26;
137629
137780
  var _b19;
137630
- var NatsCacheService = class NatsCacheService2 extends Service {
137781
+ var NatsCacheService = class NatsCacheService2 extends LifecycleService {
137631
137782
  constructor(loggerService, natsService, config2) {
137632
137783
  super();
137633
137784
  this.loggerService = loggerService;
@@ -138372,7 +138523,7 @@ var DelegateAIConfigResponse = class extends NatsResponse {
138372
138523
  this.type = type20;
138373
138524
  }
138374
138525
  validate(data) {
138375
- return !!(data.providerConfig && data.defaultModel && data.defaultModel.includes("/"));
138526
+ return !!(data.providerConfig && data.provider && data.defaultModel && data.defaultModel.includes("/"));
138376
138527
  }
138377
138528
  };
138378
138529
  NatsMessage.register(DelegateAIConfigResponse);
@@ -138407,7 +138558,6 @@ __export(dgraph_resolvers_types_exports, {
138407
138558
  ActiveStatus: () => ActiveStatus,
138408
138559
  AiProviderType: () => AiProviderType,
138409
138560
  HatColor: () => HatColor,
138410
- InfomaniakApiVersion: () => InfomaniakApiVersion,
138411
138561
  InvitationStatus: () => InvitationStatus,
138412
138562
  McpServerStatus: () => McpServerStatus,
138413
138563
  McpTransportType: () => McpTransportType,
@@ -138417,6 +138567,7 @@ __export(dgraph_resolvers_types_exports, {
138417
138567
  OAuthProviderType: () => OAuthProviderType,
138418
138568
  OnboardingStepStatus: () => OnboardingStepStatus,
138419
138569
  OnboardingStepType: () => OnboardingStepType,
138570
+ PublishStatus: () => PublishStatus,
138420
138571
  ScriptType: () => ScriptType,
138421
138572
  ToolCallStatus: () => ToolCallStatus,
138422
138573
  WorkspaceRole: () => WorkspaceRole
@@ -138425,8 +138576,10 @@ var AiProviderType = /* @__PURE__ */ ((AiProviderType2) => {
138425
138576
  AiProviderType2["Anthropic"] = "ANTHROPIC";
138426
138577
  AiProviderType2["Google"] = "GOOGLE";
138427
138578
  AiProviderType2["Infomaniak"] = "INFOMANIAK";
138579
+ AiProviderType2["InfomaniakV1"] = "INFOMANIAK_V1";
138428
138580
  AiProviderType2["Ollama"] = "OLLAMA";
138429
138581
  AiProviderType2["Openai"] = "OPENAI";
138582
+ AiProviderType2["Skilder"] = "SKILDER";
138430
138583
  return AiProviderType2;
138431
138584
  })(AiProviderType || {});
138432
138585
  var ActiveStatus = /* @__PURE__ */ ((ActiveStatus2) => {
@@ -138445,11 +138598,6 @@ var HatColor = /* @__PURE__ */ ((HatColor2) => {
138445
138598
  HatColor2["Yellow"] = "YELLOW";
138446
138599
  return HatColor2;
138447
138600
  })(HatColor || {});
138448
- var InfomaniakApiVersion = /* @__PURE__ */ ((InfomaniakApiVersion2) => {
138449
- InfomaniakApiVersion2["V1"] = "V1";
138450
- InfomaniakApiVersion2["V2"] = "V2";
138451
- return InfomaniakApiVersion2;
138452
- })(InfomaniakApiVersion || {});
138453
138601
  var InvitationStatus = /* @__PURE__ */ ((InvitationStatus2) => {
138454
138602
  InvitationStatus2["Accepted"] = "ACCEPTED";
138455
138603
  InvitationStatus2["DeclinedByUser"] = "DECLINED_BY_USER";
@@ -138495,7 +138643,10 @@ var OAuthConnectionStatus = /* @__PURE__ */ ((OAuthConnectionStatus2) => {
138495
138643
  return OAuthConnectionStatus2;
138496
138644
  })(OAuthConnectionStatus || {});
138497
138645
  var OAuthProviderType = /* @__PURE__ */ ((OAuthProviderType2) => {
138646
+ OAuthProviderType2["Github"] = "GITHUB";
138647
+ OAuthProviderType2["GithubSignin"] = "GITHUB_SIGNIN";
138498
138648
  OAuthProviderType2["Google"] = "GOOGLE";
138649
+ OAuthProviderType2["GoogleSignin"] = "GOOGLE_SIGNIN";
138499
138650
  OAuthProviderType2["McpOauth"] = "MCP_OAUTH";
138500
138651
  OAuthProviderType2["Microsoft"] = "MICROSOFT";
138501
138652
  OAuthProviderType2["Zoho"] = "ZOHO";
@@ -138513,6 +138664,11 @@ var OnboardingStepType = /* @__PURE__ */ ((OnboardingStepType2) => {
138513
138664
  OnboardingStepType2["Onboarding"] = "ONBOARDING";
138514
138665
  return OnboardingStepType2;
138515
138666
  })(OnboardingStepType || {});
138667
+ var PublishStatus = /* @__PURE__ */ ((PublishStatus2) => {
138668
+ PublishStatus2["Draft"] = "DRAFT";
138669
+ PublishStatus2["Published"] = "PUBLISHED";
138670
+ return PublishStatus2;
138671
+ })(PublishStatus || {});
138516
138672
  var ScriptType = /* @__PURE__ */ ((ScriptType3) => {
138517
138673
  ScriptType3["Bash"] = "BASH";
138518
138674
  ScriptType3["Javascript"] = "JAVASCRIPT";
@@ -138560,6 +138716,30 @@ function parseScriptArgs(argsString) {
138560
138716
  return args;
138561
138717
  }
138562
138718
 
138719
+ // ../common/src/utils/debug-utils.ts
138720
+ var MAX_DEBUG_SIZE = 5e4;
138721
+ function truncateDebug(consoleOutput) {
138722
+ if (!consoleOutput) return void 0;
138723
+ if (consoleOutput.length <= MAX_DEBUG_SIZE) return consoleOutput;
138724
+ return consoleOutput.slice(0, MAX_DEBUG_SIZE) + `
138725
+ ... [truncated, ${consoleOutput.length} chars total]`;
138726
+ }
138727
+
138728
+ // ../../node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/_lib/tzTokenizeDate/index.js
138729
+ var testDateFormatted = new Intl.DateTimeFormat("en-US", {
138730
+ hourCycle: "h23",
138731
+ timeZone: "America/New_York",
138732
+ year: "numeric",
138733
+ month: "2-digit",
138734
+ day: "2-digit",
138735
+ hour: "2-digit",
138736
+ minute: "2-digit",
138737
+ second: "2-digit"
138738
+ }).format(/* @__PURE__ */ new Date("2014-06-25T04:00:00.123Z"));
138739
+
138740
+ // ../../node_modules/.pnpm/date-fns-tz@3.2.0_date-fns@4.1.0/node_modules/date-fns-tz/dist/esm/format/formatters/index.js
138741
+ var MILLISECONDS_IN_MINUTE = 60 * 1e3;
138742
+
138563
138743
  // ../common/src/related-content-detector.ts
138564
138744
  function escapeRegex2(str) {
138565
138745
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -138702,7 +138882,7 @@ var _a27;
138702
138882
  var _b20;
138703
138883
  var PermanentAuthenticationError = class extends Error {
138704
138884
  };
138705
- var AuthService = class AuthService2 extends Service {
138885
+ var AuthService = class AuthService2 extends LifecycleService {
138706
138886
  constructor(loggerService, natsService) {
138707
138887
  super();
138708
138888
  this.loggerService = loggerService;
@@ -138866,7 +139046,7 @@ var _c;
138866
139046
  var _d;
138867
139047
  var HEARTBEAT_INTERVAL = "heartbeat.interval";
138868
139048
  var SLEEP_DETECTION_MULTIPLIER = 3;
138869
- var HealthService = class HealthService2 extends Service {
139049
+ var HealthService = class HealthService2 extends LifecycleService {
138870
139050
  constructor(loggerService, natsService, cacheService, authService) {
138871
139051
  super();
138872
139052
  this.loggerService = loggerService;
@@ -143774,7 +143954,7 @@ var AssetTruncatedError = class extends Error {
143774
143954
  this.name = "AssetTruncatedError";
143775
143955
  }
143776
143956
  };
143777
- var FileService = class FileService2 extends Service {
143957
+ var FileService = class FileService2 extends LifecycleService {
143778
143958
  constructor(loggerService) {
143779
143959
  super();
143780
143960
  this.name = "file";
@@ -144068,7 +144248,7 @@ var DelegateService = class DelegateService2 {
144068
144248
  };
144069
144249
  }
144070
144250
  try {
144071
- const configRequest = DelegateAIConfigRequest.create({ workspaceId });
144251
+ const configRequest = DelegateAIConfigRequest.create({ workspaceId, model: modelOverride });
144072
144252
  const configResponse = await this.natsService.request(configRequest, { timeout: 1e4 });
144073
144253
  if (configResponse instanceof ErrorResponse) {
144074
144254
  return { isError: true, content: [{ type: "text", text: `Error: ${configResponse.data.error}` }] };
@@ -144076,10 +144256,10 @@ var DelegateService = class DelegateService2 {
144076
144256
  if (!(configResponse instanceof DelegateAIConfigResponse)) {
144077
144257
  return { isError: true, content: [{ type: "text", text: "Error: Invalid AI config response from backend" }] };
144078
144258
  }
144079
- const { providerConfig, defaultModel } = configResponse.data;
144259
+ const { providerConfig, provider, defaultModel } = configResponse.data;
144080
144260
  const modelString = modelOverride || defaultModel;
144081
- const { provider, modelName } = this.aiProviderService.parseModelString(modelString);
144082
- const model = this.aiProviderService.getProviderModel(provider, modelName, providerConfig);
144261
+ const { slug, modelName } = this.aiProviderService.parseModelString(modelString);
144262
+ const model = this.aiProviderService.getProviderModel(provider, modelName, providerConfig, slug);
144083
144263
  const runtimeUrl = process.env.RUNTIME_MCP_URL || "http://localhost:3001/mcp";
144084
144264
  if (!process.env.RUNTIME_MCP_URL) {
144085
144265
  this.logger.warn({ runtimeUrl, event: "delegate_mcp_url_fallback" }, "RUNTIME_MCP_URL not set, falling back to default");
@@ -144530,7 +144710,9 @@ For other resources, use the \`learn\` tool instead.`
144530
144710
  const textContent = result.content.filter((c3) => c3.type === "text").map((c3) => ({ type: "text", text: c3.text }));
144531
144711
  return {
144532
144712
  content: textContent.length > 0 ? textContent : [{ type: "text", text: "(No text output)" }],
144533
- skillIds: [skill.id]
144713
+ isError: result.isError,
144714
+ skillIds: [skill.id],
144715
+ debug: response.data.debug ?? void 0
144534
144716
  };
144535
144717
  }
144536
144718
  return {
@@ -145019,7 +145201,7 @@ async function handleExecuteScript(args, ctx) {
145019
145201
  };
145020
145202
  }
145021
145203
  const path4 = args.path;
145022
- const { content, isError, skillIds } = await ctx.scriptService.execute({
145204
+ const { content, isError, skillIds, debug } = await ctx.scriptService.execute({
145023
145205
  path: path4 ?? "",
145024
145206
  workspaceId: ctx.identity.workspaceId,
145025
145207
  userId: ctx.identity.id,
@@ -145027,7 +145209,7 @@ async function handleExecuteScript(args, ctx) {
145027
145209
  runtimeExecutionId: ctx.identity.runtimeExecutionId,
145028
145210
  delegateDepth: ctx.identity.delegateDepth
145029
145211
  });
145030
- return { response: { content, isError }, skillIds };
145212
+ return { response: { content, isError }, skillIds, ...debug ? { debug } : {} };
145031
145213
  }
145032
145214
 
145033
145215
  // src/services/static-tools/feedback-skill.handler.ts
@@ -145563,7 +145745,7 @@ function buildSkillToolMap(catalog) {
145563
145745
  }
145564
145746
  return map3;
145565
145747
  }
145566
- var SkillService = class SkillService2 extends Service {
145748
+ var SkillService = class SkillService2 extends LifecycleService {
145567
145749
  constructor(loggerService, natsService, cacheService, identity, scriptService, delegateService, fileService, skillContentService, staticToolRegistry, runtimeCatalogService) {
145568
145750
  super();
145569
145751
  this.loggerService = loggerService;
@@ -145966,7 +146148,7 @@ The path must point to a downloadable (binary) resource in a skill's related ite
145966
146148
  }
145967
146149
  if (toolConfig.__routing.type === "static") {
145968
146150
  this.logger.debug(`Handling static tool ${toolConfig.__routing.toolName} for user ${this.identity.id}`);
145969
- const { response, skillIds } = await this.handleStaticTool(toolConfig.__routing.toolName, args);
146151
+ const { response, skillIds, debug } = await this.handleStaticTool(toolConfig.__routing.toolName, args);
145970
146152
  const isWrapperTool = toolConfig.__routing.toolName === "call_tool";
145971
146153
  if (toolConfig.__routing.workspaceId && !isWrapperTool) {
145972
146154
  try {
@@ -145978,7 +146160,8 @@ The path must point to a downloadable (binary) resource in a skill's related ite
145978
146160
  userId: this.identity.id,
145979
146161
  arguments: args,
145980
146162
  response,
145981
- skillIds
146163
+ skillIds,
146164
+ ...debug ? { debug } : {}
145982
146165
  });
145983
146166
  this.logger.info(`Publishing static tool call ${toolConfig.__routing.toolName} to subject: ${message.getSubject()}`);
145984
146167
  this.natsService.publish(message);
@@ -146097,7 +146280,7 @@ var _c5;
146097
146280
  var _d3;
146098
146281
  var _e3;
146099
146282
  var _g2;
146100
- var McpStdioService = class McpStdioService2 extends Service {
146283
+ var McpStdioService = class McpStdioService2 extends LifecycleService {
146101
146284
  constructor(loggerService, natsService, cacheService, healthService, authService, runtimeExecutionId, fileService, scriptService, delegateService, skillContentService, staticToolRegistry, runtimeCatalogService) {
146102
146285
  super();
146103
146286
  this.loggerService = loggerService;
@@ -146304,10 +146487,15 @@ var __param13 = function(paramIndex, decorator) {
146304
146487
  };
146305
146488
  };
146306
146489
  var _a38;
146307
- var FastifyManagerService = class FastifyManagerService2 extends Service {
146308
- constructor(loggerService) {
146490
+ var _b29;
146491
+ var _c6;
146492
+ var HEALTH_NATS_PROBE_TIMEOUT_MS = 2e3;
146493
+ var FastifyManagerService = class FastifyManagerService2 extends LifecycleService {
146494
+ constructor(loggerService, natsService, authService) {
146309
146495
  super();
146310
146496
  this.loggerService = loggerService;
146497
+ this.natsService = natsService;
146498
+ this.authService = authService;
146311
146499
  this.name = "fastify.manager";
146312
146500
  this.isListening = false;
146313
146501
  this.logger = this.loggerService.getLogger(this.name);
@@ -146398,8 +146586,27 @@ var FastifyManagerService = class FastifyManagerService2 extends Service {
146398
146586
  "Last-Event-ID"
146399
146587
  ]
146400
146588
  });
146401
- this.fastifyInstance.get("/health", (req, res) => {
146402
- res.send({ status: "ok" });
146589
+ this.fastifyInstance.get("/health", async (_req, res) => {
146590
+ try {
146591
+ if (!this.natsService.isConnected()) {
146592
+ this.logger.error({ event: "health_check_failed", reason: "nats_disconnected" }, "Health check failed: NATS not connected");
146593
+ return res.status(503).send({ status: "error", message: "NATS is not connected" });
146594
+ }
146595
+ if (!this.authService.getIdentity()) {
146596
+ this.logger.error({ event: "health_check_failed", reason: "not_authenticated" }, "Health check failed: not authenticated");
146597
+ return res.status(503).send({ status: "error", message: "Not authenticated" });
146598
+ }
146599
+ try {
146600
+ await this.natsService.flush(HEALTH_NATS_PROBE_TIMEOUT_MS);
146601
+ } catch (err) {
146602
+ this.logger.error({ event: "health_check_failed", reason: "nats_unreachable", err }, "Health check failed: NATS flush failed");
146603
+ return res.status(503).send({ status: "error", message: "NATS is not reachable" });
146604
+ }
146605
+ return res.status(200).send({ status: "ok" });
146606
+ } catch (error48) {
146607
+ this.logger.error({ event: "health_check_failed", err: error48 }, "Health check failed: unexpected error");
146608
+ return res.status(503).send({ status: "error", message: "Service unhealthy" });
146609
+ }
146403
146610
  });
146404
146611
  this.logger.info("Fastify instance configured (not listening yet)");
146405
146612
  }
@@ -146407,7 +146614,9 @@ var FastifyManagerService = class FastifyManagerService2 extends Service {
146407
146614
  FastifyManagerService = __decorate16([
146408
146615
  W(),
146409
146616
  __param13(0, U(LoggerService)),
146410
- __metadata15("design:paramtypes", [typeof (_a38 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a38 : Object])
146617
+ __param13(1, U(NatsService)),
146618
+ __param13(2, U(AuthService)),
146619
+ __metadata15("design:paramtypes", [typeof (_a38 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a38 : Object, typeof (_b29 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b29 : Object, typeof (_c6 = typeof AuthService !== "undefined" && AuthService) === "function" ? _c6 : Object])
146411
146620
  ], FastifyManagerService);
146412
146621
 
146413
146622
  // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
@@ -147895,12 +148104,12 @@ var __param14 = function(paramIndex, decorator) {
147895
148104
  };
147896
148105
  };
147897
148106
  var _a39;
147898
- var _b29;
147899
- var _c6;
148107
+ var _b30;
148108
+ var _c7;
147900
148109
  var _d4;
147901
148110
  var _e4;
147902
148111
  var _g3;
147903
- var McpSseService = class McpSseService2 extends Service {
148112
+ var McpSseService = class McpSseService2 extends LifecycleService {
147904
148113
  constructor(loggerService, natsService, cacheService, healthService, fastifyManager, runtimeExecutionId, fileService, scriptService, delegateService, skillContentService, staticToolRegistry, runtimeCatalogService) {
147905
148114
  super();
147906
148115
  this.loggerService = loggerService;
@@ -148039,7 +148248,7 @@ McpSseService = __decorate17([
148039
148248
  __param14(10, se()),
148040
148249
  __param14(11, U(RuntimeCatalogService)),
148041
148250
  __param14(11, se()),
148042
- __metadata16("design:paramtypes", [typeof (_a39 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a39 : Object, typeof (_b29 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b29 : Object, typeof (_c6 = typeof NatsCacheService !== "undefined" && NatsCacheService) === "function" ? _c6 : Object, typeof (_d4 = typeof HealthService !== "undefined" && HealthService) === "function" ? _d4 : Object, typeof (_e4 = typeof FastifyManagerService !== "undefined" && FastifyManagerService) === "function" ? _e4 : Object, String, Object, typeof (_g3 = typeof ScriptService !== "undefined" && ScriptService) === "function" ? _g3 : Object, Object, Object, Object, Object])
148251
+ __metadata16("design:paramtypes", [typeof (_a39 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a39 : Object, typeof (_b30 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b30 : Object, typeof (_c7 = typeof NatsCacheService !== "undefined" && NatsCacheService) === "function" ? _c7 : Object, typeof (_d4 = typeof HealthService !== "undefined" && HealthService) === "function" ? _d4 : Object, typeof (_e4 = typeof FastifyManagerService !== "undefined" && FastifyManagerService) === "function" ? _e4 : Object, String, Object, typeof (_g3 = typeof ScriptService !== "undefined" && ScriptService) === "function" ? _g3 : Object, Object, Object, Object, Object])
148043
148252
  ], McpSseService);
148044
148253
 
148045
148254
  // ../../node_modules/.pnpm/@hono+node-server@1.19.10_hono@4.12.4/node_modules/@hono/node-server/dist/index.mjs
@@ -149295,12 +149504,12 @@ var __param15 = function(paramIndex, decorator) {
149295
149504
  };
149296
149505
  };
149297
149506
  var _a40;
149298
- var _b30;
149299
- var _c7;
149507
+ var _b31;
149508
+ var _c8;
149300
149509
  var _d5;
149301
149510
  var _e5;
149302
149511
  var _g4;
149303
- var McpStreamableService = class McpStreamableService2 extends Service {
149512
+ var McpStreamableService = class McpStreamableService2 extends LifecycleService {
149304
149513
  constructor(loggerService, natsService, cacheService, healthService, fastifyManager, runtimeExecutionId, fileService, scriptService, delegateService, skillContentService, staticToolRegistry, runtimeCatalogService) {
149305
149514
  super();
149306
149515
  this.loggerService = loggerService;
@@ -149634,7 +149843,7 @@ McpStreamableService = __decorate18([
149634
149843
  __param15(10, se()),
149635
149844
  __param15(11, U(RuntimeCatalogService)),
149636
149845
  __param15(11, se()),
149637
- __metadata17("design:paramtypes", [typeof (_a40 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a40 : Object, typeof (_b30 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b30 : Object, typeof (_c7 = typeof NatsCacheService !== "undefined" && NatsCacheService) === "function" ? _c7 : Object, typeof (_d5 = typeof HealthService !== "undefined" && HealthService) === "function" ? _d5 : Object, typeof (_e5 = typeof FastifyManagerService !== "undefined" && FastifyManagerService) === "function" ? _e5 : Object, String, Object, typeof (_g4 = typeof ScriptService !== "undefined" && ScriptService) === "function" ? _g4 : Object, Object, Object, Object, Object])
149846
+ __metadata17("design:paramtypes", [typeof (_a40 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a40 : Object, typeof (_b31 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b31 : Object, typeof (_c8 = typeof NatsCacheService !== "undefined" && NatsCacheService) === "function" ? _c8 : Object, typeof (_d5 = typeof HealthService !== "undefined" && HealthService) === "function" ? _d5 : Object, typeof (_e5 = typeof FastifyManagerService !== "undefined" && FastifyManagerService) === "function" ? _e5 : Object, String, Object, typeof (_g4 = typeof ScriptService !== "undefined" && ScriptService) === "function" ? _g4 : Object, Object, Object, Object, Object])
149638
149847
  ], McpStreamableService);
149639
149848
 
149640
149849
  // src/services/script-executor.service.ts
@@ -149831,7 +150040,7 @@ var __param16 = function(paramIndex, decorator) {
149831
150040
  };
149832
150041
  };
149833
150042
  var _a41;
149834
- var _b31;
150043
+ var _b33;
149835
150044
  var ScriptType2 = dgraph_resolvers_types_exports.ScriptType;
149836
150045
  var ScriptExecutorService = class ScriptExecutorService2 {
149837
150046
  constructor(loggerService, fileService) {
@@ -150240,7 +150449,7 @@ ScriptExecutorService = __decorate19([
150240
150449
  W(),
150241
150450
  __param16(0, U(LoggerService)),
150242
150451
  __param16(1, U(FileService)),
150243
- __metadata18("design:paramtypes", [typeof (_a41 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a41 : Object, typeof (_b31 = typeof FileService !== "undefined" && FileService) === "function" ? _b31 : Object])
150452
+ __metadata18("design:paramtypes", [typeof (_a41 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a41 : Object, typeof (_b33 = typeof FileService !== "undefined" && FileService) === "function" ? _b33 : Object])
150244
150453
  ], ScriptExecutorService);
150245
150454
 
150246
150455
  // src/services/tool.service.ts
@@ -152152,8 +152361,8 @@ var ErrorEvent = class extends Event {
152152
152361
  * @param errorEventInitDict - Optional properties to include in the error event
152153
152362
  */
152154
152363
  constructor(type22, errorEventInitDict) {
152155
- var _a51, _b40;
152156
- super(type22), this.code = (_a51 = errorEventInitDict == null ? void 0 : errorEventInitDict.code) != null ? _a51 : void 0, this.message = (_b40 = errorEventInitDict == null ? void 0 : errorEventInitDict.message) != null ? _b40 : void 0;
152364
+ var _a51, _b41;
152365
+ super(type22), this.code = (_a51 = errorEventInitDict == null ? void 0 : errorEventInitDict.code) != null ? _a51 : void 0, this.message = (_b41 = errorEventInitDict == null ? void 0 : errorEventInitDict.message) != null ? _b41 : void 0;
152157
152366
  }
152158
152367
  /**
152159
152368
  * Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
@@ -152235,7 +152444,7 @@ var scheduleReconnect_fn;
152235
152444
  var _reconnect;
152236
152445
  var EventSource = class extends EventTarget {
152237
152446
  constructor(url2, eventSourceInitDict) {
152238
- var _a51, _b40;
152447
+ var _a51, _b41;
152239
152448
  super(), __privateAdd(this, _EventSource_instances), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, __privateAdd(this, _readyState), __privateAdd(this, _url2), __privateAdd(this, _redirectUrl), __privateAdd(this, _withCredentials), __privateAdd(this, _fetch), __privateAdd(this, _reconnectInterval), __privateAdd(this, _reconnectTimer), __privateAdd(this, _lastEventId, null), __privateAdd(this, _controller), __privateAdd(this, _parser), __privateAdd(this, _onError, null), __privateAdd(this, _onMessage, null), __privateAdd(this, _onOpen, null), __privateAdd(this, _onFetchResponse, async (response) => {
152240
152449
  var _a210;
152241
152450
  __privateGet(this, _parser).reset();
@@ -152294,7 +152503,7 @@ var EventSource = class extends EventTarget {
152294
152503
  __privateSet(this, _parser, createParser({
152295
152504
  onEvent: __privateGet(this, _onEvent),
152296
152505
  onRetry: __privateGet(this, _onRetryChange)
152297
- })), __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _reconnectInterval, 3e3), __privateSet(this, _fetch, (_a51 = eventSourceInitDict == null ? void 0 : eventSourceInitDict.fetch) != null ? _a51 : globalThis.fetch), __privateSet(this, _withCredentials, (_b40 = eventSourceInitDict == null ? void 0 : eventSourceInitDict.withCredentials) != null ? _b40 : false), __privateMethod(this, _EventSource_instances, connect_fn).call(this);
152506
+ })), __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _reconnectInterval, 3e3), __privateSet(this, _fetch, (_a51 = eventSourceInitDict == null ? void 0 : eventSourceInitDict.fetch) != null ? _a51 : globalThis.fetch), __privateSet(this, _withCredentials, (_b41 = eventSourceInitDict == null ? void 0 : eventSourceInitDict.withCredentials) != null ? _b41 : false), __privateMethod(this, _EventSource_instances, connect_fn).call(this);
152298
152507
  }
152299
152508
  /**
152300
152509
  * Returns the state of this EventSource object's connection. It can have the values described below.
@@ -152642,9 +152851,9 @@ var __metadata19 = function(k3, v2) {
152642
152851
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k3, v2);
152643
152852
  };
152644
152853
  var _a44;
152645
- var _b33;
152646
- var _c8;
152647
- var ToolServerService = class ToolServerService2 extends Service {
152854
+ var _b34;
152855
+ var _c9;
152856
+ var ToolServerService = class ToolServerService2 extends LifecycleService {
152648
152857
  constructor(logger, config2, roots = [], additionalEnv = {}, authProvider) {
152649
152858
  super();
152650
152859
  this.logger = logger;
@@ -152859,7 +153068,7 @@ var ToolServerService = class ToolServerService2 extends Service {
152859
153068
  };
152860
153069
  ToolServerService = __decorate20([
152861
153070
  W(),
152862
- __metadata19("design:paramtypes", [typeof (_a44 = typeof import_pino2.default !== "undefined" && import_pino2.default.Logger) === "function" ? _a44 : Object, typeof (_b33 = typeof dgraph_resolvers_types_exports !== "undefined" && dgraph_resolvers_types_exports.McpServer) === "function" ? _b33 : Object, Array, typeof (_c8 = typeof Record !== "undefined" && Record) === "function" ? _c8 : Object, Object])
153071
+ __metadata19("design:paramtypes", [typeof (_a44 = typeof import_pino2.default !== "undefined" && import_pino2.default.Logger) === "function" ? _a44 : Object, typeof (_b34 = typeof dgraph_resolvers_types_exports !== "undefined" && dgraph_resolvers_types_exports.McpServer) === "function" ? _b34 : Object, Array, typeof (_c9 = typeof Record !== "undefined" && Record) === "function" ? _c9 : Object, Object])
152863
153072
  ], ToolServerService);
152864
153073
  var getConfigSignature = (config2, roots) => {
152865
153074
  return `${config2.transport}-${config2.config}-${roots.length}`;
@@ -152881,7 +153090,7 @@ var __param17 = function(paramIndex, decorator) {
152881
153090
  };
152882
153091
  };
152883
153092
  var _a45;
152884
- var _b34;
153093
+ var _b35;
152885
153094
  var OAuthTokenService = class OAuthTokenService2 {
152886
153095
  constructor(loggerService, natsService) {
152887
153096
  this.loggerService = loggerService;
@@ -152964,7 +153173,7 @@ OAuthTokenService = __decorate21([
152964
153173
  W(),
152965
153174
  __param17(0, U(LoggerService)),
152966
153175
  __param17(1, U(NatsService)),
152967
- __metadata20("design:paramtypes", [typeof (_a45 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a45 : Object, typeof (_b34 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b34 : Object])
153176
+ __metadata20("design:paramtypes", [typeof (_a45 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a45 : Object, typeof (_b35 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b35 : Object])
152968
153177
  ], OAuthTokenService);
152969
153178
 
152970
153179
  // src/services/oauth-client-info.service.ts
@@ -152983,7 +153192,7 @@ var __param18 = function(paramIndex, decorator) {
152983
153192
  };
152984
153193
  };
152985
153194
  var _a46;
152986
- var _b35;
153195
+ var _b36;
152987
153196
  var CACHE_TTL_MS = 10 * 60 * 1e3;
152988
153197
  var CACHE_MAX_SIZE = 100;
152989
153198
  var OAuthClientInfoService = class OAuthClientInfoService2 {
@@ -153046,7 +153255,7 @@ OAuthClientInfoService = __decorate22([
153046
153255
  W(),
153047
153256
  __param18(0, U(LoggerService)),
153048
153257
  __param18(1, U(NatsService)),
153049
- __metadata21("design:paramtypes", [typeof (_a46 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a46 : Object, typeof (_b35 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b35 : Object])
153258
+ __metadata21("design:paramtypes", [typeof (_a46 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a46 : Object, typeof (_b36 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b36 : Object])
153050
153259
  ], OAuthClientInfoService);
153051
153260
 
153052
153261
  // src/services/dynamic-tool-router.service.ts
@@ -153065,7 +153274,7 @@ var __param19 = function(paramIndex, decorator) {
153065
153274
  };
153066
153275
  };
153067
153276
  var _a47;
153068
- var _b36;
153277
+ var _b37;
153069
153278
  var DynamicToolRouter = class DynamicToolRouter2 {
153070
153279
  constructor(loggerService, natsService) {
153071
153280
  this.natsService = natsService;
@@ -153110,7 +153319,7 @@ DynamicToolRouter = __decorate23([
153110
153319
  W(),
153111
153320
  __param19(0, U(LoggerService)),
153112
153321
  __param19(1, U(NatsService)),
153113
- __metadata22("design:paramtypes", [typeof (_a47 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a47 : Object, typeof (_b36 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b36 : Object])
153322
+ __metadata22("design:paramtypes", [typeof (_a47 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a47 : Object, typeof (_b37 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b37 : Object])
153114
153323
  ], DynamicToolRouter);
153115
153324
 
153116
153325
  // src/services/runtime-bus.service.ts
@@ -153129,7 +153338,7 @@ var __param20 = function(paramIndex, decorator) {
153129
153338
  };
153130
153339
  };
153131
153340
  var _a48;
153132
- var _b37;
153341
+ var _b38;
153133
153342
  var RuntimeBusService = class RuntimeBusService2 {
153134
153343
  constructor(loggerService, natsService) {
153135
153344
  this.natsService = natsService;
@@ -153211,7 +153420,7 @@ RuntimeBusService = __decorate24([
153211
153420
  __param20(0, U(LoggerService)),
153212
153421
  __param20(1, U(NatsService)),
153213
153422
  __param20(1, se()),
153214
- __metadata23("design:paramtypes", [typeof (_a48 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a48 : Object, typeof (_b37 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b37 : Object])
153423
+ __metadata23("design:paramtypes", [typeof (_a48 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a48 : Object, typeof (_b38 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b38 : Object])
153215
153424
  ], RuntimeBusService);
153216
153425
 
153217
153426
  // src/services/tool.service.ts
@@ -153230,8 +153439,8 @@ var __param21 = function(paramIndex, decorator) {
153230
153439
  };
153231
153440
  };
153232
153441
  var _a49;
153233
- var _b38;
153234
- var _c9;
153442
+ var _b39;
153443
+ var _c10;
153235
153444
  var _d6;
153236
153445
  var _e6;
153237
153446
  var _f2;
@@ -153280,7 +153489,7 @@ function formatScriptError(stderr, exitCode) {
153280
153489
  }
153281
153490
  return result;
153282
153491
  }
153283
- var ToolService = class ToolService2 extends Service {
153492
+ var ToolService = class ToolService2 extends LifecycleService {
153284
153493
  constructor(loggerService, natsService, cacheService, authService, healthService, toolServerServiceFactory, oauthTokenService, oauthClientInfoService, mcpStdioService, fileService, runtimeExecutionId, scriptExecutorService, delegateService, scriptService, runtimeCatalogService, dynamicToolRouter, runtimeBusService) {
153285
153494
  super();
153286
153495
  this.loggerService = loggerService;
@@ -154199,25 +154408,25 @@ ${result.stderr}`;
154199
154408
  result: {
154200
154409
  content: [{ type: "text", text: output || (useInteractive ? "(Script executed with no output() call)" : "(Script executed successfully with no output)") }]
154201
154410
  },
154202
- executedBy
154411
+ executedBy,
154412
+ debug: truncateDebug(result.consoleOutput)
154413
+ // collapse empty string to undefined
154203
154414
  }));
154204
154415
  } else {
154205
154416
  const cleanError = result.stderr ? formatScriptError(result.stderr, result.exitCode) : result.error || "Unknown error";
154206
- const consolePart = result.consoleOutput ? `Console output:
154207
- ${result.consoleOutput}
154208
-
154209
- ` : "";
154210
154417
  const stdoutPart = result.stdout ? `Output:
154211
154418
  ${result.stdout}
154212
154419
 
154213
154420
  ` : "";
154214
- const fullOutput = stdoutPart || consolePart ? `${stdoutPart}${consolePart}${cleanError}` : cleanError;
154421
+ const fullOutput = stdoutPart ? `${stdoutPart}${cleanError}` : cleanError;
154215
154422
  respond(new RuntimeCallToolResponse({
154216
154423
  result: {
154217
154424
  content: [{ type: "text", text: fullOutput }],
154218
154425
  isError: true
154219
154426
  },
154220
- executedBy
154427
+ executedBy,
154428
+ debug: truncateDebug(result.consoleOutput)
154429
+ // collapse empty string to undefined
154221
154430
  }));
154222
154431
  }
154223
154432
  }
@@ -154620,7 +154829,7 @@ ToolService = __decorate25([
154620
154829
  __param21(15, se()),
154621
154830
  __param21(16, U(RuntimeBusService)),
154622
154831
  __param21(16, se()),
154623
- __metadata24("design:paramtypes", [typeof (_a49 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a49 : Object, typeof (_b38 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b38 : Object, typeof (_c9 = typeof NatsCacheService !== "undefined" && NatsCacheService) === "function" ? _c9 : Object, typeof (_d6 = typeof AuthService !== "undefined" && AuthService) === "function" ? _d6 : Object, typeof (_e6 = typeof HealthService !== "undefined" && HealthService) === "function" ? _e6 : Object, Object, typeof (_f2 = typeof OAuthTokenService !== "undefined" && OAuthTokenService) === "function" ? _f2 : Object, typeof (_g5 = typeof OAuthClientInfoService !== "undefined" && OAuthClientInfoService) === "function" ? _g5 : Object, Object, typeof (_j = typeof FileService !== "undefined" && FileService) === "function" ? _j : Object, String, typeof (_k = typeof ScriptExecutorService !== "undefined" && ScriptExecutorService) === "function" ? _k : Object, Object, Object, typeof (_o = typeof RuntimeCatalogService !== "undefined" && RuntimeCatalogService) === "function" ? _o : Object, typeof (_p = typeof DynamicToolRouter !== "undefined" && DynamicToolRouter) === "function" ? _p : Object, typeof (_q = typeof RuntimeBusService !== "undefined" && RuntimeBusService) === "function" ? _q : Object])
154832
+ __metadata24("design:paramtypes", [typeof (_a49 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a49 : Object, typeof (_b39 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b39 : Object, typeof (_c10 = typeof NatsCacheService !== "undefined" && NatsCacheService) === "function" ? _c10 : Object, typeof (_d6 = typeof AuthService !== "undefined" && AuthService) === "function" ? _d6 : Object, typeof (_e6 = typeof HealthService !== "undefined" && HealthService) === "function" ? _e6 : Object, Object, typeof (_f2 = typeof OAuthTokenService !== "undefined" && OAuthTokenService) === "function" ? _f2 : Object, typeof (_g5 = typeof OAuthClientInfoService !== "undefined" && OAuthClientInfoService) === "function" ? _g5 : Object, Object, typeof (_j = typeof FileService !== "undefined" && FileService) === "function" ? _j : Object, String, typeof (_k = typeof ScriptExecutorService !== "undefined" && ScriptExecutorService) === "function" ? _k : Object, Object, Object, typeof (_o = typeof RuntimeCatalogService !== "undefined" && RuntimeCatalogService) === "function" ? _o : Object, typeof (_p = typeof DynamicToolRouter !== "undefined" && DynamicToolRouter) === "function" ? _p : Object, typeof (_q = typeof RuntimeBusService !== "undefined" && RuntimeBusService) === "function" ? _q : Object])
154624
154833
  ], ToolService);
154625
154834
 
154626
154835
  // src/services/runtime.main.service.ts
@@ -154639,11 +154848,11 @@ var __param22 = function(paramIndex, decorator) {
154639
154848
  };
154640
154849
  };
154641
154850
  var _a50;
154642
- var _b39;
154643
- var _c10;
154851
+ var _b40;
154852
+ var _c11;
154644
154853
  var _d7;
154645
154854
  var _k2;
154646
- var MainService = class MainService2 extends Service {
154855
+ var MainService = class MainService2 extends LifecycleService {
154647
154856
  constructor(loggerService, natsService, authService, healthService, runtimeMode, mcpStdioService, fastifyManager, mcpSseService, mcpStreamableService, toolService, fileService, runtimeBusService, runtimeCatalogService) {
154648
154857
  super();
154649
154858
  this.loggerService = loggerService;
@@ -154897,7 +155106,7 @@ var MainService = class MainService2 extends Service {
154897
155106
  }
154898
155107
  }
154899
155108
  logActiveServices(numberOfExpectedAlive = 0) {
154900
- const activeServices = Service.getActiveServices();
155109
+ const activeServices = LifecycleService.getActiveServices();
154901
155110
  if (activeServices.length > numberOfExpectedAlive) {
154902
155111
  this.logger.warn("\u26A0\uFE0F Some services are still active:");
154903
155112
  activeServices.forEach((service) => {
@@ -154928,7 +155137,7 @@ MainService = __decorate26([
154928
155137
  __param22(11, se()),
154929
155138
  __param22(12, U(RuntimeCatalogService)),
154930
155139
  __param22(12, se()),
154931
- __metadata25("design:paramtypes", [typeof (_a50 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a50 : Object, typeof (_b39 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b39 : Object, typeof (_c10 = typeof AuthService !== "undefined" && AuthService) === "function" ? _c10 : Object, typeof (_d7 = typeof HealthService !== "undefined" && HealthService) === "function" ? _d7 : Object, Object, Object, Object, Object, Object, Object, typeof (_k2 = typeof FileService !== "undefined" && FileService) === "function" ? _k2 : Object, Object, Object])
155140
+ __metadata25("design:paramtypes", [typeof (_a50 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a50 : Object, typeof (_b40 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b40 : Object, typeof (_c11 = typeof AuthService !== "undefined" && AuthService) === "function" ? _c11 : Object, typeof (_d7 = typeof HealthService !== "undefined" && HealthService) === "function" ? _d7 : Object, Object, Object, Object, Object, Object, Object, typeof (_k2 = typeof FileService !== "undefined" && FileService) === "function" ? _k2 : Object, Object, Object])
154932
155141
  ], MainService);
154933
155142
 
154934
155143
  // src/di/container.ts