@agentchatme/codex 0.7.0 → 0.7.1

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.
@@ -4244,7 +4244,7 @@ var init_wrapper = __esm({
4244
4244
  import { parseArgs } from "util";
4245
4245
  import * as path13 from "path";
4246
4246
 
4247
- // node_modules/.pnpm/@agentchatme+agent-core@0.7.0/node_modules/@agentchatme/agent-core/dist/chunk-C2ARQLZ7.js
4247
+ // node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/chunk-5KMQ23O6.js
4248
4248
  var import_cross_spawn = __toESM(require_cross_spawn(), 1);
4249
4249
  import { randomBytes } from "crypto";
4250
4250
  import * as fs from "fs";
@@ -4252,6 +4252,7 @@ import * as path from "path";
4252
4252
  import * as fs2 from "fs";
4253
4253
  import * as os from "os";
4254
4254
  import * as path2 from "path";
4255
+ import { spawn as nodeSpawn } from "child_process";
4255
4256
  var __defProp2 = Object.defineProperty;
4256
4257
  var __export2 = (target, all) => {
4257
4258
  for (var name in all)
@@ -4572,7 +4573,7 @@ function runSpawned(spec, captureBytes) {
4572
4573
  } catch {
4573
4574
  }
4574
4575
  };
4575
- const classify = (code, signal, note) => {
4576
+ const classify = (code, signal, note, exitedAt) => {
4576
4577
  const tail = redactDiagnostic(stderrTail);
4577
4578
  const extra = `${note ? ` (${note})` : ""}${tail ? `: ${tail}` : ""}`;
4578
4579
  if (timedOut) {
@@ -4585,9 +4586,10 @@ function runSpawned(spec, captureBytes) {
4585
4586
  if (code === 0) return note ? { state: "ok", exitCode: 0, detail: note } : { state: "ok", exitCode: 0 };
4586
4587
  const exit = code === null ? `signal ${signal ?? "unknown"}` : `exit ${code}`;
4587
4588
  if (stdoutBytes === 0) {
4588
- const ranMs = spawnedAt === null ? 0 : Date.now() - spawnedAt;
4589
+ const ranMs = spawnedAt === null ? 0 : Math.max(0, exitedAt - spawnedAt);
4589
4590
  if (spawnedAt !== null && ranMs >= notStartedWithinMs) {
4590
- return { state: "failed", exitCode: code, detail: `${exit} after ${Math.round(ranMs / 1e3)} s with nothing on stdout (it ran, then ended)${extra}` };
4591
+ const refused = tail.includes("API Error");
4592
+ return { state: "failed", ...refused ? {} : { silent: true }, exitCode: code, detail: `${exit} after ${Math.round(ranMs / 1e3)} s with nothing on stdout (it ran, then ended)${extra}` };
4591
4593
  }
4592
4594
  return { state: "not_started", exitCode: code, detail: `${exit} with nothing on stdout${extra}` };
4593
4595
  }
@@ -4598,7 +4600,8 @@ function runSpawned(spec, captureBytes) {
4598
4600
  return;
4599
4601
  }
4600
4602
  try {
4601
- child = spawnCommand(spec.command, [...spec.args], {
4603
+ const spawner = spec.shell === true ? nodeSpawn : spawnCommand;
4604
+ child = spawner(spec.command, [...spec.args], {
4602
4605
  cwd: spec.cwd,
4603
4606
  env: spec.env,
4604
4607
  stdio: [spec.stdin === null ? "ignore" : "pipe", "pipe", "pipe"],
@@ -4691,18 +4694,19 @@ function runSpawned(spec, captureBytes) {
4691
4694
  classify(
4692
4695
  exited.code,
4693
4696
  exited.signal,
4694
- process.platform === "win32" ? "a process the run started kept its output open after it exited; its children were swept (taskkill) and the run detached from it \u2014 a process the sweep cannot see can survive" : "a process the run started kept its output open after it exited; the run's process group was signalled (SIGKILL) and the run detached from it \u2014 a process that left the group can survive"
4697
+ process.platform === "win32" ? "a process the run started kept its output open after it exited; its children were swept (taskkill) and the run detached from it \u2014 a process the sweep cannot see can survive" : "a process the run started kept its output open after it exited; the run's process group was signalled (SIGKILL) and the run detached from it \u2014 a process that left the group can survive",
4698
+ exited.at
4695
4699
  )
4696
4700
  );
4697
4701
  });
4698
4702
  });
4699
4703
  proc.on("close", (code, signal) => {
4700
- finish(classify(code, signal, null));
4704
+ finish(classify(code, signal, null, exited?.at ?? Date.now()));
4701
4705
  });
4702
4706
  });
4703
4707
  }
4704
4708
 
4705
- // node_modules/.pnpm/@agentchatme+agent-core@0.7.0/node_modules/@agentchatme/agent-core/dist/chunk-NYSMAN4N.js
4709
+ // node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/chunk-AQTRC7G4.js
4706
4710
  import * as path3 from "path";
4707
4711
 
4708
4712
  // node_modules/.pnpm/agentchatme@1.5.0_ws@8.21.1/node_modules/agentchatme/dist/index.js
@@ -11691,7 +11695,7 @@ var HOUR = 60 * MIN;
11691
11695
  var DAY = 24 * HOUR;
11692
11696
  var MAX_ATTACHMENT_SIZE = 25 * 1024 * 1024;
11693
11697
 
11694
- // node_modules/.pnpm/@agentchatme+agent-core@0.7.0/node_modules/@agentchatme/agent-core/dist/chunk-NYSMAN4N.js
11698
+ // node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/chunk-AQTRC7G4.js
11695
11699
  import * as path22 from "path";
11696
11700
  import * as path32 from "path";
11697
11701
  import * as path4 from "path";
@@ -15968,6 +15972,7 @@ function writeIntegrationStatus(home, status) {
15968
15972
  log.debug(`integration status write failed: ${String(err)}`);
15969
15973
  }
15970
15974
  }
15975
+ var INTEGRATION_STATUS_STALE_MS = 3 * 6e4;
15971
15976
  function isRunnerFactory(source) {
15972
15977
  return typeof source.create === "function";
15973
15978
  }
@@ -16384,8 +16389,8 @@ function standbyWaiting(lockFile, home, now2 = Date.now()) {
16384
16389
  return false;
16385
16390
  }
16386
16391
 
16387
- // node_modules/.pnpm/@agentchatme+agent-core@0.7.0/node_modules/@agentchatme/agent-core/dist/chunk-PTKQIKCI.js
16388
- var VERSION2 = "0.7.0";
16392
+ // node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/chunk-4PCDVXAR.js
16393
+ var VERSION2 = "0.7.1";
16389
16394
  var HOSTED_MCP_PATH2 = integration_exports.HOSTED_MCP_PATH;
16390
16395
  function hostedMcpUrl2(apiBase) {
16391
16396
  return integration_exports.hostedMcpUrl(apiBase);
@@ -16452,7 +16457,7 @@ function runProbe(command, args, options) {
16452
16457
  });
16453
16458
  }
16454
16459
 
16455
- // node_modules/.pnpm/@agentchatme+agent-core@0.7.0/node_modules/@agentchatme/agent-core/dist/index.js
16460
+ // node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/index.js
16456
16461
  var StateSchema = external_exports.object({
16457
16462
  // Set when the user has said "not now" to setting up a handle. PERMANENT
16458
16463
  // until they change their mind, because the prompt that needs suppressing
@@ -16471,7 +16476,7 @@ var MARKER_LINES = /* @__PURE__ */ new Set([
16471
16476
  var UTF8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
16472
16477
  var NO_TEXTS = Object.freeze({ identityLine: null, identityLineTemplate: null, manual: null });
16473
16478
 
16474
- // node_modules/.pnpm/@agentchatme+agent-core@0.7.0/node_modules/@agentchatme/agent-core/dist/daemon-entry.js
16479
+ // node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/daemon-entry.js
16475
16480
  import * as path23 from "path";
16476
16481
  import * as fs3 from "fs";
16477
16482
  import * as path9 from "path";
@@ -16911,14 +16916,15 @@ ${this.options.manualPointer}` : request.prompt,
16911
16916
  }
16912
16917
  if (outcome.state !== "ok") {
16913
16918
  log.warn(
16914
- `run ${outcome.state} ${subject}${outcome.detail ? `: ${outcome.detail}` : ""} \u2014 ${kind === "conversation" ? "its card stays on the tray; if the runtime otherwise works, the failure is reported (could not process) and the server decides what follows" : "the cards stay on the tray; the next wake (or the server's re-wake) finds them"}`
16919
+ `run ${outcome.state} ${subject}${outcome.detail ? `: ${outcome.detail}` : ""} \u2014 ${kind !== "conversation" ? "the cards stay on the tray; the next wake (or the server's re-wake) finds them" : outcome.state === "failed" && outcome.silent === true ? "its card stays on the tray; a silent failure counts as a timeout: it is reported (could not process) only once another conversation's run completes, and the server decides what follows" : "its card stays on the tray; if the runtime otherwise works, the failure is reported (could not process) and the server decides what follows"}`
16915
16920
  );
16916
16921
  }
16917
16922
  this.noteRunHealth(outcome, this.lastRun.ended_at);
16918
16923
  this.writeStatus();
16919
16924
  if (outcome.state === "ok") return { status: "completed" };
16920
16925
  if (outcome.state === "not_started") return { status: "not_started", ...outcome.detail !== void 0 ? { detail: outcome.detail } : {} };
16921
- return { status: "failed", ...outcome.state === "timed_out" ? { timedOut: true } : {}, ...outcome.detail !== void 0 ? { detail: outcome.detail } : {} };
16926
+ const timedOut = outcome.state === "timed_out" || outcome.state === "failed" && outcome.silent === true;
16927
+ return { status: "failed", ...timedOut ? { timedOut: true } : {}, ...outcome.detail !== void 0 ? { detail: outcome.detail } : {} };
16922
16928
  }
16923
16929
  /**
16924
16930
  * The runner's runtime check (a minimal model call, no peer content, no
@@ -17095,7 +17101,7 @@ ${this.options.manualPointer}` : request.prompt,
17095
17101
  if (result === null) {
17096
17102
  log.warn(`could not process: ${what} \u2014 the report failed (${event.error ?? "no detail"}); nothing more is done for it now: its card stays on the tray and the server re-wakes it`);
17097
17103
  } else {
17098
- const hidden = result.hidden_message_ids.length;
17104
+ const hidden = result.hidden_count ?? result.hidden_message_ids.length;
17099
17105
  const answered = result.action === "retry" ? "retry (the first failure for these messages)" : result.action === "hidden" ? `hidden (${hidden} message(s) are now a note for this agent, still unread)` : result.action === "paused" ? `paused until ${result.paused_until ?? "?"}${hidden > 0 ? ` (${hidden} more message(s) hidden)` : ""} \u2014 no run starts there until then` : "none (nothing left to act on)";
17100
17106
  const next = event.next === "rerun" ? "it runs again after the others" : event.next === "running" ? "its next run is under way already" : event.next === "rerun_capped" ? "not run again in this cycle (3 re-runs already); the server re-wakes it" : "nothing more for it";
17101
17107
  (result.action === "paused" ? log.warn : log.info)(`could not process: ${what} \u2192 server: ${answered}; ${next}`);
@@ -17469,7 +17475,7 @@ import * as os3 from "os";
17469
17475
  import * as path10 from "path";
17470
17476
 
17471
17477
  // src/version.ts
17472
- var VERSION3 = "0.7.0";
17478
+ var VERSION3 = "0.7.1";
17473
17479
 
17474
17480
  // src/host.ts
17475
17481
  function codexHome() {
@@ -17501,7 +17507,7 @@ var CLIENT = { runtime: "codex", version: VERSION3 };
17501
17507
  var MCP_SERVER_NAME = "agentchat";
17502
17508
  var API_KEY_ENV = "AGENTCHAT_API_KEY";
17503
17509
 
17504
- // node_modules/.pnpm/@agentchatme+agent-core@0.7.0/node_modules/@agentchatme/agent-core/dist/presets.js
17510
+ // node_modules/.pnpm/@agentchatme+agent-core@0.7.1/node_modules/@agentchatme/agent-core/dist/presets.js
17505
17511
  import * as fs22 from "fs";
17506
17512
  import * as os4 from "os";
17507
17513
  import * as path11 from "path";
@@ -17835,8 +17841,18 @@ function claudeProfileArgs(profile, workdir) {
17835
17841
  }
17836
17842
  var RUNTIME_CHECK_SETTINGS = JSON.stringify({
17837
17843
  env: { CLAUDE_CODE_DISABLE_CLAUDE_MDS: "1", CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" },
17838
- disableAllHooks: true
17844
+ disableAllHooks: true,
17845
+ verbose: false,
17846
+ viewMode: "default",
17847
+ language: "english"
17839
17848
  });
17849
+ function lastResultMessage(messages) {
17850
+ for (let i = messages.length - 1; i >= 0; i -= 1) {
17851
+ const m = messages[i];
17852
+ if (m !== null && typeof m === "object" && !Array.isArray(m) && m["type"] === "result") return m;
17853
+ }
17854
+ return null;
17855
+ }
17840
17856
  function claudeRuntimeCheckJudge(stdout) {
17841
17857
  const text2 = stdout.trim();
17842
17858
  let parsed = null;
@@ -17848,9 +17864,22 @@ function claudeRuntimeCheckJudge(stdout) {
17848
17864
  parsed = null;
17849
17865
  }
17850
17866
  }
17867
+ if (Array.isArray(parsed)) {
17868
+ parsed = lastResultMessage(parsed);
17869
+ if (parsed === null) return "its answer is a list of messages with no result";
17870
+ }
17851
17871
  if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return "its answer is not a JSON result";
17852
17872
  const r = parsed;
17853
- if (r["type"] === "result" && r["subtype"] === "success" && r["is_error"] === false) return null;
17873
+ if (r["type"] === "result" && r["subtype"] === "success" && r["is_error"] === false) {
17874
+ const turns = r["num_turns"];
17875
+ if (typeof turns !== "number" || !(turns >= 1)) return `the result has no turn (num_turns ${typeof turns === "number" ? turns : "?"})`;
17876
+ const usage = r["usage"];
17877
+ if (usage !== void 0 && usage !== null) {
17878
+ const tokens = typeof usage === "object" && !Array.isArray(usage) ? usage["output_tokens"] : void 0;
17879
+ if (typeof tokens !== "number" || !(tokens >= 1)) return `the result has no output (usage.output_tokens ${typeof tokens === "number" ? tokens : "?"})`;
17880
+ }
17881
+ return null;
17882
+ }
17854
17883
  const facts = [
17855
17884
  `type ${typeof r["type"] === "string" ? r["type"] : "?"}`,
17856
17885
  `subtype ${typeof r["subtype"] === "string" ? r["subtype"] : "?"}`,
@@ -18336,8 +18365,6 @@ function codexRuntimeCheckArgs(dir, agentchatUrl) {
18336
18365
  "--sandbox",
18337
18366
  "read-only",
18338
18367
  "-c",
18339
- 'model_reasoning_effort="low"',
18340
- "-c",
18341
18368
  'web_search="disabled"',
18342
18369
  ...CODEX_RUNTIME_CHECK_DISABLED_FEATURES.flatMap((feature) => ["--disable", feature]),
18343
18370
  ...agentchatUrl !== void 0 ? ["-c", `${table}.url=${JSON.stringify(agentchatUrl)}`] : [],
@@ -18349,6 +18376,37 @@ function codexRuntimeCheckArgs(dir, agentchatUrl) {
18349
18376
  function codexRuntimeCheckWorkdir(codexHome2) {
18350
18377
  return path24.join(codexHome2, RUNTIME_CHECK_DIR);
18351
18378
  }
18379
+ function jsonObject(value) {
18380
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
18381
+ }
18382
+ function codexRuntimeCheckJudge(stdout) {
18383
+ let events = 0;
18384
+ let completed = false;
18385
+ let failed = false;
18386
+ let answered = false;
18387
+ for (const line of stdout.split(/\r?\n/)) {
18388
+ if (line.trim().length === 0) continue;
18389
+ let event;
18390
+ try {
18391
+ event = jsonObject(JSON.parse(line));
18392
+ } catch {
18393
+ continue;
18394
+ }
18395
+ if (event === null) continue;
18396
+ events += 1;
18397
+ if (event["type"] === "turn.completed") completed = true;
18398
+ else if (event["type"] === "turn.failed") failed = true;
18399
+ else if (event["type"] === "item.completed") {
18400
+ const item = jsonObject(event["item"]);
18401
+ if (item !== null && item["type"] === "agent_message" && typeof item["text"] === "string" && item["text"].trim().length > 0) answered = true;
18402
+ }
18403
+ }
18404
+ if (events === 0) return "its answer holds no JSON event";
18405
+ if (failed) return "the turn failed (turn.failed)";
18406
+ if (!completed) return "the turn did not complete (no turn.completed)";
18407
+ if (!answered) return "the turn completed with no agent message";
18408
+ return null;
18409
+ }
18352
18410
  function codexClientHeadersToml(clientVersion = VERSION2) {
18353
18411
  const pairs = Object.entries(clientHeadersOf({ runtime: "codex", version: clientVersion })).map(([name, value]) => `${JSON.stringify(name)} = ${JSON.stringify(value)}`);
18354
18412
  return `{ ${pairs.join(", ")} }`;
@@ -18674,9 +18732,11 @@ var CodexRunner = class {
18674
18732
  /**
18675
18733
  * Does the model answer right now, through this runner's binary, sign-in,
18676
18734
  * CODEX_HOME and environment? One `codex exec` with a fixed prompt in its
18677
- * own empty folder, read-only, with the hosted AgentChat server switched off
18678
- * (`codexRuntimeCheckArgs`) and no key in its environment. Its output is
18679
- * discarded. Never throws.
18735
+ * own empty folder, read-only, with the hosted AgentChat server switched
18736
+ * off and the user's hooks on, as in the runs (`codexRuntimeCheckArgs`),
18737
+ * and no key in its environment; ok only on exit 0 with a completed turn
18738
+ * that holds an agent message (`codexRuntimeCheckJudge`). Its output is
18739
+ * read for that alone and never logged. Never throws.
18680
18740
  */
18681
18741
  async checkRuntime(options = {}) {
18682
18742
  if (this.options.refuse !== void 0) return { ok: false, detail: this.options.refuse };
@@ -18689,6 +18749,8 @@ var CodexRunner = class {
18689
18749
  // The runs' environment; runRuntimeCheck takes every key variable out, this runner's own included.
18690
18750
  env: this.env(),
18691
18751
  keyEnv: this.options.keyEnv,
18752
+ // Exit 0 is not enough: the events must show a completed turn with the model's answer.
18753
+ judge: codexRuntimeCheckJudge,
18692
18754
  ...options.signal !== void 0 ? { signal: options.signal } : {}
18693
18755
  });
18694
18756
  }