@agentchatme/agent-core 0.5.3 → 0.7.0

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/dist/presets.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  VERSION,
3
3
  hostedMcpUrl,
4
4
  runProbe
5
- } from "./chunk-JL2L4WRG.js";
5
+ } from "./chunk-PTKQIKCI.js";
6
6
  import {
7
7
  atomicWriteFile,
8
8
  clientHeadersOf,
@@ -11,11 +11,12 @@ import {
11
11
  redactDiagnostic,
12
12
  spawnCommand,
13
13
  spawnRun,
14
+ spawnRunCapturing,
14
15
  workdirExposesHome
15
- } from "./chunk-3OUDKIQV.js";
16
+ } from "./chunk-C2ARQLZ7.js";
16
17
 
17
18
  // src/presets/claude-code.ts
18
- import * as fs from "fs";
19
+ import * as fs2 from "fs";
19
20
  import * as os from "os";
20
21
  import * as path from "path";
21
22
 
@@ -34,6 +35,41 @@ function semverAtLeast(actual, minimum) {
34
35
  return true;
35
36
  }
36
37
 
38
+ // src/presets/runtime-check.ts
39
+ import * as fs from "fs";
40
+ var RUNTIME_CHECK_PROMPT = "Reply with the single word OK.";
41
+ var RUNTIME_CHECK_BUDGET_MS = 45e3;
42
+ var RUNTIME_CHECK_OUTPUT_BYTES = 128 * 1024;
43
+ var RUNTIME_CHECK_DIR = "agentchat-runtime-check";
44
+ var RUNTIME_CHECK_KEY_ENV = ["AGENTCHAT_API_KEY", "AGENTCHAT_LISTENER_API_KEY"];
45
+ function withoutKeys(env, also) {
46
+ const names = new Set([...RUNTIME_CHECK_KEY_ENV, ...also].map((name) => name.toUpperCase()));
47
+ const out = {};
48
+ for (const [key, value] of Object.entries(env)) if (!names.has(key.toUpperCase())) out[key] = value;
49
+ return out;
50
+ }
51
+ async function runRuntimeCheck(spec) {
52
+ if (spec.signal?.aborted === true) return { ok: false, detail: `${spec.label} runtime check: stopped before it started` };
53
+ try {
54
+ fs.mkdirSync(spec.cwd, { recursive: true, mode: 448 });
55
+ } catch (err) {
56
+ return { ok: false, detail: `${spec.label} runtime check: could not create its folder ${spec.cwd}: ${err instanceof Error ? err.message : String(err)}` };
57
+ }
58
+ const { outcome, stdout } = await spawnRunCapturing({
59
+ command: spec.command,
60
+ args: spec.args,
61
+ cwd: spec.cwd,
62
+ env: withoutKeys(spec.env, spec.keyEnv !== void 0 ? [spec.keyEnv] : []),
63
+ stdin: RUNTIME_CHECK_PROMPT,
64
+ budgetMs: spec.budgetMs ?? RUNTIME_CHECK_BUDGET_MS,
65
+ requireStdout: true,
66
+ ...spec.signal !== void 0 ? { signal: spec.signal } : {}
67
+ }, spec.judge !== void 0 ? RUNTIME_CHECK_OUTPUT_BYTES : 0);
68
+ if (outcome.state !== "ok") return { ok: false, detail: `${spec.label} runtime check ${outcome.state.replace("_", " ")}${outcome.detail ? `: ${outcome.detail}` : ""}` };
69
+ const verdict = spec.judge === void 0 ? null : spec.judge(stdout);
70
+ return verdict === null ? { ok: true } : { ok: false, detail: `${spec.label} runtime check failed: exit 0, but ${verdict}` };
71
+ }
72
+
37
73
  // src/presets/types.ts
38
74
  var CLAUDE_CODE_ENV_KEPT = [
39
75
  // Sign-in and provider
@@ -249,7 +285,7 @@ async function claudeSignIn(configDirOverride, command = "claude", timeoutMs = P
249
285
  if (status.status === 0) return { signedIn: true, unanswered: null };
250
286
  }
251
287
  const configDir = claudeHomeFor(configDirOverride);
252
- if (fs.existsSync(path.join(configDir, ".credentials.json"))) return { signedIn: true, unanswered: null };
288
+ if (fs2.existsSync(path.join(configDir, ".credentials.json"))) return { signedIn: true, unanswered: null };
253
289
  if (process.platform !== "darwin") return { signedIn: false, unanswered: null };
254
290
  const keychain = await runProbe("security", ["find-generic-password", "-s", "Claude Code-credentials"], { timeoutMs: Math.min(timeoutMs, 5e3), ...signal !== void 0 ? { signal } : {} });
255
291
  return { signedIn: !keychain.error && keychain.status === 0, unanswered: null };
@@ -284,7 +320,7 @@ function workdirPaths(workdir) {
284
320
  const given = path.resolve(workdir);
285
321
  let real = given;
286
322
  try {
287
- real = fs.realpathSync(given);
323
+ real = fs2.realpathSync(given);
288
324
  } catch {
289
325
  }
290
326
  return real === given ? [given] : [given, real];
@@ -301,6 +337,10 @@ function workdirReadRules(workdir) {
301
337
  }
302
338
  function claudeProfileArgs(profile, workdir) {
303
339
  switch (profile) {
340
+ // The agent itself: the user's own settings decide; AgentChat's tools are
341
+ // pre-approved and nothing waits on a prompt (see the header).
342
+ case "own":
343
+ return ["--permission-prompts", "none", "--allowedTools", AGENTCHAT_TOOL_ALLOW];
304
344
  case "answer":
305
345
  return [
306
346
  "--permission-mode",
@@ -329,6 +369,55 @@ function claudeProfileArgs(profile, workdir) {
329
369
  return ["--dangerously-skip-permissions", "--permission-prompts", "none", "--allowedTools", AGENTCHAT_TOOL_ALLOW];
330
370
  }
331
371
  }
372
+ var RUNTIME_CHECK_SETTINGS = JSON.stringify({
373
+ env: { CLAUDE_CODE_DISABLE_CLAUDE_MDS: "1", CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" },
374
+ disableAllHooks: true
375
+ });
376
+ function claudeRuntimeCheckJudge(stdout) {
377
+ const text = stdout.trim();
378
+ let parsed = null;
379
+ for (const candidate of [text, text.split(/\r?\n/).filter((line) => line.trim().length > 0).at(-1) ?? ""]) {
380
+ try {
381
+ parsed = JSON.parse(candidate);
382
+ break;
383
+ } catch {
384
+ parsed = null;
385
+ }
386
+ }
387
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return "its answer is not a JSON result";
388
+ const r = parsed;
389
+ if (r["type"] === "result" && r["subtype"] === "success" && r["is_error"] === false) return null;
390
+ const facts = [
391
+ `type ${typeof r["type"] === "string" ? r["type"] : "?"}`,
392
+ `subtype ${typeof r["subtype"] === "string" ? r["subtype"] : "?"}`,
393
+ `is_error ${typeof r["is_error"] === "boolean" ? String(r["is_error"]) : "?"}`,
394
+ ...typeof r["api_error_status"] === "number" ? [`api_error_status ${r["api_error_status"]}`] : [],
395
+ ...typeof r["terminal_reason"] === "string" && /^[a-z_]{1,40}$/.test(r["terminal_reason"]) ? [`terminal_reason ${r["terminal_reason"]}`] : []
396
+ ];
397
+ return `the result is not a success (${facts.join(", ")})`;
398
+ }
399
+ function claudeRuntimeCheckArgs(denyReadPaths = []) {
400
+ const deny = readDenyRules(denyReadPaths);
401
+ return [
402
+ "-p",
403
+ "--output-format",
404
+ "json",
405
+ "--no-session-persistence",
406
+ // No --mcp-config: with this flag, no MCP server loads at all.
407
+ "--strict-mcp-config",
408
+ // Variadic; "" is none (`claude --help`). Closed by the option after it.
409
+ "--tools",
410
+ "",
411
+ "--permission-prompts",
412
+ "none",
413
+ "--settings",
414
+ RUNTIME_CHECK_SETTINGS,
415
+ ...deny.length > 0 ? ["--disallowedTools", deny.join(",")] : []
416
+ ];
417
+ }
418
+ function claudeRuntimeCheckWorkdir(configDirOverride) {
419
+ return path.join(claudeHomeFor(configDirOverride), RUNTIME_CHECK_DIR);
420
+ }
332
421
  function expressible(raw) {
333
422
  return raw.startsWith("/") && !/[,\s]/.test(raw);
334
423
  }
@@ -356,8 +445,9 @@ function claudeRunArgs(profile, options = {}) {
356
445
  // session list and off the disk.
357
446
  "--no-session-persistence",
358
447
  ...budget !== void 0 && /^\d+(\.\d+)?$/.test(budget) ? ["--max-budget-usd", budget] : [],
359
- // Variadic, so it is closed by the boolean flag right after it.
360
- ...options.mcpConfigPath !== void 0 ? ["--mcp-config", options.mcpConfigPath, "--strict-mcp-config"] : [],
448
+ // Variadic, so it is closed by the option right after it. `own` keeps the
449
+ // user's other servers: the file's `agentchat` wins over theirs by name.
450
+ ...options.mcpConfigPath !== void 0 ? ["--mcp-config", options.mcpConfigPath, ...profile === "own" ? [] : ["--strict-mcp-config"]] : [],
361
451
  ...options.appendSystemPromptFile !== void 0 ? ["--append-system-prompt-file", options.appendSystemPromptFile] : [],
362
452
  ...claudeProfileArgs(profile, options.workdir),
363
453
  // Last: the option is variadic and the prompt arrives on stdin, so there
@@ -382,7 +472,7 @@ function claudeManagedSettingsDir(platform = process.platform) {
382
472
  function gitRootOf(dir) {
383
473
  let current = path.resolve(dir);
384
474
  for (; ; ) {
385
- if (fs.existsSync(path.join(current, ".git"))) return current;
475
+ if (fs2.existsSync(path.join(current, ".git"))) return current;
386
476
  const parent = path.dirname(current);
387
477
  if (parent === current) return null;
388
478
  current = parent;
@@ -392,7 +482,7 @@ function claudeSettingsFilesGrantingDirectories(configDirOverride, workdir) {
392
482
  const managed = claudeManagedSettingsDir();
393
483
  const dropIns = (() => {
394
484
  try {
395
- return fs.readdirSync(path.join(managed, "managed-settings.d")).filter((name) => name.endsWith(".json") && !name.startsWith(".")).sort().map((name) => path.join(managed, "managed-settings.d", name));
485
+ return fs2.readdirSync(path.join(managed, "managed-settings.d")).filter((name) => name.endsWith(".json") && !name.startsWith(".")).sort().map((name) => path.join(managed, "managed-settings.d", name));
396
486
  } catch {
397
487
  return [];
398
488
  }
@@ -411,7 +501,7 @@ function claudeExtraDirectoriesGrant(configDirOverride, workdir) {
411
501
  for (const file of claudeSettingsFilesGrantingDirectories(configDirOverride, workdir)) {
412
502
  let text;
413
503
  try {
414
- text = fs.readFileSync(file, "utf-8");
504
+ text = fs2.readFileSync(file, "utf-8");
415
505
  } catch {
416
506
  continue;
417
507
  }
@@ -433,6 +523,9 @@ function extraDirectoriesRefusal(grant) {
433
523
  function claudeAnswerFallbackWorkdir(configDirOverride) {
434
524
  return path.join(claudeHomeFor(configDirOverride), "agentchat-answer-workdir");
435
525
  }
526
+ function guardsHomeWorkdir(profile) {
527
+ return profile === "answer" || profile === "own";
528
+ }
436
529
  var ClaudeRunner = class _ClaudeRunner {
437
530
  constructor(options) {
438
531
  this.options = options;
@@ -440,6 +533,7 @@ var ClaudeRunner = class _ClaudeRunner {
440
533
  }
441
534
  options;
442
535
  name = "claude";
536
+ label = "Claude Code";
443
537
  command;
444
538
  /** The workdir warning is one line per process, not one per preflight (preflight repeats every few minutes). */
445
539
  warnedWorkdir = false;
@@ -447,11 +541,11 @@ var ClaudeRunner = class _ClaudeRunner {
447
541
  warnedHome = false;
448
542
  /**
449
543
  * Where this runner's runs work: the configured workdir, except that an
450
- * `answer` run never works in the home folder or above it — it gets
544
+ * `own` or `answer` run never works in the home folder or above it — it gets
451
545
  * `claudeAnswerFallbackWorkdir` (its readable folder would be the whole home).
452
546
  */
453
547
  workdir() {
454
- if (this.options.profile === "answer" && workdirExposesHome(this.options.workdir)) return claudeAnswerFallbackWorkdir(this.options.configDir);
548
+ if (guardsHomeWorkdir(this.options.profile) && workdirExposesHome(this.options.workdir)) return claudeAnswerFallbackWorkdir(this.options.configDir);
455
549
  return this.options.workdir;
456
550
  }
457
551
  /** The denied path the workdir sits in, or null when the run can read its own cwd. */
@@ -479,7 +573,7 @@ var ClaudeRunner = class _ClaudeRunner {
479
573
  }
480
574
  if (this.workdir() !== this.options.workdir && !this.warnedHome) {
481
575
  this.warnedHome = true;
482
- log.warn(`the run workdir ${this.options.workdir} is your home folder or contains it: answer runs work in ${this.workdir()} instead, so a peer-started run reads none of your files there. Point the workdir at a folder of its own to choose another.`);
576
+ log.warn(`the run workdir ${this.options.workdir} is your home folder or contains it: ${this.options.profile} runs work in ${this.workdir()} instead, so a peer-started run reads none of your files there. Point the workdir at a folder of its own to choose another.`);
483
577
  }
484
578
  const denied = this.workdirDeniedBy();
485
579
  if (denied !== null && !this.warnedWorkdir) {
@@ -497,10 +591,10 @@ var ClaudeRunner = class _ClaudeRunner {
497
591
  log.warn(`${why}: runs can read those paths.`);
498
592
  }
499
593
  }
500
- if (this.options.mcpConfigPath !== void 0 && !fs.existsSync(this.options.mcpConfigPath)) {
594
+ if (this.options.mcpConfigPath !== void 0 && !fs2.existsSync(this.options.mcpConfigPath)) {
501
595
  return { ok: false, detail: `the hosted tool config ${this.options.mcpConfigPath} is missing` };
502
596
  }
503
- fs.mkdirSync(this.workdir(), { recursive: true, mode: 448 });
597
+ fs2.mkdirSync(this.workdir(), { recursive: true, mode: 448 });
504
598
  return { ok: true };
505
599
  }
506
600
  /** `<dir>/<stem>.<run id><ext>`: a file of this run's own beside `file` (the run id reduced to letters, digits and `-`). */
@@ -509,12 +603,17 @@ var ClaudeRunner = class _ClaudeRunner {
509
603
  const id = runId.replace(/[^A-Za-z0-9-]/g, "").slice(0, 64) || "run";
510
604
  return path.join(path.dirname(file), `${stem}.${id}${ext}`);
511
605
  }
512
- /** The answer run's own files for `runId`: its AgentChat-only tool config (integration path) and its identity-line file. */
513
- answerRunFiles(runId) {
514
- if (this.options.profile !== "answer") return {};
606
+ /**
607
+ * A run's own files for `runId`: an answer run's AgentChat-only tool config
608
+ * (integration path), and the identity-line file of an answer or own run.
609
+ * `work` and `full` write none (they load CLAUDE.md, as before).
610
+ */
611
+ runFiles(runId) {
612
+ const profile = this.options.profile;
613
+ if (profile !== "answer" && profile !== "own") return {};
515
614
  const base = this.options.mcpConfigPath ?? this.options.answerMcp?.file;
516
615
  return {
517
- ...this.options.mcpConfigPath === void 0 && this.options.answerMcp !== void 0 ? { mcpConfigPath: _ClaudeRunner.perRun(this.options.answerMcp.file, runId, ".json") } : {},
616
+ ...profile === "answer" && this.options.mcpConfigPath === void 0 && this.options.answerMcp !== void 0 ? { mcpConfigPath: _ClaudeRunner.perRun(this.options.answerMcp.file, runId, ".json") } : {},
518
617
  ...base !== void 0 ? { identityFile: _ClaudeRunner.perRun(base, runId, ".identity.md") } : {}
519
618
  };
520
619
  }
@@ -540,22 +639,50 @@ var ClaudeRunner = class _ClaudeRunner {
540
639
  }
541
640
  /**
542
641
  * The argv of a run — exported for tests to pin per profile. With a `runId`,
543
- * that run's own files (an answer run's tool config and identity-line file);
544
- * without, the configured `answerMcp.file` stands in and no identity file.
642
+ * that run's own files (an answer run's tool config, an answer or own run's
643
+ * identity-line file); without, the configured `answerMcp.file` stands in
644
+ * for an answer run's tool config, and no identity file.
545
645
  */
546
646
  args(runId, identityLine) {
547
647
  if (runId === void 0) {
548
648
  const mcpConfigPath = this.options.mcpConfigPath ?? (this.options.profile === "answer" ? this.options.answerMcp?.file : void 0);
549
649
  return this.argsFor(mcpConfigPath, void 0);
550
650
  }
551
- const files = this.answerRunFiles(runId);
651
+ const files = this.runFiles(runId);
552
652
  return this.argsFor(files.mcpConfigPath ?? this.options.mcpConfigPath, identityLine === true ? files.identityFile : void 0);
553
653
  }
554
- /** The run's environment: no parent session; an answer run loads no CLAUDE.md and no auto memory (`ANSWER_ENV`). */
654
+ /**
655
+ * The run's environment: no parent session; an answer run loads no CLAUDE.md
656
+ * and no auto memory (`ANSWER_ENV`); an own run carries no `AGENTCHAT_API_KEY`
657
+ * the daemon inherited — it has the user's own shell, and it reaches the
658
+ * hosted tools through its MCP entry, never through that variable.
659
+ */
555
660
  runEnv() {
556
- const env = buildClaudeEnv(this.options.configDir, this.options.env ?? process.env);
661
+ const source = this.options.env ?? process.env;
662
+ const env = buildClaudeEnv(this.options.configDir, this.options.profile === "own" ? withoutInheritedKey(source) : source);
557
663
  return this.options.profile === "answer" ? { ...env, ...ANSWER_ENV } : env;
558
664
  }
665
+ /**
666
+ * Does the model answer right now, through this runner's binary, sign-in
667
+ * and environment? One `claude -p` with a fixed prompt and no tool at all
668
+ * (`claudeRuntimeCheckArgs`), in its own empty folder, with no key in its
669
+ * environment and no instruction file or memory in its context; ok only
670
+ * when its JSON result says success with no error (`claudeRuntimeCheckJudge`).
671
+ * Its output is read for that alone and never logged. Never throws.
672
+ */
673
+ async checkRuntime(options = {}) {
674
+ return runRuntimeCheck({
675
+ label: "claude",
676
+ command: this.command,
677
+ args: claudeRuntimeCheckArgs(this.readDenyPaths()),
678
+ cwd: claudeRuntimeCheckWorkdir(this.options.configDir),
679
+ // No key (runRuntimeCheck takes every key variable out); no instruction file or memory.
680
+ env: { ...this.runEnv(), ...ANSWER_ENV },
681
+ // Exit 0 is not enough: the JSON result must say success with no error.
682
+ judge: claudeRuntimeCheckJudge,
683
+ ...options.signal !== void 0 ? { signal: options.signal } : {}
684
+ });
685
+ }
559
686
  async start(request) {
560
687
  const startedAt = Date.now();
561
688
  const notStarted = (detail) => ({ state: "not_started", exitCode: null, durationMs: Date.now() - startedAt, detail });
@@ -568,11 +695,11 @@ var ClaudeRunner = class _ClaudeRunner {
568
695
  const grant = claudeExtraDirectoriesGrant(this.options.configDir, this.workdir());
569
696
  if (grant !== null) return notStarted(extraDirectoriesRefusal(grant));
570
697
  }
571
- const files = this.answerRunFiles(request.runId);
572
- const identityFile = answer && request.identityLine !== void 0 ? files.identityFile : void 0;
698
+ const files = this.runFiles(request.runId);
699
+ const identityFile = request.identityLine !== void 0 ? files.identityFile : void 0;
573
700
  const written = [];
574
701
  const cleanup = () => {
575
- for (const file of written) fs.rmSync(file, { force: true });
702
+ for (const file of written) fs2.rmSync(file, { force: true });
576
703
  };
577
704
  if (answerMcp !== void 0 && files.mcpConfigPath !== void 0) {
578
705
  const key = answerMcp.apiKey();
@@ -592,12 +719,12 @@ var ClaudeRunner = class _ClaudeRunner {
592
719
  written.push(identityFile);
593
720
  } catch (err) {
594
721
  cleanup();
595
- return notStarted(`could not write the answer run's identity line ${identityFile}: ${err instanceof Error ? err.message : String(err)}`);
722
+ return notStarted(`could not write the run's identity line ${identityFile}: ${err instanceof Error ? err.message : String(err)}`);
596
723
  }
597
724
  }
598
725
  try {
599
726
  const args = this.argsFor(files.mcpConfigPath ?? this.options.mcpConfigPath, identityFile);
600
- log.debug(`claude ${args.join(" ")} (prompt on stdin, ${request.kind} run ${request.runId})`);
727
+ log.debug(`claude ${args.join(" ")} (prompt on stdin, ${request.kind} run ${request.runId}${request.conversationId !== void 0 ? ` for ${request.conversationId}` : ""})`);
601
728
  return await spawnRun({
602
729
  command: this.command,
603
730
  args,
@@ -621,10 +748,10 @@ function claudeMcpConfigPath(home) {
621
748
  }
622
749
  var claudeCodePreset = {
623
750
  name: CLAUDE_CODE_PRESET,
624
- describeMcp({ home, apiBase }) {
751
+ describeMcp({ home, apiBase, profile }) {
625
752
  return [
626
753
  `--mcp-config ${claudeMcpConfigPath(home)} (owner-only): ${CLAUDE_MCP_SERVER_NAME} \u2192 ${hostedMcpUrl(apiBase)}, Authorization: Bearer <this home's key>, X-AgentChat-Client: claude-code`,
627
- "--strict-mcp-config: no other MCP server (user, project or plugin) is loaded in these runs"
754
+ profile === "own" ? `own: your other MCP servers load too (the file is not made the only one); this file's ${CLAUDE_MCP_SERVER_NAME} is used in place of a user-scope ${CLAUDE_MCP_SERVER_NAME} (verified); a project- or local-scope one is not covered` : "--strict-mcp-config: no other MCP server (user, project or plugin) is loaded in these runs"
628
755
  ];
629
756
  },
630
757
  label: "Claude Code",
@@ -664,7 +791,7 @@ var claudeCodePreset = {
664
791
  };
665
792
 
666
793
  // src/presets/codex.ts
667
- import * as fs2 from "fs";
794
+ import * as fs3 from "fs";
668
795
  import * as os2 from "os";
669
796
  import * as path2 from "path";
670
797
  var CODEX_PRESET = "codex";
@@ -709,6 +836,9 @@ var CODEX_ANSWER_DISABLED_FEATURES = [
709
836
  ];
710
837
  function codexProfileArgs(profile) {
711
838
  switch (profile) {
839
+ // The agent itself: nothing but the run's shape (see the header).
840
+ case "own":
841
+ return [];
712
842
  case "answer":
713
843
  return [
714
844
  "-c",
@@ -734,6 +864,32 @@ function codexProfileArgs(profile) {
734
864
  return ["--dangerously-bypass-approvals-and-sandbox"];
735
865
  }
736
866
  }
867
+ var CODEX_RUNTIME_CHECK_DISABLED_FEATURES = ["memories", "plugins", "apps"];
868
+ function codexRuntimeCheckArgs(dir, agentchatUrl) {
869
+ const table = `mcp_servers.${CODEX_MCP_SERVER_NAME}`;
870
+ return [
871
+ "exec",
872
+ "--json",
873
+ "--skip-git-repo-check",
874
+ "--ephemeral",
875
+ "-C",
876
+ dir,
877
+ "--sandbox",
878
+ "read-only",
879
+ "-c",
880
+ 'model_reasoning_effort="low"',
881
+ "-c",
882
+ 'web_search="disabled"',
883
+ ...CODEX_RUNTIME_CHECK_DISABLED_FEATURES.flatMap((feature) => ["--disable", feature]),
884
+ ...agentchatUrl !== void 0 ? ["-c", `${table}.url=${JSON.stringify(agentchatUrl)}`] : [],
885
+ "-c",
886
+ `${table}.enabled=false`,
887
+ CODEX_PROMPT_FROM_STDIN
888
+ ];
889
+ }
890
+ function codexRuntimeCheckWorkdir(codexHome) {
891
+ return path2.join(codexHome, RUNTIME_CHECK_DIR);
892
+ }
737
893
  function codexClientHeadersToml(clientVersion = VERSION) {
738
894
  const pairs = Object.entries(clientHeadersOf({ runtime: "codex", version: clientVersion })).map(([name, value]) => `${JSON.stringify(name)} = ${JSON.stringify(value)}`);
739
895
  return `{ ${pairs.join(", ")} }`;
@@ -747,7 +903,7 @@ function codexMcpOverrideArgs(override) {
747
903
  "-c",
748
904
  `${table}.url=${JSON.stringify(override.url)}`,
749
905
  "-c",
750
- `${table}.bearer_token_env_var=${JSON.stringify(override.keyEnv)}`,
906
+ override.headersHelper !== void 0 ? `${table}.http_headers_helper=${JSON.stringify(override.headersHelper)}` : `${table}.bearer_token_env_var=${JSON.stringify(override.keyEnv)}`,
751
907
  "-c",
752
908
  `${table}.default_tools_approval_mode="approve"`,
753
909
  "-c",
@@ -793,6 +949,31 @@ function parseCodexMcpList(stdout) {
793
949
  }
794
950
  return { ok: true, names };
795
951
  }
952
+ function codexAgentchatExplicitAuth(stdout) {
953
+ let parsed;
954
+ try {
955
+ parsed = JSON.parse(stdout);
956
+ } catch {
957
+ return { ok: false, detail: "its output is not JSON" };
958
+ }
959
+ if (!Array.isArray(parsed)) return { ok: false, detail: "its output is not a list" };
960
+ const entry = parsed.find((e) => e?.name === CODEX_MCP_SERVER_NAME);
961
+ const transport = entry?.transport !== null && typeof entry?.transport === "object" ? entry.transport : {};
962
+ const keys = [];
963
+ const bearer = transport["bearer_token_env_var"];
964
+ if (typeof bearer === "string" && bearer.length > 0) keys.push("bearer_token_env_var");
965
+ const envHeaders = transport["env_http_headers"];
966
+ if (envHeaders !== null && typeof envHeaders === "object" && Object.keys(envHeaders).some((name) => name.toLowerCase() === "authorization")) keys.push("env_http_headers.Authorization");
967
+ return { ok: true, keys };
968
+ }
969
+ function codexDotEnvKeyNames(content) {
970
+ const names = /* @__PURE__ */ new Set();
971
+ for (const line of content.split(/\r?\n/)) {
972
+ const match = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*['"]?\S/.exec(line);
973
+ if (match?.[1] === "AGENTCHAT_API_KEY" || match?.[1] === LISTENER_KEY_ENV) names.add(match[1]);
974
+ }
975
+ return [...names];
976
+ }
796
977
  function codexMcpDisableArgs(names) {
797
978
  const args = [];
798
979
  for (const name of names) {
@@ -834,7 +1015,7 @@ function codexConfigLayerFiles(codexHome, workdir, platform = process.platform,
834
1015
  function codexListingKey(files, parts) {
835
1016
  const stats = files.map((file) => {
836
1017
  try {
837
- const st = fs2.statSync(file);
1018
+ const st = fs3.statSync(file);
838
1019
  return `${file}\0${st.size}\0${st.mtimeMs}`;
839
1020
  } catch {
840
1021
  return `${file}\0-`;
@@ -849,33 +1030,39 @@ var CodexRunner = class {
849
1030
  }
850
1031
  options;
851
1032
  name = "codex";
1033
+ label = "Codex";
852
1034
  command;
853
1035
  warnedHome = false;
854
1036
  /** The last good listing and what it depended on: a stranger's DM does not cost a listing (and its contacts to the user's MCP hosts) on every run. */
855
1037
  listing = null;
1038
+ /** The last listing that showed a listener's own run authenticates with its helper alone (`ownAuthProblem`). */
1039
+ ownListing = null;
856
1040
  /**
857
1041
  * Where this runner's runs work (`-C`): the configured workdir, except that an
858
- * `answer` run never has the home folder or above it as its workspace root —
859
- * it gets `codexAnswerFallbackWorkdir`.
1042
+ * `own` or `answer` run never has the home folder or above it as its
1043
+ * workspace root — it gets `codexAnswerFallbackWorkdir`.
860
1044
  */
861
1045
  workdir() {
862
- if (this.options.profile === "answer" && workdirExposesHome(this.options.workdir)) return codexAnswerFallbackWorkdir(this.options.codexHome);
1046
+ if ((this.options.profile === "answer" || this.options.profile === "own") && workdirExposesHome(this.options.workdir)) return codexAnswerFallbackWorkdir(this.options.codexHome);
863
1047
  return this.options.workdir;
864
1048
  }
865
1049
  async preflight(options = {}) {
1050
+ if (this.options.refuse !== void 0) return { ok: false, detail: this.options.refuse };
866
1051
  const runtime = await inspectCodexRuntime(this.options.codexHome, this.command, CODEX_PROBE_TIMEOUT_MS, options.signal);
867
1052
  if (!runtime.ok) return { ok: false, detail: runtime.detail };
868
1053
  const auth = await codexIsLoggedIn(this.options.codexHome, this.command, CODEX_PROBE_TIMEOUT_MS, options.signal);
869
1054
  if (!auth.ok) return { ok: false, detail: `codex login status failed: ${auth.detail}` };
870
1055
  if (this.workdir() !== this.options.workdir && !this.warnedHome) {
871
1056
  this.warnedHome = true;
872
- log.warn(`the run workdir ${this.options.workdir} is your home folder or contains it: answer runs work in ${this.workdir()} instead, so a peer-started run reaches none of your files there. Point the workdir at a folder of its own to choose another.`);
1057
+ log.warn(`the run workdir ${this.options.workdir} is your home folder or contains it: ${this.options.profile} runs work in ${this.workdir()} instead, so a peer-started run reaches none of your files there. Point the workdir at a folder of its own to choose another.`);
873
1058
  }
874
- fs2.mkdirSync(this.workdir(), { recursive: true });
1059
+ fs3.mkdirSync(this.workdir(), { recursive: true });
875
1060
  if (this.options.profile === "answer") {
876
1061
  const disables = await this.answerMcpDisables();
877
1062
  if (!disables.ok) return { ok: false, detail: codexAnswerListingRefusal(disables.detail) };
878
1063
  }
1064
+ const ownProblem = await this.ownAuthProblem();
1065
+ if (ownProblem !== null) return { ok: false, detail: ownProblem };
879
1066
  return { ok: true };
880
1067
  }
881
1068
  /** The exact argv one run uses — exported for tests to pin per profile. An `answer` run adds `answerMcpDisables()` before the prompt. */
@@ -884,9 +1071,20 @@ var CodexRunner = class {
884
1071
  if (this.options.mcp !== void 0 || this.options.pinMcpUrl === void 0) return args;
885
1072
  return [...args.slice(0, -1), ...codexPinnedUrlArgs(this.options.pinMcpUrl), CODEX_PROMPT_FROM_STDIN];
886
1073
  }
887
- /** The child environment: Codex's home and the key the hosted server needs, under the configured name. */
1074
+ /**
1075
+ * The child environment: Codex's home and the key the hosted server needs,
1076
+ * under the configured name. An `own` run gets no key at all — not the
1077
+ * configured one, not an `AGENTCHAT_API_KEY` the daemon inherited: it has
1078
+ * the user's own shell, and Codex hands a run's commands its environment.
1079
+ * Its hosted server authenticates through a headers helper instead.
1080
+ */
888
1081
  env() {
889
1082
  const env = { ...withoutParentSession(this.options.env ?? process.env), CODEX_HOME: this.options.codexHome };
1083
+ if (this.options.profile === "own") {
1084
+ delete env["AGENTCHAT_API_KEY"];
1085
+ delete env[this.options.keyEnv];
1086
+ return env;
1087
+ }
890
1088
  const key = this.options.apiKey();
891
1089
  if (key !== null) env[this.options.keyEnv] = key;
892
1090
  return env;
@@ -901,11 +1099,62 @@ var CodexRunner = class {
901
1099
  * an error, a timeout, output that is not the list — means no run.
902
1100
  */
903
1101
  async answerMcpDisables() {
1102
+ const { flags, key } = this.listingFlags();
1103
+ if (this.listing !== null && this.listing.key === key && Date.now() - this.listing.at < CODEX_MCP_LIST_MAX_AGE_MS) return this.listing.result;
1104
+ const listed = await this.listMcpServers(flags);
1105
+ if (!listed.ok) return listed;
1106
+ const parsed = parseCodexMcpList(listed.stdout);
1107
+ if (!parsed.ok) return parsed;
1108
+ const result = codexMcpDisableArgs(parsed.names);
1109
+ if (result.ok) this.listing = { key, at: Date.now(), result };
1110
+ return result;
1111
+ }
1112
+ /**
1113
+ * For a listener's `own` run (its key from a headers helper, none in its
1114
+ * environment): why it must not start, or null. Two things would make it
1115
+ * carry or use a key that is not the helper's — another agent's, as a
1116
+ * Codex integration from 0.5.2 or earlier left them: `$CODEX_HOME/.env`
1117
+ * setting a key variable (Codex loads it into the run's environment), and an
1118
+ * `agentchat` entry that names `bearer_token_env_var` or an `Authorization`
1119
+ * in `env_http_headers` in any config layer (Codex sends that in place of the
1120
+ * helper's: the run would act as that other agent). The entry is asked of
1121
+ * Codex itself (`codex mcp list --json` with the run's own flags, cached as
1122
+ * an answer run's listing is); a listing that fails means no run.
1123
+ */
1124
+ async ownAuthProblem() {
1125
+ if (this.options.profile !== "own" || this.options.mcp?.headersHelper === void 0) return null;
1126
+ const dotenv = path2.join(this.options.codexHome, ".env");
1127
+ let names = [];
1128
+ try {
1129
+ names = codexDotEnvKeyNames(fs3.readFileSync(dotenv, "utf-8"));
1130
+ } catch {
1131
+ names = [];
1132
+ }
1133
+ if (names.length > 0) {
1134
+ return `${dotenv} sets ${names.join(" and ")}: Codex loads that file into every run's environment, so this listener's own runs would carry that key. An AgentChat Codex integration from 0.5.2 or earlier left it there (\`npx -y @agentchatme/codex doctor --fix\` takes it out); remove the line, or run this listener with --profile answer`;
1135
+ }
1136
+ const { flags, key } = this.listingFlags();
1137
+ if (this.ownListing !== null && this.ownListing.key === key && Date.now() - this.ownListing.at < CODEX_MCP_LIST_MAX_AGE_MS) return null;
1138
+ const listed = await this.listMcpServers(flags);
1139
+ const auth = listed.ok ? codexAgentchatExplicitAuth(listed.stdout) : listed;
1140
+ if (!auth.ok) {
1141
+ return `could not list Codex's MCP servers (\`codex mcp list --json\` with the own run's flags: ${auth.detail}); a listener's own run starts only once Codex confirms its ${CODEX_MCP_SERVER_NAME} server sends this listener's key`;
1142
+ }
1143
+ if (auth.keys.length > 0) {
1144
+ return `the [mcp_servers.${CODEX_MCP_SERVER_NAME}] Codex loads for these runs sets ${auth.keys.join(" and ")}: Codex sends that credential in place of this listener's headers helper, so its own runs would act as another agent. An AgentChat Codex integration from 0.5.2 or earlier wrote bearer_token_env_var (\`npx -y @agentchatme/codex doctor --fix\` replaces it); remove it, or run this listener with --profile answer`;
1145
+ }
1146
+ this.ownListing = { key, at: Date.now() };
1147
+ return null;
1148
+ }
1149
+ /** The run's config flags (`-c <v>` and `--disable <feature>` pairs) and what a listing of them depends on. */
1150
+ listingFlags() {
904
1151
  const run = this.args();
905
1152
  const flags = run.flatMap((arg, i) => run[i - 1] === "-c" || run[i - 1] === "--disable" ? [run[i - 1], arg] : []);
906
- const key = codexListingKey(codexConfigLayerFiles(this.options.codexHome, this.workdir()), [this.command, this.workdir(), ...flags]);
907
- if (this.listing !== null && this.listing.key === key && Date.now() - this.listing.at < CODEX_MCP_LIST_MAX_AGE_MS) return this.listing.result;
908
- const listed = await new Promise((resolve3) => {
1153
+ return { flags, key: codexListingKey(codexConfigLayerFiles(this.options.codexHome, this.workdir()), [this.command, this.workdir(), ...flags]) };
1154
+ }
1155
+ /** `codex mcp list --json <flags>` from the run's workdir, with the run's environment: its output, or why there is none. Killed with its whole tree past its time. */
1156
+ async listMcpServers(flags) {
1157
+ return new Promise((resolve3) => {
909
1158
  let child;
910
1159
  try {
911
1160
  child = spawnCommand(this.command, ["mcp", "list", "--json", ...flags], {
@@ -927,12 +1176,12 @@ var CodexRunner = class {
927
1176
  let stopped = null;
928
1177
  let settled = false;
929
1178
  let abandonTimer = null;
930
- const settle = (result2) => {
1179
+ const settle = (result) => {
931
1180
  if (settled) return;
932
1181
  settled = true;
933
1182
  clearTimeout(timer);
934
1183
  if (abandonTimer !== null) clearTimeout(abandonTimer);
935
- resolve3(result2);
1184
+ resolve3(result);
936
1185
  };
937
1186
  const stop = (why) => {
938
1187
  if (stopped !== null) return;
@@ -962,22 +1211,40 @@ var CodexRunner = class {
962
1211
  else settle({ ok: true, stdout });
963
1212
  });
964
1213
  });
965
- if (!listed.ok) return listed;
966
- const parsed = parseCodexMcpList(listed.stdout);
967
- if (!parsed.ok) return parsed;
968
- const result = codexMcpDisableArgs(parsed.names);
969
- if (result.ok) this.listing = { key, at: Date.now(), result };
970
- return result;
1214
+ }
1215
+ /**
1216
+ * Does the model answer right now, through this runner's binary, sign-in,
1217
+ * CODEX_HOME and environment? One `codex exec` with a fixed prompt in its
1218
+ * own empty folder, read-only, with the hosted AgentChat server switched off
1219
+ * (`codexRuntimeCheckArgs`) and no key in its environment. Its output is
1220
+ * discarded. Never throws.
1221
+ */
1222
+ async checkRuntime(options = {}) {
1223
+ if (this.options.refuse !== void 0) return { ok: false, detail: this.options.refuse };
1224
+ const dir = codexRuntimeCheckWorkdir(this.options.codexHome);
1225
+ return runRuntimeCheck({
1226
+ label: "codex",
1227
+ command: this.command,
1228
+ args: codexRuntimeCheckArgs(dir, this.options.mcp?.url ?? this.options.pinMcpUrl),
1229
+ cwd: dir,
1230
+ // The runs' environment; runRuntimeCheck takes every key variable out, this runner's own included.
1231
+ env: this.env(),
1232
+ keyEnv: this.options.keyEnv,
1233
+ ...options.signal !== void 0 ? { signal: options.signal } : {}
1234
+ });
971
1235
  }
972
1236
  async start(request) {
973
1237
  const startedAt = Date.now();
1238
+ if (this.options.refuse !== void 0) return { state: "not_started", exitCode: null, durationMs: 0, detail: this.options.refuse };
974
1239
  let args = this.args();
975
1240
  if (this.options.profile === "answer") {
976
1241
  const disables = await this.answerMcpDisables();
977
1242
  if (!disables.ok) return { state: "not_started", exitCode: null, durationMs: Date.now() - startedAt, detail: codexAnswerListingRefusal(disables.detail) };
978
1243
  args = [...args.slice(0, -1), ...disables.args, CODEX_PROMPT_FROM_STDIN];
979
1244
  }
980
- log.debug(`codex ${args.join(" ")} (prompt on stdin, ${request.kind} run ${request.runId})`);
1245
+ const ownProblem = await this.ownAuthProblem();
1246
+ if (ownProblem !== null) return { state: "not_started", exitCode: null, durationMs: Date.now() - startedAt, detail: ownProblem };
1247
+ log.debug(`codex ${args.join(" ")} (prompt on stdin, ${request.kind} run ${request.runId}${request.conversationId !== void 0 ? ` for ${request.conversationId}` : ""})`);
981
1248
  return spawnRun({
982
1249
  command: this.command,
983
1250
  args,
@@ -992,6 +1259,31 @@ var CodexRunner = class {
992
1259
  });
993
1260
  }
994
1261
  };
1262
+ function codexListenerHeadersHelperPath(home) {
1263
+ return path2.join(home, "presets", `${CODEX_PRESET}.mcp-headers.mjs`);
1264
+ }
1265
+ var CODEX_LISTENER_HEADERS_HELPER_SOURCE = [
1266
+ "// Written by @agentchatme/agent-core for a listener's Codex runs. Codex runs this on each",
1267
+ '// connection to the MCP server "agentchat" (its http_headers_helper) and sends what it prints',
1268
+ "// as headers: the Authorization header for the key in the credentials file of this identity",
1269
+ "// home, or nothing when there is none. It reads no environment variable. Do not edit: the",
1270
+ "// listener rewrites it.",
1271
+ "import { readFileSync } from 'node:fs'",
1272
+ "let headers = {}",
1273
+ "try {",
1274
+ " const creds = JSON.parse(readFileSync(new URL('../credentials', import.meta.url), 'utf8'))",
1275
+ " const key = creds !== null && typeof creds.api_key === 'string' ? creds.api_key.trim() : ''",
1276
+ " if (key.length >= 20 && !/\\s/.test(key)) headers = { Authorization: `Bearer ${key}` }",
1277
+ "} catch {}",
1278
+ "process.stdout.write(JSON.stringify(headers))",
1279
+ ""
1280
+ ].join("\n");
1281
+ function codexHeadersHelperCommand(script, node = process.execPath, platform = process.platform) {
1282
+ const paths = [node, script];
1283
+ if (paths.some((p) => /[\r\n]/.test(p))) return null;
1284
+ if (platform === "win32") return paths.some((p) => /["%$`]/.test(p)) ? null : paths.map((p) => `"${p}"`).join(" ");
1285
+ return paths.map((p) => `'${p.replace(/'/g, `'\\''`)}'`).join(" ");
1286
+ }
995
1287
  function agentchatTableKeys(configToml) {
996
1288
  const lines = configToml.split(/\r?\n/);
997
1289
  const header = new RegExp(`^\\s*\\[mcp_servers\\.${CODEX_MCP_SERVER_NAME}\\]\\s*(#.*)?$`);
@@ -1007,17 +1299,17 @@ function agentchatTableKeys(configToml) {
1007
1299
  }
1008
1300
  var codexPreset = {
1009
1301
  name: CODEX_PRESET,
1010
- describeMcp({ apiBase, env = process.env }) {
1302
+ describeMcp({ home, apiBase, env = process.env, profile }) {
1011
1303
  const file = path2.join(codexHomeFrom(env), "config.toml");
1012
1304
  let own = null;
1013
1305
  try {
1014
- own = agentchatTableKeys(fs2.readFileSync(file, "utf-8"));
1306
+ own = agentchatTableKeys(fs3.readFileSync(file, "utf-8"));
1015
1307
  } catch {
1016
1308
  own = null;
1017
1309
  }
1018
1310
  return [
1019
1311
  `-c mcp_servers.${CODEX_MCP_SERVER_NAME}.url="${hostedMcpUrl(apiBase)}"`,
1020
- `-c mcp_servers.${CODEX_MCP_SERVER_NAME}.bearer_token_env_var="${LISTENER_KEY_ENV}" (the key set in the run's environment, never on argv)`,
1312
+ profile === "own" ? `-c mcp_servers.${CODEX_MCP_SERVER_NAME}.http_headers_helper=<node> ${codexListenerHeadersHelperPath(home)} (own: reads this home's credentials on each connection; no key in the run's environment or on argv; no run while $CODEX_HOME/.env sets a key or the merged ${CODEX_MCP_SERVER_NAME} entry names bearer_token_env_var)` : `-c mcp_servers.${CODEX_MCP_SERVER_NAME}.bearer_token_env_var="${LISTENER_KEY_ENV}" (the key set in the run's environment, never on argv)`,
1021
1313
  `-c mcp_servers.${CODEX_MCP_SERVER_NAME}.default_tools_approval_mode="approve"`,
1022
1314
  `-c mcp_servers.${CODEX_MCP_SERVER_NAME}.http_headers={ "X-AgentChat-Client" = "codex", "X-AgentChat-Client-Version" = <the listener's version> } (names the runtime to the hosted tools)`,
1023
1315
  own === null ? `${file}: no [mcp_servers.${CODEX_MCP_SERVER_NAME}] of its own \u2014 the run sees only the overrides above` : `${file}: [mcp_servers.${CODEX_MCP_SERVER_NAME}] also sets ${own.length > 0 ? own.join(", ") : "nothing"}; the overrides above replace their keys, the others still apply (how codex merges -c over an existing table is not verified on a real codex)`
@@ -1026,8 +1318,9 @@ var codexPreset = {
1026
1318
  label: "Codex",
1027
1319
  runtime: "codex",
1028
1320
  serviceEnv: ["CODEX_HOME"],
1029
- // `work` and `full` read the whole filesystem (an `answer` run reads only its
1030
- // workdir): true, because the field is one for every profile.
1321
+ // `own`, `work` and `full` read the whole filesystem (Codex's sandboxes never
1322
+ // restrict reads; an `answer` run reads only its workdir): true, because the
1323
+ // field is one for every profile.
1031
1324
  readsIdentityHome: true,
1032
1325
  async inspect(env = process.env, command = "codex") {
1033
1326
  const home = codexHomeFrom(env);
@@ -1039,16 +1332,27 @@ var codexPreset = {
1039
1332
  runner(ctx) {
1040
1333
  const env = withoutInheritedKey(ctx.env ?? process.env);
1041
1334
  const apiKey = ctx.apiKey;
1042
- return new CodexRunner({
1335
+ const base = {
1043
1336
  codexHome: codexHomeFrom(env),
1044
1337
  workdir: ctx.workdir,
1045
1338
  profile: ctx.profile,
1046
- apiKey: () => apiKey,
1047
1339
  keyEnv: LISTENER_KEY_ENV,
1048
- mcp: { url: hostedMcpUrl(ctx.apiBase), keyEnv: LISTENER_KEY_ENV, clientVersion: ctx.clientVersion ?? VERSION },
1049
1340
  ...ctx.command !== void 0 ? { command: ctx.command } : {},
1050
1341
  env
1051
- });
1342
+ };
1343
+ const mcp = { url: hostedMcpUrl(ctx.apiBase), keyEnv: LISTENER_KEY_ENV, clientVersion: ctx.clientVersion ?? VERSION };
1344
+ if (ctx.profile !== "own") return new CodexRunner({ ...base, apiKey: () => apiKey, mcp });
1345
+ const script = codexListenerHeadersHelperPath(ctx.home);
1346
+ const helper = codexHeadersHelperCommand(script);
1347
+ if (helper === null) {
1348
+ return new CodexRunner({ ...base, apiKey: () => null, mcp, refuse: `the path of Node (${process.execPath}) or of ${script} holds a character a shell command cannot carry quoted: an own run would have its key in its environment instead` });
1349
+ }
1350
+ try {
1351
+ atomicWriteFile(script, CODEX_LISTENER_HEADERS_HELPER_SOURCE, 384);
1352
+ } catch (err) {
1353
+ return new CodexRunner({ ...base, apiKey: () => null, mcp, refuse: `could not write the headers helper ${script}: ${err instanceof Error ? err.message : String(err)}` });
1354
+ }
1355
+ return new CodexRunner({ ...base, apiKey: () => null, mcp: { ...mcp, headersHelper: helper } });
1052
1356
  }
1053
1357
  };
1054
1358
 
@@ -1076,6 +1380,7 @@ export {
1076
1380
  CODEX_ANSWER_DISABLED_FEATURES,
1077
1381
  CODEX_ANSWER_FILESYSTEM,
1078
1382
  CODEX_ANSWER_PERMISSIONS,
1383
+ CODEX_LISTENER_HEADERS_HELPER_SOURCE,
1079
1384
  CODEX_MANAGED_PROXY_ENV,
1080
1385
  CODEX_MCP_LIST_MAX_AGE_MS,
1081
1386
  CODEX_MCP_LIST_TIMEOUT_MS,
@@ -1083,6 +1388,7 @@ export {
1083
1388
  CODEX_PRESET,
1084
1389
  CODEX_PROBE_TIMEOUT_MS,
1085
1390
  CODEX_PROMPT_FROM_STDIN,
1391
+ CODEX_RUNTIME_CHECK_DISABLED_FEATURES,
1086
1392
  CODEX_SESSION_ENV,
1087
1393
  ClaudeRunner,
1088
1394
  CodexRunner,
@@ -1092,6 +1398,12 @@ export {
1092
1398
  PARENT_ENV_KEYS,
1093
1399
  PRESETS,
1094
1400
  PROBE_TIMEOUT_MS,
1401
+ RUNTIME_CHECK_BUDGET_MS,
1402
+ RUNTIME_CHECK_DIR,
1403
+ RUNTIME_CHECK_KEY_ENV,
1404
+ RUNTIME_CHECK_OUTPUT_BYTES,
1405
+ RUNTIME_CHECK_PROMPT,
1406
+ RUNTIME_CHECK_SETTINGS,
1095
1407
  WEB_TOOLS,
1096
1408
  WORK_TOOLS,
1097
1409
  agentchatTableKeys,
@@ -1108,20 +1420,29 @@ export {
1108
1420
  claudeProfileArgs,
1109
1421
  claudeProjectsDirFor,
1110
1422
  claudeRunArgs,
1423
+ claudeRuntimeCheckArgs,
1424
+ claudeRuntimeCheckJudge,
1425
+ claudeRuntimeCheckWorkdir,
1111
1426
  claudeSettingsFilesGrantingDirectories,
1112
1427
  claudeSignIn,
1113
1428
  claudeUserStatePathFor,
1429
+ codexAgentchatExplicitAuth,
1114
1430
  codexAnswerFallbackWorkdir,
1115
1431
  codexClientHeadersToml,
1116
1432
  codexConfigLayerFiles,
1433
+ codexDotEnvKeyNames,
1434
+ codexHeadersHelperCommand,
1117
1435
  codexHomeFrom,
1118
1436
  codexIsLoggedIn,
1437
+ codexListenerHeadersHelperPath,
1119
1438
  codexMcpDisableArgs,
1120
1439
  codexMcpOverrideArgs,
1121
1440
  codexPinnedUrlArgs,
1122
1441
  codexPreset,
1123
1442
  codexProfileArgs,
1124
1443
  codexRunArgs,
1444
+ codexRuntimeCheckArgs,
1445
+ codexRuntimeCheckWorkdir,
1125
1446
  codexServerNameAddressable,
1126
1447
  deniedAncestorOf,
1127
1448
  inexpressibleDenyPaths,
@@ -1132,6 +1453,7 @@ export {
1132
1453
  presetNamed,
1133
1454
  presetNames,
1134
1455
  readDenyRules,
1456
+ runRuntimeCheck,
1135
1457
  semverAtLeast,
1136
1458
  withoutParentSession,
1137
1459
  workdirPaths,