@lightupai/polaris 0.0.99 → 0.0.101

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.99",
3
+ "version": "0.0.101",
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
@@ -184,8 +184,18 @@ const SYSTEMD_SERVICE_FILE = join(SYSTEMD_USER_DIR, `${SYSTEMD_SERVICE_NAME}.ser
184
184
  async function installSystemdService(daemonSecret?: string): Promise<void> {
185
185
  // Resolve bun's absolute path at install time so systemd's minimal PATH
186
186
  // doesn't matter. Bun.which() searches PATH; process.execPath is the
187
- // interpreter we're already running under — use whichever looks like bun.
188
- const bunPath = Bun.which("bun") ?? process.execPath;
187
+ // interpreter we're already running under.
188
+ const resolvedBun = Bun.which("bun") ?? process.execPath;
189
+
190
+ // Warn when bun resolved to an npx cache directory — that path is volatile
191
+ // and will break the service if the cache is pruned or the hash changes.
192
+ const isVolatile = resolvedBun.includes("/_npx/") || resolvedBun.includes("/npx_cache/");
193
+ if (isVolatile) {
194
+ console.error(` Warning: bun was found at a volatile npm cache path:`);
195
+ console.error(` ${resolvedBun}`);
196
+ console.error(` The daemon service may break if npm cleans its cache.`);
197
+ console.error(` Install bun permanently for reliability: curl -fsSL https://bun.sh/install | bash`);
198
+ }
189
199
 
190
200
  const binDir = join(POLARIS_DIR, "bin");
191
201
  const runnerPath = join(binDir, "run-daemon.sh");
@@ -194,12 +204,19 @@ async function installSystemdService(daemonSecret?: string): Promise<void> {
194
204
  );
195
205
 
196
206
  await mkdir(binDir, { recursive: true });
197
- // Bun path is baked in at install time — no runtime search needed
207
+ // Runner tries the baked-in path first (fast path), then falls back to
208
+ // common stable install locations, then npx as a last resort — so the
209
+ // service survives a cache prune or bun reinstall without needing
210
+ // `polaris install` to be rerun.
198
211
  const runner = [
199
212
  "#!/bin/sh",
200
213
  `# Polaris daemon — managed by systemd (${SYSTEMD_SERVICE_NAME}.service)`,
201
- `# bun path resolved at install time: ${bunPath}`,
202
- `exec "${bunPath}" run "${daemonTsPath}"`,
214
+ `DAEMONTS="${daemonTsPath}"`,
215
+ `for BUNPATH in "${resolvedBun}" "$HOME/.bun/bin/bun" /usr/local/bin/bun /usr/bin/bun; do`,
216
+ ` if [ -x "$BUNPATH" ]; then exec "$BUNPATH" run "$DAEMONTS"; fi`,
217
+ `done`,
218
+ `# npx fallback — slow but avoids exit-127 restart loops`,
219
+ `exec npx --yes bun run "$DAEMONTS"`,
203
220
  ].join("\n") + "\n";
204
221
  await writeFile(runnerPath, runner);
205
222
  await chmod(runnerPath, 0o755);
@@ -214,7 +231,8 @@ Type=simple
214
231
  ExecStart=${runnerPath}
215
232
  Restart=always
216
233
  RestartSec=5
217
- ${secretLine}StandardOutput=append:/tmp/polaris-daemon.log
234
+ ${secretLine}Environment=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
235
+ StandardOutput=append:/tmp/polaris-daemon.log
218
236
  StandardError=append:/tmp/polaris-daemon.log
219
237
 
220
238
  [Install]
@@ -47,14 +47,18 @@ async function daemonGet(path: string): Promise<Response> {
47
47
  // --- Session state persistence ---
48
48
 
49
49
  function sessionStatePath(): string {
50
- const hash = createHash("sha256").update(process.cwd()).digest("hex").slice(0, 16);
50
+ // Keyed by CC session ID so two Claude Code sessions in the same directory
51
+ // get independent state files and never auto-reconnect into each other's
52
+ // project. Previously keyed by cwd hash, which caused unrelated sessions to
53
+ // silently inherit another session's project connection (#154, #153).
54
+ const hash = createHash("sha256").update(CC_SESSION_ID).digest("hex").slice(0, 16);
51
55
  return `${homedir()}/.polaris/sessions/${hash}.json`;
52
56
  }
53
57
 
54
58
  async function saveSessionState(project: string, session: string, user: string, profile: string): Promise<void> {
55
59
  try {
56
60
  await mkdir(`${homedir()}/.polaris/sessions`, { recursive: true });
57
- await writeFile(sessionStatePath(), JSON.stringify({ project, session, user, profile, cwd: process.cwd() }));
61
+ await writeFile(sessionStatePath(), JSON.stringify({ project, session, user, profile, cwd: process.cwd(), ccSessionId: CC_SESSION_ID }));
58
62
  } catch { /* best-effort */ }
59
63
  }
60
64