@essentialai/cogent-plugin 3.20.0 → 3.20.2

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.20.0",
3
+ "version": "3.20.2",
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",
@@ -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.20.0") {
26393
- return "3.20.0";
26392
+ if ("3.20.2") {
26393
+ return "3.20.2";
26394
26394
  }
26395
26395
  try {
26396
26396
  const require2 = createRequire(import.meta.url);
@@ -26621,7 +26621,7 @@ var init_config = __esm({
26621
26621
  // purely additive/opt-in: nothing changes for any agent until a codex user
26622
26622
  // launches via the daemon (see bin/cogent-codex) and sets this to `app-server`.
26623
26623
  // Only affects COGENT_PLATFORM=codex; claude/gemini/mail rails never read it.
26624
- COGENT_CODEX_WAKE: import_zod2.z.enum(["exec-resume", "app-server"]).default("exec-resume"),
26624
+ COGENT_CODEX_WAKE: import_zod2.z.enum(["auto", "exec-resume", "app-server"]).default("auto"),
26625
26625
  // Auto-recovery for a blocked Codex sandbox. On a host where the OS sandbox
26626
26626
  // can't initialize (unprivileged user namespaces blocked — Ubuntu 24.04's
26627
26627
  // apparmor_restrict_unprivileged_userns, containers, hardened kernels),
@@ -27253,6 +27253,8 @@ var init_cc_cli = __esm({
27253
27253
  import { execFile as execFile2 } from "node:child_process";
27254
27254
  import { promisify as promisify2 } from "node:util";
27255
27255
  import fs8 from "node:fs/promises";
27256
+ import { join } from "node:path";
27257
+ import os5 from "node:os";
27256
27258
  function analyzeCodexHelp(helpText) {
27257
27259
  const checked = EXPECTED_CODEX_RESUME_FLAGS.map((f) => f.flag);
27258
27260
  const missing = EXPECTED_CODEX_RESUME_FLAGS.filter(
@@ -27357,6 +27359,27 @@ async function preflightCodexSandbox(config2) {
27357
27359
  }
27358
27360
  return res;
27359
27361
  }
27362
+ function detectCodexCogentServerCollision(configTomlText) {
27363
+ return /^[ \t]*\[mcp_servers\.cogent(\.[^\]]+)?\]/m.test(configTomlText);
27364
+ }
27365
+ function codexConfigPath(codexHomeDir2) {
27366
+ const home = codexHomeDir2 || process.env.CODEX_HOME || join(os5.homedir(), ".codex");
27367
+ return join(home, "config.toml");
27368
+ }
27369
+ async function preflightCodexServerCollision(codexHomeDir2) {
27370
+ const cfgPath = codexConfigPath(codexHomeDir2);
27371
+ let text;
27372
+ try {
27373
+ text = await fs8.readFile(cfgPath, "utf8");
27374
+ } catch {
27375
+ return false;
27376
+ }
27377
+ if (!detectCodexCogentServerCollision(text)) return false;
27378
+ logger.error(
27379
+ `Codex config collision: ${cfgPath} defines a standalone [mcp_servers.cogent] server, which has the SAME NAME as the cogent@cogent plugin's MCP server. Codex collapses the two by name and MCP startup can fail ("MCP client for cogent failed to start \u2026 connection closed: initialize response"). FIX: remove the [mcp_servers.cogent] block from ${cfgPath} \u2014 the plugin already provides the cogent tools \u2014 then restart Codex (new thread). Use the plugin OR a manual 'codex mcp add cogent', never both.`
27380
+ );
27381
+ return true;
27382
+ }
27360
27383
  var execFileAsync, EXPECTED_CODEX_RESUME_FLAGS;
27361
27384
  var init_codex_preflight = __esm({
27362
27385
  "src/services/codex-preflight.ts"() {
@@ -32194,7 +32217,7 @@ var init_cloud = __esm({
32194
32217
  // src/services/codex-cli.ts
32195
32218
  import { spawn as spawn2 } from "node:child_process";
32196
32219
  import fs10 from "node:fs/promises";
32197
- import os5 from "node:os";
32220
+ import os6 from "node:os";
32198
32221
  import path11 from "node:path";
32199
32222
  import { randomUUID } from "node:crypto";
32200
32223
  import { createReadStream } from "node:fs";
@@ -32223,7 +32246,7 @@ function execCodex(sessionId, message, cwd, timeoutMs) {
32223
32246
  const config2 = getConfig();
32224
32247
  const effectiveTimeout = timeoutMs ?? config2.COGENT_TIMEOUT_MS;
32225
32248
  const truncated = config2.COGENT_CHAR_LIMIT > 0 && message.length > config2.COGENT_CHAR_LIMIT ? message.slice(0, config2.COGENT_CHAR_LIMIT) + "\n...[truncated]" : message;
32226
- const lastMsgFile = path11.join(os5.tmpdir(), `cogent-codex-${randomUUID()}.txt`);
32249
+ const lastMsgFile = path11.join(os6.tmpdir(), `cogent-codex-${randomUUID()}.txt`);
32227
32250
  const args = [
32228
32251
  "exec",
32229
32252
  "resume",
@@ -32441,13 +32464,42 @@ var init_codex_cli = __esm({
32441
32464
  // src/services/codex-app-server.ts
32442
32465
  import path12 from "node:path";
32443
32466
  import fs11 from "node:fs/promises";
32444
- import { spawn as spawn3 } from "node:child_process";
32467
+ import { spawn as spawn3, spawnSync } from "node:child_process";
32445
32468
  function appServerSocketPath(codexHome = codexHomeDir()) {
32446
32469
  return path12.join(codexHome, "app-server-control", "app-server-control.sock");
32447
32470
  }
32448
32471
  function rpcUrl(sock) {
32449
32472
  return `ws+unix://${sock}:/rpc`;
32450
32473
  }
32474
+ function ancestryHasAppServer(startPid, getProc, maxDepth = 8) {
32475
+ let pid = startPid;
32476
+ for (let i = 0; i < maxDepth && pid > 1; i++) {
32477
+ const p = getProc(pid);
32478
+ if (!p) return false;
32479
+ if (/(?:^|\/)codex\S*\s+app-server(?:\s|$)/.test(p.cmd)) return true;
32480
+ pid = p.ppid;
32481
+ }
32482
+ return false;
32483
+ }
32484
+ function psProc(pid) {
32485
+ try {
32486
+ const out = spawnSync("ps", ["-o", "ppid=,args=", "-p", String(pid)], {
32487
+ encoding: "utf8",
32488
+ timeout: 3e3
32489
+ }).stdout?.trim();
32490
+ const m = out?.match(/^(\d+)\s+(.*)$/s);
32491
+ if (!m) return null;
32492
+ return { ppid: parseInt(m[1], 10), cmd: m[2] };
32493
+ } catch {
32494
+ return null;
32495
+ }
32496
+ }
32497
+ function runningUnderAppServerDaemon() {
32498
+ if (_underDaemon === void 0) {
32499
+ _underDaemon = ancestryHasAppServer(process.ppid, psProc);
32500
+ }
32501
+ return _underDaemon;
32502
+ }
32451
32503
  async function ensureDaemon(codexHome = codexHomeDir(), deps = {}) {
32452
32504
  if (ensuredSock) return ensuredSock;
32453
32505
  const run = deps.run ?? defaultRun;
@@ -32635,7 +32687,7 @@ async function _injectTurn(threadId, message, cwd, timeoutMs, deps = {}) {
32635
32687
  client.close();
32636
32688
  }
32637
32689
  }
32638
- var defaultWsFactory, ensuredSock, defaultRun, defaultSocketExists, sleep2, AppServerClient, idempotencyCache, IDEMPOTENCY_TTL_MS;
32690
+ var defaultWsFactory, _underDaemon, ensuredSock, defaultRun, defaultSocketExists, sleep2, AppServerClient, idempotencyCache, IDEMPOTENCY_TTL_MS;
32639
32691
  var init_codex_app_server = __esm({
32640
32692
  "src/services/codex-app-server.ts"() {
32641
32693
  "use strict";
@@ -32743,7 +32795,9 @@ var init_codex_app_server = __esm({
32743
32795
 
32744
32796
  // src/services/exec-remote.ts
32745
32797
  async function execCodexWake(sessionId, message, cwd, timeoutMs, idempotencyKey) {
32746
- if (getConfig().COGENT_CODEX_WAKE === "app-server") {
32798
+ const wake = getConfig().COGENT_CODEX_WAKE;
32799
+ const useAppServer = wake === "app-server" || wake === "auto" && runningUnderAppServerDaemon();
32800
+ if (useAppServer) {
32747
32801
  try {
32748
32802
  const sock = await ensureDaemon();
32749
32803
  const result = await execCodexViaAppServer(sessionId, message, cwd, timeoutMs, { socketPath: sock, idempotencyKey });
@@ -33963,7 +34017,7 @@ __export(startup_exports, {
33963
34017
  runStartup: () => runStartup,
33964
34018
  triggerReRegistration: () => triggerReRegistration
33965
34019
  });
33966
- import os6 from "node:os";
34020
+ import os7 from "node:os";
33967
34021
  import path13 from "node:path";
33968
34022
  import fs12 from "node:fs/promises";
33969
34023
  import readline2 from "node:readline";
@@ -34164,10 +34218,10 @@ async function runStartup() {
34164
34218
  if (envStatePath) {
34165
34219
  statePath = envStatePath;
34166
34220
  } else {
34167
- const defaultPath = path13.join(os6.homedir(), ".cogent");
34221
+ const defaultPath = path13.join(os7.homedir(), ".cogent");
34168
34222
  statePath = await firstRunPrompt(defaultPath);
34169
34223
  }
34170
- if (!envStatePath && statePath !== path13.join(os6.homedir(), ".cogent")) {
34224
+ if (!envStatePath && statePath !== path13.join(os7.homedir(), ".cogent")) {
34171
34225
  process.env.COGENT_STATE_PATH = statePath;
34172
34226
  } else if (!envStatePath) {
34173
34227
  process.env.COGENT_STATE_PATH = statePath;
@@ -34275,6 +34329,7 @@ async function runPreflights() {
34275
34329
  const config2 = getConfig();
34276
34330
  if (config2.COGENT_PLATFORM === "codex") {
34277
34331
  await preflightCodex(config2.COGENT_CODEX_PATH);
34332
+ await preflightCodexServerCollision();
34278
34333
  const sandbox = await preflightCodexSandbox(config2);
34279
34334
  if (sandbox.status === "blocked" && config2.COGENT_CODEX_SANDBOX_FALLBACK) {
34280
34335
  setSandboxOverride("bypass");
@@ -34305,7 +34360,7 @@ var init_startup = __esm({
34305
34360
  init_auto_relay();
34306
34361
  UUID_V4_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
34307
34362
  execFileAsync3 = promisify4(execFile5);
34308
- PERSIST_PATH = path13.join(os6.homedir(), ".cogent-config.json");
34363
+ PERSIST_PATH = path13.join(os7.homedir(), ".cogent-config.json");
34309
34364
  legacyWarnEmitted = false;
34310
34365
  cloudWsClient = null;
34311
34366
  cloudInbox = null;
@@ -34318,10 +34373,10 @@ var init_startup = __esm({
34318
34373
  import crypto3 from "node:crypto";
34319
34374
  import fs13 from "node:fs/promises";
34320
34375
  import path14 from "node:path";
34321
- import os7 from "node:os";
34376
+ import os8 from "node:os";
34322
34377
  function defaultMailCredentialPath(cwd = process.cwd()) {
34323
34378
  const hash = crypto3.createHash("sha256").update(path14.resolve(cwd)).digest("hex").slice(0, 16);
34324
- return path14.join(os7.homedir(), ".cogent", "mail-credentials", `${hash}.json`);
34379
+ return path14.join(os8.homedir(), ".cogent", "mail-credentials", `${hash}.json`);
34325
34380
  }
34326
34381
  function resolveMailCredentialPath(credentialPath) {
34327
34382
  if (credentialPath) return credentialPath;
@@ -36322,7 +36377,7 @@ var init_mail_fetcher = __esm({
36322
36377
  });
36323
36378
 
36324
36379
  // src/tools/fetch-mail.ts
36325
- import os8 from "node:os";
36380
+ import os9 from "node:os";
36326
36381
  import path17 from "node:path";
36327
36382
  function registerFetchMailTool(server, deps = {}) {
36328
36383
  const makeFetcher = deps.fetcherFactory ?? ((creds) => new ImapflowMailFetcher(creds));
@@ -36385,7 +36440,7 @@ var init_fetch_mail = __esm({
36385
36440
  init_mail_fetcher();
36386
36441
  init_auth_error();
36387
36442
  init_validate();
36388
- DEFAULT_DOWNLOAD_DIR = path17.join(os8.homedir(), ".cogent", "mail-downloads");
36443
+ DEFAULT_DOWNLOAD_DIR = path17.join(os9.homedir(), ".cogent", "mail-downloads");
36389
36444
  }
36390
36445
  });
36391
36446
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@essentialai/cogent-plugin",
3
- "version": "3.20.0",
3
+ "version": "3.20.2",
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",