UNPKG

@sellable/install

Version:

One-command installer for Sellable MCP in Claude Code, Codex, and Hermes

32 lines (28 loc) • 1.15 kB
#!/usr/bin/env node import { lstatSync, readFileSync } from "node:fs"; import { createRuntimeEgressProxy, validateRuntimeEgressProxyConfig, } from "../lib/sellable-agent/runtime-egress-proxy.mjs"; const CONFIG_PATH = "/etc/sellable-agent/egress-proxy.json"; try { if (process.argv.length !== 2) throw new Error("arguments rejected"); const link = lstatSync(CONFIG_PATH); if (link.isSymbolicLink() || !link.isFile() || link.uid !== 0 || (link.mode & 0o777) !== 0o444) { throw new Error("proxy config ownership rejected"); } const parsed = validateRuntimeEgressProxyConfig(JSON.parse(readFileSync(CONFIG_PATH, "utf8"))); if (!parsed.ok || process.getuid?.() !== parsed.config.uid || process.getgid?.() !== parsed.config.gid) { throw new Error("proxy identity rejected"); } const proxy = createRuntimeEgressProxy(parsed.config); await proxy.listen(); const stop = async () => { try { await proxy.close(); } finally { process.exit(0); } }; process.once("SIGTERM", stop); process.once("SIGINT", stop); } catch { process.stderr.write("sellable-agent egress proxy failed closed\n"); process.exitCode = 1; }