feat: serve plugin http and websockets from one mount instead of ports

This commit is contained in:
LukeGus committed 2026-09-22 16:39:41 -05:00
1 parent c496a093ca
commit 8431570ff7
102 files changed
+2894 -2308

No files matched your search

+15 -4
View File
@@ -1,19 +1,30 @@
import type { PluginContext } from "@termix/plugin-sdk/backend";
import {
TERMINAL_WS_PORT,
handleTerminalUpgrade,
sessionManager,
startTerminalServer,
stopTerminalServer,
} from "../../../../src/backend/hosts/terminal/index.js";
export async function activate(ctx: PluginContext) {
await startTerminalServer();
// Public because the terminal authenticates each socket itself: a share-link
// guest arrives with a share token instead of a session, so the check has to
// happen where that token is understood.
ctx.ws.upgrade(
"/terminal",
(request, socket, head) =>
handleTerminalUpgrade(
request as Parameters<typeof handleTerminalUpgrade>[0],
socket as Parameters<typeof handleTerminalUpgrade>[1],
head as Buffer,
),
{ public: true },
);
// Published so collab and session-sharing can reach live sessions without
// importing a plugin. Revoked automatically when this plugin is disabled.
ctx.registry.provide("terminal.sessions", sessionManager ?? null);
ctx.log.info(`SSH terminal listening on ${TERMINAL_WS_PORT ?? 30002}`);
ctx.log.info("SSH terminal mounted at /plugin-ws/ssh-terminal/terminal");
}
export async function deactivate() {