@howaboua/pi-shepherdr 0.2.20 → 0.2.21

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @howaboua/pi-shepherdr
2
2
 
3
+ ## 0.2.21
4
+
5
+ - Fixed duplicate sessions showing a stack trace instead of a warning explaining how to restore shared context.
6
+
3
7
  ## 0.2.20
4
8
 
5
9
  - Requires Pi 1.2.0 or newer.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howaboua/pi-shepherdr",
3
- "version": "0.2.20",
3
+ "version": "0.2.21",
4
4
  "description": "Persistent blocking and asynchronous Pi agents through Herdr.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -43,7 +43,7 @@
43
43
  "pack:dry": "npm pack --dry-run"
44
44
  },
45
45
  "peerDependencies": {
46
- "@howaboua/pi-codex-conversion": ">=4.0.0",
46
+ "@howaboua/pi-codex-conversion": ">=4.0.1",
47
47
  "@earendil-works/pi-ai": ">=1.1.0",
48
48
  "@earendil-works/pi-coding-agent": ">=1.2.0",
49
49
  "@earendil-works/pi-tui": ">=1.1.0",
@@ -58,7 +58,7 @@
58
58
  "@howaboua/pi-agent-board": "0.0.1"
59
59
  },
60
60
  "devDependencies": {
61
- "@howaboua/pi-codex-conversion": "4.0.0",
61
+ "@howaboua/pi-codex-conversion": "4.0.1",
62
62
  "@biomejs/biome": "^2.5.15",
63
63
  "@earendil-works/pi-ai": "1.3.0",
64
64
  "@earendil-works/pi-coding-agent": "1.3.0",
@@ -187,8 +187,11 @@ export async function listenContext(path, handle) {
187
187
  else throw error;
188
188
  }
189
189
  if (alive)
190
- throw new Error(
191
- "This shared context session is already open; close its other live owner first",
190
+ throw Object.assign(
191
+ new Error(
192
+ "This shared context session is already open; close its other live owner first",
193
+ ),
194
+ { code: "SHARED_CONTEXT_ALREADY_OPEN" },
192
195
  );
193
196
  }
194
197
  } catch (error) {
@@ -18,7 +18,7 @@ import {
18
18
  import { readSessionView } from "./shepherdr-session.mjs";
19
19
  import { watchSessions } from "./shepherdr-session-watch.mjs";
20
20
 
21
- const BRIDGE_VERSION = 21;
21
+ const BRIDGE_VERSION = 22;
22
22
  const MAX_FRAME_BYTES = 8 * 1024 * 1024;
23
23
  const subscriptions = new Map();
24
24
  const contextRelays = new Map();
@@ -17,7 +17,7 @@ import type {
17
17
  SessionView,
18
18
  } from "./types.js";
19
19
 
20
- const BRIDGE_VERSION = 21;
20
+ const BRIDGE_VERSION = 22;
21
21
  const REMOTE_HELPER = "~/.pi/agent/shepherdr.mjs";
22
22
  const REMOTE_PEER_HELPER = "~/.pi/agent/shepherdr-peer.mjs";
23
23
  const REMOTE_CHANNEL_HELPER = "~/.pi/agent/shepherdr-channel.mjs";
@@ -57,12 +57,25 @@ export async function registerSharedAgentContext(
57
57
  let unregister: (() => void) | undefined;
58
58
  const publish = async (ctx: ExtensionContext) => {
59
59
  const file = ctx.sessionManager.getSessionFile();
60
- if (file)
60
+ if (!file) return;
61
+ try {
61
62
  close = await listenContext(
62
63
  sessionContextPath(file),
63
64
  (request: unknown, signal: AbortSignal) =>
64
65
  shared.handle(ctx, request, signal),
65
66
  );
67
+ } catch (error) {
68
+ if (
69
+ !(error instanceof Error) ||
70
+ !("code" in error) ||
71
+ error.code !== "SHARED_CONTEXT_ALREADY_OPEN"
72
+ )
73
+ throw error;
74
+ ctx.ui.notify(
75
+ "This session is open in another window. Agents remain available, but shared context is unavailable here. Close the other window, then /reload here to enable sharing.",
76
+ "warning",
77
+ );
78
+ }
66
79
  };
67
80
  pi.on("session_start", async () => {
68
81
  await close?.();