@akms/mcp-ssh 0.1.8 → 0.2.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/CHANGELOG.md +14 -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/cli.js
CHANGED
|
@@ -7,7 +7,6 @@ import { spawnSync, spawn } from 'child_process';
|
|
|
7
7
|
import { randomUUID, createHash } from 'crypto';
|
|
8
8
|
import { Duplex } from 'stream';
|
|
9
9
|
import { StringDecoder } from 'string_decoder';
|
|
10
|
-
import ssh2 from 'ssh2';
|
|
11
10
|
import { setInterval as setInterval$1, clearInterval as clearInterval$1 } from 'timers';
|
|
12
11
|
import { isDeepStrictEqual } from 'util';
|
|
13
12
|
import { parse, TomlError } from 'smol-toml';
|
|
@@ -29,7 +28,7 @@ var CWD_MARKER = "__AKMS_SSH_CWD__";
|
|
|
29
28
|
var MAX_DIRECTORY_ENTRIES = 1e3;
|
|
30
29
|
var SERVER_NAME = "akms-mcp-ssh";
|
|
31
30
|
var PACKAGE_NAME = "@akms/mcp-ssh";
|
|
32
|
-
var SERVER_VERSION = "0.
|
|
31
|
+
var SERVER_VERSION = "0.2.0";
|
|
33
32
|
|
|
34
33
|
// src/_defs/command-rules.ts
|
|
35
34
|
var CRITICAL_PATH_PATTERN = new RegExp(
|
|
@@ -1353,7 +1352,6 @@ var GuardRejectionError = class extends Error {
|
|
|
1353
1352
|
};
|
|
1354
1353
|
|
|
1355
1354
|
// src/modules/ssh/ssh-connection.ts
|
|
1356
|
-
var { Client } = ssh2;
|
|
1357
1355
|
var OUTPUT_HARD_CAP_MULTIPLIER = 4;
|
|
1358
1356
|
var PRIVATE_KEY_CACHE = /* @__PURE__ */ new Map();
|
|
1359
1357
|
var WINDOWS_AGENT_PIPE = "\\\\.\\pipe\\openssh-ssh-agent";
|
|
@@ -1495,7 +1493,7 @@ function openProxyCommand(profile, hop) {
|
|
|
1495
1493
|
}
|
|
1496
1494
|
};
|
|
1497
1495
|
}
|
|
1498
|
-
function openJumpTransport(profile, jump, proxy, onHostKeySeen) {
|
|
1496
|
+
function openJumpTransport(profile, jump, proxy, onHostKeySeen, Client) {
|
|
1499
1497
|
const label = `${profile.name} jump host`;
|
|
1500
1498
|
const endpoint = `${jump.username}@${jump.host}:${jump.port}`;
|
|
1501
1499
|
const _logger = $logger.child({ context: "openJumpTransport", profile: profile.name, jump_host: jump.host });
|
|
@@ -1560,7 +1558,7 @@ function openJumpTransport(profile, jump, proxy, onHostKeySeen) {
|
|
|
1560
1558
|
jumpClient.connect(jumpConfig);
|
|
1561
1559
|
});
|
|
1562
1560
|
}
|
|
1563
|
-
async function openTransport(profile, onJumpHostKeySeen) {
|
|
1561
|
+
async function openTransport(profile, onJumpHostKeySeen, Client) {
|
|
1564
1562
|
let proxy = null;
|
|
1565
1563
|
if (profile.proxyCommand != null) {
|
|
1566
1564
|
proxy = openProxyCommand(profile, profile.jump ?? profile);
|
|
@@ -1569,7 +1567,7 @@ async function openTransport(profile, onJumpHostKeySeen) {
|
|
|
1569
1567
|
return proxy;
|
|
1570
1568
|
}
|
|
1571
1569
|
try {
|
|
1572
|
-
const jumpTransport = await openJumpTransport(profile, profile.jump, proxy, onJumpHostKeySeen);
|
|
1570
|
+
const jumpTransport = await openJumpTransport(profile, profile.jump, proxy, onJumpHostKeySeen, Client);
|
|
1573
1571
|
return jumpTransport;
|
|
1574
1572
|
} catch (ex) {
|
|
1575
1573
|
proxy?.close();
|
|
@@ -1633,6 +1631,11 @@ var SshConnection = class {
|
|
|
1633
1631
|
get wasDropped() {
|
|
1634
1632
|
return this.droppedAfterReady;
|
|
1635
1633
|
}
|
|
1634
|
+
assertNotDisposed() {
|
|
1635
|
+
if (this.disposed == true) {
|
|
1636
|
+
throw new Error(`ssh connection for '${this.profile.name}' has been closed; open a new session`);
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1636
1639
|
/**
|
|
1637
1640
|
* Opens the connection, or joins the in-flight attempt when one is already running.
|
|
1638
1641
|
*
|
|
@@ -1643,9 +1646,7 @@ var SshConnection = class {
|
|
|
1643
1646
|
* unreachable, the handshake times out, or the carrier cannot be opened.
|
|
1644
1647
|
*/
|
|
1645
1648
|
async connect(onProgress) {
|
|
1646
|
-
|
|
1647
|
-
throw new Error(`ssh connection for '${this.profile.name}' has been closed; open a new session`);
|
|
1648
|
-
}
|
|
1649
|
+
this.assertNotDisposed();
|
|
1649
1650
|
if (this.client != null) {
|
|
1650
1651
|
return;
|
|
1651
1652
|
}
|
|
@@ -1664,12 +1665,14 @@ var SshConnection = class {
|
|
|
1664
1665
|
this.observedFingerprint = fingerprint;
|
|
1665
1666
|
});
|
|
1666
1667
|
this.connecting = (async () => {
|
|
1668
|
+
const { default: { Client } } = await import('ssh2');
|
|
1669
|
+
this.assertNotDisposed();
|
|
1667
1670
|
if (this.profile.jump != null || this.profile.proxyCommand != null) {
|
|
1668
1671
|
onProgress?.("transport");
|
|
1669
1672
|
}
|
|
1670
1673
|
const transport = await openTransport(this.profile, (fingerprint) => {
|
|
1671
1674
|
this.observedJumpFingerprint = fingerprint;
|
|
1672
|
-
});
|
|
1675
|
+
}, Client);
|
|
1673
1676
|
if (this.disposed == true) {
|
|
1674
1677
|
transport?.close();
|
|
1675
1678
|
throw new Error(`ssh connection for '${this.profile.name}' was closed during the handshake`);
|