@essentialai/cogent-bridge-bundled 3.21.3 → 3.21.5
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/cogent-bridge.mjs +88 -7
- 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.
|
|
26393
|
-
return "3.21.
|
|
26392
|
+
if ("3.21.5") {
|
|
26393
|
+
return "3.21.5";
|
|
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");
|
|
@@ -27214,7 +27218,42 @@ async function validateSession(sessionId, cwd) {
|
|
|
27214
27218
|
);
|
|
27215
27219
|
return hits.some(Boolean);
|
|
27216
27220
|
}
|
|
27217
|
-
function
|
|
27221
|
+
async function rootForSession(sessionId, cwd) {
|
|
27222
|
+
const rec = await readAgentSession(cwd, "cc");
|
|
27223
|
+
if (rec?.sessionId === sessionId && rec.root) {
|
|
27224
|
+
try {
|
|
27225
|
+
await fs8.stat(rec.transcriptPath);
|
|
27226
|
+
return path10.resolve(rec.root);
|
|
27227
|
+
} catch {
|
|
27228
|
+
}
|
|
27229
|
+
}
|
|
27230
|
+
const [roots, forms] = await Promise.all([
|
|
27231
|
+
claudeConfigRoots(),
|
|
27232
|
+
cwdForms(cwd)
|
|
27233
|
+
]);
|
|
27234
|
+
for (const root of roots) {
|
|
27235
|
+
const hits = await Promise.all(
|
|
27236
|
+
forms.map(async (form) => {
|
|
27237
|
+
const file = path10.join(
|
|
27238
|
+
root,
|
|
27239
|
+
"projects",
|
|
27240
|
+
form.replace(/[^a-zA-Z0-9-]/g, "-"),
|
|
27241
|
+
`${sessionId}.jsonl`
|
|
27242
|
+
);
|
|
27243
|
+
try {
|
|
27244
|
+
await fs8.access(file);
|
|
27245
|
+
return true;
|
|
27246
|
+
} catch {
|
|
27247
|
+
return false;
|
|
27248
|
+
}
|
|
27249
|
+
})
|
|
27250
|
+
);
|
|
27251
|
+
if (hits.some(Boolean)) return root;
|
|
27252
|
+
}
|
|
27253
|
+
return null;
|
|
27254
|
+
}
|
|
27255
|
+
async function execClaude(sessionId, message, cwd, timeoutMs) {
|
|
27256
|
+
const resolvedRoot = await rootForSession(sessionId, cwd).catch(() => null);
|
|
27218
27257
|
return new Promise((resolve) => {
|
|
27219
27258
|
const config2 = getConfig();
|
|
27220
27259
|
const effectiveTimeout = timeoutMs ?? config2.COGENT_TIMEOUT_MS;
|
|
@@ -27241,6 +27280,9 @@ function execClaude(sessionId, message, cwd, timeoutMs) {
|
|
|
27241
27280
|
truncated
|
|
27242
27281
|
];
|
|
27243
27282
|
const cleanEnv = buildResumeEnv(process.env, "CLAUDE", ["CLAUDE_CONFIG_DIR"]);
|
|
27283
|
+
if (resolvedRoot && resolvedRoot !== path10.resolve(claudeConfigDir())) {
|
|
27284
|
+
cleanEnv.CLAUDE_CONFIG_DIR = resolvedRoot;
|
|
27285
|
+
}
|
|
27244
27286
|
cleanEnv.COGENT_CHECK_ON_STOP = "0";
|
|
27245
27287
|
const child = spawn(config2.COGENT_CLAUDE_PATH, args, {
|
|
27246
27288
|
cwd,
|
|
@@ -33206,7 +33248,41 @@ ${message}${formatAttachmentsBlock(attachments)}
|
|
|
33206
33248
|
---
|
|
33207
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.`;
|
|
33208
33250
|
}
|
|
33209
|
-
|
|
33251
|
+
function describeWakeFailure(exitCode, stderr) {
|
|
33252
|
+
const raw = (stderr ?? "").trim();
|
|
33253
|
+
if (!raw && exitCode !== 0) return "";
|
|
33254
|
+
const firstLine = raw.split("\n").map((l) => l.trim()).find(Boolean) ?? "";
|
|
33255
|
+
const missing = /No conversation found with session ID:?\s*(\S+)/i.exec(raw);
|
|
33256
|
+
if (missing) {
|
|
33257
|
+
return truncate(
|
|
33258
|
+
`claude could not find session ${missing[1]} in the config directory it searched \u2014 the agent's Claude state is probably outside ~/.claude. Upgrade the bridge (3.21.4+ passes the resolved config directory to the resume), or set CLAUDE_CONFIG_DIR.`
|
|
33259
|
+
);
|
|
33260
|
+
}
|
|
33261
|
+
if (/CLI_NOT_FOUND/.test(raw)) {
|
|
33262
|
+
return truncate(
|
|
33263
|
+
`the claude executable was not found \u2014 install Claude Code or set COGENT_CLAUDE_PATH.`
|
|
33264
|
+
);
|
|
33265
|
+
}
|
|
33266
|
+
const timedOut = /CLI_TIMEOUT: CLI subprocess timed out after (\d+)ms/.exec(raw);
|
|
33267
|
+
if (timedOut) {
|
|
33268
|
+
return truncate(
|
|
33269
|
+
`the resume timed out after ${timedOut[1]}ms (COGENT_TIMEOUT_MS) \u2014 the agent was still working, not idle.`
|
|
33270
|
+
);
|
|
33271
|
+
}
|
|
33272
|
+
if (firstLine) {
|
|
33273
|
+
const code = exitCode === null || exitCode === void 0 ? "?" : exitCode;
|
|
33274
|
+
return truncate(`claude exited ${code}: ${firstLine}`);
|
|
33275
|
+
}
|
|
33276
|
+
if (exitCode === 0) {
|
|
33277
|
+
return truncate(`the resume completed successfully but returned no text.`);
|
|
33278
|
+
}
|
|
33279
|
+
return "";
|
|
33280
|
+
}
|
|
33281
|
+
function truncate(s) {
|
|
33282
|
+
const flat = s.replace(/\s+/g, " ").trim();
|
|
33283
|
+
return flat.length > DIAGNOSTIC_MAX ? `${flat.slice(0, DIAGNOSTIC_MAX - 1)}\u2026` : flat;
|
|
33284
|
+
}
|
|
33285
|
+
var RELAY_STATUS, STATUS_MARKER_RE, DIAGNOSTIC_MAX, AutoRelayService, autoRelay;
|
|
33210
33286
|
var init_auto_relay = __esm({
|
|
33211
33287
|
"src/services/auto-relay.ts"() {
|
|
33212
33288
|
"use strict";
|
|
@@ -33225,6 +33301,7 @@ var init_auto_relay = __esm({
|
|
|
33225
33301
|
FAILED: "failed"
|
|
33226
33302
|
};
|
|
33227
33303
|
STATUS_MARKER_RE = /^\[cogent:(queued|processing|delivered|needs-manual|failed)\]/;
|
|
33304
|
+
DIAGNOSTIC_MAX = 220;
|
|
33228
33305
|
AutoRelayService = class {
|
|
33229
33306
|
localPeerId = null;
|
|
33230
33307
|
localSessionId = null;
|
|
@@ -33863,7 +33940,9 @@ var init_auto_relay = __esm({
|
|
|
33863
33940
|
}
|
|
33864
33941
|
if (!replied) {
|
|
33865
33942
|
await this._recordNoReplyFailure(msg, traceId, Date.now() - startMs, {
|
|
33866
|
-
codexLiveSession: result.codexLiveSession === true
|
|
33943
|
+
codexLiveSession: result.codexLiveSession === true,
|
|
33944
|
+
exitCode: result.exitCode,
|
|
33945
|
+
stderr: result.stderr
|
|
33867
33946
|
});
|
|
33868
33947
|
}
|
|
33869
33948
|
} catch (err) {
|
|
@@ -33871,7 +33950,9 @@ var init_auto_relay = __esm({
|
|
|
33871
33950
|
this._trace(traceId, "failed", { threw: true, durationMs });
|
|
33872
33951
|
logger.error(`Auto-relay: execRemote threw after ${durationMs}ms: ${err}`);
|
|
33873
33952
|
if (!replied) {
|
|
33874
|
-
await this._recordNoReplyFailure(msg, traceId, durationMs
|
|
33953
|
+
await this._recordNoReplyFailure(msg, traceId, durationMs, {
|
|
33954
|
+
stderr: `EXEC_THREW: ${err}`
|
|
33955
|
+
});
|
|
33875
33956
|
}
|
|
33876
33957
|
}
|
|
33877
33958
|
}
|
|
@@ -33887,7 +33968,7 @@ var init_auto_relay = __esm({
|
|
|
33887
33968
|
*/
|
|
33888
33969
|
async _recordNoReplyFailure(msg, traceId, durationMs, opts) {
|
|
33889
33970
|
const codexLive = opts?.codexLiveSession === true;
|
|
33890
|
-
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}" (
|
|
33971
|
+
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})`;
|
|
33891
33972
|
try {
|
|
33892
33973
|
await getBackend().recordMessage({
|
|
33893
33974
|
fromPeerId: this.localPeerId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@essentialai/cogent-bridge-bundled",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.5",
|
|
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": {
|