feat: initial webssh tooling

This commit is contained in:
Aarnav Tale 2025-05-30 19:35:47 -04:00
parent f6d8ad25e1
commit 7dfcbef774
No known key found for this signature in database
16 changed files with 792 additions and 83 deletions

View file

@ -0,0 +1,36 @@
import type { Writable } from 'node:stream';
import { decode, encode } from 'cbor2';
interface Command {
op: string;
payload: unknown;
}
interface SSHConnectCommand extends Command {
op: 'ssh_conn';
payload: {
sessionId: string;
username: string;
hostname: string;
port: number;
};
}
type AgentCommand = SSHConnectCommand;
export async function dispatchCommand(
dispatcher: Writable,
command: AgentCommand,
) {
return new Promise<void>((resolve, reject) => {
const encodedCommand = Buffer.concat([encode(command), Buffer.from('\n')]);
dispatcher.write(encodedCommand, (err) => {
console.log('Command dispatched:', command, err);
if (err) {
reject(err);
} else {
resolve();
}
});
});
}