UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

43 lines • 1.72 kB
import { randomUUID } from "node:crypto"; import { mkdtemp, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { McpPresenterControl } from "./mcp-presenter-control.js"; /** * The Windows presenter control pipe. Its name comes from its own random value, never the host's public * protocol instanceId, so nothing can learn it before the host listens and squat it. */ export function presenterPipePath() { return `\\\\.\\pipe\\senpi-presenter-${randomUUID()}`; } /** * Starts the management endpoint of an enforced host that can introduce a principal: through the inherited fd-4 * bootstrap, an injected account authority, or both (senpi#4249). Otherwise the bootstrap is destroyed and no * control exists. A failed start leaves the host without a presenter. */ export async function startMcpPresenterControl(host, options) { const { bootstrap, account } = options; if (options.enforcement !== true || (!bootstrap && !account)) { bootstrap?.destroy(); return undefined; } let dir; let control; try { if (process.platform !== "win32") dir = await mkdtemp(join(tmpdir(), "senpi-presenter-")); control = new McpPresenterControl(host, dir ? join(dir, "control.sock") : presenterPipePath(), account); await control.listen(); if (bootstrap) control.bootstrap(bootstrap); return { control, ...(dir && { dir }) }; } catch { bootstrap?.destroy(); control?.dispose(); if (dir) await rm(dir, { recursive: true, force: true }); return undefined; } } //# sourceMappingURL=mcp-presenter-control-start.js.map