mcp-agents-memory 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +4 -1
- package/README.md +40 -0
- package/build/index.js +880 -284
- 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
|
|
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 =
|
|
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
|
|
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
|
|
1478
|
-
const clientKey = await
|
|
1479
|
-
const storedKey = await
|
|
1480
|
-
const clientSignature = await
|
|
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
|
|
1483
|
-
const serverSignatureBytes = await
|
|
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
|
|
1678
|
+
const fs8 = config2.sslcert || config2.sslkey || config2.sslrootcert ? __require("fs") : null;
|
|
1679
1679
|
if (config2.sslcert) {
|
|
1680
|
-
config2.ssl.cert =
|
|
1680
|
+
config2.ssl.cert = fs8.readFileSync(config2.sslcert).toString();
|
|
1681
1681
|
}
|
|
1682
1682
|
if (config2.sslkey) {
|
|
1683
|
-
config2.ssl.key =
|
|
1683
|
+
config2.ssl.key = fs8.readFileSync(config2.sslkey).toString();
|
|
1684
1684
|
}
|
|
1685
1685
|
if (config2.sslrootcert) {
|
|
1686
|
-
config2.ssl.ca =
|
|
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((
|
|
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
|
|
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 ?
|
|
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
|
|
3623
|
-
var
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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((
|
|
3813
|
+
return new this._Promise((resolve2, reject) => {
|
|
3814
3814
|
this._connect((error2) => {
|
|
3815
3815
|
if (error2) {
|
|
3816
3816
|
reject(error2);
|
|
3817
3817
|
} else {
|
|
3818
|
-
|
|
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
|
|
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((
|
|
4165
|
-
query.callback = (err2, res) => err2 ? reject(err2) :
|
|
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((
|
|
4243
|
-
this.connection.once("end",
|
|
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(
|
|
4293
|
-
res =
|
|
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((
|
|
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(
|
|
4748
|
-
this._once("end",
|
|
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((
|
|
4925
|
+
return new this._Promise((resolve2, reject) => {
|
|
4926
4926
|
this._connect((error2) => {
|
|
4927
4927
|
if (error2) {
|
|
4928
4928
|
reject(error2);
|
|
4929
4929
|
} else {
|
|
4930
|
-
|
|
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((
|
|
4955
|
-
resolveOut =
|
|
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(
|
|
5016
|
-
cb = (err2) => err2 ? reject(err2) :
|
|
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
|
|
7932
|
-
if (
|
|
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
|
-
|
|
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
|
-
|
|
7944
|
-
if (
|
|
7943
|
+
crypto3 = __require("crypto");
|
|
7944
|
+
if (crypto3 && crypto3.randomBytes) {
|
|
7945
7945
|
nacl.setPRNG(function(x, n) {
|
|
7946
|
-
var i, v =
|
|
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
|
|
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
|
|
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 =
|
|
9229
|
-
verified =
|
|
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
|
|
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 =
|
|
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 =
|
|
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 (
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
12543
|
-
|
|
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
|
-
|
|
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 =
|
|
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(
|
|
13228
|
-
if (process.platform === "win32" && !WINDOWS_PIPE_REGEX.test(
|
|
13229
|
-
return
|
|
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(
|
|
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 =
|
|
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 =
|
|
16339
|
+
let digest = createHash2(hashName).update(secret).update(exchangeHash).update(char).update(sessionID).digest();
|
|
16340
16340
|
while (digest.length < len) {
|
|
16341
|
-
const chunk =
|
|
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
|
|
18207
|
-
var { constants } =
|
|
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(
|
|
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,
|
|
18478
|
+
return new ReadStream(this, path8, options);
|
|
18479
18479
|
}
|
|
18480
|
-
createWriteStream(
|
|
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,
|
|
18483
|
+
return new WriteStream(this, path8, options);
|
|
18484
18484
|
}
|
|
18485
|
-
open(
|
|
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(
|
|
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(
|
|
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,
|
|
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(
|
|
18641
|
+
fastXfer(fs8, this, localPath, remotePath, opts, cb);
|
|
18642
18642
|
}
|
|
18643
|
-
readFile(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
18808
|
+
this.writeFile(path8, data, options, callback);
|
|
18809
18809
|
}
|
|
18810
|
-
exists(
|
|
18810
|
+
exists(path8, cb) {
|
|
18811
18811
|
if (this.server)
|
|
18812
18812
|
throw new Error("Client-only method called in server mode");
|
|
18813
|
-
this.stat(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
19130
|
-
return this.setstat(
|
|
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(
|
|
19142
|
-
return this.setstat(
|
|
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(
|
|
19153
|
-
return this.setstat(
|
|
19152
|
+
chmod(path8, mode, cb) {
|
|
19153
|
+
return this.setstat(path8, {
|
|
19154
19154
|
mode
|
|
19155
19155
|
}, cb);
|
|
19156
19156
|
}
|
|
19157
|
-
readlink(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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 ===
|
|
19902
|
+
if (srcHandle && (src === fs8 || src.outgoing.state === "open"))
|
|
19903
19903
|
++left;
|
|
19904
|
-
if (dstHandle && (dst ===
|
|
19904
|
+
if (dstHandle && (dst === fs8 || dst.outgoing.state === "open"))
|
|
19905
19905
|
++left;
|
|
19906
|
-
if (srcHandle && (src ===
|
|
19906
|
+
if (srcHandle && (src === fs8 || src.outgoing.state === "open"))
|
|
19907
19907
|
src.close(srcHandle, cbfinal);
|
|
19908
|
-
if (dstHandle && (dst ===
|
|
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 !==
|
|
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
|
|
20707
|
+
const path8 = bufferParser.readString(true);
|
|
20708
20708
|
bufferParser.clear();
|
|
20709
|
-
if (
|
|
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,
|
|
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
|
|
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,
|
|
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
|
|
20759
|
+
const path8 = bufferParser.readString(true);
|
|
20760
20760
|
bufferParser.clear();
|
|
20761
|
-
if (
|
|
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,
|
|
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
|
|
20783
|
+
const path8 = bufferParser.readString(true);
|
|
20784
20784
|
bufferParser.clear();
|
|
20785
|
-
if (
|
|
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,
|
|
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
|
|
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,
|
|
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
|
|
20808
|
+
const path8 = bufferParser.readString(true);
|
|
20809
20809
|
bufferParser.clear();
|
|
20810
|
-
if (
|
|
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,
|
|
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
|
|
20820
|
+
const path8 = bufferParser.readString(true);
|
|
20821
20821
|
bufferParser.clear();
|
|
20822
|
-
if (
|
|
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,
|
|
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
|
|
20834
|
+
const path8 = bufferParser.readString(true);
|
|
20835
20835
|
bufferParser.clear();
|
|
20836
|
-
if (
|
|
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,
|
|
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
|
|
20859
|
+
const path8 = bufferParser.readString(true);
|
|
20860
20860
|
bufferParser.clear();
|
|
20861
|
-
if (
|
|
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,
|
|
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,
|
|
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 =
|
|
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,
|
|
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 =
|
|
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 =
|
|
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
|
|
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((
|
|
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
|
-
|
|
25328
|
+
resolve2(server);
|
|
25329
25329
|
});
|
|
25330
25330
|
});
|
|
25331
25331
|
}
|
|
25332
25332
|
async function createSSHConnection(config2) {
|
|
25333
|
-
return new Promise(function(
|
|
25333
|
+
return new Promise(function(resolve2, reject) {
|
|
25334
25334
|
let conn = new Client2();
|
|
25335
|
-
conn.on("ready", () =>
|
|
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(
|
|
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
|
-
|
|
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
|
|
25489
|
-
var
|
|
25490
|
-
var
|
|
25491
|
-
var
|
|
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 (
|
|
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 =
|
|
25605
|
+
possibleVaultPath = path8.resolve(process.cwd(), ".env.vault");
|
|
25606
25606
|
}
|
|
25607
|
-
if (
|
|
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] === "~" ?
|
|
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 =
|
|
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
|
|
25654
|
+
for (const path9 of optionPaths) {
|
|
25655
25655
|
try {
|
|
25656
|
-
const parsed = DotenvModule.parse(
|
|
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 ${
|
|
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 =
|
|
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 =
|
|
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((
|
|
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
|
-
|
|
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((
|
|
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
|
-
|
|
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 =
|
|
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
|
|
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(
|
|
29166
|
-
let input =
|
|
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 [
|
|
29366
|
-
wsComponent.path =
|
|
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
|
|
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,
|
|
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,
|
|
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
|
|
32773
|
-
import
|
|
32772
|
+
import fs6 from "fs";
|
|
32773
|
+
import path7 from "path";
|
|
32774
32774
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
32775
32775
|
function listMigrationFiles() {
|
|
32776
|
-
if (!
|
|
32777
|
-
return
|
|
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((
|
|
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
|
|
32787
|
-
reject(new Error(`Migration ${
|
|
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(
|
|
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 =
|
|
32810
|
-
migrationsDir =
|
|
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:
|
|
33297
|
-
const fullPath = [...
|
|
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,
|
|
33413
|
+
constructor(parent, value, path8, key) {
|
|
33414
33414
|
this._cachedPath = [];
|
|
33415
33415
|
this.parent = parent;
|
|
33416
33416
|
this.data = value;
|
|
33417
|
-
this._path =
|
|
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,
|
|
37055
|
-
if (!
|
|
37054
|
+
function getElementAtPath(obj, path8) {
|
|
37055
|
+
if (!path8)
|
|
37056
37056
|
return obj;
|
|
37057
|
-
return
|
|
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(
|
|
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(
|
|
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((
|
|
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((
|
|
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
|
-
|
|
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((
|
|
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(
|
|
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((
|
|
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((
|
|
47019
|
+
return new Promise((resolve2) => {
|
|
47020
47020
|
const json = serializeMessage(message);
|
|
47021
47021
|
if (this._stdout.write(json)) {
|
|
47022
|
-
|
|
47022
|
+
resolve2();
|
|
47023
47023
|
} else {
|
|
47024
|
-
this._stdout.once("drain",
|
|
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:
|
|
47173
|
-
if (
|
|
47174
|
-
uuid4 =
|
|
47175
|
-
return
|
|
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 =
|
|
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((
|
|
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((
|
|
48471
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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
|
-
${
|
|
48943
|
+
${path9}
|
|
48944
48944
|
${underline}`);
|
|
48945
48945
|
}
|
|
48946
|
-
return
|
|
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((
|
|
49120
|
-
__classPrivateFieldSet(this, _EventStream_resolveConnectedPromise,
|
|
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((
|
|
49124
|
-
__classPrivateFieldSet(this, _EventStream_resolveEndPromise,
|
|
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((
|
|
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,
|
|
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((
|
|
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((
|
|
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((
|
|
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(
|
|
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(
|
|
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(
|
|
53947
|
-
return this.methodRequest("get",
|
|
53946
|
+
get(path8, opts) {
|
|
53947
|
+
return this.methodRequest("get", path8, opts);
|
|
53948
53948
|
}
|
|
53949
|
-
post(
|
|
53950
|
-
return this.methodRequest("post",
|
|
53949
|
+
post(path8, opts) {
|
|
53950
|
+
return this.methodRequest("post", path8, opts);
|
|
53951
53951
|
}
|
|
53952
|
-
patch(
|
|
53953
|
-
return this.methodRequest("patch",
|
|
53952
|
+
patch(path8, opts) {
|
|
53953
|
+
return this.methodRequest("patch", path8, opts);
|
|
53954
53954
|
}
|
|
53955
|
-
put(
|
|
53956
|
-
return this.methodRequest("put",
|
|
53955
|
+
put(path8, opts) {
|
|
53956
|
+
return this.methodRequest("put", path8, opts);
|
|
53957
53957
|
}
|
|
53958
|
-
delete(
|
|
53959
|
-
return this.methodRequest("delete",
|
|
53958
|
+
delete(path8, opts) {
|
|
53959
|
+
return this.methodRequest("delete", path8, opts);
|
|
53960
53960
|
}
|
|
53961
|
-
methodRequest(method,
|
|
53961
|
+
methodRequest(method, path8, opts) {
|
|
53962
53962
|
return this.request(Promise.resolve(opts).then((opts2) => {
|
|
53963
|
-
return { method, path:
|
|
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(
|
|
54082
|
-
return this.requestAPIList(Page2, opts && "then" in opts ? opts.then((opts2) => ({ method: "get", path:
|
|
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:
|
|
54174
|
-
const url = this.buildURL(
|
|
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;
|
|
@@ -56796,17 +56796,605 @@ async function captureSessionEnd() {
|
|
|
56796
56796
|
}
|
|
56797
56797
|
}
|
|
56798
56798
|
|
|
56799
|
+
// src/auto_save/codex_capture.ts
|
|
56800
|
+
import * as fs3 from "node:fs";
|
|
56801
|
+
import * as path4 from "node:path";
|
|
56802
|
+
import * as os3 from "node:os";
|
|
56803
|
+
var CLIENT_PLATFORM2 = "codex-mcp-client";
|
|
56804
|
+
var SESSIONS_ROOT = path4.join(os3.homedir(), ".codex", "sessions");
|
|
56805
|
+
var FLUSH_DEBOUNCE_MS2 = 200;
|
|
56806
|
+
var _state2 = null;
|
|
56807
|
+
var _watcher2 = null;
|
|
56808
|
+
var _flushInProgress2 = false;
|
|
56809
|
+
var _flushPending2 = false;
|
|
56810
|
+
var _flushDebounceTimer2 = null;
|
|
56811
|
+
function extractSessionId(filename) {
|
|
56812
|
+
const m = filename.match(/^rollout-.+?-([0-9a-f-]{36})\.jsonl$/);
|
|
56813
|
+
return m ? m[1] : null;
|
|
56814
|
+
}
|
|
56815
|
+
function probeSessionMeta(filePath) {
|
|
56816
|
+
let fd;
|
|
56817
|
+
try {
|
|
56818
|
+
fd = fs3.openSync(filePath, "r");
|
|
56819
|
+
} catch {
|
|
56820
|
+
return null;
|
|
56821
|
+
}
|
|
56822
|
+
try {
|
|
56823
|
+
const buf = Buffer.alloc(8192);
|
|
56824
|
+
const n = fs3.readSync(fd, buf, 0, 8192, 0);
|
|
56825
|
+
if (n === 0) return null;
|
|
56826
|
+
const slice = buf.slice(0, n).toString("utf-8");
|
|
56827
|
+
const nl = slice.indexOf("\n");
|
|
56828
|
+
if (nl === -1) return null;
|
|
56829
|
+
const entry = JSON.parse(slice.slice(0, nl));
|
|
56830
|
+
if (entry.type !== "session_meta") return null;
|
|
56831
|
+
const sid = entry.payload?.id;
|
|
56832
|
+
const cwd = entry.payload?.cwd;
|
|
56833
|
+
if (typeof sid !== "string" || typeof cwd !== "string") return null;
|
|
56834
|
+
return { sessionId: sid, cwd };
|
|
56835
|
+
} catch {
|
|
56836
|
+
return null;
|
|
56837
|
+
} finally {
|
|
56838
|
+
try {
|
|
56839
|
+
fs3.closeSync(fd);
|
|
56840
|
+
} catch {
|
|
56841
|
+
}
|
|
56842
|
+
}
|
|
56843
|
+
}
|
|
56844
|
+
function* walkRollouts(root) {
|
|
56845
|
+
if (!fs3.existsSync(root)) return;
|
|
56846
|
+
const stack = [root];
|
|
56847
|
+
while (stack.length) {
|
|
56848
|
+
const dir = stack.pop();
|
|
56849
|
+
let entries;
|
|
56850
|
+
try {
|
|
56851
|
+
entries = fs3.readdirSync(dir, { withFileTypes: true });
|
|
56852
|
+
} catch {
|
|
56853
|
+
continue;
|
|
56854
|
+
}
|
|
56855
|
+
for (const e of entries) {
|
|
56856
|
+
const p = path4.join(dir, e.name);
|
|
56857
|
+
if (e.isDirectory()) {
|
|
56858
|
+
stack.push(p);
|
|
56859
|
+
} else if (e.isFile() && e.name.startsWith("rollout-") && e.name.endsWith(".jsonl")) {
|
|
56860
|
+
yield p;
|
|
56861
|
+
}
|
|
56862
|
+
}
|
|
56863
|
+
}
|
|
56864
|
+
}
|
|
56865
|
+
function captureSessionStart2(cwd) {
|
|
56866
|
+
const cwdNormalized = path4.resolve(cwd);
|
|
56867
|
+
const rootExists = fs3.existsSync(SESSIONS_ROOT);
|
|
56868
|
+
_state2 = {
|
|
56869
|
+
cwd,
|
|
56870
|
+
cwdNormalized,
|
|
56871
|
+
rootExists,
|
|
56872
|
+
files: /* @__PURE__ */ new Map()
|
|
56873
|
+
};
|
|
56874
|
+
if (!rootExists) {
|
|
56875
|
+
return;
|
|
56876
|
+
}
|
|
56877
|
+
let count = 0, matched = 0;
|
|
56878
|
+
for (const filePath of walkRollouts(SESSIONS_ROOT)) {
|
|
56879
|
+
let stat;
|
|
56880
|
+
try {
|
|
56881
|
+
stat = fs3.statSync(filePath);
|
|
56882
|
+
} catch {
|
|
56883
|
+
continue;
|
|
56884
|
+
}
|
|
56885
|
+
const sessionId = extractSessionId(path4.basename(filePath));
|
|
56886
|
+
if (!sessionId) continue;
|
|
56887
|
+
const meta = probeSessionMeta(filePath);
|
|
56888
|
+
let cwdMatched = null;
|
|
56889
|
+
if (meta) {
|
|
56890
|
+
cwdMatched = path4.resolve(meta.cwd) === cwdNormalized;
|
|
56891
|
+
}
|
|
56892
|
+
_state2.files.set(filePath, {
|
|
56893
|
+
cursorBytes: stat.size,
|
|
56894
|
+
sessionId,
|
|
56895
|
+
cwdMatched,
|
|
56896
|
+
currentModel: null
|
|
56897
|
+
});
|
|
56898
|
+
count++;
|
|
56899
|
+
if (cwdMatched) matched++;
|
|
56900
|
+
}
|
|
56901
|
+
console.error(`\u{1F4DD} [Codex] capture armed: ${count} rollout(s), ${matched} cwd-matched`);
|
|
56902
|
+
armDirWatcher2();
|
|
56903
|
+
}
|
|
56904
|
+
function parseEntry2(line, byteOffset) {
|
|
56905
|
+
let entry;
|
|
56906
|
+
try {
|
|
56907
|
+
entry = JSON.parse(line);
|
|
56908
|
+
} catch {
|
|
56909
|
+
return null;
|
|
56910
|
+
}
|
|
56911
|
+
if (entry.type !== "event_msg") return null;
|
|
56912
|
+
const payload = entry.payload;
|
|
56913
|
+
if (!payload || typeof payload !== "object") return null;
|
|
56914
|
+
const ptype = payload.type;
|
|
56915
|
+
let role;
|
|
56916
|
+
if (ptype === "user_message") {
|
|
56917
|
+
role = "user";
|
|
56918
|
+
} else if (ptype === "agent_message") {
|
|
56919
|
+
role = "assistant";
|
|
56920
|
+
} else {
|
|
56921
|
+
return null;
|
|
56922
|
+
}
|
|
56923
|
+
const message = typeof payload.message === "string" ? payload.message.trim() : "";
|
|
56924
|
+
if (!message) return null;
|
|
56925
|
+
return { byteOffset, role, message };
|
|
56926
|
+
}
|
|
56927
|
+
function extractModelFromTurnContext(line) {
|
|
56928
|
+
try {
|
|
56929
|
+
const entry = JSON.parse(line);
|
|
56930
|
+
if (entry.type !== "turn_context") return null;
|
|
56931
|
+
const m = entry.payload?.model;
|
|
56932
|
+
return typeof m === "string" ? m : null;
|
|
56933
|
+
} catch {
|
|
56934
|
+
return null;
|
|
56935
|
+
}
|
|
56936
|
+
}
|
|
56937
|
+
function applySessionMetaIfPresent(line, fileState, cwdNormalized) {
|
|
56938
|
+
if (fileState.cwdMatched !== null) return;
|
|
56939
|
+
try {
|
|
56940
|
+
const entry = JSON.parse(line);
|
|
56941
|
+
if (entry.type !== "session_meta") return;
|
|
56942
|
+
const cwd = entry.payload?.cwd;
|
|
56943
|
+
if (typeof cwd !== "string") return;
|
|
56944
|
+
fileState.cwdMatched = path4.resolve(cwd) === cwdNormalized;
|
|
56945
|
+
} catch {
|
|
56946
|
+
}
|
|
56947
|
+
}
|
|
56948
|
+
async function flushDeltaForFile2(filePath, fileState, cwdNormalized) {
|
|
56949
|
+
if (!fs3.existsSync(filePath)) return { inserted: 0, skipped: 0, dedup: 0 };
|
|
56950
|
+
let stat;
|
|
56951
|
+
try {
|
|
56952
|
+
stat = fs3.statSync(filePath);
|
|
56953
|
+
} catch {
|
|
56954
|
+
return { inserted: 0, skipped: 0, dedup: 0 };
|
|
56955
|
+
}
|
|
56956
|
+
if (stat.size <= fileState.cursorBytes) return { inserted: 0, skipped: 0, dedup: 0 };
|
|
56957
|
+
const length = stat.size - fileState.cursorBytes;
|
|
56958
|
+
const fd = fs3.openSync(filePath, "r");
|
|
56959
|
+
let raw;
|
|
56960
|
+
try {
|
|
56961
|
+
const buf = Buffer.alloc(length);
|
|
56962
|
+
fs3.readSync(fd, buf, 0, length, fileState.cursorBytes);
|
|
56963
|
+
raw = buf.toString("utf-8");
|
|
56964
|
+
} finally {
|
|
56965
|
+
fs3.closeSync(fd);
|
|
56966
|
+
}
|
|
56967
|
+
const lastNl = raw.lastIndexOf("\n");
|
|
56968
|
+
if (lastNl === -1) return { inserted: 0, skipped: 0, dedup: 0 };
|
|
56969
|
+
const parsable = raw.slice(0, lastNl);
|
|
56970
|
+
const advanceBy = Buffer.byteLength(parsable, "utf-8") + 1;
|
|
56971
|
+
const startBase = fileState.cursorBytes;
|
|
56972
|
+
const newCursor = fileState.cursorBytes + advanceBy;
|
|
56973
|
+
const userId = await getDefaultUserId();
|
|
56974
|
+
let inserted = 0, skipped = 0, dedup = 0;
|
|
56975
|
+
let lineStartInRaw = 0;
|
|
56976
|
+
const lines = parsable.split("\n");
|
|
56977
|
+
for (const line of lines) {
|
|
56978
|
+
const trimmed = line.trim();
|
|
56979
|
+
if (!trimmed) {
|
|
56980
|
+
lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
|
|
56981
|
+
continue;
|
|
56982
|
+
}
|
|
56983
|
+
applySessionMetaIfPresent(trimmed, fileState, cwdNormalized);
|
|
56984
|
+
const m = extractModelFromTurnContext(trimmed);
|
|
56985
|
+
if (m !== null) {
|
|
56986
|
+
fileState.currentModel = m;
|
|
56987
|
+
lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
|
|
56988
|
+
continue;
|
|
56989
|
+
}
|
|
56990
|
+
if (fileState.cwdMatched === false) {
|
|
56991
|
+
lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
|
|
56992
|
+
continue;
|
|
56993
|
+
}
|
|
56994
|
+
const byteOffset = startBase + lineStartInRaw;
|
|
56995
|
+
const parsed = parseEntry2(trimmed, byteOffset);
|
|
56996
|
+
if (!parsed) {
|
|
56997
|
+
skipped++;
|
|
56998
|
+
lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
|
|
56999
|
+
continue;
|
|
57000
|
+
}
|
|
57001
|
+
if (fileState.cwdMatched !== true) {
|
|
57002
|
+
skipped++;
|
|
57003
|
+
lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
|
|
57004
|
+
continue;
|
|
57005
|
+
}
|
|
57006
|
+
const externalUuid = `codex:${fileState.sessionId}:${parsed.byteOffset}`;
|
|
57007
|
+
const agentModel = parsed.role === "user" ? null : fileState.currentModel ?? "unknown";
|
|
57008
|
+
try {
|
|
57009
|
+
const result = await insertRawMemory({
|
|
57010
|
+
user_id: userId,
|
|
57011
|
+
agent_platform: CLIENT_PLATFORM2,
|
|
57012
|
+
agent_model: agentModel,
|
|
57013
|
+
role: parsed.role,
|
|
57014
|
+
message: parsed.message,
|
|
57015
|
+
external_uuid: externalUuid
|
|
57016
|
+
});
|
|
57017
|
+
if (result.inserted) inserted++;
|
|
57018
|
+
else dedup++;
|
|
57019
|
+
} catch (err2) {
|
|
57020
|
+
console.error(`\u26A0\uFE0F [Codex] insert failed at offset ${byteOffset}:`, err2);
|
|
57021
|
+
skipped++;
|
|
57022
|
+
}
|
|
57023
|
+
lineStartInRaw += Buffer.byteLength(line, "utf-8") + 1;
|
|
57024
|
+
}
|
|
57025
|
+
fileState.cursorBytes = newCursor;
|
|
57026
|
+
return { inserted, skipped, dedup };
|
|
57027
|
+
}
|
|
57028
|
+
async function flushAllFiles2() {
|
|
57029
|
+
if (!_state2 || !_state2.rootExists) return { inserted: 0, skipped: 0, dedup: 0 };
|
|
57030
|
+
const cwdNormalized = _state2.cwdNormalized;
|
|
57031
|
+
let totalI = 0, totalS = 0, totalD = 0;
|
|
57032
|
+
for (const filePath of walkRollouts(SESSIONS_ROOT)) {
|
|
57033
|
+
let fileState = _state2.files.get(filePath);
|
|
57034
|
+
if (!fileState) {
|
|
57035
|
+
const sessionId = extractSessionId(path4.basename(filePath));
|
|
57036
|
+
if (!sessionId) continue;
|
|
57037
|
+
fileState = {
|
|
57038
|
+
cursorBytes: 0,
|
|
57039
|
+
sessionId,
|
|
57040
|
+
cwdMatched: null,
|
|
57041
|
+
currentModel: null
|
|
57042
|
+
};
|
|
57043
|
+
_state2.files.set(filePath, fileState);
|
|
57044
|
+
console.error(`\u{1F4DD} [Codex] new rollout detected: ${path4.basename(filePath)}`);
|
|
57045
|
+
}
|
|
57046
|
+
const r = await flushDeltaForFile2(filePath, fileState, cwdNormalized);
|
|
57047
|
+
totalI += r.inserted;
|
|
57048
|
+
totalS += r.skipped;
|
|
57049
|
+
totalD += r.dedup;
|
|
57050
|
+
}
|
|
57051
|
+
return { inserted: totalI, skipped: totalS, dedup: totalD };
|
|
57052
|
+
}
|
|
57053
|
+
async function flushWithMutex2() {
|
|
57054
|
+
if (_flushInProgress2) {
|
|
57055
|
+
_flushPending2 = true;
|
|
57056
|
+
return;
|
|
57057
|
+
}
|
|
57058
|
+
_flushInProgress2 = true;
|
|
57059
|
+
try {
|
|
57060
|
+
const r = await flushAllFiles2();
|
|
57061
|
+
if (r.inserted > 0 || r.skipped > 0 || r.dedup > 0) {
|
|
57062
|
+
console.error(`\u{1F4DD} [Codex] live flush: inserted=${r.inserted}, dedup=${r.dedup}, skipped=${r.skipped}`);
|
|
57063
|
+
}
|
|
57064
|
+
} catch (err2) {
|
|
57065
|
+
console.error("\u26A0\uFE0F [Codex] live flush error:", err2);
|
|
57066
|
+
} finally {
|
|
57067
|
+
_flushInProgress2 = false;
|
|
57068
|
+
if (_flushPending2) {
|
|
57069
|
+
_flushPending2 = false;
|
|
57070
|
+
setImmediate(() => {
|
|
57071
|
+
void flushWithMutex2();
|
|
57072
|
+
});
|
|
57073
|
+
}
|
|
57074
|
+
}
|
|
57075
|
+
}
|
|
57076
|
+
function scheduleFlush2() {
|
|
57077
|
+
if (_flushDebounceTimer2) clearTimeout(_flushDebounceTimer2);
|
|
57078
|
+
_flushDebounceTimer2 = setTimeout(() => {
|
|
57079
|
+
_flushDebounceTimer2 = null;
|
|
57080
|
+
void flushWithMutex2();
|
|
57081
|
+
}, FLUSH_DEBOUNCE_MS2);
|
|
57082
|
+
}
|
|
57083
|
+
function armDirWatcher2() {
|
|
57084
|
+
if (!_state2 || !_state2.rootExists) return;
|
|
57085
|
+
if (_watcher2) return;
|
|
57086
|
+
try {
|
|
57087
|
+
_watcher2 = fs3.watch(SESSIONS_ROOT, { recursive: true }, (_evt, filename) => {
|
|
57088
|
+
if (!filename) return;
|
|
57089
|
+
const base = path4.basename(filename);
|
|
57090
|
+
if (!base.startsWith("rollout-") || !base.endsWith(".jsonl")) return;
|
|
57091
|
+
scheduleFlush2();
|
|
57092
|
+
});
|
|
57093
|
+
console.error(`\u{1F4DD} [Codex] dir watcher armed (recursive)`);
|
|
57094
|
+
} catch (err2) {
|
|
57095
|
+
console.error("\u26A0\uFE0F [Codex] fs.watch failed (shutdown-only flush \uD3F4\uBC31):", err2);
|
|
57096
|
+
}
|
|
57097
|
+
}
|
|
57098
|
+
function disarmDirWatcher2() {
|
|
57099
|
+
if (_flushDebounceTimer2) {
|
|
57100
|
+
clearTimeout(_flushDebounceTimer2);
|
|
57101
|
+
_flushDebounceTimer2 = null;
|
|
57102
|
+
}
|
|
57103
|
+
if (_watcher2) {
|
|
57104
|
+
try {
|
|
57105
|
+
_watcher2.close();
|
|
57106
|
+
} catch {
|
|
57107
|
+
}
|
|
57108
|
+
_watcher2 = null;
|
|
57109
|
+
}
|
|
57110
|
+
}
|
|
57111
|
+
async function captureSessionEnd2() {
|
|
57112
|
+
disarmDirWatcher2();
|
|
57113
|
+
const waitStart = Date.now();
|
|
57114
|
+
while (_flushInProgress2 && Date.now() - waitStart < 2e3) {
|
|
57115
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
57116
|
+
}
|
|
57117
|
+
if (!_state2 || !_state2.rootExists) {
|
|
57118
|
+
return { inserted: 0, skipped: 0, error: "session not armed" };
|
|
57119
|
+
}
|
|
57120
|
+
_flushInProgress2 = true;
|
|
57121
|
+
try {
|
|
57122
|
+
const r = await flushAllFiles2();
|
|
57123
|
+
if (r.inserted > 0 || r.skipped > 0 || r.dedup > 0) {
|
|
57124
|
+
console.error(`\u{1F4DD} [Codex] final flush: inserted=${r.inserted}, dedup=${r.dedup}, skipped=${r.skipped}`);
|
|
57125
|
+
}
|
|
57126
|
+
return { inserted: r.inserted, skipped: r.skipped };
|
|
57127
|
+
} finally {
|
|
57128
|
+
_flushInProgress2 = false;
|
|
57129
|
+
}
|
|
57130
|
+
}
|
|
57131
|
+
|
|
57132
|
+
// src/auto_save/gemini_capture.ts
|
|
57133
|
+
import * as fs4 from "node:fs";
|
|
57134
|
+
import * as path5 from "node:path";
|
|
57135
|
+
import * as os4 from "node:os";
|
|
57136
|
+
import * as crypto2 from "node:crypto";
|
|
57137
|
+
var CLIENT_PLATFORM3 = "gemini-cli-mcp-client";
|
|
57138
|
+
var GEMINI_TMP_ROOT = path5.join(os4.homedir(), ".gemini", "tmp");
|
|
57139
|
+
var FLUSH_DEBOUNCE_MS3 = 200;
|
|
57140
|
+
var PARSE_RETRY_MS = 80;
|
|
57141
|
+
var _state3 = null;
|
|
57142
|
+
var _watchers = [];
|
|
57143
|
+
var _flushInProgress3 = false;
|
|
57144
|
+
var _flushPending3 = false;
|
|
57145
|
+
var _flushDebounceTimer3 = null;
|
|
57146
|
+
function extractShortId(filename) {
|
|
57147
|
+
const m = filename.match(/^session-.+?-([0-9a-f]+)\.json$/);
|
|
57148
|
+
return m ? m[1] : filename.replace(/\.json$/, "");
|
|
57149
|
+
}
|
|
57150
|
+
function deriveChatsDirCandidates(cwd) {
|
|
57151
|
+
const cwdHash = crypto2.createHash("sha256").update(cwd).digest("hex");
|
|
57152
|
+
const candidates = [
|
|
57153
|
+
path5.join(GEMINI_TMP_ROOT, cwdHash, "chats"),
|
|
57154
|
+
path5.join(GEMINI_TMP_ROOT, path5.basename(cwd), "chats")
|
|
57155
|
+
];
|
|
57156
|
+
return candidates.filter((d) => fs4.existsSync(d));
|
|
57157
|
+
}
|
|
57158
|
+
async function readSessionFile(filePath) {
|
|
57159
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
57160
|
+
try {
|
|
57161
|
+
const raw = fs4.readFileSync(filePath, "utf-8");
|
|
57162
|
+
if (!raw.trim()) return null;
|
|
57163
|
+
return JSON.parse(raw);
|
|
57164
|
+
} catch {
|
|
57165
|
+
if (attempt === 0) {
|
|
57166
|
+
await new Promise((r) => setTimeout(r, PARSE_RETRY_MS));
|
|
57167
|
+
continue;
|
|
57168
|
+
}
|
|
57169
|
+
return null;
|
|
57170
|
+
}
|
|
57171
|
+
}
|
|
57172
|
+
return null;
|
|
57173
|
+
}
|
|
57174
|
+
function parseMessage(msg, fallbackId) {
|
|
57175
|
+
let role;
|
|
57176
|
+
if (msg.type === "user") role = "user";
|
|
57177
|
+
else if (msg.type === "gemini") role = "assistant";
|
|
57178
|
+
else return null;
|
|
57179
|
+
let text = "";
|
|
57180
|
+
const c = msg.content;
|
|
57181
|
+
if (typeof c === "string") {
|
|
57182
|
+
text = c;
|
|
57183
|
+
} else if (Array.isArray(c)) {
|
|
57184
|
+
for (const block of c) {
|
|
57185
|
+
if (block && typeof block === "object" && typeof block.text === "string") {
|
|
57186
|
+
text += (text ? "\n" : "") + block.text;
|
|
57187
|
+
}
|
|
57188
|
+
}
|
|
57189
|
+
}
|
|
57190
|
+
text = text.trim();
|
|
57191
|
+
if (!text) return null;
|
|
57192
|
+
const msgId = typeof msg.id === "string" && msg.id ? msg.id : fallbackId;
|
|
57193
|
+
const agent_model = role === "assistant" && typeof msg.model === "string" ? msg.model : null;
|
|
57194
|
+
return { msgId, role, message: text, agent_model };
|
|
57195
|
+
}
|
|
57196
|
+
async function flushDeltaForFile3(filePath, fileState) {
|
|
57197
|
+
const session = await readSessionFile(filePath);
|
|
57198
|
+
if (!session || !Array.isArray(session.messages)) {
|
|
57199
|
+
return { inserted: 0, skipped: 0, dedup: 0 };
|
|
57200
|
+
}
|
|
57201
|
+
const messages = session.messages;
|
|
57202
|
+
if (messages.length <= fileState.cursorIndex) {
|
|
57203
|
+
return { inserted: 0, skipped: 0, dedup: 0 };
|
|
57204
|
+
}
|
|
57205
|
+
if (typeof session.sessionId === "string" && session.sessionId) {
|
|
57206
|
+
fileState.sessionId = session.sessionId;
|
|
57207
|
+
}
|
|
57208
|
+
const userId = await getDefaultUserId();
|
|
57209
|
+
let inserted = 0, skipped = 0, dedup = 0;
|
|
57210
|
+
for (let i = fileState.cursorIndex; i < messages.length; i++) {
|
|
57211
|
+
const msg = messages[i];
|
|
57212
|
+
const fallbackId = `${fileState.sessionId}-${i}`;
|
|
57213
|
+
const parsed = parseMessage(msg, fallbackId);
|
|
57214
|
+
if (!parsed) {
|
|
57215
|
+
skipped++;
|
|
57216
|
+
continue;
|
|
57217
|
+
}
|
|
57218
|
+
const externalUuid = `gemini:${fileState.sessionId}:${parsed.msgId}`;
|
|
57219
|
+
const agentModel = parsed.role === "user" ? null : parsed.agent_model ?? "unknown";
|
|
57220
|
+
try {
|
|
57221
|
+
const result = await insertRawMemory({
|
|
57222
|
+
user_id: userId,
|
|
57223
|
+
agent_platform: CLIENT_PLATFORM3,
|
|
57224
|
+
agent_model: agentModel,
|
|
57225
|
+
role: parsed.role,
|
|
57226
|
+
message: parsed.message,
|
|
57227
|
+
external_uuid: externalUuid
|
|
57228
|
+
});
|
|
57229
|
+
if (result.inserted) inserted++;
|
|
57230
|
+
else dedup++;
|
|
57231
|
+
} catch (err2) {
|
|
57232
|
+
console.error(`\u26A0\uFE0F [Gemini] insert failed at index ${i}:`, err2);
|
|
57233
|
+
skipped++;
|
|
57234
|
+
}
|
|
57235
|
+
}
|
|
57236
|
+
fileState.cursorIndex = messages.length;
|
|
57237
|
+
return { inserted, skipped, dedup };
|
|
57238
|
+
}
|
|
57239
|
+
async function flushAllFiles3() {
|
|
57240
|
+
if (!_state3) return { inserted: 0, skipped: 0, dedup: 0 };
|
|
57241
|
+
let totalI = 0, totalS = 0, totalD = 0;
|
|
57242
|
+
for (const dir of _state3.chatsDirs) {
|
|
57243
|
+
if (!fs4.existsSync(dir)) continue;
|
|
57244
|
+
let entries;
|
|
57245
|
+
try {
|
|
57246
|
+
entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
57247
|
+
} catch {
|
|
57248
|
+
continue;
|
|
57249
|
+
}
|
|
57250
|
+
for (const entry of entries) {
|
|
57251
|
+
if (!entry.isFile() || !entry.name.endsWith(".json")) continue;
|
|
57252
|
+
if (!entry.name.startsWith("session-")) continue;
|
|
57253
|
+
const filePath = path5.join(dir, entry.name);
|
|
57254
|
+
let fileState = _state3.files.get(filePath);
|
|
57255
|
+
if (!fileState) {
|
|
57256
|
+
const sessionId = extractShortId(entry.name);
|
|
57257
|
+
fileState = { cursorIndex: 0, sessionId };
|
|
57258
|
+
_state3.files.set(filePath, fileState);
|
|
57259
|
+
console.error(`\u{1F4DD} [Gemini] new session detected: ${entry.name}`);
|
|
57260
|
+
}
|
|
57261
|
+
const r = await flushDeltaForFile3(filePath, fileState);
|
|
57262
|
+
totalI += r.inserted;
|
|
57263
|
+
totalS += r.skipped;
|
|
57264
|
+
totalD += r.dedup;
|
|
57265
|
+
}
|
|
57266
|
+
}
|
|
57267
|
+
return { inserted: totalI, skipped: totalS, dedup: totalD };
|
|
57268
|
+
}
|
|
57269
|
+
async function flushWithMutex3() {
|
|
57270
|
+
if (_flushInProgress3) {
|
|
57271
|
+
_flushPending3 = true;
|
|
57272
|
+
return;
|
|
57273
|
+
}
|
|
57274
|
+
_flushInProgress3 = true;
|
|
57275
|
+
try {
|
|
57276
|
+
const r = await flushAllFiles3();
|
|
57277
|
+
if (r.inserted > 0 || r.skipped > 0 || r.dedup > 0) {
|
|
57278
|
+
console.error(`\u{1F4DD} [Gemini] live flush: inserted=${r.inserted}, dedup=${r.dedup}, skipped=${r.skipped}`);
|
|
57279
|
+
}
|
|
57280
|
+
} catch (err2) {
|
|
57281
|
+
console.error("\u26A0\uFE0F [Gemini] live flush error:", err2);
|
|
57282
|
+
} finally {
|
|
57283
|
+
_flushInProgress3 = false;
|
|
57284
|
+
if (_flushPending3) {
|
|
57285
|
+
_flushPending3 = false;
|
|
57286
|
+
setImmediate(() => {
|
|
57287
|
+
void flushWithMutex3();
|
|
57288
|
+
});
|
|
57289
|
+
}
|
|
57290
|
+
}
|
|
57291
|
+
}
|
|
57292
|
+
function scheduleFlush3() {
|
|
57293
|
+
if (_flushDebounceTimer3) clearTimeout(_flushDebounceTimer3);
|
|
57294
|
+
_flushDebounceTimer3 = setTimeout(() => {
|
|
57295
|
+
_flushDebounceTimer3 = null;
|
|
57296
|
+
void flushWithMutex3();
|
|
57297
|
+
}, FLUSH_DEBOUNCE_MS3);
|
|
57298
|
+
}
|
|
57299
|
+
function captureSessionStart3(cwd) {
|
|
57300
|
+
const chatsDirs = deriveChatsDirCandidates(cwd);
|
|
57301
|
+
_state3 = { cwd, chatsDirs, files: /* @__PURE__ */ new Map() };
|
|
57302
|
+
if (chatsDirs.length === 0) {
|
|
57303
|
+
return;
|
|
57304
|
+
}
|
|
57305
|
+
let count = 0;
|
|
57306
|
+
for (const dir of chatsDirs) {
|
|
57307
|
+
let entries;
|
|
57308
|
+
try {
|
|
57309
|
+
entries = fs4.readdirSync(dir, { withFileTypes: true });
|
|
57310
|
+
} catch {
|
|
57311
|
+
continue;
|
|
57312
|
+
}
|
|
57313
|
+
for (const entry of entries) {
|
|
57314
|
+
if (!entry.isFile() || !entry.name.endsWith(".json")) continue;
|
|
57315
|
+
if (!entry.name.startsWith("session-")) continue;
|
|
57316
|
+
const filePath = path5.join(dir, entry.name);
|
|
57317
|
+
let session = null;
|
|
57318
|
+
try {
|
|
57319
|
+
const raw = fs4.readFileSync(filePath, "utf-8");
|
|
57320
|
+
session = JSON.parse(raw);
|
|
57321
|
+
} catch {
|
|
57322
|
+
session = null;
|
|
57323
|
+
}
|
|
57324
|
+
const sessionId = session && typeof session.sessionId === "string" && session.sessionId || extractShortId(entry.name);
|
|
57325
|
+
const cursorIndex = session && Array.isArray(session.messages) ? session.messages.length : 0;
|
|
57326
|
+
_state3.files.set(filePath, { cursorIndex, sessionId });
|
|
57327
|
+
count++;
|
|
57328
|
+
}
|
|
57329
|
+
}
|
|
57330
|
+
console.error(
|
|
57331
|
+
`\u{1F4DD} [Gemini] capture armed: ${count} session(s) across ${chatsDirs.length} chats dir(s)`
|
|
57332
|
+
);
|
|
57333
|
+
armDirWatchers();
|
|
57334
|
+
}
|
|
57335
|
+
function armDirWatchers() {
|
|
57336
|
+
if (!_state3) return;
|
|
57337
|
+
if (_watchers.length > 0) return;
|
|
57338
|
+
for (const dir of _state3.chatsDirs) {
|
|
57339
|
+
try {
|
|
57340
|
+
const w = fs4.watch(dir, (_evt, filename) => {
|
|
57341
|
+
if (filename && !filename.endsWith(".json")) return;
|
|
57342
|
+
scheduleFlush3();
|
|
57343
|
+
});
|
|
57344
|
+
_watchers.push(w);
|
|
57345
|
+
} catch (err2) {
|
|
57346
|
+
console.error(`\u26A0\uFE0F [Gemini] fs.watch ${dir} failed:`, err2);
|
|
57347
|
+
}
|
|
57348
|
+
}
|
|
57349
|
+
if (_watchers.length > 0) {
|
|
57350
|
+
console.error(`\u{1F4DD} [Gemini] dir watcher(s) armed: ${_watchers.length}`);
|
|
57351
|
+
}
|
|
57352
|
+
}
|
|
57353
|
+
function disarmDirWatchers() {
|
|
57354
|
+
if (_flushDebounceTimer3) {
|
|
57355
|
+
clearTimeout(_flushDebounceTimer3);
|
|
57356
|
+
_flushDebounceTimer3 = null;
|
|
57357
|
+
}
|
|
57358
|
+
for (const w of _watchers) {
|
|
57359
|
+
try {
|
|
57360
|
+
w.close();
|
|
57361
|
+
} catch {
|
|
57362
|
+
}
|
|
57363
|
+
}
|
|
57364
|
+
_watchers.length = 0;
|
|
57365
|
+
}
|
|
57366
|
+
async function captureSessionEnd3() {
|
|
57367
|
+
disarmDirWatchers();
|
|
57368
|
+
const waitStart = Date.now();
|
|
57369
|
+
while (_flushInProgress3 && Date.now() - waitStart < 2e3) {
|
|
57370
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
57371
|
+
}
|
|
57372
|
+
if (!_state3 || _state3.chatsDirs.length === 0) {
|
|
57373
|
+
return { inserted: 0, skipped: 0, error: "session not armed" };
|
|
57374
|
+
}
|
|
57375
|
+
_flushInProgress3 = true;
|
|
57376
|
+
try {
|
|
57377
|
+
const r = await flushAllFiles3();
|
|
57378
|
+
if (r.inserted > 0 || r.skipped > 0 || r.dedup > 0) {
|
|
57379
|
+
console.error(`\u{1F4DD} [Gemini] final flush: inserted=${r.inserted}, dedup=${r.dedup}, skipped=${r.skipped}`);
|
|
57380
|
+
}
|
|
57381
|
+
return { inserted: r.inserted, skipped: r.skipped };
|
|
57382
|
+
} finally {
|
|
57383
|
+
_flushInProgress3 = false;
|
|
57384
|
+
}
|
|
57385
|
+
}
|
|
57386
|
+
|
|
56799
57387
|
// src/version.ts
|
|
56800
|
-
import
|
|
56801
|
-
import
|
|
57388
|
+
import fs5 from "fs";
|
|
57389
|
+
import path6 from "path";
|
|
56802
57390
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
56803
|
-
var __dirname3 =
|
|
56804
|
-
var packageJsonPath =
|
|
56805
|
-
var packageJson = JSON.parse(
|
|
57391
|
+
var __dirname3 = path6.dirname(fileURLToPath2(import.meta.url));
|
|
57392
|
+
var packageJsonPath = path6.resolve(__dirname3, "..", "package.json");
|
|
57393
|
+
var packageJson = JSON.parse(fs5.readFileSync(packageJsonPath, "utf8"));
|
|
56806
57394
|
var PACKAGE_VERSION2 = packageJson.version || "0.0.0";
|
|
56807
57395
|
|
|
56808
57396
|
// src/index.ts
|
|
56809
|
-
import
|
|
57397
|
+
import fs7 from "fs";
|
|
56810
57398
|
var BRIEF_DB_TIMEOUT_MS = 5e3;
|
|
56811
57399
|
var STATIC_INSTRUCTIONS = `Long-term memory MCP server (RESPEC v1).
|
|
56812
57400
|
|
|
@@ -56814,12 +57402,14 @@ Tools:
|
|
|
56814
57402
|
- 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
57403
|
- search_memory : \uACFC\uAC70 \uAE30\uC5B5 \uC870\uD68C/\uAC80\uC0C9 \uD1B5\uD569 (\uC758\uBBF8 + \uD0A4\uC6CC\uB4DC fallback)
|
|
56816
57404
|
- 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 : \
|
|
57405
|
+
- save_message : transcript \uCEA1\uCC98 \uBBF8\uC9C0\uC6D0 platform \uD55C\uC815 fallback (Cursor \uB4F1). Hot Path \uC9C1\uC811 INSERT.
|
|
56818
57406
|
|
|
56819
|
-
Hot Path (\uC790\uB3D9 \uC800\uC7A5)
|
|
57407
|
+
Hot Path (\uC790\uB3D9 \uC800\uC7A5) \uB8F0:
|
|
57408
|
+
- **Claude Code / Codex CLI / Gemini CLI**: server\uAC00 transcript \uD30C\uC77C\uC744 passive read\uD574\uC11C \uC790\uB3D9 \uCEA1\uCC98.
|
|
57409
|
+
\uBCC4\uB3C4 save_message \uD638\uCD9C X. \uD638\uCD9C\uD558\uBA74 \uB3D9\uC77C \uBA54\uC2DC\uC9C0 \uC911\uBCF5 row \uBC1C\uC0DD.
|
|
57410
|
+
- **\uADF8 \uC678 platform** (Cursor, Antigravity \uB4F1 transcript \uBE44\uACF5\uAC1C): \uB9E4 turn save_message \uD638\uCD9C \u2014 fallback.
|
|
56820
57411
|
|
|
56821
57412
|
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
57413
|
- manage_knowledge / save_message \uD638\uCD9C \uC2DC agent_model \uBA85\uC2DC (\uC0DD\uB7B5 \uC2DC 'unknown' \uC800\uC7A5)
|
|
56824
57414
|
- subagent context\uBA74 subagent: true + subagent_model + subagent_role \uD568\uAED8`;
|
|
56825
57415
|
var STATIC_INSTRUCTIONS_BRIEF_UNAVAILABLE = `
|
|
@@ -56869,11 +57459,15 @@ async function shutdown(reason) {
|
|
|
56869
57459
|
stopParentWatchdog();
|
|
56870
57460
|
try {
|
|
56871
57461
|
await Promise.race([
|
|
56872
|
-
|
|
56873
|
-
|
|
57462
|
+
Promise.allSettled([
|
|
57463
|
+
captureSessionEnd(),
|
|
57464
|
+
captureSessionEnd2(),
|
|
57465
|
+
captureSessionEnd3()
|
|
57466
|
+
]),
|
|
57467
|
+
new Promise((resolve2) => setTimeout(resolve2, 3e3))
|
|
56874
57468
|
]);
|
|
56875
57469
|
} catch (err2) {
|
|
56876
|
-
console.error("\u{1F4DD}
|
|
57470
|
+
console.error("\u{1F4DD} capture error (non-blocking):", err2);
|
|
56877
57471
|
}
|
|
56878
57472
|
try {
|
|
56879
57473
|
stopColdPathWorker();
|
|
@@ -56882,7 +57476,7 @@ async function shutdown(reason) {
|
|
|
56882
57476
|
try {
|
|
56883
57477
|
await Promise.race([
|
|
56884
57478
|
drainColdPath(),
|
|
56885
|
-
new Promise((
|
|
57479
|
+
new Promise((resolve2) => setTimeout(resolve2, 2e4))
|
|
56886
57480
|
]);
|
|
56887
57481
|
} catch (err2) {
|
|
56888
57482
|
console.error("\u{1F535} [ColdPath] drain error (non-blocking):", err2);
|
|
@@ -56890,7 +57484,7 @@ async function shutdown(reason) {
|
|
|
56890
57484
|
try {
|
|
56891
57485
|
await Promise.race([
|
|
56892
57486
|
db.close(),
|
|
56893
|
-
new Promise((
|
|
57487
|
+
new Promise((resolve2) => setTimeout(resolve2, 3e3))
|
|
56894
57488
|
]);
|
|
56895
57489
|
} catch (err2) {
|
|
56896
57490
|
console.error("Error during shutdown:", err2);
|
|
@@ -56975,11 +57569,13 @@ async function runMcpServer() {
|
|
|
56975
57569
|
installShutdownHandlers();
|
|
56976
57570
|
startParentWatchdog();
|
|
56977
57571
|
captureSessionStart(process.cwd());
|
|
57572
|
+
captureSessionStart2(process.cwd());
|
|
57573
|
+
captureSessionStart3(process.cwd());
|
|
56978
57574
|
console.error("\u{1F680} Starting Memory MCP Server...");
|
|
56979
57575
|
if (process.env.SSH_ENABLED === "true" && !process.env.SSH_KEY_PATH) {
|
|
56980
57576
|
throw new Error("\u274C SSH_KEY_PATH is required when SSH is enabled");
|
|
56981
57577
|
}
|
|
56982
|
-
if (process.env.SSH_KEY_PATH && !
|
|
57578
|
+
if (process.env.SSH_KEY_PATH && !fs7.existsSync(process.env.SSH_KEY_PATH)) {
|
|
56983
57579
|
console.error(`\u26A0\uFE0F [WARNING] SSH key not found at: ${process.env.SSH_KEY_PATH}`);
|
|
56984
57580
|
}
|
|
56985
57581
|
try {
|