instar 1.3.163 → 1.3.165

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;AAsSH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAqwDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA0vPtE;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;AAsSH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAqwDD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA6xPtE;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"}
@@ -8779,6 +8779,14 @@ export async function startServer(options) {
8779
8779
  const r = ownReg.cas({ type: 'place', machineId }, { sessionKey: sk, sender: meshSelfId, nonce: `${meshSelfId}:c:${++routerNonce}` });
8780
8780
  return { ok: r.ok, epoch: ownReg.read(sk)?.ownershipEpoch ?? 0 };
8781
8781
  },
8782
+ // bug #11: confirm the remote owner (placing → active) after the spawn is
8783
+ // dispatched. The router holds the authoritative ownReg (single-router
8784
+ // topology); the FSM permits a claim whose machineId equals the placed
8785
+ // owner, so the router confirms on the target's behalf. Without this the
8786
+ // record stays 'placing' and every later message for the session queues.
8787
+ confirmClaim: (sk, machineId) => {
8788
+ ownReg.cas({ type: 'claim', machineId }, { sessionKey: sk, sender: meshSelfId, nonce: `${meshSelfId}:cl:${++routerNonce}` });
8789
+ },
8782
8790
  deliverMessage: async (target, env) => {
8783
8791
  const url = peerUrl(target);
8784
8792
  if (!url)
@@ -8844,6 +8852,36 @@ export async function startServer(options) {
8844
8852
  }
8845
8853
  };
8846
8854
  console.log(pc.green(' SessionRouter wired (L4) — inert until rollout stage advances past dark'));
8855
+ // bug #7: tokenless-standby outbound Telegram relay. TelegramAdapter.sendToTopic
8856
+ // only invokes this when the adapter has NO bot token (a pool standby serving a
8857
+ // session moved to it); a token-holding router never calls it. It relays the send
8858
+ // to the Telegram-OWNING lease holder's /telegram/reply, so a moved session's
8859
+ // replies reach the user without the standby ever sending on the shared bot
8860
+ // (preserving the single-Telegram-owner invariant — the 409-conflict guard).
8861
+ if (telegram) {
8862
+ telegram.outboundRelay = async (topicId, text, opts) => {
8863
+ const holder = coordinator.getSyncStatus().leaseHolder;
8864
+ if (!holder || holder === meshSelfId)
8865
+ return null; // we ARE the owner, or none known
8866
+ const url = peerUrl(holder);
8867
+ if (!url)
8868
+ return null;
8869
+ try {
8870
+ const resp = await fetch(`${url}/telegram/reply/${topicId}`, {
8871
+ method: 'POST',
8872
+ headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${config.authToken}` },
8873
+ body: JSON.stringify({ text, ...(opts?.silent ? { silent: true } : {}) }),
8874
+ });
8875
+ if (!resp.ok)
8876
+ return null;
8877
+ const j = (await resp.json().catch(() => ({})));
8878
+ return { messageId: j.messageId ?? 0, topicId };
8879
+ }
8880
+ catch {
8881
+ return null; // relay unreachable → sendToTopic surfaces the failure
8882
+ }
8883
+ };
8884
+ }
8847
8885
  // ── L4 transfer-by-nickname activation: the "move/run this on <nickname>"
8848
8886
  // trigger. The recognizer + planner are pure units; this wires them to the
8849
8887
  // pin store + ownership so a recognized command pins the topic to the named