@akms/mcp-ssh 0.1.8 → 0.1.9
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/CHANGELOG.md +8 -0
- package/README.md +8 -0
- package/lib/cli.cjs +13 -11
- package/lib/cli.cjs.map +1 -1
- package/lib/cli.js +13 -10
- package/lib/cli.js.map +1 -1
- package/lib/index.cjs +13 -11
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +2 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +13 -10
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -8,7 +8,6 @@ var child_process = require('child_process');
|
|
|
8
8
|
var crypto = require('crypto');
|
|
9
9
|
var stream = require('stream');
|
|
10
10
|
var string_decoder = require('string_decoder');
|
|
11
|
-
var ssh2 = require('ssh2');
|
|
12
11
|
var timers = require('timers');
|
|
13
12
|
var zod = require('zod');
|
|
14
13
|
|
|
@@ -17,7 +16,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
17
16
|
var fs2__default = /*#__PURE__*/_interopDefault(fs2);
|
|
18
17
|
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
19
18
|
var path2__default = /*#__PURE__*/_interopDefault(path2);
|
|
20
|
-
var ssh2__default = /*#__PURE__*/_interopDefault(ssh2);
|
|
21
19
|
|
|
22
20
|
// src/server.ts
|
|
23
21
|
|
|
@@ -34,7 +32,7 @@ var SESSION_SWEEP_INTERVAL_MS = 6e4;
|
|
|
34
32
|
var CWD_MARKER = "__AKMS_SSH_CWD__";
|
|
35
33
|
var MAX_DIRECTORY_ENTRIES = 1e3;
|
|
36
34
|
var SERVER_NAME = "akms-mcp-ssh";
|
|
37
|
-
var SERVER_VERSION = "0.1.
|
|
35
|
+
var SERVER_VERSION = "0.1.9";
|
|
38
36
|
|
|
39
37
|
// src/_defs/command-rules.ts
|
|
40
38
|
var CRITICAL_PATH_PATTERN = new RegExp(
|
|
@@ -1340,7 +1338,6 @@ var GuardRejectionError = class extends Error {
|
|
|
1340
1338
|
};
|
|
1341
1339
|
|
|
1342
1340
|
// src/modules/ssh/ssh-connection.ts
|
|
1343
|
-
var { Client } = ssh2__default.default;
|
|
1344
1341
|
var OUTPUT_HARD_CAP_MULTIPLIER = 4;
|
|
1345
1342
|
var PRIVATE_KEY_CACHE = /* @__PURE__ */ new Map();
|
|
1346
1343
|
var WINDOWS_AGENT_PIPE = "\\\\.\\pipe\\openssh-ssh-agent";
|
|
@@ -1482,7 +1479,7 @@ function openProxyCommand(profile, hop) {
|
|
|
1482
1479
|
}
|
|
1483
1480
|
};
|
|
1484
1481
|
}
|
|
1485
|
-
function openJumpTransport(profile, jump, proxy, onHostKeySeen) {
|
|
1482
|
+
function openJumpTransport(profile, jump, proxy, onHostKeySeen, Client) {
|
|
1486
1483
|
const label = `${profile.name} jump host`;
|
|
1487
1484
|
const endpoint = `${jump.username}@${jump.host}:${jump.port}`;
|
|
1488
1485
|
const _logger = $logger.child({ context: "openJumpTransport", profile: profile.name, jump_host: jump.host });
|
|
@@ -1547,7 +1544,7 @@ function openJumpTransport(profile, jump, proxy, onHostKeySeen) {
|
|
|
1547
1544
|
jumpClient.connect(jumpConfig);
|
|
1548
1545
|
});
|
|
1549
1546
|
}
|
|
1550
|
-
async function openTransport(profile, onJumpHostKeySeen) {
|
|
1547
|
+
async function openTransport(profile, onJumpHostKeySeen, Client) {
|
|
1551
1548
|
let proxy = null;
|
|
1552
1549
|
if (profile.proxyCommand != null) {
|
|
1553
1550
|
proxy = openProxyCommand(profile, profile.jump ?? profile);
|
|
@@ -1556,7 +1553,7 @@ async function openTransport(profile, onJumpHostKeySeen) {
|
|
|
1556
1553
|
return proxy;
|
|
1557
1554
|
}
|
|
1558
1555
|
try {
|
|
1559
|
-
const jumpTransport = await openJumpTransport(profile, profile.jump, proxy, onJumpHostKeySeen);
|
|
1556
|
+
const jumpTransport = await openJumpTransport(profile, profile.jump, proxy, onJumpHostKeySeen, Client);
|
|
1560
1557
|
return jumpTransport;
|
|
1561
1558
|
} catch (ex) {
|
|
1562
1559
|
proxy?.close();
|
|
@@ -1620,6 +1617,11 @@ var SshConnection = class {
|
|
|
1620
1617
|
get wasDropped() {
|
|
1621
1618
|
return this.droppedAfterReady;
|
|
1622
1619
|
}
|
|
1620
|
+
assertNotDisposed() {
|
|
1621
|
+
if (this.disposed == true) {
|
|
1622
|
+
throw new Error(`ssh connection for '${this.profile.name}' has been closed; open a new session`);
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1623
1625
|
/**
|
|
1624
1626
|
* Opens the connection, or joins the in-flight attempt when one is already running.
|
|
1625
1627
|
*
|
|
@@ -1630,9 +1632,7 @@ var SshConnection = class {
|
|
|
1630
1632
|
* unreachable, the handshake times out, or the carrier cannot be opened.
|
|
1631
1633
|
*/
|
|
1632
1634
|
async connect(onProgress) {
|
|
1633
|
-
|
|
1634
|
-
throw new Error(`ssh connection for '${this.profile.name}' has been closed; open a new session`);
|
|
1635
|
-
}
|
|
1635
|
+
this.assertNotDisposed();
|
|
1636
1636
|
if (this.client != null) {
|
|
1637
1637
|
return;
|
|
1638
1638
|
}
|
|
@@ -1651,12 +1651,14 @@ var SshConnection = class {
|
|
|
1651
1651
|
this.observedFingerprint = fingerprint;
|
|
1652
1652
|
});
|
|
1653
1653
|
this.connecting = (async () => {
|
|
1654
|
+
const { default: { Client } } = await import('ssh2');
|
|
1655
|
+
this.assertNotDisposed();
|
|
1654
1656
|
if (this.profile.jump != null || this.profile.proxyCommand != null) {
|
|
1655
1657
|
onProgress?.("transport");
|
|
1656
1658
|
}
|
|
1657
1659
|
const transport = await openTransport(this.profile, (fingerprint) => {
|
|
1658
1660
|
this.observedJumpFingerprint = fingerprint;
|
|
1659
|
-
});
|
|
1661
|
+
}, Client);
|
|
1660
1662
|
if (this.disposed == true) {
|
|
1661
1663
|
transport?.close();
|
|
1662
1664
|
throw new Error(`ssh connection for '${this.profile.name}' was closed during the handshake`);
|