@essentialai/cogent-bridge-bundled 3.23.6 → 3.23.7

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.
Files changed (2) hide show
  1. package/cogent-bridge.mjs +62 -16
  2. package/package.json +1 -1
package/cogent-bridge.mjs CHANGED
@@ -26389,8 +26389,8 @@ var init_stdio2 = __esm({
26389
26389
  // src/constants.ts
26390
26390
  import { createRequire } from "node:module";
26391
26391
  function resolveVersion() {
26392
- if ("3.23.6") {
26393
- return "3.23.6";
26392
+ if ("3.23.7") {
26393
+ return "3.23.7";
26394
26394
  }
26395
26395
  try {
26396
26396
  const require2 = createRequire(import.meta.url);
@@ -35861,19 +35861,60 @@ function registerRegisterPeerTool(server) {
35861
35861
  storedPeerSecret = void 0;
35862
35862
  }
35863
35863
  }
35864
- const peer = await backend.registerPeer(
35865
- peerId,
35866
- sessionId,
35867
- cwd,
35868
- label,
35869
- CLIENT_VERSION,
35870
- mode,
35871
- channelSessionId,
35872
- capabilities,
35873
- workspaceId,
35874
- threadId,
35875
- storedPeerSecret
35876
- );
35864
+ let peer;
35865
+ try {
35866
+ peer = await backend.registerPeer(
35867
+ peerId,
35868
+ sessionId,
35869
+ cwd,
35870
+ label,
35871
+ CLIENT_VERSION,
35872
+ mode,
35873
+ channelSessionId,
35874
+ capabilities,
35875
+ workspaceId,
35876
+ threadId,
35877
+ storedPeerSecret
35878
+ );
35879
+ } catch (regErr) {
35880
+ const msg = regErr instanceof Error ? regErr.message : String(regErr);
35881
+ let recovered;
35882
+ if (/PEER_NOT_YOURS/.test(msg) && isCloudMode()) {
35883
+ try {
35884
+ const creds = await loadCredentials();
35885
+ if (creds?.ownerToken && creds.ownerToken !== creds.token && creds.endpoint && creds.sessionId) {
35886
+ logger.warn(
35887
+ `register_peer: '${peerId}' is owned by an earlier token (its peerSecret was lost by a pre-3.23.5 re-join). Re-proving ownership with the stored owner token.`
35888
+ );
35889
+ const res = await fetch(`${creds.endpoint}/api/sessions/${creds.sessionId}/peers`, {
35890
+ method: "POST",
35891
+ headers: { "content-type": "application/json", authorization: `Bearer ${creds.ownerToken}` },
35892
+ body: JSON.stringify({
35893
+ peerId,
35894
+ cwd,
35895
+ label,
35896
+ type: "agent",
35897
+ clientVersion: CLIENT_VERSION,
35898
+ ...mode ? { mode } : {},
35899
+ ...capabilities ? { capabilities } : {}
35900
+ })
35901
+ });
35902
+ if (res.ok) {
35903
+ recovered = await res.json();
35904
+ const secret = recovered?.peerSecret;
35905
+ if (secret) {
35906
+ await saveCredentials({ ...creds, peerId, peerSecret: secret, savedAt: (/* @__PURE__ */ new Date()).toISOString() });
35907
+ logger.info(`register_peer: ownership reclaimed for '${peerId}'; a fresh peerSecret is stored.`);
35908
+ }
35909
+ }
35910
+ }
35911
+ } catch (recoverErr) {
35912
+ logger.debug(`register_peer: ownership recovery failed: ${recoverErr.message}`);
35913
+ }
35914
+ }
35915
+ if (!recovered) throw regErr;
35916
+ peer = recovered;
35917
+ }
35877
35918
  if (isCloudMode()) {
35878
35919
  try {
35879
35920
  const creds = await loadCredentials();
@@ -37390,7 +37431,12 @@ function registerJoinSessionTool(server) {
37390
37431
  if (prior && prior.endpoint === endpoint && prior.sessionId === data.sessionId) {
37391
37432
  carried = {
37392
37433
  ...prior.peerId ? { peerId: prior.peerId } : {},
37393
- ...prior.peerSecret ? { peerSecret: prior.peerSecret } : {}
37434
+ ...prior.peerSecret ? { peerSecret: prior.peerSecret } : {},
37435
+ // Keep the token that owns the peer. A re-join mints a NEW one, and ownership is
37436
+ // proven by the CREATING token (or its secret) — so overwriting this field is what
37437
+ // turned a lost peerSecret into a permanent lockout. Prefer an ownerToken we are
37438
+ // already carrying; only fall back to `prior.token` the first time.
37439
+ ...prior.ownerToken || prior.token ? { ownerToken: prior.ownerToken ?? prior.token } : {}
37394
37440
  };
37395
37441
  }
37396
37442
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@essentialai/cogent-bridge-bundled",
3
- "version": "3.23.6",
3
+ "version": "3.23.7",
4
4
  "description": "Zero-dependency, pre-bundled Cogent MCP bridge — a single self-contained file for fast cold `npx` startup (used by the Codex plugin, whose MCP startup window is short). Functionally identical to @essentialai/cogent-bridge; carries no npm dependencies so `npx` skips dependency install.",
5
5
  "type": "module",
6
6
  "bin": {