mcp-agents-memory 0.8.3 → 0.9.1

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.
Files changed (3) hide show
  1. package/README.md +19 -0
  2. package/build/index.js +928 -289
  3. package/package.json +1 -1
package/build/index.js CHANGED
@@ -1420,7 +1420,7 @@ var require_cert_signatures = __commonJS({
1420
1420
  var require_sasl = __commonJS({
1421
1421
  "node_modules/pg/lib/crypto/sasl.js"(exports, module) {
1422
1422
  "use strict";
1423
- var crypto2 = require_utils2();
1423
+ var crypto3 = require_utils2();
1424
1424
  var { signatureAlgorithmHashFromCertificate } = require_cert_signatures();
1425
1425
  function startSession(mechanisms, stream) {
1426
1426
  const candidates = ["SCRAM-SHA-256"];
@@ -1432,7 +1432,7 @@ var require_sasl = __commonJS({
1432
1432
  if (mechanism === "SCRAM-SHA-256-PLUS" && typeof stream.getPeerCertificate !== "function") {
1433
1433
  throw new Error("SASL: Mechanism SCRAM-SHA-256-PLUS requires a certificate");
1434
1434
  }
1435
- const clientNonce = crypto2.randomBytes(18).toString("base64");
1435
+ const clientNonce = crypto3.randomBytes(18).toString("base64");
1436
1436
  const gs2Header = mechanism === "SCRAM-SHA-256-PLUS" ? "p=tls-server-end-point" : stream ? "y" : "n";
1437
1437
  return {
1438
1438
  mechanism,
@@ -1467,20 +1467,20 @@ var require_sasl = __commonJS({
1467
1467
  const peerCert = stream.getPeerCertificate().raw;
1468
1468
  let hashName = signatureAlgorithmHashFromCertificate(peerCert);
1469
1469
  if (hashName === "MD5" || hashName === "SHA-1") hashName = "SHA-256";
1470
- const certHash = await crypto2.hashByName(hashName, peerCert);
1470
+ const certHash = await crypto3.hashByName(hashName, peerCert);
1471
1471
  const bindingData = Buffer.concat([Buffer.from("p=tls-server-end-point,,"), Buffer.from(certHash)]);
1472
1472
  channelBinding = bindingData.toString("base64");
1473
1473
  }
1474
1474
  const clientFinalMessageWithoutProof = "c=" + channelBinding + ",r=" + sv.nonce;
1475
1475
  const authMessage = clientFirstMessageBare + "," + serverFirstMessage + "," + clientFinalMessageWithoutProof;
1476
1476
  const saltBytes = Buffer.from(sv.salt, "base64");
1477
- const saltedPassword = await crypto2.deriveKey(password, saltBytes, sv.iteration);
1478
- const clientKey = await crypto2.hmacSha256(saltedPassword, "Client Key");
1479
- const storedKey = await crypto2.sha256(clientKey);
1480
- const clientSignature = await crypto2.hmacSha256(storedKey, authMessage);
1477
+ const saltedPassword = await crypto3.deriveKey(password, saltBytes, sv.iteration);
1478
+ const clientKey = await crypto3.hmacSha256(saltedPassword, "Client Key");
1479
+ const storedKey = await crypto3.sha256(clientKey);
1480
+ const clientSignature = await crypto3.hmacSha256(storedKey, authMessage);
1481
1481
  const clientProof = xorBuffers(Buffer.from(clientKey), Buffer.from(clientSignature)).toString("base64");
1482
- const serverKey = await crypto2.hmacSha256(saltedPassword, "Server Key");
1483
- const serverSignatureBytes = await crypto2.hmacSha256(serverKey, authMessage);
1482
+ const serverKey = await crypto3.hmacSha256(saltedPassword, "Server Key");
1483
+ const serverSignatureBytes = await crypto3.hmacSha256(serverKey, authMessage);
1484
1484
  session.message = "SASLResponse";
1485
1485
  session.serverSignature = Buffer.from(serverSignatureBytes).toString("base64");
1486
1486
  session.response = clientFinalMessageWithoutProof + ",p=" + clientProof;
@@ -1675,15 +1675,15 @@ var require_pg_connection_string = __commonJS({
1675
1675
  if (config2.sslcert || config2.sslkey || config2.sslrootcert || config2.sslmode) {
1676
1676
  config2.ssl = {};
1677
1677
  }
1678
- const fs6 = config2.sslcert || config2.sslkey || config2.sslrootcert ? __require("fs") : null;
1678
+ const fs8 = config2.sslcert || config2.sslkey || config2.sslrootcert ? __require("fs") : null;
1679
1679
  if (config2.sslcert) {
1680
- config2.ssl.cert = fs6.readFileSync(config2.sslcert).toString();
1680
+ config2.ssl.cert = fs8.readFileSync(config2.sslcert).toString();
1681
1681
  }
1682
1682
  if (config2.sslkey) {
1683
- config2.ssl.key = fs6.readFileSync(config2.sslkey).toString();
1683
+ config2.ssl.key = fs8.readFileSync(config2.sslkey).toString();
1684
1684
  }
1685
1685
  if (config2.sslrootcert) {
1686
- config2.ssl.ca = fs6.readFileSync(config2.sslrootcert).toString();
1686
+ config2.ssl.ca = fs8.readFileSync(config2.sslrootcert).toString();
1687
1687
  }
1688
1688
  if (options.useLibpqCompat && config2.uselibpqcompat) {
1689
1689
  throw new Error("Both useLibpqCompat and uselibpqcompat are set. Please use only one of them.");
@@ -3079,7 +3079,7 @@ var require_dist = __commonJS({
3079
3079
  function parse3(stream, callback) {
3080
3080
  const parser = new parser_1.Parser();
3081
3081
  stream.on("data", (buffer) => parser.parse(buffer, callback));
3082
- return new Promise((resolve) => stream.on("end", () => resolve()));
3082
+ return new Promise((resolve2) => stream.on("end", () => resolve2()));
3083
3083
  }
3084
3084
  exports.parse = parse3;
3085
3085
  }
@@ -3448,7 +3448,7 @@ var require_split2 = __commonJS({
3448
3448
  var require_helper = __commonJS({
3449
3449
  "node_modules/pgpass/lib/helper.js"(exports, module) {
3450
3450
  "use strict";
3451
- var path6 = __require("path");
3451
+ var path8 = __require("path");
3452
3452
  var Stream2 = __require("stream").Stream;
3453
3453
  var split = require_split2();
3454
3454
  var util2 = __require("util");
@@ -3487,7 +3487,7 @@ var require_helper = __commonJS({
3487
3487
  };
3488
3488
  module.exports.getFileName = function(rawEnv) {
3489
3489
  var env = rawEnv || process.env;
3490
- var file = env.PGPASSFILE || (isWin ? path6.join(env.APPDATA || "./", "postgresql", "pgpass.conf") : path6.join(env.HOME || "./", ".pgpass"));
3490
+ var file = env.PGPASSFILE || (isWin ? path8.join(env.APPDATA || "./", "postgresql", "pgpass.conf") : path8.join(env.HOME || "./", ".pgpass"));
3491
3491
  return file;
3492
3492
  };
3493
3493
  module.exports.usePgPass = function(stats, fname) {
@@ -3619,16 +3619,16 @@ var require_helper = __commonJS({
3619
3619
  var require_lib = __commonJS({
3620
3620
  "node_modules/pgpass/lib/index.js"(exports, module) {
3621
3621
  "use strict";
3622
- var path6 = __require("path");
3623
- var fs6 = __require("fs");
3622
+ var path8 = __require("path");
3623
+ var fs8 = __require("fs");
3624
3624
  var helper = require_helper();
3625
3625
  module.exports = function(connInfo, cb) {
3626
3626
  var file = helper.getFileName();
3627
- fs6.stat(file, function(err2, stat) {
3627
+ fs8.stat(file, function(err2, stat) {
3628
3628
  if (err2 || !helper.usePgPass(stat, file)) {
3629
3629
  return cb(void 0);
3630
3630
  }
3631
- var st = fs6.createReadStream(file);
3631
+ var st = fs8.createReadStream(file);
3632
3632
  helper.getPassword(connInfo, st, cb);
3633
3633
  });
3634
3634
  };
@@ -3648,7 +3648,7 @@ var require_client = __commonJS({
3648
3648
  var Query2 = require_query();
3649
3649
  var defaults3 = require_defaults();
3650
3650
  var Connection2 = require_connection();
3651
- var crypto2 = require_utils2();
3651
+ var crypto3 = require_utils2();
3652
3652
  var activeQueryDeprecationNotice = nodeUtils.deprecate(
3653
3653
  () => {
3654
3654
  },
@@ -3810,12 +3810,12 @@ var require_client = __commonJS({
3810
3810
  this._connect(callback);
3811
3811
  return;
3812
3812
  }
3813
- return new this._Promise((resolve, reject) => {
3813
+ return new this._Promise((resolve2, reject) => {
3814
3814
  this._connect((error2) => {
3815
3815
  if (error2) {
3816
3816
  reject(error2);
3817
3817
  } else {
3818
- resolve(this);
3818
+ resolve2(this);
3819
3819
  }
3820
3820
  });
3821
3821
  });
@@ -3883,7 +3883,7 @@ var require_client = __commonJS({
3883
3883
  _handleAuthMD5Password(msg) {
3884
3884
  this._getPassword(async () => {
3885
3885
  try {
3886
- const hashedPassword = await crypto2.postgresMd5PasswordHash(this.user, this.password, msg.salt);
3886
+ const hashedPassword = await crypto3.postgresMd5PasswordHash(this.user, this.password, msg.salt);
3887
3887
  this.connection.password(hashedPassword);
3888
3888
  } catch (e) {
3889
3889
  this.emit("error", e);
@@ -4161,8 +4161,8 @@ var require_client = __commonJS({
4161
4161
  readTimeout = config2.query_timeout || this.connectionParameters.query_timeout;
4162
4162
  query = new Query2(config2, values, callback);
4163
4163
  if (!query.callback) {
4164
- result = new this._Promise((resolve, reject) => {
4165
- query.callback = (err2, res) => err2 ? reject(err2) : resolve(res);
4164
+ result = new this._Promise((resolve2, reject) => {
4165
+ query.callback = (err2, res) => err2 ? reject(err2) : resolve2(res);
4166
4166
  }).catch((err2) => {
4167
4167
  Error.captureStackTrace(err2);
4168
4168
  throw err2;
@@ -4239,8 +4239,8 @@ var require_client = __commonJS({
4239
4239
  if (cb) {
4240
4240
  this.connection.once("end", cb);
4241
4241
  } else {
4242
- return new this._Promise((resolve) => {
4243
- this.connection.once("end", resolve);
4242
+ return new this._Promise((resolve2) => {
4243
+ this.connection.once("end", resolve2);
4244
4244
  });
4245
4245
  }
4246
4246
  }
@@ -4289,8 +4289,8 @@ var require_pg_pool = __commonJS({
4289
4289
  const cb = function(err2, client2) {
4290
4290
  err2 ? rej(err2) : res(client2);
4291
4291
  };
4292
- const result = new Promise2(function(resolve, reject) {
4293
- res = resolve;
4292
+ const result = new Promise2(function(resolve2, reject) {
4293
+ res = resolve2;
4294
4294
  rej = reject;
4295
4295
  }).catch((err2) => {
4296
4296
  Error.captureStackTrace(err2);
@@ -4351,7 +4351,7 @@ var require_pg_pool = __commonJS({
4351
4351
  if (typeof Promise2.try === "function") {
4352
4352
  return Promise2.try(f);
4353
4353
  }
4354
- return new Promise2((resolve) => resolve(f()));
4354
+ return new Promise2((resolve2) => resolve2(f()));
4355
4355
  }
4356
4356
  _isFull() {
4357
4357
  return this._clients.length >= this.options.max;
@@ -4744,8 +4744,8 @@ var require_query2 = __commonJS({
4744
4744
  NativeQuery.prototype._getPromise = function() {
4745
4745
  if (this._promise) return this._promise;
4746
4746
  this._promise = new Promise(
4747
- function(resolve, reject) {
4748
- this._once("end", resolve);
4747
+ function(resolve2, reject) {
4748
+ this._once("end", resolve2);
4749
4749
  this._once("error", reject);
4750
4750
  }.bind(this)
4751
4751
  );
@@ -4922,12 +4922,12 @@ var require_client2 = __commonJS({
4922
4922
  this._connect(callback);
4923
4923
  return;
4924
4924
  }
4925
- return new this._Promise((resolve, reject) => {
4925
+ return new this._Promise((resolve2, reject) => {
4926
4926
  this._connect((error2) => {
4927
4927
  if (error2) {
4928
4928
  reject(error2);
4929
4929
  } else {
4930
- resolve(this);
4930
+ resolve2(this);
4931
4931
  }
4932
4932
  });
4933
4933
  });
@@ -4951,8 +4951,8 @@ var require_client2 = __commonJS({
4951
4951
  query = new NativeQuery(config2, values, callback);
4952
4952
  if (!query.callback) {
4953
4953
  let resolveOut, rejectOut;
4954
- result = new this._Promise((resolve, reject) => {
4955
- resolveOut = resolve;
4954
+ result = new this._Promise((resolve2, reject) => {
4955
+ resolveOut = resolve2;
4956
4956
  rejectOut = reject;
4957
4957
  }).catch((err2) => {
4958
4958
  Error.captureStackTrace(err2);
@@ -5012,8 +5012,8 @@ var require_client2 = __commonJS({
5012
5012
  }
5013
5013
  let result;
5014
5014
  if (!cb) {
5015
- result = new this._Promise(function(resolve, reject) {
5016
- cb = (err2) => err2 ? reject(err2) : resolve();
5015
+ result = new this._Promise(function(resolve2, reject) {
5016
+ cb = (err2) => err2 ? reject(err2) : resolve2();
5017
5017
  });
5018
5018
  }
5019
5019
  this.native.end(function() {
@@ -7928,22 +7928,22 @@ var require_nacl_fast = __commonJS({
7928
7928
  randombytes = fn;
7929
7929
  };
7930
7930
  (function() {
7931
- var crypto2 = typeof self !== "undefined" ? self.crypto || self.msCrypto : null;
7932
- if (crypto2 && crypto2.getRandomValues) {
7931
+ var crypto3 = typeof self !== "undefined" ? self.crypto || self.msCrypto : null;
7932
+ if (crypto3 && crypto3.getRandomValues) {
7933
7933
  var QUOTA = 65536;
7934
7934
  nacl.setPRNG(function(x, n) {
7935
7935
  var i, v = new Uint8Array(n);
7936
7936
  for (i = 0; i < n; i += QUOTA) {
7937
- crypto2.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
7937
+ crypto3.getRandomValues(v.subarray(i, i + Math.min(n - i, QUOTA)));
7938
7938
  }
7939
7939
  for (i = 0; i < n; i++) x[i] = v[i];
7940
7940
  cleanup(v);
7941
7941
  });
7942
7942
  } else if (typeof __require !== "undefined") {
7943
- crypto2 = __require("crypto");
7944
- if (crypto2 && crypto2.randomBytes) {
7943
+ crypto3 = __require("crypto");
7944
+ if (crypto3 && crypto3.randomBytes) {
7945
7945
  nacl.setPRNG(function(x, n) {
7946
- var i, v = crypto2.randomBytes(n);
7946
+ var i, v = crypto3.randomBytes(n);
7947
7947
  for (i = 0; i < n; i++) x[i] = v[i];
7948
7948
  cleanup(v);
7949
7949
  });
@@ -9211,7 +9211,7 @@ var require_bcrypt_pbkdf = __commonJS({
9211
9211
  var require_constants = __commonJS({
9212
9212
  "node_modules/ssh2/lib/protocol/constants.js"(exports, module) {
9213
9213
  "use strict";
9214
- var crypto2 = __require("crypto");
9214
+ var crypto3 = __require("crypto");
9215
9215
  var cpuInfo;
9216
9216
  try {
9217
9217
  cpuInfo = __require("cpu-features")();
@@ -9219,21 +9219,21 @@ var require_constants = __commonJS({
9219
9219
  }
9220
9220
  var { bindingAvailable, CIPHER_INFO, MAC_INFO } = require_crypto();
9221
9221
  var eddsaSupported = (() => {
9222
- if (typeof crypto2.sign === "function" && typeof crypto2.verify === "function") {
9222
+ if (typeof crypto3.sign === "function" && typeof crypto3.verify === "function") {
9223
9223
  const key = "-----BEGIN PRIVATE KEY-----\r\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r\n-----END PRIVATE KEY-----";
9224
9224
  const data = Buffer.from("a");
9225
9225
  let sig;
9226
9226
  let verified;
9227
9227
  try {
9228
- sig = crypto2.sign(null, data, key);
9229
- verified = crypto2.verify(null, data, key, sig);
9228
+ sig = crypto3.sign(null, data, key);
9229
+ verified = crypto3.verify(null, data, key, sig);
9230
9230
  } catch {
9231
9231
  }
9232
9232
  return Buffer.isBuffer(sig) && sig.length === 64 && verified === true;
9233
9233
  }
9234
9234
  return false;
9235
9235
  })();
9236
- var curve25519Supported = typeof crypto2.diffieHellman === "function" && typeof crypto2.generateKeyPairSync === "function" && typeof crypto2.createPublicKey === "function";
9236
+ var curve25519Supported = typeof crypto3.diffieHellman === "function" && typeof crypto3.generateKeyPairSync === "function" && typeof crypto3.createPublicKey === "function";
9237
9237
  var DEFAULT_KEX = [
9238
9238
  // https://tools.ietf.org/html/rfc5656#section-10.1
9239
9239
  "ecdh-sha2-nistp256",
@@ -9276,7 +9276,7 @@ var require_constants = __commonJS({
9276
9276
  "ssh-dss"
9277
9277
  ]);
9278
9278
  var canUseCipher = (() => {
9279
- const ciphers = crypto2.getCiphers();
9279
+ const ciphers = crypto3.getCiphers();
9280
9280
  return (name) => ciphers.includes(CIPHER_INFO[name].sslName);
9281
9281
  })();
9282
9282
  var DEFAULT_CIPHER = [
@@ -9314,7 +9314,7 @@ var require_constants = __commonJS({
9314
9314
  "arcfour"
9315
9315
  ].filter(canUseCipher));
9316
9316
  var canUseMAC = (() => {
9317
- const hashes = crypto2.getHashes();
9317
+ const hashes = crypto3.getHashes();
9318
9318
  return (name) => hashes.includes(MAC_INFO[name].sslName);
9319
9319
  })();
9320
9320
  var DEFAULT_MAC = [
@@ -11652,7 +11652,7 @@ var require_crypto = __commonJS({
11652
11652
  MAC_INFO,
11653
11653
  bindingAvailable: !!binding,
11654
11654
  init: (() => {
11655
- return new Promise(async (resolve, reject) => {
11655
+ return new Promise(async (resolve2, reject) => {
11656
11656
  try {
11657
11657
  POLY1305_WASM_MODULE = await require_poly1305()();
11658
11658
  POLY1305_RESULT_MALLOC = POLY1305_WASM_MODULE._malloc(16);
@@ -11664,7 +11664,7 @@ var require_crypto = __commonJS({
11664
11664
  } catch (ex) {
11665
11665
  return reject(ex);
11666
11666
  }
11667
- resolve();
11667
+ resolve2();
11668
11668
  });
11669
11669
  })(),
11670
11670
  NullCipher,
@@ -11682,7 +11682,7 @@ var require_keyParser = __commonJS({
11682
11682
  var {
11683
11683
  createDecipheriv,
11684
11684
  createECDH,
11685
- createHash,
11685
+ createHash: createHash2,
11686
11686
  createHmac,
11687
11687
  createSign,
11688
11688
  createVerify,
@@ -12370,11 +12370,11 @@ ${formatted}-----END ${type} KEY-----`;
12370
12370
  );
12371
12371
  }
12372
12372
  const ivSlice = bufferSlice(cipherIV, 0, 8);
12373
- let cipherKey = createHash("md5").update(passphrase).update(ivSlice).digest();
12373
+ let cipherKey = createHash2("md5").update(passphrase).update(ivSlice).digest();
12374
12374
  while (cipherKey.length < encInfo.keyLen) {
12375
12375
  cipherKey = combineBuffers(
12376
12376
  cipherKey,
12377
- createHash("md5").update(cipherKey).update(passphrase).update(ivSlice).digest()
12377
+ createHash2("md5").update(cipherKey).update(passphrase).update(ivSlice).digest()
12378
12378
  );
12379
12379
  }
12380
12380
  if (cipherKey.length > encInfo.keyLen)
@@ -12539,8 +12539,8 @@ ${formatted}-----END ${type} KEY-----`;
12539
12539
  if (encrypted) {
12540
12540
  const encInfo = CIPHER_INFO[cipherName];
12541
12541
  let cipherKey = combineBuffers(
12542
- createHash("sha1").update(PPK_PP1).update(passphrase).digest(),
12543
- createHash("sha1").update(PPK_PP2).update(passphrase).digest()
12542
+ createHash2("sha1").update(PPK_PP1).update(passphrase).digest(),
12543
+ createHash2("sha1").update(PPK_PP2).update(passphrase).digest()
12544
12544
  );
12545
12545
  if (cipherKey.length > encInfo.keyLen)
12546
12546
  cipherKey = bufferSlice(cipherKey, 0, encInfo.keyLen);
@@ -12580,7 +12580,7 @@ ${formatted}-----END ${type} KEY-----`;
12580
12580
  passphrase = EMPTY_PASSPHRASE;
12581
12581
  const calcMAC = createHmac(
12582
12582
  "sha1",
12583
- createHash("sha1").update("putty-private-key-file-mac-key").update(passphrase).digest()
12583
+ createHash2("sha1").update("putty-private-key-file-mac-key").update(passphrase).digest()
12584
12584
  ).update(macData).digest("hex");
12585
12585
  if (calcMAC !== mac) {
12586
12586
  if (encrypted) {
@@ -12922,7 +12922,7 @@ var require_agent = __commonJS({
12922
12922
  "use strict";
12923
12923
  var { Socket } = __require("net");
12924
12924
  var { Duplex } = __require("stream");
12925
- var { resolve } = __require("path");
12925
+ var { resolve: resolve2 } = __require("path");
12926
12926
  var { readFile } = __require("fs");
12927
12927
  var { execFile, spawn: spawn2 } = __require("child_process");
12928
12928
  var { isParsedKey, parseKey } = require_keyParser();
@@ -13058,7 +13058,7 @@ var require_agent = __commonJS({
13058
13058
  const RET_ERR_BINSTDIN = 13;
13059
13059
  const RET_ERR_BINSTDOUT = 14;
13060
13060
  const RET_ERR_BADLEN = 15;
13061
- const EXEPATH = resolve(__dirname, "..", "util/pagent.exe");
13061
+ const EXEPATH = resolve2(__dirname, "..", "util/pagent.exe");
13062
13062
  const ERROR = {
13063
13063
  [RET_ERR_BADARGS]: new Error("Invalid pagent.exe arguments"),
13064
13064
  [RET_ERR_UNAVAILABLE]: new Error("Pageant is not running"),
@@ -13224,11 +13224,11 @@ var require_agent = __commonJS({
13224
13224
  };
13225
13225
  })();
13226
13226
  var WINDOWS_PIPE_REGEX = /^[/\\][/\\]\.[/\\]pipe[/\\].+/;
13227
- function createAgent(path6) {
13228
- if (process.platform === "win32" && !WINDOWS_PIPE_REGEX.test(path6)) {
13229
- return path6 === "pageant" ? new PageantAgent() : new CygwinAgent(path6);
13227
+ function createAgent(path8) {
13228
+ if (process.platform === "win32" && !WINDOWS_PIPE_REGEX.test(path8)) {
13229
+ return path8 === "pageant" ? new PageantAgent() : new CygwinAgent(path8);
13230
13230
  }
13231
- return new OpenSSHAgent(path6);
13231
+ return new OpenSSHAgent(path8);
13232
13232
  }
13233
13233
  var AgentProtocol = (() => {
13234
13234
  const SSH_AGENTC_REQUEST_IDENTITIES = 11;
@@ -14902,7 +14902,7 @@ var require_kex = __commonJS({
14902
14902
  createDiffieHellman,
14903
14903
  createDiffieHellmanGroup,
14904
14904
  createECDH,
14905
- createHash,
14905
+ createHash: createHash2,
14906
14906
  createPublicKey,
14907
14907
  diffieHellman,
14908
14908
  generateKeyPairSync,
@@ -15328,7 +15328,7 @@ var require_kex = __commonJS({
15328
15328
  DISCONNECT_REASON.KEY_EXCHANGE_FAILED
15329
15329
  );
15330
15330
  }
15331
- const hash = createHash(this.hashName);
15331
+ const hash = createHash2(this.hashName);
15332
15332
  hashString(hash, isServer ? this._remoteIdentRaw : this._identRaw);
15333
15333
  hashString(hash, isServer ? this._identRaw : this._remoteIdentRaw);
15334
15334
  hashString(hash, isServer ? this._remoteKexinit : this._kexinit);
@@ -16336,9 +16336,9 @@ var require_kex = __commonJS({
16336
16336
  function generateKEXVal(len, hashName, secret, exchangeHash, sessionID, char) {
16337
16337
  let ret;
16338
16338
  if (len) {
16339
- let digest = createHash(hashName).update(secret).update(exchangeHash).update(char).update(sessionID).digest();
16339
+ let digest = createHash2(hashName).update(secret).update(exchangeHash).update(char).update(sessionID).digest();
16340
16340
  while (digest.length < len) {
16341
- const chunk = createHash(hashName).update(secret).update(exchangeHash).update(digest).digest();
16341
+ const chunk = createHash2(hashName).update(secret).update(exchangeHash).update(digest).digest();
16342
16342
  const extended = Buffer.allocUnsafe(digest.length + chunk.length);
16343
16343
  extended.set(digest, 0);
16344
16344
  extended.set(chunk, digest.length);
@@ -18203,8 +18203,8 @@ var require_SFTP = __commonJS({
18203
18203
  "node_modules/ssh2/lib/protocol/SFTP.js"(exports, module) {
18204
18204
  "use strict";
18205
18205
  var EventEmitter = __require("events");
18206
- var fs6 = __require("fs");
18207
- var { constants } = fs6;
18206
+ var fs8 = __require("fs");
18207
+ var { constants } = fs8;
18208
18208
  var {
18209
18209
  Readable: ReadableStream2,
18210
18210
  Writable: WritableStream
@@ -18472,17 +18472,17 @@ var require_SFTP = __commonJS({
18472
18472
  // ===========================================================================
18473
18473
  // Client-specific ===========================================================
18474
18474
  // ===========================================================================
18475
- createReadStream(path6, options) {
18475
+ createReadStream(path8, options) {
18476
18476
  if (this.server)
18477
18477
  throw new Error("Client-only method called in server mode");
18478
- return new ReadStream(this, path6, options);
18478
+ return new ReadStream(this, path8, options);
18479
18479
  }
18480
- createWriteStream(path6, options) {
18480
+ createWriteStream(path8, options) {
18481
18481
  if (this.server)
18482
18482
  throw new Error("Client-only method called in server mode");
18483
- return new WriteStream(this, path6, options);
18483
+ return new WriteStream(this, path8, options);
18484
18484
  }
18485
- open(path6, flags_, attrs, cb) {
18485
+ open(path8, flags_, attrs, cb) {
18486
18486
  if (this.server)
18487
18487
  throw new Error("Client-only method called in server mode");
18488
18488
  if (typeof attrs === "function") {
@@ -18501,7 +18501,7 @@ var require_SFTP = __commonJS({
18501
18501
  attrsFlags = attrs.flags;
18502
18502
  attrsLen = attrs.nb;
18503
18503
  }
18504
- const pathLen = Buffer.byteLength(path6);
18504
+ const pathLen = Buffer.byteLength(path8);
18505
18505
  let p = 9;
18506
18506
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + 4 + attrsLen);
18507
18507
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -18509,7 +18509,7 @@ var require_SFTP = __commonJS({
18509
18509
  const reqid = this._writeReqid = this._writeReqid + 1 & MAX_REQID;
18510
18510
  writeUInt32BE(buf, reqid, 5);
18511
18511
  writeUInt32BE(buf, pathLen, p);
18512
- buf.utf8Write(path6, p += 4, pathLen);
18512
+ buf.utf8Write(path8, p += 4, pathLen);
18513
18513
  writeUInt32BE(buf, flags, p += pathLen);
18514
18514
  writeUInt32BE(buf, attrsFlags, p += 4);
18515
18515
  if (attrsLen) {
@@ -18633,14 +18633,14 @@ var require_SFTP = __commonJS({
18633
18633
  fastGet(remotePath, localPath, opts, cb) {
18634
18634
  if (this.server)
18635
18635
  throw new Error("Client-only method called in server mode");
18636
- fastXfer(this, fs6, remotePath, localPath, opts, cb);
18636
+ fastXfer(this, fs8, remotePath, localPath, opts, cb);
18637
18637
  }
18638
18638
  fastPut(localPath, remotePath, opts, cb) {
18639
18639
  if (this.server)
18640
18640
  throw new Error("Client-only method called in server mode");
18641
- fastXfer(fs6, this, localPath, remotePath, opts, cb);
18641
+ fastXfer(fs8, this, localPath, remotePath, opts, cb);
18642
18642
  }
18643
- readFile(path6, options, callback_) {
18643
+ readFile(path8, options, callback_) {
18644
18644
  if (this.server)
18645
18645
  throw new Error("Client-only method called in server mode");
18646
18646
  let callback;
@@ -18713,13 +18713,13 @@ var require_SFTP = __commonJS({
18713
18713
  return callback && callback(er, buffer);
18714
18714
  });
18715
18715
  };
18716
- this.open(path6, flag, 438, (er, handle_) => {
18716
+ this.open(path8, flag, 438, (er, handle_) => {
18717
18717
  if (er)
18718
18718
  return callback && callback(er);
18719
18719
  handle = handle_;
18720
18720
  const tryStat = (er2, st) => {
18721
18721
  if (er2) {
18722
- this.stat(path6, (er_, st_) => {
18722
+ this.stat(path8, (er_, st_) => {
18723
18723
  if (er_) {
18724
18724
  return this.close(handle, () => {
18725
18725
  callback && callback(er2);
@@ -18740,7 +18740,7 @@ var require_SFTP = __commonJS({
18740
18740
  this.fstat(handle, tryStat);
18741
18741
  });
18742
18742
  }
18743
- writeFile(path6, data, options, callback_) {
18743
+ writeFile(path8, data, options, callback_) {
18744
18744
  if (this.server)
18745
18745
  throw new Error("Client-only method called in server mode");
18746
18746
  let callback;
@@ -18759,7 +18759,7 @@ var require_SFTP = __commonJS({
18759
18759
  if (options.encoding && !Buffer.isEncoding(options.encoding))
18760
18760
  throw new Error(`Unknown encoding: ${options.encoding}`);
18761
18761
  const flag = options.flag || "w";
18762
- this.open(path6, flag, options.mode, (openErr, handle) => {
18762
+ this.open(path8, flag, options.mode, (openErr, handle) => {
18763
18763
  if (openErr) {
18764
18764
  callback && callback(openErr);
18765
18765
  } else {
@@ -18768,7 +18768,7 @@ var require_SFTP = __commonJS({
18768
18768
  if (position === null) {
18769
18769
  const tryStat = (er, st) => {
18770
18770
  if (er) {
18771
- this.stat(path6, (er_, st_) => {
18771
+ this.stat(path8, (er_, st_) => {
18772
18772
  if (er_) {
18773
18773
  return this.close(handle, () => {
18774
18774
  callback && callback(er);
@@ -18787,7 +18787,7 @@ var require_SFTP = __commonJS({
18787
18787
  }
18788
18788
  });
18789
18789
  }
18790
- appendFile(path6, data, options, callback_) {
18790
+ appendFile(path8, data, options, callback_) {
18791
18791
  if (this.server)
18792
18792
  throw new Error("Client-only method called in server mode");
18793
18793
  let callback;
@@ -18805,12 +18805,12 @@ var require_SFTP = __commonJS({
18805
18805
  throw new TypeError("Bad arguments");
18806
18806
  if (!options.flag)
18807
18807
  options = Object.assign({ flag: "a" }, options);
18808
- this.writeFile(path6, data, options, callback);
18808
+ this.writeFile(path8, data, options, callback);
18809
18809
  }
18810
- exists(path6, cb) {
18810
+ exists(path8, cb) {
18811
18811
  if (this.server)
18812
18812
  throw new Error("Client-only method called in server mode");
18813
- this.stat(path6, (err2) => {
18813
+ this.stat(path8, (err2) => {
18814
18814
  cb && cb(err2 ? false : true);
18815
18815
  });
18816
18816
  }
@@ -18853,7 +18853,7 @@ var require_SFTP = __commonJS({
18853
18853
  `SFTP: Outbound: ${isBuffered ? "Buffered" : "Sending"} RENAME`
18854
18854
  );
18855
18855
  }
18856
- mkdir(path6, attrs, cb) {
18856
+ mkdir(path8, attrs, cb) {
18857
18857
  if (this.server)
18858
18858
  throw new Error("Client-only method called in server mode");
18859
18859
  let flags = 0;
@@ -18867,7 +18867,7 @@ var require_SFTP = __commonJS({
18867
18867
  flags = attrs.flags;
18868
18868
  attrsLen = attrs.nb;
18869
18869
  }
18870
- const pathLen = Buffer.byteLength(path6);
18870
+ const pathLen = Buffer.byteLength(path8);
18871
18871
  let p = 9;
18872
18872
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);
18873
18873
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -18875,7 +18875,7 @@ var require_SFTP = __commonJS({
18875
18875
  const reqid = this._writeReqid = this._writeReqid + 1 & MAX_REQID;
18876
18876
  writeUInt32BE(buf, reqid, 5);
18877
18877
  writeUInt32BE(buf, pathLen, p);
18878
- buf.utf8Write(path6, p += 4, pathLen);
18878
+ buf.utf8Write(path8, p += 4, pathLen);
18879
18879
  writeUInt32BE(buf, flags, p += pathLen);
18880
18880
  if (attrsLen) {
18881
18881
  p += 4;
@@ -18891,10 +18891,10 @@ var require_SFTP = __commonJS({
18891
18891
  `SFTP: Outbound: ${isBuffered ? "Buffered" : "Sending"} MKDIR`
18892
18892
  );
18893
18893
  }
18894
- rmdir(path6, cb) {
18894
+ rmdir(path8, cb) {
18895
18895
  if (this.server)
18896
18896
  throw new Error("Client-only method called in server mode");
18897
- const pathLen = Buffer.byteLength(path6);
18897
+ const pathLen = Buffer.byteLength(path8);
18898
18898
  let p = 9;
18899
18899
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
18900
18900
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -18902,7 +18902,7 @@ var require_SFTP = __commonJS({
18902
18902
  const reqid = this._writeReqid = this._writeReqid + 1 & MAX_REQID;
18903
18903
  writeUInt32BE(buf, reqid, 5);
18904
18904
  writeUInt32BE(buf, pathLen, p);
18905
- buf.utf8Write(path6, p += 4, pathLen);
18905
+ buf.utf8Write(path8, p += 4, pathLen);
18906
18906
  this._requests[reqid] = { cb };
18907
18907
  const isBuffered = sendOrBuffer(this, buf);
18908
18908
  this._debug && this._debug(
@@ -18992,10 +18992,10 @@ var require_SFTP = __commonJS({
18992
18992
  `SFTP: Outbound: ${isBuffered ? "Buffered" : "Sending"} FSTAT`
18993
18993
  );
18994
18994
  }
18995
- stat(path6, cb) {
18995
+ stat(path8, cb) {
18996
18996
  if (this.server)
18997
18997
  throw new Error("Client-only method called in server mode");
18998
- const pathLen = Buffer.byteLength(path6);
18998
+ const pathLen = Buffer.byteLength(path8);
18999
18999
  let p = 9;
19000
19000
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
19001
19001
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -19003,17 +19003,17 @@ var require_SFTP = __commonJS({
19003
19003
  const reqid = this._writeReqid = this._writeReqid + 1 & MAX_REQID;
19004
19004
  writeUInt32BE(buf, reqid, 5);
19005
19005
  writeUInt32BE(buf, pathLen, p);
19006
- buf.utf8Write(path6, p += 4, pathLen);
19006
+ buf.utf8Write(path8, p += 4, pathLen);
19007
19007
  this._requests[reqid] = { cb };
19008
19008
  const isBuffered = sendOrBuffer(this, buf);
19009
19009
  this._debug && this._debug(
19010
19010
  `SFTP: Outbound: ${isBuffered ? "Buffered" : "Sending"} STAT`
19011
19011
  );
19012
19012
  }
19013
- lstat(path6, cb) {
19013
+ lstat(path8, cb) {
19014
19014
  if (this.server)
19015
19015
  throw new Error("Client-only method called in server mode");
19016
- const pathLen = Buffer.byteLength(path6);
19016
+ const pathLen = Buffer.byteLength(path8);
19017
19017
  let p = 9;
19018
19018
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
19019
19019
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -19021,17 +19021,17 @@ var require_SFTP = __commonJS({
19021
19021
  const reqid = this._writeReqid = this._writeReqid + 1 & MAX_REQID;
19022
19022
  writeUInt32BE(buf, reqid, 5);
19023
19023
  writeUInt32BE(buf, pathLen, p);
19024
- buf.utf8Write(path6, p += 4, pathLen);
19024
+ buf.utf8Write(path8, p += 4, pathLen);
19025
19025
  this._requests[reqid] = { cb };
19026
19026
  const isBuffered = sendOrBuffer(this, buf);
19027
19027
  this._debug && this._debug(
19028
19028
  `SFTP: Outbound: ${isBuffered ? "Buffered" : "Sending"} LSTAT`
19029
19029
  );
19030
19030
  }
19031
- opendir(path6, cb) {
19031
+ opendir(path8, cb) {
19032
19032
  if (this.server)
19033
19033
  throw new Error("Client-only method called in server mode");
19034
- const pathLen = Buffer.byteLength(path6);
19034
+ const pathLen = Buffer.byteLength(path8);
19035
19035
  let p = 9;
19036
19036
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
19037
19037
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -19039,14 +19039,14 @@ var require_SFTP = __commonJS({
19039
19039
  const reqid = this._writeReqid = this._writeReqid + 1 & MAX_REQID;
19040
19040
  writeUInt32BE(buf, reqid, 5);
19041
19041
  writeUInt32BE(buf, pathLen, p);
19042
- buf.utf8Write(path6, p += 4, pathLen);
19042
+ buf.utf8Write(path8, p += 4, pathLen);
19043
19043
  this._requests[reqid] = { cb };
19044
19044
  const isBuffered = sendOrBuffer(this, buf);
19045
19045
  this._debug && this._debug(
19046
19046
  `SFTP: Outbound: ${isBuffered ? "Buffered" : "Sending"} OPENDIR`
19047
19047
  );
19048
19048
  }
19049
- setstat(path6, attrs, cb) {
19049
+ setstat(path8, attrs, cb) {
19050
19050
  if (this.server)
19051
19051
  throw new Error("Client-only method called in server mode");
19052
19052
  let flags = 0;
@@ -19058,7 +19058,7 @@ var require_SFTP = __commonJS({
19058
19058
  } else if (typeof attrs === "function") {
19059
19059
  cb = attrs;
19060
19060
  }
19061
- const pathLen = Buffer.byteLength(path6);
19061
+ const pathLen = Buffer.byteLength(path8);
19062
19062
  let p = 9;
19063
19063
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen + 4 + attrsLen);
19064
19064
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -19066,7 +19066,7 @@ var require_SFTP = __commonJS({
19066
19066
  const reqid = this._writeReqid = this._writeReqid + 1 & MAX_REQID;
19067
19067
  writeUInt32BE(buf, reqid, 5);
19068
19068
  writeUInt32BE(buf, pathLen, p);
19069
- buf.utf8Write(path6, p += 4, pathLen);
19069
+ buf.utf8Write(path8, p += 4, pathLen);
19070
19070
  writeUInt32BE(buf, flags, p += pathLen);
19071
19071
  if (attrsLen) {
19072
19072
  p += 4;
@@ -19126,8 +19126,8 @@ var require_SFTP = __commonJS({
19126
19126
  mtime: toUnixTimestamp(mtime)
19127
19127
  }, cb);
19128
19128
  }
19129
- utimes(path6, atime, mtime, cb) {
19130
- return this.setstat(path6, {
19129
+ utimes(path8, atime, mtime, cb) {
19130
+ return this.setstat(path8, {
19131
19131
  atime: toUnixTimestamp(atime),
19132
19132
  mtime: toUnixTimestamp(mtime)
19133
19133
  }, cb);
@@ -19138,8 +19138,8 @@ var require_SFTP = __commonJS({
19138
19138
  gid
19139
19139
  }, cb);
19140
19140
  }
19141
- chown(path6, uid, gid, cb) {
19142
- return this.setstat(path6, {
19141
+ chown(path8, uid, gid, cb) {
19142
+ return this.setstat(path8, {
19143
19143
  uid,
19144
19144
  gid
19145
19145
  }, cb);
@@ -19149,15 +19149,15 @@ var require_SFTP = __commonJS({
19149
19149
  mode
19150
19150
  }, cb);
19151
19151
  }
19152
- chmod(path6, mode, cb) {
19153
- return this.setstat(path6, {
19152
+ chmod(path8, mode, cb) {
19153
+ return this.setstat(path8, {
19154
19154
  mode
19155
19155
  }, cb);
19156
19156
  }
19157
- readlink(path6, cb) {
19157
+ readlink(path8, cb) {
19158
19158
  if (this.server)
19159
19159
  throw new Error("Client-only method called in server mode");
19160
- const pathLen = Buffer.byteLength(path6);
19160
+ const pathLen = Buffer.byteLength(path8);
19161
19161
  let p = 9;
19162
19162
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
19163
19163
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -19165,7 +19165,7 @@ var require_SFTP = __commonJS({
19165
19165
  const reqid = this._writeReqid = this._writeReqid + 1 & MAX_REQID;
19166
19166
  writeUInt32BE(buf, reqid, 5);
19167
19167
  writeUInt32BE(buf, pathLen, p);
19168
- buf.utf8Write(path6, p += 4, pathLen);
19168
+ buf.utf8Write(path8, p += 4, pathLen);
19169
19169
  this._requests[reqid] = {
19170
19170
  cb: (err2, names) => {
19171
19171
  if (typeof cb !== "function")
@@ -19210,10 +19210,10 @@ var require_SFTP = __commonJS({
19210
19210
  `SFTP: Outbound: ${isBuffered ? "Buffered" : "Sending"} SYMLINK`
19211
19211
  );
19212
19212
  }
19213
- realpath(path6, cb) {
19213
+ realpath(path8, cb) {
19214
19214
  if (this.server)
19215
19215
  throw new Error("Client-only method called in server mode");
19216
- const pathLen = Buffer.byteLength(path6);
19216
+ const pathLen = Buffer.byteLength(path8);
19217
19217
  let p = 9;
19218
19218
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + pathLen);
19219
19219
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -19221,7 +19221,7 @@ var require_SFTP = __commonJS({
19221
19221
  const reqid = this._writeReqid = this._writeReqid + 1 & MAX_REQID;
19222
19222
  writeUInt32BE(buf, reqid, 5);
19223
19223
  writeUInt32BE(buf, pathLen, p);
19224
- buf.utf8Write(path6, p += 4, pathLen);
19224
+ buf.utf8Write(path8, p += 4, pathLen);
19225
19225
  this._requests[reqid] = {
19226
19226
  cb: (err2, names) => {
19227
19227
  if (typeof cb !== "function")
@@ -19266,13 +19266,13 @@ var require_SFTP = __commonJS({
19266
19266
  this._debug(`SFTP: Outbound: ${which} posix-rename@openssh.com`);
19267
19267
  }
19268
19268
  }
19269
- ext_openssh_statvfs(path6, cb) {
19269
+ ext_openssh_statvfs(path8, cb) {
19270
19270
  if (this.server)
19271
19271
  throw new Error("Client-only method called in server mode");
19272
19272
  const ext = this._extensions["statvfs@openssh.com"];
19273
19273
  if (!ext || ext !== "2")
19274
19274
  throw new Error("Server does not support this extended request");
19275
- const pathLen = Buffer.byteLength(path6);
19275
+ const pathLen = Buffer.byteLength(path8);
19276
19276
  let p = 9;
19277
19277
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 19 + 4 + pathLen);
19278
19278
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -19282,7 +19282,7 @@ var require_SFTP = __commonJS({
19282
19282
  writeUInt32BE(buf, 19, p);
19283
19283
  buf.utf8Write("statvfs@openssh.com", p += 4, 19);
19284
19284
  writeUInt32BE(buf, pathLen, p += 19);
19285
- buf.utf8Write(path6, p += 4, pathLen);
19285
+ buf.utf8Write(path8, p += 4, pathLen);
19286
19286
  this._requests[reqid] = { extended: "statvfs@openssh.com", cb };
19287
19287
  const isBuffered = sendOrBuffer(this, buf);
19288
19288
  if (this._debug) {
@@ -19368,7 +19368,7 @@ var require_SFTP = __commonJS({
19368
19368
  `SFTP: Outbound: ${isBuffered ? "Buffered" : "Sending"} fsync@openssh.com`
19369
19369
  );
19370
19370
  }
19371
- ext_openssh_lsetstat(path6, attrs, cb) {
19371
+ ext_openssh_lsetstat(path8, attrs, cb) {
19372
19372
  if (this.server)
19373
19373
  throw new Error("Client-only method called in server mode");
19374
19374
  const ext = this._extensions["lsetstat@openssh.com"];
@@ -19383,7 +19383,7 @@ var require_SFTP = __commonJS({
19383
19383
  } else if (typeof attrs === "function") {
19384
19384
  cb = attrs;
19385
19385
  }
19386
- const pathLen = Buffer.byteLength(path6);
19386
+ const pathLen = Buffer.byteLength(path8);
19387
19387
  let p = 9;
19388
19388
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 20 + 4 + pathLen + 4 + attrsLen);
19389
19389
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -19393,7 +19393,7 @@ var require_SFTP = __commonJS({
19393
19393
  writeUInt32BE(buf, 20, p);
19394
19394
  buf.utf8Write("lsetstat@openssh.com", p += 4, 20);
19395
19395
  writeUInt32BE(buf, pathLen, p += 20);
19396
- buf.utf8Write(path6, p += 4, pathLen);
19396
+ buf.utf8Write(path8, p += 4, pathLen);
19397
19397
  writeUInt32BE(buf, flags, p += pathLen);
19398
19398
  if (attrsLen) {
19399
19399
  p += 4;
@@ -19410,13 +19410,13 @@ var require_SFTP = __commonJS({
19410
19410
  this._debug(`SFTP: Outbound: ${status} lsetstat@openssh.com`);
19411
19411
  }
19412
19412
  }
19413
- ext_openssh_expandPath(path6, cb) {
19413
+ ext_openssh_expandPath(path8, cb) {
19414
19414
  if (this.server)
19415
19415
  throw new Error("Client-only method called in server mode");
19416
19416
  const ext = this._extensions["expand-path@openssh.com"];
19417
19417
  if (ext !== "1")
19418
19418
  throw new Error("Server does not support this extended request");
19419
- const pathLen = Buffer.byteLength(path6);
19419
+ const pathLen = Buffer.byteLength(path8);
19420
19420
  let p = 9;
19421
19421
  const buf = Buffer.allocUnsafe(4 + 1 + 4 + 4 + 23 + 4 + pathLen);
19422
19422
  writeUInt32BE(buf, buf.length - 4, 0);
@@ -19426,7 +19426,7 @@ var require_SFTP = __commonJS({
19426
19426
  writeUInt32BE(buf, 23, p);
19427
19427
  buf.utf8Write("expand-path@openssh.com", p += 4, 23);
19428
19428
  writeUInt32BE(buf, pathLen, p += 20);
19429
- buf.utf8Write(path6, p += 4, pathLen);
19429
+ buf.utf8Write(path8, p += 4, pathLen);
19430
19430
  this._requests[reqid] = {
19431
19431
  cb: (err2, names) => {
19432
19432
  if (typeof cb !== "function")
@@ -19899,13 +19899,13 @@ var require_SFTP = __commonJS({
19899
19899
  if (--left === 0)
19900
19900
  cb(err2);
19901
19901
  };
19902
- if (srcHandle && (src === fs6 || src.outgoing.state === "open"))
19902
+ if (srcHandle && (src === fs8 || src.outgoing.state === "open"))
19903
19903
  ++left;
19904
- if (dstHandle && (dst === fs6 || dst.outgoing.state === "open"))
19904
+ if (dstHandle && (dst === fs8 || dst.outgoing.state === "open"))
19905
19905
  ++left;
19906
- if (srcHandle && (src === fs6 || src.outgoing.state === "open"))
19906
+ if (srcHandle && (src === fs8 || src.outgoing.state === "open"))
19907
19907
  src.close(srcHandle, cbfinal);
19908
- if (dstHandle && (dst === fs6 || dst.outgoing.state === "open"))
19908
+ if (dstHandle && (dst === fs8 || dst.outgoing.state === "open"))
19909
19909
  dst.close(dstHandle, cbfinal);
19910
19910
  } else {
19911
19911
  cb(err2);
@@ -19921,7 +19921,7 @@ var require_SFTP = __commonJS({
19921
19921
  tryStat(null, { size: fileSize });
19922
19922
  function tryStat(err3, attrs) {
19923
19923
  if (err3) {
19924
- if (src !== fs6) {
19924
+ if (src !== fs8) {
19925
19925
  src.stat(srcPath, (err_, attrs_) => {
19926
19926
  if (err_)
19927
19927
  return onerror(err3);
@@ -20704,12 +20704,12 @@ var require_SFTP = __commonJS({
20704
20704
  [REQUEST.LSTAT]: (sftp, payload) => {
20705
20705
  bufferParser.init(payload, 1);
20706
20706
  const reqID = bufferParser.readUInt32BE();
20707
- const path6 = bufferParser.readString(true);
20707
+ const path8 = bufferParser.readString(true);
20708
20708
  bufferParser.clear();
20709
- if (path6 === void 0)
20709
+ if (path8 === void 0)
20710
20710
  return doFatalSFTPError(sftp, "Malformed LSTAT packet");
20711
20711
  sftp._debug && sftp._debug(`SFTP: Inbound: Received LSTAT (id:${reqID})`);
20712
- if (!sftp.emit("LSTAT", reqID, path6)) {
20712
+ if (!sftp.emit("LSTAT", reqID, path8)) {
20713
20713
  sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
20714
20714
  }
20715
20715
  },
@@ -20728,13 +20728,13 @@ var require_SFTP = __commonJS({
20728
20728
  [REQUEST.SETSTAT]: (sftp, payload) => {
20729
20729
  bufferParser.init(payload, 1);
20730
20730
  const reqID = bufferParser.readUInt32BE();
20731
- const path6 = bufferParser.readString(true);
20731
+ const path8 = bufferParser.readString(true);
20732
20732
  const attrs = readAttrs(sftp._biOpt);
20733
20733
  bufferParser.clear();
20734
20734
  if (attrs === void 0)
20735
20735
  return doFatalSFTPError(sftp, "Malformed SETSTAT packet");
20736
20736
  sftp._debug && sftp._debug(`SFTP: Inbound: Received SETSTAT (id:${reqID})`);
20737
- if (!sftp.emit("SETSTAT", reqID, path6, attrs)) {
20737
+ if (!sftp.emit("SETSTAT", reqID, path8, attrs)) {
20738
20738
  sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
20739
20739
  }
20740
20740
  },
@@ -20756,12 +20756,12 @@ var require_SFTP = __commonJS({
20756
20756
  [REQUEST.OPENDIR]: (sftp, payload) => {
20757
20757
  bufferParser.init(payload, 1);
20758
20758
  const reqID = bufferParser.readUInt32BE();
20759
- const path6 = bufferParser.readString(true);
20759
+ const path8 = bufferParser.readString(true);
20760
20760
  bufferParser.clear();
20761
- if (path6 === void 0)
20761
+ if (path8 === void 0)
20762
20762
  return doFatalSFTPError(sftp, "Malformed OPENDIR packet");
20763
20763
  sftp._debug && sftp._debug(`SFTP: Inbound: Received OPENDIR (id:${reqID})`);
20764
- if (!sftp.emit("OPENDIR", reqID, path6)) {
20764
+ if (!sftp.emit("OPENDIR", reqID, path8)) {
20765
20765
  sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
20766
20766
  }
20767
20767
  },
@@ -20780,63 +20780,63 @@ var require_SFTP = __commonJS({
20780
20780
  [REQUEST.REMOVE]: (sftp, payload) => {
20781
20781
  bufferParser.init(payload, 1);
20782
20782
  const reqID = bufferParser.readUInt32BE();
20783
- const path6 = bufferParser.readString(true);
20783
+ const path8 = bufferParser.readString(true);
20784
20784
  bufferParser.clear();
20785
- if (path6 === void 0)
20785
+ if (path8 === void 0)
20786
20786
  return doFatalSFTPError(sftp, "Malformed REMOVE packet");
20787
20787
  sftp._debug && sftp._debug(`SFTP: Inbound: Received REMOVE (id:${reqID})`);
20788
- if (!sftp.emit("REMOVE", reqID, path6)) {
20788
+ if (!sftp.emit("REMOVE", reqID, path8)) {
20789
20789
  sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
20790
20790
  }
20791
20791
  },
20792
20792
  [REQUEST.MKDIR]: (sftp, payload) => {
20793
20793
  bufferParser.init(payload, 1);
20794
20794
  const reqID = bufferParser.readUInt32BE();
20795
- const path6 = bufferParser.readString(true);
20795
+ const path8 = bufferParser.readString(true);
20796
20796
  const attrs = readAttrs(sftp._biOpt);
20797
20797
  bufferParser.clear();
20798
20798
  if (attrs === void 0)
20799
20799
  return doFatalSFTPError(sftp, "Malformed MKDIR packet");
20800
20800
  sftp._debug && sftp._debug(`SFTP: Inbound: Received MKDIR (id:${reqID})`);
20801
- if (!sftp.emit("MKDIR", reqID, path6, attrs)) {
20801
+ if (!sftp.emit("MKDIR", reqID, path8, attrs)) {
20802
20802
  sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
20803
20803
  }
20804
20804
  },
20805
20805
  [REQUEST.RMDIR]: (sftp, payload) => {
20806
20806
  bufferParser.init(payload, 1);
20807
20807
  const reqID = bufferParser.readUInt32BE();
20808
- const path6 = bufferParser.readString(true);
20808
+ const path8 = bufferParser.readString(true);
20809
20809
  bufferParser.clear();
20810
- if (path6 === void 0)
20810
+ if (path8 === void 0)
20811
20811
  return doFatalSFTPError(sftp, "Malformed RMDIR packet");
20812
20812
  sftp._debug && sftp._debug(`SFTP: Inbound: Received RMDIR (id:${reqID})`);
20813
- if (!sftp.emit("RMDIR", reqID, path6)) {
20813
+ if (!sftp.emit("RMDIR", reqID, path8)) {
20814
20814
  sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
20815
20815
  }
20816
20816
  },
20817
20817
  [REQUEST.REALPATH]: (sftp, payload) => {
20818
20818
  bufferParser.init(payload, 1);
20819
20819
  const reqID = bufferParser.readUInt32BE();
20820
- const path6 = bufferParser.readString(true);
20820
+ const path8 = bufferParser.readString(true);
20821
20821
  bufferParser.clear();
20822
- if (path6 === void 0)
20822
+ if (path8 === void 0)
20823
20823
  return doFatalSFTPError(sftp, "Malformed REALPATH packet");
20824
20824
  sftp._debug && sftp._debug(
20825
20825
  `SFTP: Inbound: Received REALPATH (id:${reqID})`
20826
20826
  );
20827
- if (!sftp.emit("REALPATH", reqID, path6)) {
20827
+ if (!sftp.emit("REALPATH", reqID, path8)) {
20828
20828
  sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
20829
20829
  }
20830
20830
  },
20831
20831
  [REQUEST.STAT]: (sftp, payload) => {
20832
20832
  bufferParser.init(payload, 1);
20833
20833
  const reqID = bufferParser.readUInt32BE();
20834
- const path6 = bufferParser.readString(true);
20834
+ const path8 = bufferParser.readString(true);
20835
20835
  bufferParser.clear();
20836
- if (path6 === void 0)
20836
+ if (path8 === void 0)
20837
20837
  return doFatalSFTPError(sftp, "Malformed STAT packet");
20838
20838
  sftp._debug && sftp._debug(`SFTP: Inbound: Received STAT (id:${reqID})`);
20839
- if (!sftp.emit("STAT", reqID, path6)) {
20839
+ if (!sftp.emit("STAT", reqID, path8)) {
20840
20840
  sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
20841
20841
  }
20842
20842
  },
@@ -20856,14 +20856,14 @@ var require_SFTP = __commonJS({
20856
20856
  [REQUEST.READLINK]: (sftp, payload) => {
20857
20857
  bufferParser.init(payload, 1);
20858
20858
  const reqID = bufferParser.readUInt32BE();
20859
- const path6 = bufferParser.readString(true);
20859
+ const path8 = bufferParser.readString(true);
20860
20860
  bufferParser.clear();
20861
- if (path6 === void 0)
20861
+ if (path8 === void 0)
20862
20862
  return doFatalSFTPError(sftp, "Malformed READLINK packet");
20863
20863
  sftp._debug && sftp._debug(
20864
20864
  `SFTP: Inbound: Received READLINK (id:${reqID})`
20865
20865
  );
20866
- if (!sftp.emit("READLINK", reqID, path6)) {
20866
+ if (!sftp.emit("READLINK", reqID, path8)) {
20867
20867
  sftp.status(reqID, STATUS_CODE.OP_UNSUPPORTED);
20868
20868
  }
20869
20869
  },
@@ -20934,7 +20934,7 @@ var require_SFTP = __commonJS({
20934
20934
  function roundUpToMultipleOf8(n) {
20935
20935
  return n + 7 & ~7;
20936
20936
  }
20937
- function ReadStream(sftp, path6, options) {
20937
+ function ReadStream(sftp, path8, options) {
20938
20938
  if (options === void 0)
20939
20939
  options = {};
20940
20940
  else if (typeof options === "string")
@@ -20948,7 +20948,7 @@ var require_SFTP = __commonJS({
20948
20948
  options.emitClose = false;
20949
20949
  options.autoDestroy = false;
20950
20950
  ReadableStream2.call(this, options);
20951
- this.path = path6;
20951
+ this.path = path8;
20952
20952
  this.flags = options.flags === void 0 ? "r" : options.flags;
20953
20953
  this.mode = options.mode === void 0 ? 438 : options.mode;
20954
20954
  this.start = options.start;
@@ -21079,7 +21079,7 @@ var require_SFTP = __commonJS({
21079
21079
  },
21080
21080
  configurable: true
21081
21081
  });
21082
- function WriteStream(sftp, path6, options) {
21082
+ function WriteStream(sftp, path8, options) {
21083
21083
  if (options === void 0)
21084
21084
  options = {};
21085
21085
  else if (typeof options === "string")
@@ -21091,7 +21091,7 @@ var require_SFTP = __commonJS({
21091
21091
  options.emitClose = false;
21092
21092
  options.autoDestroy = false;
21093
21093
  WritableStream.call(this, options);
21094
- this.path = path6;
21094
+ this.path = path8;
21095
21095
  this.flags = options.flags === void 0 ? "w" : options.flags;
21096
21096
  this.mode = options.mode === void 0 ? 438 : options.mode;
21097
21097
  this.start = options.start;
@@ -21773,7 +21773,7 @@ var require_client3 = __commonJS({
21773
21773
  "node_modules/ssh2/lib/client.js"(exports, module) {
21774
21774
  "use strict";
21775
21775
  var {
21776
- createHash,
21776
+ createHash: createHash2,
21777
21777
  getHashes,
21778
21778
  randomFillSync
21779
21779
  } = __require("crypto");
@@ -21995,7 +21995,7 @@ var require_client3 = __commonJS({
21995
21995
  }
21996
21996
  hostVerifier = (key, verify) => {
21997
21997
  if (hashAlgo)
21998
- key = createHash(hashAlgo).update(key).digest("hex");
21998
+ key = createHash2(hashAlgo).update(key).digest("hex");
21999
21999
  const ret = hashCb(key, verify);
22000
22000
  if (ret !== void 0)
22001
22001
  verify(ret);
@@ -25300,7 +25300,7 @@ var require_tunnel_ssh = __commonJS({
25300
25300
  "node_modules/tunnel-ssh/index.js"(exports) {
25301
25301
  var net = __require("net");
25302
25302
  var { Client: Client2 } = require_lib4();
25303
- var os3 = __require("os");
25303
+ var os5 = __require("os");
25304
25304
  function autoClose(server, connection) {
25305
25305
  connection.on("close", () => {
25306
25306
  server.getConnections((error2, count) => {
@@ -25315,7 +25315,7 @@ var require_tunnel_ssh = __commonJS({
25315
25315
  if (!serverOptions.port && !serverOptions.path) {
25316
25316
  serverOptions = null;
25317
25317
  }
25318
- return new Promise((resolve, reject) => {
25318
+ return new Promise((resolve2, reject) => {
25319
25319
  let server = net.createServer();
25320
25320
  let errorHandler = function(error2) {
25321
25321
  reject(error2);
@@ -25325,14 +25325,14 @@ var require_tunnel_ssh = __commonJS({
25325
25325
  server.listen(serverOptions);
25326
25326
  server.on("listening", () => {
25327
25327
  process.removeListener("uncaughtException", errorHandler);
25328
- resolve(server);
25328
+ resolve2(server);
25329
25329
  });
25330
25330
  });
25331
25331
  }
25332
25332
  async function createSSHConnection(config2) {
25333
- return new Promise(function(resolve, reject) {
25333
+ return new Promise(function(resolve2, reject) {
25334
25334
  let conn = new Client2();
25335
- conn.on("ready", () => resolve(conn));
25335
+ conn.on("ready", () => resolve2(conn));
25336
25336
  conn.on("error", reject);
25337
25337
  conn.connect(config2);
25338
25338
  });
@@ -25342,7 +25342,7 @@ var require_tunnel_ssh = __commonJS({
25342
25342
  let forwardOptionsLocal = Object.assign({ dstAddr: "0.0.0.0" }, forwardOptions);
25343
25343
  let tunnelOptionsLocal = Object.assign({ autoClose: false, reconnectOnError: false }, tunnelOptions || {});
25344
25344
  let server, sshConnection;
25345
- return new Promise(async function(resolve, reject) {
25345
+ return new Promise(async function(resolve2, reject) {
25346
25346
  try {
25347
25347
  sshConnection = await createSSHConnection(sshOptionslocal);
25348
25348
  addListenerSshConnection(sshConnection);
@@ -25407,7 +25407,7 @@ var require_tunnel_ssh = __commonJS({
25407
25407
  }
25408
25408
  );
25409
25409
  }
25410
- resolve([server, sshConnection]);
25410
+ resolve2([server, sshConnection]);
25411
25411
  });
25412
25412
  }
25413
25413
  exports.createTunnel = createTunnel2;
@@ -25485,10 +25485,10 @@ var require_package2 = __commonJS({
25485
25485
  // node_modules/dotenv/lib/main.js
25486
25486
  var require_main = __commonJS({
25487
25487
  "node_modules/dotenv/lib/main.js"(exports, module) {
25488
- var fs6 = __require("fs");
25489
- var path6 = __require("path");
25490
- var os3 = __require("os");
25491
- var crypto2 = __require("crypto");
25488
+ var fs8 = __require("fs");
25489
+ var path8 = __require("path");
25490
+ var os5 = __require("os");
25491
+ var crypto3 = __require("crypto");
25492
25492
  var packageJson2 = require_package2();
25493
25493
  var version2 = packageJson2.version;
25494
25494
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
@@ -25594,7 +25594,7 @@ var require_main = __commonJS({
25594
25594
  if (options && options.path && options.path.length > 0) {
25595
25595
  if (Array.isArray(options.path)) {
25596
25596
  for (const filepath of options.path) {
25597
- if (fs6.existsSync(filepath)) {
25597
+ if (fs8.existsSync(filepath)) {
25598
25598
  possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
25599
25599
  }
25600
25600
  }
@@ -25602,15 +25602,15 @@ var require_main = __commonJS({
25602
25602
  possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
25603
25603
  }
25604
25604
  } else {
25605
- possibleVaultPath = path6.resolve(process.cwd(), ".env.vault");
25605
+ possibleVaultPath = path8.resolve(process.cwd(), ".env.vault");
25606
25606
  }
25607
- if (fs6.existsSync(possibleVaultPath)) {
25607
+ if (fs8.existsSync(possibleVaultPath)) {
25608
25608
  return possibleVaultPath;
25609
25609
  }
25610
25610
  return null;
25611
25611
  }
25612
25612
  function _resolveHome(envPath) {
25613
- return envPath[0] === "~" ? path6.join(os3.homedir(), envPath.slice(1)) : envPath;
25613
+ return envPath[0] === "~" ? path8.join(os5.homedir(), envPath.slice(1)) : envPath;
25614
25614
  }
25615
25615
  function _configVault(options) {
25616
25616
  const debug = Boolean(options && options.debug);
@@ -25627,7 +25627,7 @@ var require_main = __commonJS({
25627
25627
  return { parsed };
25628
25628
  }
25629
25629
  function configDotenv(options) {
25630
- const dotenvPath = path6.resolve(process.cwd(), ".env");
25630
+ const dotenvPath = path8.resolve(process.cwd(), ".env");
25631
25631
  let encoding = "utf8";
25632
25632
  const debug = Boolean(options && options.debug);
25633
25633
  const quiet = options && "quiet" in options ? options.quiet : true;
@@ -25651,13 +25651,13 @@ var require_main = __commonJS({
25651
25651
  }
25652
25652
  let lastError;
25653
25653
  const parsedAll = {};
25654
- for (const path7 of optionPaths) {
25654
+ for (const path9 of optionPaths) {
25655
25655
  try {
25656
- const parsed = DotenvModule.parse(fs6.readFileSync(path7, { encoding }));
25656
+ const parsed = DotenvModule.parse(fs8.readFileSync(path9, { encoding }));
25657
25657
  DotenvModule.populate(parsedAll, parsed, options);
25658
25658
  } catch (e) {
25659
25659
  if (debug) {
25660
- _debug(`Failed to load ${path7} ${e.message}`);
25660
+ _debug(`Failed to load ${path9} ${e.message}`);
25661
25661
  }
25662
25662
  lastError = e;
25663
25663
  }
@@ -25672,7 +25672,7 @@ var require_main = __commonJS({
25672
25672
  const shortPaths = [];
25673
25673
  for (const filePath of optionPaths) {
25674
25674
  try {
25675
- const relative = path6.relative(process.cwd(), filePath);
25675
+ const relative = path8.relative(process.cwd(), filePath);
25676
25676
  shortPaths.push(relative);
25677
25677
  } catch (e) {
25678
25678
  if (debug) {
@@ -25707,7 +25707,7 @@ var require_main = __commonJS({
25707
25707
  const authTag = ciphertext.subarray(-16);
25708
25708
  ciphertext = ciphertext.subarray(12, -16);
25709
25709
  try {
25710
- const aesgcm = crypto2.createDecipheriv("aes-256-gcm", key, nonce);
25710
+ const aesgcm = crypto3.createDecipheriv("aes-256-gcm", key, nonce);
25711
25711
  aesgcm.setAuthTag(authTag);
25712
25712
  return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
25713
25713
  } catch (error2) {
@@ -25882,7 +25882,7 @@ var init_db = __esm({
25882
25882
  dstAddr: process.env.DB_HOST || "localhost",
25883
25883
  dstPort: parseInt(process.env.DB_PORT || "5432")
25884
25884
  };
25885
- return new Promise((resolve, reject) => {
25885
+ return new Promise((resolve2, reject) => {
25886
25886
  (0, import_tunnel_ssh.createTunnel)(tunnelOptions, serverOptions, sshOptions, forwardOptions).then(async ([server, conn]) => {
25887
25887
  this.tunnelServer = server;
25888
25888
  this.tunnelConn = conn;
@@ -25903,7 +25903,7 @@ var init_db = __esm({
25903
25903
  await pool2.query("SELECT 1");
25904
25904
  console.error("\u2705 Database connection verified.");
25905
25905
  this.pool = pool2;
25906
- resolve(pool2);
25906
+ resolve2(pool2);
25907
25907
  } catch (err2) {
25908
25908
  console.error("\u274C Database connection probe failed:", err2);
25909
25909
  await pool2.end().catch(() => {
@@ -25955,11 +25955,11 @@ var init_db = __esm({
25955
25955
  this.tunnelConn = null;
25956
25956
  }
25957
25957
  if (this.tunnelServer) {
25958
- await new Promise((resolve) => {
25958
+ await new Promise((resolve2) => {
25959
25959
  this.tunnelServer.close(() => {
25960
25960
  this.tunnelServer = null;
25961
25961
  console.error("\u{1F512} SSH Tunnel closed.");
25962
- resolve();
25962
+ resolve2();
25963
25963
  });
25964
25964
  });
25965
25965
  }
@@ -28920,7 +28920,7 @@ var require_compile = __commonJS({
28920
28920
  const schOrFunc = root.refs[ref];
28921
28921
  if (schOrFunc)
28922
28922
  return schOrFunc;
28923
- let _sch = resolve.call(this, root, ref);
28923
+ let _sch = resolve2.call(this, root, ref);
28924
28924
  if (_sch === void 0) {
28925
28925
  const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
28926
28926
  const { schemaId } = this.opts;
@@ -28947,7 +28947,7 @@ var require_compile = __commonJS({
28947
28947
  function sameSchemaEnv(s1, s2) {
28948
28948
  return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
28949
28949
  }
28950
- function resolve(root, ref) {
28950
+ function resolve2(root, ref) {
28951
28951
  let sch;
28952
28952
  while (typeof (sch = this.refs[ref]) == "string")
28953
28953
  ref = sch;
@@ -29162,8 +29162,8 @@ var require_utils5 = __commonJS({
29162
29162
  }
29163
29163
  return ind;
29164
29164
  }
29165
- function removeDotSegments(path6) {
29166
- let input = path6;
29165
+ function removeDotSegments(path8) {
29166
+ let input = path8;
29167
29167
  const output = [];
29168
29168
  let nextSlash = -1;
29169
29169
  let len = 0;
@@ -29362,8 +29362,8 @@ var require_schemes = __commonJS({
29362
29362
  wsComponent.secure = void 0;
29363
29363
  }
29364
29364
  if (wsComponent.resourceName) {
29365
- const [path6, query] = wsComponent.resourceName.split("?");
29366
- wsComponent.path = path6 && path6 !== "/" ? path6 : void 0;
29365
+ const [path8, query] = wsComponent.resourceName.split("?");
29366
+ wsComponent.path = path8 && path8 !== "/" ? path8 : void 0;
29367
29367
  wsComponent.query = query;
29368
29368
  wsComponent.resourceName = void 0;
29369
29369
  }
@@ -29522,7 +29522,7 @@ var require_fast_uri = __commonJS({
29522
29522
  }
29523
29523
  return uri;
29524
29524
  }
29525
- function resolve(baseURI, relativeURI, options) {
29525
+ function resolve2(baseURI, relativeURI, options) {
29526
29526
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
29527
29527
  const resolved = resolveComponent(parse3(baseURI, schemelessOptions), parse3(relativeURI, schemelessOptions), schemelessOptions, true);
29528
29528
  schemelessOptions.skipEscape = true;
@@ -29749,7 +29749,7 @@ var require_fast_uri = __commonJS({
29749
29749
  var fastUri = {
29750
29750
  SCHEMES,
29751
29751
  normalize,
29752
- resolve,
29752
+ resolve: resolve2,
29753
29753
  resolveComponent,
29754
29754
  equal,
29755
29755
  serialize,
@@ -32725,12 +32725,12 @@ var require_dist2 = __commonJS({
32725
32725
  throw new Error(`Unknown format "${name}"`);
32726
32726
  return f;
32727
32727
  };
32728
- function addFormats(ajv, list, fs6, exportName) {
32728
+ function addFormats(ajv, list, fs8, exportName) {
32729
32729
  var _a3;
32730
32730
  var _b;
32731
32731
  (_a3 = (_b = ajv.opts.code).formats) !== null && _a3 !== void 0 ? _a3 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
32732
32732
  for (const f of list)
32733
- ajv.addFormat(f, fs6[f]);
32733
+ ajv.addFormat(f, fs8[f]);
32734
32734
  }
32735
32735
  module.exports = exports = formatsPlugin;
32736
32736
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -32769,22 +32769,22 @@ __export(runner_exports, {
32769
32769
  runAllMigrations: () => runAllMigrations
32770
32770
  });
32771
32771
  import { spawn } from "child_process";
32772
- import fs4 from "fs";
32773
- import path5 from "path";
32772
+ import fs6 from "fs";
32773
+ import path7 from "path";
32774
32774
  import { fileURLToPath as fileURLToPath3 } from "url";
32775
32775
  function listMigrationFiles() {
32776
- if (!fs4.existsSync(migrationsDir)) return [];
32777
- return fs4.readdirSync(migrationsDir).filter((f) => MIGRATION_FILE_RE.test(f)).sort();
32776
+ if (!fs6.existsSync(migrationsDir)) return [];
32777
+ return fs6.readdirSync(migrationsDir).filter((f) => MIGRATION_FILE_RE.test(f)).sort();
32778
32778
  }
32779
32779
  function runOne(file) {
32780
- return new Promise((resolve, reject) => {
32780
+ return new Promise((resolve2, reject) => {
32781
32781
  const child = spawn(process.execPath, [file], {
32782
32782
  stdio: "inherit",
32783
32783
  env: process.env
32784
32784
  });
32785
32785
  child.on("exit", (code) => {
32786
- if (code === 0) return resolve();
32787
- reject(new Error(`Migration ${path5.basename(file)} exited with code ${code}`));
32786
+ if (code === 0) return resolve2();
32787
+ reject(new Error(`Migration ${path7.basename(file)} exited with code ${code}`));
32788
32788
  });
32789
32789
  child.on("error", reject);
32790
32790
  });
@@ -32797,7 +32797,7 @@ async function runAllMigrations() {
32797
32797
  }
32798
32798
  console.log(`\u{1F4E6} Running ${files.length} migration(s) from ${migrationsDir}`);
32799
32799
  for (const f of files) {
32800
- await runOne(path5.join(migrationsDir, f));
32800
+ await runOne(path7.join(migrationsDir, f));
32801
32801
  }
32802
32802
  console.log(`\u2705 Migration runner complete \u2014 ${files.length} file(s) processed.`);
32803
32803
  return { ran: files.length, files };
@@ -32806,8 +32806,8 @@ var __dirname4, migrationsDir, MIGRATION_FILE_RE;
32806
32806
  var init_runner = __esm({
32807
32807
  "src/migrations/runner.ts"() {
32808
32808
  "use strict";
32809
- __dirname4 = path5.dirname(fileURLToPath3(import.meta.url));
32810
- migrationsDir = fs4.existsSync(path5.join(__dirname4, "migrations")) ? path5.join(__dirname4, "migrations") : __dirname4;
32809
+ __dirname4 = path7.dirname(fileURLToPath3(import.meta.url));
32810
+ migrationsDir = fs6.existsSync(path7.join(__dirname4, "migrations")) ? path7.join(__dirname4, "migrations") : __dirname4;
32811
32811
  MIGRATION_FILE_RE = /^\d{3}_.+\.js$/;
32812
32812
  }
32813
32813
  });
@@ -33293,8 +33293,8 @@ function getErrorMap() {
33293
33293
 
33294
33294
  // node_modules/zod/v3/helpers/parseUtil.js
33295
33295
  var makeIssue = (params) => {
33296
- const { data, path: path6, errorMaps, issueData } = params;
33297
- const fullPath = [...path6, ...issueData.path || []];
33296
+ const { data, path: path8, errorMaps, issueData } = params;
33297
+ const fullPath = [...path8, ...issueData.path || []];
33298
33298
  const fullIssue = {
33299
33299
  ...issueData,
33300
33300
  path: fullPath
@@ -33410,11 +33410,11 @@ var errorUtil;
33410
33410
 
33411
33411
  // node_modules/zod/v3/types.js
33412
33412
  var ParseInputLazyPath = class {
33413
- constructor(parent, value, path6, key) {
33413
+ constructor(parent, value, path8, key) {
33414
33414
  this._cachedPath = [];
33415
33415
  this.parent = parent;
33416
33416
  this.data = value;
33417
- this._path = path6;
33417
+ this._path = path8;
33418
33418
  this._key = key;
33419
33419
  }
33420
33420
  get path() {
@@ -37051,10 +37051,10 @@ function assignProp(target, prop, value) {
37051
37051
  configurable: true
37052
37052
  });
37053
37053
  }
37054
- function getElementAtPath(obj, path6) {
37055
- if (!path6)
37054
+ function getElementAtPath(obj, path8) {
37055
+ if (!path8)
37056
37056
  return obj;
37057
- return path6.reduce((acc, key) => acc?.[key], obj);
37057
+ return path8.reduce((acc, key) => acc?.[key], obj);
37058
37058
  }
37059
37059
  function promiseAllObject(promisesObj) {
37060
37060
  const keys = Object.keys(promisesObj);
@@ -37374,11 +37374,11 @@ function aborted(x, startIndex = 0) {
37374
37374
  }
37375
37375
  return false;
37376
37376
  }
37377
- function prefixIssues(path6, issues) {
37377
+ function prefixIssues(path8, issues) {
37378
37378
  return issues.map((iss) => {
37379
37379
  var _a3;
37380
37380
  (_a3 = iss).path ?? (_a3.path = []);
37381
- iss.path.unshift(path6);
37381
+ iss.path.unshift(path8);
37382
37382
  return iss;
37383
37383
  });
37384
37384
  }
@@ -44906,7 +44906,7 @@ var Protocol = class {
44906
44906
  return;
44907
44907
  }
44908
44908
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
44909
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
44909
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
44910
44910
  options?.signal?.throwIfAborted();
44911
44911
  }
44912
44912
  } catch (error2) {
@@ -44923,7 +44923,7 @@ var Protocol = class {
44923
44923
  */
44924
44924
  request(request, resultSchema, options) {
44925
44925
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
44926
- return new Promise((resolve, reject) => {
44926
+ return new Promise((resolve2, reject) => {
44927
44927
  const earlyReject = (error2) => {
44928
44928
  reject(error2);
44929
44929
  };
@@ -45001,7 +45001,7 @@ var Protocol = class {
45001
45001
  if (!parseResult.success) {
45002
45002
  reject(parseResult.error);
45003
45003
  } else {
45004
- resolve(parseResult.data);
45004
+ resolve2(parseResult.data);
45005
45005
  }
45006
45006
  } catch (error2) {
45007
45007
  reject(error2);
@@ -45262,12 +45262,12 @@ var Protocol = class {
45262
45262
  }
45263
45263
  } catch {
45264
45264
  }
45265
- return new Promise((resolve, reject) => {
45265
+ return new Promise((resolve2, reject) => {
45266
45266
  if (signal.aborted) {
45267
45267
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
45268
45268
  return;
45269
45269
  }
45270
- const timeoutId = setTimeout(resolve, interval);
45270
+ const timeoutId = setTimeout(resolve2, interval);
45271
45271
  signal.addEventListener("abort", () => {
45272
45272
  clearTimeout(timeoutId);
45273
45273
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -46367,7 +46367,7 @@ var McpServer = class {
46367
46367
  let task = createTaskResult.task;
46368
46368
  const pollInterval = task.pollInterval ?? 5e3;
46369
46369
  while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
46370
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
46370
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
46371
46371
  const updatedTask = await extra.taskStore.getTask(taskId);
46372
46372
  if (!updatedTask) {
46373
46373
  throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
@@ -47016,12 +47016,12 @@ var StdioServerTransport = class {
47016
47016
  this.onclose?.();
47017
47017
  }
47018
47018
  send(message) {
47019
- return new Promise((resolve) => {
47019
+ return new Promise((resolve2) => {
47020
47020
  const json = serializeMessage(message);
47021
47021
  if (this._stdout.write(json)) {
47022
- resolve();
47022
+ resolve2();
47023
47023
  } else {
47024
- this._stdout.once("drain", resolve);
47024
+ this._stdout.once("drain", resolve2);
47025
47025
  }
47026
47026
  });
47027
47027
  }
@@ -47169,13 +47169,13 @@ function __classPrivateFieldGet(receiver, state, kind, f) {
47169
47169
 
47170
47170
  // node_modules/openai/internal/utils/uuid.mjs
47171
47171
  var uuid4 = function() {
47172
- const { crypto: crypto2 } = globalThis;
47173
- if (crypto2?.randomUUID) {
47174
- uuid4 = crypto2.randomUUID.bind(crypto2);
47175
- return crypto2.randomUUID();
47172
+ const { crypto: crypto3 } = globalThis;
47173
+ if (crypto3?.randomUUID) {
47174
+ uuid4 = crypto3.randomUUID.bind(crypto3);
47175
+ return crypto3.randomUUID();
47176
47176
  }
47177
47177
  const u8 = new Uint8Array(1);
47178
- const randomByte = crypto2 ? () => crypto2.getRandomValues(u8)[0] : () => Math.random() * 255 & 255;
47178
+ const randomByte = crypto3 ? () => crypto3.getRandomValues(u8)[0] : () => Math.random() * 255 & 255;
47179
47179
  return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => (+c ^ randomByte() & 15 >> +c / 4).toString(16));
47180
47180
  };
47181
47181
 
@@ -47388,7 +47388,7 @@ var safeJSON = (text) => {
47388
47388
  };
47389
47389
 
47390
47390
  // node_modules/openai/internal/utils/sleep.mjs
47391
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
47391
+ var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
47392
47392
 
47393
47393
  // node_modules/openai/version.mjs
47394
47394
  var VERSION = "6.34.0";
@@ -48467,8 +48467,8 @@ function addRequestID(value, response) {
48467
48467
  var _APIPromise_client;
48468
48468
  var APIPromise = class _APIPromise extends Promise {
48469
48469
  constructor(client2, responsePromise, parseResponse2 = defaultParseResponse) {
48470
- super((resolve) => {
48471
- resolve(null);
48470
+ super((resolve2) => {
48471
+ resolve2(null);
48472
48472
  });
48473
48473
  this.responsePromise = responsePromise;
48474
48474
  this.parseResponse = parseResponse2;
@@ -48897,12 +48897,12 @@ function encodeURIPath(str2) {
48897
48897
  return str2.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
48898
48898
  }
48899
48899
  var EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null));
48900
- var createPathTagFunction = (pathEncoder = encodeURIPath) => function path6(statics, ...params) {
48900
+ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path8(statics, ...params) {
48901
48901
  if (statics.length === 1)
48902
48902
  return statics[0];
48903
48903
  let postPath = false;
48904
48904
  const invalidSegments = [];
48905
- const path7 = statics.reduce((previousValue, currentValue, index) => {
48905
+ const path9 = statics.reduce((previousValue, currentValue, index) => {
48906
48906
  if (/[?#]/.test(currentValue)) {
48907
48907
  postPath = true;
48908
48908
  }
@@ -48919,7 +48919,7 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path6(stat
48919
48919
  }
48920
48920
  return previousValue + currentValue + (index === params.length ? "" : encoded);
48921
48921
  }, "");
48922
- const pathOnly = path7.split(/[?#]/, 1)[0];
48922
+ const pathOnly = path9.split(/[?#]/, 1)[0];
48923
48923
  const invalidSegmentPattern = /(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi;
48924
48924
  let match;
48925
48925
  while ((match = invalidSegmentPattern.exec(pathOnly)) !== null) {
@@ -48940,10 +48940,10 @@ var createPathTagFunction = (pathEncoder = encodeURIPath) => function path6(stat
48940
48940
  }, "");
48941
48941
  throw new OpenAIError(`Path parameters result in path with invalid segments:
48942
48942
  ${invalidSegments.map((e) => e.error).join("\n")}
48943
- ${path7}
48943
+ ${path9}
48944
48944
  ${underline}`);
48945
48945
  }
48946
- return path7;
48946
+ return path9;
48947
48947
  };
48948
48948
  var path2 = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
48949
48949
 
@@ -49116,12 +49116,12 @@ var EventStream = class {
49116
49116
  _EventStream_errored.set(this, false);
49117
49117
  _EventStream_aborted.set(this, false);
49118
49118
  _EventStream_catchingPromiseCreated.set(this, false);
49119
- __classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((resolve, reject) => {
49120
- __classPrivateFieldSet(this, _EventStream_resolveConnectedPromise, resolve, "f");
49119
+ __classPrivateFieldSet(this, _EventStream_connectedPromise, new Promise((resolve2, reject) => {
49120
+ __classPrivateFieldSet(this, _EventStream_resolveConnectedPromise, resolve2, "f");
49121
49121
  __classPrivateFieldSet(this, _EventStream_rejectConnectedPromise, reject, "f");
49122
49122
  }), "f");
49123
- __classPrivateFieldSet(this, _EventStream_endPromise, new Promise((resolve, reject) => {
49124
- __classPrivateFieldSet(this, _EventStream_resolveEndPromise, resolve, "f");
49123
+ __classPrivateFieldSet(this, _EventStream_endPromise, new Promise((resolve2, reject) => {
49124
+ __classPrivateFieldSet(this, _EventStream_resolveEndPromise, resolve2, "f");
49125
49125
  __classPrivateFieldSet(this, _EventStream_rejectEndPromise, reject, "f");
49126
49126
  }), "f");
49127
49127
  __classPrivateFieldGet(this, _EventStream_connectedPromise, "f").catch(() => {
@@ -49205,11 +49205,11 @@ var EventStream = class {
49205
49205
  * const message = await stream.emitted('message') // rejects if the stream errors
49206
49206
  */
49207
49207
  emitted(event) {
49208
- return new Promise((resolve, reject) => {
49208
+ return new Promise((resolve2, reject) => {
49209
49209
  __classPrivateFieldSet(this, _EventStream_catchingPromiseCreated, true, "f");
49210
49210
  if (event !== "error")
49211
49211
  this.once("error", reject);
49212
- this.once(event, resolve);
49212
+ this.once(event, resolve2);
49213
49213
  });
49214
49214
  }
49215
49215
  async done() {
@@ -50148,7 +50148,7 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
50148
50148
  if (done) {
50149
50149
  return { value: void 0, done: true };
50150
50150
  }
50151
- return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
50151
+ return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
50152
50152
  }
50153
50153
  const chunk = pushQueue.shift();
50154
50154
  return { value: chunk, done: false };
@@ -50980,7 +50980,7 @@ var AssistantStream = class extends EventStream {
50980
50980
  if (done) {
50981
50981
  return { value: void 0, done: true };
50982
50982
  }
50983
- return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
50983
+ return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
50984
50984
  }
50985
50985
  const chunk = pushQueue.shift();
50986
50986
  return { value: chunk, done: false };
@@ -52929,7 +52929,7 @@ var ResponseStream = class _ResponseStream extends EventStream {
52929
52929
  if (done) {
52930
52930
  return { value: void 0, done: true };
52931
52931
  }
52932
- return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
52932
+ return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
52933
52933
  }
52934
52934
  const event = pushQueue.shift();
52935
52935
  return { value: event, done: false };
@@ -53916,9 +53916,9 @@ var OpenAI = class {
53916
53916
  this.apiKey = token;
53917
53917
  return true;
53918
53918
  }
53919
- buildURL(path6, query, defaultBaseURL) {
53919
+ buildURL(path8, query, defaultBaseURL) {
53920
53920
  const baseURL = !__classPrivateFieldGet(this, _OpenAI_instances, "m", _OpenAI_baseURLOverridden).call(this) && defaultBaseURL || this.baseURL;
53921
- const url = isAbsoluteURL(path6) ? new URL(path6) : new URL(baseURL + (baseURL.endsWith("/") && path6.startsWith("/") ? path6.slice(1) : path6));
53921
+ const url = isAbsoluteURL(path8) ? new URL(path8) : new URL(baseURL + (baseURL.endsWith("/") && path8.startsWith("/") ? path8.slice(1) : path8));
53922
53922
  const defaultQuery = this.defaultQuery();
53923
53923
  const pathQuery = Object.fromEntries(url.searchParams);
53924
53924
  if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
@@ -53943,24 +53943,24 @@ var OpenAI = class {
53943
53943
  */
53944
53944
  async prepareRequest(request, { url, options }) {
53945
53945
  }
53946
- get(path6, opts) {
53947
- return this.methodRequest("get", path6, opts);
53946
+ get(path8, opts) {
53947
+ return this.methodRequest("get", path8, opts);
53948
53948
  }
53949
- post(path6, opts) {
53950
- return this.methodRequest("post", path6, opts);
53949
+ post(path8, opts) {
53950
+ return this.methodRequest("post", path8, opts);
53951
53951
  }
53952
- patch(path6, opts) {
53953
- return this.methodRequest("patch", path6, opts);
53952
+ patch(path8, opts) {
53953
+ return this.methodRequest("patch", path8, opts);
53954
53954
  }
53955
- put(path6, opts) {
53956
- return this.methodRequest("put", path6, opts);
53955
+ put(path8, opts) {
53956
+ return this.methodRequest("put", path8, opts);
53957
53957
  }
53958
- delete(path6, opts) {
53959
- return this.methodRequest("delete", path6, opts);
53958
+ delete(path8, opts) {
53959
+ return this.methodRequest("delete", path8, opts);
53960
53960
  }
53961
- methodRequest(method, path6, opts) {
53961
+ methodRequest(method, path8, opts) {
53962
53962
  return this.request(Promise.resolve(opts).then((opts2) => {
53963
- return { method, path: path6, ...opts2 };
53963
+ return { method, path: path8, ...opts2 };
53964
53964
  }));
53965
53965
  }
53966
53966
  request(options, remainingRetries = null) {
@@ -54078,8 +54078,8 @@ var OpenAI = class {
54078
54078
  }));
54079
54079
  return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
54080
54080
  }
54081
- getAPIList(path6, Page2, opts) {
54082
- return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path6, ...opts2 })) : { method: "get", path: path6, ...opts });
54081
+ getAPIList(path8, Page2, opts) {
54082
+ return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path: path8, ...opts2 })) : { method: "get", path: path8, ...opts });
54083
54083
  }
54084
54084
  requestAPIList(Page2, options) {
54085
54085
  const request = this.makeRequest(options, null, void 0);
@@ -54170,8 +54170,8 @@ var OpenAI = class {
54170
54170
  }
54171
54171
  async buildRequest(inputOptions, { retryCount = 0 } = {}) {
54172
54172
  const options = { ...inputOptions };
54173
- const { method, path: path6, query, defaultBaseURL } = options;
54174
- const url = this.buildURL(path6, query, defaultBaseURL);
54173
+ const { method, path: path8, query, defaultBaseURL } = options;
54174
+ const url = this.buildURL(path8, query, defaultBaseURL);
54175
54175
  if ("timeout" in options)
54176
54176
  validatePositiveInteger("timeout", options.timeout);
54177
54177
  options.timeout = options.timeout ?? this.timeout;
@@ -56567,14 +56567,57 @@ var _watcher = null;
56567
56567
  var _flushInProgress = false;
56568
56568
  var _flushPending = false;
56569
56569
  var _flushDebounceTimer = null;
56570
- function deriveProjectDir(cwd) {
56571
- const slug = cwd.replace(/^\/+/, "").replace(/\//g, "-").replace(/^-+/, "-");
56572
- return path3.join(PROJECTS_ROOT, `-${slug}`);
56570
+ function findProjectDir(cwd) {
56571
+ let subdirs;
56572
+ try {
56573
+ subdirs = fs2.readdirSync(PROJECTS_ROOT, { withFileTypes: true });
56574
+ } catch {
56575
+ return null;
56576
+ }
56577
+ for (const subdir of subdirs) {
56578
+ if (!subdir.isDirectory()) continue;
56579
+ const dirPath = path3.join(PROJECTS_ROOT, subdir.name);
56580
+ let files;
56581
+ try {
56582
+ files = fs2.readdirSync(dirPath, { withFileTypes: true });
56583
+ } catch {
56584
+ continue;
56585
+ }
56586
+ const jsonlFile = files.find((f) => f.isFile() && f.name.endsWith(".jsonl"));
56587
+ if (!jsonlFile) continue;
56588
+ const foundCwd = readCwdFromJsonl(path3.join(dirPath, jsonlFile.name));
56589
+ if (foundCwd === cwd) return dirPath;
56590
+ }
56591
+ return null;
56592
+ }
56593
+ function readCwdFromJsonl(jsonlPath) {
56594
+ let fd;
56595
+ try {
56596
+ fd = fs2.openSync(jsonlPath, "r");
56597
+ } catch {
56598
+ return null;
56599
+ }
56600
+ try {
56601
+ const buf = Buffer.alloc(2048);
56602
+ const bytesRead = fs2.readSync(fd, buf, 0, 2048, 0);
56603
+ const raw = buf.slice(0, bytesRead).toString("utf-8");
56604
+ for (const line of raw.split("\n")) {
56605
+ if (!line.trim()) continue;
56606
+ try {
56607
+ const entry = JSON.parse(line);
56608
+ if (typeof entry.cwd === "string") return entry.cwd;
56609
+ } catch {
56610
+ }
56611
+ }
56612
+ return null;
56613
+ } finally {
56614
+ fs2.closeSync(fd);
56615
+ }
56573
56616
  }
56574
56617
  function captureSessionStart(cwd) {
56575
- const projectDir = deriveProjectDir(cwd);
56576
56618
  _state = { cwd, projectDir: null, files: /* @__PURE__ */ new Map() };
56577
- if (!fs2.existsSync(projectDir)) {
56619
+ const projectDir = findProjectDir(cwd);
56620
+ if (!projectDir) {
56578
56621
  return;
56579
56622
  }
56580
56623
  _state.projectDir = projectDir;
@@ -56796,17 +56839,605 @@ async function captureSessionEnd() {
56796
56839
  }
56797
56840
  }
56798
56841
 
56842
+ // src/auto_save/codex_capture.ts
56843
+ import * as fs3 from "node:fs";
56844
+ import * as path4 from "node:path";
56845
+ import * as os3 from "node:os";
56846
+ var CLIENT_PLATFORM2 = "codex-mcp-client";
56847
+ var SESSIONS_ROOT = path4.join(os3.homedir(), ".codex", "sessions");
56848
+ var FLUSH_DEBOUNCE_MS2 = 200;
56849
+ var _state2 = null;
56850
+ var _watcher2 = null;
56851
+ var _flushInProgress2 = false;
56852
+ var _flushPending2 = false;
56853
+ var _flushDebounceTimer2 = null;
56854
+ function extractSessionId(filename) {
56855
+ const m = filename.match(/^rollout-.+?-([0-9a-f-]{36})\.jsonl$/);
56856
+ return m ? m[1] : null;
56857
+ }
56858
+ function probeSessionMeta(filePath) {
56859
+ let fd;
56860
+ try {
56861
+ fd = fs3.openSync(filePath, "r");
56862
+ } catch {
56863
+ return null;
56864
+ }
56865
+ try {
56866
+ const buf = Buffer.alloc(8192);
56867
+ const n = fs3.readSync(fd, buf, 0, 8192, 0);
56868
+ if (n === 0) return null;
56869
+ const slice = buf.slice(0, n).toString("utf-8");
56870
+ const nl = slice.indexOf("\n");
56871
+ if (nl === -1) return null;
56872
+ const entry = JSON.parse(slice.slice(0, nl));
56873
+ if (entry.type !== "session_meta") return null;
56874
+ const sid = entry.payload?.id;
56875
+ const cwd = entry.payload?.cwd;
56876
+ if (typeof sid !== "string" || typeof cwd !== "string") return null;
56877
+ return { sessionId: sid, cwd };
56878
+ } catch {
56879
+ return null;
56880
+ } finally {
56881
+ try {
56882
+ fs3.closeSync(fd);
56883
+ } catch {
56884
+ }
56885
+ }
56886
+ }
56887
+ function* walkRollouts(root) {
56888
+ if (!fs3.existsSync(root)) return;
56889
+ const stack = [root];
56890
+ while (stack.length) {
56891
+ const dir = stack.pop();
56892
+ let entries;
56893
+ try {
56894
+ entries = fs3.readdirSync(dir, { withFileTypes: true });
56895
+ } catch {
56896
+ continue;
56897
+ }
56898
+ for (const e of entries) {
56899
+ const p = path4.join(dir, e.name);
56900
+ if (e.isDirectory()) {
56901
+ stack.push(p);
56902
+ } else if (e.isFile() && e.name.startsWith("rollout-") && e.name.endsWith(".jsonl")) {
56903
+ yield p;
56904
+ }
56905
+ }
56906
+ }
56907
+ }
56908
+ function captureSessionStart2(cwd) {
56909
+ const cwdNormalized = path4.resolve(cwd);
56910
+ const rootExists = fs3.existsSync(SESSIONS_ROOT);
56911
+ _state2 = {
56912
+ cwd,
56913
+ cwdNormalized,
56914
+ rootExists,
56915
+ files: /* @__PURE__ */ new Map()
56916
+ };
56917
+ if (!rootExists) {
56918
+ return;
56919
+ }
56920
+ let count = 0, matched = 0;
56921
+ for (const filePath of walkRollouts(SESSIONS_ROOT)) {
56922
+ let stat;
56923
+ try {
56924
+ stat = fs3.statSync(filePath);
56925
+ } catch {
56926
+ continue;
56927
+ }
56928
+ const sessionId = extractSessionId(path4.basename(filePath));
56929
+ if (!sessionId) continue;
56930
+ const meta = probeSessionMeta(filePath);
56931
+ let cwdMatched = null;
56932
+ if (meta) {
56933
+ cwdMatched = path4.resolve(meta.cwd) === cwdNormalized;
56934
+ }
56935
+ _state2.files.set(filePath, {
56936
+ cursorBytes: stat.size,
56937
+ sessionId,
56938
+ cwdMatched,
56939
+ currentModel: null
56940
+ });
56941
+ count++;
56942
+ if (cwdMatched) matched++;
56943
+ }
56944
+ console.error(`\u{1F4DD} [Codex] capture armed: ${count} rollout(s), ${matched} cwd-matched`);
56945
+ armDirWatcher2();
56946
+ }
56947
+ function parseEntry2(line, byteOffset) {
56948
+ let entry;
56949
+ try {
56950
+ entry = JSON.parse(line);
56951
+ } catch {
56952
+ return null;
56953
+ }
56954
+ if (entry.type !== "event_msg") return null;
56955
+ const payload = entry.payload;
56956
+ if (!payload || typeof payload !== "object") return null;
56957
+ const ptype = payload.type;
56958
+ let role;
56959
+ if (ptype === "user_message") {
56960
+ role = "user";
56961
+ } else if (ptype === "agent_message") {
56962
+ role = "assistant";
56963
+ } else {
56964
+ return null;
56965
+ }
56966
+ const message = typeof payload.message === "string" ? payload.message.trim() : "";
56967
+ if (!message) return null;
56968
+ return { byteOffset, role, message };
56969
+ }
56970
+ function extractModelFromTurnContext(line) {
56971
+ try {
56972
+ const entry = JSON.parse(line);
56973
+ if (entry.type !== "turn_context") return null;
56974
+ const m = entry.payload?.model;
56975
+ return typeof m === "string" ? m : null;
56976
+ } catch {
56977
+ return null;
56978
+ }
56979
+ }
56980
+ function applySessionMetaIfPresent(line, fileState, cwdNormalized) {
56981
+ if (fileState.cwdMatched !== null) return;
56982
+ try {
56983
+ const entry = JSON.parse(line);
56984
+ if (entry.type !== "session_meta") return;
56985
+ const cwd = entry.payload?.cwd;
56986
+ if (typeof cwd !== "string") return;
56987
+ fileState.cwdMatched = path4.resolve(cwd) === cwdNormalized;
56988
+ } catch {
56989
+ }
56990
+ }
56991
+ async function flushDeltaForFile2(filePath, fileState, cwdNormalized) {
56992
+ if (!fs3.existsSync(filePath)) return { inserted: 0, skipped: 0, dedup: 0 };
56993
+ let stat;
56994
+ try {
56995
+ stat = fs3.statSync(filePath);
56996
+ } catch {
56997
+ return { inserted: 0, skipped: 0, dedup: 0 };
56998
+ }
56999
+ if (stat.size <= fileState.cursorBytes) return { inserted: 0, skipped: 0, dedup: 0 };
57000
+ const length = stat.size - fileState.cursorBytes;
57001
+ const fd = fs3.openSync(filePath, "r");
57002
+ let raw;
57003
+ try {
57004
+ const buf = Buffer.alloc(length);
57005
+ fs3.readSync(fd, buf, 0, length, fileState.cursorBytes);
57006
+ raw = buf.toString("utf-8");
57007
+ } finally {
57008
+ fs3.closeSync(fd);
57009
+ }
57010
+ const lastNl = raw.lastIndexOf("\n");
57011
+ if (lastNl === -1) return { inserted: 0, skipped: 0, dedup: 0 };
57012
+ const parsable = raw.slice(0, lastNl);
57013
+ const advanceBy = Buffer.byteLength(parsable, "utf-8") + 1;
57014
+ const startBase = fileState.cursorBytes;
57015
+ const newCursor = fileState.cursorBytes + advanceBy;
57016
+ const userId = await getDefaultUserId();
57017
+ let inserted = 0, skipped = 0, dedup = 0;
57018
+ let lineStartInRaw = 0;
57019
+ const lines = parsable.split("\n");
57020
+ for (const line of lines) {
57021
+ const trimmed = line.trim();
57022
+ if (!trimmed) {
57023
+ lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
57024
+ continue;
57025
+ }
57026
+ applySessionMetaIfPresent(trimmed, fileState, cwdNormalized);
57027
+ const m = extractModelFromTurnContext(trimmed);
57028
+ if (m !== null) {
57029
+ fileState.currentModel = m;
57030
+ lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
57031
+ continue;
57032
+ }
57033
+ if (fileState.cwdMatched === false) {
57034
+ lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
57035
+ continue;
57036
+ }
57037
+ const byteOffset = startBase + lineStartInRaw;
57038
+ const parsed = parseEntry2(trimmed, byteOffset);
57039
+ if (!parsed) {
57040
+ skipped++;
57041
+ lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
57042
+ continue;
57043
+ }
57044
+ if (fileState.cwdMatched !== true) {
57045
+ skipped++;
57046
+ lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
57047
+ continue;
57048
+ }
57049
+ const externalUuid = `codex:${fileState.sessionId}:${parsed.byteOffset}`;
57050
+ const agentModel = parsed.role === "user" ? null : fileState.currentModel ?? "unknown";
57051
+ try {
57052
+ const result = await insertRawMemory({
57053
+ user_id: userId,
57054
+ agent_platform: CLIENT_PLATFORM2,
57055
+ agent_model: agentModel,
57056
+ role: parsed.role,
57057
+ message: parsed.message,
57058
+ external_uuid: externalUuid
57059
+ });
57060
+ if (result.inserted) inserted++;
57061
+ else dedup++;
57062
+ } catch (err2) {
57063
+ console.error(`\u26A0\uFE0F [Codex] insert failed at offset ${byteOffset}:`, err2);
57064
+ skipped++;
57065
+ }
57066
+ lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
57067
+ }
57068
+ fileState.cursorBytes = newCursor;
57069
+ return { inserted, skipped, dedup };
57070
+ }
57071
+ async function flushAllFiles2() {
57072
+ if (!_state2 || !_state2.rootExists) return { inserted: 0, skipped: 0, dedup: 0 };
57073
+ const cwdNormalized = _state2.cwdNormalized;
57074
+ let totalI = 0, totalS = 0, totalD = 0;
57075
+ for (const filePath of walkRollouts(SESSIONS_ROOT)) {
57076
+ let fileState = _state2.files.get(filePath);
57077
+ if (!fileState) {
57078
+ const sessionId = extractSessionId(path4.basename(filePath));
57079
+ if (!sessionId) continue;
57080
+ fileState = {
57081
+ cursorBytes: 0,
57082
+ sessionId,
57083
+ cwdMatched: null,
57084
+ currentModel: null
57085
+ };
57086
+ _state2.files.set(filePath, fileState);
57087
+ console.error(`\u{1F4DD} [Codex] new rollout detected: ${path4.basename(filePath)}`);
57088
+ }
57089
+ const r = await flushDeltaForFile2(filePath, fileState, cwdNormalized);
57090
+ totalI += r.inserted;
57091
+ totalS += r.skipped;
57092
+ totalD += r.dedup;
57093
+ }
57094
+ return { inserted: totalI, skipped: totalS, dedup: totalD };
57095
+ }
57096
+ async function flushWithMutex2() {
57097
+ if (_flushInProgress2) {
57098
+ _flushPending2 = true;
57099
+ return;
57100
+ }
57101
+ _flushInProgress2 = true;
57102
+ try {
57103
+ const r = await flushAllFiles2();
57104
+ if (r.inserted > 0 || r.skipped > 0 || r.dedup > 0) {
57105
+ console.error(`\u{1F4DD} [Codex] live flush: inserted=${r.inserted}, dedup=${r.dedup}, skipped=${r.skipped}`);
57106
+ }
57107
+ } catch (err2) {
57108
+ console.error("\u26A0\uFE0F [Codex] live flush error:", err2);
57109
+ } finally {
57110
+ _flushInProgress2 = false;
57111
+ if (_flushPending2) {
57112
+ _flushPending2 = false;
57113
+ setImmediate(() => {
57114
+ void flushWithMutex2();
57115
+ });
57116
+ }
57117
+ }
57118
+ }
57119
+ function scheduleFlush2() {
57120
+ if (_flushDebounceTimer2) clearTimeout(_flushDebounceTimer2);
57121
+ _flushDebounceTimer2 = setTimeout(() => {
57122
+ _flushDebounceTimer2 = null;
57123
+ void flushWithMutex2();
57124
+ }, FLUSH_DEBOUNCE_MS2);
57125
+ }
57126
+ function armDirWatcher2() {
57127
+ if (!_state2 || !_state2.rootExists) return;
57128
+ if (_watcher2) return;
57129
+ try {
57130
+ _watcher2 = fs3.watch(SESSIONS_ROOT, { recursive: true }, (_evt, filename) => {
57131
+ if (!filename) return;
57132
+ const base = path4.basename(filename);
57133
+ if (!base.startsWith("rollout-") || !base.endsWith(".jsonl")) return;
57134
+ scheduleFlush2();
57135
+ });
57136
+ console.error(`\u{1F4DD} [Codex] dir watcher armed (recursive)`);
57137
+ } catch (err2) {
57138
+ console.error("\u26A0\uFE0F [Codex] fs.watch failed (shutdown-only flush \uD3F4\uBC31):", err2);
57139
+ }
57140
+ }
57141
+ function disarmDirWatcher2() {
57142
+ if (_flushDebounceTimer2) {
57143
+ clearTimeout(_flushDebounceTimer2);
57144
+ _flushDebounceTimer2 = null;
57145
+ }
57146
+ if (_watcher2) {
57147
+ try {
57148
+ _watcher2.close();
57149
+ } catch {
57150
+ }
57151
+ _watcher2 = null;
57152
+ }
57153
+ }
57154
+ async function captureSessionEnd2() {
57155
+ disarmDirWatcher2();
57156
+ const waitStart = Date.now();
57157
+ while (_flushInProgress2 && Date.now() - waitStart < 2e3) {
57158
+ await new Promise((r) => setTimeout(r, 50));
57159
+ }
57160
+ if (!_state2 || !_state2.rootExists) {
57161
+ return { inserted: 0, skipped: 0, error: "session not armed" };
57162
+ }
57163
+ _flushInProgress2 = true;
57164
+ try {
57165
+ const r = await flushAllFiles2();
57166
+ if (r.inserted > 0 || r.skipped > 0 || r.dedup > 0) {
57167
+ console.error(`\u{1F4DD} [Codex] final flush: inserted=${r.inserted}, dedup=${r.dedup}, skipped=${r.skipped}`);
57168
+ }
57169
+ return { inserted: r.inserted, skipped: r.skipped };
57170
+ } finally {
57171
+ _flushInProgress2 = false;
57172
+ }
57173
+ }
57174
+
57175
+ // src/auto_save/gemini_capture.ts
57176
+ import * as fs4 from "node:fs";
57177
+ import * as path5 from "node:path";
57178
+ import * as os4 from "node:os";
57179
+ import * as crypto2 from "node:crypto";
57180
+ var CLIENT_PLATFORM3 = "gemini-cli-mcp-client";
57181
+ var GEMINI_TMP_ROOT = path5.join(os4.homedir(), ".gemini", "tmp");
57182
+ var FLUSH_DEBOUNCE_MS3 = 200;
57183
+ var PARSE_RETRY_MS = 80;
57184
+ var _state3 = null;
57185
+ var _watchers = [];
57186
+ var _flushInProgress3 = false;
57187
+ var _flushPending3 = false;
57188
+ var _flushDebounceTimer3 = null;
57189
+ function extractShortId(filename) {
57190
+ const m = filename.match(/^session-.+?-([0-9a-f]+)\.json$/);
57191
+ return m ? m[1] : filename.replace(/\.json$/, "");
57192
+ }
57193
+ function deriveChatsDirCandidates(cwd) {
57194
+ const cwdHash = crypto2.createHash("sha256").update(cwd).digest("hex");
57195
+ const candidates = [
57196
+ path5.join(GEMINI_TMP_ROOT, cwdHash, "chats"),
57197
+ path5.join(GEMINI_TMP_ROOT, path5.basename(cwd), "chats")
57198
+ ];
57199
+ return candidates.filter((d) => fs4.existsSync(d));
57200
+ }
57201
+ async function readSessionFile(filePath) {
57202
+ for (let attempt = 0; attempt < 2; attempt++) {
57203
+ try {
57204
+ const raw = fs4.readFileSync(filePath, "utf-8");
57205
+ if (!raw.trim()) return null;
57206
+ return JSON.parse(raw);
57207
+ } catch {
57208
+ if (attempt === 0) {
57209
+ await new Promise((r) => setTimeout(r, PARSE_RETRY_MS));
57210
+ continue;
57211
+ }
57212
+ return null;
57213
+ }
57214
+ }
57215
+ return null;
57216
+ }
57217
+ function parseMessage(msg, fallbackId) {
57218
+ let role;
57219
+ if (msg.type === "user") role = "user";
57220
+ else if (msg.type === "gemini") role = "assistant";
57221
+ else return null;
57222
+ let text = "";
57223
+ const c = msg.content;
57224
+ if (typeof c === "string") {
57225
+ text = c;
57226
+ } else if (Array.isArray(c)) {
57227
+ for (const block of c) {
57228
+ if (block && typeof block === "object" && typeof block.text === "string") {
57229
+ text += (text ? "\n" : "") + block.text;
57230
+ }
57231
+ }
57232
+ }
57233
+ text = text.trim();
57234
+ if (!text) return null;
57235
+ const msgId = typeof msg.id === "string" && msg.id ? msg.id : fallbackId;
57236
+ const agent_model = role === "assistant" && typeof msg.model === "string" ? msg.model : null;
57237
+ return { msgId, role, message: text, agent_model };
57238
+ }
57239
+ async function flushDeltaForFile3(filePath, fileState) {
57240
+ const session = await readSessionFile(filePath);
57241
+ if (!session || !Array.isArray(session.messages)) {
57242
+ return { inserted: 0, skipped: 0, dedup: 0 };
57243
+ }
57244
+ const messages = session.messages;
57245
+ if (messages.length <= fileState.cursorIndex) {
57246
+ return { inserted: 0, skipped: 0, dedup: 0 };
57247
+ }
57248
+ if (typeof session.sessionId === "string" && session.sessionId) {
57249
+ fileState.sessionId = session.sessionId;
57250
+ }
57251
+ const userId = await getDefaultUserId();
57252
+ let inserted = 0, skipped = 0, dedup = 0;
57253
+ for (let i = fileState.cursorIndex; i < messages.length; i++) {
57254
+ const msg = messages[i];
57255
+ const fallbackId = `${fileState.sessionId}-${i}`;
57256
+ const parsed = parseMessage(msg, fallbackId);
57257
+ if (!parsed) {
57258
+ skipped++;
57259
+ continue;
57260
+ }
57261
+ const externalUuid = `gemini:${fileState.sessionId}:${parsed.msgId}`;
57262
+ const agentModel = parsed.role === "user" ? null : parsed.agent_model ?? "unknown";
57263
+ try {
57264
+ const result = await insertRawMemory({
57265
+ user_id: userId,
57266
+ agent_platform: CLIENT_PLATFORM3,
57267
+ agent_model: agentModel,
57268
+ role: parsed.role,
57269
+ message: parsed.message,
57270
+ external_uuid: externalUuid
57271
+ });
57272
+ if (result.inserted) inserted++;
57273
+ else dedup++;
57274
+ } catch (err2) {
57275
+ console.error(`\u26A0\uFE0F [Gemini] insert failed at index ${i}:`, err2);
57276
+ skipped++;
57277
+ }
57278
+ }
57279
+ fileState.cursorIndex = messages.length;
57280
+ return { inserted, skipped, dedup };
57281
+ }
57282
+ async function flushAllFiles3() {
57283
+ if (!_state3) return { inserted: 0, skipped: 0, dedup: 0 };
57284
+ let totalI = 0, totalS = 0, totalD = 0;
57285
+ for (const dir of _state3.chatsDirs) {
57286
+ if (!fs4.existsSync(dir)) continue;
57287
+ let entries;
57288
+ try {
57289
+ entries = fs4.readdirSync(dir, { withFileTypes: true });
57290
+ } catch {
57291
+ continue;
57292
+ }
57293
+ for (const entry of entries) {
57294
+ if (!entry.isFile() || !entry.name.endsWith(".json")) continue;
57295
+ if (!entry.name.startsWith("session-")) continue;
57296
+ const filePath = path5.join(dir, entry.name);
57297
+ let fileState = _state3.files.get(filePath);
57298
+ if (!fileState) {
57299
+ const sessionId = extractShortId(entry.name);
57300
+ fileState = { cursorIndex: 0, sessionId };
57301
+ _state3.files.set(filePath, fileState);
57302
+ console.error(`\u{1F4DD} [Gemini] new session detected: ${entry.name}`);
57303
+ }
57304
+ const r = await flushDeltaForFile3(filePath, fileState);
57305
+ totalI += r.inserted;
57306
+ totalS += r.skipped;
57307
+ totalD += r.dedup;
57308
+ }
57309
+ }
57310
+ return { inserted: totalI, skipped: totalS, dedup: totalD };
57311
+ }
57312
+ async function flushWithMutex3() {
57313
+ if (_flushInProgress3) {
57314
+ _flushPending3 = true;
57315
+ return;
57316
+ }
57317
+ _flushInProgress3 = true;
57318
+ try {
57319
+ const r = await flushAllFiles3();
57320
+ if (r.inserted > 0 || r.skipped > 0 || r.dedup > 0) {
57321
+ console.error(`\u{1F4DD} [Gemini] live flush: inserted=${r.inserted}, dedup=${r.dedup}, skipped=${r.skipped}`);
57322
+ }
57323
+ } catch (err2) {
57324
+ console.error("\u26A0\uFE0F [Gemini] live flush error:", err2);
57325
+ } finally {
57326
+ _flushInProgress3 = false;
57327
+ if (_flushPending3) {
57328
+ _flushPending3 = false;
57329
+ setImmediate(() => {
57330
+ void flushWithMutex3();
57331
+ });
57332
+ }
57333
+ }
57334
+ }
57335
+ function scheduleFlush3() {
57336
+ if (_flushDebounceTimer3) clearTimeout(_flushDebounceTimer3);
57337
+ _flushDebounceTimer3 = setTimeout(() => {
57338
+ _flushDebounceTimer3 = null;
57339
+ void flushWithMutex3();
57340
+ }, FLUSH_DEBOUNCE_MS3);
57341
+ }
57342
+ function captureSessionStart3(cwd) {
57343
+ const chatsDirs = deriveChatsDirCandidates(cwd);
57344
+ _state3 = { cwd, chatsDirs, files: /* @__PURE__ */ new Map() };
57345
+ if (chatsDirs.length === 0) {
57346
+ return;
57347
+ }
57348
+ let count = 0;
57349
+ for (const dir of chatsDirs) {
57350
+ let entries;
57351
+ try {
57352
+ entries = fs4.readdirSync(dir, { withFileTypes: true });
57353
+ } catch {
57354
+ continue;
57355
+ }
57356
+ for (const entry of entries) {
57357
+ if (!entry.isFile() || !entry.name.endsWith(".json")) continue;
57358
+ if (!entry.name.startsWith("session-")) continue;
57359
+ const filePath = path5.join(dir, entry.name);
57360
+ let session = null;
57361
+ try {
57362
+ const raw = fs4.readFileSync(filePath, "utf-8");
57363
+ session = JSON.parse(raw);
57364
+ } catch {
57365
+ session = null;
57366
+ }
57367
+ const sessionId = session && typeof session.sessionId === "string" && session.sessionId || extractShortId(entry.name);
57368
+ const cursorIndex = session && Array.isArray(session.messages) ? session.messages.length : 0;
57369
+ _state3.files.set(filePath, { cursorIndex, sessionId });
57370
+ count++;
57371
+ }
57372
+ }
57373
+ console.error(
57374
+ `\u{1F4DD} [Gemini] capture armed: ${count} session(s) across ${chatsDirs.length} chats dir(s)`
57375
+ );
57376
+ armDirWatchers();
57377
+ }
57378
+ function armDirWatchers() {
57379
+ if (!_state3) return;
57380
+ if (_watchers.length > 0) return;
57381
+ for (const dir of _state3.chatsDirs) {
57382
+ try {
57383
+ const w = fs4.watch(dir, (_evt, filename) => {
57384
+ if (filename && !filename.endsWith(".json")) return;
57385
+ scheduleFlush3();
57386
+ });
57387
+ _watchers.push(w);
57388
+ } catch (err2) {
57389
+ console.error(`\u26A0\uFE0F [Gemini] fs.watch ${dir} failed:`, err2);
57390
+ }
57391
+ }
57392
+ if (_watchers.length > 0) {
57393
+ console.error(`\u{1F4DD} [Gemini] dir watcher(s) armed: ${_watchers.length}`);
57394
+ }
57395
+ }
57396
+ function disarmDirWatchers() {
57397
+ if (_flushDebounceTimer3) {
57398
+ clearTimeout(_flushDebounceTimer3);
57399
+ _flushDebounceTimer3 = null;
57400
+ }
57401
+ for (const w of _watchers) {
57402
+ try {
57403
+ w.close();
57404
+ } catch {
57405
+ }
57406
+ }
57407
+ _watchers.length = 0;
57408
+ }
57409
+ async function captureSessionEnd3() {
57410
+ disarmDirWatchers();
57411
+ const waitStart = Date.now();
57412
+ while (_flushInProgress3 && Date.now() - waitStart < 2e3) {
57413
+ await new Promise((r) => setTimeout(r, 50));
57414
+ }
57415
+ if (!_state3 || _state3.chatsDirs.length === 0) {
57416
+ return { inserted: 0, skipped: 0, error: "session not armed" };
57417
+ }
57418
+ _flushInProgress3 = true;
57419
+ try {
57420
+ const r = await flushAllFiles3();
57421
+ if (r.inserted > 0 || r.skipped > 0 || r.dedup > 0) {
57422
+ console.error(`\u{1F4DD} [Gemini] final flush: inserted=${r.inserted}, dedup=${r.dedup}, skipped=${r.skipped}`);
57423
+ }
57424
+ return { inserted: r.inserted, skipped: r.skipped };
57425
+ } finally {
57426
+ _flushInProgress3 = false;
57427
+ }
57428
+ }
57429
+
56799
57430
  // src/version.ts
56800
- import fs3 from "fs";
56801
- import path4 from "path";
57431
+ import fs5 from "fs";
57432
+ import path6 from "path";
56802
57433
  import { fileURLToPath as fileURLToPath2 } from "url";
56803
- var __dirname3 = path4.dirname(fileURLToPath2(import.meta.url));
56804
- var packageJsonPath = path4.resolve(__dirname3, "..", "package.json");
56805
- var packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf8"));
57434
+ var __dirname3 = path6.dirname(fileURLToPath2(import.meta.url));
57435
+ var packageJsonPath = path6.resolve(__dirname3, "..", "package.json");
57436
+ var packageJson = JSON.parse(fs5.readFileSync(packageJsonPath, "utf8"));
56806
57437
  var PACKAGE_VERSION2 = packageJson.version || "0.0.0";
56807
57438
 
56808
57439
  // src/index.ts
56809
- import fs5 from "fs";
57440
+ import fs7 from "fs";
56810
57441
  var BRIEF_DB_TIMEOUT_MS = 5e3;
56811
57442
  var STATIC_INSTRUCTIONS = `Long-term memory MCP server (RESPEC v1).
56812
57443
 
@@ -56814,12 +57445,14 @@ Tools:
56814
57445
  - memory_startup : \uC2DC\uC791 brief (user profile + \uCD5C\uADFC \uD65C\uC131 \uD504\uB85C\uC81D\uD2B8 + \uCD5C\uADFC \uBA54\uBAA8\uB9AC). \uC138\uC158 \uC2DC\uC791 \uC2DC \uCCAB \uD638\uCD9C \uAD8C\uC7A5.
56815
57446
  - search_memory : \uACFC\uAC70 \uAE30\uC5B5 \uC870\uD68C/\uAC80\uC0C9 \uD1B5\uD569 (\uC758\uBBF8 + \uD0A4\uC6CC\uB4DC fallback)
56816
57447
  - manage_knowledge : \uBA85\uC2DC \uC800\uC7A5/\uC218\uC815/\uC0AD\uC81C \uD1B5\uD569 (\uAC15\uC81C \uAE30\uC5B5\uC740 is_pinned, archive \uBA74\uC81C)
56817
- - save_message : \uB9E4 user/assistant turn \uB05D\uB098\uBA74 \uD638\uCD9C \u2014 Hot Path \uC790\uB3D9 \uC800\uC7A5
57448
+ - save_message : transcript \uCEA1\uCC98 \uBBF8\uC9C0\uC6D0 platform \uD55C\uC815 fallback (Cursor \uB4F1). Hot Path \uC9C1\uC811 INSERT.
56818
57449
 
56819
- Hot Path (\uC790\uB3D9 \uC800\uC7A5)\uB294 caller\uAC00 raw \uBA54\uC2DC\uC9C0 \uBC1C\uC0DD \uC2DC \uC9C1\uC811 \uD638\uCD9C \u2014 \uC0AC\uB78C\uC758 \uAE30\uC5B5\uCC98\uB7FC \uC2DC\uAC04 \uC21C\uC11C\uB85C raw \uBCF4\uC874, Cold Path\uAC00 \uBC31\uADF8\uB77C\uC6B4\uB4DC\uC5D0\uC11C \uD0DC\uAE45+\uC784\uBCA0\uB529.
57450
+ Hot Path (\uC790\uB3D9 \uC800\uC7A5) \uB8F0:
57451
+ - **Claude Code / Codex CLI / Gemini CLI**: server\uAC00 transcript \uD30C\uC77C\uC744 passive read\uD574\uC11C \uC790\uB3D9 \uCEA1\uCC98.
57452
+ \uBCC4\uB3C4 save_message \uD638\uCD9C X. \uD638\uCD9C\uD558\uBA74 \uB3D9\uC77C \uBA54\uC2DC\uC9C0 \uC911\uBCF5 row \uBC1C\uC0DD.
57453
+ - **\uADF8 \uC678 platform** (Cursor, Antigravity \uB4F1 transcript \uBE44\uACF5\uAC1C): \uB9E4 turn save_message \uD638\uCD9C \u2014 fallback.
56820
57454
 
56821
57455
  caller convention:
56822
- - \uB9E4 user/assistant turn \uB05D\uB098\uBA74 save_message \uD638\uCD9C (\uB610\uB294 Claude Code\uB294 SessionEnd JSONL \uC790\uB3D9 \uCEA1\uCC98)
56823
57456
  - manage_knowledge / save_message \uD638\uCD9C \uC2DC agent_model \uBA85\uC2DC (\uC0DD\uB7B5 \uC2DC 'unknown' \uC800\uC7A5)
56824
57457
  - subagent context\uBA74 subagent: true + subagent_model + subagent_role \uD568\uAED8`;
56825
57458
  var STATIC_INSTRUCTIONS_BRIEF_UNAVAILABLE = `
@@ -56869,11 +57502,15 @@ async function shutdown(reason) {
56869
57502
  stopParentWatchdog();
56870
57503
  try {
56871
57504
  await Promise.race([
56872
- captureSessionEnd(),
56873
- new Promise((resolve) => setTimeout(resolve, 3e3))
57505
+ Promise.allSettled([
57506
+ captureSessionEnd(),
57507
+ captureSessionEnd2(),
57508
+ captureSessionEnd3()
57509
+ ]),
57510
+ new Promise((resolve2) => setTimeout(resolve2, 3e3))
56874
57511
  ]);
56875
57512
  } catch (err2) {
56876
- console.error("\u{1F4DD} [JSONL] capture error (non-blocking):", err2);
57513
+ console.error("\u{1F4DD} capture error (non-blocking):", err2);
56877
57514
  }
56878
57515
  try {
56879
57516
  stopColdPathWorker();
@@ -56882,7 +57519,7 @@ async function shutdown(reason) {
56882
57519
  try {
56883
57520
  await Promise.race([
56884
57521
  drainColdPath(),
56885
- new Promise((resolve) => setTimeout(resolve, 2e4))
57522
+ new Promise((resolve2) => setTimeout(resolve2, 2e4))
56886
57523
  ]);
56887
57524
  } catch (err2) {
56888
57525
  console.error("\u{1F535} [ColdPath] drain error (non-blocking):", err2);
@@ -56890,7 +57527,7 @@ async function shutdown(reason) {
56890
57527
  try {
56891
57528
  await Promise.race([
56892
57529
  db.close(),
56893
- new Promise((resolve) => setTimeout(resolve, 3e3))
57530
+ new Promise((resolve2) => setTimeout(resolve2, 3e3))
56894
57531
  ]);
56895
57532
  } catch (err2) {
56896
57533
  console.error("Error during shutdown:", err2);
@@ -56975,11 +57612,13 @@ async function runMcpServer() {
56975
57612
  installShutdownHandlers();
56976
57613
  startParentWatchdog();
56977
57614
  captureSessionStart(process.cwd());
57615
+ captureSessionStart2(process.cwd());
57616
+ captureSessionStart3(process.cwd());
56978
57617
  console.error("\u{1F680} Starting Memory MCP Server...");
56979
57618
  if (process.env.SSH_ENABLED === "true" && !process.env.SSH_KEY_PATH) {
56980
57619
  throw new Error("\u274C SSH_KEY_PATH is required when SSH is enabled");
56981
57620
  }
56982
- if (process.env.SSH_KEY_PATH && !fs5.existsSync(process.env.SSH_KEY_PATH)) {
57621
+ if (process.env.SSH_KEY_PATH && !fs7.existsSync(process.env.SSH_KEY_PATH)) {
56983
57622
  console.error(`\u26A0\uFE0F [WARNING] SSH key not found at: ${process.env.SSH_KEY_PATH}`);
56984
57623
  }
56985
57624
  try {