@lightupai/polaris 0.0.80 → 0.0.81

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightupai/polaris",
3
- "version": "0.0.80",
3
+ "version": "0.0.81",
4
4
  "description": "Record and stream Claude Code sessions to Slack. Like Gong for AI coding — capture every prompt, response, and tool call. Multiplayer collaboration across AI coding agents.",
5
5
  "keywords": [
6
6
  "claude-code",
package/src/cli/cli.ts CHANGED
@@ -486,6 +486,23 @@ async function profiles() {
486
486
 
487
487
  // --- Daemon ---
488
488
 
489
+ async function killExistingDaemon(): Promise<void> {
490
+ // Ask the running daemon to shut down gracefully via the HTTP API, then
491
+ // wait briefly for the port to free up. Falls back silently if no daemon
492
+ // is running or the port is already free.
493
+ try {
494
+ const secret = await ensureDaemonSecret();
495
+ const headers: Record<string, string> = { "Content-Type": "application/json" };
496
+ if (secret) headers["x-polaris-daemon-secret"] = secret;
497
+ await fetch("http://127.0.0.1:4322/shutdown", { method: "POST", headers }).catch(() => {});
498
+ } catch { /* no daemon running */ }
499
+ // Give it a moment to exit, then kill any straggler by port
500
+ await new Promise((r) => setTimeout(r, 500));
501
+ try {
502
+ Bun.spawnSync(["sh", "-c", "lsof -ti :4322 | xargs kill -9 2>/dev/null || true"]);
503
+ } catch { /* best-effort */ }
504
+ }
505
+
489
506
  async function daemon() {
490
507
  const daemonPath = join(import.meta.dir, "..", "daemon", "daemon.ts");
491
508
  console.log("Starting Polaris daemon...");
@@ -789,7 +806,8 @@ switch (command) {
789
806
  console.log("Polaris — authenticating\n");
790
807
  await login(appUrl, profileName);
791
808
  console.log("\n✓ Login complete!");
792
- // Auto-start daemon in background
809
+ // Replace any existing daemon with the current version
810
+ await killExistingDaemon();
793
811
  const daemonPath = join(import.meta.dir, "..", "daemon", "daemon.ts");
794
812
  Bun.spawn(["bun", "run", daemonPath], {
795
813
  stdout: "ignore",
@@ -839,7 +857,8 @@ switch (command) {
839
857
  console.log("[2/2] Authenticating...\n");
840
858
  await login(DEFAULT_APP_URL);
841
859
  console.log("\n✓ Polaris is set up on this machine!");
842
- // Auto-start daemon in background
860
+ // Replace any existing daemon with the current version
861
+ await killExistingDaemon();
843
862
  const daemonPath = join(import.meta.dir, "..", "daemon", "daemon.ts");
844
863
  Bun.spawn(["bun", "run", daemonPath], {
845
864
  stdout: "ignore",
@@ -884,6 +884,13 @@ export function startDaemon(port = Number(process.env.POLARIS_DAEMON_PORT ?? 432
884
884
  }
885
885
  }
886
886
 
887
+ // POST /shutdown — graceful shutdown (used by `polaris install` to replace an old daemon)
888
+ if (method === "POST" && pathname === "/shutdown") {
889
+ // Respond first, then exit after a short delay so the response is delivered
890
+ setTimeout(() => process.exit(0), 100);
891
+ return json({ status: "shutting_down" });
892
+ }
893
+
887
894
  return error("Not found", 404);
888
895
  },
889
896
  });