@skilder-ai/runtime 0.8.6 → 0.8.8

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
@@ -21941,7 +21941,7 @@ var require_transport = __commonJS({
21941
21941
  stream.flushSync();
21942
21942
  }
21943
21943
  function transport(fullOptions) {
21944
- const { pipeline, targets, levels, dedupe, worker = {}, caller = getCallers(), sync = false } = fullOptions;
21944
+ const { pipeline: pipeline2, targets, levels, dedupe, worker = {}, caller = getCallers(), sync = false } = fullOptions;
21945
21945
  const options = {
21946
21946
  ...fullOptions.options
21947
21947
  };
@@ -21969,9 +21969,9 @@ var require_transport = __commonJS({
21969
21969
  };
21970
21970
  });
21971
21971
  });
21972
- } else if (pipeline) {
21972
+ } else if (pipeline2) {
21973
21973
  target = bundlerOverrides["pino-worker"] || join6(__dirname, "worker.js");
21974
- options.pipelines = [pipeline.map((dest) => {
21974
+ options.pipelines = [pipeline2.map((dest) => {
21975
21975
  return {
21976
21976
  ...dest,
21977
21977
  target: fixTarget(dest.target)
@@ -24188,7 +24188,7 @@ var require_pump = __commonJS({
24188
24188
  var require_split2 = __commonJS({
24189
24189
  "../../node_modules/.pnpm/split2@4.2.0/node_modules/split2/index.js"(exports2, module2) {
24190
24190
  "use strict";
24191
- var { Transform } = require("stream");
24191
+ var { Transform: Transform2 } = require("stream");
24192
24192
  var { StringDecoder } = require("string_decoder");
24193
24193
  var kLast = /* @__PURE__ */ Symbol("last");
24194
24194
  var kDecoder = /* @__PURE__ */ Symbol("decoder");
@@ -24267,7 +24267,7 @@ var require_split2 = __commonJS({
24267
24267
  options.transform = transform2;
24268
24268
  options.flush = flush;
24269
24269
  options.readableObjectMode = true;
24270
- const stream = new Transform(options);
24270
+ const stream = new Transform2(options);
24271
24271
  stream[kLast] = "";
24272
24272
  stream[kDecoder] = new StringDecoder("utf8");
24273
24273
  stream.matcher = matcher;
@@ -26244,7 +26244,7 @@ var require_pino_pretty = __commonJS({
26244
26244
  "use strict";
26245
26245
  var { isColorSupported } = require_colorette();
26246
26246
  var pump = require_pump();
26247
- var { Transform } = require("node:stream");
26247
+ var { Transform: Transform2 } = require("node:stream");
26248
26248
  var abstractTransport = require_pino_abstract_transport();
26249
26249
  var colors = require_colors();
26250
26250
  var {
@@ -26301,7 +26301,7 @@ var require_pino_pretty = __commonJS({
26301
26301
  pretty3 = prettyFactory(opts);
26302
26302
  source.off("message", pinoConfigListener);
26303
26303
  });
26304
- const stream = new Transform({
26304
+ const stream = new Transform2({
26305
26305
  objectMode: true,
26306
26306
  autoDestroy: true,
26307
26307
  transform(chunk, enc, cb) {
@@ -41248,8 +41248,8 @@ var require_scope = __commonJS({
41248
41248
  return `${prefix}${ng.index++}`;
41249
41249
  }
41250
41250
  _nameGroup(prefix) {
41251
- var _a51, _b39;
41252
- if (((_b39 = (_a51 = this._parent) === null || _a51 === void 0 ? void 0 : _a51._prefixes) === null || _b39 === void 0 ? void 0 : _b39.has(prefix)) || this._prefixes && !this._prefixes.has(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)) {
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, _b39;
41713
+ var _a51, _b40;
41714
41714
  super.optimizeNodes();
41715
41715
  (_a51 = this.catch) === null || _a51 === void 0 ? void 0 : _a51.optimizeNodes();
41716
- (_b39 = this.finally) === null || _b39 === void 0 ? void 0 : _b39.optimizeNodes();
41716
+ (_b40 = this.finally) === null || _b40 === void 0 ? void 0 : _b40.optimizeNodes();
41717
41717
  return this;
41718
41718
  }
41719
41719
  optimizeNames(names, constants2) {
41720
- var _a51, _b39;
41720
+ var _a51, _b40;
41721
41721
  super.optimizeNames(names, constants2);
41722
41722
  (_a51 = this.catch) === null || _a51 === void 0 ? void 0 : _a51.optimizeNames(names, constants2);
41723
- (_b39 = this.finally) === null || _b39 === void 0 ? void 0 : _b39.optimizeNames(names, constants2);
41723
+ (_b40 = this.finally) === null || _b40 === void 0 ? void 0 : _b40.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, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _j2, _k3, _l, _m, _o2, _p2, _q2, _r2, _s, _t, _u, _v, _w, _x, _y, _z, _0;
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;
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 = (_b39 = o.code) === null || _b39 === void 0 ? void 0 : _b39.regExp) !== null && _c11 !== void 0 ? _c11 : defaultRegExp;
44945
+ const regExp = (_c11 = (_b40 = o.code) === null || _b40 === void 0 ? void 0 : _b40.regExp) !== null && _c11 !== void 0 ? _c11 : 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,
@@ -44952,7 +44952,7 @@ var require_core2 = __commonJS({
44952
44952
  strictRequired: (_p2 = (_o2 = o.strictRequired) !== null && _o2 !== void 0 ? _o2 : s) !== null && _p2 !== void 0 ? _p2 : false,
44953
44953
  code: o.code ? { ...o.code, optimize, regExp } : { optimize, regExp },
44954
44954
  loopRequired: (_q2 = o.loopRequired) !== null && _q2 !== void 0 ? _q2 : MAX_EXPRESSION,
44955
- loopEnum: (_r2 = o.loopEnum) !== null && _r2 !== void 0 ? _r2 : MAX_EXPRESSION,
44955
+ loopEnum: (_r = o.loopEnum) !== null && _r !== void 0 ? _r : MAX_EXPRESSION,
44956
44956
  meta: (_s = o.meta) !== null && _s !== void 0 ? _s : true,
44957
44957
  messages: (_t = o.messages) !== null && _t !== void 0 ? _t : true,
44958
44958
  inlineRefs: (_u = o.inlineRefs) !== null && _u !== void 0 ? _u : true,
@@ -47803,8 +47803,8 @@ var require_dist2 = __commonJS({
47803
47803
  };
47804
47804
  function addFormats(ajv, list, fs5, exportName) {
47805
47805
  var _a51;
47806
- var _b39;
47807
- (_a51 = (_b39 = ajv.opts.code).formats) !== null && _a51 !== void 0 ? _a51 : _b39.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
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}`;
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, _b39;
47936
+ var e_1, _a51, e_2, _b40;
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 && (_b39 = _finalizers_1.return)) _b39.call(_finalizers_1);
47991
+ if (_finalizers_1_1 && !_finalizers_1_1.done && (_b40 = _finalizers_1.return)) _b40.call(_finalizers_1);
47992
47992
  } finally {
47993
47993
  if (e_2) throw e_2.error;
47994
47994
  }
@@ -49037,7 +49037,7 @@ var require_Subject = __commonJS({
49037
49037
  _this.currentObservers = Array.from(_this.observers);
49038
49038
  }
49039
49039
  try {
49040
- for (var _b39 = __values(_this.currentObservers), _c11 = _b39.next(); !_c11.done; _c11 = _b39.next()) {
49040
+ for (var _b40 = __values(_this.currentObservers), _c11 = _b40.next(); !_c11.done; _c11 = _b40.next()) {
49041
49041
  var observer = _c11.value;
49042
49042
  observer.next(value);
49043
49043
  }
@@ -49045,7 +49045,7 @@ var require_Subject = __commonJS({
49045
49045
  e_1 = { error: e_1_1 };
49046
49046
  } finally {
49047
49047
  try {
49048
- if (_c11 && !_c11.done && (_a51 = _b39.return)) _a51.call(_b39);
49048
+ if (_c11 && !_c11.done && (_a51 = _b40.return)) _a51.call(_b40);
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, _b39;
49146
- (_b39 = (_a51 = this.destination) === null || _a51 === void 0 ? void 0 : _a51.next) === null || _b39 === void 0 ? void 0 : _b39.call(_a51, 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);
49147
49147
  };
49148
49148
  AnonymousSubject2.prototype.error = function(err) {
49149
- var _a51, _b39;
49150
- (_b39 = (_a51 = this.destination) === null || _a51 === void 0 ? void 0 : _a51.error) === null || _b39 === void 0 ? void 0 : _b39.call(_a51, 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);
49151
49151
  };
49152
49152
  AnonymousSubject2.prototype.complete = function() {
49153
- var _a51, _b39;
49154
- (_b39 = (_a51 = this.destination) === null || _a51 === void 0 ? void 0 : _a51.complete) === null || _b39 === void 0 ? void 0 : _b39.call(_a51);
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);
49155
49155
  };
49156
49156
  AnonymousSubject2.prototype._subscribe = function(subscriber) {
49157
- var _a51, _b39;
49158
- return (_b39 = (_a51 = this.source) === null || _a51 === void 0 ? void 0 : _a51.subscribe(subscriber)) !== null && _b39 !== void 0 ? _b39 : Subscription_1.EMPTY_SUBSCRIPTION;
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;
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(_b39) {
50618
- switch (_b39.label) {
50617
+ return __generator(this, function(_b40) {
50618
+ switch (_b40.label) {
50619
50619
  case 0:
50620
50620
  reader = readableStream.getReader();
50621
- _b39.label = 1;
50621
+ _b40.label = 1;
50622
50622
  case 1:
50623
- _b39.trys.push([1, , 9, 10]);
50624
- _b39.label = 2;
50623
+ _b40.trys.push([1, , 9, 10]);
50624
+ _b40.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 = _b39.sent(), value = _a51.value, done = _a51.done;
50629
+ _a51 = _b40.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, _b39.sent()];
50633
+ return [2, _b40.sent()];
50634
50634
  case 5:
50635
50635
  return [4, __await(value)];
50636
50636
  case 6:
50637
- return [4, _b39.sent()];
50637
+ return [4, _b40.sent()];
50638
50638
  case 7:
50639
- _b39.sent();
50639
+ _b40.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(_b39) {
50904
- switch (_b39.label) {
50903
+ return __generator(this, function(_b40) {
50904
+ switch (_b40.label) {
50905
50905
  case 0:
50906
- _b39.trys.push([0, 5, 6, 11]);
50906
+ _b40.trys.push([0, 5, 6, 11]);
50907
50907
  asyncIterable_1 = __asyncValues(asyncIterable);
50908
- _b39.label = 1;
50908
+ _b40.label = 1;
50909
50909
  case 1:
50910
50910
  return [4, asyncIterable_1.next()];
50911
50911
  case 2:
50912
- if (!(asyncIterable_1_1 = _b39.sent(), !asyncIterable_1_1.done)) return [3, 4];
50912
+ if (!(asyncIterable_1_1 = _b40.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
- _b39.label = 3;
50918
+ _b40.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 = _b39.sent();
50924
+ e_2_1 = _b40.sent();
50925
50925
  e_2 = { error: e_2_1 };
50926
50926
  return [3, 11];
50927
50927
  case 6:
50928
- _b39.trys.push([6, , 9, 10]);
50928
+ _b40.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
- _b39.sent();
50933
- _b39.label = 8;
50932
+ _b40.sent();
50933
+ _b40.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, _b39, _c11;
51342
+ var _a51, _b40, _c11;
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" ? (_b39 = observer.error) === null || _b39 === void 0 ? void 0 : _b39.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" ? (_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);
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, _b39 = _a51.with, _with = _b39 === void 0 ? timeoutErrorFactory : _b39, _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, _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;
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, _b39;
52381
+ var _a51, _b40;
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, _b39 = _a51.resultSelector, resultSelector = _b39 === void 0 ? identity_1.identity : _b39, scheduler2 = _a51.scheduler;
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;
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, _b39;
53001
+ var e_1, _a51, e_2, _b40;
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 && (_b39 = toEmit_1.return)) _b39.call(toEmit_1);
53035
+ if (toEmit_1_1 && !toEmit_1_1.done && (_b40 = toEmit_1.return)) _b40.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, _b39;
53092
+ var _a51, _b40;
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 = (_b39 = otherArgs[0]) !== null && _b39 !== void 0 ? _b39 : null;
53098
+ var bufferCreationInterval = (_b40 = otherArgs[0]) !== null && _b40 !== void 0 ? _b40 : 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, _b39 = config2.resetOnSuccess, resetOnSuccess = _b39 === void 0 ? false : _b39;
55122
+ var _a51 = config2.count, count = _a51 === void 0 ? Infinity : _a51, delay2 = config2.delay, _b40 = config2.resetOnSuccess, resetOnSuccess = _b40 === void 0 ? false : _b40;
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, _b39 = options.resetOnError, resetOnError = _b39 === void 0 ? true : _b39, _c11 = options.resetOnComplete, resetOnComplete = _c11 === void 0 ? true : _c11, _d8 = options.resetOnRefCountZero, resetOnRefCountZero = _d8 === void 0 ? true : _d8;
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;
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, _b39, _c11;
55461
+ var _a51, _b40, _c11;
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, _b39 = configOrBufferSize.windowTime, windowTime = _b39 === void 0 ? Infinity : _b39, _c11 = configOrBufferSize.refCount, refCount = _c11 === void 0 ? false : _c11, scheduler2 = configOrBufferSize.scheduler;
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;
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, _b39;
55814
+ var _a54, _b40;
55815
55815
  if (isUnsub) {
55816
55816
  (_a54 = tapObserver.unsubscribe) === null || _a54 === void 0 ? void 0 : _a54.call(tapObserver);
55817
55817
  }
55818
- (_b39 = tapObserver.finalize) === null || _b39 === void 0 ? void 0 : _b39.call(tapObserver);
55818
+ (_b40 = tapObserver.finalize) === null || _b40 === void 0 ? void 0 : _b40.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 : {}, _b39 = _a51.leading, leading = _b39 === void 0 ? true : _b39, _c11 = _a51.trailing, trailing = _c11 === void 0 ? false : _c11;
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;
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, _b39;
56126
+ var _a51, _b40;
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 = (_b39 = otherArgs[0]) !== null && _b39 !== void 0 ? _b39 : null;
56132
+ var windowCreationInterval = (_b40 = otherArgs[0]) !== null && _b40 !== void 0 ? _b40 : null;
56133
56133
  var maxWindowSize = otherArgs[1] || Infinity;
56134
56134
  return lift_1.operate(function(source, subscriber) {
56135
56135
  var windowRecords = [];
@@ -61516,7 +61516,7 @@ var require_reply = __commonJS({
61516
61516
  "../../node_modules/.pnpm/fastify@5.6.2/node_modules/fastify/lib/reply.js"(exports2, module2) {
61517
61517
  "use strict";
61518
61518
  var eos = require("node:stream").finished;
61519
- var Readable2 = require("node:stream").Readable;
61519
+ var Readable3 = require("node:stream").Readable;
61520
61520
  var {
61521
61521
  kFourOhFourContext,
61522
61522
  kReplyErrorHandlerCalled,
@@ -62051,7 +62051,7 @@ var require_reply = __commonJS({
62051
62051
  if (payload.locked) {
62052
62052
  throw new FST_ERR_REP_READABLE_STREAM_LOCKED();
62053
62053
  }
62054
- const nodeStream = Readable2.fromWeb(payload);
62054
+ const nodeStream = Readable3.fromWeb(payload);
62055
62055
  sendStream(nodeStream, res, reply);
62056
62056
  }
62057
62057
  function sendStream(payload, res, reply) {
@@ -72720,11 +72720,11 @@ var require_util4 = __commonJS({
72720
72720
  });
72721
72721
  };
72722
72722
  exports2.tokenizeClass = (str, regexpStr) => {
72723
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6;
72723
+ var _a51, _b40, _c11, _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 = (_b39 = (_a51 = rs[1] && sets.words()) !== null && _a51 !== void 0 ? _a51 : rs[2] && sets.ints()) !== null && _b39 !== void 0 ? _b39 : 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 = (_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] && {
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)
@@ -77153,15 +77153,15 @@ var require_parse_url = __commonJS({
77153
77153
  var require_form_data = __commonJS({
77154
77154
  "../../node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/form-data.js"(exports2, module2) {
77155
77155
  "use strict";
77156
- var { randomUUID: randomUUID4 } = require("node:crypto");
77157
- var { Readable: Readable2 } = require("node:stream");
77156
+ var { randomUUID: randomUUID5 } = require("node:crypto");
77157
+ var { Readable: Readable3 } = require("node:stream");
77158
77158
  var textEncoder;
77159
77159
  function isFormDataLike(payload) {
77160
77160
  return payload && typeof payload === "object" && typeof payload.append === "function" && typeof payload.delete === "function" && typeof payload.get === "function" && typeof payload.getAll === "function" && typeof payload.has === "function" && typeof payload.set === "function" && payload[Symbol.toStringTag] === "FormData";
77161
77161
  }
77162
77162
  function formDataToStream(formdata) {
77163
77163
  textEncoder = textEncoder ?? new TextEncoder();
77164
- const boundary = `----formdata-${randomUUID4()}`;
77164
+ const boundary = `----formdata-${randomUUID5()}`;
77165
77165
  const prefix = `--${boundary}\r
77166
77166
  Content-Disposition: form-data`;
77167
77167
  const escape2 = (str) => str.replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22");
@@ -77193,7 +77193,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
77193
77193
  }
77194
77194
  yield textEncoder.encode(`--${boundary}--`);
77195
77195
  }
77196
- const stream = Readable2.from(asyncIterator());
77196
+ const stream = Readable3.from(asyncIterator());
77197
77197
  return {
77198
77198
  stream,
77199
77199
  contentType: `multipart/form-data; boundary=${boundary}`
@@ -77208,7 +77208,7 @@ Content-Type: ${value.type || "application/octet-stream"}\r
77208
77208
  var require_request3 = __commonJS({
77209
77209
  "../../node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/request.js"(exports2, module2) {
77210
77210
  "use strict";
77211
- var { Readable: Readable2, addAbortSignal } = require("node:stream");
77211
+ var { Readable: Readable3, addAbortSignal } = require("node:stream");
77212
77212
  var util2 = require("node:util");
77213
77213
  var cookie = require_dist5();
77214
77214
  var assert2 = require("node:assert");
@@ -77246,7 +77246,7 @@ var require_request3 = __commonJS({
77246
77246
  }
77247
77247
  }
77248
77248
  function Request2(options) {
77249
- Readable2.call(this, {
77249
+ Readable3.call(this, {
77250
77250
  autoDestroy: false
77251
77251
  });
77252
77252
  const parsedURL = parseURL(options.url || options.path, options.query);
@@ -77378,7 +77378,7 @@ var require_request3 = __commonJS({
77378
77378
  }
77379
77379
  });
77380
77380
  }
77381
- util2.inherits(Request2, Readable2);
77381
+ util2.inherits(Request2, Readable3);
77382
77382
  util2.inherits(CustomRequest, Request2);
77383
77383
  Request2.prototype.destroy = function(error48) {
77384
77384
  if (this.destroyed || this._lightMyRequest.isDone) return;
@@ -77583,14 +77583,14 @@ var require_response = __commonJS({
77583
77583
  "../../node_modules/.pnpm/light-my-request@6.6.0/node_modules/light-my-request/lib/response.js"(exports2, module2) {
77584
77584
  "use strict";
77585
77585
  var http = require("node:http");
77586
- var { Writable, Readable: Readable2, addAbortSignal } = require("node:stream");
77586
+ var { Writable, Readable: Readable3, addAbortSignal } = require("node:stream");
77587
77587
  var util2 = require("node:util");
77588
77588
  var setCookie = require_set_cookie();
77589
77589
  function Response3(req, onEnd, reject) {
77590
77590
  http.ServerResponse.call(this, req);
77591
77591
  if (req._lightMyRequest?.payloadAsStream) {
77592
77592
  const read = this.emit.bind(this, "drain");
77593
- this._lightMyRequest = { headers: null, trailers: {}, stream: new Readable2({ read }) };
77593
+ this._lightMyRequest = { headers: null, trailers: {}, stream: new Readable3({ read }) };
77594
77594
  const signal = req._lightMyRequest.signal;
77595
77595
  if (signal) {
77596
77596
  addAbortSignal(signal, this._lightMyRequest.stream);
@@ -77736,7 +77736,7 @@ var require_response = __commonJS({
77736
77736
  if (response._lightMyRequest.stream) {
77737
77737
  return response._lightMyRequest.stream;
77738
77738
  }
77739
- return Readable2.from(response._lightMyRequest.payloadChunks);
77739
+ return Readable3.from(response._lightMyRequest.payloadChunks);
77740
77740
  };
77741
77741
  return res;
77742
77742
  }
@@ -84311,14 +84311,14 @@ var require_streams = __commonJS({
84311
84311
  "use strict";
84312
84312
  var Buffer2 = require_safer().Buffer;
84313
84313
  module2.exports = function(streamModule) {
84314
- var Transform = streamModule.Transform;
84314
+ var Transform2 = streamModule.Transform;
84315
84315
  function IconvLiteEncoderStream(conv, options) {
84316
84316
  this.conv = conv;
84317
84317
  options = options || {};
84318
84318
  options.decodeStrings = false;
84319
- Transform.call(this, options);
84319
+ Transform2.call(this, options);
84320
84320
  }
84321
- IconvLiteEncoderStream.prototype = Object.create(Transform.prototype, {
84321
+ IconvLiteEncoderStream.prototype = Object.create(Transform2.prototype, {
84322
84322
  constructor: { value: IconvLiteEncoderStream }
84323
84323
  });
84324
84324
  IconvLiteEncoderStream.prototype._transform = function(chunk, encoding, done) {
@@ -84357,9 +84357,9 @@ var require_streams = __commonJS({
84357
84357
  this.conv = conv;
84358
84358
  options = options || {};
84359
84359
  options.encoding = this.encoding = "utf8";
84360
- Transform.call(this, options);
84360
+ Transform2.call(this, options);
84361
84361
  }
84362
- IconvLiteDecoderStream.prototype = Object.create(Transform.prototype, {
84362
+ IconvLiteDecoderStream.prototype = Object.create(Transform2.prototype, {
84363
84363
  constructor: { value: IconvLiteDecoderStream }
84364
84364
  });
84365
84365
  IconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) {
@@ -87646,6 +87646,10 @@ var ne2 = class {
87646
87646
  };
87647
87647
 
87648
87648
  // ../common/src/constants.ts
87649
+ var FILE_BODY_LIMIT_MB = 100;
87650
+ var FILE_BODY_LIMIT_BYTES = FILE_BODY_LIMIT_MB * 1024 * 1024;
87651
+ var GRAPHQL_BODY_LIMIT_MB = 10;
87652
+ var GRAPHQL_BODY_LIMIT_BYTES = GRAPHQL_BODY_LIMIT_MB * 1024 * 1024;
87649
87653
  var DEFAULT_OLLAMA_BASE_URL = "http://localhost:11434/api";
87650
87654
  var DEFAULT_TEMPERATURE = 1;
87651
87655
  var AI_PROVIDER_API_URLS = {
@@ -89601,7 +89605,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
89601
89605
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
89602
89606
  const result = { errors: [] };
89603
89607
  const processError = (error49, path4 = []) => {
89604
- var _a51, _b39;
89608
+ var _a51, _b40;
89605
89609
  for (const issue2 of error49.issues) {
89606
89610
  if (issue2.code === "invalid_union" && issue2.errors.length) {
89607
89611
  issue2.errors.map((issues) => processError({ issues }, issue2.path));
@@ -89626,7 +89630,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
89626
89630
  curr = curr.properties[el];
89627
89631
  } else {
89628
89632
  curr.items ?? (curr.items = []);
89629
- (_b39 = curr.items)[el] ?? (_b39[el] = { errors: [] });
89633
+ (_b40 = curr.items)[el] ?? (_b40[el] = { errors: [] });
89630
89634
  curr = curr.items[el];
89631
89635
  }
89632
89636
  if (terminal) {
@@ -90294,7 +90298,7 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
90294
90298
  };
90295
90299
  });
90296
90300
  var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
90297
- var _a51, _b39;
90301
+ var _a51, _b40;
90298
90302
  $ZodCheck.init(inst, def);
90299
90303
  inst._zod.onattach.push((inst2) => {
90300
90304
  const bag = inst2._zod.bag;
@@ -90320,7 +90324,7 @@ var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat"
90320
90324
  });
90321
90325
  });
90322
90326
  else
90323
- (_b39 = inst._zod).check ?? (_b39.check = () => {
90327
+ (_b40 = inst._zod).check ?? (_b40.check = () => {
90324
90328
  });
90325
90329
  });
90326
90330
  var $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
@@ -108842,7 +108846,7 @@ function shouldAttemptFallback(response, pathname) {
108842
108846
  return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
108843
108847
  }
108844
108848
  async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
108845
- var _a310, _b39;
108849
+ var _a310, _b310;
108846
108850
  const issuer = new URL(serverUrl);
108847
108851
  const protocolVersion = (_a310 = opts == null ? void 0 : opts.protocolVersion) != null ? _a310 : LATEST_PROTOCOL_VERSION;
108848
108852
  let url2;
@@ -108850,7 +108854,7 @@ async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, o
108850
108854
  url2 = new URL(opts.metadataUrl);
108851
108855
  } else {
108852
108856
  const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
108853
- url2 = new URL(wellKnownPath, (_b39 = opts == null ? void 0 : opts.metadataServerUrl) != null ? _b39 : issuer);
108857
+ url2 = new URL(wellKnownPath, (_b310 = opts == null ? void 0 : opts.metadataServerUrl) != null ? _b310 : issuer);
108854
108858
  url2.search = issuer.search;
108855
108859
  }
108856
108860
  let response = await tryMetadataDiscovery(url2, protocolVersion, fetchFn);
@@ -109210,7 +109214,7 @@ async function registerClient(authorizationServerUrl, {
109210
109214
  return OAuthClientInformationFullSchema.parse(await response.json());
109211
109215
  }
109212
109216
  async function auth(provider, options) {
109213
- var _a310, _b39;
109217
+ var _a310, _b310;
109214
109218
  try {
109215
109219
  return await authInternal(provider, options);
109216
109220
  } catch (error48) {
@@ -109218,7 +109222,7 @@ async function auth(provider, options) {
109218
109222
  await ((_a310 = provider.invalidateCredentials) == null ? void 0 : _a310.call(provider, "all"));
109219
109223
  return await authInternal(provider, options);
109220
109224
  } else if (error48 instanceof InvalidGrantError) {
109221
- await ((_b39 = provider.invalidateCredentials) == null ? void 0 : _b39.call(provider, "tokens"));
109225
+ await ((_b310 = provider.invalidateCredentials) == null ? void 0 : _b310.call(provider, "tokens"));
109222
109226
  return await authInternal(provider, options);
109223
109227
  }
109224
109228
  throw error48;
@@ -109389,7 +109393,7 @@ var SseMCPTransport = class {
109389
109393
  }
109390
109394
  this.abortController = new AbortController();
109391
109395
  const establishConnection = async (triedAuth = false) => {
109392
- var _a310, _b39, _c11, _d8, _e7;
109396
+ var _a310, _b310, _c11, _d8, _e7;
109393
109397
  try {
109394
109398
  const headers = await this.commonHeaders({
109395
109399
  Accept: "text/event-stream"
@@ -109407,7 +109411,7 @@ var SseMCPTransport = class {
109407
109411
  });
109408
109412
  if (result !== "AUTHORIZED") {
109409
109413
  const error48 = new UnauthorizedError();
109410
- (_b39 = this.onerror) == null ? void 0 : _b39.call(this, error48);
109414
+ (_b310 = this.onerror) == null ? void 0 : _b310.call(this, error48);
109411
109415
  return reject(error48);
109412
109416
  }
109413
109417
  } catch (error48) {
@@ -109492,10 +109496,10 @@ var SseMCPTransport = class {
109492
109496
  });
109493
109497
  }
109494
109498
  async close() {
109495
- var _a310, _b39, _c11;
109499
+ var _a310, _b310, _c11;
109496
109500
  this.connected = false;
109497
109501
  (_a310 = this.sseConnection) == null ? void 0 : _a310.close();
109498
- (_b39 = this.abortController) == null ? void 0 : _b39.abort();
109502
+ (_b310 = this.abortController) == null ? void 0 : _b310.abort();
109499
109503
  (_c11 = this.onclose) == null ? void 0 : _c11.call(this);
109500
109504
  }
109501
109505
  async send(message) {
@@ -109506,7 +109510,7 @@ var SseMCPTransport = class {
109506
109510
  }
109507
109511
  const endpoint = this.endpoint;
109508
109512
  const attempt = async (triedAuth = false) => {
109509
- var _a310, _b39, _c11, _d8, _e7;
109513
+ var _a310, _b310, _c11, _d8, _e7;
109510
109514
  try {
109511
109515
  const headers = await this.commonHeaders({
109512
109516
  "Content-Type": "application/json"
@@ -109527,7 +109531,7 @@ var SseMCPTransport = class {
109527
109531
  });
109528
109532
  if (result !== "AUTHORIZED") {
109529
109533
  const error48 = new UnauthorizedError();
109530
- (_b39 = this.onerror) == null ? void 0 : _b39.call(this, error48);
109534
+ (_b310 = this.onerror) == null ? void 0 : _b310.call(this, error48);
109531
109535
  return;
109532
109536
  }
109533
109537
  } catch (error48) {
@@ -109600,7 +109604,7 @@ var HttpMCPTransport = class {
109600
109604
  void this.openInboundSse();
109601
109605
  }
109602
109606
  async close() {
109603
- var _a310, _b39, _c11;
109607
+ var _a310, _b310, _c11;
109604
109608
  (_a310 = this.inboundSseConnection) == null ? void 0 : _a310.close();
109605
109609
  try {
109606
109610
  if (this.sessionId && this.abortController && !this.abortController.signal.aborted) {
@@ -109613,12 +109617,12 @@ var HttpMCPTransport = class {
109613
109617
  }
109614
109618
  } catch (e2) {
109615
109619
  }
109616
- (_b39 = this.abortController) == null ? void 0 : _b39.abort();
109620
+ (_b310 = this.abortController) == null ? void 0 : _b310.abort();
109617
109621
  (_c11 = this.onclose) == null ? void 0 : _c11.call(this);
109618
109622
  }
109619
109623
  async send(message) {
109620
109624
  const attempt = async (triedAuth = false) => {
109621
- var _a310, _b39, _c11, _d8, _e7, _f3, _g6;
109625
+ var _a310, _b310, _c11, _d8, _e7, _f3, _g6;
109622
109626
  try {
109623
109627
  const headers = await this.commonHeaders({
109624
109628
  "Content-Type": "application/json",
@@ -109647,7 +109651,7 @@ var HttpMCPTransport = class {
109647
109651
  throw error210;
109648
109652
  }
109649
109653
  } catch (error210) {
109650
- (_b39 = this.onerror) == null ? void 0 : _b39.call(this, error210);
109654
+ (_b310 = this.onerror) == null ? void 0 : _b310.call(this, error210);
109651
109655
  throw error210;
109652
109656
  }
109653
109657
  return attempt(true);
@@ -109766,7 +109770,7 @@ var HttpMCPTransport = class {
109766
109770
  }
109767
109771
  // Open optional inbound SSE stream; best-effort and resumable
109768
109772
  async openInboundSse(triedAuth = false, resumeToken) {
109769
- var _a310, _b39, _c11, _d8, _e7, _f3;
109773
+ var _a310, _b310, _c11, _d8, _e7, _f3;
109770
109774
  try {
109771
109775
  const headers = await this.commonHeaders({
109772
109776
  Accept: "text/event-stream"
@@ -109792,7 +109796,7 @@ var HttpMCPTransport = class {
109792
109796
  });
109793
109797
  if (result !== "AUTHORIZED") {
109794
109798
  const error48 = new UnauthorizedError();
109795
- (_b39 = this.onerror) == null ? void 0 : _b39.call(this, error48);
109799
+ (_b310 = this.onerror) == null ? void 0 : _b310.call(this, error48);
109796
109800
  return;
109797
109801
  }
109798
109802
  } catch (error48) {
@@ -110199,7 +110203,7 @@ var DefaultMCPClient = class {
110199
110203
  * Creates AI SDK tools from tool definitions without fetching from the server.
110200
110204
  */
110201
110205
  toolsFromDefinitions(definitions, { schemas = "automatic" } = {}) {
110202
- var _a310, _b39;
110206
+ var _a310, _b310;
110203
110207
  const tools = {};
110204
110208
  for (const {
110205
110209
  name: name34,
@@ -110229,7 +110233,7 @@ var DefaultMCPClient = class {
110229
110233
  title: resolvedTitle,
110230
110234
  inputSchema: jsonSchema({
110231
110235
  ...inputSchema,
110232
- properties: (_b39 = inputSchema.properties) != null ? _b39 : {},
110236
+ properties: (_b310 = inputSchema.properties) != null ? _b310 : {},
110233
110237
  additionalProperties: false
110234
110238
  }),
110235
110239
  execute,
@@ -112846,12 +112850,12 @@ function registerGlobal(type22, instance, diag, allowOverride) {
112846
112850
  return true;
112847
112851
  }
112848
112852
  function getGlobal(type22) {
112849
- var _a51, _b39;
112853
+ var _a51, _b40;
112850
112854
  var globalVersion = (_a51 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a51 === void 0 ? void 0 : _a51.version;
112851
112855
  if (!globalVersion || !isCompatible(globalVersion)) {
112852
112856
  return;
112853
112857
  }
112854
- return (_b39 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b39 === void 0 ? void 0 : _b39[type22];
112858
+ return (_b40 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b40 === void 0 ? void 0 : _b40[type22];
112855
112859
  }
112856
112860
  function unregisterGlobal(type22, diag) {
112857
112861
  diag.debug("@opentelemetry/api: Unregistering a global for " + type22 + " v" + VERSION4 + ".");
@@ -113024,7 +113028,7 @@ var DiagAPI = (
113024
113028
  }
113025
113029
  var self2 = this;
113026
113030
  var setLogger = function(logger, optionsOrLogLevel) {
113027
- var _a51, _b39, _c11;
113031
+ var _a51, _b40, _c11;
113028
113032
  if (optionsOrLogLevel === void 0) {
113029
113033
  optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
113030
113034
  }
@@ -113039,7 +113043,7 @@ var DiagAPI = (
113039
113043
  };
113040
113044
  }
113041
113045
  var oldLogger = getGlobal("diag");
113042
- var newLogger = createLogLevelDiagLogger((_b39 = optionsOrLogLevel.logLevel) !== null && _b39 !== void 0 ? _b39 : DiagLogLevel.INFO, logger);
113046
+ var newLogger = createLogLevelDiagLogger((_b40 = optionsOrLogLevel.logLevel) !== null && _b40 !== void 0 ? _b40 : DiagLogLevel.INFO, logger);
113043
113047
  if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
113044
113048
  var stack = (_c11 = new Error().stack) !== null && _c11 !== void 0 ? _c11 : "<failed to generate stacktrace>";
113045
113049
  oldLogger.warn("Current logger will be overwritten from " + stack);
@@ -114174,8 +114178,8 @@ var dataContentSchema = external_exports.union([
114174
114178
  external_exports.custom(
114175
114179
  // Buffer might not be available in some environments such as CloudFlare:
114176
114180
  (value) => {
114177
- var _a212, _b39;
114178
- return (_b39 = (_a212 = globalThis.Buffer) == null ? void 0 : _a212.isBuffer(value)) != null ? _b39 : false;
114181
+ var _a212, _b40;
114182
+ return (_b40 = (_a212 = globalThis.Buffer) == null ? void 0 : _a212.isBuffer(value)) != null ? _b40 : false;
114179
114183
  },
114180
114184
  { message: "Must be a Buffer" }
114181
114185
  )
@@ -115261,13 +115265,13 @@ function createNullLanguageModelUsage() {
115261
115265
  };
115262
115266
  }
115263
115267
  function addLanguageModelUsage(usage1, usage2) {
115264
- var _a212, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2;
115268
+ var _a212, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2;
115265
115269
  return {
115266
115270
  inputTokens: addTokenCounts(usage1.inputTokens, usage2.inputTokens),
115267
115271
  inputTokenDetails: {
115268
115272
  noCacheTokens: addTokenCounts(
115269
115273
  (_a212 = usage1.inputTokenDetails) == null ? void 0 : _a212.noCacheTokens,
115270
- (_b39 = usage2.inputTokenDetails) == null ? void 0 : _b39.noCacheTokens
115274
+ (_b40 = usage2.inputTokenDetails) == null ? void 0 : _b40.noCacheTokens
115271
115275
  ),
115272
115276
  cacheReadTokens: addTokenCounts(
115273
115277
  (_c11 = usage1.inputTokenDetails) == null ? void 0 : _c11.cacheReadTokens,
@@ -115531,8 +115535,8 @@ function collectToolApprovals({
115531
115535
  return { approvedToolApprovals, deniedToolApprovals };
115532
115536
  }
115533
115537
  function now() {
115534
- var _a212, _b39;
115535
- return (_b39 = (_a212 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a212.now()) != null ? _b39 : Date.now();
115538
+ var _a212, _b40;
115539
+ return (_b40 = (_a212 = globalThis == null ? void 0 : globalThis.performance) == null ? void 0 : _a212.now()) != null ? _b40 : Date.now();
115536
115540
  }
115537
115541
  async function executeToolCall({
115538
115542
  toolCall,
@@ -116855,7 +116859,7 @@ async function generateText({
116855
116859
  }),
116856
116860
  tracer,
116857
116861
  fn: async (span) => {
116858
- var _a212, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
116862
+ var _a212, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
116859
116863
  const initialMessages = initialPrompt.messages;
116860
116864
  const responseMessages = [];
116861
116865
  const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
@@ -116962,7 +116966,7 @@ async function generateText({
116962
116966
  };
116963
116967
  const promptMessages = await convertToLanguageModelPrompt({
116964
116968
  prompt: {
116965
- system: (_b39 = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b39 : initialPrompt.system,
116969
+ system: (_b40 = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b40 : initialPrompt.system,
116966
116970
  messages: (_c11 = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _c11 : stepInputMessages
116967
116971
  },
116968
116972
  supportedUrls: await stepModel.supportedUrls,
@@ -117917,7 +117921,7 @@ function processUIMessageStream({
117917
117921
  new TransformStream({
117918
117922
  async transform(chunk, controller) {
117919
117923
  await runUpdateMessageJob(async ({ state, write }) => {
117920
- var _a212, _b39, _c11, _d8;
117924
+ var _a212, _b40, _c11, _d8;
117921
117925
  function getToolInvocation(toolCallId) {
117922
117926
  const toolInvocations = state.message.parts.filter(isToolUIPart);
117923
117927
  const toolInvocation = toolInvocations.find(
@@ -118060,7 +118064,7 @@ function processUIMessageStream({
118060
118064
  });
118061
118065
  }
118062
118066
  textPart.state = "done";
118063
- textPart.providerMetadata = (_b39 = chunk.providerMetadata) != null ? _b39 : textPart.providerMetadata;
118067
+ textPart.providerMetadata = (_b40 = chunk.providerMetadata) != null ? _b40 : textPart.providerMetadata;
118064
118068
  delete state.activeTextParts[chunk.id];
118065
118069
  write();
118066
118070
  break;
@@ -119170,7 +119174,7 @@ var DefaultStreamTextResult = class {
119170
119174
  let activeReasoningContent = {};
119171
119175
  const eventProcessor = new TransformStream({
119172
119176
  async transform(chunk, controller) {
119173
- var _a212, _b39, _c11, _d8;
119177
+ var _a212, _b40, _c11, _d8;
119174
119178
  controller.enqueue(chunk);
119175
119179
  const { part } = chunk;
119176
119180
  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") {
@@ -119214,7 +119218,7 @@ var DefaultStreamTextResult = class {
119214
119218
  });
119215
119219
  return;
119216
119220
  }
119217
- activeText.providerMetadata = (_b39 = part.providerMetadata) != null ? _b39 : activeText.providerMetadata;
119221
+ activeText.providerMetadata = (_b40 = part.providerMetadata) != null ? _b40 : activeText.providerMetadata;
119218
119222
  delete activeTextContent[part.id];
119219
119223
  }
119220
119224
  if (part.type === "reasoning-start") {
@@ -119641,7 +119645,7 @@ var DefaultStreamTextResult = class {
119641
119645
  responseMessages,
119642
119646
  usage
119643
119647
  }) {
119644
- var _a212, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i;
119648
+ var _a212, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i;
119645
119649
  const includeRawChunks2 = self2.includeRawChunks;
119646
119650
  const stepTimeoutId = stepTimeoutMs != null ? setTimeout(() => stepAbortController.abort(), stepTimeoutMs) : void 0;
119647
119651
  let chunkTimeoutId = void 0;
@@ -119686,7 +119690,7 @@ var DefaultStreamTextResult = class {
119686
119690
  };
119687
119691
  const promptMessages = await convertToLanguageModelPrompt({
119688
119692
  prompt: {
119689
- system: (_b39 = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b39 : initialPrompt.system,
119693
+ system: (_b40 = prepareStepResult == null ? void 0 : prepareStepResult.system) != null ? _b40 : initialPrompt.system,
119690
119694
  messages: (_c11 = prepareStepResult == null ? void 0 : prepareStepResult.messages) != null ? _c11 : stepInputMessages
119691
119695
  },
119692
119696
  supportedUrls: await stepModel.supportedUrls,
@@ -120276,11 +120280,11 @@ var DefaultStreamTextResult = class {
120276
120280
  );
120277
120281
  }
120278
120282
  get elementStream() {
120279
- var _a212, _b39, _c11;
120283
+ var _a212, _b40, _c11;
120280
120284
  const transform2 = (_a212 = this.outputSpecification) == null ? void 0 : _a212.createElementStreamTransform();
120281
120285
  if (transform2 == null) {
120282
120286
  throw new UnsupportedFunctionalityError({
120283
- functionality: `element streams in ${(_c11 = (_b39 = this.outputSpecification) == null ? void 0 : _b39.name) != null ? _c11 : "text"} mode`
120287
+ functionality: `element streams in ${(_c11 = (_b40 = this.outputSpecification) == null ? void 0 : _b40.name) != null ? _c11 : "text"} mode`
120284
120288
  });
120285
120289
  }
120286
120290
  return createAsyncIterableStream(this.teeStream().pipeThrough(transform2));
@@ -120941,7 +120945,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
120941
120945
  };
120942
120946
  }
120943
120947
  function convertOpenAIChatUsage(usage) {
120944
- var _a51, _b39, _c11, _d8, _e7, _f3;
120948
+ var _a51, _b40, _c11, _d8, _e7, _f3;
120945
120949
  if (usage == null) {
120946
120950
  return {
120947
120951
  inputTokens: {
@@ -120959,7 +120963,7 @@ function convertOpenAIChatUsage(usage) {
120959
120963
  };
120960
120964
  }
120961
120965
  const promptTokens = (_a51 = usage.prompt_tokens) != null ? _a51 : 0;
120962
- const completionTokens = (_b39 = usage.completion_tokens) != null ? _b39 : 0;
120966
+ const completionTokens = (_b40 = usage.completion_tokens) != null ? _b40 : 0;
120963
120967
  const cachedTokens = (_d8 = (_c11 = usage.prompt_tokens_details) == null ? void 0 : _c11.cached_tokens) != null ? _d8 : 0;
120964
120968
  const reasoningTokens = (_f3 = (_e7 = usage.completion_tokens_details) == null ? void 0 : _e7.reasoning_tokens) != null ? _f3 : 0;
120965
120969
  return {
@@ -121020,7 +121024,7 @@ function convertToOpenAIChatMessages({
121020
121024
  messages.push({
121021
121025
  role: "user",
121022
121026
  content: content.map((part, index) => {
121023
- var _a210, _b39, _c11;
121027
+ var _a210, _b40, _c11;
121024
121028
  switch (part.type) {
121025
121029
  case "text": {
121026
121030
  return { type: "text", text: part.text };
@@ -121033,7 +121037,7 @@ function convertToOpenAIChatMessages({
121033
121037
  image_url: {
121034
121038
  url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`,
121035
121039
  // OpenAI specific extension: image detail
121036
- detail: (_b39 = (_a210 = part.providerOptions) == null ? void 0 : _a210.openai) == null ? void 0 : _b39.imageDetail
121040
+ detail: (_b40 = (_a210 = part.providerOptions) == null ? void 0 : _a210.openai) == null ? void 0 : _b40.imageDetail
121037
121041
  }
121038
121042
  };
121039
121043
  } else if (part.mediaType.startsWith("audio/")) {
@@ -121523,7 +121527,7 @@ var OpenAIChatLanguageModel = class {
121523
121527
  toolChoice,
121524
121528
  providerOptions
121525
121529
  }) {
121526
- var _a51, _b39, _c11, _d8, _e7;
121530
+ var _a51, _b40, _c11, _d8, _e7;
121527
121531
  const warnings = [];
121528
121532
  const openaiOptions = (_a51 = await parseProviderOptions({
121529
121533
  provider: "openai",
@@ -121531,7 +121535,7 @@ var OpenAIChatLanguageModel = class {
121531
121535
  schema: openaiLanguageModelChatOptions
121532
121536
  })) != null ? _a51 : {};
121533
121537
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
121534
- const isReasoningModel = (_b39 = openaiOptions.forceReasoning) != null ? _b39 : modelCapabilities.isReasoningModel;
121538
+ const isReasoningModel = (_b40 = openaiOptions.forceReasoning) != null ? _b40 : modelCapabilities.isReasoningModel;
121535
121539
  if (topK != null) {
121536
121540
  warnings.push({ type: "unsupported", feature: "topK" });
121537
121541
  }
@@ -121690,7 +121694,7 @@ var OpenAIChatLanguageModel = class {
121690
121694
  };
121691
121695
  }
121692
121696
  async doGenerate(options) {
121693
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6;
121697
+ var _a51, _b40, _c11, _d8, _e7, _f3, _g6;
121694
121698
  const { args: body, warnings } = await this.getArgs(options);
121695
121699
  const {
121696
121700
  responseHeaders,
@@ -121719,7 +121723,7 @@ var OpenAIChatLanguageModel = class {
121719
121723
  for (const toolCall of (_a51 = choice2.message.tool_calls) != null ? _a51 : []) {
121720
121724
  content.push({
121721
121725
  type: "tool-call",
121722
- toolCallId: (_b39 = toolCall.id) != null ? _b39 : generateId(),
121726
+ toolCallId: (_b40 = toolCall.id) != null ? _b40 : generateId(),
121723
121727
  toolName: toolCall.function.name,
121724
121728
  input: toolCall.function.arguments
121725
121729
  });
@@ -121801,7 +121805,7 @@ var OpenAIChatLanguageModel = class {
121801
121805
  controller.enqueue({ type: "stream-start", warnings });
121802
121806
  },
121803
121807
  transform(chunk, controller) {
121804
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2;
121808
+ var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2;
121805
121809
  if (options.includeRawChunks) {
121806
121810
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
121807
121811
  }
@@ -121829,7 +121833,7 @@ var OpenAIChatLanguageModel = class {
121829
121833
  if (value.usage != null) {
121830
121834
  usage = value.usage;
121831
121835
  if (((_a51 = value.usage.completion_tokens_details) == null ? void 0 : _a51.accepted_prediction_tokens) != null) {
121832
- providerMetadata.openai.acceptedPredictionTokens = (_b39 = value.usage.completion_tokens_details) == null ? void 0 : _b39.accepted_prediction_tokens;
121836
+ providerMetadata.openai.acceptedPredictionTokens = (_b40 = value.usage.completion_tokens_details) == null ? void 0 : _b40.accepted_prediction_tokens;
121833
121837
  }
121834
121838
  if (((_c11 = value.usage.completion_tokens_details) == null ? void 0 : _c11.rejected_prediction_tokens) != null) {
121835
121839
  providerMetadata.openai.rejectedPredictionTokens = (_d8 = value.usage.completion_tokens_details) == null ? void 0 : _d8.rejected_prediction_tokens;
@@ -121979,7 +121983,7 @@ var OpenAIChatLanguageModel = class {
121979
121983
  }
121980
121984
  };
121981
121985
  function convertOpenAICompletionUsage(usage) {
121982
- var _a51, _b39, _c11, _d8;
121986
+ var _a51, _b40, _c11, _d8;
121983
121987
  if (usage == null) {
121984
121988
  return {
121985
121989
  inputTokens: {
@@ -121997,7 +122001,7 @@ function convertOpenAICompletionUsage(usage) {
121997
122001
  };
121998
122002
  }
121999
122003
  const promptTokens = (_a51 = usage.prompt_tokens) != null ? _a51 : 0;
122000
- const completionTokens = (_b39 = usage.completion_tokens) != null ? _b39 : 0;
122004
+ const completionTokens = (_b40 = usage.completion_tokens) != null ? _b40 : 0;
122001
122005
  return {
122002
122006
  inputTokens: {
122003
122007
  total: (_c11 = usage.prompt_tokens) != null ? _c11 : void 0,
@@ -122593,7 +122597,7 @@ var OpenAIImageModel = class {
122593
122597
  headers,
122594
122598
  abortSignal
122595
122599
  }) {
122596
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3;
122600
+ var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3;
122597
122601
  const warnings = [];
122598
122602
  if (aspectRatio != null) {
122599
122603
  warnings.push({
@@ -122605,7 +122609,7 @@ var OpenAIImageModel = class {
122605
122609
  if (seed != null) {
122606
122610
  warnings.push({ type: "unsupported", feature: "seed" });
122607
122611
  }
122608
- const currentDate = (_c11 = (_b39 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
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();
122609
122613
  if (files != null) {
122610
122614
  const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi({
122611
122615
  url: this.config.url({
@@ -123311,7 +123315,7 @@ var openaiTools = {
123311
123315
  mcp
123312
123316
  };
123313
123317
  function convertOpenAIResponsesUsage(usage) {
123314
- var _a51, _b39, _c11, _d8;
123318
+ var _a51, _b40, _c11, _d8;
123315
123319
  if (usage == null) {
123316
123320
  return {
123317
123321
  inputTokens: {
@@ -123330,7 +123334,7 @@ function convertOpenAIResponsesUsage(usage) {
123330
123334
  }
123331
123335
  const inputTokens = usage.input_tokens;
123332
123336
  const outputTokens = usage.output_tokens;
123333
- const cachedTokens = (_b39 = (_a51 = usage.input_tokens_details) == null ? void 0 : _a51.cached_tokens) != null ? _b39 : 0;
123337
+ const cachedTokens = (_b40 = (_a51 = usage.input_tokens_details) == null ? void 0 : _a51.cached_tokens) != null ? _b40 : 0;
123334
123338
  const reasoningTokens = (_d8 = (_c11 = usage.output_tokens_details) == null ? void 0 : _c11.reasoning_tokens) != null ? _d8 : 0;
123335
123339
  return {
123336
123340
  inputTokens: {
@@ -123364,7 +123368,7 @@ async function convertToOpenAIResponsesInput({
123364
123368
  hasApplyPatchTool = false,
123365
123369
  customProviderToolNames
123366
123370
  }) {
123367
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
123371
+ var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
123368
123372
  const input = [];
123369
123373
  const warnings = [];
123370
123374
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -123464,7 +123468,7 @@ async function convertToOpenAIResponsesInput({
123464
123468
  break;
123465
123469
  }
123466
123470
  case "tool-call": {
123467
- const id = (_f3 = (_c11 = (_b39 = part.providerOptions) == null ? void 0 : _b39[providerOptionsName]) == null ? void 0 : _c11.itemId) != null ? _f3 : (_e7 = (_d8 = part.providerMetadata) == null ? void 0 : _d8[providerOptionsName]) == null ? void 0 : _e7.itemId;
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;
123468
123472
  if (hasConversation && id != null) {
123469
123473
  break;
123470
123474
  }
@@ -125115,13 +125119,13 @@ function mapShellSkills(skills) {
125115
125119
  );
125116
125120
  }
125117
125121
  function extractApprovalRequestIdToToolCallIdMapping(prompt) {
125118
- var _a51, _b39;
125122
+ var _a51, _b40;
125119
125123
  const mapping = {};
125120
125124
  for (const message of prompt) {
125121
125125
  if (message.role !== "assistant") continue;
125122
125126
  for (const part of message.content) {
125123
125127
  if (part.type !== "tool-call") continue;
125124
- const approvalRequestId = (_b39 = (_a51 = part.providerOptions) == null ? void 0 : _a51.openai) == null ? void 0 : _b39.approvalRequestId;
125128
+ const approvalRequestId = (_b40 = (_a51 = part.providerOptions) == null ? void 0 : _a51.openai) == null ? void 0 : _b40.approvalRequestId;
125125
125129
  if (approvalRequestId != null) {
125126
125130
  mapping[approvalRequestId] = part.toolCallId;
125127
125131
  }
@@ -125157,7 +125161,7 @@ var OpenAIResponsesLanguageModel = class {
125157
125161
  toolChoice,
125158
125162
  responseFormat
125159
125163
  }) {
125160
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i;
125164
+ var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i;
125161
125165
  const warnings = [];
125162
125166
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
125163
125167
  if (topK != null) {
@@ -125225,7 +125229,7 @@ var OpenAIResponsesLanguageModel = class {
125225
125229
  const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
125226
125230
  prompt,
125227
125231
  toolNameMapping,
125228
- systemMessageMode: (_b39 = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _b39 : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
125232
+ systemMessageMode: (_b40 = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _b40 : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
125229
125233
  providerOptionsName,
125230
125234
  fileIdPrefixes: this.config.fileIdPrefixes,
125231
125235
  store: (_c11 = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _c11 : true,
@@ -125385,7 +125389,7 @@ var OpenAIResponsesLanguageModel = class {
125385
125389
  };
125386
125390
  }
125387
125391
  async doGenerate(options) {
125388
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r2, _s, _t, _u, _v, _w, _x, _y;
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;
125389
125393
  const {
125390
125394
  args: body,
125391
125395
  warnings,
@@ -125521,7 +125525,7 @@ var OpenAIResponsesLanguageModel = class {
125521
125525
  }
125522
125526
  case "message": {
125523
125527
  for (const contentPart of part.content) {
125524
- if (((_c11 = (_b39 = options.providerOptions) == null ? void 0 : _b39[providerOptionsName]) == null ? void 0 : _c11.logprobs) && contentPart.logprobs) {
125528
+ if (((_c11 = (_b40 = options.providerOptions) == null ? void 0 : _b40[providerOptionsName]) == null ? void 0 : _c11.logprobs) && contentPart.logprobs) {
125525
125529
  logprobs.push(contentPart.logprobs);
125526
125530
  }
125527
125531
  const providerMetadata2 = {
@@ -125687,7 +125691,7 @@ var OpenAIResponsesLanguageModel = class {
125687
125691
  }
125688
125692
  case "mcp_approval_request": {
125689
125693
  const approvalRequestId = (_q2 = part.approval_request_id) != null ? _q2 : part.id;
125690
- const dummyToolCallId = (_t = (_s = (_r2 = this.config).generateId) == null ? void 0 : _s.call(_r2)) != null ? _t : generateId();
125694
+ const dummyToolCallId = (_t = (_s = (_r = this.config).generateId) == null ? void 0 : _s.call(_r)) != null ? _t : generateId();
125691
125695
  const toolName = `mcp.${part.name}`;
125692
125696
  content.push({
125693
125697
  type: "tool-call",
@@ -125868,7 +125872,7 @@ var OpenAIResponsesLanguageModel = class {
125868
125872
  controller.enqueue({ type: "stream-start", warnings });
125869
125873
  },
125870
125874
  transform(chunk, controller) {
125871
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r2, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
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;
125872
125876
  if (options.includeRawChunks) {
125873
125877
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
125874
125878
  }
@@ -126046,7 +126050,7 @@ var OpenAIResponsesLanguageModel = class {
126046
126050
  providerMetadata: {
126047
126051
  [providerOptionsName]: {
126048
126052
  itemId: value.item.id,
126049
- reasoningEncryptedContent: (_b39 = value.item.encrypted_content) != null ? _b39 : null
126053
+ reasoningEncryptedContent: (_b40 = value.item.encrypted_content) != null ? _b40 : null
126050
126054
  }
126051
126055
  }
126052
126056
  });
@@ -126516,7 +126520,7 @@ var OpenAIResponsesLanguageModel = class {
126516
126520
  } else if (isResponseFinishedChunk(value)) {
126517
126521
  finishReason = {
126518
126522
  unified: mapOpenAIResponseFinishReason({
126519
- finishReason: (_r2 = value.response.incomplete_details) == null ? void 0 : _r2.reason,
126523
+ finishReason: (_r = value.response.incomplete_details) == null ? void 0 : _r.reason,
126520
126524
  hasFunctionCall
126521
126525
  }),
126522
126526
  raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
@@ -126752,8 +126756,8 @@ var OpenAISpeechModel = class {
126752
126756
  };
126753
126757
  }
126754
126758
  async doGenerate(options) {
126755
- var _a51, _b39, _c11;
126756
- const currentDate = (_c11 = (_b39 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
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();
126757
126761
  const { requestBody, warnings } = await this.getArgs(options);
126758
126762
  const {
126759
126763
  value: audio,
@@ -126964,8 +126968,8 @@ var OpenAITranscriptionModel = class {
126964
126968
  };
126965
126969
  }
126966
126970
  async doGenerate(options) {
126967
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2;
126968
- const currentDate = (_c11 = (_b39 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
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();
126969
126973
  const { formData, warnings } = await this.getArgs(options);
126970
126974
  const {
126971
126975
  value: response,
@@ -127011,14 +127015,14 @@ var OpenAITranscriptionModel = class {
127011
127015
  };
127012
127016
  var VERSION6 = true ? "3.0.39" : "0.0.0-test";
127013
127017
  function createOpenAI(options = {}) {
127014
- var _a51, _b39;
127018
+ var _a51, _b40;
127015
127019
  const baseURL = (_a51 = withoutTrailingSlash(
127016
127020
  loadOptionalSetting({
127017
127021
  settingValue: options.baseURL,
127018
127022
  environmentVariableName: "OPENAI_BASE_URL"
127019
127023
  })
127020
127024
  )) != null ? _a51 : "https://api.openai.com/v1";
127021
- const providerName = (_b39 = options.name) != null ? _b39 : "openai";
127025
+ const providerName = (_b40 = options.name) != null ? _b40 : "openai";
127022
127026
  const getHeaders = () => withUserAgentSuffix(
127023
127027
  {
127024
127028
  Authorization: `Bearer ${loadApiKey({
@@ -128453,9 +128457,9 @@ function convertAnthropicMessagesUsage({
128453
128457
  usage,
128454
128458
  rawUsage
128455
128459
  }) {
128456
- var _a51, _b39;
128460
+ var _a51, _b40;
128457
128461
  const cacheCreationTokens = (_a51 = usage.cache_creation_input_tokens) != null ? _a51 : 0;
128458
- const cacheReadTokens = (_b39 = usage.cache_read_input_tokens) != null ? _b39 : 0;
128462
+ const cacheReadTokens = (_b40 = usage.cache_read_input_tokens) != null ? _b40 : 0;
128459
128463
  let inputTokens;
128460
128464
  let outputTokens;
128461
128465
  if (usage.iterations && usage.iterations.length > 0) {
@@ -128695,7 +128699,7 @@ async function convertToAnthropicMessagesPrompt({
128695
128699
  cacheControlValidator,
128696
128700
  toolNameMapping
128697
128701
  }) {
128698
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r2;
128702
+ var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2, _r;
128699
128703
  const betas = /* @__PURE__ */ new Set();
128700
128704
  const blocks = groupIntoBlocks(prompt);
128701
128705
  const validator = cacheControlValidator || new CacheControlValidator();
@@ -128799,7 +128803,7 @@ async function convertToAnthropicMessagesPrompt({
128799
128803
  media_type: "application/pdf",
128800
128804
  data: convertToBase64(part.data)
128801
128805
  },
128802
- title: (_b39 = metadata.title) != null ? _b39 : part.filename,
128806
+ title: (_b40 = metadata.title) != null ? _b40 : part.filename,
128803
128807
  ...metadata.context && { context: metadata.context },
128804
128808
  ...enableCitations && {
128805
128809
  citations: { enabled: true }
@@ -129290,7 +129294,7 @@ async function convertToAnthropicMessagesPrompt({
129290
129294
  tool_use_id: part.toolCallId,
129291
129295
  content: {
129292
129296
  type: "web_fetch_tool_result_error",
129293
- error_code: (_r2 = errorValue.errorCode) != null ? _r2 : "unknown"
129297
+ error_code: (_r = errorValue.errorCode) != null ? _r : "unknown"
129294
129298
  },
129295
129299
  cache_control: cacheControl
129296
129300
  });
@@ -129543,8 +129547,8 @@ var AnthropicMessagesLanguageModel = class {
129543
129547
  return dotIndex === -1 ? provider : provider.substring(0, dotIndex);
129544
129548
  }
129545
129549
  get supportedUrls() {
129546
- var _a51, _b39, _c11;
129547
- return (_c11 = (_b39 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : {};
129550
+ var _a51, _b40, _c11;
129551
+ return (_c11 = (_b40 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : {};
129548
129552
  }
129549
129553
  async getArgs({
129550
129554
  userSuppliedBetas,
@@ -129563,7 +129567,7 @@ var AnthropicMessagesLanguageModel = class {
129563
129567
  providerOptions,
129564
129568
  stream
129565
129569
  }) {
129566
- var _a51, _b39, _c11, _d8, _e7, _f3;
129570
+ var _a51, _b40, _c11, _d8, _e7, _f3;
129567
129571
  const warnings = [];
129568
129572
  if (frequencyPenalty != null) {
129569
129573
  warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
@@ -129621,7 +129625,7 @@ var AnthropicMessagesLanguageModel = class {
129621
129625
  isKnownModel
129622
129626
  } = getModelCapabilities(this.modelId);
129623
129627
  const supportsStructuredOutput = ((_a51 = this.config.supportsNativeStructuredOutput) != null ? _a51 : true) && modelSupportsStructuredOutput;
129624
- const structureOutputMode = (_b39 = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _b39 : "auto";
129628
+ const structureOutputMode = (_b40 = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _b40 : "auto";
129625
129629
  const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
129626
129630
  const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
129627
129631
  type: "function",
@@ -129919,10 +129923,10 @@ var AnthropicMessagesLanguageModel = class {
129919
129923
  );
129920
129924
  }
129921
129925
  async getBetasFromHeaders(requestHeaders) {
129922
- var _a51, _b39;
129926
+ var _a51, _b40;
129923
129927
  const configHeaders = await resolve2(this.config.headers);
129924
129928
  const configBetaHeader = (_a51 = configHeaders["anthropic-beta"]) != null ? _a51 : "";
129925
- const requestBetaHeader = (_b39 = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b39 : "";
129929
+ const requestBetaHeader = (_b40 = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b40 : "";
129926
129930
  return new Set(
129927
129931
  [
129928
129932
  ...configBetaHeader.toLowerCase().split(","),
@@ -129931,16 +129935,16 @@ var AnthropicMessagesLanguageModel = class {
129931
129935
  );
129932
129936
  }
129933
129937
  buildRequestUrl(isStreaming) {
129934
- var _a51, _b39, _c11;
129935
- return (_c11 = (_b39 = (_a51 = this.config).buildRequestUrl) == null ? void 0 : _b39.call(_a51, this.config.baseURL, isStreaming)) != null ? _c11 : `${this.config.baseURL}/messages`;
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`;
129936
129940
  }
129937
129941
  transformRequestBody(args) {
129938
- var _a51, _b39, _c11;
129939
- return (_c11 = (_b39 = (_a51 = this.config).transformRequestBody) == null ? void 0 : _b39.call(_a51, args)) != null ? _c11 : args;
129942
+ var _a51, _b40, _c11;
129943
+ return (_c11 = (_b40 = (_a51 = this.config).transformRequestBody) == null ? void 0 : _b40.call(_a51, args)) != null ? _c11 : args;
129940
129944
  }
129941
129945
  extractCitationDocuments(prompt) {
129942
129946
  const isCitationPart = (part) => {
129943
- var _a51, _b39;
129947
+ var _a51, _b40;
129944
129948
  if (part.type !== "file") {
129945
129949
  return false;
129946
129950
  }
@@ -129949,7 +129953,7 @@ var AnthropicMessagesLanguageModel = class {
129949
129953
  }
129950
129954
  const anthropic2 = (_a51 = part.providerOptions) == null ? void 0 : _a51.anthropic;
129951
129955
  const citationsConfig = anthropic2 == null ? void 0 : anthropic2.citations;
129952
- return (_b39 = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b39 : false;
129956
+ return (_b40 = citationsConfig == null ? void 0 : citationsConfig.enabled) != null ? _b40 : false;
129953
129957
  };
129954
129958
  return prompt.filter((message) => message.role === "user").flatMap((message) => message.content).filter(isCitationPart).map((part) => {
129955
129959
  var _a51;
@@ -129962,7 +129966,7 @@ var AnthropicMessagesLanguageModel = class {
129962
129966
  });
129963
129967
  }
129964
129968
  async doGenerate(options) {
129965
- var _a51, _b39, _c11, _d8, _e7, _f3;
129969
+ var _a51, _b40, _c11, _d8, _e7, _f3;
129966
129970
  const {
129967
129971
  args,
129968
129972
  warnings,
@@ -130210,7 +130214,7 @@ var AnthropicMessagesLanguageModel = class {
130210
130214
  title: result.title,
130211
130215
  providerMetadata: {
130212
130216
  anthropic: {
130213
- pageAge: (_b39 = result.page_age) != null ? _b39 : null
130217
+ pageAge: (_b40 = result.page_age) != null ? _b40 : null
130214
130218
  }
130215
130219
  }
130216
130220
  });
@@ -130366,7 +130370,7 @@ var AnthropicMessagesLanguageModel = class {
130366
130370
  };
130367
130371
  }
130368
130372
  async doStream(options) {
130369
- var _a51, _b39;
130373
+ var _a51, _b40;
130370
130374
  const {
130371
130375
  args: body,
130372
130376
  warnings,
@@ -131095,7 +131099,7 @@ var AnthropicMessagesLanguageModel = class {
131095
131099
  if (((_a51 = result.value) == null ? void 0 : _a51.type) === "raw") {
131096
131100
  result = await firstChunkReader.read();
131097
131101
  }
131098
- if (((_b39 = result.value) == null ? void 0 : _b39.type) === "error") {
131102
+ if (((_b40 = result.value) == null ? void 0 : _b40.type) === "error") {
131099
131103
  const error48 = result.value.error;
131100
131104
  throw new APICallError({
131101
131105
  message: error48.message,
@@ -131724,14 +131728,14 @@ var anthropicTools = {
131724
131728
  toolSearchBm25_20251119
131725
131729
  };
131726
131730
  function createAnthropic(options = {}) {
131727
- var _a51, _b39;
131731
+ var _a51, _b40;
131728
131732
  const baseURL = (_a51 = withoutTrailingSlash(
131729
131733
  loadOptionalSetting({
131730
131734
  settingValue: options.baseURL,
131731
131735
  environmentVariableName: "ANTHROPIC_BASE_URL"
131732
131736
  })
131733
131737
  )) != null ? _a51 : "https://api.anthropic.com/v1";
131734
- const providerName = (_b39 = options.name) != null ? _b39 : "anthropic.messages";
131738
+ const providerName = (_b40 = options.name) != null ? _b40 : "anthropic.messages";
131735
131739
  if (options.apiKey && options.authToken) {
131736
131740
  throw new InvalidArgumentError({
131737
131741
  argument: "apiKey/authToken",
@@ -131952,7 +131956,7 @@ var googleGenerativeAISingleEmbeddingResponseSchema = lazySchema(
131952
131956
  )
131953
131957
  );
131954
131958
  function convertGoogleGenerativeAIUsage(usage) {
131955
- var _a51, _b39, _c11, _d8;
131959
+ var _a51, _b40, _c11, _d8;
131956
131960
  if (usage == null) {
131957
131961
  return {
131958
131962
  inputTokens: {
@@ -131970,7 +131974,7 @@ function convertGoogleGenerativeAIUsage(usage) {
131970
131974
  };
131971
131975
  }
131972
131976
  const promptTokens = (_a51 = usage.promptTokenCount) != null ? _a51 : 0;
131973
- const candidatesTokens = (_b39 = usage.candidatesTokenCount) != null ? _b39 : 0;
131977
+ const candidatesTokens = (_b40 = usage.candidatesTokenCount) != null ? _b40 : 0;
131974
131978
  const cachedContentTokens = (_c11 = usage.cachedContentTokenCount) != null ? _c11 : 0;
131975
131979
  const thoughtsTokens = (_d8 = usage.thoughtsTokenCount) != null ? _d8 : 0;
131976
131980
  return {
@@ -132103,12 +132107,12 @@ function isEmptyObjectSchema(jsonSchema2) {
132103
132107
  return jsonSchema2 != null && typeof jsonSchema2 === "object" && jsonSchema2.type === "object" && (jsonSchema2.properties == null || Object.keys(jsonSchema2.properties).length === 0) && !jsonSchema2.additionalProperties;
132104
132108
  }
132105
132109
  function convertToGoogleGenerativeAIMessages(prompt, options) {
132106
- var _a51, _b39, _c11;
132110
+ var _a51, _b40, _c11;
132107
132111
  const systemInstructionParts = [];
132108
132112
  const contents = [];
132109
132113
  let systemMessagesAllowed = true;
132110
132114
  const isGemmaModel = (_a51 = options == null ? void 0 : options.isGemmaModel) != null ? _a51 : false;
132111
- const providerOptionsName = (_b39 = options == null ? void 0 : options.providerOptionsName) != null ? _b39 : "google";
132115
+ const providerOptionsName = (_b40 = options == null ? void 0 : options.providerOptionsName) != null ? _b40 : "google";
132112
132116
  for (const { role, content } of prompt) {
132113
132117
  switch (role) {
132114
132118
  case "system": {
@@ -132628,8 +132632,8 @@ var GoogleGenerativeAILanguageModel = class {
132628
132632
  return this.config.provider;
132629
132633
  }
132630
132634
  get supportedUrls() {
132631
- var _a51, _b39, _c11;
132632
- return (_c11 = (_b39 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : {};
132635
+ var _a51, _b40, _c11;
132636
+ return (_c11 = (_b40 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : {};
132633
132637
  }
132634
132638
  async getArgs({
132635
132639
  prompt,
@@ -132730,7 +132734,7 @@ var GoogleGenerativeAILanguageModel = class {
132730
132734
  };
132731
132735
  }
132732
132736
  async doGenerate(options) {
132733
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2;
132737
+ var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2;
132734
132738
  const { args, warnings, providerOptionsName } = await this.getArgs(options);
132735
132739
  const mergedHeaders = combineHeaders(
132736
132740
  await resolve2(this.config.headers),
@@ -132753,7 +132757,7 @@ var GoogleGenerativeAILanguageModel = class {
132753
132757
  });
132754
132758
  const candidate = response.candidates[0];
132755
132759
  const content = [];
132756
- const parts = (_b39 = (_a51 = candidate.content) == null ? void 0 : _a51.parts) != null ? _b39 : [];
132760
+ const parts = (_b40 = (_a51 = candidate.content) == null ? void 0 : _a51.parts) != null ? _b40 : [];
132757
132761
  const usageMetadata = response.usageMetadata;
132758
132762
  let lastCodeExecutionToolCallId;
132759
132763
  for (const part of parts) {
@@ -132897,7 +132901,7 @@ var GoogleGenerativeAILanguageModel = class {
132897
132901
  controller.enqueue({ type: "stream-start", warnings });
132898
132902
  },
132899
132903
  transform(chunk, controller) {
132900
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2;
132904
+ var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2;
132901
132905
  if (options.includeRawChunks) {
132902
132906
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
132903
132907
  }
@@ -132928,7 +132932,7 @@ var GoogleGenerativeAILanguageModel = class {
132928
132932
  }
132929
132933
  }
132930
132934
  if (content != null) {
132931
- const parts = (_b39 = content.parts) != null ? _b39 : [];
132935
+ const parts = (_b40 = content.parts) != null ? _b40 : [];
132932
132936
  for (const part of parts) {
132933
132937
  if ("executableCode" in part && ((_c11 = part.executableCode) == null ? void 0 : _c11.code)) {
132934
132938
  const toolCallId = generateId3();
@@ -133129,7 +133133,7 @@ function extractSources({
133129
133133
  groundingMetadata,
133130
133134
  generateId: generateId3
133131
133135
  }) {
133132
- var _a51, _b39, _c11, _d8, _e7;
133136
+ var _a51, _b40, _c11, _d8, _e7;
133133
133137
  if (!(groundingMetadata == null ? void 0 : groundingMetadata.groundingChunks)) {
133134
133138
  return void 0;
133135
133139
  }
@@ -133152,7 +133156,7 @@ function extractSources({
133152
133156
  sourceType: "url",
133153
133157
  id: generateId3(),
133154
133158
  url: uri,
133155
- title: (_b39 = chunk.retrievedContext.title) != null ? _b39 : void 0
133159
+ title: (_b40 = chunk.retrievedContext.title) != null ? _b40 : void 0
133156
133160
  });
133157
133161
  } else if (uri) {
133158
133162
  const title = (_c11 = chunk.retrievedContext.title) != null ? _c11 : "Unknown Document";
@@ -133498,7 +133502,7 @@ var GoogleGenerativeAIImageModel = class {
133498
133502
  return this.doGenerateImagen(options);
133499
133503
  }
133500
133504
  async doGenerateImagen(options) {
133501
- var _a51, _b39, _c11;
133505
+ var _a51, _b40, _c11;
133502
133506
  const {
133503
133507
  prompt,
133504
133508
  n: n3 = 1,
@@ -133541,7 +133545,7 @@ var GoogleGenerativeAIImageModel = class {
133541
133545
  providerOptions,
133542
133546
  schema: googleImageModelOptionsSchema
133543
133547
  });
133544
- const currentDate = (_c11 = (_b39 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
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();
133545
133549
  const parameters = {
133546
133550
  sampleCount: n3
133547
133551
  };
@@ -133586,7 +133590,7 @@ var GoogleGenerativeAIImageModel = class {
133586
133590
  };
133587
133591
  }
133588
133592
  async doGenerateGemini(options) {
133589
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i;
133593
+ var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i;
133590
133594
  const {
133591
133595
  prompt,
133592
133596
  n: n3,
@@ -133646,7 +133650,7 @@ var GoogleGenerativeAIImageModel = class {
133646
133650
  baseURL: this.config.baseURL,
133647
133651
  headers: (_a51 = this.config.headers) != null ? _a51 : {},
133648
133652
  fetch: this.config.fetch,
133649
- generateId: (_b39 = this.config.generateId) != null ? _b39 : generateId
133653
+ generateId: (_b40 = this.config.generateId) != null ? _b40 : generateId
133650
133654
  });
133651
133655
  const result = await languageModel.doGenerate({
133652
133656
  prompt: languageModelPrompt,
@@ -133722,8 +133726,8 @@ var GoogleGenerativeAIVideoModel = class {
133722
133726
  return 4;
133723
133727
  }
133724
133728
  async doGenerate(options) {
133725
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2;
133726
- const currentDate = (_c11 = (_b39 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
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();
133727
133731
  const warnings = [];
133728
133732
  const googleOptions = await parseProviderOptions({
133729
133733
  provider: "google",
@@ -133957,9 +133961,9 @@ var googleVideoModelOptionsSchema = lazySchema(
133957
133961
  )
133958
133962
  );
133959
133963
  function createGoogleGenerativeAI(options = {}) {
133960
- var _a51, _b39;
133964
+ var _a51, _b40;
133961
133965
  const baseURL = (_a51 = withoutTrailingSlash(options.baseURL)) != null ? _a51 : "https://generativelanguage.googleapis.com/v1beta";
133962
- const providerName = (_b39 = options.name) != null ? _b39 : "google.generative-ai";
133966
+ const providerName = (_b40 = options.name) != null ? _b40 : "google.generative-ai";
133963
133967
  const getHeaders = () => withUserAgentSuffix(
133964
133968
  {
133965
133969
  "x-goog-api-key": loadApiKey({
@@ -134300,7 +134304,7 @@ var OllamaCompletionLanguageModel = class {
134300
134304
  };
134301
134305
  }
134302
134306
  async doGenerate(options) {
134303
- var _a51, _b39;
134307
+ var _a51, _b40;
134304
134308
  const { args: body, warnings } = this.getArgs(options);
134305
134309
  const {
134306
134310
  responseHeaders,
@@ -134337,7 +134341,7 @@ var OllamaCompletionLanguageModel = class {
134337
134341
  cacheWrite: void 0
134338
134342
  },
134339
134343
  outputTokens: {
134340
- total: (_b39 = typedResponse.eval_count) != null ? _b39 : 0,
134344
+ total: (_b40 = typedResponse.eval_count) != null ? _b40 : 0,
134341
134345
  text: void 0,
134342
134346
  reasoning: void 0
134343
134347
  }
@@ -134471,13 +134475,13 @@ var ollamaEmbeddingProviderOptions = external_exports.object({
134471
134475
  var OllamaEmbeddingModel = class {
134472
134476
  constructor(modelId, settings, config2) {
134473
134477
  this.specificationVersion = "v3";
134474
- var _a51, _b39;
134478
+ var _a51, _b40;
134475
134479
  this.modelId = modelId;
134476
134480
  this.settings = settings;
134477
134481
  this.config = config2;
134478
134482
  this.provider = config2.provider;
134479
134483
  this.maxEmbeddingsPerCall = (_a51 = settings.maxEmbeddingsPerCall) != null ? _a51 : 2048;
134480
- this.supportsParallelCalls = (_b39 = settings.supportsParallelCalls) != null ? _b39 : true;
134484
+ this.supportsParallelCalls = (_b40 = settings.supportsParallelCalls) != null ? _b40 : true;
134481
134485
  }
134482
134486
  getArgs({
134483
134487
  values
@@ -134498,7 +134502,7 @@ var OllamaEmbeddingModel = class {
134498
134502
  abortSignal,
134499
134503
  providerOptions
134500
134504
  }) {
134501
- var _a51, _b39, _c11;
134505
+ var _a51, _b40, _c11;
134502
134506
  if (this.maxEmbeddingsPerCall && values.length > this.maxEmbeddingsPerCall) {
134503
134507
  throw new TooManyEmbeddingValuesForCallError({
134504
134508
  provider: this.provider,
@@ -134513,7 +134517,7 @@ var OllamaEmbeddingModel = class {
134513
134517
  schema: ollamaEmbeddingProviderOptions
134514
134518
  });
134515
134519
  const dimensions = (_a51 = ollamaOptions == null ? void 0 : ollamaOptions.dimensions) != null ? _a51 : this.settings.dimensions;
134516
- const truncate = (_b39 = ollamaOptions == null ? void 0 : ollamaOptions.truncate) != null ? _b39 : this.settings.truncate;
134520
+ const truncate = (_b40 = ollamaOptions == null ? void 0 : ollamaOptions.truncate) != null ? _b40 : this.settings.truncate;
134517
134521
  const keepAlive = (_c11 = ollamaOptions == null ? void 0 : ollamaOptions.keepAlive) != null ? _c11 : this.settings.keepAlive;
134518
134522
  const body = {
134519
134523
  model: this.modelId,
@@ -134599,7 +134603,7 @@ var OllamaResponseProcessor = class {
134599
134603
  };
134600
134604
  }
134601
134605
  extractContent(response) {
134602
- var _a51, _b39, _c11, _d8, _e7;
134606
+ var _a51, _b40, _c11, _d8, _e7;
134603
134607
  const content = [];
134604
134608
  const text2 = response.message.content;
134605
134609
  if (text2 != null && text2.length > 0) {
@@ -134618,7 +134622,7 @@ var OllamaResponseProcessor = class {
134618
134622
  for (const toolCall of (_a51 = response.message.tool_calls) != null ? _a51 : []) {
134619
134623
  content.push({
134620
134624
  type: "tool-call",
134621
- toolCallId: (_e7 = toolCall.id) != null ? _e7 : (_d8 = (_c11 = (_b39 = this.config).generateId) == null ? void 0 : _c11.call(_b39)) != null ? _d8 : generateId(),
134625
+ toolCallId: (_e7 = toolCall.id) != null ? _e7 : (_d8 = (_c11 = (_b40 = this.config).generateId) == null ? void 0 : _c11.call(_b40)) != null ? _d8 : generateId(),
134622
134626
  toolName: toolCall.function.name,
134623
134627
  input: JSON.stringify(toolCall.function.arguments)
134624
134628
  });
@@ -134626,7 +134630,7 @@ var OllamaResponseProcessor = class {
134626
134630
  return content;
134627
134631
  }
134628
134632
  extractUsage(response) {
134629
- var _a51, _b39;
134633
+ var _a51, _b40;
134630
134634
  return {
134631
134635
  inputTokens: {
134632
134636
  total: (_a51 = response.prompt_eval_count) != null ? _a51 : 0,
@@ -134635,7 +134639,7 @@ var OllamaResponseProcessor = class {
134635
134639
  cacheWrite: void 0
134636
134640
  },
134637
134641
  outputTokens: {
134638
- total: (_b39 = response.eval_count) != null ? _b39 : 0,
134642
+ total: (_b40 = response.eval_count) != null ? _b40 : 0,
134639
134643
  text: void 0,
134640
134644
  reasoning: void 0
134641
134645
  }
@@ -134839,7 +134843,7 @@ function convertToOllamaResponsesMessages({
134839
134843
  messages.push({
134840
134844
  role: "user",
134841
134845
  content: content.map((part, index) => {
134842
- var _a51, _b39, _c11;
134846
+ var _a51, _b40, _c11;
134843
134847
  switch (part.type) {
134844
134848
  case "text": {
134845
134849
  return { type: "input_text", text: part.text };
@@ -134851,7 +134855,7 @@ function convertToOllamaResponsesMessages({
134851
134855
  type: "input_image",
134852
134856
  image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
134853
134857
  // Ollama specific extension: image detail
134854
- detail: (_b39 = (_a51 = part.providerOptions) == null ? void 0 : _a51.ollama) == null ? void 0 : _b39.imageDetail
134858
+ detail: (_b40 = (_a51 = part.providerOptions) == null ? void 0 : _a51.ollama) == null ? void 0 : _b40.imageDetail
134855
134859
  };
134856
134860
  } else if (part.mediaType === "application/pdf") {
134857
134861
  if (part.data instanceof URL) {
@@ -135095,7 +135099,7 @@ var OllamaRequestBuilder = class {
135095
135099
  responseFormat,
135096
135100
  ollamaOptions
135097
135101
  }) {
135098
- var _a51, _b39;
135102
+ var _a51, _b40;
135099
135103
  return {
135100
135104
  model: modelId,
135101
135105
  messages: convertToOllamaChatMessages({
@@ -135109,7 +135113,7 @@ var OllamaRequestBuilder = class {
135109
135113
  format: responseFormat.schema != null ? responseFormat.schema : "json"
135110
135114
  },
135111
135115
  think: (_a51 = ollamaOptions == null ? void 0 : ollamaOptions.think) != null ? _a51 : false,
135112
- options: (_b39 = ollamaOptions == null ? void 0 : ollamaOptions.options) != null ? _b39 : void 0
135116
+ options: (_b40 = ollamaOptions == null ? void 0 : ollamaOptions.options) != null ? _b40 : void 0
135113
135117
  };
135114
135118
  }
135115
135119
  };
@@ -135252,9 +135256,9 @@ var OllamaStreamProcessor = class {
135252
135256
  }
135253
135257
  }
135254
135258
  processToolCalls(delta, controller) {
135255
- var _a51, _b39, _c11, _d8;
135259
+ var _a51, _b40, _c11, _d8;
135256
135260
  for (const toolCall of (_a51 = delta.tool_calls) != null ? _a51 : []) {
135257
- if (((_b39 = toolCall.function) == null ? void 0 : _b39.name) == null) {
135261
+ if (((_b40 = toolCall.function) == null ? void 0 : _b40.name) == null) {
135258
135262
  throw new InvalidResponseDataError({
135259
135263
  data: toolCall,
135260
135264
  message: `Expected 'function.name' to be a string.`
@@ -135266,8 +135270,8 @@ var OllamaStreamProcessor = class {
135266
135270
  }
135267
135271
  }
135268
135272
  emitToolCall(toolCall, controller) {
135269
- var _a51, _b39, _c11, _d8;
135270
- const id = (_d8 = toolCall.id) != null ? _d8 : (_c11 = (_b39 = (_a51 = this.config).generateId) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : generateId();
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();
135271
135275
  controller.enqueue({
135272
135276
  type: "tool-input-start",
135273
135277
  id,
@@ -135388,9 +135392,9 @@ var OllamaResponsesLanguageModel = class {
135388
135392
  }
135389
135393
  };
135390
135394
  function createOllama(options = {}) {
135391
- var _a51, _b39;
135395
+ var _a51, _b40;
135392
135396
  const baseURL = (_a51 = withoutTrailingSlash(options.baseURL)) != null ? _a51 : "http://127.0.0.1:11434/api";
135393
- const providerName = (_b39 = options.name) != null ? _b39 : "ollama";
135397
+ const providerName = (_b40 = options.name) != null ? _b40 : "ollama";
135394
135398
  const getHeaders = () => ({
135395
135399
  "Ollama-Organization": options.organization,
135396
135400
  "Ollama-Project": options.project,
@@ -135448,8 +135452,8 @@ var ollama = createOllama();
135448
135452
 
135449
135453
  // ../../node_modules/.pnpm/@ai-sdk+openai-compatible@1.0.30_zod@4.3.6/node_modules/@ai-sdk/openai-compatible/dist/index.mjs
135450
135454
  function getOpenAIMetadata(message) {
135451
- var _a51, _b39;
135452
- return (_b39 = (_a51 = message == null ? void 0 : message.providerOptions) == null ? void 0 : _a51.openaiCompatible) != null ? _b39 : {};
135455
+ var _a51, _b40;
135456
+ return (_b40 = (_a51 = message == null ? void 0 : message.providerOptions) == null ? void 0 : _a51.openaiCompatible) != null ? _b40 : {};
135453
135457
  }
135454
135458
  function convertToOpenAICompatibleChatMessages(prompt) {
135455
135459
  const messages = [];
@@ -135674,7 +135678,7 @@ var OpenAICompatibleChatLanguageModel = class {
135674
135678
  // type inferred via constructor
135675
135679
  constructor(modelId, config2) {
135676
135680
  this.specificationVersion = "v2";
135677
- var _a51, _b39;
135681
+ var _a51, _b40;
135678
135682
  this.modelId = modelId;
135679
135683
  this.config = config2;
135680
135684
  const errorStructure = (_a51 = config2.errorStructure) != null ? _a51 : defaultOpenAICompatibleErrorStructure;
@@ -135682,7 +135686,7 @@ var OpenAICompatibleChatLanguageModel = class {
135682
135686
  errorStructure.errorSchema
135683
135687
  );
135684
135688
  this.failedResponseHandler = createJsonErrorResponseHandler(errorStructure);
135685
- this.supportsStructuredOutputs = (_b39 = config2.supportsStructuredOutputs) != null ? _b39 : false;
135689
+ this.supportsStructuredOutputs = (_b40 = config2.supportsStructuredOutputs) != null ? _b40 : false;
135686
135690
  }
135687
135691
  get provider() {
135688
135692
  return this.config.provider;
@@ -135691,8 +135695,8 @@ var OpenAICompatibleChatLanguageModel = class {
135691
135695
  return this.config.provider.split(".")[0].trim();
135692
135696
  }
135693
135697
  get supportedUrls() {
135694
- var _a51, _b39, _c11;
135695
- return (_c11 = (_b39 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : {};
135698
+ var _a51, _b40, _c11;
135699
+ return (_c11 = (_b40 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : {};
135696
135700
  }
135697
135701
  async getArgs({
135698
135702
  prompt,
@@ -135709,7 +135713,7 @@ var OpenAICompatibleChatLanguageModel = class {
135709
135713
  toolChoice,
135710
135714
  tools
135711
135715
  }) {
135712
- var _a51, _b39, _c11, _d8;
135716
+ var _a51, _b40, _c11, _d8;
135713
135717
  const warnings = [];
135714
135718
  const compatibleOptions = Object.assign(
135715
135719
  (_a51 = await parseProviderOptions({
@@ -135717,11 +135721,11 @@ var OpenAICompatibleChatLanguageModel = class {
135717
135721
  providerOptions,
135718
135722
  schema: openaiCompatibleProviderOptions
135719
135723
  })) != null ? _a51 : {},
135720
- (_b39 = await parseProviderOptions({
135724
+ (_b40 = await parseProviderOptions({
135721
135725
  provider: this.providerOptionsName,
135722
135726
  providerOptions,
135723
135727
  schema: openaiCompatibleProviderOptions
135724
- })) != null ? _b39 : {}
135728
+ })) != null ? _b40 : {}
135725
135729
  );
135726
135730
  if (topK != null) {
135727
135731
  warnings.push({ type: "unsupported-setting", setting: "topK" });
@@ -135782,7 +135786,7 @@ var OpenAICompatibleChatLanguageModel = class {
135782
135786
  };
135783
135787
  }
135784
135788
  async doGenerate(options) {
135785
- var _a51, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2;
135789
+ var _a51, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m, _n, _o2, _p2, _q2;
135786
135790
  const { args, warnings } = await this.getArgs({ ...options });
135787
135791
  const body = JSON.stringify(args);
135788
135792
  const {
@@ -135820,7 +135824,7 @@ var OpenAICompatibleChatLanguageModel = class {
135820
135824
  for (const toolCall of choice2.message.tool_calls) {
135821
135825
  content.push({
135822
135826
  type: "tool-call",
135823
- toolCallId: (_b39 = toolCall.id) != null ? _b39 : generateId(),
135827
+ toolCallId: (_b40 = toolCall.id) != null ? _b40 : generateId(),
135824
135828
  toolName: toolCall.function.name,
135825
135829
  input: toolCall.function.arguments
135826
135830
  });
@@ -135910,7 +135914,7 @@ var OpenAICompatibleChatLanguageModel = class {
135910
135914
  },
135911
135915
  // TODO we lost type safety on Chunk, most likely due to the error schema. MUST FIX
135912
135916
  transform(chunk, controller) {
135913
- var _a210, _b39, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
135917
+ var _a210, _b40, _c11, _d8, _e7, _f3, _g6, _h2, _i, _j2, _k3, _l, _m;
135914
135918
  if (options.includeRawChunks) {
135915
135919
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
135916
135920
  }
@@ -136003,7 +136007,7 @@ var OpenAICompatibleChatLanguageModel = class {
136003
136007
  message: `Expected 'id' to be a string.`
136004
136008
  });
136005
136009
  }
136006
- if (((_b39 = toolCallDelta.function) == null ? void 0 : _b39.name) == null) {
136010
+ if (((_b40 = toolCallDelta.function) == null ? void 0 : _b40.name) == null) {
136007
136011
  throw new InvalidResponseDataError({
136008
136012
  data: toolCallDelta,
136009
136013
  message: `Expected 'function.name' to be a string.`
@@ -136077,7 +136081,7 @@ var OpenAICompatibleChatLanguageModel = class {
136077
136081
  }
136078
136082
  },
136079
136083
  flush(controller) {
136080
- var _a210, _b39, _c11, _d8, _e7, _f3;
136084
+ var _a210, _b40, _c11, _d8, _e7, _f3;
136081
136085
  if (isActiveReasoning) {
136082
136086
  controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
136083
136087
  }
@@ -136112,7 +136116,7 @@ var OpenAICompatibleChatLanguageModel = class {
136112
136116
  type: "finish",
136113
136117
  finishReason,
136114
136118
  usage: {
136115
- inputTokens: (_b39 = usage.promptTokens) != null ? _b39 : void 0,
136119
+ inputTokens: (_b40 = usage.promptTokens) != null ? _b40 : void 0,
136116
136120
  outputTokens: (_c11 = usage.completionTokens) != null ? _c11 : void 0,
136117
136121
  totalTokens: (_d8 = usage.totalTokens) != null ? _d8 : void 0,
136118
136122
  reasoningTokens: (_e7 = usage.completionTokensDetails.reasoningTokens) != null ? _e7 : void 0,
@@ -136339,8 +136343,8 @@ var OpenAICompatibleCompletionLanguageModel = class {
136339
136343
  return this.config.provider.split(".")[0].trim();
136340
136344
  }
136341
136345
  get supportedUrls() {
136342
- var _a51, _b39, _c11;
136343
- return (_c11 = (_b39 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : {};
136346
+ var _a51, _b40, _c11;
136347
+ return (_c11 = (_b40 = (_a51 = this.config).supportedUrls) == null ? void 0 : _b40.call(_a51)) != null ? _c11 : {};
136344
136348
  }
136345
136349
  async getArgs({
136346
136350
  prompt,
@@ -136408,7 +136412,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
136408
136412
  };
136409
136413
  }
136410
136414
  async doGenerate(options) {
136411
- var _a51, _b39, _c11, _d8, _e7, _f3;
136415
+ var _a51, _b40, _c11, _d8, _e7, _f3;
136412
136416
  const { args, warnings } = await this.getArgs(options);
136413
136417
  const {
136414
136418
  responseHeaders,
@@ -136436,7 +136440,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
136436
136440
  return {
136437
136441
  content,
136438
136442
  usage: {
136439
- inputTokens: (_b39 = (_a51 = response.usage) == null ? void 0 : _a51.prompt_tokens) != null ? _b39 : void 0,
136443
+ inputTokens: (_b40 = (_a51 = response.usage) == null ? void 0 : _a51.prompt_tokens) != null ? _b40 : void 0,
136440
136444
  outputTokens: (_d8 = (_c11 = response.usage) == null ? void 0 : _c11.completion_tokens) != null ? _d8 : void 0,
136441
136445
  totalTokens: (_f3 = (_e7 = response.usage) == null ? void 0 : _e7.total_tokens) != null ? _f3 : void 0
136442
136446
  },
@@ -136486,7 +136490,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
136486
136490
  controller.enqueue({ type: "stream-start", warnings });
136487
136491
  },
136488
136492
  transform(chunk, controller) {
136489
- var _a51, _b39, _c11;
136493
+ var _a51, _b40, _c11;
136490
136494
  if (options.includeRawChunks) {
136491
136495
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
136492
136496
  }
@@ -136514,7 +136518,7 @@ var OpenAICompatibleCompletionLanguageModel = class {
136514
136518
  }
136515
136519
  if (value.usage != null) {
136516
136520
  usage.inputTokens = (_a51 = value.usage.prompt_tokens) != null ? _a51 : void 0;
136517
- usage.outputTokens = (_b39 = value.usage.completion_tokens) != null ? _b39 : void 0;
136521
+ usage.outputTokens = (_b40 = value.usage.completion_tokens) != null ? _b40 : void 0;
136518
136522
  usage.totalTokens = (_c11 = value.usage.total_tokens) != null ? _c11 : void 0;
136519
136523
  }
136520
136524
  const choice2 = value.choices[0];
@@ -136619,18 +136623,18 @@ var OpenAICompatibleEmbeddingModel = class {
136619
136623
  abortSignal,
136620
136624
  providerOptions
136621
136625
  }) {
136622
- var _a51, _b39, _c11;
136626
+ var _a51, _b40, _c11;
136623
136627
  const compatibleOptions = Object.assign(
136624
136628
  (_a51 = await parseProviderOptions({
136625
136629
  provider: "openai-compatible",
136626
136630
  providerOptions,
136627
136631
  schema: openaiCompatibleEmbeddingProviderOptions
136628
136632
  })) != null ? _a51 : {},
136629
- (_b39 = await parseProviderOptions({
136633
+ (_b40 = await parseProviderOptions({
136630
136634
  provider: this.providerOptionsName,
136631
136635
  providerOptions,
136632
136636
  schema: openaiCompatibleEmbeddingProviderOptions
136633
- })) != null ? _b39 : {}
136637
+ })) != null ? _b40 : {}
136634
136638
  );
136635
136639
  if (values.length > this.maxEmbeddingsPerCall) {
136636
136640
  throw new TooManyEmbeddingValuesForCallError({
@@ -136699,7 +136703,7 @@ var OpenAICompatibleImageModel = class {
136699
136703
  headers,
136700
136704
  abortSignal
136701
136705
  }) {
136702
- var _a51, _b39, _c11, _d8, _e7;
136706
+ var _a51, _b40, _c11, _d8, _e7;
136703
136707
  const warnings = [];
136704
136708
  if (aspectRatio != null) {
136705
136709
  warnings.push({
@@ -136711,7 +136715,7 @@ var OpenAICompatibleImageModel = class {
136711
136715
  if (seed != null) {
136712
136716
  warnings.push({ type: "unsupported-setting", setting: "seed" });
136713
136717
  }
136714
- const currentDate = (_c11 = (_b39 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b39.call(_a51)) != null ? _c11 : /* @__PURE__ */ new Date();
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();
136715
136719
  const { value: response, responseHeaders } = await postJsonToApi({
136716
136720
  url: this.config.url({
136717
136721
  path: "/images/generations",
@@ -137041,8 +137045,8 @@ var InfomaniakTranscriptionModel = class {
137041
137045
  throw new Error(`Transcription timed out after ${maxRetries} attempts`);
137042
137046
  }
137043
137047
  async doGenerate(options) {
137044
- var _a51, _b39, _c11, _d8;
137045
- const currentDate = ((_b39 = (_a51 = this.config._internal) == null ? void 0 : _a51.currentDate) == null ? void 0 : _b39.call(_a51)) ?? /* @__PURE__ */ new Date();
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();
137046
137050
  const { formData, warnings } = await this.getArgs(options);
137047
137051
  const { value: batchResponse } = await postFormDataToApi({
137048
137052
  url: this.config.url({
@@ -138096,10 +138100,10 @@ var SkillCallToolRequest = class extends NatsRequest {
138096
138100
  return `*.${type9}.>`;
138097
138101
  }
138098
138102
  /**
138099
- * Subscribe to a specific static tool by name
138103
+ * Subscribe to a specific static tool by name, scoped to a workspace.
138100
138104
  */
138101
- static subscribeToStaticTool(toolName) {
138102
- return `*.${type9}.static.${toolName}.*`;
138105
+ static subscribeToStaticTool(toolName, workspaceId) {
138106
+ return `${workspaceId}.${type9}.static.${toolName}.*`;
138103
138107
  }
138104
138108
  /**
138105
138109
  * Subscribe to all script execution calls
@@ -138108,20 +138112,21 @@ var SkillCallToolRequest = class extends NatsRequest {
138108
138112
  return `*.${type9}.script.>`;
138109
138113
  }
138110
138114
  /**
138111
- * Subscribe to a specific script by ID
138115
+ * Subscribe to a specific script by ID, scoped to a workspace.
138112
138116
  */
138113
- static subscribeToScript(scriptId) {
138114
- return `*.${type9}.script.${scriptId}.*.*`;
138117
+ static subscribeToScript(scriptId, workspaceId) {
138118
+ return `${workspaceId}.${type9}.script.${scriptId}.*.*`;
138115
138119
  }
138116
138120
  /**
138117
- * Subscribe to all script execution calls for a specific runtime
138121
+ * Subscribe to all script execution calls for a specific runtime, scoped to a workspace.
138118
138122
  * Format: {workspaceId}.call-tool.script.{scriptId}.{targetRuntimeId}.{from}
138123
+ * When workspaceId is empty (system runtimes that are cross-workspace), uses a wildcard.
138119
138124
  */
138120
- static subscribeToScriptsForRuntime(runtimeId) {
138121
- return `*.${type9}.script.*.${runtimeId}.*`;
138125
+ static subscribeToScriptsForRuntime(runtimeId, workspaceId) {
138126
+ return workspaceId ? `${workspaceId}.${type9}.script.*.${runtimeId}.*` : `*.${type9}.script.*.${runtimeId}.*`;
138122
138127
  }
138123
- static subscribeToTool(toolId) {
138124
- return `*.${type9}.${toolId}.*`;
138128
+ static subscribeToTool(toolId, workspaceId) {
138129
+ return `${workspaceId}.${type9}.${toolId}.*`;
138125
138130
  }
138126
138131
  static subscribeToToolOnOneRuntime(toolId, workspaceId, runtimeId) {
138127
138132
  return `${workspaceId}.${type9}.${toolId}.${runtimeId}`;
@@ -143735,6 +143740,9 @@ var StdioServerTransport = class {
143735
143740
  // src/services/file.service.ts
143736
143741
  var fs3 = __toESM(require("fs"));
143737
143742
  var path2 = __toESM(require("path"));
143743
+ var import_node_crypto3 = require("node:crypto");
143744
+ var import_promises = require("node:stream/promises");
143745
+ var import_node_stream = require("node:stream");
143738
143746
  var __decorate8 = function(decorators, target, key, desc) {
143739
143747
  var c3 = arguments.length, r2 = c3 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d2;
143740
143748
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
@@ -143758,6 +143766,14 @@ var AssetTooLargeError = class extends Error {
143758
143766
  this.name = "AssetTooLargeError";
143759
143767
  }
143760
143768
  };
143769
+ var AssetTruncatedError = class extends Error {
143770
+ constructor(receivedBytes, expectedBytes) {
143771
+ super(`Asset stream truncated: received ${receivedBytes} bytes, expected ${expectedBytes}`);
143772
+ this.receivedBytes = receivedBytes;
143773
+ this.expectedBytes = expectedBytes;
143774
+ this.name = "AssetTruncatedError";
143775
+ }
143776
+ };
143761
143777
  var FileService = class FileService2 extends Service {
143762
143778
  constructor(loggerService) {
143763
143779
  super();
@@ -143803,41 +143819,42 @@ var FileService = class FileService2 extends Service {
143803
143819
  SKILDER_MAX_FILE_SIZE_MB: String(this.maxFileSizeMB)
143804
143820
  };
143805
143821
  }
143806
- async runGarbageCollection() {
143822
+ async sweepDirByAge(dir, maxAgeMs, label) {
143807
143823
  let deletedCount = 0;
143808
143824
  let bytesFreed = 0;
143809
143825
  try {
143810
- const entries = await fs3.promises.readdir(this.workingDir);
143826
+ const entries = await fs3.promises.readdir(dir);
143811
143827
  const now2 = Date.now();
143812
143828
  for (const entry of entries) {
143813
- const filePath = path2.join(this.workingDir, entry);
143829
+ const filePath = path2.join(dir, entry);
143814
143830
  try {
143815
143831
  const stat = await fs3.promises.lstat(filePath);
143816
143832
  if (stat.isSymbolicLink()) {
143817
- this.logger.warn({ filePath }, "GC removing unexpected symlink from working directory");
143833
+ this.logger.warn({ filePath }, `${label} removing unexpected symlink`);
143834
+ await fs3.promises.unlink(filePath);
143818
143835
  bytesFreed += stat.size;
143819
143836
  deletedCount++;
143837
+ } else if (stat.isFile() && now2 - stat.mtimeMs > maxAgeMs) {
143820
143838
  await fs3.promises.unlink(filePath);
143821
- } else if (stat.isFile() && now2 - stat.mtimeMs > this.gcMaxAgeMs) {
143822
143839
  bytesFreed += stat.size;
143823
143840
  deletedCount++;
143824
- await fs3.promises.unlink(filePath);
143825
- } else if (stat.isDirectory()) {
143826
- this.logger.debug({ filePath }, "GC skipping directory in working directory");
143827
143841
  }
143828
143842
  } catch (error48) {
143829
- if (error48 instanceof Error && "code" in error48 && error48.code === "ENOENT") {
143843
+ if (error48 instanceof Error && "code" in error48 && error48.code === "ENOENT")
143830
143844
  continue;
143831
- }
143832
- this.logger.warn({ filePath, error: error48 }, "GC failed to process file");
143845
+ this.logger.warn({ filePath, error: error48 }, `${label} failed to process file`);
143833
143846
  }
143834
143847
  }
143835
143848
  } catch (error48) {
143836
143849
  if (error48 instanceof Error && "code" in error48 && error48.code === "ENOENT") {
143837
- return;
143850
+ return { deletedCount, bytesFreed };
143838
143851
  }
143839
- this.logger.warn({ error: error48 }, "GC failed to read working directory");
143852
+ this.logger.warn({ error: error48 }, `${label} failed to read directory`);
143840
143853
  }
143854
+ return { deletedCount, bytesFreed };
143855
+ }
143856
+ async runGarbageCollection() {
143857
+ const { deletedCount, bytesFreed } = await this.sweepDirByAge(this.workingDir, this.gcMaxAgeMs, "GC");
143841
143858
  if (deletedCount > 0) {
143842
143859
  this.logger.info({ deletedCount, bytesFreed }, `GC completed: ${deletedCount} file(s) deleted, ${bytesFreed} bytes freed`);
143843
143860
  }
@@ -143892,6 +143909,49 @@ var FileService = class FileService2 extends Service {
143892
143909
  }
143893
143910
  return writeAssetCache(assetPath, buffer, this.getFileConfig());
143894
143911
  }
143912
+ /**
143913
+ * Stream an asset to the local cache without buffering the whole payload in
143914
+ * memory. Used by the runtime's `download_asset` flow to handle large files
143915
+ * (the new content-addressed `/assets/:id` endpoint streams bytes directly).
143916
+ *
143917
+ * Enforces the same size limit as `cacheAsset`. Returns the absolute path
143918
+ * of the cached file.
143919
+ */
143920
+ async cacheAssetFromStream(assetPath, source, options = {}) {
143921
+ const maxBytes = this.maxFileSizeMB * 1024 * 1024;
143922
+ const cachePath = resolveAssetCachePath(assetPath, this.getFileConfig());
143923
+ await fs3.promises.mkdir(path2.dirname(cachePath), { recursive: true, mode: 448 });
143924
+ let totalBytes = 0;
143925
+ const sizeGuard = new import_node_stream.Transform({
143926
+ transform(chunk, _enc, cb) {
143927
+ totalBytes += chunk.length;
143928
+ if (totalBytes > maxBytes) {
143929
+ cb(new AssetTooLargeError(totalBytes, maxBytes));
143930
+ return;
143931
+ }
143932
+ cb(null, chunk);
143933
+ }
143934
+ });
143935
+ const tmpPath = `${cachePath}.${(0, import_node_crypto3.randomUUID)()}.partial`;
143936
+ try {
143937
+ await (0, import_promises.pipeline)(source, sizeGuard, fs3.createWriteStream(tmpPath, { flags: "wx" }));
143938
+ if (options.expectedBytes !== void 0 && totalBytes !== options.expectedBytes) {
143939
+ throw new AssetTruncatedError(totalBytes, options.expectedBytes);
143940
+ }
143941
+ await fs3.promises.rename(tmpPath, cachePath);
143942
+ } catch (err) {
143943
+ await fs3.promises.unlink(tmpPath).catch((unlinkErr) => {
143944
+ if (unlinkErr instanceof Error && "code" in unlinkErr && unlinkErr.code === "ENOENT")
143945
+ return;
143946
+ this.logger.warn({ tmpPath, err: unlinkErr }, "Failed to clean up partial asset cache file");
143947
+ });
143948
+ throw err;
143949
+ }
143950
+ return cachePath;
143951
+ }
143952
+ get maxAssetBytes() {
143953
+ return this.maxFileSizeMB * 1024 * 1024;
143954
+ }
143895
143955
  /**
143896
143956
  * Get the local cache path for a @skilder-asset:/ path (may or may not exist).
143897
143957
  */
@@ -143903,39 +143963,7 @@ var FileService = class FileService2 extends Service {
143903
143963
  * main working dir (5 min), but both are configurable via environment variables.
143904
143964
  */
143905
143965
  async runAssetCacheGC() {
143906
- const cacheDir = this.getAssetCacheDir();
143907
- let deletedCount = 0;
143908
- let bytesFreed = 0;
143909
- try {
143910
- const entries = await fs3.promises.readdir(cacheDir);
143911
- const now2 = Date.now();
143912
- for (const entry of entries) {
143913
- const filePath = path2.join(cacheDir, entry);
143914
- try {
143915
- const stat = await fs3.promises.lstat(filePath);
143916
- if (stat.isSymbolicLink()) {
143917
- this.logger.warn({ filePath }, "Asset cache GC removing unexpected symlink");
143918
- await fs3.promises.unlink(filePath);
143919
- bytesFreed += stat.size;
143920
- deletedCount++;
143921
- } else if (stat.isFile() && now2 - stat.mtimeMs > this.assetCacheMaxAgeMs) {
143922
- await fs3.promises.unlink(filePath);
143923
- bytesFreed += stat.size;
143924
- deletedCount++;
143925
- }
143926
- } catch (error48) {
143927
- if (error48 instanceof Error && "code" in error48 && error48.code === "ENOENT") {
143928
- continue;
143929
- }
143930
- this.logger.warn({ filePath, error: error48 }, "Asset cache GC failed to process file");
143931
- }
143932
- }
143933
- } catch (error48) {
143934
- if (error48 instanceof Error && "code" in error48 && error48.code === "ENOENT") {
143935
- return;
143936
- }
143937
- this.logger.warn({ error: error48 }, "Asset cache GC failed to read cache directory");
143938
- }
143966
+ const { deletedCount, bytesFreed } = await this.sweepDirByAge(this.getAssetCacheDir(), this.assetCacheMaxAgeMs, "Asset cache GC");
143939
143967
  if (deletedCount > 0) {
143940
143968
  this.logger.info({ deletedCount, bytesFreed }, `Asset cache GC completed: ${deletedCount} file(s) deleted, ${bytesFreed} bytes freed`);
143941
143969
  }
@@ -144358,7 +144386,7 @@ var ScriptService = class ScriptService2 {
144358
144386
  * @returns Result with content array and optional error/skill tracking
144359
144387
  */
144360
144388
  async execute(params) {
144361
- const { path: path4, workspaceId, userId, userKey, runtimeExecutionId, delegateDepth } = params;
144389
+ const { path: path4, workspaceId, userId, userKey, runtimeExecutionId, delegateDepth, args: structuredArgs } = params;
144362
144390
  if (!path4) {
144363
144391
  return {
144364
144392
  content: [
@@ -144454,7 +144482,7 @@ For other resources, use the \`learn\` tool instead.`
144454
144482
  isError: true
144455
144483
  };
144456
144484
  }
144457
- const args = lookupArgs ? parseScriptArgs(lookupArgs) : [];
144485
+ const args = structuredArgs !== void 0 ? structuredArgs : lookupArgs ? parseScriptArgs(lookupArgs) : [];
144458
144486
  return this.routeScriptToRuntime(scriptEntry, skill, args, workspaceId, userId, userKey, runtimeExecutionId, delegateDepth);
144459
144487
  }
144460
144488
  /**
@@ -145174,6 +145202,10 @@ ${JSON.stringify(toolConfig.inputSchema, null, 2)}`
145174
145202
  }
145175
145203
 
145176
145204
  // src/services/static-tools/download-asset.handler.ts
145205
+ var import_node_stream2 = require("node:stream");
145206
+ function getBackendUrl3() {
145207
+ return (process.env.SKILDER_BACKEND_URL || "http://localhost:3000").replace(/\/$/, "");
145208
+ }
145177
145209
  var DownloadAssetError = class extends Error {
145178
145210
  constructor(userMessage, skillId) {
145179
145211
  super(userMessage);
@@ -145258,16 +145290,6 @@ To execute this script:
145258
145290
  skill.id
145259
145291
  );
145260
145292
  }
145261
- if (!deps.skillContentService) {
145262
- deps.logger.error(
145263
- { skillId: skill.id, assetId: item.id },
145264
- "SkillContentService not injected \u2014 cannot download assets"
145265
- );
145266
- throw new DownloadAssetError(
145267
- "Error: Content service is not available. Cannot download assets in this runtime configuration.",
145268
- skill.id
145269
- );
145270
- }
145271
145293
  if (!deps.userKey) {
145272
145294
  deps.logger.error(
145273
145295
  { skillId: skill.id, assetId: item.id },
@@ -145278,33 +145300,81 @@ To execute this script:
145278
145300
  skill.id
145279
145301
  );
145280
145302
  }
145281
- let rawContent;
145303
+ const assetUrl = `${getBackendUrl3()}/assets/${encodeURIComponent(item.id)}`;
145304
+ let response;
145282
145305
  try {
145283
- rawContent = await deps.skillContentService.getContent(item.id, deps.userKey);
145306
+ response = await fetch(assetUrl, {
145307
+ headers: { Authorization: `Bearer ${deps.userKey}` }
145308
+ });
145284
145309
  } catch (error48) {
145285
- deps.logger.error({ err: error48, assetName: item.name, assetId: item.id }, "Failed to download skill asset");
145310
+ deps.logger.error(
145311
+ { err: error48, assetName: item.name, assetId: item.id, url: assetUrl },
145312
+ "Failed to fetch skill asset from backend"
145313
+ );
145286
145314
  throw new DownloadAssetError(
145287
- `Error: Failed to download asset "${item.name}". Please try again. If the issue persists, verify that the Skilder backend is running and your authentication is valid.`,
145315
+ `Error: Failed to download asset "${item.name}". Please try again. If the issue persists, verify that the Skilder backend is reachable and your authentication is valid.`,
145288
145316
  skill.id
145289
145317
  );
145290
145318
  }
145291
- if (rawContent == null) {
145319
+ if (!response.ok) {
145320
+ if (response.status === 404) {
145321
+ throw new DownloadAssetError(
145322
+ `Error: Asset "${item.name}" has not been uploaded yet, or no longer exists.`,
145323
+ skill.id
145324
+ );
145325
+ }
145326
+ if (response.status === 401 || response.status === 403) {
145327
+ throw new DownloadAssetError(
145328
+ `Error: Not authorized to download asset "${item.name}". Verify your user key has access to this workspace.`,
145329
+ skill.id
145330
+ );
145331
+ }
145332
+ const body = await response.text().catch((err) => {
145333
+ deps.logger.warn({ err }, "Failed to read backend error response body");
145334
+ return "";
145335
+ });
145292
145336
  deps.logger.error(
145293
- { assetName: item.name, assetId: item.id },
145294
- "skillContentService.getContent returned null/undefined"
145337
+ {
145338
+ assetName: item.name,
145339
+ assetId: item.id,
145340
+ status: response.status,
145341
+ body: body.slice(0, 200)
145342
+ },
145343
+ "Backend returned non-OK response for asset download"
145295
145344
  );
145296
145345
  throw new DownloadAssetError(
145297
- `Error: No content found for asset "${item.name}". The resource may be unavailable.`,
145346
+ `Error: Failed to download asset "${item.name}" (HTTP ${response.status}). Please try again.`,
145347
+ skill.id
145348
+ );
145349
+ }
145350
+ const contentLengthHeader = response.headers.get("content-length");
145351
+ let expectedBytes;
145352
+ if (contentLengthHeader) {
145353
+ const contentLength = Number.parseInt(contentLengthHeader, 10);
145354
+ if (Number.isFinite(contentLength)) {
145355
+ if (contentLength > deps.fileService.maxAssetBytes) {
145356
+ const maxMB = Math.floor(deps.fileService.maxAssetBytes / (1024 * 1024));
145357
+ throw new DownloadAssetError(
145358
+ `Error: Asset "${item.name}" is too large to download (${contentLength} bytes exceeds the ${maxMB}MB limit). Consider requesting a smaller version or processing the data differently.`,
145359
+ skill.id
145360
+ );
145361
+ }
145362
+ expectedBytes = contentLength;
145363
+ }
145364
+ }
145365
+ if (!response.body) {
145366
+ throw new DownloadAssetError(
145367
+ `Error: Backend returned no body for asset "${item.name}".`,
145298
145368
  skill.id
145299
145369
  );
145300
145370
  }
145301
- const buffer = Buffer.from(rawContent, "base64");
145302
145371
  const assetPath = generateSkilderAssetPath(item.id, item.name);
145372
+ const nodeStream = import_node_stream2.Readable.fromWeb(response.body);
145303
145373
  try {
145304
- await deps.fileService.cacheAsset(assetPath, buffer);
145374
+ await deps.fileService.cacheAssetFromStream(assetPath, nodeStream, { expectedBytes });
145305
145375
  } catch (writeError) {
145306
145376
  deps.logger.error(
145307
- { err: writeError, assetName: item.name, assetId: item.id },
145377
+ { err: writeError, assetName: item.name, assetId: item.id, expectedBytes },
145308
145378
  "Failed to write downloaded asset to disk"
145309
145379
  );
145310
145380
  if (writeError instanceof AssetTooLargeError) {
@@ -145314,6 +145384,12 @@ To execute this script:
145314
145384
  skill.id
145315
145385
  );
145316
145386
  }
145387
+ if (writeError instanceof AssetTruncatedError) {
145388
+ throw new DownloadAssetError(
145389
+ `Error: Asset "${item.name}" download was truncated (received ${writeError.receivedBytes} of ${writeError.expectedBytes} bytes). Please retry.`,
145390
+ skill.id
145391
+ );
145392
+ }
145317
145393
  throw new DownloadAssetError(
145318
145394
  `Error: Failed to write asset "${item.name}" to disk. Please try again.`,
145319
145395
  skill.id
@@ -145350,7 +145426,6 @@ Examples:
145350
145426
  const { assetPath, itemName, mimetype, skillId } = await downloadSkillAsset(path4, {
145351
145427
  catalog: ctx.catalog,
145352
145428
  fileService: ctx.fileService,
145353
- skillContentService: ctx.skillContentService,
145354
145429
  userKey: ctx.identity.userKey,
145355
145430
  logger: ctx.logger
145356
145431
  });
@@ -147209,7 +147284,7 @@ var EMPTY_COMPLETION_RESULT = {
147209
147284
  };
147210
147285
 
147211
147286
  // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sse.js
147212
- var import_node_crypto3 = require("node:crypto");
147287
+ var import_node_crypto4 = require("node:crypto");
147213
147288
  var import_node_tls = require("node:tls");
147214
147289
  var import_raw_body = __toESM(require_raw_body(), 1);
147215
147290
  var import_content_type = __toESM(require_content_type(), 1);
@@ -147222,7 +147297,7 @@ var SSEServerTransport = class {
147222
147297
  constructor(_endpoint, res, options) {
147223
147298
  this._endpoint = _endpoint;
147224
147299
  this.res = res;
147225
- this._sessionId = (0, import_node_crypto3.randomUUID)();
147300
+ this._sessionId = (0, import_node_crypto4.randomUUID)();
147226
147301
  this._options = options || { enableDnsRebindingProtection: false };
147227
147302
  }
147228
147303
  /**
@@ -149204,7 +149279,7 @@ var StreamableHTTPServerTransport = class {
149204
149279
  };
149205
149280
 
149206
149281
  // src/services/mcp.streamable.service.ts
149207
- var import_node_crypto4 = require("node:crypto");
149282
+ var import_node_crypto5 = require("node:crypto");
149208
149283
  var __decorate18 = function(decorators, target, key, desc) {
149209
149284
  var c3 = arguments.length, r2 = c3 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d2;
149210
149285
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
@@ -149441,7 +149516,7 @@ var McpStreamableService = class McpStreamableService2 extends Service {
149441
149516
  * Each session gets its own Server instance to avoid the "Already connected" error.
149442
149517
  */
149443
149518
  async createStreamableTransport() {
149444
- const sessionId = (0, import_node_crypto4.randomUUID)();
149519
+ const sessionId = (0, import_node_crypto5.randomUUID)();
149445
149520
  const partialSession = {};
149446
149521
  const server = new McpServer({ name: "Remote Skilder Server", version: "1.0.0" }, { capabilities: { tools: { listChanged: true } } });
149447
149522
  registerMcpHandlers(server, this.sessions, this.logger);
@@ -149564,10 +149639,183 @@ McpStreamableService = __decorate18([
149564
149639
 
149565
149640
  // src/services/script-executor.service.ts
149566
149641
  var import_child_process = require("child_process");
149567
- var import_promises = require("fs/promises");
149642
+ var import_promises2 = require("fs/promises");
149568
149643
  var import_path2 = require("path");
149569
149644
  var import_os4 = require("os");
149570
149645
  var import_readline = require("readline");
149646
+
149647
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
149648
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
149649
+ var import_node_process2 = __toESM(require("node:process"), 1);
149650
+ var import_node_stream3 = require("node:stream");
149651
+ var DEFAULT_INHERITED_ENV_VARS = import_node_process2.default.platform === "win32" ? [
149652
+ "APPDATA",
149653
+ "HOMEDRIVE",
149654
+ "HOMEPATH",
149655
+ "LOCALAPPDATA",
149656
+ "PATH",
149657
+ "PROCESSOR_ARCHITECTURE",
149658
+ "SYSTEMDRIVE",
149659
+ "SYSTEMROOT",
149660
+ "TEMP",
149661
+ "USERNAME",
149662
+ "USERPROFILE",
149663
+ "PROGRAMFILES"
149664
+ ] : (
149665
+ /* list inspired by the default env inheritance of sudo */
149666
+ ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"]
149667
+ );
149668
+ function getDefaultEnvironment() {
149669
+ const env = {};
149670
+ for (const key of DEFAULT_INHERITED_ENV_VARS) {
149671
+ const value = import_node_process2.default.env[key];
149672
+ if (value === void 0) {
149673
+ continue;
149674
+ }
149675
+ if (value.startsWith("()")) {
149676
+ continue;
149677
+ }
149678
+ env[key] = value;
149679
+ }
149680
+ return env;
149681
+ }
149682
+ var StdioClientTransport = class {
149683
+ constructor(server) {
149684
+ this._readBuffer = new ReadBuffer();
149685
+ this._stderrStream = null;
149686
+ this._serverParams = server;
149687
+ if (server.stderr === "pipe" || server.stderr === "overlapped") {
149688
+ this._stderrStream = new import_node_stream3.PassThrough();
149689
+ }
149690
+ }
149691
+ /**
149692
+ * Starts the server process and prepares to communicate with it.
149693
+ */
149694
+ async start() {
149695
+ if (this._process) {
149696
+ throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
149697
+ }
149698
+ return new Promise((resolve5, reject) => {
149699
+ this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
149700
+ // merge default env with server env because mcp server needs some env vars
149701
+ env: {
149702
+ ...getDefaultEnvironment(),
149703
+ ...this._serverParams.env
149704
+ },
149705
+ stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
149706
+ shell: false,
149707
+ windowsHide: import_node_process2.default.platform === "win32" && isElectron(),
149708
+ cwd: this._serverParams.cwd
149709
+ });
149710
+ this._process.on("error", (error48) => {
149711
+ reject(error48);
149712
+ this.onerror?.(error48);
149713
+ });
149714
+ this._process.on("spawn", () => {
149715
+ resolve5();
149716
+ });
149717
+ this._process.on("close", (_code) => {
149718
+ this._process = void 0;
149719
+ this.onclose?.();
149720
+ });
149721
+ this._process.stdin?.on("error", (error48) => {
149722
+ this.onerror?.(error48);
149723
+ });
149724
+ this._process.stdout?.on("data", (chunk) => {
149725
+ this._readBuffer.append(chunk);
149726
+ this.processReadBuffer();
149727
+ });
149728
+ this._process.stdout?.on("error", (error48) => {
149729
+ this.onerror?.(error48);
149730
+ });
149731
+ if (this._stderrStream && this._process.stderr) {
149732
+ this._process.stderr.pipe(this._stderrStream);
149733
+ }
149734
+ });
149735
+ }
149736
+ /**
149737
+ * The stderr stream of the child process, if `StdioServerParameters.stderr` was set to "pipe" or "overlapped".
149738
+ *
149739
+ * If stderr piping was requested, a PassThrough stream is returned _immediately_, allowing callers to
149740
+ * attach listeners before the start method is invoked. This prevents loss of any early
149741
+ * error output emitted by the child process.
149742
+ */
149743
+ get stderr() {
149744
+ if (this._stderrStream) {
149745
+ return this._stderrStream;
149746
+ }
149747
+ return this._process?.stderr ?? null;
149748
+ }
149749
+ /**
149750
+ * The child process pid spawned by this transport.
149751
+ *
149752
+ * This is only available after the transport has been started.
149753
+ */
149754
+ get pid() {
149755
+ return this._process?.pid ?? null;
149756
+ }
149757
+ processReadBuffer() {
149758
+ while (true) {
149759
+ try {
149760
+ const message = this._readBuffer.readMessage();
149761
+ if (message === null) {
149762
+ break;
149763
+ }
149764
+ this.onmessage?.(message);
149765
+ } catch (error48) {
149766
+ this.onerror?.(error48);
149767
+ }
149768
+ }
149769
+ }
149770
+ async close() {
149771
+ if (this._process) {
149772
+ const processToClose = this._process;
149773
+ this._process = void 0;
149774
+ const closePromise = new Promise((resolve5) => {
149775
+ processToClose.once("close", () => {
149776
+ resolve5();
149777
+ });
149778
+ });
149779
+ try {
149780
+ processToClose.stdin?.end();
149781
+ } catch {
149782
+ }
149783
+ await Promise.race([closePromise, new Promise((resolve5) => setTimeout(resolve5, 2e3).unref())]);
149784
+ if (processToClose.exitCode === null) {
149785
+ try {
149786
+ processToClose.kill("SIGTERM");
149787
+ } catch {
149788
+ }
149789
+ await Promise.race([closePromise, new Promise((resolve5) => setTimeout(resolve5, 2e3).unref())]);
149790
+ }
149791
+ if (processToClose.exitCode === null) {
149792
+ try {
149793
+ processToClose.kill("SIGKILL");
149794
+ } catch {
149795
+ }
149796
+ }
149797
+ }
149798
+ this._readBuffer.clear();
149799
+ }
149800
+ send(message) {
149801
+ return new Promise((resolve5) => {
149802
+ if (!this._process?.stdin) {
149803
+ throw new Error("Not connected");
149804
+ }
149805
+ const json3 = serializeMessage(message);
149806
+ if (this._process.stdin.write(json3)) {
149807
+ resolve5();
149808
+ } else {
149809
+ this._process.stdin.once("drain", resolve5);
149810
+ }
149811
+ });
149812
+ }
149813
+ };
149814
+ function isElectron() {
149815
+ return "type" in import_node_process2.default;
149816
+ }
149817
+
149818
+ // src/services/script-executor.service.ts
149571
149819
  var __decorate19 = function(decorators, target, key, desc) {
149572
149820
  var c3 = arguments.length, r2 = c3 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d2;
149573
149821
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
@@ -149583,24 +149831,36 @@ var __param16 = function(paramIndex, decorator) {
149583
149831
  };
149584
149832
  };
149585
149833
  var _a41;
149834
+ var _b31;
149586
149835
  var ScriptType2 = dgraph_resolvers_types_exports.ScriptType;
149587
149836
  var ScriptExecutorService = class ScriptExecutorService2 {
149588
- constructor(loggerService) {
149837
+ constructor(loggerService, fileService) {
149838
+ this.fileService = fileService;
149589
149839
  this.logger = loggerService.getLogger("script-executor");
149590
149840
  }
149841
+ buildScriptEnv(extra = {}) {
149842
+ const env = {
149843
+ ...getDefaultEnvironment(),
149844
+ ...this.fileService.getEnvVars(),
149845
+ ...extra
149846
+ };
149847
+ this.logger.debug({ envKeys: Object.keys(env) }, "Built script environment");
149848
+ return env;
149849
+ }
149591
149850
  async execute(options) {
149592
149851
  const { code, scriptType, args = [], timeout: timeout2 = DEFAULT_SCRIPT_TIMEOUT_MS } = options;
149593
149852
  this.logger.debug({ scriptType, argsCount: args.length, timeout: timeout2 }, "Executing script");
149594
149853
  let tempDir;
149595
149854
  let tempFile;
149596
149855
  try {
149597
- tempDir = await (0, import_promises.mkdtemp)((0, import_path2.join)((0, import_os4.tmpdir)(), "skilder-script-"));
149856
+ tempDir = await (0, import_promises2.mkdtemp)((0, import_path2.join)((0, import_os4.tmpdir)(), "skilder-script-"));
149598
149857
  const extension = this.getFileExtension(scriptType);
149599
149858
  tempFile = (0, import_path2.join)(tempDir, `script${extension}`);
149600
- await (0, import_promises.writeFile)(tempFile, code, "utf-8");
149859
+ await (0, import_promises2.writeFile)(tempFile, code, "utf-8");
149601
149860
  const { command, commandArgs } = this.getCommand(scriptType, tempFile, args);
149602
149861
  this.logger.debug({ command, commandArgs }, "Spawning process");
149603
- const result = await this.spawnProcess(command, commandArgs, timeout2);
149862
+ const scriptEnv = this.buildScriptEnv();
149863
+ const result = await this.spawnProcess(command, commandArgs, timeout2, scriptEnv);
149604
149864
  return result;
149605
149865
  } catch (error48) {
149606
149866
  this.logger.error({ error: error48 }, "Script execution failed");
@@ -149641,7 +149901,7 @@ var ScriptExecutorService = class ScriptExecutorService2 {
149641
149901
  throw new Error(`Unsupported script type: ${scriptType}`);
149642
149902
  }
149643
149903
  }
149644
- spawnProcess(command, args, timeout2) {
149904
+ spawnProcess(command, args, timeout2, env) {
149645
149905
  return new Promise((resolve5) => {
149646
149906
  let stdout = "";
149647
149907
  let stderr = "";
@@ -149650,8 +149910,8 @@ var ScriptExecutorService = class ScriptExecutorService2 {
149650
149910
  let totalOutputSize = 0;
149651
149911
  const child = (0, import_child_process.spawn)(command, args, {
149652
149912
  stdio: ["pipe", "pipe", "pipe"],
149653
- // Use shell on Windows for better compatibility
149654
- shell: process.platform === "win32"
149913
+ shell: process.platform === "win32",
149914
+ env
149655
149915
  });
149656
149916
  const timeoutId = setTimeout(() => {
149657
149917
  killed = true;
@@ -149686,6 +149946,7 @@ var ScriptExecutorService = class ScriptExecutorService2 {
149686
149946
  });
149687
149947
  child.on("error", (error48) => {
149688
149948
  clearTimeout(timeoutId);
149949
+ this.logger.error({ err: error48, command }, "Spawned process emitted error");
149689
149950
  resolve5({
149690
149951
  success: false,
149691
149952
  stdout,
@@ -149700,7 +149961,7 @@ var ScriptExecutorService = class ScriptExecutorService2 {
149700
149961
  success: false,
149701
149962
  stdout,
149702
149963
  stderr,
149703
- error: "Script output exceeded maximum size of 10MB"
149964
+ error: `Script output exceeded maximum size of ${MAX_SCRIPT_OUTPUT_SIZE / (1024 * 1024)}MB`
149704
149965
  });
149705
149966
  return;
149706
149967
  }
@@ -149741,18 +150002,19 @@ var ScriptExecutorService = class ScriptExecutorService2 {
149741
150002
  this.logger.debug({ scriptType, argsCount: args.length }, "Executing interactive script");
149742
150003
  let tempDir;
149743
150004
  try {
149744
- tempDir = await (0, import_promises.mkdtemp)((0, import_path2.join)((0, import_os4.tmpdir)(), "skilder-script-"));
150005
+ tempDir = await (0, import_promises2.mkdtemp)((0, import_path2.join)((0, import_os4.tmpdir)(), "skilder-script-"));
149745
150006
  const extension = this.getFileExtension(scriptType);
149746
150007
  const tempFile = (0, import_path2.join)(tempDir, `script${extension}`);
149747
- await (0, import_promises.writeFile)(tempFile, code, "utf-8");
149748
- await (0, import_promises.writeFile)((0, import_path2.join)(tempDir, "package.json"), JSON.stringify({ type: "module" }), "utf-8");
150008
+ await (0, import_promises2.writeFile)(tempFile, code, "utf-8");
150009
+ await (0, import_promises2.writeFile)((0, import_path2.join)(tempDir, "package.json"), JSON.stringify({ type: "module" }), "utf-8");
149749
150010
  const sdkDir = (0, import_path2.join)(tempDir, "node_modules", "@skilder-ai", "script-sdk");
149750
- await (0, import_promises.mkdir)(sdkDir, { recursive: true });
149751
- await (0, import_promises.writeFile)((0, import_path2.join)(sdkDir, "index.cjs"), sdkBundleContent, "utf-8");
149752
- await (0, import_promises.writeFile)((0, import_path2.join)(sdkDir, "package.json"), JSON.stringify({ name: "@skilder-ai/script-sdk", version: "0.1.0", main: "index.cjs", exports: { ".": { require: "./index.cjs", default: "./index.cjs" } } }), "utf-8");
150011
+ await (0, import_promises2.mkdir)(sdkDir, { recursive: true });
150012
+ await (0, import_promises2.writeFile)((0, import_path2.join)(sdkDir, "index.cjs"), sdkBundleContent, "utf-8");
150013
+ await (0, import_promises2.writeFile)((0, import_path2.join)(sdkDir, "package.json"), JSON.stringify({ name: "@skilder-ai/script-sdk", version: "0.1.0", main: "index.cjs", exports: { ".": { require: "./index.cjs", default: "./index.cjs" } } }), "utf-8");
149753
150014
  const { command, commandArgs } = this.getCommand(scriptType, tempFile, args);
149754
150015
  this.logger.debug({ command, commandArgs }, "Spawning interactive process");
149755
- const result = await this.spawnInteractiveProcess(command, commandArgs, tempDir, timeout2, toolCallTimeout, onRequest);
150016
+ const scriptEnv = this.buildScriptEnv({ SKILDER_INTERACTIVE: "1", NODE_PATH: (0, import_path2.join)(tempDir, "node_modules") });
150017
+ const result = await this.spawnInteractiveProcess(command, commandArgs, timeout2, toolCallTimeout, onRequest, scriptEnv);
149756
150018
  return result;
149757
150019
  } catch (error48) {
149758
150020
  this.logger.error({ error: error48 }, "Interactive script execution failed");
@@ -149765,25 +150027,22 @@ var ScriptExecutorService = class ScriptExecutorService2 {
149765
150027
  await this.cleanupRecursive(tempDir);
149766
150028
  }
149767
150029
  }
149768
- spawnInteractiveProcess(command, args, tempDir, timeout2, toolCallTimeout, onRequest) {
150030
+ spawnInteractiveProcess(command, args, timeout2, toolCallTimeout, onRequest, env) {
149769
150031
  return new Promise((resolve5) => {
149770
150032
  let stderr = "";
149771
150033
  let killed = false;
149772
150034
  let outputTruncated = false;
149773
150035
  let totalOutputSize = 0;
149774
150036
  let childExited = false;
149775
- const outputParts = [];
150037
+ const outputChunks = [];
150038
+ const consoleChunks = [];
149776
150039
  const totalStartTime = Date.now();
149777
150040
  let inflightCount = 0;
149778
150041
  let inflightDone;
149779
150042
  const child = (0, import_child_process.spawn)(command, args, {
149780
150043
  stdio: ["pipe", "pipe", "pipe"],
149781
150044
  shell: process.platform === "win32",
149782
- env: {
149783
- ...process.env,
149784
- SKILDER_INTERACTIVE: "1",
149785
- NODE_PATH: (0, import_path2.join)(tempDir, "node_modules")
149786
- }
150045
+ env
149787
150046
  });
149788
150047
  const pendingIds = /* @__PURE__ */ new Set();
149789
150048
  let currentTimeout = timeout2;
@@ -149865,15 +150124,20 @@ var ScriptExecutorService = class ScriptExecutorService2 {
149865
150124
  try {
149866
150125
  msg = JSON.parse(line);
149867
150126
  } catch {
149868
- outputParts.push(line);
150127
+ consoleChunks.push(line);
150128
+ this.logger.debug({ line }, "Script console line (non-JSON)");
149869
150129
  return;
149870
150130
  }
149871
150131
  if (msg.jsonrpc !== "2.0" || !msg.method) {
149872
- outputParts.push(line);
150132
+ consoleChunks.push(line);
149873
150133
  return;
149874
150134
  }
149875
150135
  if (msg.id === void 0) {
149876
- this.logger.debug({ method: msg.method }, "Received JSON-RPC notification (no id) \u2014 ignoring");
150136
+ if (msg.method === "$output" && msg.params !== null && typeof msg.params === "object" && typeof msg.params.text === "string") {
150137
+ outputChunks.push(msg.params.text);
150138
+ } else {
150139
+ this.logger.debug({ method: msg.method }, "Received JSON-RPC notification (no id) \u2014 ignoring");
150140
+ }
149877
150141
  return;
149878
150142
  }
149879
150143
  inflightCount++;
@@ -149914,34 +150178,46 @@ var ScriptExecutorService = class ScriptExecutorService2 {
149914
150178
  totalOutputSize += dataSize;
149915
150179
  stderr += data.toString();
149916
150180
  });
149917
- child.on("error", (error48) => {
150181
+ child.on("error", async (error48) => {
149918
150182
  childExited = true;
149919
150183
  clearTimeout(timeoutId);
149920
- resolve5({ success: false, stdout: outputParts.join("\n"), stderr, error: error48.message });
150184
+ this.logger.error({ err: error48, command }, "Spawned interactive process emitted error");
150185
+ rl.close();
150186
+ if (inflightCount > 0) {
150187
+ await new Promise((done) => {
150188
+ inflightDone = done;
150189
+ });
150190
+ }
150191
+ const stdout = outputChunks.join("\n");
150192
+ const consoleOutput = consoleChunks.join("\n") || void 0;
150193
+ resolve5({ success: false, stdout, consoleOutput, stderr, error: error48.message });
149921
150194
  });
149922
150195
  child.on("close", async (exitCode) => {
149923
150196
  childExited = true;
149924
150197
  clearTimeout(timeoutId);
150198
+ rl.close();
149925
150199
  if (inflightCount > 0) {
149926
150200
  await new Promise((done) => {
149927
150201
  inflightDone = done;
149928
150202
  });
149929
150203
  }
149930
- const stdout = outputParts.join("\n");
150204
+ const stdout = outputChunks.join("\n");
150205
+ const consoleOutput = consoleChunks.join("\n") || void 0;
149931
150206
  if (outputTruncated) {
149932
- resolve5({ success: false, stdout, stderr, error: "Script output exceeded maximum size of 10MB" });
150207
+ resolve5({ success: false, stdout, consoleOutput, stderr, error: `Script output exceeded maximum size of ${MAX_SCRIPT_OUTPUT_SIZE / (1024 * 1024)}MB` });
149933
150208
  return;
149934
150209
  }
149935
150210
  if (killed) {
149936
- resolve5({ success: false, stdout, stderr, error: `Script execution timed out after ${currentTimeout}ms` });
150211
+ resolve5({ success: false, stdout, consoleOutput, stderr, error: `Script execution timed out after ${currentTimeout}ms` });
149937
150212
  return;
149938
150213
  }
149939
150214
  if (exitCode === 0) {
149940
- resolve5({ success: true, stdout, stderr: stderr || void 0, exitCode: 0 });
150215
+ resolve5({ success: true, stdout, consoleOutput, stderr: stderr || void 0, exitCode: 0 });
149941
150216
  } else {
149942
150217
  resolve5({
149943
150218
  success: false,
149944
150219
  stdout,
150220
+ consoleOutput,
149945
150221
  stderr,
149946
150222
  exitCode: exitCode ?? void 0,
149947
150223
  error: stderr || `Script exited with code ${exitCode}`
@@ -149953,7 +150229,7 @@ var ScriptExecutorService = class ScriptExecutorService2 {
149953
150229
  async cleanupRecursive(tempDir) {
149954
150230
  try {
149955
150231
  if (tempDir) {
149956
- await (0, import_promises.rm)(tempDir, { recursive: true, force: true });
150232
+ await (0, import_promises2.rm)(tempDir, { recursive: true, force: true });
149957
150233
  }
149958
150234
  } catch (error48) {
149959
150235
  this.logger.warn({ error: error48, tempDir }, "Failed to cleanup temp files");
@@ -149963,11 +150239,12 @@ var ScriptExecutorService = class ScriptExecutorService2 {
149963
150239
  ScriptExecutorService = __decorate19([
149964
150240
  W(),
149965
150241
  __param16(0, U(LoggerService)),
149966
- __metadata18("design:paramtypes", [typeof (_a41 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a41 : Object])
150242
+ __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])
149967
150244
  ], ScriptExecutorService);
149968
150245
 
149969
150246
  // src/services/tool.service.ts
149970
- var import_promises2 = require("fs/promises");
150247
+ var import_promises3 = require("fs/promises");
149971
150248
  var import_path3 = require("path");
149972
150249
 
149973
150250
  // src/services/tool.mcp.server.service.ts
@@ -150647,177 +150924,6 @@ var Client = class extends Protocol {
150647
150924
  }
150648
150925
  };
150649
150926
 
150650
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
150651
- var import_cross_spawn = __toESM(require_cross_spawn(), 1);
150652
- var import_node_process2 = __toESM(require("node:process"), 1);
150653
- var import_node_stream = require("node:stream");
150654
- var DEFAULT_INHERITED_ENV_VARS = import_node_process2.default.platform === "win32" ? [
150655
- "APPDATA",
150656
- "HOMEDRIVE",
150657
- "HOMEPATH",
150658
- "LOCALAPPDATA",
150659
- "PATH",
150660
- "PROCESSOR_ARCHITECTURE",
150661
- "SYSTEMDRIVE",
150662
- "SYSTEMROOT",
150663
- "TEMP",
150664
- "USERNAME",
150665
- "USERPROFILE",
150666
- "PROGRAMFILES"
150667
- ] : (
150668
- /* list inspired by the default env inheritance of sudo */
150669
- ["HOME", "LOGNAME", "PATH", "SHELL", "TERM", "USER"]
150670
- );
150671
- function getDefaultEnvironment() {
150672
- const env = {};
150673
- for (const key of DEFAULT_INHERITED_ENV_VARS) {
150674
- const value = import_node_process2.default.env[key];
150675
- if (value === void 0) {
150676
- continue;
150677
- }
150678
- if (value.startsWith("()")) {
150679
- continue;
150680
- }
150681
- env[key] = value;
150682
- }
150683
- return env;
150684
- }
150685
- var StdioClientTransport = class {
150686
- constructor(server) {
150687
- this._readBuffer = new ReadBuffer();
150688
- this._stderrStream = null;
150689
- this._serverParams = server;
150690
- if (server.stderr === "pipe" || server.stderr === "overlapped") {
150691
- this._stderrStream = new import_node_stream.PassThrough();
150692
- }
150693
- }
150694
- /**
150695
- * Starts the server process and prepares to communicate with it.
150696
- */
150697
- async start() {
150698
- if (this._process) {
150699
- throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
150700
- }
150701
- return new Promise((resolve5, reject) => {
150702
- this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
150703
- // merge default env with server env because mcp server needs some env vars
150704
- env: {
150705
- ...getDefaultEnvironment(),
150706
- ...this._serverParams.env
150707
- },
150708
- stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
150709
- shell: false,
150710
- windowsHide: import_node_process2.default.platform === "win32" && isElectron(),
150711
- cwd: this._serverParams.cwd
150712
- });
150713
- this._process.on("error", (error48) => {
150714
- reject(error48);
150715
- this.onerror?.(error48);
150716
- });
150717
- this._process.on("spawn", () => {
150718
- resolve5();
150719
- });
150720
- this._process.on("close", (_code) => {
150721
- this._process = void 0;
150722
- this.onclose?.();
150723
- });
150724
- this._process.stdin?.on("error", (error48) => {
150725
- this.onerror?.(error48);
150726
- });
150727
- this._process.stdout?.on("data", (chunk) => {
150728
- this._readBuffer.append(chunk);
150729
- this.processReadBuffer();
150730
- });
150731
- this._process.stdout?.on("error", (error48) => {
150732
- this.onerror?.(error48);
150733
- });
150734
- if (this._stderrStream && this._process.stderr) {
150735
- this._process.stderr.pipe(this._stderrStream);
150736
- }
150737
- });
150738
- }
150739
- /**
150740
- * The stderr stream of the child process, if `StdioServerParameters.stderr` was set to "pipe" or "overlapped".
150741
- *
150742
- * If stderr piping was requested, a PassThrough stream is returned _immediately_, allowing callers to
150743
- * attach listeners before the start method is invoked. This prevents loss of any early
150744
- * error output emitted by the child process.
150745
- */
150746
- get stderr() {
150747
- if (this._stderrStream) {
150748
- return this._stderrStream;
150749
- }
150750
- return this._process?.stderr ?? null;
150751
- }
150752
- /**
150753
- * The child process pid spawned by this transport.
150754
- *
150755
- * This is only available after the transport has been started.
150756
- */
150757
- get pid() {
150758
- return this._process?.pid ?? null;
150759
- }
150760
- processReadBuffer() {
150761
- while (true) {
150762
- try {
150763
- const message = this._readBuffer.readMessage();
150764
- if (message === null) {
150765
- break;
150766
- }
150767
- this.onmessage?.(message);
150768
- } catch (error48) {
150769
- this.onerror?.(error48);
150770
- }
150771
- }
150772
- }
150773
- async close() {
150774
- if (this._process) {
150775
- const processToClose = this._process;
150776
- this._process = void 0;
150777
- const closePromise = new Promise((resolve5) => {
150778
- processToClose.once("close", () => {
150779
- resolve5();
150780
- });
150781
- });
150782
- try {
150783
- processToClose.stdin?.end();
150784
- } catch {
150785
- }
150786
- await Promise.race([closePromise, new Promise((resolve5) => setTimeout(resolve5, 2e3).unref())]);
150787
- if (processToClose.exitCode === null) {
150788
- try {
150789
- processToClose.kill("SIGTERM");
150790
- } catch {
150791
- }
150792
- await Promise.race([closePromise, new Promise((resolve5) => setTimeout(resolve5, 2e3).unref())]);
150793
- }
150794
- if (processToClose.exitCode === null) {
150795
- try {
150796
- processToClose.kill("SIGKILL");
150797
- } catch {
150798
- }
150799
- }
150800
- }
150801
- this._readBuffer.clear();
150802
- }
150803
- send(message) {
150804
- return new Promise((resolve5) => {
150805
- if (!this._process?.stdin) {
150806
- throw new Error("Not connected");
150807
- }
150808
- const json3 = serializeMessage(message);
150809
- if (this._process.stdin.write(json3)) {
150810
- resolve5();
150811
- } else {
150812
- this._process.stdin.once("drain", resolve5);
150813
- }
150814
- });
150815
- }
150816
- };
150817
- function isElectron() {
150818
- return "type" in import_node_process2.default;
150819
- }
150820
-
150821
150927
  // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/transport.js
150822
150928
  function normalizeHeaders2(headers) {
150823
150929
  if (!headers)
@@ -152046,8 +152152,8 @@ var ErrorEvent = class extends Event {
152046
152152
  * @param errorEventInitDict - Optional properties to include in the error event
152047
152153
  */
152048
152154
  constructor(type22, errorEventInitDict) {
152049
- var _a51, _b39;
152050
- super(type22), this.code = (_a51 = errorEventInitDict == null ? void 0 : errorEventInitDict.code) != null ? _a51 : void 0, this.message = (_b39 = errorEventInitDict == null ? void 0 : errorEventInitDict.message) != null ? _b39 : void 0;
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;
152051
152157
  }
152052
152158
  /**
152053
152159
  * Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
@@ -152129,7 +152235,7 @@ var scheduleReconnect_fn;
152129
152235
  var _reconnect;
152130
152236
  var EventSource = class extends EventTarget {
152131
152237
  constructor(url2, eventSourceInitDict) {
152132
- var _a51, _b39;
152238
+ var _a51, _b40;
152133
152239
  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) => {
152134
152240
  var _a210;
152135
152241
  __privateGet(this, _parser).reset();
@@ -152188,7 +152294,7 @@ var EventSource = class extends EventTarget {
152188
152294
  __privateSet(this, _parser, createParser({
152189
152295
  onEvent: __privateGet(this, _onEvent),
152190
152296
  onRetry: __privateGet(this, _onRetryChange)
152191
- })), __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, (_b39 = eventSourceInitDict == null ? void 0 : eventSourceInitDict.withCredentials) != null ? _b39 : false), __privateMethod(this, _EventSource_instances, connect_fn).call(this);
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);
152192
152298
  }
152193
152299
  /**
152194
152300
  * Returns the state of this EventSource object's connection. It can have the values described below.
@@ -152536,7 +152642,7 @@ var __metadata19 = function(k3, v2) {
152536
152642
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k3, v2);
152537
152643
  };
152538
152644
  var _a44;
152539
- var _b31;
152645
+ var _b33;
152540
152646
  var _c8;
152541
152647
  var ToolServerService = class ToolServerService2 extends Service {
152542
152648
  constructor(logger, config2, roots = [], additionalEnv = {}, authProvider) {
@@ -152753,7 +152859,7 @@ var ToolServerService = class ToolServerService2 extends Service {
152753
152859
  };
152754
152860
  ToolServerService = __decorate20([
152755
152861
  W(),
152756
- __metadata19("design:paramtypes", [typeof (_a44 = typeof import_pino2.default !== "undefined" && import_pino2.default.Logger) === "function" ? _a44 : Object, typeof (_b31 = typeof dgraph_resolvers_types_exports !== "undefined" && dgraph_resolvers_types_exports.McpServer) === "function" ? _b31 : Object, Array, typeof (_c8 = typeof Record !== "undefined" && Record) === "function" ? _c8 : Object, Object])
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])
152757
152863
  ], ToolServerService);
152758
152864
  var getConfigSignature = (config2, roots) => {
152759
152865
  return `${config2.transport}-${config2.config}-${roots.length}`;
@@ -152775,7 +152881,7 @@ var __param17 = function(paramIndex, decorator) {
152775
152881
  };
152776
152882
  };
152777
152883
  var _a45;
152778
- var _b33;
152884
+ var _b34;
152779
152885
  var OAuthTokenService = class OAuthTokenService2 {
152780
152886
  constructor(loggerService, natsService) {
152781
152887
  this.loggerService = loggerService;
@@ -152858,7 +152964,7 @@ OAuthTokenService = __decorate21([
152858
152964
  W(),
152859
152965
  __param17(0, U(LoggerService)),
152860
152966
  __param17(1, U(NatsService)),
152861
- __metadata20("design:paramtypes", [typeof (_a45 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a45 : Object, typeof (_b33 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b33 : Object])
152967
+ __metadata20("design:paramtypes", [typeof (_a45 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a45 : Object, typeof (_b34 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b34 : Object])
152862
152968
  ], OAuthTokenService);
152863
152969
 
152864
152970
  // src/services/oauth-client-info.service.ts
@@ -152877,7 +152983,7 @@ var __param18 = function(paramIndex, decorator) {
152877
152983
  };
152878
152984
  };
152879
152985
  var _a46;
152880
- var _b34;
152986
+ var _b35;
152881
152987
  var CACHE_TTL_MS = 10 * 60 * 1e3;
152882
152988
  var CACHE_MAX_SIZE = 100;
152883
152989
  var OAuthClientInfoService = class OAuthClientInfoService2 {
@@ -152940,7 +153046,7 @@ OAuthClientInfoService = __decorate22([
152940
153046
  W(),
152941
153047
  __param18(0, U(LoggerService)),
152942
153048
  __param18(1, U(NatsService)),
152943
- __metadata21("design:paramtypes", [typeof (_a46 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a46 : Object, typeof (_b34 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b34 : Object])
153049
+ __metadata21("design:paramtypes", [typeof (_a46 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a46 : Object, typeof (_b35 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b35 : Object])
152944
153050
  ], OAuthClientInfoService);
152945
153051
 
152946
153052
  // src/services/dynamic-tool-router.service.ts
@@ -152959,7 +153065,7 @@ var __param19 = function(paramIndex, decorator) {
152959
153065
  };
152960
153066
  };
152961
153067
  var _a47;
152962
- var _b35;
153068
+ var _b36;
152963
153069
  var DynamicToolRouter = class DynamicToolRouter2 {
152964
153070
  constructor(loggerService, natsService) {
152965
153071
  this.natsService = natsService;
@@ -153004,7 +153110,7 @@ DynamicToolRouter = __decorate23([
153004
153110
  W(),
153005
153111
  __param19(0, U(LoggerService)),
153006
153112
  __param19(1, U(NatsService)),
153007
- __metadata22("design:paramtypes", [typeof (_a47 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a47 : Object, typeof (_b35 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b35 : Object])
153113
+ __metadata22("design:paramtypes", [typeof (_a47 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a47 : Object, typeof (_b36 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b36 : Object])
153008
153114
  ], DynamicToolRouter);
153009
153115
 
153010
153116
  // src/services/runtime-bus.service.ts
@@ -153023,7 +153129,7 @@ var __param20 = function(paramIndex, decorator) {
153023
153129
  };
153024
153130
  };
153025
153131
  var _a48;
153026
- var _b36;
153132
+ var _b37;
153027
153133
  var RuntimeBusService = class RuntimeBusService2 {
153028
153134
  constructor(loggerService, natsService) {
153029
153135
  this.natsService = natsService;
@@ -153069,7 +153175,7 @@ var RuntimeBusService = class RuntimeBusService2 {
153069
153175
  return;
153070
153176
  }
153071
153177
  for (const runtimeId of toSubscribe) {
153072
- this.subscribeRuntime(runtimeId);
153178
+ this.subscribeRuntime(runtimeId, workspaceId);
153073
153179
  }
153074
153180
  }
153075
153181
  async drain() {
@@ -153086,10 +153192,10 @@ var RuntimeBusService = class RuntimeBusService2 {
153086
153192
  }
153087
153193
  /** Subscribe a single runtimeId. If the handler exits, drop from observed so the next
153088
153194
  * syncSubscriptions() resubscribes (no exponential-backoff resurrection). */
153089
- subscribeRuntime(runtimeId) {
153195
+ subscribeRuntime(runtimeId, workspaceId) {
153090
153196
  if (!this.natsService || !this.onMessage)
153091
153197
  return;
153092
- const subject = SkillCallToolRequest.subscribeToScriptsForRuntime(runtimeId);
153198
+ const subject = SkillCallToolRequest.subscribeToScriptsForRuntime(runtimeId, workspaceId);
153093
153199
  const subscription = this.natsService.subscribe(subject);
153094
153200
  this.observed.set(runtimeId, { unsubscribe: () => subscription.unsubscribe() });
153095
153201
  Promise.resolve(this.onMessage(subscription)).catch((err) => {
@@ -153105,7 +153211,7 @@ RuntimeBusService = __decorate24([
153105
153211
  __param20(0, U(LoggerService)),
153106
153212
  __param20(1, U(NatsService)),
153107
153213
  __param20(1, se()),
153108
- __metadata23("design:paramtypes", [typeof (_a48 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a48 : Object, typeof (_b36 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b36 : Object])
153214
+ __metadata23("design:paramtypes", [typeof (_a48 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a48 : Object, typeof (_b37 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b37 : Object])
153109
153215
  ], RuntimeBusService);
153110
153216
 
153111
153217
  // src/services/tool.service.ts
@@ -153124,7 +153230,7 @@ var __param21 = function(paramIndex, decorator) {
153124
153230
  };
153125
153231
  };
153126
153232
  var _a49;
153127
- var _b37;
153233
+ var _b38;
153128
153234
  var _c9;
153129
153235
  var _d6;
153130
153236
  var _e6;
@@ -153135,7 +153241,6 @@ var _k;
153135
153241
  var _o;
153136
153242
  var _p;
153137
153243
  var _q;
153138
- var _r;
153139
153244
  var GET_SKILL_RELATED_QUERY = `
153140
153245
  query GetSkillRelated($id: ID!) {
153141
153246
  skillRelated(id: $id) {
@@ -153176,7 +153281,7 @@ function formatScriptError(stderr, exitCode) {
153176
153281
  return result;
153177
153282
  }
153178
153283
  var ToolService = class ToolService2 extends Service {
153179
- constructor(loggerService, natsService, cacheService, authService, healthService, toolServerServiceFactory, oauthTokenService, oauthClientInfoService, mcpStdioService, fileService, runtimeExecutionId, scriptExecutorService, delegateService, scriptService, skillContentService, runtimeCatalogService, dynamicToolRouter, runtimeBusService) {
153284
+ constructor(loggerService, natsService, cacheService, authService, healthService, toolServerServiceFactory, oauthTokenService, oauthClientInfoService, mcpStdioService, fileService, runtimeExecutionId, scriptExecutorService, delegateService, scriptService, runtimeCatalogService, dynamicToolRouter, runtimeBusService) {
153180
153285
  super();
153181
153286
  this.loggerService = loggerService;
153182
153287
  this.natsService = natsService;
@@ -153191,7 +153296,6 @@ var ToolService = class ToolService2 extends Service {
153191
153296
  this.scriptExecutorService = scriptExecutorService;
153192
153297
  this.delegateService = delegateService;
153193
153298
  this.scriptService = scriptService;
153194
- this.skillContentService = skillContentService;
153195
153299
  this.runtimeCatalogService = runtimeCatalogService;
153196
153300
  this.dynamicToolRouter = dynamicToolRouter;
153197
153301
  this.runtimeBusService = runtimeBusService;
@@ -153403,7 +153507,7 @@ var ToolService = class ToolService2 extends Service {
153403
153507
  await this.stopMCPServer(mcpServer);
153404
153508
  }
153405
153509
  if (existingDormant) {
153406
- this.dormantConfigs.delete(mcpServer.id);
153510
+ this.removeDormantServer(mcpServer.id);
153407
153511
  }
153408
153512
  this.activationFailures.delete(mcpServer.id);
153409
153513
  const isStdio = mcpServer.transport === dgraph_resolvers_types_exports.McpTransportType.Stdio;
@@ -153654,8 +153758,8 @@ var ToolService = class ToolService2 extends Service {
153654
153758
  }
153655
153759
  }
153656
153760
  // Subscribe to a tool and return the subscription
153657
- subscribeToTool(tool2) {
153658
- const subject = SkillCallToolRequest.subscribeToTool(tool2.id);
153761
+ subscribeToTool(tool2, workspaceId) {
153762
+ const subject = SkillCallToolRequest.subscribeToTool(tool2.id, workspaceId);
153659
153763
  this.logger.debug(`Subscribing to tool ${tool2.id} on subject: ${subject}`);
153660
153764
  const subscription = this.natsService.subscribe(subject);
153661
153765
  this.handleToolCall(subscription).catch((err) => {
@@ -153909,11 +154013,17 @@ var ToolService = class ToolService2 extends Service {
153909
154013
  }
153910
154014
  if (!toolCalled) {
153911
154015
  const catalogEntry = this.runtimeCatalogService?.findEntryByToolId(msg.data.workspaceId, toolId);
153912
- if (catalogEntry) {
153913
- this.logger.warn({ toolId, ownerRuntimeId: catalogEntry.runtimeId }, "Tool call arrived at wrong runtime \u2014 tool belongs to another runtime");
154016
+ const selfId = identity?.id;
154017
+ if (catalogEntry && selfId && catalogEntry.runtimeId !== selfId) {
154018
+ this.logger.warn({ toolId, ownerRuntimeId: catalogEntry.runtimeId, selfId }, "Tool call arrived at wrong runtime \u2014 tool belongs to another runtime");
153914
154019
  msg.respond(new ErrorResponse({
153915
154020
  error: `Tool ${toolId} is served by runtime ${catalogEntry.runtimeId}, not this runtime. The request was misrouted.`
153916
154021
  }));
154022
+ } else if (catalogEntry && selfId && catalogEntry.runtimeId === selfId) {
154023
+ this.logger.warn({ toolId, selfId }, "Tool call arrived but tool not loaded \u2014 MCP server may be initializing or restarting");
154024
+ msg.respond(new ErrorResponse({
154025
+ error: `Tool ${toolId} is not currently loaded on this runtime. The MCP server may be initializing. Please retry.`
154026
+ }));
153917
154027
  } else {
153918
154028
  this.logger.warn(`Tool ${toolId} not found in any MCP Server or workspace catalog`);
153919
154029
  msg.respond(new ErrorResponse({
@@ -154087,16 +154197,21 @@ ${result.stderr}`;
154087
154197
  }
154088
154198
  respond(new RuntimeCallToolResponse({
154089
154199
  result: {
154090
- content: [{ type: "text", text: output || "(Script executed successfully with no output)" }]
154200
+ content: [{ type: "text", text: output || (useInteractive ? "(Script executed with no output() call)" : "(Script executed successfully with no output)") }]
154091
154201
  },
154092
154202
  executedBy
154093
154203
  }));
154094
154204
  } else {
154095
154205
  const cleanError = result.stderr ? formatScriptError(result.stderr, result.exitCode) : result.error || "Unknown error";
154096
- const fullOutput = result.stdout ? `Output:
154206
+ const consolePart = result.consoleOutput ? `Console output:
154207
+ ${result.consoleOutput}
154208
+
154209
+ ` : "";
154210
+ const stdoutPart = result.stdout ? `Output:
154097
154211
  ${result.stdout}
154098
154212
 
154099
- ${cleanError}` : cleanError;
154213
+ ` : "";
154214
+ const fullOutput = stdoutPart || consolePart ? `${stdoutPart}${consolePart}${cleanError}` : cleanError;
154100
154215
  respond(new RuntimeCallToolResponse({
154101
154216
  result: {
154102
154217
  content: [{ type: "text", text: fullOutput }],
@@ -154130,9 +154245,15 @@ ${cleanError}` : cleanError;
154130
154245
  if (!params || typeof params !== "object" || typeof params.path !== "string") {
154131
154246
  throw new Error("Invalid scripts/execute params: expected { path: string, arguments?: string[] }");
154132
154247
  }
154133
- const { path: path4, arguments: scriptArgs } = params;
154134
- const combinedPath = Array.isArray(scriptArgs) && scriptArgs.length > 0 ? `${path4} ${scriptArgs.join(" ")}` : path4;
154135
- return this.handleScriptExecuteFromSdk(combinedPath, workspaceId, userId, userKey, runtimeId, delegateDepth);
154248
+ const { path: path4, arguments: rawArgs } = params;
154249
+ if (rawArgs !== void 0 && !Array.isArray(rawArgs)) {
154250
+ throw new Error("Invalid scripts/execute params: arguments must be a string array");
154251
+ }
154252
+ if (rawArgs !== void 0 && !rawArgs.every((a3) => typeof a3 === "string")) {
154253
+ throw new Error("Invalid scripts/execute params: arguments must be a string array");
154254
+ }
154255
+ const scriptArgs = rawArgs;
154256
+ return this.handleScriptExecuteFromSdk(path4, workspaceId, userId, userKey, runtimeId, delegateDepth, scriptArgs);
154136
154257
  }
154137
154258
  case "assets/download": {
154138
154259
  if (!params || typeof params !== "object" || typeof params.path !== "string") {
@@ -154165,7 +154286,6 @@ ${cleanError}` : cleanError;
154165
154286
  const result = await downloadSkillAsset(path4, {
154166
154287
  catalog,
154167
154288
  fileService: this.fileService,
154168
- skillContentService: this.skillContentService,
154169
154289
  userKey,
154170
154290
  logger: this.logger
154171
154291
  });
@@ -154184,7 +154304,7 @@ ${cleanError}` : cleanError;
154184
154304
  * Handle a script execute request from a TypeScript script via JSON-RPC IPC.
154185
154305
  * Resolves the path and routes execution using ScriptService.
154186
154306
  */
154187
- async handleScriptExecuteFromSdk(path4, workspaceId, userId, userKey, runtimeId, delegateDepth) {
154307
+ async handleScriptExecuteFromSdk(path4, workspaceId, userId, userKey, runtimeId, delegateDepth, args) {
154188
154308
  if (!this.scriptService) {
154189
154309
  this.logger.warn({ event: "script_service_unavailable" }, "Script execute requested but ScriptService not injected");
154190
154310
  return {
@@ -154203,7 +154323,8 @@ ${cleanError}` : cleanError;
154203
154323
  userId,
154204
154324
  userKey,
154205
154325
  runtimeExecutionId: runtimeId,
154206
- delegateDepth
154326
+ delegateDepth,
154327
+ args
154207
154328
  });
154208
154329
  return {
154209
154330
  content: result.content,
@@ -154325,7 +154446,7 @@ ${cleanError}` : cleanError;
154325
154446
  ];
154326
154447
  for (const candidate of candidates) {
154327
154448
  try {
154328
- this.sdkBundleContent = await (0, import_promises2.readFile)(candidate, "utf-8");
154449
+ this.sdkBundleContent = await (0, import_promises3.readFile)(candidate, "utf-8");
154329
154450
  this.logger.debug({ path: candidate }, "Loaded script SDK bundle");
154330
154451
  return this.sdkBundleContent;
154331
154452
  } catch (err) {
@@ -154380,14 +154501,31 @@ ${cleanError}` : cleanError;
154380
154501
  */
154381
154502
  ensureToolsSubscribed(mcpServerId, tools) {
154382
154503
  this.mcpTools.set(mcpServerId, tools.filter((tool2) => !!tool2));
154504
+ const workspaceId = this.mcpServerWorkspaces.get(mcpServerId);
154505
+ if (!workspaceId) {
154506
+ this.logger.warn({ event: "tool_subscribe_no_workspace", mcpServerId }, "Cannot subscribe to tools: workspace not registered for MCP server");
154507
+ return;
154508
+ }
154383
154509
  if (!this.toolSubscriptions.has(mcpServerId)) {
154384
154510
  this.toolSubscriptions.set(mcpServerId, /* @__PURE__ */ new Map());
154385
154511
  }
154386
154512
  const serverToolSubs = this.toolSubscriptions.get(mcpServerId);
154513
+ const currentToolIds = new Set(tools.filter(Boolean).map((t4) => t4.id));
154514
+ for (const [toolId, subscription] of serverToolSubs.entries()) {
154515
+ if (!currentToolIds.has(toolId)) {
154516
+ this.logger.debug(`Unsubscribing stale tool ${toolId} from server ${mcpServerId}`);
154517
+ try {
154518
+ subscription.unsubscribe();
154519
+ } catch (error48) {
154520
+ this.logger.warn({ toolId, err: error48 }, "Failed to unsubscribe stale tool");
154521
+ }
154522
+ serverToolSubs.delete(toolId);
154523
+ }
154524
+ }
154387
154525
  for (const tool2 of tools) {
154388
154526
  if (tool2 && !serverToolSubs.has(tool2.id)) {
154389
154527
  this.logger.debug(`Subscribing to tool ${tool2.name} (${tool2.id})`);
154390
- const subscription = this.subscribeToTool(tool2);
154528
+ const subscription = this.subscribeToTool(tool2, workspaceId);
154391
154529
  serverToolSubs.set(tool2.id, subscription);
154392
154530
  } else if (tool2) {
154393
154531
  this.logger.debug(`Tool ${tool2.name} (${tool2.id}) already subscribed -> skipping`);
@@ -154476,15 +154614,13 @@ ToolService = __decorate25([
154476
154614
  __param21(12, se()),
154477
154615
  __param21(13, U(ScriptService)),
154478
154616
  __param21(13, se()),
154479
- __param21(14, U(SkillContentService)),
154617
+ __param21(14, U(RuntimeCatalogService)),
154480
154618
  __param21(14, se()),
154481
- __param21(15, U(RuntimeCatalogService)),
154619
+ __param21(15, U(DynamicToolRouter)),
154482
154620
  __param21(15, se()),
154483
- __param21(16, U(DynamicToolRouter)),
154621
+ __param21(16, U(RuntimeBusService)),
154484
154622
  __param21(16, se()),
154485
- __param21(17, U(RuntimeBusService)),
154486
- __param21(17, se()),
154487
- __metadata24("design:paramtypes", [typeof (_a49 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a49 : Object, typeof (_b37 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b37 : 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 SkillContentService !== "undefined" && SkillContentService) === "function" ? _o : Object, typeof (_p = typeof RuntimeCatalogService !== "undefined" && RuntimeCatalogService) === "function" ? _p : Object, typeof (_q = typeof DynamicToolRouter !== "undefined" && DynamicToolRouter) === "function" ? _q : Object, typeof (_r = typeof RuntimeBusService !== "undefined" && RuntimeBusService) === "function" ? _r : Object])
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])
154488
154624
  ], ToolService);
154489
154625
 
154490
154626
  // src/services/runtime.main.service.ts
@@ -154503,7 +154639,7 @@ var __param22 = function(paramIndex, decorator) {
154503
154639
  };
154504
154640
  };
154505
154641
  var _a50;
154506
- var _b38;
154642
+ var _b39;
154507
154643
  var _c10;
154508
154644
  var _d7;
154509
154645
  var _k2;
@@ -154792,7 +154928,7 @@ MainService = __decorate26([
154792
154928
  __param22(11, se()),
154793
154929
  __param22(12, U(RuntimeCatalogService)),
154794
154930
  __param22(12, se()),
154795
- __metadata25("design:paramtypes", [typeof (_a50 = typeof LoggerService !== "undefined" && LoggerService) === "function" ? _a50 : Object, typeof (_b38 = typeof NatsService !== "undefined" && NatsService) === "function" ? _b38 : 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])
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])
154796
154932
  ], MainService);
154797
154933
 
154798
154934
  // src/di/container.ts