@essentialai/cogent-bridge-bundled 3.21.4 → 3.21.6

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 +46 -7
  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.21.4") {
26393
- return "3.21.4";
26392
+ if ("3.21.6") {
26393
+ return "3.21.6";
26394
26394
  }
26395
26395
  try {
26396
26396
  const require2 = createRequire(import.meta.url);
@@ -27031,6 +27031,10 @@ var init_peer_registry = __esm({
27031
27031
  // src/services/agent-config.ts
27032
27032
  import os4 from "node:os";
27033
27033
  import path8 from "node:path";
27034
+ function claudeConfigDir() {
27035
+ const override = process.env.CLAUDE_CONFIG_DIR?.trim();
27036
+ return override ? override : path8.join(os4.homedir(), ".claude");
27037
+ }
27034
27038
  function codexHomeDir() {
27035
27039
  const override = process.env.CODEX_HOME?.trim();
27036
27040
  return override ? override : path8.join(os4.homedir(), ".codex");
@@ -27276,7 +27280,9 @@ async function execClaude(sessionId, message, cwd, timeoutMs) {
27276
27280
  truncated
27277
27281
  ];
27278
27282
  const cleanEnv = buildResumeEnv(process.env, "CLAUDE", ["CLAUDE_CONFIG_DIR"]);
27279
- if (resolvedRoot) cleanEnv.CLAUDE_CONFIG_DIR = resolvedRoot;
27283
+ if (resolvedRoot && resolvedRoot !== path10.resolve(claudeConfigDir())) {
27284
+ cleanEnv.CLAUDE_CONFIG_DIR = resolvedRoot;
27285
+ }
27280
27286
  cleanEnv.COGENT_CHECK_ON_STOP = "0";
27281
27287
  const child = spawn(config2.COGENT_CLAUDE_PATH, args, {
27282
27288
  cwd,
@@ -33242,9 +33248,9 @@ ${message}${formatAttachmentsBlock(attachments)}
33242
33248
  ---
33243
33249
  FYI ONLY \u2014 another agent addressed the whole channel. Take note for context, but do NOT reply and do NOT call any cogent_* tool in response. A human will drive any reply.`;
33244
33250
  }
33245
- function describeWakeFailure(exitCode, stderr) {
33251
+ function describeWakeFailure(exitCode, stderr, stdout) {
33246
33252
  const raw = (stderr ?? "").trim();
33247
- if (!raw && exitCode !== 0) return "";
33253
+ if (!raw && exitCode !== 0 && !stdout) return "";
33248
33254
  const firstLine = raw.split("\n").map((l) => l.trim()).find(Boolean) ?? "";
33249
33255
  const missing = /No conversation found with session ID:?\s*(\S+)/i.exec(raw);
33250
33256
  if (missing) {
@@ -33263,6 +33269,25 @@ function describeWakeFailure(exitCode, stderr) {
33263
33269
  `the resume timed out after ${timedOut[1]}ms (COGENT_TIMEOUT_MS) \u2014 the agent was still working, not idle.`
33264
33270
  );
33265
33271
  }
33272
+ const childStderr = /\. stderr:\s*([\s\S]*)$/.exec(raw)?.[1]?.trim() ?? raw;
33273
+ if (!childStderr) {
33274
+ const code = exitCode === null || exitCode === void 0 ? "?" : exitCode;
33275
+ const env = parseResultEnvelope(stdout);
33276
+ if (env) {
33277
+ const bits = [];
33278
+ if (env.terminalReason) {
33279
+ bits.push(
33280
+ env.terminalReason === "api_error" ? `the CLI could not complete an API call (terminal_reason "api_error") \u2014 check that agent's Claude credentials / API access` : `terminal_reason "${env.terminalReason}"`
33281
+ );
33282
+ }
33283
+ if (env.result) bits.push(env.result);
33284
+ if (!bits.length && env.isError) bits.push("the run reported is_error with no detail");
33285
+ if (bits.length) return truncate(`claude exited ${code}: ${bits.join(" \u2014 ")}`);
33286
+ }
33287
+ return truncate(
33288
+ stdout?.trim() ? `claude exited ${code} with nothing on stderr; its stdout was not a readable result envelope` : `claude exited ${code} with no output at all on stdout or stderr`
33289
+ );
33290
+ }
33266
33291
  if (firstLine) {
33267
33292
  const code = exitCode === null || exitCode === void 0 ? "?" : exitCode;
33268
33293
  return truncate(`claude exited ${code}: ${firstLine}`);
@@ -33272,6 +33297,19 @@ function describeWakeFailure(exitCode, stderr) {
33272
33297
  }
33273
33298
  return "";
33274
33299
  }
33300
+ function parseResultEnvelope(stdout) {
33301
+ const text = (stdout ?? "").trim();
33302
+ if (!text.startsWith("{")) return null;
33303
+ try {
33304
+ const o = JSON.parse(text);
33305
+ const result = typeof o.result === "string" && o.result.trim() ? o.result.trim() : null;
33306
+ const terminalReason = typeof o.terminal_reason === "string" && o.terminal_reason.trim() ? o.terminal_reason.trim() : null;
33307
+ if (o.is_error === void 0 && !terminalReason && !result) return null;
33308
+ return { isError: o.is_error === true, terminalReason, result };
33309
+ } catch {
33310
+ return null;
33311
+ }
33312
+ }
33275
33313
  function truncate(s) {
33276
33314
  const flat = s.replace(/\s+/g, " ").trim();
33277
33315
  return flat.length > DIAGNOSTIC_MAX ? `${flat.slice(0, DIAGNOSTIC_MAX - 1)}\u2026` : flat;
@@ -33936,7 +33974,8 @@ var init_auto_relay = __esm({
33936
33974
  await this._recordNoReplyFailure(msg, traceId, Date.now() - startMs, {
33937
33975
  codexLiveSession: result.codexLiveSession === true,
33938
33976
  exitCode: result.exitCode,
33939
- stderr: result.stderr
33977
+ stderr: result.stderr,
33978
+ stdout: result.stdout
33940
33979
  });
33941
33980
  }
33942
33981
  } catch (err) {
@@ -33962,7 +34001,7 @@ var init_auto_relay = __esm({
33962
34001
  */
33963
34002
  async _recordNoReplyFailure(msg, traceId, durationMs, opts) {
33964
34003
  const codexLive = opts?.codexLiveSession === true;
33965
- const message = codexLive ? `\u{1F4E8} Queued for "${this.localPeerId}": it's live in an interactive Codex session, so Cogent can't resume it in real time \u2014 it will see this at its next turn. For real-time replies, launch it via \`cogent-codex\` (COGENT_CODEX_WAKE=app-server). (trace ${traceId})` : `\u26A0\uFE0F Cogent could not capture a reply from "${this.localPeerId}". ${describeWakeFailure(opts?.exitCode, opts?.stderr) || "It may have been busy, or the resume produced no output."} Manual response required \u2014 the target agent must reply in its own session. (trace ${traceId})`;
34004
+ const message = codexLive ? `\u{1F4E8} Queued for "${this.localPeerId}": it's live in an interactive Codex session, so Cogent can't resume it in real time \u2014 it will see this at its next turn. For real-time replies, launch it via \`cogent-codex\` (COGENT_CODEX_WAKE=app-server). (trace ${traceId})` : `\u26A0\uFE0F Cogent could not capture a reply from "${this.localPeerId}". ${describeWakeFailure(opts?.exitCode, opts?.stderr, opts?.stdout) || "It may have been busy, or the resume produced no output."} Manual response required \u2014 the target agent must reply in its own session. (trace ${traceId})`;
33966
34005
  try {
33967
34006
  await getBackend().recordMessage({
33968
34007
  fromPeerId: this.localPeerId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@essentialai/cogent-bridge-bundled",
3
- "version": "3.21.4",
3
+ "version": "3.21.6",
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": {