xc-copilot-api 1.0.5 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"daemon-main.js","names":["jobs: CopilotJob[]","procs: CopilotProcess[]","units: string[]","installArgs: DaemonInstallArgs"],"sources":["../src/daemon.ts","../src/daemon-main.ts"],"sourcesContent":["/* eslint-disable */\nimport { execSync, spawnSync } from \"node:child_process\"\nimport fs from \"node:fs\"\nimport os from \"node:os\"\nimport path from \"node:path\"\n\nimport { defineCommand } from \"citty\"\n\nconst APP_DIR = path.join(os.homedir(), \".local\", \"share\", \"copilot-api\")\nconst LOG_FILE = path.join(APP_DIR, \"copilot-api.log\")\nconst ERR_FILE = path.join(APP_DIR, \"copilot-api.err\")\n\n// ---------------------------------------------------------------------------\n// Naming / paths\n// ---------------------------------------------------------------------------\n\nconst LAUNCHD_LABEL = \"com.xc-copilot-api\"\nconst SYSTEMD_UNIT = \"xc-copilot-api.service\"\nconst WINDOWS_RUN_KEY_NAME = \"XcCopilotApi\"\n\nfunction plistPath(): string {\n return path.join(\n os.homedir(),\n \"Library\",\n \"LaunchAgents\",\n `${LAUNCHD_LABEL}.plist`,\n )\n}\n\nfunction systemdUnitPath(): string {\n return path.join(\n os.homedir(),\n \".config\",\n \"systemd\",\n \"user\",\n SYSTEMD_UNIT,\n )\n}\n\nfunction launcherPath(): string {\n return path.join(APP_DIR, \"launcher.sh\")\n}\n\n// ---------------------------------------------------------------------------\n// Build start command\n// ---------------------------------------------------------------------------\n\nfunction buildStartArgs(args: DaemonInstallArgs): string[] {\n const cmd = [\"xc-copilot-api\", \"start\"]\n if (args.port) cmd.push(\"--port\", args.port)\n if (args.verbose) cmd.push(\"--verbose\")\n if (args.accountType && args.accountType !== \"individual\")\n cmd.push(\"--account-type\", args.accountType)\n if (args.githubToken) cmd.push(\"--github-token\", args.githubToken)\n if (args.proxyEnv) cmd.push(\"--proxy-env\")\n return cmd\n}\n\nfunction buildNpxCommand(args: DaemonInstallArgs): string {\n const startArgs = buildStartArgs(args)\n // npx always fetches latest → auto-update on restart\n return [\"npx\", ...startArgs].map(shellQuote).join(\" \")\n}\n\nfunction buildDirectCommand(args: DaemonInstallArgs): string {\n const startArgs = buildStartArgs(args)\n return startArgs.map(shellQuote).join(\" \")\n}\n\nfunction shellQuote(s: string): string {\n if (/^[\\w./:@=-]+$/.test(s)) return s\n return `'${s.replace(/'/g, \"'\\\\''\")}'`\n}\n\n// ---------------------------------------------------------------------------\n// macOS (launchd)\n// ---------------------------------------------------------------------------\n\nfunction installMacOS(args: DaemonInstallArgs): void {\n const plist = plistPath()\n const launcher = launcherPath()\n\n fs.mkdirSync(APP_DIR, { recursive: true })\n fs.mkdirSync(path.dirname(plist), { recursive: true })\n\n const execCmd = args.npx\n ? buildNpxCommand(args)\n : buildDirectCommand(args)\n\n // Launcher script sources login shell so PATH includes nvm, homebrew, etc.\n fs.writeFileSync(\n launcher,\n [\n \"#!/bin/zsh -l\",\n '[ -f \"$HOME/.zshrc\" ] && source \"$HOME/.zshrc\"',\n `exec ${execCmd}`,\n \"\",\n ].join(\"\\n\"),\n )\n fs.chmodSync(launcher, 0o755)\n\n const plistContent = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n <key>Label</key>\n <string>${LAUNCHD_LABEL}</string>\n <key>ProgramArguments</key>\n <array>\n <string>${launcher}</string>\n </array>\n <key>WorkingDirectory</key>\n <string>${os.homedir()}</string>\n <key>RunAtLoad</key>\n <true/>\n <key>KeepAlive</key>\n <true/>\n <key>StandardOutPath</key>\n <string>${LOG_FILE}</string>\n <key>StandardErrorPath</key>\n <string>${ERR_FILE}</string>\n</dict>\n</plist>\n`\n fs.writeFileSync(plist, plistContent)\n\n console.log(`Installed LaunchAgent '${LAUNCHD_LABEL}'`)\n console.log(` Plist: ${plist}`)\n console.log(` Launcher: ${launcher}`)\n console.log(` Log: ${LOG_FILE}`)\n console.log(` Mode: ${args.npx ? \"npx (auto-update)\" : \"direct\"}`)\n console.log(` Start: xc-copilot-api-daemon restart`)\n}\n\nfunction uninstallMacOS(): void {\n stopMacOS()\n const plist = plistPath()\n if (fs.existsSync(plist)) {\n fs.unlinkSync(plist)\n console.log(`Removed LaunchAgent plist: ${plist}`)\n }\n const launcher = launcherPath()\n if (fs.existsSync(launcher)) {\n fs.unlinkSync(launcher)\n console.log(`Removed launcher: ${launcher}`)\n }\n console.log(`Uninstalled daemon '${LAUNCHD_LABEL}'`)\n}\n\nfunction stopMacOS(): boolean {\n const domain = `gui/${process.getuid?.() ?? 501}`\n const job = `${domain}/${LAUNCHD_LABEL}`\n const result = spawnSync(\"launchctl\", [\"bootout\", job], {\n encoding: \"utf-8\",\n timeout: 15000,\n })\n if (result.status === 0) {\n console.log(`Stopped LaunchAgent '${LAUNCHD_LABEL}'`)\n return true\n }\n const detail = (result.stderr || result.stdout || \"\").toLowerCase()\n if (detail.includes(\"not find\") || detail.includes(\"no such\")) {\n return true // not running\n }\n return false\n}\n\nfunction startMacOS(): boolean {\n const plist = plistPath()\n if (!fs.existsSync(plist)) {\n console.error(`LaunchAgent plist not found: ${plist}`)\n console.error(\"Run 'xc-copilot-api-daemon install' first.\")\n return false\n }\n\n const domain = `gui/${process.getuid?.() ?? 501}`\n const job = `${domain}/${LAUNCHD_LABEL}`\n\n // Bootstrap (load) the daemon\n const bootstrap = spawnSync(\"launchctl\", [\"bootstrap\", domain, plist], {\n encoding: \"utf-8\",\n timeout: 10000,\n })\n if (bootstrap.status !== 0) {\n const detail = (bootstrap.stderr || bootstrap.stdout || \"\").toLowerCase()\n if (!detail.includes(\"already\")) {\n console.error(`launchctl bootstrap failed: ${detail.trim()}`)\n return false\n }\n }\n\n // Kickstart -k kills existing instance and restarts\n const kick = spawnSync(\"launchctl\", [\"kickstart\", \"-k\", job], {\n encoding: \"utf-8\",\n timeout: 15000,\n })\n if (kick.status !== 0) {\n console.error(\n `launchctl kickstart failed: ${(kick.stderr || kick.stdout || \"\").trim()}`,\n )\n return false\n }\n\n console.log(`Started LaunchAgent '${LAUNCHD_LABEL}'`)\n return true\n}\n\nfunction statusMacOS(): void {\n const plist = plistPath()\n if (!fs.existsSync(plist)) {\n console.log(\"Daemon: not installed\")\n return\n }\n\n console.log(`Daemon: installed`)\n console.log(` Plist: ${plist}`)\n\n const launcher = launcherPath()\n if (fs.existsSync(launcher)) {\n const content = fs.readFileSync(launcher, \"utf-8\")\n const execLine = content\n .split(\"\\n\")\n .find((l) => l.startsWith(\"exec \"))\n if (execLine) {\n console.log(` Command: ${execLine.replace(\"exec \", \"\")}`)\n }\n }\n\n // Check if running via launchctl\n const result = spawnSync(\"launchctl\", [\"list\", LAUNCHD_LABEL], {\n encoding: \"utf-8\",\n timeout: 5000,\n })\n if (result.status === 0) {\n const output = result.stdout.trim()\n // Parse PID and status from launchctl list output\n const pidLine = output\n .split(\"\\n\")\n .find((l) => l.includes(\"PID\") || l.match(/^\\s*\"PID\"/))\n const lastExitLine = output\n .split(\"\\n\")\n .find((l) => l.includes(\"LastExitStatus\"))\n\n // launchctl list <label> outputs key-value pairs\n const pidMatch = output.match(/\"PID\"\\s*=\\s*(\\d+)/)\n const exitMatch = output.match(/\"LastExitStatus\"\\s*=\\s*(\\d+)/)\n\n if (pidMatch) {\n console.log(` Status: running (PID ${pidMatch[1]})`)\n } else {\n console.log(` Status: not running`)\n }\n if (exitMatch) {\n console.log(` Last exit: ${exitMatch[1]}`)\n }\n if (pidLine) void pidLine // suppress unused\n if (lastExitLine) void lastExitLine // suppress unused\n } else {\n console.log(\" Status: not loaded\")\n }\n\n // Show recent log\n if (fs.existsSync(LOG_FILE)) {\n const stat = fs.statSync(LOG_FILE)\n console.log(\n ` Log: ${LOG_FILE} (${(stat.size / 1024).toFixed(1)} KB)`,\n )\n }\n}\n\n// ---------------------------------------------------------------------------\n// Linux (systemd)\n// ---------------------------------------------------------------------------\n\nfunction installLinux(args: DaemonInstallArgs): void {\n const unitPath = systemdUnitPath()\n const launcher = launcherPath()\n\n fs.mkdirSync(APP_DIR, { recursive: true })\n fs.mkdirSync(path.dirname(unitPath), { recursive: true })\n\n const execCmd = args.npx\n ? buildNpxCommand(args)\n : buildDirectCommand(args)\n\n // Launcher script sources login shell\n fs.writeFileSync(\n launcher,\n [\n \"#!/bin/bash -l\",\n '[ -f \"$HOME/.bashrc\" ] && source \"$HOME/.bashrc\"',\n `exec ${execCmd}`,\n \"\",\n ].join(\"\\n\"),\n )\n fs.chmodSync(launcher, 0o755)\n\n const unitContent = `[Unit]\nDescription=xc-copilot-api - GitHub Copilot OpenAI Compatible API\nAfter=network.target\n\n[Service]\nType=simple\nExecStart=${launcher}\nRestart=on-failure\nRestartSec=10\nStandardOutput=append:${LOG_FILE}\nStandardError=append:${ERR_FILE}\n\n[Install]\nWantedBy=default.target\n`\n fs.writeFileSync(unitPath, unitContent)\n\n spawnSync(\"systemctl\", [\"--user\", \"daemon-reload\"], { encoding: \"utf-8\" })\n spawnSync(\"systemctl\", [\"--user\", \"enable\", SYSTEMD_UNIT], {\n encoding: \"utf-8\",\n })\n\n console.log(`Installed systemd unit '${SYSTEMD_UNIT}'`)\n console.log(` Unit: ${unitPath}`)\n console.log(` Launcher: ${launcher}`)\n console.log(` Log: ${LOG_FILE}`)\n console.log(` Mode: ${args.npx ? \"npx (auto-update)\" : \"direct\"}`)\n console.log(` Start: xc-copilot-api-daemon restart`)\n}\n\nfunction uninstallLinux(): void {\n spawnSync(\"systemctl\", [\"--user\", \"stop\", SYSTEMD_UNIT], {\n encoding: \"utf-8\",\n })\n spawnSync(\"systemctl\", [\"--user\", \"disable\", SYSTEMD_UNIT], {\n encoding: \"utf-8\",\n })\n const unitPath = systemdUnitPath()\n if (fs.existsSync(unitPath)) {\n fs.unlinkSync(unitPath)\n spawnSync(\"systemctl\", [\"--user\", \"daemon-reload\"], {\n encoding: \"utf-8\",\n })\n }\n const launcher = launcherPath()\n if (fs.existsSync(launcher)) {\n fs.unlinkSync(launcher)\n }\n console.log(`Uninstalled systemd unit '${SYSTEMD_UNIT}'`)\n}\n\nfunction startLinux(): boolean {\n const result = spawnSync(\n \"systemctl\",\n [\"--user\", \"start\", SYSTEMD_UNIT],\n { encoding: \"utf-8\", timeout: 10000 },\n )\n if (result.status !== 0) {\n console.error(\n `systemd start failed: ${(result.stderr || result.stdout || \"\").trim()}`,\n )\n return false\n }\n console.log(`Started systemd unit '${SYSTEMD_UNIT}'`)\n return true\n}\n\nfunction stopLinux(): boolean {\n const result = spawnSync(\n \"systemctl\",\n [\"--user\", \"stop\", SYSTEMD_UNIT],\n { encoding: \"utf-8\", timeout: 15000 },\n )\n if (result.status !== 0) {\n const detail = (result.stderr || result.stdout || \"\").trim()\n if (!detail.includes(\"not loaded\")) {\n console.error(`systemd stop failed: ${detail}`)\n return false\n }\n }\n console.log(`Stopped systemd unit '${SYSTEMD_UNIT}'`)\n return true\n}\n\nfunction statusLinux(): void {\n const unitPath = systemdUnitPath()\n if (!fs.existsSync(unitPath)) {\n console.log(\"Daemon: not installed\")\n return\n }\n\n console.log(\"Daemon: installed\")\n console.log(` Unit: ${unitPath}`)\n\n const launcher = launcherPath()\n if (fs.existsSync(launcher)) {\n const content = fs.readFileSync(launcher, \"utf-8\")\n const execLine = content\n .split(\"\\n\")\n .find((l) => l.startsWith(\"exec \"))\n if (execLine) {\n console.log(` Command: ${execLine.replace(\"exec \", \"\")}`)\n }\n }\n\n const result = spawnSync(\n \"systemctl\",\n [\"--user\", \"status\", SYSTEMD_UNIT, \"--no-pager\"],\n { encoding: \"utf-8\", timeout: 5000 },\n )\n // systemctl status returns non-zero if daemon is not running, that's ok\n console.log(result.stdout.trim())\n}\n\n// ---------------------------------------------------------------------------\n// Windows (Registry Run Key + VBS launcher)\n// ---------------------------------------------------------------------------\n\nfunction windowsAppDir(): string {\n const localAppData = process.env.LOCALAPPDATA || path.join(os.homedir(), \"AppData\", \"Local\")\n return path.join(localAppData, \"copilot-api\")\n}\n\nfunction windowsLauncherVbsPath(): string {\n return path.join(windowsAppDir(), \"launcher.vbs\")\n}\n\nfunction windowsLogFile(): string {\n return path.join(windowsAppDir(), \"copilot-api.log\")\n}\n\nfunction buildWindowsCommand(args: DaemonInstallArgs): string {\n const startArgs = buildStartArgs(args)\n const parts = args.npx ? [\"npx\", ...startArgs] : startArgs\n return parts.map((s) => (s.includes(\" \") ? `\"${s}\"` : s)).join(\" \")\n}\n\nfunction installWindows(args: DaemonInstallArgs): void {\n const appDir = windowsAppDir()\n const logFile = windowsLogFile()\n const errFile = path.join(appDir, \"copilot-api.err\")\n const launcherVbs = windowsLauncherVbsPath()\n\n fs.mkdirSync(appDir, { recursive: true })\n\n const execCmd = buildWindowsCommand(args)\n\n // VBS launcher runs command hidden (no console window), with log redirection\n const cmdStr = `cmd /c cd /d \"\"${os.homedir()}\"\" ^& ${execCmd} >> \"\"${logFile}\"\" 2>> \"\"${errFile}\"\"`\n const vbsContent = [\n 'Set WshShell = CreateObject(\"WScript.Shell\")',\n `WshShell.Run \"${cmdStr}\", 0, False`,\n \"\",\n ].join(\"\\r\\n\")\n fs.writeFileSync(launcherVbs, vbsContent)\n\n // Register in current-user Run key (auto-start on login, no admin needed)\n const result = spawnSync(\"reg.exe\", [\n \"add\",\n \"HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\",\n \"/v\", WINDOWS_RUN_KEY_NAME,\n \"/t\", \"REG_SZ\",\n \"/d\", `wscript.exe \"${launcherVbs}\"`,\n \"/f\",\n ], { encoding: \"utf-8\", timeout: 10000 })\n\n if (result.status !== 0) {\n console.error(`Failed to register Run key: ${(result.stderr || \"\").trim()}`)\n process.exit(1)\n }\n\n console.log(`Installed Windows Run key '${WINDOWS_RUN_KEY_NAME}'`)\n console.log(` Launcher: ${launcherVbs}`)\n console.log(` Log: ${logFile}`)\n console.log(` Mode: ${args.npx ? \"npx (auto-update)\" : \"direct\"}`)\n console.log(` Start: xc-copilot-api-daemon restart`)\n}\n\nfunction uninstallWindows(): void {\n stopWindows()\n\n // Remove Run key\n spawnSync(\"reg.exe\", [\n \"delete\",\n \"HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\",\n \"/v\", WINDOWS_RUN_KEY_NAME,\n \"/f\",\n ], { encoding: \"utf-8\", timeout: 10000 })\n\n const launcherVbs = windowsLauncherVbsPath()\n if (fs.existsSync(launcherVbs)) fs.unlinkSync(launcherVbs)\n // Clean up legacy CMD launcher if present\n const legacyCmdPath = path.join(windowsAppDir(), \"launcher.cmd\")\n if (fs.existsSync(legacyCmdPath)) fs.unlinkSync(legacyCmdPath)\n console.log(`Uninstalled Windows Run key '${WINDOWS_RUN_KEY_NAME}'`)\n}\n\nfunction startWindows(): boolean {\n const launcherVbs = windowsLauncherVbsPath()\n if (!fs.existsSync(launcherVbs)) {\n console.error(`Launcher not found: ${launcherVbs}`)\n console.error(\"Run 'xc-copilot-api-daemon install' first.\")\n return false\n }\n\n spawnSync(\"wscript.exe\", [launcherVbs], {\n encoding: \"utf-8\",\n timeout: 10000,\n detached: true,\n stdio: \"ignore\",\n })\n\n console.log(\"Started xc-copilot-api (background)\")\n return true\n}\n\nfunction findCopilotPids(filter: string): string[] {\n // Use WQL filter; exclude the PowerShell process itself ($PID) to avoid self-matching\n const wqlFilter = filter.replace(/\\*/g, \"%\")\n const result = spawnSync(\"powershell\", [\n \"-NoProfile\", \"-Command\",\n `Get-CimInstance Win32_Process -Filter \"CommandLine LIKE '${wqlFilter}' AND ProcessId != $PID\" | Select-Object -ExpandProperty ProcessId`,\n ], { encoding: \"utf-8\", timeout: 10000 })\n\n if (result.status !== 0) return []\n return result.stdout.split(\"\\n\").map((l) => l.trim()).filter(Boolean)\n}\n\nfunction stopWindows(): boolean {\n // Find copilot-api processes excluding daemon management and self\n const result = spawnSync(\"powershell\", [\n \"-NoProfile\", \"-Command\",\n `Get-CimInstance Win32_Process -Filter \"CommandLine LIKE '%copilot-api%' AND NOT (CommandLine LIKE '%daemon%') AND ProcessId != $PID\" | Select-Object -ExpandProperty ProcessId`,\n ], { encoding: \"utf-8\", timeout: 10000 })\n\n const pids = (result.status === 0 ? result.stdout : \"\")\n .split(\"\\n\").map((l) => l.trim()).filter(Boolean)\n\n for (const pid of pids) {\n spawnSync(\"taskkill\", [\"/PID\", pid, \"/F\"], { encoding: \"utf-8\", timeout: 5000 })\n }\n\n if (pids.length > 0) {\n console.log(`Stopped ${pids.length} process(es)`)\n return true\n }\n\n console.log(\"No copilot-api processes found.\")\n return true\n}\n\nfunction statusWindows(): void {\n // Check Run key\n const regResult = spawnSync(\"reg.exe\", [\n \"query\",\n \"HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\",\n \"/v\", WINDOWS_RUN_KEY_NAME,\n ], { encoding: \"utf-8\", timeout: 5000 })\n\n if (regResult.status !== 0) {\n console.log(\"Daemon: not installed\")\n return\n }\n\n console.log(\"Daemon: installed\")\n\n // Show command from VBS launcher\n const launcherVbs = windowsLauncherVbsPath()\n if (fs.existsSync(launcherVbs)) {\n const content = fs.readFileSync(launcherVbs, \"utf-8\")\n // Extract the command between cd /d ... ^& and >> ...\n const match = content.match(/\\^&\\s*(.+?)\\s*>>/)\n if (match) {\n console.log(` Command: ${match[1].trim()}`)\n }\n }\n\n // Check if running\n const pids = findCopilotPids(\"*copilot-api*start*\")\n\n console.log(pids.length > 0\n ? ` Status: running (PID ${pids.join(\", \")})`\n : \" Status: not running\")\n\n const logFile = windowsLogFile()\n if (fs.existsSync(logFile)) {\n const stat = fs.statSync(logFile)\n console.log(` Log: ${logFile} (${(stat.size / 1024).toFixed(1)} KB)`)\n }\n}\n\n// ---------------------------------------------------------------------------\n// --all: find all copilot-api related jobs / processes\n// ---------------------------------------------------------------------------\n\ninterface CopilotJob {\n label: string\n pid: string | null\n plistPath: string | null\n}\n\nfunction findAllCopilotLaunchdJobs(): CopilotJob[] {\n const result = spawnSync(\"launchctl\", [\"list\"], {\n encoding: \"utf-8\",\n timeout: 5000,\n })\n if (result.status !== 0) return []\n\n const jobs: CopilotJob[] = []\n for (const line of result.stdout.split(\"\\n\")) {\n if (!line.toLowerCase().includes(\"copilot\")) continue\n const parts = line.trim().split(/\\s+/)\n if (parts.length < 3) continue\n const pid = parts[0] === \"-\" ? null : parts[0]\n const label = parts[2]\n const plist = path.join(\n os.homedir(),\n \"Library\",\n \"LaunchAgents\",\n `${label}.plist`,\n )\n jobs.push({\n label,\n pid,\n plistPath: fs.existsSync(plist) ? plist : null,\n })\n }\n return jobs\n}\n\ninterface CopilotProcess {\n pid: string\n command: string\n}\n\nfunction findAllCopilotProcesses(): CopilotProcess[] {\n try {\n const output = execSync(\n \"ps aux | grep -i copilot-api | grep -v grep\",\n { encoding: \"utf-8\", timeout: 5000 },\n )\n const procs: CopilotProcess[] = []\n for (const line of output.trim().split(\"\\n\")) {\n if (!line) continue\n const parts = line.trim().split(/\\s+/)\n if (parts.length < 11) continue\n const pid = parts[1]\n const command = parts.slice(10).join(\" \")\n procs.push({ pid, command })\n }\n return procs\n } catch {\n return []\n }\n}\n\nfunction findAllCopilotSystemdUnits(): string[] {\n const result = spawnSync(\n \"systemctl\",\n [\"--user\", \"list-units\", \"--all\", \"--no-pager\", \"--plain\"],\n { encoding: \"utf-8\", timeout: 5000 },\n )\n if (result.status !== 0) return []\n const units: string[] = []\n for (const line of result.stdout.split(\"\\n\")) {\n if (line.toLowerCase().includes(\"copilot\")) {\n const unit = line.trim().split(/\\s+/)[0]\n if (unit) units.push(unit)\n }\n }\n return units\n}\n\nfunction statusAll(): void {\n if (isMacOS()) {\n const jobs = findAllCopilotLaunchdJobs()\n if (jobs.length > 0) {\n console.log(\"=== LaunchAgent Jobs ===\")\n for (const job of jobs) {\n console.log(`\\n Label: ${job.label}`)\n if (job.plistPath) console.log(` Plist: ${job.plistPath}`)\n else console.log(` Plist: (not found)`)\n console.log(` PID: ${job.pid ?? \"not running\"}`)\n }\n } else {\n console.log(\"No copilot-api LaunchAgent jobs found.\")\n }\n\n const procs = findAllCopilotProcesses()\n if (procs.length > 0) {\n console.log(\"\\n=== Processes ===\")\n for (const proc of procs) {\n console.log(` PID ${proc.pid}: ${proc.command}`)\n }\n }\n } else {\n const units = findAllCopilotSystemdUnits()\n if (units.length > 0) {\n console.log(\"=== Systemd Units ===\")\n for (const unit of units) {\n const r = spawnSync(\n \"systemctl\",\n [\"--user\", \"status\", unit, \"--no-pager\"],\n { encoding: \"utf-8\", timeout: 5000 },\n )\n console.log(`\\n--- ${unit} ---`)\n console.log(r.stdout.trim())\n }\n } else {\n console.log(\"No copilot-api systemd units found.\")\n }\n\n const procs = findAllCopilotProcesses()\n if (procs.length > 0) {\n console.log(\"\\n=== Processes ===\")\n for (const proc of procs) {\n console.log(` PID ${proc.pid}: ${proc.command}`)\n }\n }\n }\n}\n\nfunction stopAll(): void {\n let stopped = 0\n\n if (isMacOS()) {\n const jobs = findAllCopilotLaunchdJobs()\n const domain = `gui/${process.getuid?.() ?? 501}`\n for (const job of jobs) {\n const jobTarget = `${domain}/${job.label}`\n console.log(`Stopping LaunchAgent '${job.label}'...`)\n spawnSync(\"launchctl\", [\"bootout\", jobTarget], {\n encoding: \"utf-8\",\n timeout: 15000,\n })\n stopped++\n }\n } else {\n const units = findAllCopilotSystemdUnits()\n for (const unit of units) {\n console.log(`Stopping systemd unit '${unit}'...`)\n spawnSync(\"systemctl\", [\"--user\", \"stop\", unit], {\n encoding: \"utf-8\",\n timeout: 15000,\n })\n stopped++\n }\n }\n\n // Kill remaining processes\n const procs = findAllCopilotProcesses()\n for (const proc of procs) {\n console.log(`Killing PID ${proc.pid}: ${proc.command}`)\n try {\n process.kill(Number.parseInt(proc.pid, 10), \"SIGTERM\")\n stopped++\n } catch {\n // already dead\n }\n }\n\n if (stopped === 0) {\n console.log(\"No copilot-api processes found.\")\n } else {\n console.log(`\\nStopped/killed ${stopped} item(s).`)\n }\n}\n\n// ---------------------------------------------------------------------------\n// Platform dispatch\n// ---------------------------------------------------------------------------\n\ninterface DaemonInstallArgs {\n npx: boolean\n port?: string\n verbose: boolean\n accountType?: string\n githubToken?: string\n proxyEnv: boolean\n}\n\nfunction isMacOS(): boolean {\n return process.platform === \"darwin\"\n}\n\nfunction isLinux(): boolean {\n return process.platform === \"linux\"\n}\n\nfunction isWindows(): boolean {\n return process.platform === \"win32\"\n}\n\nfunction assertSupported(): void {\n if (!isMacOS() && !isLinux() && !isWindows()) {\n console.error(\"Daemon management is only supported on macOS, Linux, and Windows.\")\n process.exit(1)\n }\n}\n\n// ---------------------------------------------------------------------------\n// CLI subcommands\n// ---------------------------------------------------------------------------\n\nconst installCmd = defineCommand({\n meta: {\n name: \"install\",\n description:\n \"Install xc-copilot-api daemon (launchd on macOS, systemd on Linux, Run key on Windows)\",\n },\n args: {\n npx: {\n type: \"boolean\",\n default: true,\n description:\n \"Use npx to run (auto-updates on restart). Set --no-npx to use direct binary.\",\n },\n port: {\n alias: \"p\",\n type: \"string\",\n default: \"4141\",\n description: \"Port for the API server\",\n },\n verbose: {\n alias: \"v\",\n type: \"boolean\",\n default: false,\n description: \"Enable verbose logging\",\n },\n \"account-type\": {\n alias: \"a\",\n type: \"string\",\n default: \"individual\",\n description: \"Account type (individual, business, enterprise)\",\n },\n \"github-token\": {\n alias: \"g\",\n type: \"string\",\n description: \"GitHub token to use\",\n },\n \"proxy-env\": {\n type: \"boolean\",\n default: false,\n description: \"Initialize proxy from environment variables\",\n },\n },\n run({ args }) {\n assertSupported()\n const installArgs: DaemonInstallArgs = {\n npx: args.npx,\n port: args.port,\n verbose: args.verbose,\n accountType: args[\"account-type\"],\n githubToken: args[\"github-token\"],\n proxyEnv: args[\"proxy-env\"],\n }\n if (isMacOS()) {\n installMacOS(installArgs)\n } else if (isWindows()) {\n installWindows(installArgs)\n } else {\n installLinux(installArgs)\n }\n },\n})\n\nconst uninstallCmd = defineCommand({\n meta: {\n name: \"uninstall\",\n description: \"Uninstall the daemon\",\n },\n run() {\n assertSupported()\n if (isMacOS()) {\n uninstallMacOS()\n } else if (isWindows()) {\n uninstallWindows()\n } else {\n uninstallLinux()\n }\n },\n})\n\nconst statusCmd = defineCommand({\n meta: {\n name: \"status\",\n description: \"Show daemon status (use --all to show all copilot-api instances)\",\n },\n args: {\n all: {\n type: \"boolean\",\n default: false,\n description:\n \"Show all copilot-api related daemons and processes\",\n },\n },\n run({ args }) {\n assertSupported()\n if (args.all) {\n statusAll()\n } else if (isMacOS()) {\n statusMacOS()\n } else if (isWindows()) {\n statusWindows()\n } else {\n statusLinux()\n }\n },\n})\n\nconst restartCmd = defineCommand({\n meta: {\n name: \"restart\",\n description:\n \"Restart the daemon (npx mode fetches latest version automatically)\",\n },\n run() {\n assertSupported()\n if (isMacOS()) {\n if (!startMacOS()) process.exit(1)\n } else if (isWindows()) {\n stopWindows()\n if (!startWindows()) process.exit(1)\n } else {\n stopLinux()\n if (!startLinux()) process.exit(1)\n }\n },\n})\n\nconst stopCmd = defineCommand({\n meta: {\n name: \"stop\",\n description: \"Stop the daemon (use --all to kill all copilot-api instances)\",\n },\n args: {\n all: {\n type: \"boolean\",\n default: false,\n description:\n \"Stop all copilot-api related daemons and kill all processes\",\n },\n },\n run({ args }) {\n assertSupported()\n if (args.all) {\n stopAll()\n } else if (isMacOS()) {\n if (!stopMacOS()) process.exit(1)\n } else if (isWindows()) {\n if (!stopWindows()) process.exit(1)\n } else {\n if (!stopLinux()) process.exit(1)\n }\n },\n})\n\nconst logsCmd = defineCommand({\n meta: {\n name: \"logs\",\n description: \"Show recent daemon logs\",\n },\n args: {\n follow: {\n alias: \"f\",\n type: \"boolean\",\n default: false,\n description: \"Follow log output (like tail -f)\",\n },\n lines: {\n alias: \"n\",\n type: \"string\",\n default: \"50\",\n description: \"Number of lines to show\",\n },\n },\n run({ args }) {\n assertSupported()\n const logPath = isWindows() ? windowsLogFile() : LOG_FILE\n if (!fs.existsSync(logPath)) {\n console.log(\"No log file found.\")\n return\n }\n\n if (isWindows()) {\n // Windows: use powershell Get-Content\n if (args.follow) {\n const { status } = spawnSync(\"powershell\", [\"-Command\", `Get-Content -Path '${logPath}' -Wait -Tail ${args.lines}`], { stdio: \"inherit\" })\n process.exit(status ?? 0)\n } else {\n const { status } = spawnSync(\"powershell\", [\"-Command\", `Get-Content -Path '${logPath}' -Tail ${args.lines}`], { stdio: \"inherit\" })\n process.exit(status ?? 0)\n }\n } else {\n if (args.follow) {\n const { status } = spawnSync(\"tail\", [\"-f\", logPath], { stdio: \"inherit\" })\n process.exit(status ?? 0)\n } else {\n const { status } = spawnSync(\"tail\", [\"-n\", args.lines, logPath], { stdio: \"inherit\" })\n process.exit(status ?? 0)\n }\n }\n },\n})\n\n// ---------------------------------------------------------------------------\n// Main daemon command\n// ---------------------------------------------------------------------------\n\nexport const daemon = defineCommand({\n meta: {\n name: \"xc-copilot-api-daemon\",\n description:\n \"Manage xc-copilot-api daemon (install, status, restart, stop, uninstall, logs)\",\n },\n subCommands: {\n install: installCmd,\n uninstall: uninstallCmd,\n status: statusCmd,\n restart: restartCmd,\n stop: stopCmd,\n logs: logsCmd,\n },\n})\n","#!/usr/bin/env node\n\nimport { runMain } from \"citty\"\n\nimport { daemon } from \"./daemon\"\n\nawait runMain(daemon)\n"],"mappings":";;;;;;;;AAQA,MAAM,UAAU,KAAK,KAAK,GAAG,SAAS,EAAE,UAAU,SAAS,cAAc;AACzE,MAAM,WAAW,KAAK,KAAK,SAAS,kBAAkB;AACtD,MAAM,WAAW,KAAK,KAAK,SAAS,kBAAkB;AAMtD,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,uBAAuB;AAE7B,SAAS,YAAoB;AAC3B,QAAO,KAAK,KACV,GAAG,SAAS,EACZ,WACA,gBACA,GAAG,cAAc,QAClB;;AAGH,SAAS,kBAA0B;AACjC,QAAO,KAAK,KACV,GAAG,SAAS,EACZ,WACA,WACA,QACA,aACD;;A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WAAQ,KAAK,UAAU,EAAE;SACpB;GACL,MAAM,EAAE,WAAW,UAAU,cAAc,CAAC,YAAY,sBAAsB,QAAQ,UAAU,KAAK,QAAQ,EAAE,EAAE,OAAO,WAAW,CAAC;AACpI,WAAQ,KAAK,UAAU,EAAE;;WAGvB,KAAK,QAAQ;GACf,MAAM,EAAE,WAAW,UAAU,QAAQ,CAAC,MAAM,QAAQ,EAAE,EAAE,OAAO,WAAW,CAAC;AAC3E,WAAQ,KAAK,UAAU,EAAE;SACpB;GACL,MAAM,EAAE,WAAW,UAAU,QAAQ;IAAC;IAAM,KAAK;IAAO;IAAQ,EAAE,EAAE,OAAO,WAAW,CAAC;AACvF,WAAQ,KAAK,UAAU,EAAE;;;CAIhC,CAAC;AAMF,MAAa,SAAS,cAAc;CAClC,MAAM;EACJ,MAAM;EACN,aACE;EACH;CACD,aAAa;EACX,SAAS;EACT,WAAW;EACX,QAAQ;EACR,SAAS;EACT,MAAM;EACN,MAAM;EACP;CACF,CAAC;;;;ACt/BF,MAAM,QAAQ,OAAO"}
package/dist/main.js CHANGED
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from "citty";
3
- import consola from "consola";
4
- import fs from "node:fs/promises";
3
+ import { execSync } from "node:child_process";
5
4
  import os from "node:os";
6
5
  import path from "node:path";
6
+ import consola from "consola";
7
+ import fs from "node:fs/promises";
7
8
  import { randomUUID } from "node:crypto";
8
9
  import clipboard from "clipboardy";
9
10
  import { serve } from "srvx";
10
11
  import invariant from "tiny-invariant";
11
12
  import { getProxyForUrl } from "proxy-from-env";
12
13
  import { Agent, ProxyAgent, setGlobalDispatcher } from "undici";
13
- import { execSync } from "node:child_process";
14
14
  import process$1 from "node:process";
15
15
  import { Hono } from "hono";
16
16
  import { cors } from "hono/cors";
@@ -20,7 +20,7 @@ import { html } from "hono/html";
20
20
 
21
21
  //#region package.json
22
22
  var name = "xc-copilot-api";
23
- var version = "1.0.5";
23
+ var version = "1.1.0";
24
24
  var description = "Turn GitHub Copilot into OpenAI/Anthropic API compatible server. Usable with Claude Code and Codex";
25
25
  var keywords = [
26
26
  "proxy",
@@ -35,7 +35,10 @@ var repository = {
35
35
  };
36
36
  var author = "Xiaochen <wxc9312@gmail.com>";
37
37
  var type = "module";
38
- var bin = { "xc-copilot-api": "./dist/main.js" };
38
+ var bin = {
39
+ "xc-copilot-api": "./dist/main.js",
40
+ "xc-copilot-api-daemon": "./dist/daemon-main.js"
41
+ };
39
42
  var files = ["dist"];
40
43
  var scripts = {
41
44
  "build": "tsdown",
@@ -49,8 +52,8 @@ var scripts = {
49
52
  "start": "NODE_ENV=production bun run ./src/main.ts start",
50
53
  "typecheck": "tsc"
51
54
  };
52
- var simple_git_hooks = { "pre-commit": "bunx lint-staged" };
53
- var lint_staged = { "*": "bun run lint --fix" };
55
+ var simple_git_hooks = {};
56
+ var lint_staged = {};
54
57
  var dependencies = {
55
58
  "citty": "^0.1.6",
56
59
  "clipboardy": "^5.0.0",
@@ -998,7 +1001,7 @@ embeddingRoutes.post("/", async (c) => {
998
1001
  //#region src/routes/index/route.ts
999
1002
  const indexRoute = new Hono();
1000
1003
  indexRoute.get("/", (c) => {
1001
- const version$1 = process.env.npm_package_version ?? "unknown";
1004
+ const version$1 = process.env.npm_package_version ?? package_default.version;
1002
1005
  const login = state.githubLogin ?? "unknown";
1003
1006
  const accountType = state.accountType;
1004
1007
  const format = c.req.query("format");
@@ -1026,9 +1029,14 @@ indexRoute.get("/", (c) => {
1026
1029
  --yellow: #fabd2f;
1027
1030
  --orange: #fe8019;
1028
1031
  }
1029
- * { margin: 0; padding: 0; box-sizing: border-box; }
1032
+ * {
1033
+ margin: 0;
1034
+ padding: 0;
1035
+ box-sizing: border-box;
1036
+ }
1030
1037
  body {
1031
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
1038
+ font-family:
1039
+ -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
1032
1040
  background: var(--bg-darkest);
1033
1041
  color: var(--fg);
1034
1042
  min-height: 100vh;
@@ -1036,7 +1044,10 @@ indexRoute.get("/", (c) => {
1036
1044
  justify-content: center;
1037
1045
  padding: 48px 16px;
1038
1046
  }
1039
- .container { max-width: 560px; width: 100%; }
1047
+ .container {
1048
+ max-width: 560px;
1049
+ width: 100%;
1050
+ }
1040
1051
  h1 {
1041
1052
  font-size: 1.5rem;
1042
1053
  color: var(--fg0);
@@ -1078,13 +1089,20 @@ indexRoute.get("/", (c) => {
1078
1089
  padding: 6px 0;
1079
1090
  font-size: 0.875rem;
1080
1091
  }
1081
- .info-label { color: var(--fg2); }
1082
- .info-value { color: var(--fg0); font-weight: 500; }
1092
+ .info-label {
1093
+ color: var(--fg2);
1094
+ }
1095
+ .info-value {
1096
+ color: var(--fg0);
1097
+ font-weight: 500;
1098
+ }
1083
1099
  .info-value a {
1084
1100
  color: var(--blue);
1085
1101
  text-decoration: none;
1086
1102
  }
1087
- .info-value a:hover { text-decoration: underline; }
1103
+ .info-value a:hover {
1104
+ text-decoration: underline;
1105
+ }
1088
1106
  .links {
1089
1107
  display: flex;
1090
1108
  flex-direction: column;
@@ -1102,7 +1120,9 @@ indexRoute.get("/", (c) => {
1102
1120
  font-size: 0.875rem;
1103
1121
  transition: background 0.15s;
1104
1122
  }
1105
- .link-item:hover { background: var(--bg2); }
1123
+ .link-item:hover {
1124
+ background: var(--bg2);
1125
+ }
1106
1126
  .link-icon {
1107
1127
  font-size: 1rem;
1108
1128
  width: 20px;
@@ -1118,14 +1138,23 @@ indexRoute.get("/", (c) => {
1118
1138
  <body>
1119
1139
  <div class="container">
1120
1140
  <h1>Copilot API <span class="badge">running</span></h1>
1121
- <p class="subtitle">v${version$1} · <a href="/?format=text" style="color: var(--gray); text-decoration: none; border-bottom: 1px dashed var(--gray);">plain text</a></p>
1141
+ <p class="subtitle">
1142
+ v${version$1} ·
1143
+ <a
1144
+ href="/?format=text"
1145
+ style="color: var(--gray); text-decoration: none; border-bottom: 1px dashed var(--gray);"
1146
+ >plain text</a
1147
+ >
1148
+ </p>
1122
1149
 
1123
1150
  <div class="section">
1124
1151
  <div class="section-title">Account</div>
1125
1152
  <div class="info-row">
1126
1153
  <span class="info-label">GitHub User</span>
1127
1154
  <span class="info-value">
1128
- <a href="https://github.com/${login}" target="_blank">${login}</a>
1155
+ <a href="https://github.com/${login}" target="_blank"
1156
+ >${login}</a
1157
+ >
1129
1158
  </span>
1130
1159
  </div>
1131
1160
  <div class="info-row">
@@ -1151,14 +1180,22 @@ indexRoute.get("/", (c) => {
1151
1180
  <div class="link-desc">List available models</div>
1152
1181
  </div>
1153
1182
  </a>
1154
- <a class="link-item" href="https://github.com/billxc/copilot-api" target="_blank">
1183
+ <a
1184
+ class="link-item"
1185
+ href="https://github.com/billxc/copilot-api"
1186
+ target="_blank"
1187
+ >
1155
1188
  <span class="link-icon">⭐</span>
1156
1189
  <div>
1157
1190
  <div>GitHub</div>
1158
1191
  <div class="link-desc">Source code &amp; documentation</div>
1159
1192
  </div>
1160
1193
  </a>
1161
- <a class="link-item" href="https://github.com/billxc/copilot-api/issues" target="_blank">
1194
+ <a
1195
+ class="link-item"
1196
+ href="https://github.com/billxc/copilot-api/issues"
1197
+ target="_blank"
1198
+ >
1162
1199
  <span class="link-icon">🐛</span>
1163
1200
  <div>
1164
1201
  <div>Issues</div>