@mindexec/cli 0.2.43 → 0.2.45

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/codex-runtime.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { promises as fs, readFileSync } from 'fs';
2
2
  import path from 'path';
3
+ import os from 'os';
3
4
  import { exec, spawn } from 'child_process';
4
5
  import { promisify } from 'util';
5
6
  import crypto from 'crypto';
@@ -36,6 +37,7 @@ const DEFAULT_TIMEOUT_MS = 8 * 60 * 1000;
36
37
  const MAX_LOG_CHARS = 4000;
37
38
  const MAX_EVENT_LOG = 120;
38
39
  const TEMP_DIR = '.ai/codex';
40
+ const CODEX_CONFIG_PATH = path.join(os.homedir(), '.codex', 'config.toml');
39
41
 
40
42
  let cachedSdkModule = null;
41
43
  let cachedSdkLoadError = null;
@@ -88,6 +90,75 @@ function normalizeProviderKind(value) {
88
90
  return '';
89
91
  }
90
92
 
93
+ function isEnabledEnv(value) {
94
+ return /^(1|true|yes|on)$/i.test(String(value || '').trim());
95
+ }
96
+
97
+ function unquoteTomlKey(value) {
98
+ const text = String(value || '').trim();
99
+ if (text.length >= 2 && ((text.startsWith('"') && text.endsWith('"')) || (text.startsWith("'") && text.endsWith("'")))) {
100
+ return text.slice(1, -1).replace(/\\(["\\])/g, '$1').trim();
101
+ }
102
+
103
+ return text;
104
+ }
105
+
106
+ function readConfiguredMcpServerNames() {
107
+ if (isEnabledEnv(process.env.MINDEXEC_CODEX_INHERIT_MCP)) {
108
+ return [];
109
+ }
110
+
111
+ const names = new Set();
112
+ try {
113
+ const content = readFileSync(CODEX_CONFIG_PATH, 'utf8');
114
+ for (const rawLine of content.split(/\r?\n/)) {
115
+ const line = rawLine.trim();
116
+ const match = line.match(/^\[mcp_servers\.((?:"(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+'|[^\]\s]+))\]$/);
117
+ if (!match) {
118
+ continue;
119
+ }
120
+
121
+ const name = unquoteTomlKey(match[1]);
122
+ if (/^[A-Za-z0-9_-]+$/.test(name)) {
123
+ names.add(name);
124
+ }
125
+ }
126
+ } catch {
127
+ // Missing Codex config is fine; SDK auth still reports its own error if login is required.
128
+ }
129
+
130
+ for (const name of String(process.env.MINDEXEC_CODEX_DISABLED_MCP_SERVERS || 'cloudflare,supabase')
131
+ .split(',')
132
+ .map(item => item.trim())
133
+ .filter(Boolean)) {
134
+ if (/^[A-Za-z0-9_-]+$/.test(name)) {
135
+ names.add(name);
136
+ }
137
+ }
138
+
139
+ return Array.from(names).sort();
140
+ }
141
+
142
+ function buildCodexSdkConfigOverrides() {
143
+ const mcpServerNames = readConfiguredMcpServerNames();
144
+ if (mcpServerNames.length === 0) {
145
+ return {};
146
+ }
147
+
148
+ const mcpServers = {};
149
+ for (const name of mcpServerNames) {
150
+ mcpServers[name] = { enabled: false };
151
+ }
152
+
153
+ return { mcp_servers: mcpServers };
154
+ }
155
+
156
+ function appendCodexIsolationConfigArgs(args) {
157
+ for (const name of readConfiguredMcpServerNames()) {
158
+ args.push('--config', `mcp_servers.${name}.enabled=false`);
159
+ }
160
+ }
161
+
91
162
  function normalizeReasoningEffort(value) {
92
163
  const normalized = String(value || '').trim().toLowerCase();
93
164
  return ['minimal', 'low', 'medium', 'high', 'xhigh'].includes(normalized)
@@ -491,7 +562,7 @@ export function createCodexRuntime(options) {
491
562
 
492
563
  if (providerKind === PROVIDER_KIND.typeScriptSdk) {
493
564
  const sdk = await loadCodexSdk();
494
- const codex = new sdk.Codex();
565
+ const codex = new sdk.Codex({ config: buildCodexSdkConfigOverrides() });
495
566
  const thread = codex.startThread(threadOptions);
496
567
  const localThreadId = `local_${crypto.randomUUID()}`;
497
568
  threads.set(localThreadId, {
@@ -553,7 +624,7 @@ export function createCodexRuntime(options) {
553
624
  }
554
625
 
555
626
  const sdk = await loadCodexSdk();
556
- const codex = new sdk.Codex();
627
+ const codex = new sdk.Codex({ config: buildCodexSdkConfigOverrides() });
557
628
  const officialId = requestedThreadId && !requestedThreadId.startsWith('local_')
558
629
  ? requestedThreadId
559
630
  : '';
@@ -708,6 +779,7 @@ export function createCodexRuntime(options) {
708
779
  '--config',
709
780
  `model_reasoning_effort=${threadOptions.modelReasoningEffort}`
710
781
  ];
782
+ appendCodexIsolationConfigArgs(args);
711
783
 
712
784
  if (threadOptions.model) {
713
785
  args.push('-m', threadOptions.model);
@@ -863,7 +935,7 @@ export function createCodexRuntime(options) {
863
935
  const workingDirectory = await resolveWorkingDirectory(body.workingDir || body.workingDirectory || '');
864
936
  const threadOptions = buildThreadOptions(body, workingDirectory);
865
937
  const sdk = await loadCodexSdk();
866
- const codex = new sdk.Codex();
938
+ const codex = new sdk.Codex({ config: buildCodexSdkConfigOverrides() });
867
939
  const thread = codex.resumeThread(threadId, threadOptions);
868
940
  threads.set(threadId, {
869
941
  providerKind,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindexec/cli",
3
- "version": "0.2.43",
3
+ "version": "0.2.45",
4
4
  "description": "MindExec local runtime and bridge CLI",
5
5
  "main": "server.js",
6
6
  "type": "module",