@skilder-ai/runtime 0.9.2 → 0.9.4

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
@@ -1917,7 +1917,7 @@ var require_package = __commonJS({
1917
1917
  // ../../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js
1918
1918
  var require_main = __commonJS({
1919
1919
  "../../node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js"(exports2, module2) {
1920
- var fs5 = require("fs");
1920
+ var fs6 = require("fs");
1921
1921
  var path4 = require("path");
1922
1922
  var os4 = require("os");
1923
1923
  var crypto5 = require("crypto");
@@ -2059,7 +2059,7 @@ var require_main = __commonJS({
2059
2059
  if (options && options.path && options.path.length > 0) {
2060
2060
  if (Array.isArray(options.path)) {
2061
2061
  for (const filepath of options.path) {
2062
- if (fs5.existsSync(filepath)) {
2062
+ if (fs6.existsSync(filepath)) {
2063
2063
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
2064
2064
  }
2065
2065
  }
@@ -2069,7 +2069,7 @@ var require_main = __commonJS({
2069
2069
  } else {
2070
2070
  possibleVaultPath = path4.resolve(process.cwd(), ".env.vault");
2071
2071
  }
2072
- if (fs5.existsSync(possibleVaultPath)) {
2072
+ if (fs6.existsSync(possibleVaultPath)) {
2073
2073
  return possibleVaultPath;
2074
2074
  }
2075
2075
  return null;
@@ -2122,7 +2122,7 @@ var require_main = __commonJS({
2122
2122
  const parsedAll = {};
2123
2123
  for (const path5 of optionPaths) {
2124
2124
  try {
2125
- const parsed = DotenvModule.parse(fs5.readFileSync(path5, { encoding }));
2125
+ const parsed = DotenvModule.parse(fs6.readFileSync(path5, { encoding }));
2126
2126
  DotenvModule.populate(parsedAll, parsed, options);
2127
2127
  } catch (e2) {
2128
2128
  if (debug) {
@@ -14151,7 +14151,7 @@ var require_graphql = __commonJS({
14151
14151
  var _validate2 = require_validate2();
14152
14152
  var _execute = require_execute();
14153
14153
  function graphql(args) {
14154
- return new Promise((resolve5) => resolve5(graphqlImpl(args)));
14154
+ return new Promise((resolve6) => resolve6(graphqlImpl(args)));
14155
14155
  }
14156
14156
  function graphqlSync(args) {
14157
14157
  const result = graphqlImpl(args);
@@ -20661,7 +20661,7 @@ var require_atomic_sleep = __commonJS({
20661
20661
  var require_sonic_boom = __commonJS({
20662
20662
  "../../node_modules/.pnpm/sonic-boom@4.2.0/node_modules/sonic-boom/index.js"(exports2, module2) {
20663
20663
  "use strict";
20664
- var fs5 = require("fs");
20664
+ var fs6 = require("fs");
20665
20665
  var EventEmitter = require("events");
20666
20666
  var inherits = require("util").inherits;
20667
20667
  var path4 = require("path");
@@ -20718,20 +20718,20 @@ var require_sonic_boom = __commonJS({
20718
20718
  const mode = sonic.mode;
20719
20719
  if (sonic.sync) {
20720
20720
  try {
20721
- if (sonic.mkdir) fs5.mkdirSync(path4.dirname(file2), { recursive: true });
20722
- const fd = fs5.openSync(file2, flags, mode);
20721
+ if (sonic.mkdir) fs6.mkdirSync(path4.dirname(file2), { recursive: true });
20722
+ const fd = fs6.openSync(file2, flags, mode);
20723
20723
  fileOpened(null, fd);
20724
20724
  } catch (err) {
20725
20725
  fileOpened(err);
20726
20726
  throw err;
20727
20727
  }
20728
20728
  } else if (sonic.mkdir) {
20729
- fs5.mkdir(path4.dirname(file2), { recursive: true }, (err) => {
20729
+ fs6.mkdir(path4.dirname(file2), { recursive: true }, (err) => {
20730
20730
  if (err) return fileOpened(err);
20731
- fs5.open(file2, flags, mode, fileOpened);
20731
+ fs6.open(file2, flags, mode, fileOpened);
20732
20732
  });
20733
20733
  } else {
20734
- fs5.open(file2, flags, mode, fileOpened);
20734
+ fs6.open(file2, flags, mode, fileOpened);
20735
20735
  }
20736
20736
  }
20737
20737
  function SonicBoom(opts) {
@@ -20772,16 +20772,16 @@ var require_sonic_boom = __commonJS({
20772
20772
  this.flush = flushBuffer;
20773
20773
  this.flushSync = flushBufferSync;
20774
20774
  this._actualWrite = actualWriteBuffer;
20775
- fsWriteSync = () => fs5.writeSync(this.fd, this._writingBuf);
20776
- fsWrite = () => fs5.write(this.fd, this._writingBuf, this.release);
20775
+ fsWriteSync = () => fs6.writeSync(this.fd, this._writingBuf);
20776
+ fsWrite = () => fs6.write(this.fd, this._writingBuf, this.release);
20777
20777
  } else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
20778
20778
  this._writingBuf = "";
20779
20779
  this.write = write;
20780
20780
  this.flush = flush;
20781
20781
  this.flushSync = flushSync;
20782
20782
  this._actualWrite = actualWrite;
20783
- fsWriteSync = () => fs5.writeSync(this.fd, this._writingBuf, "utf8");
20784
- fsWrite = () => fs5.write(this.fd, this._writingBuf, "utf8", this.release);
20783
+ fsWriteSync = () => fs6.writeSync(this.fd, this._writingBuf, "utf8");
20784
+ fsWrite = () => fs6.write(this.fd, this._writingBuf, "utf8", this.release);
20785
20785
  } else {
20786
20786
  throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
20787
20787
  }
@@ -20837,7 +20837,7 @@ var require_sonic_boom = __commonJS({
20837
20837
  }
20838
20838
  }
20839
20839
  if (this._fsync) {
20840
- fs5.fsyncSync(this.fd);
20840
+ fs6.fsyncSync(this.fd);
20841
20841
  }
20842
20842
  const len = this._len;
20843
20843
  if (this._reopening) {
@@ -20949,7 +20949,7 @@ var require_sonic_boom = __commonJS({
20949
20949
  const onDrain = () => {
20950
20950
  if (!this._fsync) {
20951
20951
  try {
20952
- fs5.fsync(this.fd, (err) => {
20952
+ fs6.fsync(this.fd, (err) => {
20953
20953
  this._flushPending = false;
20954
20954
  cb(err);
20955
20955
  });
@@ -21051,7 +21051,7 @@ var require_sonic_boom = __commonJS({
21051
21051
  const fd = this.fd;
21052
21052
  this.once("ready", () => {
21053
21053
  if (fd !== this.fd) {
21054
- fs5.close(fd, (err) => {
21054
+ fs6.close(fd, (err) => {
21055
21055
  if (err) {
21056
21056
  return this.emit("error", err);
21057
21057
  }
@@ -21100,7 +21100,7 @@ var require_sonic_boom = __commonJS({
21100
21100
  buf = this._bufs[0];
21101
21101
  }
21102
21102
  try {
21103
- const n3 = fs5.writeSync(this.fd, buf, "utf8");
21103
+ const n3 = fs6.writeSync(this.fd, buf, "utf8");
21104
21104
  const releasedBufObj = releaseWritingBuf(buf, this._len, n3);
21105
21105
  buf = releasedBufObj.writingBuf;
21106
21106
  this._len = releasedBufObj.len;
@@ -21116,7 +21116,7 @@ var require_sonic_boom = __commonJS({
21116
21116
  }
21117
21117
  }
21118
21118
  try {
21119
- fs5.fsyncSync(this.fd);
21119
+ fs6.fsyncSync(this.fd);
21120
21120
  } catch {
21121
21121
  }
21122
21122
  }
@@ -21137,7 +21137,7 @@ var require_sonic_boom = __commonJS({
21137
21137
  buf = mergeBuf(this._bufs[0], this._lens[0]);
21138
21138
  }
21139
21139
  try {
21140
- const n3 = fs5.writeSync(this.fd, buf);
21140
+ const n3 = fs6.writeSync(this.fd, buf);
21141
21141
  buf = buf.subarray(n3);
21142
21142
  this._len = Math.max(this._len - n3, 0);
21143
21143
  if (buf.length <= 0) {
@@ -21165,13 +21165,13 @@ var require_sonic_boom = __commonJS({
21165
21165
  this._writingBuf = this._writingBuf || this._bufs.shift() || "";
21166
21166
  if (this.sync) {
21167
21167
  try {
21168
- const written = fs5.writeSync(this.fd, this._writingBuf, "utf8");
21168
+ const written = fs6.writeSync(this.fd, this._writingBuf, "utf8");
21169
21169
  release(null, written);
21170
21170
  } catch (err) {
21171
21171
  release(err);
21172
21172
  }
21173
21173
  } else {
21174
- fs5.write(this.fd, this._writingBuf, "utf8", release);
21174
+ fs6.write(this.fd, this._writingBuf, "utf8", release);
21175
21175
  }
21176
21176
  }
21177
21177
  function actualWriteBuffer() {
@@ -21180,7 +21180,7 @@ var require_sonic_boom = __commonJS({
21180
21180
  this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
21181
21181
  if (this.sync) {
21182
21182
  try {
21183
- const written = fs5.writeSync(this.fd, this._writingBuf);
21183
+ const written = fs6.writeSync(this.fd, this._writingBuf);
21184
21184
  release(null, written);
21185
21185
  } catch (err) {
21186
21186
  release(err);
@@ -21189,7 +21189,7 @@ var require_sonic_boom = __commonJS({
21189
21189
  if (kCopyBuffer) {
21190
21190
  this._writingBuf = Buffer.from(this._writingBuf);
21191
21191
  }
21192
- fs5.write(this.fd, this._writingBuf, release);
21192
+ fs6.write(this.fd, this._writingBuf, release);
21193
21193
  }
21194
21194
  }
21195
21195
  function actualClose(sonic) {
@@ -21205,12 +21205,12 @@ var require_sonic_boom = __commonJS({
21205
21205
  sonic._lens = [];
21206
21206
  assert2(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
21207
21207
  try {
21208
- fs5.fsync(sonic.fd, closeWrapped);
21208
+ fs6.fsync(sonic.fd, closeWrapped);
21209
21209
  } catch {
21210
21210
  }
21211
21211
  function closeWrapped() {
21212
21212
  if (sonic.fd !== 1 && sonic.fd !== 2) {
21213
- fs5.close(sonic.fd, done);
21213
+ fs6.close(sonic.fd, done);
21214
21214
  } else {
21215
21215
  done();
21216
21216
  }
@@ -21887,9 +21887,9 @@ var require_thread_stream = __commonJS({
21887
21887
  var require_transport = __commonJS({
21888
21888
  "../../node_modules/.pnpm/pino@10.1.0/node_modules/pino/lib/transport.js"(exports2, module2) {
21889
21889
  "use strict";
21890
- var { createRequire } = require("module");
21890
+ var { createRequire: createRequire2 } = require("module");
21891
21891
  var getCallers = require_caller();
21892
- var { join: join6, isAbsolute: isAbsolute3, sep: sep2 } = require("node:path");
21892
+ var { join: join6, isAbsolute: isAbsolute3, sep: sep3 } = require("node:path");
21893
21893
  var sleep = require_atomic_sleep();
21894
21894
  var onExit = require_on_exit_leak_free();
21895
21895
  var ThreadStream = require_thread_stream();
@@ -21997,8 +21997,8 @@ var require_transport = __commonJS({
21997
21997
  let fixTarget2;
21998
21998
  for (const filePath of callers) {
21999
21999
  try {
22000
- const context2 = filePath === "node:repl" ? process.cwd() + sep2 : filePath;
22001
- fixTarget2 = createRequire(context2).resolve(origin);
22000
+ const context2 = filePath === "node:repl" ? process.cwd() + sep3 : filePath;
22001
+ fixTarget2 = createRequire2(context2).resolve(origin);
22002
22002
  break;
22003
22003
  } catch (err) {
22004
22004
  continue;
@@ -24114,9 +24114,9 @@ var require_pump = __commonJS({
24114
24114
  "../../node_modules/.pnpm/pump@3.0.3/node_modules/pump/index.js"(exports2, module2) {
24115
24115
  var once = require_once();
24116
24116
  var eos = require_end_of_stream();
24117
- var fs5;
24117
+ var fs6;
24118
24118
  try {
24119
- fs5 = require("fs");
24119
+ fs6 = require("fs");
24120
24120
  } catch (e2) {
24121
24121
  }
24122
24122
  var noop2 = function() {
@@ -24127,8 +24127,8 @@ var require_pump = __commonJS({
24127
24127
  };
24128
24128
  var isFS = function(stream) {
24129
24129
  if (!ancient) return false;
24130
- if (!fs5) return false;
24131
- return (stream instanceof (fs5.ReadStream || noop2) || stream instanceof (fs5.WriteStream || noop2)) && isFn(stream.close);
24130
+ if (!fs6) return false;
24131
+ return (stream instanceof (fs6.ReadStream || noop2) || stream instanceof (fs6.WriteStream || noop2)) && isFn(stream.close);
24132
24132
  };
24133
24133
  var isRequest = function(stream) {
24134
24134
  return stream.setHeader && isFn(stream.abort);
@@ -24294,13 +24294,13 @@ var require_pino_abstract_transport = __commonJS({
24294
24294
  var { Duplex } = require("stream");
24295
24295
  var { parentPort, workerData } = require("worker_threads");
24296
24296
  function createDeferred() {
24297
- let resolve5;
24297
+ let resolve6;
24298
24298
  let reject;
24299
24299
  const promise2 = new Promise((_resolve, _reject) => {
24300
- resolve5 = _resolve;
24300
+ resolve6 = _resolve;
24301
24301
  reject = _reject;
24302
24302
  });
24303
- promise2.resolve = resolve5;
24303
+ promise2.resolve = resolve6;
24304
24304
  promise2.reject = reject;
24305
24305
  return promise2;
24306
24306
  }
@@ -26628,14 +26628,14 @@ var require_util = __commonJS({
26628
26628
  }
26629
26629
  function delay2(ms = 0) {
26630
26630
  let methods;
26631
- const p2 = new Promise((resolve5) => {
26631
+ const p2 = new Promise((resolve6) => {
26632
26632
  const timer = setTimeout(() => {
26633
- resolve5();
26633
+ resolve6();
26634
26634
  }, ms);
26635
26635
  const cancel = () => {
26636
26636
  if (timer) {
26637
26637
  clearTimeout(timer);
26638
- resolve5();
26638
+ resolve6();
26639
26639
  }
26640
26640
  };
26641
26641
  methods = { cancel };
@@ -26655,18 +26655,18 @@ var require_util = __commonJS({
26655
26655
  }
26656
26656
  function deferred() {
26657
26657
  let methods = {};
26658
- const p2 = new Promise((resolve5, reject) => {
26659
- methods = { resolve: resolve5, reject };
26658
+ const p2 = new Promise((resolve6, reject) => {
26659
+ methods = { resolve: resolve6, reject };
26660
26660
  });
26661
26661
  return Object.assign(p2, methods);
26662
26662
  }
26663
26663
  function debugDeferred() {
26664
26664
  let methods = {};
26665
- const p2 = new Promise((resolve5, reject) => {
26665
+ const p2 = new Promise((resolve6, reject) => {
26666
26666
  methods = {
26667
26667
  resolve: (v2) => {
26668
26668
  console.trace("resolve", v2);
26669
- resolve5(v2);
26669
+ resolve6(v2);
26670
26670
  },
26671
26671
  reject: (err) => {
26672
26672
  console.trace("reject");
@@ -33144,12 +33144,12 @@ var require_protocol = __commonJS({
33144
33144
  }
33145
33145
  }
33146
33146
  async _doDial(srv) {
33147
- const { resolve: resolve5 } = this.options;
33147
+ const { resolve: resolve6 } = this.options;
33148
33148
  const alts = await srv.resolve({
33149
33149
  fn: (0, transport_1.getResolveFn)(),
33150
33150
  debug: this.options.debug,
33151
33151
  randomize: !this.options.noRandomize,
33152
- resolve: resolve5
33152
+ resolve: resolve6
33153
33153
  });
33154
33154
  let lastErr = null;
33155
33155
  for (const a3 of alts) {
@@ -33543,12 +33543,12 @@ var require_protocol = __commonJS({
33543
33543
  }
33544
33544
  async drain() {
33545
33545
  const subs = this.subscriptions.all();
33546
- const promises3 = [];
33546
+ const promises4 = [];
33547
33547
  subs.forEach((sub) => {
33548
- promises3.push(sub.drain());
33548
+ promises4.push(sub.drain());
33549
33549
  });
33550
33550
  try {
33551
- await Promise.allSettled(promises3);
33551
+ await Promise.allSettled(promises4);
33552
33552
  } catch {
33553
33553
  } finally {
33554
33554
  this.noMorePublishing = true;
@@ -33745,11 +33745,11 @@ var require_nats = __commonJS({
33745
33745
  this.options = (0, options_1.parseOptions)(opts);
33746
33746
  }
33747
33747
  static connect(opts = {}) {
33748
- return new Promise((resolve5, reject) => {
33748
+ return new Promise((resolve6, reject) => {
33749
33749
  const nc = new _NatsConnectionImpl(opts);
33750
33750
  protocol_1.ProtocolHandler.connect(nc.options, nc).then((ph) => {
33751
33751
  nc.protocol = ph;
33752
- resolve5(nc);
33752
+ resolve6(nc);
33753
33753
  }).catch((err) => {
33754
33754
  reject(err);
33755
33755
  });
@@ -36751,11 +36751,11 @@ var require_jsmconsumer_api = __commonJS({
36751
36751
  consumerName = cfg.name ?? cfg.durable_name ?? "";
36752
36752
  }
36753
36753
  if (consumerName !== "") {
36754
- let fs5 = cfg.filter_subject ?? void 0;
36755
- if (fs5 === ">") {
36756
- fs5 = void 0;
36754
+ let fs6 = cfg.filter_subject ?? void 0;
36755
+ if (fs6 === ">") {
36756
+ fs6 = void 0;
36757
36757
  }
36758
- subj = fs5 !== void 0 ? `${this.prefix}.CONSUMER.CREATE.${stream}.${consumerName}.${fs5}` : `${this.prefix}.CONSUMER.CREATE.${stream}.${consumerName}`;
36758
+ subj = fs6 !== void 0 ? `${this.prefix}.CONSUMER.CREATE.${stream}.${consumerName}.${fs6}` : `${this.prefix}.CONSUMER.CREATE.${stream}.${consumerName}`;
36759
36759
  } else {
36760
36760
  subj = cfg.durable_name ? `${this.prefix}.CONSUMER.DURABLE.CREATE.${stream}.${cfg.durable_name}` : `${this.prefix}.CONSUMER.CREATE.${stream}`;
36761
36761
  }
@@ -40568,7 +40568,7 @@ var require_auth_config = __commonJS({
40568
40568
  writeAuthConfig: () => writeAuthConfig
40569
40569
  });
40570
40570
  module2.exports = __toCommonJS(auth_config_exports);
40571
- var fs5 = __toESM2(require("fs"));
40571
+ var fs6 = __toESM2(require("fs"));
40572
40572
  var path4 = __toESM2(require("path"));
40573
40573
  var import_token_util = require_token_util();
40574
40574
  function getAuthConfigPath() {
@@ -40583,10 +40583,10 @@ var require_auth_config = __commonJS({
40583
40583
  function readAuthConfig() {
40584
40584
  try {
40585
40585
  const authPath = getAuthConfigPath();
40586
- if (!fs5.existsSync(authPath)) {
40586
+ if (!fs6.existsSync(authPath)) {
40587
40587
  return null;
40588
40588
  }
40589
- const content = fs5.readFileSync(authPath, "utf8");
40589
+ const content = fs6.readFileSync(authPath, "utf8");
40590
40590
  if (!content) {
40591
40591
  return null;
40592
40592
  }
@@ -40598,10 +40598,10 @@ var require_auth_config = __commonJS({
40598
40598
  function writeAuthConfig(config2) {
40599
40599
  const authPath = getAuthConfigPath();
40600
40600
  const authDir = path4.dirname(authPath);
40601
- if (!fs5.existsSync(authDir)) {
40602
- fs5.mkdirSync(authDir, { mode: 504, recursive: true });
40601
+ if (!fs6.existsSync(authDir)) {
40602
+ fs6.mkdirSync(authDir, { mode: 504, recursive: true });
40603
40603
  }
40604
- fs5.writeFileSync(authPath, JSON.stringify(config2, null, 2), { mode: 384 });
40604
+ fs6.writeFileSync(authPath, JSON.stringify(config2, null, 2), { mode: 384 });
40605
40605
  }
40606
40606
  function isValidAccessToken(authConfig) {
40607
40607
  if (!authConfig.token)
@@ -40748,7 +40748,7 @@ var require_token_util = __commonJS({
40748
40748
  });
40749
40749
  module2.exports = __toCommonJS(token_util_exports);
40750
40750
  var path4 = __toESM2(require("path"));
40751
- var fs5 = __toESM2(require("fs"));
40751
+ var fs6 = __toESM2(require("fs"));
40752
40752
  var import_token_error = require_token_error();
40753
40753
  var import_token_io = require_token_io();
40754
40754
  var import_auth_config = require_auth_config();
@@ -40833,12 +40833,12 @@ var require_token_util = __commonJS({
40833
40833
  );
40834
40834
  }
40835
40835
  const prjPath = path4.join(dir, ".vercel", "project.json");
40836
- if (!fs5.existsSync(prjPath)) {
40836
+ if (!fs6.existsSync(prjPath)) {
40837
40837
  throw new import_token_error.VercelOidcTokenError(
40838
40838
  "project.json not found, have you linked your project with `vc link?`"
40839
40839
  );
40840
40840
  }
40841
- const prj = JSON.parse(fs5.readFileSync(prjPath, "utf8"));
40841
+ const prj = JSON.parse(fs6.readFileSync(prjPath, "utf8"));
40842
40842
  if (typeof prj.projectId !== "string" && typeof prj.orgId !== "string") {
40843
40843
  throw new TypeError(
40844
40844
  "Expected a string-valued projectId property. Try running `vc link` to re-link your project."
@@ -40855,9 +40855,9 @@ var require_token_util = __commonJS({
40855
40855
  }
40856
40856
  const tokenPath = path4.join(dir, "com.vercel.token", `${projectId}.json`);
40857
40857
  const tokenJson = JSON.stringify(token);
40858
- fs5.mkdirSync(path4.dirname(tokenPath), { mode: 504, recursive: true });
40859
- fs5.writeFileSync(tokenPath, tokenJson);
40860
- fs5.chmodSync(tokenPath, 432);
40858
+ fs6.mkdirSync(path4.dirname(tokenPath), { mode: 504, recursive: true });
40859
+ fs6.writeFileSync(tokenPath, tokenJson);
40860
+ fs6.chmodSync(tokenPath, 432);
40861
40861
  return;
40862
40862
  }
40863
40863
  function loadToken(projectId) {
@@ -40868,10 +40868,10 @@ var require_token_util = __commonJS({
40868
40868
  );
40869
40869
  }
40870
40870
  const tokenPath = path4.join(dir, "com.vercel.token", `${projectId}.json`);
40871
- if (!fs5.existsSync(tokenPath)) {
40871
+ if (!fs6.existsSync(tokenPath)) {
40872
40872
  return null;
40873
40873
  }
40874
- const token = JSON.parse(fs5.readFileSync(tokenPath, "utf8"));
40874
+ const token = JSON.parse(fs6.readFileSync(tokenPath, "utf8"));
40875
40875
  assertVercelOidcTokenResponse(token);
40876
40876
  return token;
40877
40877
  }
@@ -44005,7 +44005,7 @@ var require_compile = __commonJS({
44005
44005
  const schOrFunc = root.refs[ref];
44006
44006
  if (schOrFunc)
44007
44007
  return schOrFunc;
44008
- let _sch = resolve5.call(this, root, ref);
44008
+ let _sch = resolve6.call(this, root, ref);
44009
44009
  if (_sch === void 0) {
44010
44010
  const schema = (_a51 = root.localRefs) === null || _a51 === void 0 ? void 0 : _a51[ref];
44011
44011
  const { schemaId } = this.opts;
@@ -44032,7 +44032,7 @@ var require_compile = __commonJS({
44032
44032
  function sameSchemaEnv(s1, s2) {
44033
44033
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
44034
44034
  }
44035
- function resolve5(root, ref) {
44035
+ function resolve6(root, ref) {
44036
44036
  let sch;
44037
44037
  while (typeof (sch = this.refs[ref]) == "string")
44038
44038
  ref = sch;
@@ -44607,7 +44607,7 @@ var require_fast_uri = __commonJS({
44607
44607
  }
44608
44608
  return uri;
44609
44609
  }
44610
- function resolve5(baseURI, relativeURI, options) {
44610
+ function resolve6(baseURI, relativeURI, options) {
44611
44611
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
44612
44612
  const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
44613
44613
  schemelessOptions.skipEscape = true;
@@ -44834,7 +44834,7 @@ var require_fast_uri = __commonJS({
44834
44834
  var fastUri = {
44835
44835
  SCHEMES,
44836
44836
  normalize: normalize2,
44837
- resolve: resolve5,
44837
+ resolve: resolve6,
44838
44838
  resolveComponent,
44839
44839
  equal,
44840
44840
  serialize,
@@ -47801,12 +47801,12 @@ var require_dist2 = __commonJS({
47801
47801
  throw new Error(`Unknown format "${name21}"`);
47802
47802
  return f2;
47803
47803
  };
47804
- function addFormats(ajv, list, fs5, exportName) {
47804
+ function addFormats(ajv, list, fs6, exportName) {
47805
47805
  var _a51;
47806
47806
  var _b41;
47807
47807
  (_a51 = (_b41 = ajv.opts.code).formats) !== null && _a51 !== void 0 ? _a51 : _b41.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
47808
47808
  for (const f2 of list)
47809
- ajv.addFormat(f2, fs5[f2]);
47809
+ ajv.addFormat(f2, fs6[f2]);
47810
47810
  }
47811
47811
  module2.exports = exports2 = formatsPlugin;
47812
47812
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -48527,7 +48527,7 @@ var require_Observable = __commonJS({
48527
48527
  Observable2.prototype.forEach = function(next, promiseCtor) {
48528
48528
  var _this = this;
48529
48529
  promiseCtor = getPromiseCtor(promiseCtor);
48530
- return new promiseCtor(function(resolve5, reject) {
48530
+ return new promiseCtor(function(resolve6, reject) {
48531
48531
  var subscriber = new Subscriber_1.SafeSubscriber({
48532
48532
  next: function(value) {
48533
48533
  try {
@@ -48538,7 +48538,7 @@ var require_Observable = __commonJS({
48538
48538
  }
48539
48539
  },
48540
48540
  error: reject,
48541
- complete: resolve5
48541
+ complete: resolve6
48542
48542
  });
48543
48543
  _this.subscribe(subscriber);
48544
48544
  });
@@ -48560,14 +48560,14 @@ var require_Observable = __commonJS({
48560
48560
  Observable2.prototype.toPromise = function(promiseCtor) {
48561
48561
  var _this = this;
48562
48562
  promiseCtor = getPromiseCtor(promiseCtor);
48563
- return new promiseCtor(function(resolve5, reject) {
48563
+ return new promiseCtor(function(resolve6, reject) {
48564
48564
  var value;
48565
48565
  _this.subscribe(function(x3) {
48566
48566
  return value = x3;
48567
48567
  }, function(err) {
48568
48568
  return reject(err);
48569
48569
  }, function() {
48570
- return resolve5(value);
48570
+ return resolve6(value);
48571
48571
  });
48572
48572
  });
48573
48573
  };
@@ -50663,11 +50663,11 @@ var require_innerFrom = __commonJS({
50663
50663
  "use strict";
50664
50664
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P3, generator) {
50665
50665
  function adopt(value) {
50666
- return value instanceof P3 ? value : new P3(function(resolve5) {
50667
- resolve5(value);
50666
+ return value instanceof P3 ? value : new P3(function(resolve6) {
50667
+ resolve6(value);
50668
50668
  });
50669
50669
  }
50670
- return new (P3 || (P3 = Promise))(function(resolve5, reject) {
50670
+ return new (P3 || (P3 = Promise))(function(resolve6, reject) {
50671
50671
  function fulfilled(value) {
50672
50672
  try {
50673
50673
  step(generator.next(value));
@@ -50683,7 +50683,7 @@ var require_innerFrom = __commonJS({
50683
50683
  }
50684
50684
  }
50685
50685
  function step(result) {
50686
- result.done ? resolve5(result.value) : adopt(result.value).then(fulfilled, rejected);
50686
+ result.done ? resolve6(result.value) : adopt(result.value).then(fulfilled, rejected);
50687
50687
  }
50688
50688
  step((generator = generator.apply(thisArg, _arguments || [])).next());
50689
50689
  });
@@ -50765,14 +50765,14 @@ var require_innerFrom = __commonJS({
50765
50765
  }, i2);
50766
50766
  function verb(n3) {
50767
50767
  i2[n3] = o[n3] && function(v2) {
50768
- return new Promise(function(resolve5, reject) {
50769
- v2 = o[n3](v2), settle(resolve5, reject, v2.done, v2.value);
50768
+ return new Promise(function(resolve6, reject) {
50769
+ v2 = o[n3](v2), settle(resolve6, reject, v2.done, v2.value);
50770
50770
  });
50771
50771
  };
50772
50772
  }
50773
- function settle(resolve5, reject, d2, v2) {
50773
+ function settle(resolve6, reject, d2, v2) {
50774
50774
  Promise.resolve(v2).then(function(v3) {
50775
- resolve5({ value: v3, done: d2 });
50775
+ resolve6({ value: v3, done: d2 });
50776
50776
  }, reject);
50777
50777
  }
50778
50778
  };
@@ -51391,7 +51391,7 @@ var require_lastValueFrom = __commonJS({
51391
51391
  var EmptyError_1 = require_EmptyError();
51392
51392
  function lastValueFrom(source, config2) {
51393
51393
  var hasConfig = typeof config2 === "object";
51394
- return new Promise(function(resolve5, reject) {
51394
+ return new Promise(function(resolve6, reject) {
51395
51395
  var _hasValue = false;
51396
51396
  var _value;
51397
51397
  source.subscribe({
@@ -51402,9 +51402,9 @@ var require_lastValueFrom = __commonJS({
51402
51402
  error: reject,
51403
51403
  complete: function() {
51404
51404
  if (_hasValue) {
51405
- resolve5(_value);
51405
+ resolve6(_value);
51406
51406
  } else if (hasConfig) {
51407
- resolve5(config2.defaultValue);
51407
+ resolve6(config2.defaultValue);
51408
51408
  } else {
51409
51409
  reject(new EmptyError_1.EmptyError());
51410
51410
  }
@@ -51426,16 +51426,16 @@ var require_firstValueFrom = __commonJS({
51426
51426
  var Subscriber_1 = require_Subscriber();
51427
51427
  function firstValueFrom3(source, config2) {
51428
51428
  var hasConfig = typeof config2 === "object";
51429
- return new Promise(function(resolve5, reject) {
51429
+ return new Promise(function(resolve6, reject) {
51430
51430
  var subscriber = new Subscriber_1.SafeSubscriber({
51431
51431
  next: function(value) {
51432
- resolve5(value);
51432
+ resolve6(value);
51433
51433
  subscriber.unsubscribe();
51434
51434
  },
51435
51435
  error: reject,
51436
51436
  complete: function() {
51437
51437
  if (hasConfig) {
51438
- resolve5(config2.defaultValue);
51438
+ resolve6(config2.defaultValue);
51439
51439
  } else {
51440
51440
  reject(new EmptyError_1.EmptyError());
51441
51441
  }
@@ -57478,41 +57478,41 @@ var require_queue2 = __commonJS({
57478
57478
  queue.drained = drained;
57479
57479
  return queue;
57480
57480
  function push(value) {
57481
- var p2 = new Promise(function(resolve5, reject) {
57481
+ var p2 = new Promise(function(resolve6, reject) {
57482
57482
  pushCb(value, function(err, result) {
57483
57483
  if (err) {
57484
57484
  reject(err);
57485
57485
  return;
57486
57486
  }
57487
- resolve5(result);
57487
+ resolve6(result);
57488
57488
  });
57489
57489
  });
57490
57490
  p2.catch(noop2);
57491
57491
  return p2;
57492
57492
  }
57493
57493
  function unshift(value) {
57494
- var p2 = new Promise(function(resolve5, reject) {
57494
+ var p2 = new Promise(function(resolve6, reject) {
57495
57495
  unshiftCb(value, function(err, result) {
57496
57496
  if (err) {
57497
57497
  reject(err);
57498
57498
  return;
57499
57499
  }
57500
- resolve5(result);
57500
+ resolve6(result);
57501
57501
  });
57502
57502
  });
57503
57503
  p2.catch(noop2);
57504
57504
  return p2;
57505
57505
  }
57506
57506
  function drained() {
57507
- var p2 = new Promise(function(resolve5) {
57507
+ var p2 = new Promise(function(resolve6) {
57508
57508
  process.nextTick(function() {
57509
57509
  if (queue.idle()) {
57510
- resolve5();
57510
+ resolve6();
57511
57511
  } else {
57512
57512
  var previousDrain = queue.drain;
57513
57513
  queue.drain = function() {
57514
57514
  if (typeof previousDrain === "function") previousDrain();
57515
- resolve5();
57515
+ resolve6();
57516
57516
  queue.drain = previousDrain;
57517
57517
  };
57518
57518
  }
@@ -57855,8 +57855,8 @@ var require_create_promise = __commonJS({
57855
57855
  reject: null,
57856
57856
  promise: null
57857
57857
  };
57858
- obj.promise = new Promise((resolve5, reject) => {
57859
- obj.resolve = resolve5;
57858
+ obj.promise = new Promise((resolve6, reject) => {
57859
+ obj.resolve = resolve6;
57860
57860
  obj.reject = reject;
57861
57861
  });
57862
57862
  return obj;
@@ -58125,11 +58125,11 @@ var require_thenify = __commonJS({
58125
58125
  return;
58126
58126
  }
58127
58127
  debug("thenify");
58128
- return (resolve5, reject) => {
58128
+ return (resolve6, reject) => {
58129
58129
  const p2 = this._loadRegistered();
58130
58130
  return p2.then(() => {
58131
58131
  this[kThenifyDoNotWrap] = true;
58132
- return resolve5(this._server);
58132
+ return resolve6(this._server);
58133
58133
  }, reject);
58134
58134
  };
58135
58135
  }
@@ -58398,12 +58398,12 @@ var require_boot = __commonJS({
58398
58398
  throw new AVV_ERR_CALLBACK_NOT_FN("close", typeof func);
58399
58399
  }
58400
58400
  } else {
58401
- promise2 = new Promise(function(resolve5, reject) {
58401
+ promise2 = new Promise(function(resolve6, reject) {
58402
58402
  func = function(err) {
58403
58403
  if (err) {
58404
58404
  return reject(err);
58405
58405
  }
58406
- resolve5();
58406
+ resolve6();
58407
58407
  };
58408
58408
  });
58409
58409
  }
@@ -58423,7 +58423,7 @@ var require_boot = __commonJS({
58423
58423
  queueMicrotask(this.start.bind(this));
58424
58424
  return;
58425
58425
  }
58426
- return new Promise((resolve5, reject) => {
58426
+ return new Promise((resolve6, reject) => {
58427
58427
  this._readyQ.push(readyPromiseCB);
58428
58428
  this.start();
58429
58429
  const relativeContext = this._current[0].server;
@@ -58431,7 +58431,7 @@ var require_boot = __commonJS({
58431
58431
  if (err) {
58432
58432
  reject(err);
58433
58433
  } else {
58434
- resolve5(relativeContext);
58434
+ resolve6(relativeContext);
58435
58435
  }
58436
58436
  process.nextTick(done);
58437
58437
  }
@@ -59691,8 +59691,8 @@ var require_promise = __commonJS({
59691
59691
  var { kTestInternals } = require_symbols3();
59692
59692
  function withResolvers() {
59693
59693
  let res, rej;
59694
- const promise2 = new Promise((resolve5, reject) => {
59695
- res = resolve5;
59694
+ const promise2 = new Promise((resolve6, reject) => {
59695
+ res = resolve6;
59696
59696
  rej = reject;
59697
59697
  });
59698
59698
  return { promise: promise2, resolve: res, reject: rej };
@@ -59791,15 +59791,15 @@ var require_server = __commonJS({
59791
59791
  if (cb === void 0) {
59792
59792
  const listening = listenPromise.call(this, server, listenOptions);
59793
59793
  return listening.then((address) => {
59794
- const { promise: promise2, resolve: resolve5 } = PonyPromise.withResolvers();
59794
+ const { promise: promise2, resolve: resolve6 } = PonyPromise.withResolvers();
59795
59795
  if (host === "localhost") {
59796
59796
  multipleBindings.call(this, server, httpHandler, options, listenOptions, () => {
59797
59797
  this[kState].listening = true;
59798
- resolve5(address);
59798
+ resolve6(address);
59799
59799
  onListenHookRunner(this);
59800
59800
  });
59801
59801
  } else {
59802
- resolve5(address);
59802
+ resolve6(address);
59803
59803
  onListenHookRunner(this);
59804
59804
  }
59805
59805
  return promise2;
@@ -59926,7 +59926,7 @@ var require_server = __commonJS({
59926
59926
  }
59927
59927
  return this.ready().then(() => {
59928
59928
  if (this[kState].aborted) return;
59929
- const { promise: promise2, resolve: resolve5, reject } = PonyPromise.withResolvers();
59929
+ const { promise: promise2, resolve: resolve6, reject } = PonyPromise.withResolvers();
59930
59930
  const errEventHandler = (err) => {
59931
59931
  cleanup();
59932
59932
  this[kState].listening = false;
@@ -59935,7 +59935,7 @@ var require_server = __commonJS({
59935
59935
  const listeningEventHandler = () => {
59936
59936
  cleanup();
59937
59937
  this[kState].listening = true;
59938
- resolve5(logServerAddress.call(
59938
+ resolve6(logServerAddress.call(
59939
59939
  this,
59940
59940
  server,
59941
59941
  listenOptions.listenTextResolver || defaultResolveServerListeningText
@@ -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 Readable3 = require("node:stream").Readable;
61519
+ var Readable4 = 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 = Readable3.fromWeb(payload);
62054
+ const nodeStream = Readable4.fromWeb(payload);
62055
62055
  sendStream(nodeStream, res, reply);
62056
62056
  }
62057
62057
  function sendStream(payload, res, reply) {
@@ -77154,7 +77154,7 @@ 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
77156
  var { randomUUID: randomUUID5 } = require("node:crypto");
77157
- var { Readable: Readable3 } = require("node:stream");
77157
+ var { Readable: Readable4 } = 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";
@@ -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 = Readable3.from(asyncIterator());
77196
+ const stream = Readable4.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: Readable3, addAbortSignal } = require("node:stream");
77211
+ var { Readable: Readable4, 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
- Readable3.call(this, {
77249
+ Readable4.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, Readable3);
77381
+ util2.inherits(Request2, Readable4);
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: Readable3, addAbortSignal } = require("node:stream");
77586
+ var { Writable, Readable: Readable4, 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 Readable3({ read }) };
77593
+ this._lightMyRequest = { headers: null, trailers: {}, stream: new Readable4({ 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 Readable3.from(response._lightMyRequest.payloadChunks);
77739
+ return Readable4.from(response._lightMyRequest.payloadChunks);
77740
77740
  };
77741
77741
  return res;
77742
77742
  }
@@ -78664,9 +78664,9 @@ var require_light_my_request = __commonJS({
78664
78664
  const res = new Response3(req, callback);
78665
78665
  return makeRequest(dispatchFunc, server, req, res);
78666
78666
  } else {
78667
- return new Promise((resolve5, reject) => {
78667
+ return new Promise((resolve6, reject) => {
78668
78668
  const req = new RequestConstructor(options);
78669
- const res = new Response3(req, resolve5, reject);
78669
+ const res = new Response3(req, resolve6, reject);
78670
78670
  makeRequest(dispatchFunc, server, req, res);
78671
78671
  });
78672
78672
  }
@@ -84625,10 +84625,10 @@ var require_raw_body = __commonJS({
84625
84625
  if (done) {
84626
84626
  return readStream(stream, encoding, length, limit, wrap(done));
84627
84627
  }
84628
- return new Promise(function executor(resolve5, reject) {
84628
+ return new Promise(function executor(resolve6, reject) {
84629
84629
  readStream(stream, encoding, length, limit, function onRead(err, buf) {
84630
84630
  if (err) return reject(err);
84631
- resolve5(buf);
84631
+ resolve6(buf);
84632
84632
  });
84633
84633
  });
84634
84634
  }
@@ -84871,7 +84871,7 @@ var require_windows = __commonJS({
84871
84871
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/windows.js"(exports2, module2) {
84872
84872
  module2.exports = isexe;
84873
84873
  isexe.sync = sync;
84874
- var fs5 = require("fs");
84874
+ var fs6 = require("fs");
84875
84875
  function checkPathExt(path4, options) {
84876
84876
  var pathext = options.pathExt !== void 0 ? options.pathExt : process.env.PATHEXT;
84877
84877
  if (!pathext) {
@@ -84896,12 +84896,12 @@ var require_windows = __commonJS({
84896
84896
  return checkPathExt(path4, options);
84897
84897
  }
84898
84898
  function isexe(path4, options, cb) {
84899
- fs5.stat(path4, function(er, stat) {
84899
+ fs6.stat(path4, function(er, stat) {
84900
84900
  cb(er, er ? false : checkStat(stat, path4, options));
84901
84901
  });
84902
84902
  }
84903
84903
  function sync(path4, options) {
84904
- return checkStat(fs5.statSync(path4), path4, options);
84904
+ return checkStat(fs6.statSync(path4), path4, options);
84905
84905
  }
84906
84906
  }
84907
84907
  });
@@ -84911,14 +84911,14 @@ var require_mode = __commonJS({
84911
84911
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/mode.js"(exports2, module2) {
84912
84912
  module2.exports = isexe;
84913
84913
  isexe.sync = sync;
84914
- var fs5 = require("fs");
84914
+ var fs6 = require("fs");
84915
84915
  function isexe(path4, options, cb) {
84916
- fs5.stat(path4, function(er, stat) {
84916
+ fs6.stat(path4, function(er, stat) {
84917
84917
  cb(er, er ? false : checkStat(stat, options));
84918
84918
  });
84919
84919
  }
84920
84920
  function sync(path4, options) {
84921
- return checkStat(fs5.statSync(path4), options);
84921
+ return checkStat(fs6.statSync(path4), options);
84922
84922
  }
84923
84923
  function checkStat(stat, options) {
84924
84924
  return stat.isFile() && checkMode(stat, options);
@@ -84942,7 +84942,7 @@ var require_mode = __commonJS({
84942
84942
  // ../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js
84943
84943
  var require_isexe = __commonJS({
84944
84944
  "../../node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports2, module2) {
84945
- var fs5 = require("fs");
84945
+ var fs6 = require("fs");
84946
84946
  var core;
84947
84947
  if (process.platform === "win32" || global.TESTING_WINDOWS) {
84948
84948
  core = require_windows();
@@ -84960,12 +84960,12 @@ var require_isexe = __commonJS({
84960
84960
  if (typeof Promise !== "function") {
84961
84961
  throw new TypeError("callback not provided");
84962
84962
  }
84963
- return new Promise(function(resolve5, reject) {
84963
+ return new Promise(function(resolve6, reject) {
84964
84964
  isexe(path4, options || {}, function(er, is) {
84965
84965
  if (er) {
84966
84966
  reject(er);
84967
84967
  } else {
84968
- resolve5(is);
84968
+ resolve6(is);
84969
84969
  }
84970
84970
  });
84971
84971
  });
@@ -85031,27 +85031,27 @@ var require_which = __commonJS({
85031
85031
  opt = {};
85032
85032
  const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
85033
85033
  const found = [];
85034
- const step = (i2) => new Promise((resolve5, reject) => {
85034
+ const step = (i2) => new Promise((resolve6, reject) => {
85035
85035
  if (i2 === pathEnv.length)
85036
- return opt.all && found.length ? resolve5(found) : reject(getNotFoundError(cmd));
85036
+ return opt.all && found.length ? resolve6(found) : reject(getNotFoundError(cmd));
85037
85037
  const ppRaw = pathEnv[i2];
85038
85038
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
85039
85039
  const pCmd = path4.join(pathPart, cmd);
85040
85040
  const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
85041
- resolve5(subStep(p2, i2, 0));
85041
+ resolve6(subStep(p2, i2, 0));
85042
85042
  });
85043
- const subStep = (p2, i2, ii) => new Promise((resolve5, reject) => {
85043
+ const subStep = (p2, i2, ii) => new Promise((resolve6, reject) => {
85044
85044
  if (ii === pathExt.length)
85045
- return resolve5(step(i2 + 1));
85045
+ return resolve6(step(i2 + 1));
85046
85046
  const ext = pathExt[ii];
85047
85047
  isexe(p2 + ext, { pathExt: pathExtExe }, (er, is) => {
85048
85048
  if (!er && is) {
85049
85049
  if (opt.all)
85050
85050
  found.push(p2 + ext);
85051
85051
  else
85052
- return resolve5(p2 + ext);
85052
+ return resolve6(p2 + ext);
85053
85053
  }
85054
- return resolve5(subStep(p2, i2, ii + 1));
85054
+ return resolve6(subStep(p2, i2, ii + 1));
85055
85055
  });
85056
85056
  });
85057
85057
  return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
@@ -85206,16 +85206,16 @@ var require_shebang_command = __commonJS({
85206
85206
  var require_readShebang = __commonJS({
85207
85207
  "../../node_modules/.pnpm/cross-spawn@7.0.6/node_modules/cross-spawn/lib/util/readShebang.js"(exports2, module2) {
85208
85208
  "use strict";
85209
- var fs5 = require("fs");
85209
+ var fs6 = require("fs");
85210
85210
  var shebangCommand = require_shebang_command();
85211
85211
  function readShebang(command) {
85212
85212
  const size = 150;
85213
85213
  const buffer = Buffer.alloc(size);
85214
85214
  let fd;
85215
85215
  try {
85216
- fd = fs5.openSync(command, "r");
85217
- fs5.readSync(fd, buffer, 0, size, 0);
85218
- fs5.closeSync(fd);
85216
+ fd = fs6.openSync(command, "r");
85217
+ fs6.readSync(fd, buffer, 0, size, 0);
85218
+ fs6.closeSync(fd);
85219
85219
  } catch (e2) {
85220
85220
  }
85221
85221
  return shebangCommand(buffer.toString());
@@ -87858,6 +87858,9 @@ async function writeAssetCache(assetPath, buffer, config2) {
87858
87858
  await fs.promises.writeFile(cachePath, buffer, { mode: 384 });
87859
87859
  return cachePath;
87860
87860
  }
87861
+ function isSkilderPath(filePath) {
87862
+ return filePath.startsWith(SKILDER_FILE_PREFIX);
87863
+ }
87861
87864
  function resolveFilePath(filePath, config2) {
87862
87865
  const workingDirPrefix = config2.workingDir.endsWith(path.sep) ? config2.workingDir : config2.workingDir + path.sep;
87863
87866
  if (filePath.startsWith(SKILDER_ASSET_PREFIX)) {
@@ -89103,8 +89106,8 @@ function getElementAtPath(obj, path4) {
89103
89106
  }
89104
89107
  function promiseAllObject(promisesObj) {
89105
89108
  const keys = Object.keys(promisesObj);
89106
- const promises3 = keys.map((key) => promisesObj[key]);
89107
- return Promise.all(promises3).then((results) => {
89109
+ const promises4 = keys.map((key) => promisesObj[key]);
89110
+ return Promise.all(promises4).then((results) => {
89108
89111
  const resolvedObj = {};
89109
89112
  for (let i2 = 0; i2 < keys.length; i2++) {
89110
89113
  resolvedObj[keys[i2]] = results[i2];
@@ -109452,9 +109455,9 @@ var SseMCPTransport = class {
109452
109455
  );
109453
109456
  }
109454
109457
  async start() {
109455
- return new Promise((resolve5, reject) => {
109458
+ return new Promise((resolve6, reject) => {
109456
109459
  if (this.connected) {
109457
- return resolve5();
109460
+ return resolve6();
109458
109461
  }
109459
109462
  this.abortController = new AbortController();
109460
109463
  const establishConnection = async (triedAuth = false) => {
@@ -109521,7 +109524,7 @@ var SseMCPTransport = class {
109521
109524
  });
109522
109525
  }
109523
109526
  this.connected = true;
109524
- resolve5();
109527
+ resolve6();
109525
109528
  } else if (event === "message") {
109526
109529
  try {
109527
109530
  const message = JSONRPCMessageSchema.parse(
@@ -110098,7 +110101,7 @@ var DefaultMCPClient = class {
110098
110101
  resultSchema,
110099
110102
  options
110100
110103
  }) {
110101
- return new Promise((resolve5, reject) => {
110104
+ return new Promise((resolve6, reject) => {
110102
110105
  if (this.isClosed) {
110103
110106
  return reject(
110104
110107
  new MCPClientError({
@@ -110132,7 +110135,7 @@ var DefaultMCPClient = class {
110132
110135
  }
110133
110136
  try {
110134
110137
  const result = resultSchema.parse(response.result);
110135
- resolve5(result);
110138
+ resolve6(result);
110136
110139
  } catch (error48) {
110137
110140
  const parseError = new MCPClientError({
110138
110141
  message: "Failed to parse server response",
@@ -110611,8 +110614,10 @@ function safeParseConfig(data) {
110611
110614
  }
110612
110615
 
110613
110616
  // ../common/src/mcp-transport.builders.ts
110614
- function substituteEnvVars(value) {
110617
+ function substituteEnvVars(value, extraEnv = {}) {
110615
110618
  return value.replace(/\$\{([^}]+)\}/g, (_3, varName) => {
110619
+ if (varName in extraEnv)
110620
+ return extraEnv[varName];
110616
110621
  return process.env[varName] || "";
110617
110622
  });
110618
110623
  }
@@ -110634,7 +110639,7 @@ function getCommandFromRegistryType(registryType) {
110634
110639
  throw new Error(`Unsupported registry type: ${registryType}. Supported types: ${supportedTypes.join(", ")}`);
110635
110640
  }
110636
110641
  }
110637
- function buildStdioArgs(pkg) {
110642
+ function buildStdioArgs(pkg, extraEnv = {}) {
110638
110643
  const args = [];
110639
110644
  const packageArgs = pkg.packageArguments || [];
110640
110645
  const runtimeArgs = pkg.runtimeArguments || [];
@@ -110644,10 +110649,10 @@ function buildStdioArgs(pkg) {
110644
110649
  if (arg.type === "named" && arg.name) {
110645
110650
  args.push(`--${arg.name}`);
110646
110651
  if (arg.value) {
110647
- args.push(substituteEnvVars(String(arg.value)));
110652
+ args.push(substituteEnvVars(String(arg.value), extraEnv));
110648
110653
  }
110649
110654
  } else if (arg.value) {
110650
- args.push(substituteEnvVars(String(arg.value)));
110655
+ args.push(substituteEnvVars(String(arg.value), extraEnv));
110651
110656
  }
110652
110657
  });
110653
110658
  if (registryType === "oci") {
@@ -110661,10 +110666,10 @@ function buildStdioArgs(pkg) {
110661
110666
  if (arg.type === "named" && arg.name) {
110662
110667
  args.push(`--${arg.name}`);
110663
110668
  if (arg.value) {
110664
- args.push(substituteEnvVars(String(arg.value)));
110669
+ args.push(substituteEnvVars(String(arg.value), extraEnv));
110665
110670
  }
110666
110671
  } else if (arg.value) {
110667
- args.push(substituteEnvVars(String(arg.value)));
110672
+ args.push(substituteEnvVars(String(arg.value), extraEnv));
110668
110673
  }
110669
110674
  });
110670
110675
  return args;
@@ -110697,8 +110702,8 @@ function buildStdioTransport(pkg, defaultEnv = {}) {
110697
110702
  throw new Error(`Package registryType is required`);
110698
110703
  }
110699
110704
  const command = registryType === "none" ? identifier : getCommandFromRegistryType(registryType);
110700
- const args = buildStdioArgs(pkg);
110701
110705
  const env = buildEnvironmentVariables(envVars, defaultEnv);
110706
+ const args = buildStdioArgs(pkg, env);
110702
110707
  return {
110703
110708
  command,
110704
110709
  args,
@@ -137125,7 +137130,7 @@ var InfomaniakTranscriptionModel = class {
137125
137130
  };
137126
137131
  }
137127
137132
  if (attempt < maxRetries - 1) {
137128
- await new Promise((resolve5) => setTimeout(resolve5, delayMs));
137133
+ await new Promise((resolve6) => setTimeout(resolve6, delayMs));
137129
137134
  }
137130
137135
  }
137131
137136
  throw new Error(`Transcription timed out after ${maxRetries} attempts`);
@@ -142852,7 +142857,7 @@ var Protocol = class {
142852
142857
  return;
142853
142858
  }
142854
142859
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
142855
- await new Promise((resolve5) => setTimeout(resolve5, pollInterval));
142860
+ await new Promise((resolve6) => setTimeout(resolve6, pollInterval));
142856
142861
  options?.signal?.throwIfAborted();
142857
142862
  }
142858
142863
  } catch (error48) {
@@ -142869,7 +142874,7 @@ var Protocol = class {
142869
142874
  */
142870
142875
  request(request, resultSchema, options) {
142871
142876
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
142872
- return new Promise((resolve5, reject) => {
142877
+ return new Promise((resolve6, reject) => {
142873
142878
  const earlyReject = (error48) => {
142874
142879
  reject(error48);
142875
142880
  };
@@ -142947,7 +142952,7 @@ var Protocol = class {
142947
142952
  if (!parseResult.success) {
142948
142953
  reject(parseResult.error);
142949
142954
  } else {
142950
- resolve5(parseResult.data);
142955
+ resolve6(parseResult.data);
142951
142956
  }
142952
142957
  } catch (error48) {
142953
142958
  reject(error48);
@@ -143208,12 +143213,12 @@ var Protocol = class {
143208
143213
  }
143209
143214
  } catch {
143210
143215
  }
143211
- return new Promise((resolve5, reject) => {
143216
+ return new Promise((resolve6, reject) => {
143212
143217
  if (signal.aborted) {
143213
143218
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
143214
143219
  return;
143215
143220
  }
143216
- const timeoutId = setTimeout(resolve5, interval);
143221
+ const timeoutId = setTimeout(resolve6, interval);
143217
143222
  signal.addEventListener("abort", () => {
143218
143223
  clearTimeout(timeoutId);
143219
143224
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -144083,12 +144088,12 @@ var StdioServerTransport = class {
144083
144088
  this.onclose?.();
144084
144089
  }
144085
144090
  send(message) {
144086
- return new Promise((resolve5) => {
144091
+ return new Promise((resolve6) => {
144087
144092
  const json3 = serializeMessage(message);
144088
144093
  if (this._stdout.write(json3)) {
144089
- resolve5();
144094
+ resolve6();
144090
144095
  } else {
144091
- this._stdout.once("drain", resolve5);
144096
+ this._stdout.once("drain", resolve6);
144092
144097
  }
144093
144098
  });
144094
144099
  }
@@ -144176,14 +144181,45 @@ var FileService = class FileService2 extends LifecycleService {
144176
144181
  SKILDER_MAX_FILE_SIZE_MB: String(this.maxFileSizeMB)
144177
144182
  };
144178
144183
  }
144179
- async sweepDirByAge(dir, maxAgeMs, label) {
144184
+ /**
144185
+ * Resolve a relative path under the working dir for transient files written
144186
+ * by MCP servers (e.g. `<workspaceId>/playwright-mcp/shot.png`). Rejects any
144187
+ * `..` segment so callers can't escape the working dir.
144188
+ */
144189
+ resolveTransientPath(rel) {
144190
+ const resolved = path2.resolve(this.workingDir, rel);
144191
+ if (resolved !== this.workingDir && !resolved.startsWith(this.workingDir + path2.sep)) {
144192
+ throw new Error(`Path traversal detected in "${rel}".`);
144193
+ }
144194
+ return resolved;
144195
+ }
144196
+ /**
144197
+ * Resolve the per-workspace working directory used for transient files
144198
+ * produced by MCP servers (e.g. Playwright screenshots). The segment is the
144199
+ * raw workspaceId; callers must pass a trusted id from auth context.
144200
+ */
144201
+ getWorkspaceDir(workspaceId) {
144202
+ if (!workspaceId || workspaceId.includes("/") || workspaceId.includes("..") || workspaceId.includes(path2.sep)) {
144203
+ throw new Error(`Invalid workspaceId for workspace dir: "${workspaceId}"`);
144204
+ }
144205
+ return path2.join(this.workingDir, workspaceId);
144206
+ }
144207
+ async sweepDirByAge(dir, maxAgeMs, label, maxDepth = 2, skipDirs = /* @__PURE__ */ new Set()) {
144180
144208
  let deletedCount = 0;
144181
144209
  let bytesFreed = 0;
144182
- try {
144183
- const entries = await fs3.promises.readdir(dir);
144184
- const now2 = Date.now();
144210
+ const now2 = Date.now();
144211
+ const walk = async (current, depth) => {
144212
+ let entries;
144213
+ try {
144214
+ entries = await fs3.promises.readdir(current);
144215
+ } catch (error48) {
144216
+ if (error48 instanceof Error && "code" in error48 && error48.code === "ENOENT")
144217
+ return;
144218
+ this.logger.warn({ dir: current, error: error48 }, `${label} failed to read directory`);
144219
+ return;
144220
+ }
144185
144221
  for (const entry of entries) {
144186
- const filePath = path2.join(dir, entry);
144222
+ const filePath = path2.join(current, entry);
144187
144223
  try {
144188
144224
  const stat = await fs3.promises.lstat(filePath);
144189
144225
  if (stat.isSymbolicLink()) {
@@ -144195,6 +144231,8 @@ var FileService = class FileService2 extends LifecycleService {
144195
144231
  await fs3.promises.unlink(filePath);
144196
144232
  bytesFreed += stat.size;
144197
144233
  deletedCount++;
144234
+ } else if (stat.isDirectory() && depth < maxDepth && !skipDirs.has(filePath)) {
144235
+ await walk(filePath, depth + 1);
144198
144236
  }
144199
144237
  } catch (error48) {
144200
144238
  if (error48 instanceof Error && "code" in error48 && error48.code === "ENOENT")
@@ -144202,16 +144240,13 @@ var FileService = class FileService2 extends LifecycleService {
144202
144240
  this.logger.warn({ filePath, error: error48 }, `${label} failed to process file`);
144203
144241
  }
144204
144242
  }
144205
- } catch (error48) {
144206
- if (error48 instanceof Error && "code" in error48 && error48.code === "ENOENT") {
144207
- return { deletedCount, bytesFreed };
144208
- }
144209
- this.logger.warn({ error: error48 }, `${label} failed to read directory`);
144210
- }
144243
+ };
144244
+ await walk(dir, 0);
144211
144245
  return { deletedCount, bytesFreed };
144212
144246
  }
144213
144247
  async runGarbageCollection() {
144214
- const { deletedCount, bytesFreed } = await this.sweepDirByAge(this.workingDir, this.gcMaxAgeMs, "GC");
144248
+ const skip2 = /* @__PURE__ */ new Set([this.getAssetCacheDir()]);
144249
+ const { deletedCount, bytesFreed } = await this.sweepDirByAge(this.workingDir, this.gcMaxAgeMs, "GC", 2, skip2);
144215
144250
  if (deletedCount > 0) {
144216
144251
  this.logger.info({ deletedCount, bytesFreed }, `GC completed: ${deletedCount} file(s) deleted, ${bytesFreed} bytes freed`);
144217
144252
  }
@@ -144268,7 +144303,7 @@ var FileService = class FileService2 extends LifecycleService {
144268
144303
  }
144269
144304
  /**
144270
144305
  * Stream an asset to the local cache without buffering the whole payload in
144271
- * memory. Used by the runtime's `download_asset` flow to handle large files
144306
+ * memory. Used by the runtime's `read_skilder_file` flow to handle large files
144272
144307
  * (the new content-addressed `/assets/:id` endpoint streams bytes directly).
144273
144308
  *
144274
144309
  * Enforces the same size limit as `cacheAsset`. Returns the absolute path
@@ -145192,22 +145227,26 @@ function errorResult(text2, skillIds) {
145192
145227
  function appendReferencedResources(lines, mentions, related, skillName) {
145193
145228
  if (mentions.length === 0) return;
145194
145229
  lines.push("## Resources");
145195
- lines.push("Only resources referenced in the skill description or instructions are shown.");
145196
145230
  lines.push("");
145197
145231
  for (const m2 of mentions) {
145198
- const resourcePath = `/${skillName}/${m2.qualifiedName}`;
145199
145232
  const entry = related.find((r2) => (r2.path ? `${r2.path}/${r2.name}` : r2.name) === m2.qualifiedName);
145200
- lines.push(`### ${m2.name}`);
145233
+ const path4 = m2.class === "downloadable" && entry?.id ? generateSkilderAssetPath(entry.id, entry.name) : `/${skillName}/${m2.qualifiedName}`;
145234
+ lines.push(`### ${m2.name} (${m2.class})`);
145201
145235
  if (entry?.description) {
145202
145236
  lines.push(entry.description);
145203
145237
  }
145204
- lines.push("");
145205
145238
  if (m2.class === "learnable") {
145206
- lines.push(`**Consume:** \`learn --path "${resourcePath}"\``);
145239
+ lines.push(`**Consume:** \`learn --path "${path4}"\``);
145207
145240
  } else if (m2.class === "executable") {
145208
- lines.push(`**Consume:** \`execute_script --path "${resourcePath}"\``);
145241
+ lines.push(`**Consume:** \`execute_script --path "${path4}"\``);
145209
145242
  } else {
145210
- lines.push(`**Consume:** \`download_asset --path "${resourcePath}"\``);
145243
+ lines.push("**How to use:**");
145244
+ lines.push(
145245
+ `- **Default \u2014 pass URI to a tool:** send the path as-is (e.g. \`{ "filePath": "${path4}" }\`). Do NOT call \`read_skilder_file\` unless the tool requires raw bytes.`
145246
+ );
145247
+ lines.push(
145248
+ `- **Read bytes (text/image only):** \`read_skilder_file --path "${path4}"\` \u2014 use only for text inspection or image preview. Binary files (PDF, zip, xlsx, etc.) will fail. Always check before hand that you really need the bytes before attempting a read.`
145249
+ );
145211
145250
  }
145212
145251
  lines.push("");
145213
145252
  }
@@ -145860,41 +145899,187 @@ To execute this script:
145860
145899
  skillId: skill.id
145861
145900
  };
145862
145901
  }
145863
- async function handleDownloadAsset(args, ctx) {
145902
+
145903
+ // src/services/static-tools/read-skilder-file.handler.ts
145904
+ var fs5 = __toESM(require("fs"));
145905
+ var import_node_stream3 = require("node:stream");
145906
+ var IMAGE_EXTENSIONS = {
145907
+ ".png": "image/png",
145908
+ ".jpg": "image/jpeg",
145909
+ ".jpeg": "image/jpeg",
145910
+ ".gif": "image/gif",
145911
+ ".webp": "image/webp",
145912
+ ".svg": "image/svg+xml"
145913
+ };
145914
+ var TEXT_EXTENSIONS = {
145915
+ ".txt": "text/plain",
145916
+ ".md": "text/markdown",
145917
+ ".markdown": "text/markdown",
145918
+ ".json": "application/json",
145919
+ ".xml": "application/xml",
145920
+ ".csv": "text/csv",
145921
+ ".tsv": "text/tab-separated-values",
145922
+ ".yaml": "text/yaml",
145923
+ ".yml": "text/yaml",
145924
+ ".html": "text/html",
145925
+ ".htm": "text/html",
145926
+ ".log": "text/plain"
145927
+ };
145928
+ function extensionOf(filePath) {
145929
+ const lower = filePath.toLowerCase();
145930
+ const dot = lower.lastIndexOf(".");
145931
+ return dot === -1 ? void 0 : lower.slice(dot);
145932
+ }
145933
+ function imageMimeFromExtension(filePath) {
145934
+ const ext = extensionOf(filePath);
145935
+ return ext ? IMAGE_EXTENSIONS[ext] : void 0;
145936
+ }
145937
+ function textMimeFromExtension(filePath) {
145938
+ const ext = extensionOf(filePath);
145939
+ return ext ? TEXT_EXTENSIONS[ext] : void 0;
145940
+ }
145941
+ function getBackendUrl4() {
145942
+ return (process.env.SKILDER_BACKEND_URL || "http://localhost:3000").replace(/\/$/, "");
145943
+ }
145944
+ async function readLocalBytes(absolutePath, fileService) {
145945
+ const stat = await fs5.promises.stat(absolutePath);
145946
+ if (stat.size > fileService.maxAssetBytes) {
145947
+ throw new DownloadAssetError(
145948
+ `Error: File "${absolutePath}" is ${stat.size} bytes, exceeding the ${Math.floor(fileService.maxAssetBytes / (1024 * 1024))}MB limit.`
145949
+ );
145950
+ }
145951
+ return fs5.promises.readFile(absolutePath);
145952
+ }
145953
+ async function fetchAssetIntoCache(assetUri, resourceId, deps) {
145954
+ const assetUrl = `${getBackendUrl4()}/assets/${encodeURIComponent(resourceId)}`;
145955
+ let response;
145956
+ try {
145957
+ response = await fetch(assetUrl, { headers: { Authorization: `Bearer ${deps.userKey}` } });
145958
+ } catch (err) {
145959
+ deps.logger.error({ err, assetUri, url: assetUrl }, "Failed to fetch asset from backend");
145960
+ throw new DownloadAssetError(
145961
+ `Error: Failed to download asset "${assetUri}". Please try again. If the issue persists, verify that the Skilder backend is reachable and your authentication is valid.`
145962
+ );
145963
+ }
145964
+ if (!response.ok) {
145965
+ if (response.status === 404) {
145966
+ throw new DownloadAssetError(`Error: Asset "${assetUri}" has not been uploaded yet, or no longer exists.`);
145967
+ }
145968
+ if (response.status === 401 || response.status === 403) {
145969
+ throw new DownloadAssetError(`Error: Not authorized to fetch "${assetUri}".`);
145970
+ }
145971
+ throw new DownloadAssetError(`Error: Failed to fetch "${assetUri}" (HTTP ${response.status}).`);
145972
+ }
145973
+ if (!response.body) {
145974
+ throw new DownloadAssetError(`Error: Backend returned no body for "${assetUri}".`);
145975
+ }
145976
+ const contentLengthHeader = response.headers.get("content-length");
145977
+ const expectedBytes = contentLengthHeader ? Number.parseInt(contentLengthHeader, 10) : void 0;
145978
+ if (expectedBytes !== void 0 && Number.isFinite(expectedBytes) && expectedBytes > deps.fileService.maxAssetBytes) {
145979
+ const maxMB = Math.floor(deps.fileService.maxAssetBytes / (1024 * 1024));
145980
+ throw new DownloadAssetError(`Error: "${assetUri}" is ${expectedBytes} bytes, exceeding the ${maxMB}MB limit.`);
145981
+ }
145982
+ const nodeStream = import_node_stream3.Readable.fromWeb(response.body);
145983
+ try {
145984
+ return await deps.fileService.cacheAssetFromStream(assetUri, nodeStream, {
145985
+ expectedBytes: Number.isFinite(expectedBytes) ? expectedBytes : void 0
145986
+ });
145987
+ } catch (writeError) {
145988
+ if (writeError instanceof AssetTooLargeError) {
145989
+ const maxMB = Math.floor(writeError.maxBytes / (1024 * 1024));
145990
+ throw new DownloadAssetError(
145991
+ `Error: "${assetUri}" is ${writeError.bufferBytes} bytes, exceeding the ${maxMB}MB limit.`
145992
+ );
145993
+ }
145994
+ if (writeError instanceof AssetTruncatedError) {
145995
+ throw new DownloadAssetError(
145996
+ `Error: "${assetUri}" download was truncated (received ${writeError.receivedBytes} of ${writeError.expectedBytes} bytes). Please retry.`
145997
+ );
145998
+ }
145999
+ deps.logger.error({ err: writeError, assetUri }, "Failed to cache asset");
146000
+ throw new DownloadAssetError(`Error: Failed to cache "${assetUri}".`);
146001
+ }
146002
+ }
146003
+ function buildSuccessResult(reportedPath, absolutePath, bytes, skillIds) {
146004
+ const content = [];
146005
+ const imageMime = imageMimeFromExtension(absolutePath);
146006
+ if (imageMime) {
146007
+ content.push({ type: "image", mimeType: imageMime, data: bytes.toString("base64") });
146008
+ } else {
146009
+ const textMime = textMimeFromExtension(absolutePath);
146010
+ if (textMime) {
146011
+ content.push({ type: "text", text: bytes.toString("utf8") });
146012
+ } else {
146013
+ content.push({
146014
+ type: "text",
146015
+ text: `File "${reportedPath}" is binary (${bytes.length} bytes). It cannot be inlined; pass the path to a binary-aware tool (e.g. \`execute_script\`) to process it.`
146016
+ });
146017
+ }
146018
+ }
146019
+ return {
146020
+ response: { content },
146021
+ ...skillIds ? { skillIds } : {}
146022
+ };
146023
+ }
146024
+ async function handleReadSkilderFile(args, ctx) {
145864
146025
  const path4 = args.path;
145865
146026
  if (!path4) {
145866
146027
  return errorResult(
145867
146028
  `Error: path is required.
145868
146029
 
145869
- Usage: download_asset --path "/Skill Name/filename.ext"
146030
+ Usage:
146031
+ - \`read_skilder_file --path "@skilder-file:/<workspaceId>/playwright-mcp/shot.png"\`
146032
+ - \`read_skilder_file --path "@skilder-asset:/<resourceId>/file.xlsx"\``
146033
+ );
146034
+ }
146035
+ if (!ctx.fileService) {
146036
+ return errorResult("Error: File service is not available in this runtime configuration.");
146037
+ }
146038
+ if (!isSkilderPath(path4) && !isSkilderAssetPath(path4)) {
146039
+ return errorResult(
146040
+ `Error: path must be a Skilder URI.
145870
146041
 
145871
- Examples:
145872
- - \`download_asset --path "/Data Processing/template.xlsx"\`
145873
- - \`download_asset --path "/Reports/logo.png"\``
146042
+ Accepted forms:
146043
+ - \`@skilder-file:/<workspaceId>/...\` for transient runtime files.
146044
+ - \`@skilder-asset:/<resourceId>/<filename>\` for skill assets (use \`learn\` to discover these).`
145874
146045
  );
145875
146046
  }
145876
146047
  try {
145877
- const { assetPath, itemName, mimetype, skillId } = await downloadSkillAsset(path4, {
145878
- catalog: ctx.catalog,
145879
- fileService: ctx.fileService,
145880
- userKey: ctx.identity.userKey,
145881
- logger: ctx.logger
145882
- });
145883
- return {
145884
- response: {
145885
- content: [
145886
- {
145887
- type: "text",
145888
- text: `Successfully downloaded "${itemName}" (${mimetype}).
145889
-
145890
- **Local path:** \`${assetPath}\`
145891
-
145892
- This file can be used with other file I/O tools that accept \`@skilder-asset:/\` paths. This path can be resolved by any runtime \u2014 the asset will be fetched from the backend automatically if not cached locally.`
145893
- }
145894
- ]
145895
- },
145896
- skillIds: [skillId]
145897
- };
146048
+ if (isSkilderPath(path4)) {
146049
+ const rel = path4.slice("@skilder-file:/".length);
146050
+ let fullPath;
146051
+ try {
146052
+ fullPath = ctx.fileService.resolveTransientPath(rel);
146053
+ } catch {
146054
+ return errorResult(`Error: Path traversal detected in "${path4}".`);
146055
+ }
146056
+ let bytes2;
146057
+ try {
146058
+ bytes2 = await readLocalBytes(fullPath, ctx.fileService);
146059
+ } catch (err) {
146060
+ if (err instanceof DownloadAssetError) return errorResult(err.userMessage);
146061
+ if (err instanceof Error && "code" in err && err.code === "ENOENT") {
146062
+ return errorResult(`Error: File "${path4}" not found. It may have been garbage-collected or never created.`);
146063
+ }
146064
+ throw err;
146065
+ }
146066
+ return buildSuccessResult(path4, fullPath, bytes2);
146067
+ }
146068
+ const { resourceId } = parseAssetPath(path4);
146069
+ if (!ctx.identity.userKey) {
146070
+ return errorResult("Error: Authentication is not available. Cannot fetch assets without a user key.");
146071
+ }
146072
+ const cachePath = ctx.fileService.getAssetCachePath(path4);
146073
+ const cached2 = await ctx.fileService.isAssetCached(path4);
146074
+ if (!cached2) {
146075
+ await fetchAssetIntoCache(path4, resourceId, {
146076
+ fileService: ctx.fileService,
146077
+ userKey: ctx.identity.userKey,
146078
+ logger: ctx.logger
146079
+ });
146080
+ }
146081
+ const bytes = await readLocalBytes(cachePath, ctx.fileService);
146082
+ return buildSuccessResult(path4, cachePath, bytes);
145898
146083
  } catch (error48) {
145899
146084
  if (error48 instanceof DownloadAssetError) {
145900
146085
  return errorResult(error48.userMessage, error48.skillId ? [error48.skillId] : void 0);
@@ -145952,7 +146137,7 @@ var STATIC_TOOL_NAMES = [
145952
146137
  "execute_script",
145953
146138
  "feedback_skill",
145954
146139
  "call_tool",
145955
- "download_asset",
146140
+ "read_skilder_file",
145956
146141
  "delegate"
145957
146142
  ];
145958
146143
  var HANDLERS = {
@@ -145961,7 +146146,7 @@ var HANDLERS = {
145961
146146
  execute_script: handleExecuteScript,
145962
146147
  feedback_skill: handleFeedbackSkill,
145963
146148
  call_tool: handleCallTool,
145964
- download_asset: handleDownloadAsset,
146149
+ read_skilder_file: handleReadSkilderFile,
145965
146150
  delegate: handleDelegate
145966
146151
  };
145967
146152
  var StaticToolRegistry = class StaticToolRegistry2 {
@@ -146149,7 +146334,7 @@ var SkillService = class SkillService2 extends LifecycleService {
146149
146334
  this.prepareCallToolTool()
146150
146335
  ];
146151
146336
  if (this.fileService) {
146152
- tools.push(this.prepareDownloadAssetTool());
146337
+ tools.push(this.prepareReadSkilderFileTool());
146153
146338
  }
146154
146339
  if (process.env.SKILDER_ENABLE_AGENT_DELEGATE === "true" && (this.identity.delegateDepth ?? 0) < MAX_DELEGATE_DEPTH) {
146155
146340
  tools.push(this.prepareDelegateTool());
@@ -146348,41 +146533,47 @@ Scripts run on their linked runtime.`,
146348
146533
  };
146349
146534
  }
146350
146535
  /**
146351
- * Prepare the download_asset tool definition.
146352
- * Downloads a binary asset from a skill and saves it to a local file.
146536
+ * Prepare the read_skilder_file tool definition.
146537
+ * Reads a file from any Skilder-managed location and returns it (plus an
146538
+ * inline image content block for image MIME types).
146353
146539
  */
146354
- prepareDownloadAssetTool() {
146540
+ prepareReadSkilderFileTool() {
146355
146541
  return {
146356
- name: "download_asset",
146357
- title: "download_asset",
146358
- description: `Download a binary asset from a skill and save it to a local file. Returns a \`@skilder-file:/\` path for use by other I/O file tools.
146542
+ name: "read_skilder_file",
146543
+ title: "read_skilder_file",
146544
+ description: `Read the bytes of a Skilder-managed file and return them in a form the agent can directly consume. Use this when you need to actually see/process the file's contents (e.g. look at a screenshot, read a CSV) \u2014 not when you just need to pass a path to another tool.
146359
146545
 
146360
- Path format: \`/Skill Name/filename.ext\`
146546
+ Returned content depends on the file type:
146547
+ - Images (png, jpg, gif, webp, svg) \u2014 inline image content block so vision-capable agents can see the file directly.
146548
+ - Text-ish files (text/*, JSON, XML, CSV) \u2014 inline text content with the file's contents.
146549
+ - Other binary files \u2014 handle via a binary-aware tool (e.g. \`execute_script\`); the Skilder path you already have is what that tool needs.
146361
146550
 
146362
- Examples:
146363
- - \`download_asset --path "/Data Processing/template.xlsx"\`
146364
- - \`download_asset --path "/Reports/logo.png"\`
146551
+ Accepted path forms:
146552
+ - \`@skilder-file:/<path>\` \u2014 transient runtime file (e.g. an MCP-produced screenshot under \`<workspaceId>/playwright-mcp/\`).
146553
+ - \`@skilder-asset:/<resourceId>/<filename>\` \u2014 backend-hosted skill asset; fetched on cache miss. Surfaced by \`learn\`.
146365
146554
 
146366
- The path must point to a downloadable (binary) resource in a skill's related items. Learnable (text) resources should be accessed via \`learn\`, and executable scripts via \`execute_script\`.`,
146555
+ Examples:
146556
+ - \`read_skilder_file --path "@skilder-file:/ws123/playwright-mcp/step-01.png"\`
146557
+ - \`read_skilder_file --path "@skilder-asset:/0xabc/report.csv"\``,
146367
146558
  inputSchema: {
146368
146559
  type: "object",
146369
146560
  properties: {
146370
146561
  path: {
146371
146562
  type: "string",
146372
- description: "Path to the downloadable asset. Format: /Skill Name/filename.ext"
146563
+ description: "Skilder URI: @skilder-file:/<path> or @skilder-asset:/<resourceId>/<filename>"
146373
146564
  }
146374
146565
  },
146375
146566
  required: ["path"]
146376
146567
  },
146377
146568
  annotations: {
146378
- title: "Download Asset",
146379
- readOnlyHint: false,
146380
- idempotentHint: false,
146569
+ title: "Read Skilder File",
146570
+ readOnlyHint: true,
146571
+ idempotentHint: true,
146381
146572
  openWorldHint: false
146382
146573
  },
146383
146574
  __routing: {
146384
146575
  type: "static",
146385
- toolName: "download_asset",
146576
+ toolName: "read_skilder_file",
146386
146577
  workspaceId: this.identity.workspaceId
146387
146578
  }
146388
146579
  };
@@ -147242,7 +147433,7 @@ var McpServer = class {
147242
147433
  let task = createTaskResult.task;
147243
147434
  const pollInterval = task.pollInterval ?? 5e3;
147244
147435
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
147245
- await new Promise((resolve5) => setTimeout(resolve5, pollInterval));
147436
+ await new Promise((resolve6) => setTimeout(resolve6, pollInterval));
147246
147437
  const updatedTask = await extra.taskStore.getTask(taskId);
147247
147438
  if (!updatedTask) {
147248
147439
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -148971,7 +149162,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
148971
149162
  });
148972
149163
  if (!chunk) {
148973
149164
  if (i2 === 1) {
148974
- await new Promise((resolve5) => setTimeout(resolve5));
149165
+ await new Promise((resolve6) => setTimeout(resolve6));
148975
149166
  maxReadCount = 3;
148976
149167
  continue;
148977
149168
  }
@@ -149467,9 +149658,9 @@ data:
149467
149658
  const initRequest = messages.find((m2) => isInitializeRequest(m2));
149468
149659
  const clientProtocolVersion = initRequest ? initRequest.params.protocolVersion : req.headers.get("mcp-protocol-version") ?? DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
149469
149660
  if (this._enableJsonResponse) {
149470
- return new Promise((resolve5) => {
149661
+ return new Promise((resolve6) => {
149471
149662
  this._streamMapping.set(streamId, {
149472
- resolveJson: resolve5,
149663
+ resolveJson: resolve6,
149473
149664
  cleanup: () => {
149474
149665
  this._streamMapping.delete(streamId);
149475
149666
  }
@@ -150166,12 +150357,14 @@ var import_child_process = require("child_process");
150166
150357
  var import_promises2 = require("fs/promises");
150167
150358
  var import_path2 = require("path");
150168
150359
  var import_os4 = require("os");
150360
+ var import_module = require("module");
150361
+ var import_url = require("url");
150169
150362
  var import_readline = require("readline");
150170
150363
 
150171
150364
  // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.27.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
150172
150365
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
150173
150366
  var import_node_process2 = __toESM(require("node:process"), 1);
150174
- var import_node_stream3 = require("node:stream");
150367
+ var import_node_stream4 = require("node:stream");
150175
150368
  var DEFAULT_INHERITED_ENV_VARS = import_node_process2.default.platform === "win32" ? [
150176
150369
  "APPDATA",
150177
150370
  "HOMEDRIVE",
@@ -150209,7 +150402,7 @@ var StdioClientTransport = class {
150209
150402
  this._stderrStream = null;
150210
150403
  this._serverParams = server;
150211
150404
  if (server.stderr === "pipe" || server.stderr === "overlapped") {
150212
- this._stderrStream = new import_node_stream3.PassThrough();
150405
+ this._stderrStream = new import_node_stream4.PassThrough();
150213
150406
  }
150214
150407
  }
150215
150408
  /**
@@ -150219,7 +150412,7 @@ var StdioClientTransport = class {
150219
150412
  if (this._process) {
150220
150413
  throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
150221
150414
  }
150222
- return new Promise((resolve5, reject) => {
150415
+ return new Promise((resolve6, reject) => {
150223
150416
  this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
150224
150417
  // merge default env with server env because mcp server needs some env vars
150225
150418
  env: {
@@ -150236,7 +150429,7 @@ var StdioClientTransport = class {
150236
150429
  this.onerror?.(error48);
150237
150430
  });
150238
150431
  this._process.on("spawn", () => {
150239
- resolve5();
150432
+ resolve6();
150240
150433
  });
150241
150434
  this._process.on("close", (_code) => {
150242
150435
  this._process = void 0;
@@ -150295,22 +150488,22 @@ var StdioClientTransport = class {
150295
150488
  if (this._process) {
150296
150489
  const processToClose = this._process;
150297
150490
  this._process = void 0;
150298
- const closePromise = new Promise((resolve5) => {
150491
+ const closePromise = new Promise((resolve6) => {
150299
150492
  processToClose.once("close", () => {
150300
- resolve5();
150493
+ resolve6();
150301
150494
  });
150302
150495
  });
150303
150496
  try {
150304
150497
  processToClose.stdin?.end();
150305
150498
  } catch {
150306
150499
  }
150307
- await Promise.race([closePromise, new Promise((resolve5) => setTimeout(resolve5, 2e3).unref())]);
150500
+ await Promise.race([closePromise, new Promise((resolve6) => setTimeout(resolve6, 2e3).unref())]);
150308
150501
  if (processToClose.exitCode === null) {
150309
150502
  try {
150310
150503
  processToClose.kill("SIGTERM");
150311
150504
  } catch {
150312
150505
  }
150313
- await Promise.race([closePromise, new Promise((resolve5) => setTimeout(resolve5, 2e3).unref())]);
150506
+ await Promise.race([closePromise, new Promise((resolve6) => setTimeout(resolve6, 2e3).unref())]);
150314
150507
  }
150315
150508
  if (processToClose.exitCode === null) {
150316
150509
  try {
@@ -150322,15 +150515,15 @@ var StdioClientTransport = class {
150322
150515
  this._readBuffer.clear();
150323
150516
  }
150324
150517
  send(message) {
150325
- return new Promise((resolve5) => {
150518
+ return new Promise((resolve6) => {
150326
150519
  if (!this._process?.stdin) {
150327
150520
  throw new Error("Not connected");
150328
150521
  }
150329
150522
  const json3 = serializeMessage(message);
150330
150523
  if (this._process.stdin.write(json3)) {
150331
- resolve5();
150524
+ resolve6();
150332
150525
  } else {
150333
- this._process.stdin.once("drain", resolve5);
150526
+ this._process.stdin.once("drain", resolve6);
150334
150527
  }
150335
150528
  });
150336
150529
  }
@@ -150340,6 +150533,7 @@ function isElectron() {
150340
150533
  }
150341
150534
 
150342
150535
  // src/services/script-executor.service.ts
150536
+ var import_meta = {};
150343
150537
  var __decorate19 = function(decorators, target, key, desc) {
150344
150538
  var c3 = arguments.length, r2 = c3 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d2;
150345
150539
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r2 = Reflect.decorate(decorators, target, key, desc);
@@ -150357,6 +150551,8 @@ var __param16 = function(paramIndex, decorator) {
150357
150551
  var _a41;
150358
150552
  var _b33;
150359
150553
  var ScriptType2 = dgraph_resolvers_types_exports.ScriptType;
150554
+ var moduleAnchor = typeof __filename === "string" && __filename.length > 0 ? __filename : (0, import_url.fileURLToPath)(import_meta.url);
150555
+ var TSX_CLI_PATH = (0, import_module.createRequire)(moduleAnchor).resolve("tsx/cli");
150360
150556
  var ScriptExecutorService = class ScriptExecutorService2 {
150361
150557
  constructor(loggerService, fileService) {
150362
150558
  this.fileService = fileService;
@@ -150420,13 +150616,13 @@ var ScriptExecutorService = class ScriptExecutorService2 {
150420
150616
  case ScriptType2.Javascript:
150421
150617
  return { command: "node", commandArgs: [filePath, ...args] };
150422
150618
  case ScriptType2.Typescript:
150423
- return { command: "tsx", commandArgs: [filePath, ...args] };
150619
+ return { command: process.execPath, commandArgs: [TSX_CLI_PATH, filePath, ...args] };
150424
150620
  default:
150425
150621
  throw new Error(`Unsupported script type: ${scriptType}`);
150426
150622
  }
150427
150623
  }
150428
150624
  spawnProcess(command, args, timeout2, env) {
150429
- return new Promise((resolve5) => {
150625
+ return new Promise((resolve6) => {
150430
150626
  let stdout = "";
150431
150627
  let stderr = "";
150432
150628
  let killed = false;
@@ -150471,7 +150667,7 @@ var ScriptExecutorService = class ScriptExecutorService2 {
150471
150667
  child.on("error", (error48) => {
150472
150668
  clearTimeout(timeoutId);
150473
150669
  this.logger.error({ err: error48, command }, "Spawned process emitted error");
150474
- resolve5({
150670
+ resolve6({
150475
150671
  success: false,
150476
150672
  stdout,
150477
150673
  stderr,
@@ -150481,7 +150677,7 @@ var ScriptExecutorService = class ScriptExecutorService2 {
150481
150677
  child.on("close", (exitCode) => {
150482
150678
  clearTimeout(timeoutId);
150483
150679
  if (outputTruncated) {
150484
- resolve5({
150680
+ resolve6({
150485
150681
  success: false,
150486
150682
  stdout,
150487
150683
  stderr,
@@ -150490,7 +150686,7 @@ var ScriptExecutorService = class ScriptExecutorService2 {
150490
150686
  return;
150491
150687
  }
150492
150688
  if (killed) {
150493
- resolve5({
150689
+ resolve6({
150494
150690
  success: false,
150495
150691
  stdout,
150496
150692
  stderr,
@@ -150499,14 +150695,14 @@ var ScriptExecutorService = class ScriptExecutorService2 {
150499
150695
  return;
150500
150696
  }
150501
150697
  if (exitCode === 0) {
150502
- resolve5({
150698
+ resolve6({
150503
150699
  success: true,
150504
150700
  stdout,
150505
150701
  stderr: stderr || void 0,
150506
150702
  exitCode: 0
150507
150703
  });
150508
150704
  } else {
150509
- resolve5({
150705
+ resolve6({
150510
150706
  success: false,
150511
150707
  stdout,
150512
150708
  stderr,
@@ -150552,7 +150748,7 @@ var ScriptExecutorService = class ScriptExecutorService2 {
150552
150748
  }
150553
150749
  }
150554
150750
  spawnInteractiveProcess(command, args, timeout2, toolCallTimeout, onRequest, env) {
150555
- return new Promise((resolve5) => {
150751
+ return new Promise((resolve6) => {
150556
150752
  let stderr = "";
150557
150753
  let killed = false;
150558
150754
  let outputTruncated = false;
@@ -150714,7 +150910,7 @@ var ScriptExecutorService = class ScriptExecutorService2 {
150714
150910
  }
150715
150911
  const stdout = outputChunks.join("\n");
150716
150912
  const consoleOutput = consoleChunks.join("\n") || void 0;
150717
- resolve5({ success: false, stdout, consoleOutput, stderr, error: error48.message });
150913
+ resolve6({ success: false, stdout, consoleOutput, stderr, error: error48.message });
150718
150914
  });
150719
150915
  child.on("close", async (exitCode) => {
150720
150916
  childExited = true;
@@ -150728,17 +150924,17 @@ var ScriptExecutorService = class ScriptExecutorService2 {
150728
150924
  const stdout = outputChunks.join("\n");
150729
150925
  const consoleOutput = consoleChunks.join("\n") || void 0;
150730
150926
  if (outputTruncated) {
150731
- resolve5({ success: false, stdout, consoleOutput, stderr, error: `Script output exceeded maximum size of ${MAX_SCRIPT_OUTPUT_SIZE / (1024 * 1024)}MB` });
150927
+ resolve6({ success: false, stdout, consoleOutput, stderr, error: `Script output exceeded maximum size of ${MAX_SCRIPT_OUTPUT_SIZE / (1024 * 1024)}MB` });
150732
150928
  return;
150733
150929
  }
150734
150930
  if (killed) {
150735
- resolve5({ success: false, stdout, consoleOutput, stderr, error: `Script execution timed out after ${currentTimeout}ms` });
150931
+ resolve6({ success: false, stdout, consoleOutput, stderr, error: `Script execution timed out after ${currentTimeout}ms` });
150736
150932
  return;
150737
150933
  }
150738
150934
  if (exitCode === 0) {
150739
- resolve5({ success: true, stdout, consoleOutput, stderr: stderr || void 0, exitCode: 0 });
150935
+ resolve6({ success: true, stdout, consoleOutput, stderr: stderr || void 0, exitCode: 0 });
150740
150936
  } else {
150741
- resolve5({
150937
+ resolve6({
150742
150938
  success: false,
150743
150939
  stdout,
150744
150940
  consoleOutput,
@@ -153022,7 +153218,7 @@ var SSEClientTransport = class {
153022
153218
  }
153023
153219
  _startOrAuth() {
153024
153220
  const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
153025
- return new Promise((resolve5, reject) => {
153221
+ return new Promise((resolve6, reject) => {
153026
153222
  this._eventSource = new EventSource(this._url.href, {
153027
153223
  ...this._eventSourceInit,
153028
153224
  fetch: async (url2, init) => {
@@ -153043,7 +153239,7 @@ var SSEClientTransport = class {
153043
153239
  this._abortController = new AbortController();
153044
153240
  this._eventSource.onerror = (event) => {
153045
153241
  if (event.code === 401 && this._authProvider) {
153046
- this._authThenStart().then(resolve5, reject);
153242
+ this._authThenStart().then(resolve6, reject);
153047
153243
  return;
153048
153244
  }
153049
153245
  const error48 = new SseError(event.code, event.message, event);
@@ -153065,7 +153261,7 @@ var SSEClientTransport = class {
153065
153261
  void this.close();
153066
153262
  return;
153067
153263
  }
153068
- resolve5();
153264
+ resolve6();
153069
153265
  });
153070
153266
  this._eventSource.onmessage = (event) => {
153071
153267
  const messageEvent = event;
@@ -153221,7 +153417,11 @@ var ToolServerService = class ToolServerService2 extends LifecycleService {
153221
153417
  if (this.config.transport === dgraph_resolvers_types_exports.McpTransportType.Stdio && "identifier" in parsedConfig) {
153222
153418
  this.logger.info(`Setting STDIO transport for ${this.config.name}`);
153223
153419
  const defaultEnv = getDefaultEnvironment();
153224
- const stdioConfig = buildStdioTransport(parsedConfig, { ...defaultEnv, LOG_LEVEL: "silent" });
153420
+ const stdioConfig = buildStdioTransport(parsedConfig, {
153421
+ ...defaultEnv,
153422
+ LOG_LEVEL: "silent",
153423
+ ...this.additionalEnv
153424
+ });
153225
153425
  Object.assign(stdioConfig.env, this.additionalEnv);
153226
153426
  this.isPythonServer = parsedConfig.registryType === "pypi" || stdioConfig.command === "uvx";
153227
153427
  this.transport = new StdioClientTransport({
@@ -153355,7 +153555,7 @@ var ToolServerService = class ToolServerService2 extends LifecycleService {
153355
153555
  while (Date.now() - startTime < 1e3) {
153356
153556
  try {
153357
153557
  process.kill(pid, 0);
153358
- await new Promise((resolve5) => setTimeout(resolve5, 50));
153558
+ await new Promise((resolve6) => setTimeout(resolve6, 50));
153359
153559
  } catch {
153360
153560
  this.logger.debug(`Process ${pid} exited gracefully`);
153361
153561
  break;
@@ -153820,6 +154020,24 @@ var GET_SKILL_RELATED_QUERY = `
153820
154020
  }
153821
154021
  }
153822
154022
  `;
154023
+ function rewriteWorkspacePathsInResult(result, workspaceId, workspaceDir) {
154024
+ if (!result || !Array.isArray(result.content) || !workspaceDir)
154025
+ return result;
154026
+ const escaped = workspaceDir.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
154027
+ const pattern = new RegExp(escaped, "g");
154028
+ const replacement = `@skilder-file:/${workspaceId}`;
154029
+ const rewritten = result.content.map((block) => {
154030
+ if (block && block.type === "text" && typeof block.text === "string") {
154031
+ const text2 = block.text;
154032
+ const next = text2.replace(pattern, replacement);
154033
+ if (next === text2)
154034
+ return block;
154035
+ return { ...block, text: next };
154036
+ }
154037
+ return block;
154038
+ });
154039
+ return { ...result, content: rewritten };
154040
+ }
153823
154041
  function formatScriptError(stderr, exitCode) {
153824
154042
  const lines = stderr.split("\n");
153825
154043
  let errorMessage = "";
@@ -153921,10 +154139,10 @@ var ToolService = class ToolService2 extends LifecycleService {
153921
154139
  return mcpServerId;
153922
154140
  }
153923
154141
  parseInstanceKey(key) {
153924
- const sep2 = key.indexOf(":");
153925
- if (sep2 === -1)
154142
+ const sep3 = key.indexOf(":");
154143
+ if (sep3 === -1)
153926
154144
  return { mcpServerId: key };
153927
- return { mcpServerId: key.slice(0, sep2), userId: key.slice(sep2 + 1) };
154145
+ return { mcpServerId: key.slice(0, sep3), userId: key.slice(sep3 + 1) };
153928
154146
  }
153929
154147
  /** All live instance keys belonging to a given MCP server (1 for shared, N for per-user). */
153930
154148
  getInstanceKeysForServer(mcpServerId) {
@@ -154214,7 +154432,7 @@ var ToolService = class ToolService2 extends LifecycleService {
154214
154432
  this.publishMCPServerStatus(void 0, mcpServer.id, "ERROR", "Server has no workspace association");
154215
154433
  throw new Error(`MCP Server ${mcpServer.name} has no workspace association`);
154216
154434
  }
154217
- const mcpServerService = this.toolServerServiceFactory(mcpServer, roots, authProvider);
154435
+ const mcpServerService = this.toolServerServiceFactory(mcpServer, roots, authProvider, mcpServer.workspace?.id);
154218
154436
  this.logger.info({ instanceKey, userId }, `Activating MCPServer: ${mcpServer.name} with ${mcpServer.tools?.length ?? 0} tools, and roots: ${JSON.stringify(roots)}`);
154219
154437
  if (this.mcpServers.has(instanceKey)) {
154220
154438
  this.logger.debug(`MCPServer ${mcpServer.name} instance ${instanceKey} already running -> shutting down`);
@@ -154451,8 +154669,15 @@ var ToolService = class ToolService2 extends LifecycleService {
154451
154669
  scriptMsg.respond(response);
154452
154670
  };
154453
154671
  if (this.inFlightScripts >= MAX_CONCURRENT_SCRIPTS) {
154454
- this.logger.warn({ event: "script_execution_rejected_busy", scriptId, inFlight: this.inFlightScripts, limit: MAX_CONCURRENT_SCRIPTS }, "Rejecting script execution: runtime at concurrency limit");
154455
- respondOnce(new ErrorResponse({ error: `Runtime busy: ${this.inFlightScripts}/${MAX_CONCURRENT_SCRIPTS} scripts running. Please retry shortly.` }));
154672
+ this.logger.warn({
154673
+ event: "script_execution_rejected_busy",
154674
+ scriptId,
154675
+ inFlight: this.inFlightScripts,
154676
+ limit: MAX_CONCURRENT_SCRIPTS
154677
+ }, "Rejecting script execution: runtime at concurrency limit");
154678
+ respondOnce(new ErrorResponse({
154679
+ error: `Runtime busy: ${this.inFlightScripts}/${MAX_CONCURRENT_SCRIPTS} scripts running. Please retry shortly.`
154680
+ }));
154456
154681
  continue;
154457
154682
  }
154458
154683
  this.inFlightScripts++;
@@ -154678,6 +154903,11 @@ var ToolService = class ToolService2 extends LifecycleService {
154678
154903
  }
154679
154904
  }
154680
154905
  }
154906
+ const rewriteWorkspaceId = msg.data.workspaceId;
154907
+ if (rewriteWorkspaceId) {
154908
+ const workspaceDir = this.fileService.getWorkspaceDir(rewriteWorkspaceId);
154909
+ result = rewriteWorkspacePathsInResult(result, rewriteWorkspaceId, workspaceDir);
154910
+ }
154681
154911
  msg.respond(new RuntimeCallToolResponse({
154682
154912
  result,
154683
154913
  executedBy
@@ -154876,7 +155106,12 @@ ${result.stderr}`;
154876
155106
  }
154877
155107
  respond(new RuntimeCallToolResponse({
154878
155108
  result: {
154879
- content: [{ type: "text", text: output || (useInteractive ? "(Script executed with no output() call)" : "(Script executed successfully with no output)") }]
155109
+ content: [
155110
+ {
155111
+ type: "text",
155112
+ text: output || (useInteractive ? "(Script executed with no output() call)" : "(Script executed successfully with no output)")
155113
+ }
155114
+ ]
154880
155115
  },
154881
155116
  executedBy,
154882
155117
  debug: truncateDebug(result.consoleOutput)
@@ -155083,7 +155318,12 @@ ${result.stdout}
155083
155318
  }
155084
155319
  if (!userId) {
155085
155320
  return {
155086
- content: [{ type: "text", text: "SKILDER_OAUTH_ERROR:NO_USER_CONTEXT:Script-originated tool call lacks an originating user." }],
155321
+ content: [
155322
+ {
155323
+ type: "text",
155324
+ text: "SKILDER_OAUTH_ERROR:NO_USER_CONTEXT:Script-originated tool call lacks an originating user."
155325
+ }
155326
+ ],
155087
155327
  isError: true
155088
155328
  };
155089
155329
  }
@@ -155104,7 +155344,12 @@ ${result.stdout}
155104
155344
  return this.dynamicToolRouter.routeByToolId(catalogEntry.toolId, toolName, workspaceId, runtimeId, userId, userKey, args);
155105
155345
  }
155106
155346
  return {
155107
- content: [{ type: "text", text: `Error: Tool '${toolName}' not found on this runtime or any other runtime in the workspace.` }],
155347
+ content: [
155348
+ {
155349
+ type: "text",
155350
+ text: `Error: Tool '${toolName}' not found on this runtime or any other runtime in the workspace.`
155351
+ }
155352
+ ],
155108
155353
  isError: true
155109
155354
  };
155110
155355
  }
@@ -155434,7 +155679,10 @@ ${result.stdout}
155434
155679
  buildTestTransport(transportType, parsedConfig, authProvider) {
155435
155680
  if (transportType === dgraph_resolvers_types_exports.McpTransportType.Stdio) {
155436
155681
  const defaultEnv = getDefaultEnvironment();
155437
- const stdioConfig = buildStdioTransport(parsedConfig, { ...defaultEnv, LOG_LEVEL: "silent" });
155682
+ const stdioConfig = buildStdioTransport(parsedConfig, {
155683
+ ...defaultEnv,
155684
+ LOG_LEVEL: "silent"
155685
+ });
155438
155686
  Object.assign(stdioConfig.env, this.fileService.getEnvVars());
155439
155687
  return new StdioClientTransport({
155440
155688
  command: stdioConfig.command,
@@ -155802,7 +156050,7 @@ var MainService = class MainService2 extends LifecycleService {
155802
156050
  await this.up();
155803
156051
  }
155804
156052
  wait(ms) {
155805
- return new Promise((resolve5) => setTimeout(resolve5, ms));
156053
+ return new Promise((resolve6) => setTimeout(resolve6, ms));
155806
156054
  }
155807
156055
  async subscribeToReconnectMessage() {
155808
156056
  this.logger.debug("Subscribing to RuntimeReconnectMessage");
@@ -156015,10 +156263,14 @@ var start = () => {
156015
156263
  container.bind(LOG_LEVELS).toConstantValue(process.env.LOG_LEVELS);
156016
156264
  container.bind(LoggerService).toSelf().inSingletonScope();
156017
156265
  container.bind(ToolServerService).toFactory((context2) => {
156018
- return (config2, roots, authProvider) => {
156266
+ return (config2, roots, authProvider, workspaceId) => {
156019
156267
  const logger = context2.get(LoggerService).getLogger(`tool.server.${config2.name}`);
156020
156268
  const fileService = context2.get(FileService);
156021
- return new ToolServerService(logger, config2, roots, fileService.getEnvVars(), authProvider);
156269
+ const envVars = fileService.getEnvVars();
156270
+ if (workspaceId) {
156271
+ envVars.SKILDER_WORKSPACE_DIR = fileService.getWorkspaceDir(workspaceId);
156272
+ }
156273
+ return new ToolServerService(logger, config2, roots, envVars, authProvider);
156022
156274
  };
156023
156275
  });
156024
156276
  container.bind(AIProviderService).toSelf().inSingletonScope();