@essentialai/cogent-plugin 3.25.7 → 3.25.8

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,6 +1,6 @@
1
1
  {
2
2
  "name": "cogent",
3
- "version": "3.25.7",
3
+ "version": "3.25.8",
4
4
  "description": "Inter-session communication bridge for Claude Code with Slack integration. Enables CC agents and Slack team members to communicate in real time.",
5
5
  "author": {
6
6
  "name": "Essential AI Solutions",
@@ -26412,8 +26412,8 @@ var init_stdio2 = __esm({
26412
26412
  // src/constants.ts
26413
26413
  import { createRequire } from "node:module";
26414
26414
  function resolveVersion() {
26415
- if ("3.25.7") {
26416
- return "3.25.7";
26415
+ if ("3.25.8") {
26416
+ return "3.25.8";
26417
26417
  }
26418
26418
  try {
26419
26419
  const require2 = createRequire(import.meta.url);
@@ -26833,6 +26833,7 @@ var init_errors4 = __esm({
26833
26833
  BridgeErrorCode2["JOIN_NOT_CONFIRMED"] = "JOIN_NOT_CONFIRMED";
26834
26834
  BridgeErrorCode2["CHANNEL_NOT_FOUND"] = "CHANNEL_NOT_FOUND";
26835
26835
  BridgeErrorCode2["PEER_NOT_YOURS"] = "PEER_NOT_YOURS";
26836
+ BridgeErrorCode2["PEER_HELD_IN_FOLDER"] = "PEER_HELD_IN_FOLDER";
26836
26837
  return BridgeErrorCode2;
26837
26838
  })(BridgeErrorCode || {});
26838
26839
  BridgeError = class extends Error {
@@ -35396,6 +35397,19 @@ function otherBridgesInFolder(entries, self, listProcs) {
35396
35397
  (e) => e.peerId !== PROCESS_MARK && e.pid !== self.pid && !e.draining && holderRelation(e.sessionId, self.sessionId) !== "same-session" && !holderClientGone(e, procs ??= listProcs())
35397
35398
  );
35398
35399
  }
35400
+ function heldInFolder(others, peerId, ownSession) {
35401
+ return others.find((o) => o.peerId === peerId && !mayBeOwnPreSessionBridge(o, ownSession));
35402
+ }
35403
+ function mayBeOwnPreSessionBridge(holder, ownSession) {
35404
+ if (holder.sessionId || !ownSession) return false;
35405
+ const v = /^(\d+)\.(\d+)\.(\d+)$/.exec(String(holder.version ?? ""));
35406
+ if (!v) return false;
35407
+ const [maj, min, pat] = [Number(v[1]), Number(v[2]), Number(v[3])];
35408
+ return maj < 3 || maj === 3 && (min < 25 || min === 25 && pat < 7);
35409
+ }
35410
+ function heldNameAdvice(peerId) {
35411
+ return `If this agent was just restarted, its previous connection closes within ${HOLDER_LINGER_SECONDS} seconds: wait ${HOLDER_LINGER_SECONDS}+ seconds, then run /cogent:register again with the SAME peer name '${peerId}'. If '${peerId}' is still held after that, another live connection is using it \u2014 another agent, or an old window of this one still open. Do not take the name and do not rename: ask the user`;
35412
+ }
35399
35413
  function anotherAgentSessionAmong(others, ownSession) {
35400
35414
  return others.some((o) => holderRelation(o.sessionId, ownSession) === "other-session");
35401
35415
  }
@@ -35461,7 +35475,7 @@ async function restorePresence(deps) {
35461
35475
  const started = Number.isFinite(servedBy.startedAt) ? new Date(servedBy.startedAt).toISOString() : "unknown";
35462
35476
  const recheck = holder === "same-session";
35463
35477
  const every = deps.recheckSeconds ? ` (re-checked every ${deps.recheckSeconds}s)` : "";
35464
- const take = `To take '${peerId}' for this agent now, run /cogent:register (cogent_join_session, then cogent_register_peer)`;
35478
+ const take = heldNameAdvice(peerId);
35465
35479
  const why = {
35466
35480
  "same-session": `That bridge serves this same agent session (${session})`,
35467
35481
  "no-session": `Neither bridge records an agent session (codex, gemini), so it cannot be told whether that bridge is this agent's previous one or another agent's. ${take}`,
@@ -35545,7 +35559,7 @@ function logPresence(outcome) {
35545
35559
  logger.debug(`Presence: ${outcome.state} \u2014 ${outcome.detail}.`);
35546
35560
  }
35547
35561
  }
35548
- var ORPHAN_PARENT_RE, NPX_WRAPPER_RE, lastPresence;
35562
+ var ORPHAN_PARENT_RE, NPX_WRAPPER_RE, HOLDER_LINGER_SECONDS, lastPresence;
35549
35563
  var init_peer_presence = __esm({
35550
35564
  "src/services/peer-presence.ts"() {
35551
35565
  "use strict";
@@ -35553,6 +35567,7 @@ var init_peer_presence = __esm({
35553
35567
  init_wake_ownership();
35554
35568
  ORPHAN_PARENT_RE = /^(init|launchd|systemd)$/;
35555
35569
  NPX_WRAPPER_RE = /^(?:\S*\/)?(?:sh|bash|dash) -c cogent-bridge\b|^npm exec @essentialai\/cogent-bridge/;
35570
+ HOLDER_LINGER_SECONDS = 60;
35556
35571
  lastPresence = null;
35557
35572
  }
35558
35573
  });
@@ -36469,6 +36484,24 @@ function registerRegisterPeerTool(server) {
36469
36484
  )
36470
36485
  );
36471
36486
  }
36487
+ if (config2.COGENT_ENDPOINT) try {
36488
+ const own = agentSessionId();
36489
+ const seen = /* @__PURE__ */ new Set();
36490
+ const entries = [...listLiveBridgesInFolder(cwd), ...listLiveBridgesInFolder(process.cwd())].filter((e) => !seen.has(`${e.pid}:${e.peerId}`) && seen.add(`${e.pid}:${e.peerId}`));
36491
+ const holder = heldInFolder(otherBridgesInFolder(entries, { pid: process.pid, sessionId: own }, listProcesses), peerId, own);
36492
+ if (holder) {
36493
+ logger.info(`Register: refused '${peerId}' \u2014 held in this folder by bridge pid ${holder.pid}`);
36494
+ return errorResult(
36495
+ new BridgeError(
36496
+ "PEER_HELD_IN_FOLDER" /* PEER_HELD_IN_FOLDER */,
36497
+ `'${peerId}' is held by another live connection in this folder (bridge pid ${holder.pid}, version ${registryText(holder.version)}); this bridge has NOT registered`,
36498
+ heldNameAdvice(peerId)
36499
+ )
36500
+ );
36501
+ }
36502
+ } catch (err) {
36503
+ logger.debug(`Register: could not check this folder for a holder of '${peerId}': ${err.message}`);
36504
+ }
36472
36505
  const hasCloudEndpointConfig = config2.COGENT_ENDPOINT && isCloudEndpoint(config2.COGENT_ENDPOINT);
36473
36506
  let sessionCreated = false;
36474
36507
  let cloudSessionId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@essentialai/cogent-plugin",
3
- "version": "3.25.7",
3
+ "version": "3.25.8",
4
4
  "description": "Cogent — Claude Code plugin (skills + slash-commands + MCP server) for the cross-agent comms fabric.",
5
5
  "author": { "name": "Essential AI Solutions Ltd.", "url": "https://essentialai.uk" },
6
6
  "homepage": "https://cogent.tools",