Lines 1-30javascript
2 * Install the always-on service (launchd on macOS, systemd user unit on Linux)
3 * that runs `codex-channel-bgos start`. Run this AFTER a successful `connect`
4 * (so the pairing token is on disk) and from a persistent install (a global
5 * `npm i -g codex-channel-bgos`), not an ephemeral `npx` cache dir.
7import { mkdirSync, writeFileSync } from "node:fs";
8import { homedir } from "node:os";
9import { dirname, join } from "node:path";
10import { fileURLToPath } from "node:url";
11import { spawnSync } from "node:child_process";
12import { pickSupervisor, renderLaunchdPlist, renderSystemdUnit, LAUNCHD_LABEL, SYSTEMD_UNIT, } from "./setup/supervisor.js";
13function codexBgosHome() {
14 return process.env.CODEX_BGOS_HOME ?? join(homedir(), ".codex-bgos");
16/** Absolute path to the installed CLI entry (dist/cli.js). */
17export function cliEntryPath() {
18 const here = fileURLToPath(import.meta.url);
19 return join(dirname(here), "cli.js");
21export function installService() {
22 const kind = pickSupervisor(process.platform);
23 const home = codexBgosHome();
MediumInstall Persistence
Source writes installer persistence such as shell profile or service configuration.
dist/install-service.jsView on unpkg · L10 24 const nodePath = process.execPath;
25 const cliEntry = cliEntryPath();
27 mkdirSync(join(home, "logs"), { recursive: true });
30 /* logs dir is best-effort */