evolcore 0.0.22 → 0.0.24
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/CHANGELOG.md +74 -14
- package/README.md +4 -0
- package/bin/codex-managed-acl.ps1 +160 -0
- package/bin/codex-managed-hook.mjs +127 -10
- package/bin/ec-safe-output.js +85 -3
- package/bin/install-codex-managed-hooks.mjs +384 -95
- package/dist/agents/baseagent-availability.js +48 -0
- package/dist/agents/baseagent.js +30 -2
- package/dist/agents/claude-runner.js +179 -240
- package/dist/agents/{codex-app-server-client.js → codex/app-server-client.js} +90 -20
- package/dist/{utils/codex-app-server-registry.js → agents/codex/app-server-registry.js} +2 -2
- package/dist/agents/codex/catalog.js +70 -0
- package/dist/agents/codex/diagnostics.js +369 -0
- package/dist/agents/codex-runner.js +839 -192
- package/dist/agents/ecagent-runner.js +27 -34
- package/dist/agents/gemini-runner.js +62 -8
- package/dist/agents/runner-types.js +1 -1
- package/dist/aun/aid/managed-operation.js +28 -6
- package/dist/aun/aid/store.js +43 -0
- package/dist/aun/menu-client.js +272 -0
- package/dist/aun/msg/group.js +65 -4
- package/dist/aun/msg/index.js +1 -1
- package/dist/aun/msg/managed-operation.js +57 -5
- package/dist/aun/outbox.js +56 -18
- package/dist/aun/rpc/client.js +7 -1
- package/dist/channels/aun.js +178 -77
- package/dist/channels/daemon.js +7 -1
- package/dist/channels/dingtalk.js +1 -0
- package/dist/channels/feishu.js +10 -4
- package/dist/channels/wechat.js +81 -10
- package/dist/channels/wecom.js +2 -1
- package/dist/cli/agent-command.js +29 -3
- package/dist/cli/agent-create.js +538 -0
- package/dist/cli/agent.js +26 -675
- package/dist/cli/aun-commands.js +108 -24
- package/dist/cli/command-log.js +21 -2
- package/dist/cli/ctl-command.js +2 -0
- package/dist/cli/daemon-commands.js +289 -61
- package/dist/cli/index.js +22 -2
- package/dist/cli/init.js +2 -10
- package/dist/cli/managed-command-guard.js +3 -0
- package/dist/cli/menu-client.js +95 -0
- package/dist/cli/model.js +23 -8
- package/dist/cli/restart-monitor.js +432 -8
- package/dist/cli/stats.js +110 -0
- package/dist/cli/task-context.js +12 -2
- package/dist/cli/trigger-command.js +9 -1
- package/dist/config/builtin-roles.js +2 -0
- package/dist/config/schema-migration.js +14 -2
- package/dist/core/auth/agent-delegation.js +10 -7
- package/dist/core/auth/auth-gateway.js +3 -2
- package/dist/core/auth/authorization-audit.js +75 -18
- package/dist/core/auth/operation-authorizer.js +63 -3
- package/dist/core/auth/operation-catalog.js +14 -2
- package/dist/core/auth/remote-access-store.js +136 -0
- package/dist/core/baseagent-loader.js +4 -4
- package/dist/core/bootstrap-messages.js +39 -18
- package/dist/core/bootstrap-service.js +32 -26
- package/dist/core/capability/capability-manager.js +8 -4
- package/dist/core/capability/providers/codex-capability-provider.js +1 -1
- package/dist/core/command/agent-control.js +7 -2
- package/dist/core/command/command-handler.js +128 -30
- package/dist/core/command/daemon-diagnostics.js +448 -0
- package/dist/core/command/menu-catalog.js +6 -1
- package/dist/core/command/menu-handler.js +410 -98
- package/dist/core/command/menu-protocol.js +123 -0
- package/dist/core/command/slash-gate.js +4 -6
- package/dist/core/command/slash-handler.js +199 -70
- package/dist/core/data-migration.js +5 -15
- package/dist/core/event-catalog.js +3 -0
- package/dist/core/handoff/runtime.js +3 -1
- package/dist/core/handoff/store.js +7 -1
- package/dist/core/message/im-renderer.js +13 -6
- package/dist/core/message/message-bridge.js +5 -36
- package/dist/core/message/message-queue.js +20 -15
- package/dist/core/message/message-utils.js +6 -3
- package/dist/core/message/response-engine.js +147 -94
- package/dist/core/model/catalog-service.js +310 -0
- package/dist/core/model/model-catalog.js +134 -334
- package/dist/core/model/model-diagnostics.js +4 -5
- package/dist/core/model/model-fallback.js +9 -16
- package/dist/core/model/model-permission.js +5 -2
- package/dist/core/permission/approval-gateway.js +183 -32
- package/dist/core/permission/protected-paths.js +63 -4
- package/dist/core/permission/sandbox-runtime.js +4 -2
- package/dist/core/permission/tool-policy.js +257 -31
- package/dist/core/runtime-lock.js +13 -8
- package/dist/core/session/adapters/codex-session-file-adapter.js +71 -3
- package/dist/core/session/session-manager.js +49 -13
- package/dist/core/session/session-renew.js +1 -0
- package/dist/index.js +214 -57
- package/dist/ipc.js +191 -102
- package/dist/paths.js +23 -1
- package/dist/stats/billing.js +18 -4
- package/dist/trigger/manager.js +3 -1
- package/dist/trigger/parser.js +77 -13
- package/dist/trigger/patch.js +104 -1
- package/dist/utils/atomic-write.js +26 -2
- package/dist/utils/cross-platform.js +436 -1
- package/dist/utils/ecweb-supervisor.js +11 -2
- package/dist/utils/ecweb-utils.js +8 -26
- package/dist/utils/error-utils.js +16 -2
- package/dist/utils/model-prices.jsonl +23 -20
- package/dist/utils/npm-ops.js +70 -15
- package/dist/utils/windows-autostart.js +1 -1
- package/kits/docs/evolcore/INDEX.md +1 -0
- package/kits/docs/evolcore/agent-create.md +13 -0
- package/kits/docs/evolcore/group-collaboration.md +7 -2
- package/kits/docs/evolcore/menu-client.md +34 -0
- package/kits/migrations/migrate-contact-book-v2.mjs +9 -1
- package/kits/migrations/migrate-role-config-v4.mjs +11 -5
- package/kits/migrations/migrate-role-config-v5.mjs +8 -2
- package/kits/templates/roles/admin.json +2 -0
- package/kits/templates/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/bootstrap.md +8 -1
- package/package.json +16 -4
- package/dist/utils/codex-cli.js +0 -43
|
@@ -3,16 +3,25 @@
|
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import os from 'node:os';
|
|
5
5
|
import path from 'node:path';
|
|
6
|
+
import { randomUUID } from 'node:crypto';
|
|
6
7
|
import { execFileSync } from 'node:child_process';
|
|
8
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
9
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
10
|
+
import { parse as parseToml } from 'smol-toml';
|
|
7
11
|
|
|
8
12
|
const markerStart = '# BEGIN EVOLCORE MANAGED CODEX HOOK';
|
|
9
13
|
const markerEnd = '# END EVOLCORE MANAGED CODEX HOOK';
|
|
14
|
+
const aclScript = fileURLToPath(new URL('./codex-managed-acl.ps1', import.meta.url));
|
|
10
15
|
|
|
11
16
|
function argument(name) {
|
|
12
17
|
const index = process.argv.indexOf(name);
|
|
13
18
|
return index >= 0 ? process.argv[index + 1] : undefined;
|
|
14
19
|
}
|
|
15
20
|
|
|
21
|
+
function hasArgument(name) {
|
|
22
|
+
return process.argv.includes(name);
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
function fail(message) {
|
|
17
26
|
process.stderr.write(`[evolcore] ${message}\n`);
|
|
18
27
|
process.exit(1);
|
|
@@ -22,6 +31,11 @@ function isGlobalInstall() {
|
|
|
22
31
|
return ['1', 'true'].includes(String(process.env.npm_config_global || '').toLowerCase());
|
|
23
32
|
}
|
|
24
33
|
|
|
34
|
+
function lifecycleEvent() {
|
|
35
|
+
const entry = Object.entries(process.env).find(([key]) => key.toLowerCase() === 'npm_lifecycle_event');
|
|
36
|
+
return String(entry?.[1] || '').toLowerCase();
|
|
37
|
+
}
|
|
38
|
+
|
|
25
39
|
function ensureRealDirectory(directory) {
|
|
26
40
|
let stat;
|
|
27
41
|
try {
|
|
@@ -81,15 +95,47 @@ function windowsCommandArg(value) {
|
|
|
81
95
|
return `"${value.replaceAll('"', '\\"')}"`;
|
|
82
96
|
}
|
|
83
97
|
|
|
98
|
+
function windowsPostinstallNotice() {
|
|
99
|
+
if (process.platform !== 'win32') return;
|
|
100
|
+
process.stderr.write(
|
|
101
|
+
'[evolcore] ec start/restart automatically checks and installs missing Codex managed hooks on Windows.\n'
|
|
102
|
+
+ '[evolcore] Accept the Windows administrator (UAC) prompt when installation is needed; no separate setup command is required.\n',
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
84
106
|
function removeManagedBlock(source) {
|
|
85
|
-
const
|
|
86
|
-
|
|
107
|
+
const original = parseToml(source);
|
|
108
|
+
if (!source.includes(markerStart) && !source.includes(markerEnd)) return source;
|
|
109
|
+
const unsafe = () => new Error('Ambiguous EvolCore managed Hook markers in requirements.toml. Existing configuration was not modified.');
|
|
110
|
+
const expression = new RegExp(`^${markerStart}\\r?\\n[\\s\\S]*?^${markerEnd}(?:\\r?\\n|$)`, 'gm');
|
|
111
|
+
const matches = [...source.matchAll(expression)];
|
|
112
|
+
if (matches.length !== 1 || source.split(markerStart).length !== 2 || source.split(markerEnd).length !== 2) throw unsafe();
|
|
113
|
+
const block = parseToml(matches[0][0]);
|
|
114
|
+
const groups = block.hooks?.PreToolUse;
|
|
115
|
+
if (!Array.isArray(groups) || groups.length !== 1
|
|
116
|
+
|| !isDeepStrictEqual(block, { hooks: { PreToolUse: groups } })) throw unsafe();
|
|
117
|
+
const content = source.replace(matches[0][0], '');
|
|
118
|
+
const retained = parseToml(content);
|
|
119
|
+
const originalGroups = original.hooks?.PreToolUse;
|
|
120
|
+
if (!Array.isArray(originalGroups)) throw unsafe();
|
|
121
|
+
// Markers inside a TOML string are not comments. Prove that removing the
|
|
122
|
+
// block removes only its Hook group, with every other policy unchanged.
|
|
123
|
+
const safe = originalGroups.some((group, index) => {
|
|
124
|
+
if (!isDeepStrictEqual(group, groups[0])) return false;
|
|
125
|
+
const expected = structuredClone(original);
|
|
126
|
+
expected.hooks.PreToolUse.splice(index, 1);
|
|
127
|
+
if (!expected.hooks.PreToolUse.length && !retained.hooks?.PreToolUse) delete expected.hooks.PreToolUse;
|
|
128
|
+
if (!Object.keys(expected.hooks).length && !retained.hooks) delete expected.hooks;
|
|
129
|
+
return isDeepStrictEqual(expected, retained);
|
|
130
|
+
});
|
|
131
|
+
if (!safe) throw unsafe();
|
|
132
|
+
return content;
|
|
87
133
|
}
|
|
88
134
|
|
|
89
135
|
function tableBounds(lines, table) {
|
|
90
136
|
const header = table ? `[${table}]` : null;
|
|
91
137
|
const start = header
|
|
92
|
-
? lines.findIndex(line => line.trim() === header)
|
|
138
|
+
? lines.findIndex(line => line.trim() === header || line.trim().startsWith(`${header} #`))
|
|
93
139
|
: -1;
|
|
94
140
|
if (table && start < 0) return null;
|
|
95
141
|
const from = table ? start + 1 : 0;
|
|
@@ -127,51 +173,9 @@ function setTomlKey(source, table, key, value) {
|
|
|
127
173
|
return lines.join('\n');
|
|
128
174
|
}
|
|
129
175
|
|
|
130
|
-
function
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return;
|
|
134
|
-
} catch (error) {
|
|
135
|
-
if (error?.code !== 'EEXIST' && error?.code !== 'EPERM') throw error;
|
|
136
|
-
}
|
|
137
|
-
const backup = `${file}.evolcore-backup-${process.pid}-${Date.now()}`;
|
|
138
|
-
fs.renameSync(file, backup);
|
|
139
|
-
try {
|
|
140
|
-
fs.renameSync(temporary, file);
|
|
141
|
-
} catch (error) {
|
|
142
|
-
try { fs.renameSync(backup, file); } catch {}
|
|
143
|
-
throw error;
|
|
144
|
-
}
|
|
145
|
-
try { fs.rmSync(backup, { force: true }); } catch {}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function atomicWrite(file, content) {
|
|
149
|
-
const temporary = `${file}.evolcore-${process.pid}-${Date.now()}.tmp`;
|
|
150
|
-
try {
|
|
151
|
-
fs.writeFileSync(temporary, content, { encoding: 'utf8', mode: 0o440, flag: 'wx' });
|
|
152
|
-
atomicReplace(file, temporary);
|
|
153
|
-
} finally {
|
|
154
|
-
try { fs.rmSync(temporary, { force: true }); } catch {}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function restrictWindowsAcl(target) {
|
|
159
|
-
if (process.platform !== 'win32') return;
|
|
160
|
-
// Keep the hook and requirements administrator-owned while allowing the
|
|
161
|
-
// daemon's normal user token to read and execute them.
|
|
162
|
-
execFileSync('icacls.exe', [
|
|
163
|
-
target,
|
|
164
|
-
'/inheritance:r',
|
|
165
|
-
'/grant:r',
|
|
166
|
-
'*S-1-5-18:(OI)(CI)F',
|
|
167
|
-
'*S-1-5-32-544:(OI)(CI)F',
|
|
168
|
-
'*S-1-5-32-545:(OI)(CI)RX',
|
|
169
|
-
], { stdio: 'ignore' });
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function managedHookLauncher(packageRoot) {
|
|
173
|
-
// Keep the machine-wide entrypoint stable across npm upgrades. The app
|
|
174
|
-
// npm upgrades replace the package contents at this stable global path, so
|
|
176
|
+
export function managedHookLauncher(packageRoot) {
|
|
177
|
+
// Keep the machine-wide entrypoint stable across npm upgrades. Those
|
|
178
|
+
// upgrades replace the package contents at this stable global path, so
|
|
175
179
|
// this file never needs to be rewritten just because the hook changed.
|
|
176
180
|
const trustedPackageRoot = path.resolve(packageRoot);
|
|
177
181
|
return `#!/usr/bin/env node
|
|
@@ -191,42 +195,11 @@ try {
|
|
|
191
195
|
`;
|
|
192
196
|
}
|
|
193
197
|
|
|
194
|
-
function
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
if (process.platform === 'linux' && argument('--mountpoint')) {
|
|
200
|
-
runLinuxPostinstall();
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (process.platform !== 'win32' && !argument('--requirements')) {
|
|
204
|
-
fail('Codex managed hook provisioning is only supported on Windows.');
|
|
205
|
-
}
|
|
206
|
-
const packageRoot = argument('--package-root');
|
|
207
|
-
const nodePath = argument('--node-path') || process.execPath;
|
|
208
|
-
const requirements = argument('--requirements')
|
|
209
|
-
|| path.join(process.env.ProgramData || path.join(os.homedir(), 'ProgramData'), 'OpenAI', 'Codex', 'requirements.toml');
|
|
210
|
-
if (!packageRoot) fail('--package-root is required.');
|
|
211
|
-
const existingRequirements = fs.existsSync(requirements) ? fs.readFileSync(requirements, 'utf8') : '';
|
|
212
|
-
const targetDirectory = argument('--managed-dir')
|
|
213
|
-
|| path.join(path.dirname(requirements), 'EvolCore', 'hooks');
|
|
214
|
-
const sourceHook = path.join(packageRoot, 'bin', 'codex-managed-hook.mjs');
|
|
215
|
-
if (!fs.existsSync(sourceHook) || !fs.statSync(sourceHook).isFile()) fail(`Codex PreToolUse hook source was not found: ${sourceHook}`);
|
|
216
|
-
|
|
217
|
-
fs.mkdirSync(targetDirectory, { recursive: true, mode: 0o700 });
|
|
218
|
-
const hookPath = path.join(targetDirectory, 'pre-tool-use.mjs');
|
|
219
|
-
const temporaryHook = `${hookPath}.evolcore-${process.pid}-${Date.now()}.tmp`;
|
|
220
|
-
try {
|
|
221
|
-
fs.writeFileSync(temporaryHook, managedHookLauncher(packageRoot), { encoding: 'utf8', mode: 0o500, flag: 'wx' });
|
|
222
|
-
fs.chmodSync(temporaryHook, 0o500);
|
|
223
|
-
atomicReplace(hookPath, temporaryHook);
|
|
224
|
-
} finally {
|
|
225
|
-
try { fs.rmSync(temporaryHook, { force: true }); } catch {}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
let content = existingRequirements;
|
|
229
|
-
content = removeManagedBlock(content);
|
|
198
|
+
export function buildManagedRequirements(source, { targetDirectory, nodePath, hookPath }) {
|
|
199
|
+
// Keep the existing text editor, but reject unsupported TOML layouts before
|
|
200
|
+
// writing anything. Parsing also catches duplicate tables/keys on reinstall.
|
|
201
|
+
let content = removeManagedBlock(source);
|
|
202
|
+
const before = parseToml(content);
|
|
230
203
|
content = setTomlKey(content, null, 'allow_managed_hooks_only', 'true');
|
|
231
204
|
content = setTomlKey(content, 'features', 'hooks', 'true');
|
|
232
205
|
content = setTomlKey(content, 'hooks', 'windows_managed_dir', tomlString(path.resolve(targetDirectory)));
|
|
@@ -250,17 +223,333 @@ function main() {
|
|
|
250
223
|
markerEnd,
|
|
251
224
|
'',
|
|
252
225
|
].join('\n');
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
226
|
+
const after = parseToml(content);
|
|
227
|
+
const expected = {
|
|
228
|
+
...before,
|
|
229
|
+
allow_managed_hooks_only: true,
|
|
230
|
+
features: { ...before.features, hooks: true },
|
|
231
|
+
hooks: {
|
|
232
|
+
...before.hooks,
|
|
233
|
+
windows_managed_dir: path.resolve(targetDirectory),
|
|
234
|
+
PreToolUse: [
|
|
235
|
+
...(before.hooks?.PreToolUse || []),
|
|
236
|
+
{ matcher: '*', hooks: [{ type: 'command', command, command_windows: command, statusMessage: 'Checking EvolCore session policy' }] },
|
|
237
|
+
],
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
if (!isDeepStrictEqual(after, expected)) {
|
|
241
|
+
throw new Error('Could not safely update requirements.toml without changing unrelated policy. Existing configuration was not modified.');
|
|
242
|
+
}
|
|
243
|
+
return content;
|
|
260
244
|
}
|
|
261
245
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
246
|
+
function regularFile(file) {
|
|
247
|
+
try {
|
|
248
|
+
const stat = fs.lstatSync(file);
|
|
249
|
+
if (!stat.isFile() || stat.isSymbolicLink()) return { ok: false, unsafe: true };
|
|
250
|
+
return { ok: true };
|
|
251
|
+
} catch (error) {
|
|
252
|
+
if (error?.code === 'ENOENT') return { ok: false, unsafe: false };
|
|
253
|
+
return { ok: false, unsafe: true, error };
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function sourceHasManagedMarker(source) {
|
|
258
|
+
return source.includes(markerStart) || source.includes(markerEnd);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Inspect only the canonical EvolCore managed-hook targets. */
|
|
262
|
+
export function inspectManagedHookInstallation({ requirements, managedDir, packageRoot }) {
|
|
263
|
+
const canonicalRequirements = path.resolve(requirements);
|
|
264
|
+
const canonicalManagedDir = path.resolve(managedDir);
|
|
265
|
+
const hookPath = path.join(canonicalManagedDir, 'pre-tool-use.mjs');
|
|
266
|
+
for (const directory of [path.dirname(canonicalRequirements), canonicalManagedDir]) {
|
|
267
|
+
try {
|
|
268
|
+
const stat = fs.lstatSync(directory);
|
|
269
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) {
|
|
270
|
+
return { status: 'unsafe', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath, reason: `${directory} must be a real directory` };
|
|
271
|
+
}
|
|
272
|
+
} catch (error) {
|
|
273
|
+
if (error?.code !== 'ENOENT') return { status: 'unsafe', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath, reason: error?.message || String(error) };
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
const req = regularFile(canonicalRequirements);
|
|
277
|
+
const hook = regularFile(hookPath);
|
|
278
|
+
if (req.unsafe || hook.unsafe) return { status: 'unsafe', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath, reason: 'requirements or launcher is not a regular file' };
|
|
279
|
+
if (!req.ok && hook.ok) return { status: 'unsafe', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath, reason: 'canonical launcher exists but requirements.toml is missing' };
|
|
280
|
+
if (req.ok && !hook.ok) {
|
|
281
|
+
// A missing launcher can be repaired only when the requirements file is
|
|
282
|
+
// still an untouched user configuration. If it already contains any
|
|
283
|
+
// EvolCore-managed policy, treat the partial state as drift and fail
|
|
284
|
+
// closed instead of guessing which policy is authoritative.
|
|
285
|
+
try {
|
|
286
|
+
const source = fs.readFileSync(canonicalRequirements, 'utf8');
|
|
287
|
+
const partial = parseToml(source);
|
|
288
|
+
const managedPolicyPresent = sourceHasManagedMarker(source)
|
|
289
|
+
|| partial.allow_managed_hooks_only !== undefined
|
|
290
|
+
|| partial.hooks?.windows_managed_dir !== undefined
|
|
291
|
+
|| partial.hooks?.managed_dir !== undefined;
|
|
292
|
+
if (managedPolicyPresent) {
|
|
293
|
+
return { status: 'unsafe', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath, reason: 'requirements contains managed-hook policy but the canonical launcher is missing' };
|
|
294
|
+
}
|
|
295
|
+
} catch (error) {
|
|
296
|
+
return { status: 'unsafe', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath, reason: `requirements.toml is invalid: ${error?.message || String(error)}` };
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (!req.ok || !hook.ok) return { status: 'missing', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath, reason: 'requirements or launcher is missing' };
|
|
300
|
+
let parsed;
|
|
301
|
+
try { parsed = parseToml(fs.readFileSync(canonicalRequirements, 'utf8')); }
|
|
302
|
+
catch (error) { return { status: 'unsafe', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath, reason: `requirements.toml is invalid: ${error?.message || String(error)}` }; }
|
|
303
|
+
const configured = parsed.hooks?.windows_managed_dir ?? parsed.hooks?.managed_dir;
|
|
304
|
+
const normalized = value => path.normalize(String(value || '')).toLowerCase();
|
|
305
|
+
const launcher = fs.readFileSync(hookPath, 'utf8');
|
|
306
|
+
const packageMarker = launcher.includes('EVOLCORE_MANAGED_HOOK_LAUNCHER')
|
|
307
|
+
&& launcher.toLowerCase().includes(JSON.stringify(path.resolve(packageRoot || process.cwd())).toLowerCase());
|
|
308
|
+
const preToolUse = parsed.hooks?.PreToolUse;
|
|
309
|
+
const canonicalCommand = value => {
|
|
310
|
+
if (typeof value !== 'string' || !value || /[\r\n;&|<>]/.test(value)) return false;
|
|
311
|
+
const withoutSocket = value.replace(/\s+%EVOLCORE_INSTANCE_SOCKET%\s*$/i, '').trim();
|
|
312
|
+
return withoutSocket.replace(/["']+$/, '').toLowerCase().endsWith(normalized(hookPath));
|
|
313
|
+
};
|
|
314
|
+
const loaded = Array.isArray(preToolUse) && preToolUse.some(group => group?.matcher === '*'
|
|
315
|
+
&& Array.isArray(group.hooks) && group.hooks.some(handler => handler?.type === 'command'
|
|
316
|
+
&& handler.async !== true && typeof handler.command === 'string'
|
|
317
|
+
&& canonicalCommand(handler.command)
|
|
318
|
+
&& canonicalCommand(handler.command_windows ?? handler.commandWindows)));
|
|
319
|
+
const valid = parsed.allow_managed_hooks_only === true
|
|
320
|
+
&& parsed.features?.hooks === true
|
|
321
|
+
&& normalized(configured) === normalized(canonicalManagedDir)
|
|
322
|
+
&& packageMarker && loaded;
|
|
323
|
+
return valid
|
|
324
|
+
? { status: 'installed', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath }
|
|
325
|
+
: { status: 'unsafe', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath, reason: 'managed-hook policy is missing, altered, or points outside the canonical target' };
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** Idempotently repair a missing canonical installation; unsafe edits fail closed. */
|
|
329
|
+
export function repairManagedHookInstallation(options, acl = windowsAcl) {
|
|
330
|
+
const { requirements, managedDir, packageRoot, nodePath = process.execPath } = options;
|
|
331
|
+
const canonicalRequirements = path.resolve(requirements);
|
|
332
|
+
const canonicalManagedDir = path.resolve(managedDir);
|
|
333
|
+
const hookPath = path.join(canonicalManagedDir, 'pre-tool-use.mjs');
|
|
334
|
+
const sourceHook = path.join(packageRoot, 'bin', 'codex-managed-hook.mjs');
|
|
335
|
+
const state = inspectManagedHookInstallation({ requirements: canonicalRequirements, managedDir: canonicalManagedDir, packageRoot });
|
|
336
|
+
if (state.status === 'installed') return { ...state, repaired: false, warnings: [] };
|
|
337
|
+
if (state.status === 'unsafe') throw new Error(`Refusing automatic managed-hook repair: ${state.reason}`);
|
|
338
|
+
if (!fs.existsSync(sourceHook)) throw new Error(`Required Hook runtime file was not found: ${sourceHook}`);
|
|
339
|
+
const previousContent = fs.existsSync(canonicalRequirements) ? fs.readFileSync(canonicalRequirements, 'utf8') : '';
|
|
340
|
+
const content = buildManagedRequirements(previousContent, { targetDirectory: canonicalManagedDir, nodePath, hookPath });
|
|
341
|
+
const warnings = provisionManagedFiles({ requirements: canonicalRequirements, hookPath, sourceHook, nodePath, previousContent, content, launcher: managedHookLauncher(packageRoot) }, acl);
|
|
342
|
+
return { status: 'installed', requirements: canonicalRequirements, managedDir: canonicalManagedDir, hookPath, repaired: true, warnings };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export function windowsAcl(action, payload = {}, run = execFileSync) {
|
|
346
|
+
const executable = path.join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
|
347
|
+
try {
|
|
348
|
+
const output = run(executable, [
|
|
349
|
+
'-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-File', aclScript,
|
|
350
|
+
'-Request', Buffer.from(JSON.stringify({ action, ...payload })).toString('base64'),
|
|
351
|
+
], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true, timeout: 30_000 });
|
|
352
|
+
return JSON.parse(output.replace(/^\uFEFF/, '').trim());
|
|
353
|
+
} catch (error) {
|
|
354
|
+
const detail = error.stderr?.toString().trim() || error.message || String(error);
|
|
355
|
+
throw new Error(`Windows ACL ${action} failed (${payload.path || 'access verification'}, exit=${error.status ?? 'unknown'}): ${detail}`, { cause: error });
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function existingFile(file, io) {
|
|
360
|
+
try {
|
|
361
|
+
const stat = io.lstatSync(file);
|
|
362
|
+
if (!stat.isFile() || stat.isSymbolicLink()) throw new Error(`Expected a regular file: ${file}`);
|
|
363
|
+
return stat;
|
|
364
|
+
} catch (error) {
|
|
365
|
+
if (error.code === 'ENOENT') return undefined;
|
|
366
|
+
throw error;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function makeReplaceable(file, io) {
|
|
371
|
+
const stat = existingFile(file, io);
|
|
372
|
+
// Windows' readonly attribute prevents replacement even for Administrators.
|
|
373
|
+
// chmod affects that attribute, not the DACL. Restore it on the old inode.
|
|
374
|
+
if (process.platform === 'win32' && stat && !(stat.mode & 0o200)) io.chmodSync(file, 0o600);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** Keep the original inodes (including ACLs) until both replacements validate. */
|
|
378
|
+
export function commitPreparedFiles(entries, verify, io = fs) {
|
|
379
|
+
const records = [];
|
|
380
|
+
try {
|
|
381
|
+
for (const entry of entries) {
|
|
382
|
+
const stat = existingFile(entry.file, io);
|
|
383
|
+
const record = { ...entry, mode: stat?.mode, backup: undefined, installed: false };
|
|
384
|
+
if (stat) {
|
|
385
|
+
const backup = `${entry.file}.evolcore-backup-${randomUUID()}`;
|
|
386
|
+
// A same-directory hard link retains the exact original security
|
|
387
|
+
// descriptor. If unsupported, stop before replacing any live file.
|
|
388
|
+
io.linkSync(entry.file, backup);
|
|
389
|
+
record.backup = backup;
|
|
390
|
+
}
|
|
391
|
+
records.push(record);
|
|
392
|
+
}
|
|
393
|
+
for (const record of records) {
|
|
394
|
+
makeReplaceable(record.file, io);
|
|
395
|
+
io.renameSync(record.temporary, record.file);
|
|
396
|
+
record.installed = true;
|
|
397
|
+
if (record.backup) io.chmodSync(record.backup, record.mode);
|
|
398
|
+
}
|
|
399
|
+
verify();
|
|
400
|
+
} catch (error) {
|
|
401
|
+
const recoveryErrors = [];
|
|
402
|
+
for (const record of records.toReversed()) {
|
|
403
|
+
try {
|
|
404
|
+
if (record.installed) {
|
|
405
|
+
makeReplaceable(record.file, io);
|
|
406
|
+
if (record.backup) io.renameSync(record.backup, record.file);
|
|
407
|
+
else io.unlinkSync(record.file);
|
|
408
|
+
}
|
|
409
|
+
if (record.backup && io.existsSync(record.backup)) {
|
|
410
|
+
makeReplaceable(record.backup, io);
|
|
411
|
+
io.unlinkSync(record.backup);
|
|
412
|
+
}
|
|
413
|
+
if (record.mode !== undefined) io.chmodSync(record.file, record.mode);
|
|
414
|
+
} catch (recoveryError) {
|
|
415
|
+
recoveryErrors.push(`${record.file}: ${recoveryError.message}; original retained at ${record.backup || '(new installation)'}`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
throw new Error(`${error.message}${recoveryErrors.length
|
|
419
|
+
? `; rollback incomplete: ${recoveryErrors.join(' | ')}`
|
|
420
|
+
: '; previous files and permissions restored'}`, { cause: error });
|
|
421
|
+
}
|
|
422
|
+
const warnings = [];
|
|
423
|
+
for (const record of records) {
|
|
424
|
+
if (!record.backup) continue;
|
|
425
|
+
try {
|
|
426
|
+
makeReplaceable(record.backup, io);
|
|
427
|
+
io.unlinkSync(record.backup);
|
|
428
|
+
} catch (error) {
|
|
429
|
+
warnings.push(`Installed successfully, but could not remove backup ${record.backup}: ${error.message}`);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return warnings;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** This transaction is used only by explicit provisioning, never npm upgrades. */
|
|
436
|
+
export function provisionManagedFiles(options, acl = windowsAcl) {
|
|
437
|
+
const { requirements, hookPath, sourceHook, nodePath, content, launcher } = options;
|
|
438
|
+
const directory = path.dirname(hookPath);
|
|
439
|
+
const configDirectory = path.dirname(requirements);
|
|
440
|
+
acl('preflight');
|
|
441
|
+
fs.mkdirSync(configDirectory, { recursive: true });
|
|
442
|
+
const lockPath = path.join(configDirectory, '.evolcore-hooks.install.lock');
|
|
443
|
+
let lock;
|
|
444
|
+
try { lock = fs.openSync(lockPath, 'wx', 0o600); } catch (error) {
|
|
445
|
+
throw new Error(`Cannot acquire installer lock ${lockPath}: ${error.message}. If an installer crashed, confirm it has stopped before removing the lock.`, { cause: error });
|
|
446
|
+
}
|
|
447
|
+
const staged = [];
|
|
448
|
+
let committed = false;
|
|
449
|
+
try {
|
|
450
|
+
fs.writeFileSync(lock, JSON.stringify({ pid: process.pid, started: new Date().toISOString() }));
|
|
451
|
+
const existing = existingFile(requirements, fs);
|
|
452
|
+
// Detect edits made after configuration generation, including a second
|
|
453
|
+
// installer completing just before this process acquired the lock.
|
|
454
|
+
if ((existing ? fs.readFileSync(requirements, 'utf8') : '') !== options.previousContent) {
|
|
455
|
+
throw new Error(`Configuration changed while preparing installation: ${requirements}. Retry using the latest configuration.`);
|
|
456
|
+
}
|
|
457
|
+
if (fs.existsSync(directory)) {
|
|
458
|
+
const stat = fs.lstatSync(directory);
|
|
459
|
+
if (!stat.isDirectory() || stat.isSymbolicLink()) throw new Error(`Expected a real hook directory: ${directory}`);
|
|
460
|
+
} else {
|
|
461
|
+
fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
462
|
+
acl('prepare', { path: directory, directory: true });
|
|
463
|
+
}
|
|
464
|
+
// Existing directory ACLs are checked below, never rewritten: changing
|
|
465
|
+
// inheritable ACEs could alter the live Hook before the transaction starts.
|
|
466
|
+
for (const [file, value, reference] of [
|
|
467
|
+
[hookPath, launcher, undefined],
|
|
468
|
+
[requirements, content, existing ? requirements : undefined],
|
|
469
|
+
]) {
|
|
470
|
+
const temporary = `${file}.evolcore-${randomUUID()}.tmp`;
|
|
471
|
+
staged.push({ file, temporary, value });
|
|
472
|
+
fs.writeFileSync(temporary, value, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
|
|
473
|
+
acl('prepare', { path: temporary, reference });
|
|
474
|
+
}
|
|
475
|
+
const readable = [
|
|
476
|
+
{ path: configDirectory, execute: true },
|
|
477
|
+
{ path: sourceHook },
|
|
478
|
+
{ path: nodePath, execute: true },
|
|
479
|
+
];
|
|
480
|
+
const verify = (temporary) => {
|
|
481
|
+
for (const entry of staged) {
|
|
482
|
+
const target = temporary ? entry.temporary : entry.file;
|
|
483
|
+
if (fs.readFileSync(target, 'utf8') !== entry.value) throw new Error(`Installed content differs: ${target}`);
|
|
484
|
+
}
|
|
485
|
+
return acl('verify', { entries: [
|
|
486
|
+
{ path: directory, protected: true, execute: true },
|
|
487
|
+
...staged.map(entry => ({ path: temporary ? entry.temporary : entry.file, protected: true })),
|
|
488
|
+
...readable,
|
|
489
|
+
] });
|
|
490
|
+
};
|
|
491
|
+
verify(true);
|
|
492
|
+
let accessReport;
|
|
493
|
+
const warnings = commitPreparedFiles(staged, () => { accessReport = verify(false); });
|
|
494
|
+
committed = true;
|
|
495
|
+
if ([accessReport].flat().some(entry => entry?.userProbe === 'unavailable')) {
|
|
496
|
+
warnings.push('ACLs verified, but this elevated account has no normal UAC linked token. Verify file reads and Hook execution from the intended non-elevated user before use.');
|
|
497
|
+
}
|
|
498
|
+
return warnings;
|
|
499
|
+
} finally {
|
|
500
|
+
for (const entry of staged) {
|
|
501
|
+
try { fs.rmSync(entry.temporary, { force: true }); } catch (error) {
|
|
502
|
+
process.stderr.write(`[evolcore] Could not clean staging file ${entry.temporary}: ${error.message}\n`);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
fs.closeSync(lock);
|
|
506
|
+
try { fs.unlinkSync(lockPath); } catch (error) {
|
|
507
|
+
process.stderr.write(`[evolcore] ${committed ? 'Installed; ' : ''}could not remove installer lock ${lockPath}: ${error.message}\n`);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function main() {
|
|
513
|
+
// An explicit package root selects provisioning, even if the elevated
|
|
514
|
+
// child inherited npm lifecycle variables. Ordinary postinstall skips it.
|
|
515
|
+
if (!argument('--package-root') && (lifecycleEvent() === 'postinstall' || isGlobalInstall())) {
|
|
516
|
+
runLinuxPostinstall();
|
|
517
|
+
windowsPostinstallNotice();
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (process.platform === 'linux' && argument('--mountpoint')) {
|
|
521
|
+
runLinuxPostinstall();
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (process.platform !== 'win32') fail('Codex managed hook provisioning is only supported on Windows.');
|
|
525
|
+
if (!argument('--package-root')) fail('--package-root is required.');
|
|
526
|
+
const packageRoot = path.resolve(argument('--package-root'));
|
|
527
|
+
const nodePath = path.resolve(argument('--node-path') || process.execPath);
|
|
528
|
+
const requirements = path.resolve(argument('--requirements')
|
|
529
|
+
|| path.join(process.env.ProgramData || path.join(os.homedir(), 'ProgramData'), 'OpenAI', 'Codex', 'requirements.toml'));
|
|
530
|
+
const targetDirectory = path.resolve(argument('--managed-dir') || path.join(path.dirname(requirements), 'EvolCore', 'hooks'));
|
|
531
|
+
const hookPath = path.join(targetDirectory, 'pre-tool-use.mjs');
|
|
532
|
+
const sourceHook = path.join(packageRoot, 'bin', 'codex-managed-hook.mjs');
|
|
533
|
+
for (const file of [sourceHook, nodePath]) {
|
|
534
|
+
if (!fs.statSync(file).isFile()) fail(`Required Hook runtime file was not found: ${file}`);
|
|
535
|
+
}
|
|
536
|
+
if (hasArgument('--repair')) {
|
|
537
|
+
const result = repairManagedHookInstallation({ requirements, managedDir: targetDirectory, packageRoot, nodePath });
|
|
538
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
const previousContent = fs.existsSync(requirements) ? fs.readFileSync(requirements, 'utf8') : '';
|
|
542
|
+
const content = buildManagedRequirements(previousContent, { targetDirectory, nodePath, hookPath });
|
|
543
|
+
const warnings = provisionManagedFiles({
|
|
544
|
+
requirements, hookPath, sourceHook, nodePath, previousContent, content,
|
|
545
|
+
launcher: managedHookLauncher(packageRoot),
|
|
546
|
+
});
|
|
547
|
+
for (const warning of warnings) process.stderr.write(`[evolcore] ${warning}\n`);
|
|
548
|
+
process.stdout.write(`${JSON.stringify({ requirements, managedDir: targetDirectory, hookPath })}\n`);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (process.argv[1] && pathToFileURL(fs.realpathSync(process.argv[1])).href === import.meta.url) {
|
|
552
|
+
try { main(); } catch (error) {
|
|
553
|
+
fail(error instanceof Error ? error.message : String(error));
|
|
554
|
+
}
|
|
266
555
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { commandExists } from '../utils/cross-platform.js';
|
|
2
|
+
import { getCodexAppServerAvailability } from './codex-runner.js';
|
|
3
|
+
export const BASEAGENT_CANDIDATES = ['claude', 'codex', 'gemini', 'ecagent'];
|
|
4
|
+
export const AUTO_BASEAGENT_CANDIDATES = ['claude', 'codex', 'gemini'];
|
|
5
|
+
/**
|
|
6
|
+
* Single source of truth for init and ECWeb base-agent probing.
|
|
7
|
+
* Claude/Gemini require an executable; Codex additionally requires a supported
|
|
8
|
+
* CLI with app-server; ecagent is bundled with EvolCore.
|
|
9
|
+
*/
|
|
10
|
+
export function detectAvailableBaseagents(codexAvailability = getCodexAppServerAvailability()) {
|
|
11
|
+
return BASEAGENT_CANDIDATES.filter((baseagent) => {
|
|
12
|
+
if (baseagent === 'ecagent')
|
|
13
|
+
return true;
|
|
14
|
+
if (baseagent === 'codex')
|
|
15
|
+
return codexAvailability.available;
|
|
16
|
+
return commandExists(baseagent);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export function detectBaseagentDetails(codexAvailability = getCodexAppServerAvailability()) {
|
|
20
|
+
const claude = commandExists('claude');
|
|
21
|
+
const gemini = commandExists('gemini');
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
id: 'claude',
|
|
25
|
+
detected: claude,
|
|
26
|
+
detectionSource: claude ? ['PATH'] : [],
|
|
27
|
+
reason: claude ? undefined : '未检测到 Claude CLI。',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: 'codex',
|
|
31
|
+
detected: codexAvailability.available,
|
|
32
|
+
detectionSource: codexAvailability.available ? ['Codex CLI app-server'] : [],
|
|
33
|
+
reason: codexAvailability.available ? undefined : codexAvailability.reason,
|
|
34
|
+
version: codexAvailability.version,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'gemini',
|
|
38
|
+
detected: gemini,
|
|
39
|
+
detectionSource: gemini ? ['PATH'] : [],
|
|
40
|
+
reason: gemini ? undefined : '未检测到 Gemini CLI。',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'ecagent',
|
|
44
|
+
detected: true,
|
|
45
|
+
detectionSource: ['内置'],
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
}
|
package/dist/agents/baseagent.js
CHANGED
|
@@ -12,7 +12,35 @@
|
|
|
12
12
|
import fs from 'fs';
|
|
13
13
|
import path from 'path';
|
|
14
14
|
import os from 'os';
|
|
15
|
-
import { commandExists } from '../utils/cross-platform.js';
|
|
15
|
+
import { commandExists, isWindows, resolveProbePath } from '../utils/cross-platform.js';
|
|
16
|
+
import { execFileSync } from 'child_process';
|
|
17
|
+
/** Resolve the installed Codex CLI entrypoint, including npm shims on Windows. */
|
|
18
|
+
export function resolveCodexCliPath() {
|
|
19
|
+
return resolveProbePath('codex');
|
|
20
|
+
}
|
|
21
|
+
export function resolveCodexLaunchCommand(args, options = {}) {
|
|
22
|
+
const windows = options.isWindows ?? isWindows;
|
|
23
|
+
const commandPath = options.commandPath !== undefined ? options.commandPath : resolveCodexCliPath();
|
|
24
|
+
if (!commandPath)
|
|
25
|
+
return null;
|
|
26
|
+
if (windows && /\.(cmd|bat)$/i.test(commandPath)) {
|
|
27
|
+
return { command: options.comSpec ?? process.env.ComSpec ?? 'cmd.exe', args: ['/d', '/s', '/c', commandPath, ...args] };
|
|
28
|
+
}
|
|
29
|
+
return { command: commandPath, args };
|
|
30
|
+
}
|
|
31
|
+
/** Execute a Codex CLI command using the resolved npm shim/path. */
|
|
32
|
+
export function execCodexCliSync(args, options) {
|
|
33
|
+
const commandPath = resolveCodexCliPath();
|
|
34
|
+
if (!commandPath)
|
|
35
|
+
throw new Error('Codex CLI not found');
|
|
36
|
+
const launchCommand = resolveCodexLaunchCommand(args, { commandPath });
|
|
37
|
+
if (!launchCommand)
|
|
38
|
+
throw new Error('Codex CLI not found');
|
|
39
|
+
return execFileSync(launchCommand.command, launchCommand.args, {
|
|
40
|
+
...(options ?? {}),
|
|
41
|
+
windowsHide: isWindows,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
16
44
|
const BASEAGENT_ALIASES = {
|
|
17
45
|
claude: { canonical: 'claude', displayName: 'Claude Code' },
|
|
18
46
|
cc: { canonical: 'claude', displayName: 'Claude Code' },
|
|
@@ -157,7 +185,7 @@ export function resolveAnthropicConfig(config, override) {
|
|
|
157
185
|
|| pickExec(config.agents?.claude?.pathToClaudeCodeExecutable);
|
|
158
186
|
return { apiKey, baseUrl, headers, queryParams, model, effort, pathToClaudeCodeExecutable };
|
|
159
187
|
}
|
|
160
|
-
function loadCodexSettings() {
|
|
188
|
+
export function loadCodexSettings() {
|
|
161
189
|
try {
|
|
162
190
|
const configuredHome = process.env.CODEX_HOME?.trim();
|
|
163
191
|
const codexHome = configuredHome ? path.resolve(configuredHome) : path.join(os.homedir(), '.codex');
|