@lightupai/polaris 0.0.113 → 0.0.114

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.113",
3
+ "version": "0.0.114",
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",
@@ -707,6 +707,17 @@ export function startDaemon(port = Number(process.env.POLARIS_DAEMON_PORT ?? 432
707
707
  };
708
708
  sessions.set(body.ccSessionId, mapping);
709
709
 
710
+ // Evict stale alias entries that share this (project, session) pair.
711
+ // After a reconnect the old CC session ID still has an entry with the
712
+ // same pair; leaving it allows hook events from the old shell to
713
+ // alias-claim a future pending session or send duplicate events.
714
+ for (const [id, m] of sessions) {
715
+ if (id !== body.ccSessionId && m.project === mapping.project && m.session === mapping.session) {
716
+ sessions.delete(id);
717
+ console.error(`[daemon] Evicted stale alias ${id.slice(0, 8)} for ${mapping.project}/${mapping.session}`);
718
+ }
719
+ }
720
+
710
721
  // Ensure the session exists (create if not, claim driver)
711
722
  // Retry with new name on 409 (collision with generated name)
712
723
  let attempts = 0;
@@ -850,10 +861,16 @@ export function startDaemon(port = Number(process.env.POLARIS_DAEMON_PORT ?? 432
850
861
  // ran polaris_connect. Always returns not_connected; hooks from
851
862
  // unjoined shells are never auto-routed to an existing session.
852
863
  let mapping = sessions.get(ccSessionId);
853
- if (!mapping || !mapping.project) {
854
- // CC session_id doesn't match any registered MCP client. The MCP
855
- // server uses a different UUID than CC's session_id. Match to a
856
- // session with pendingMapping (most recent first).
864
+ if (mapping && !mapping.project) {
865
+ // Known CC session ID but deliberately disconnected (project cleared
866
+ // by /disconnect). Hooks still fire after disconnect — do NOT
867
+ // alias-claim a pending session; the shell intentionally left.
868
+ return json({ status: "not_connected" });
869
+ }
870
+ if (!mapping) {
871
+ // Truly unknown CC session_id — the MCP client's UUID differs from
872
+ // CC's hook session_id. Match to a session with pendingMapping
873
+ // (most recent first) to learn the alias.
857
874
  const pending = Array.from(sessions.values()).filter((m) => m.project && m.pendingMapping);
858
875
  if (pending.length > 0) {
859
876
  // Map the CC session ID to the most recently connected pending session