@mindexec/cli 0.2.439 → 0.2.440
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 +3 -78
- package/package.json +1 -1
package/codex-runtime.js
CHANGED
|
@@ -37,7 +37,6 @@ const DEFAULT_TIMEOUT_MS = 8 * 60 * 1000;
|
|
|
37
37
|
const MAX_LOG_CHARS = 4000;
|
|
38
38
|
const MAX_EVENT_LOG = 120;
|
|
39
39
|
const TEMP_DIR = '.ai/codex';
|
|
40
|
-
const CODEX_CONFIG_PATH = path.join(os.homedir(), '.codex', 'config.toml');
|
|
41
40
|
const CODEX_SOURCE_HOME = path.join(os.homedir(), '.codex');
|
|
42
41
|
const CODEX_RUNTIME_HOME_ENV = 'MINDEXEC_CODEX_HOME';
|
|
43
42
|
const DEFAULT_CODEX_RUNTIME_HOME = path.join(os.homedir(), '.mindexec', 'codex-runtime');
|
|
@@ -95,69 +94,6 @@ function normalizeProviderKind(value) {
|
|
|
95
94
|
return '';
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
function isEnabledEnv(value) {
|
|
99
|
-
return /^(1|true|yes|on)$/i.test(String(value || '').trim());
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function unquoteTomlKey(value) {
|
|
103
|
-
const text = String(value || '').trim();
|
|
104
|
-
if (text.length >= 2 && ((text.startsWith('"') && text.endsWith('"')) || (text.startsWith("'") && text.endsWith("'")))) {
|
|
105
|
-
return text.slice(1, -1).replace(/\\(["\\])/g, '$1').trim();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return text;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function readConfiguredMcpServerNames() {
|
|
112
|
-
if (isEnabledEnv(process.env.MINDEXEC_CODEX_INHERIT_MCP)) {
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const names = new Set();
|
|
117
|
-
try {
|
|
118
|
-
const content = readFileSync(CODEX_CONFIG_PATH, 'utf8');
|
|
119
|
-
for (const rawLine of content.split(/\r?\n/)) {
|
|
120
|
-
const line = rawLine.trim();
|
|
121
|
-
const match = line.match(/^\[mcp_servers\.((?:"(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+'|[^\]\s]+))\]$/);
|
|
122
|
-
if (!match) {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const name = unquoteTomlKey(match[1]);
|
|
127
|
-
if (/^[A-Za-z0-9_-]+$/.test(name)) {
|
|
128
|
-
names.add(name);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
} catch {
|
|
132
|
-
// Missing Codex config is fine; SDK auth still reports its own error if login is required.
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
for (const name of String(process.env.MINDEXEC_CODEX_DISABLED_MCP_SERVERS || 'cloudflare,supabase')
|
|
136
|
-
.split(',')
|
|
137
|
-
.map(item => item.trim())
|
|
138
|
-
.filter(Boolean)) {
|
|
139
|
-
if (/^[A-Za-z0-9_-]+$/.test(name)) {
|
|
140
|
-
names.add(name);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return Array.from(names).sort();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function buildCodexSdkConfigOverrides() {
|
|
148
|
-
const mcpServerNames = readConfiguredMcpServerNames();
|
|
149
|
-
if (mcpServerNames.length === 0) {
|
|
150
|
-
return {};
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const mcpServers = {};
|
|
154
|
-
for (const name of mcpServerNames) {
|
|
155
|
-
mcpServers[name] = { enabled: false };
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
return { mcp_servers: mcpServers };
|
|
159
|
-
}
|
|
160
|
-
|
|
161
97
|
function resolveCodexRuntimeHome() {
|
|
162
98
|
const configured = String(process.env[CODEX_RUNTIME_HOME_ENV] || '').trim();
|
|
163
99
|
return path.resolve(configured || DEFAULT_CODEX_RUNTIME_HOME);
|
|
@@ -222,12 +158,6 @@ function buildCodexChildEnv() {
|
|
|
222
158
|
return env;
|
|
223
159
|
}
|
|
224
160
|
|
|
225
|
-
function appendCodexIsolationConfigArgs(args) {
|
|
226
|
-
for (const name of readConfiguredMcpServerNames()) {
|
|
227
|
-
args.push('--config', `mcp_servers.${name}.enabled=false`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
161
|
function normalizeReasoningEffort(value) {
|
|
232
162
|
const normalized = String(value || '').trim().toLowerCase();
|
|
233
163
|
return ['minimal', 'low', 'medium', 'high', 'xhigh'].includes(normalized)
|
|
@@ -636,8 +566,7 @@ export function createCodexRuntime(options) {
|
|
|
636
566
|
const sdk = await loadCodexSdk();
|
|
637
567
|
await ensureCodexRuntimeHome();
|
|
638
568
|
const codex = new sdk.Codex({
|
|
639
|
-
env: buildCodexChildEnv()
|
|
640
|
-
config: buildCodexSdkConfigOverrides()
|
|
569
|
+
env: buildCodexChildEnv()
|
|
641
570
|
});
|
|
642
571
|
const thread = codex.startThread(threadOptions);
|
|
643
572
|
const localThreadId = `local_${crypto.randomUUID()}`;
|
|
@@ -702,8 +631,7 @@ export function createCodexRuntime(options) {
|
|
|
702
631
|
const sdk = await loadCodexSdk();
|
|
703
632
|
await ensureCodexRuntimeHome();
|
|
704
633
|
const codex = new sdk.Codex({
|
|
705
|
-
env: buildCodexChildEnv()
|
|
706
|
-
config: buildCodexSdkConfigOverrides()
|
|
634
|
+
env: buildCodexChildEnv()
|
|
707
635
|
});
|
|
708
636
|
const officialId = requestedThreadId && !requestedThreadId.startsWith('local_')
|
|
709
637
|
? requestedThreadId
|
|
@@ -860,8 +788,6 @@ export function createCodexRuntime(options) {
|
|
|
860
788
|
'--config',
|
|
861
789
|
`model_reasoning_effort=${threadOptions.modelReasoningEffort}`
|
|
862
790
|
];
|
|
863
|
-
appendCodexIsolationConfigArgs(args);
|
|
864
|
-
|
|
865
791
|
if (threadOptions.model) {
|
|
866
792
|
args.push('-m', threadOptions.model);
|
|
867
793
|
}
|
|
@@ -1019,8 +945,7 @@ export function createCodexRuntime(options) {
|
|
|
1019
945
|
const sdk = await loadCodexSdk();
|
|
1020
946
|
await ensureCodexRuntimeHome();
|
|
1021
947
|
const codex = new sdk.Codex({
|
|
1022
|
-
env: buildCodexChildEnv()
|
|
1023
|
-
config: buildCodexSdkConfigOverrides()
|
|
948
|
+
env: buildCodexChildEnv()
|
|
1024
949
|
});
|
|
1025
950
|
const thread = codex.resumeThread(threadId, threadOptions);
|
|
1026
951
|
threads.set(threadId, {
|