@sjawhar/pi-legion-envoy 0.4.0 → 0.4.1

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/dist/envoy.js CHANGED
@@ -30990,18 +30990,35 @@ function envoyExtension(pi) {
30990
30990
  }, NATS_RETRY_INTERVAL_MS);
30991
30991
  }
30992
30992
  });
30993
- const rebind = async (_event, context) => {
30993
+ const rebind = async (reason, context) => {
30994
30994
  if (defaults.natsUrls.length === 0)
30995
30995
  return;
30996
+ const previousID = sessionID;
30996
30997
  try {
30997
30998
  await establishSession(context);
30998
30999
  } catch (error48) {
30999
31000
  context.ui.notify(`envoy: rebind failed (${messageFor(error48)}); will recover on reconnect`, "warning");
31000
31001
  }
31001
- };
31002
- pi.on("session_switch", rebind);
31003
- pi.on("session_branch", rebind);
31004
- pi.on("session_tree", rebind);
31002
+ if (previousID === "" || previousID === sessionID)
31003
+ return;
31004
+ if (reason === "new" || reason === "resume")
31005
+ return;
31006
+ pi.sendMessage({
31007
+ customType: "envoy-message",
31008
+ content: encode3({
31009
+ envoy: {
31010
+ notice: "session id changed",
31011
+ previous_session_id: previousID,
31012
+ session_id: sessionID,
31013
+ detail: "This conversation now lives under a new session id. Any identity you shared earlier (envoy_whoami output, session ids named in messages) is stale, and peers using the old id cannot reach you. Re-run envoy_whoami before identifying yourself and re-announce the new id to peers you already introduced yourself to."
31014
+ }
31015
+ }),
31016
+ display: true
31017
+ }, { deliverAs: "steer", triggerTurn: false });
31018
+ };
31019
+ pi.on("session_switch", (event, context) => rebind(event.reason, context));
31020
+ pi.on("session_branch", (_event, context) => rebind(undefined, context));
31021
+ pi.on("session_tree", (_event, context) => rebind(undefined, context));
31005
31022
  pi.on("session_shutdown", async () => {
31006
31023
  shuttingDown = true;
31007
31024
  try {
@@ -200,6 +200,14 @@ Examples:
200
200
 
201
201
  You do NOT need to subscribe in order to send or publish.
202
202
 
203
+ **Session ids are not stable for the life of a conversation.** On OMP, `/fork` and `/handoff`
204
+ re-mint the session id while the conversation continues (esc-esc rewinds also did, on omp
205
+ 18.1.0–18.1.2 only); the extension rebinds automatically and injects an `envoy` notice naming
206
+ the previous and new ids. When that notice arrives, any id you shared earlier (an
207
+ `envoy_whoami` result quoted in a message, an id a peer saved) is stale — re-run
208
+ `envoy_whoami` and re-announce yourself. Never treat a whoami result from earlier in the
209
+ transcript as current when identifying yourself to peers.
210
+
203
211
  ### To wait for CI, PR checks, or other async work
204
212
 
205
213
  **Don't `sleep`-poll. Don't "check back in N minutes."** Subscribe to the event and continue with productive work — the system will wake the session when the event arrives.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjawhar/pi-legion-envoy",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "omp": {
6
6
  "extensions": [