INNER CODE UNIT · JavaScript
createProxyCommandSocket
bvisible/mcp-ssh-manager · src/index.js:467
async function createProxyCommandSocket(proxyCommand, host, port) {
const { spawn } = await import('child_process');
const { Duplex } = await import('stream');
const cmd = proxyCommand.replace(/%h/g, host).replace(/%p/g, port.toString());
return new Promise((resolve, reject) => {
const child = spawn(cmd, {
shell: true,
stdio: ['pipe', 'pipe', 'pipe']
});
// Cast: Node accepts a {readable, writable} pair here, but the bundled
// types only model the stream/iterable overloads.
const socket = Duplex.from(/** @type {any} */ ({
readable: child.stdout,
writable: child.stdin,
allowHalfOpen: false