instar 1.3.167 → 1.3.169

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.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuSH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA+wDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqzPtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuSH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AA+wDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA00PtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
@@ -8696,7 +8696,28 @@ export async function startServer(options) {
8696
8696
  : (cmd.payload && typeof cmd.payload === 'object' && 'text' in cmd.payload)
8697
8697
  ? String(cmd.payload.text)
8698
8698
  : undefined;
8699
- const sessionName = tg.getSessionForTopic(topicId) ?? `topic-${topicId}`;
8699
+ // bug #13: a moved session ALREADY running on this machine must receive
8700
+ // follow-ups via INJECTION (mirroring the normal inbound dispatch), NOT a
8701
+ // re-spawn. getSessionForTopic returns the already-prefixed tmux name; routing
8702
+ // it back through spawnSessionForTopic re-prefixes it (projectBase-projectBase-
8703
+ // topic-N) so tmuxSessionExists misses and a DUPLICATE session is spawned on
8704
+ // every follow-up — the moved conversation never advances. So: if a live
8705
+ // session exists, inject the text into it (with the [telegram:N …] prefix the
8706
+ // session expects) and return; only spawn when there is none.
8707
+ const existing = tg.getSessionForTopic(topicId);
8708
+ if (existing && sessionManager.isSessionAlive(existing)) {
8709
+ if (text) {
8710
+ console.log(pc.green(` [session-pool] owner-side inject for forwarded topic ${topicId} → ${existing}`));
8711
+ sessionManager.injectTelegramMessage(existing, topicId, text, tg.getTopicName?.(topicId) ?? undefined);
8712
+ tg.trackMessageInjection(topicId, existing, text);
8713
+ }
8714
+ return;
8715
+ }
8716
+ // No live session yet (the FIRST forwarded message for this topic, or the
8717
+ // prior one died) — spawn the moved session with the relayed context, under a
8718
+ // clean topic-derived name. NEVER reuse the prefixed getSessionForTopic value
8719
+ // as the spawn name (that is the double-prefix defect above).
8720
+ const spawnName = `topic-${topicId}`;
8700
8721
  // bug #2: fetch the prior conversation from the router (this machine's local
8701
8722
  // history for the topic is empty) so the moved session continues with context
8702
8723
  // instead of starting blank. Best-effort — on any failure we spawn without it.
@@ -8717,10 +8738,10 @@ export async function startServer(options) {
8717
8738
  catch {
8718
8739
  // @silent-fallback-ok — cross-machine context relay is best-effort
8719
8740
  }
8720
- return spawnSessionForTopic(sessionManager, tg, sessionName, topicId, text, undefined, undefined, movedContext);
8741
+ return spawnSessionForTopic(sessionManager, tg, spawnName, topicId, text, undefined, undefined, movedContext);
8721
8742
  })()
8722
8743
  .then((name) => {
8723
- tg.registerTopicSession(topicId, name, sessionName);
8744
+ tg.registerTopicSession(topicId, name, spawnName);
8724
8745
  console.log(pc.green(` [session-pool] owner-side resume for forwarded topic ${topicId} → ${name}`));
8725
8746
  })
8726
8747
  .catch((err) => console.warn(` [session-pool] owner-side resume failed for topic ${topicId}: ${err instanceof Error ? err.message : String(err)}`));