evolcore 0.0.21 → 0.0.23
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/AGENTS.md +62 -0
- package/CHANGELOG.md +53 -0
- package/README.md +2 -0
- package/bin/codex-managed-acl.ps1 +155 -0
- package/bin/codex-managed-hook.mjs +3 -0
- package/bin/install-codex-managed-hooks.mjs +376 -96
- package/dist/agents/baseagent-availability.js +48 -0
- package/dist/agents/baseagent.js +1 -1
- package/dist/agents/claude-runner.js +44 -226
- package/dist/agents/{codex-app-server-client.js → codex/app-server-client.js} +103 -17
- 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 +154 -0
- package/dist/agents/codex-runner.js +1292 -219
- package/dist/agents/ecagent-runner.js +10 -31
- package/dist/agents/gemini-runner.js +2 -6
- package/dist/aun/aid/store.js +2 -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 +51 -4
- package/dist/aun/outbox.js +7 -0
- package/dist/aun/rpc/client.js +8 -1
- package/dist/channels/aun.js +240 -36
- package/dist/channels/wechat.js +81 -10
- package/dist/cli/aun-commands.js +48 -4
- package/dist/cli/command-log.js +21 -2
- package/dist/cli/daemon-commands.js +169 -51
- package/dist/cli/index.js +20 -0
- package/dist/cli/init.js +2 -10
- package/dist/cli/menu-client.js +95 -0
- package/dist/cli/model.js +23 -8
- package/dist/cli/task-context.js +16 -2
- package/dist/cli/trigger-command.js +22 -5
- package/dist/config/config-field-policy.js +3 -0
- package/dist/config/config-manager.js +32 -5
- package/dist/config/contact-book-store.js +25 -3
- package/dist/config/schema-migration.js +14 -2
- package/dist/core/auth/agent-delegation.js +15 -0
- package/dist/core/auth/auth-gateway.js +8 -0
- package/dist/core/auth/authorization-audit.js +70 -6
- package/dist/core/auth/operation-catalog.js +4 -0
- package/dist/core/auth/remote-access-store.js +135 -0
- package/dist/core/bootstrap-messages.js +8 -0
- package/dist/core/bootstrap-service.js +93 -25
- package/dist/core/command/command-handler.js +62 -5
- package/dist/core/command/daemon-diagnostics.js +448 -0
- package/dist/core/command/menu-catalog.js +3 -0
- package/dist/core/command/menu-handler.js +150 -33
- package/dist/core/command/menu-protocol.js +120 -1
- package/dist/core/command/slash-gate.js +3 -3
- package/dist/core/command/slash-handler.js +83 -40
- package/dist/core/data-migration.js +11 -1
- package/dist/core/event-catalog.js +32 -0
- package/dist/core/handoff/runtime.js +23 -3
- package/dist/core/message/im-renderer.js +7 -3
- package/dist/core/message/message-bridge.js +60 -2
- package/dist/core/message/message-log.js +33 -0
- package/dist/core/message/message-queue.js +41 -15
- package/dist/core/message/response-engine.js +246 -114
- package/dist/core/model/catalog-service.js +308 -0
- package/dist/core/model/model-catalog.js +124 -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 +1 -1
- package/dist/core/permission/approval-gateway.js +16 -1
- package/dist/core/permission/ec-command-parser.js +272 -70
- package/dist/core/permission/protected-paths.js +74 -14
- package/dist/core/permission/sandbox-runtime.js +4 -2
- package/dist/core/permission/tool-error-code.js +12 -0
- package/dist/core/permission/tool-policy.js +290 -30
- package/dist/core/runtime-lock.js +13 -8
- package/dist/core/session/session-manager.js +30 -0
- package/dist/core/session/session-renew.js +18 -1
- package/dist/core/session/session-turn-coordinator.js +5 -1
- package/dist/index.js +104 -34
- package/dist/ipc.js +218 -96
- package/dist/paths.js +18 -0
- package/dist/response-system/engines/v1/proactive-flow.js +7 -2
- package/dist/stats/price-resolver.js +4 -0
- package/dist/trigger/feedback.js +14 -2
- package/dist/trigger/manager.js +3 -1
- package/dist/trigger/parser.js +86 -13
- package/dist/trigger/patch.js +104 -1
- package/dist/trigger/scheduler.js +20 -3
- package/dist/utils/ecweb-supervisor.js +11 -2
- package/dist/utils/ecweb-utils.js +8 -26
- package/dist/utils/error-utils.js +7 -0
- package/dist/utils/logger.js +9 -4
- package/dist/utils/npm-ops.js +47 -15
- package/dist/utils/tool-summary.js +59 -0
- package/dist/utils/windows-shell-trust.js +201 -0
- package/kits/docs/evolcore/INDEX.md +3 -2
- package/kits/docs/evolcore/agent-create.md +159 -0
- package/kits/docs/evolcore/agent.md +6 -0
- package/kits/docs/evolcore/group-collaboration.md +256 -0
- package/kits/docs/evolcore/group-rules.md +1 -19
- package/kits/docs/evolcore/group.md +3 -1
- package/kits/docs/evolcore/menu-client.md +34 -0
- package/kits/docs/evolcore/trigger.md +6 -3
- package/kits/docs/prompt-loading-architecture.md +6 -0
- package/kits/eck_message_manifest.json +6 -6
- 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/schemas/_meta.json +3 -2
- package/kits/schemas/agent-config.schema.12.json +427 -0
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/bootstrap.md +10 -2
- package/kits/templates/system-fragments/commands.md +2 -2
- package/package.json +11 -3
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { parse as parseToml } from 'smol-toml';
|
|
5
|
+
export function checkCodexProjectPath(value, options = {}) {
|
|
6
|
+
const configured = typeof value === 'string' ? value.trim() : '';
|
|
7
|
+
if (!configured) {
|
|
8
|
+
return { status: 'invalid', path: configured, warnings: [], reason: 'projects.defaultPath is not configured' };
|
|
9
|
+
}
|
|
10
|
+
const projectPath = path.resolve(configured);
|
|
11
|
+
const warnings = [];
|
|
12
|
+
if ((options.platform ?? process.platform) === 'win32') {
|
|
13
|
+
if (projectPath.length >= 240) {
|
|
14
|
+
warnings.push(`Windows path is long (${projectPath.length} characters); Codex or a child tool may reject it.`);
|
|
15
|
+
}
|
|
16
|
+
if (projectPath.startsWith('\\\\')) {
|
|
17
|
+
warnings.push('Windows UNC/network project path may be unavailable to Codex sandboxed processes.');
|
|
18
|
+
}
|
|
19
|
+
const systemRoot = process.env.SystemRoot ? path.resolve(process.env.SystemRoot).toLowerCase() : '';
|
|
20
|
+
if (systemRoot && projectPath.toLowerCase().startsWith(`${systemRoot}${path.sep}`)) {
|
|
21
|
+
warnings.push('Project path is under the Windows system directory; use a dedicated workspace when possible.');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const root = path.parse(projectPath).root;
|
|
25
|
+
if (projectPath === root)
|
|
26
|
+
warnings.push('Project path is a filesystem root; use a dedicated project directory when possible.');
|
|
27
|
+
try {
|
|
28
|
+
const stat = fs.statSync(projectPath);
|
|
29
|
+
if (!stat.isDirectory())
|
|
30
|
+
return { status: 'not-directory', path: projectPath, warnings, reason: 'path exists but is not a directory' };
|
|
31
|
+
try {
|
|
32
|
+
fs.accessSync(projectPath, fs.constants.R_OK | fs.constants.W_OK);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return { status: 'inaccessible', path: projectPath, warnings, reason: error instanceof Error ? error.message : String(error) };
|
|
36
|
+
}
|
|
37
|
+
return { status: 'ok', path: projectPath, warnings };
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error?.code === 'ENOENT') {
|
|
41
|
+
return { status: 'missing', path: projectPath, warnings, reason: 'directory does not exist' };
|
|
42
|
+
}
|
|
43
|
+
return { status: 'inaccessible', path: projectPath, warnings, reason: error instanceof Error ? error.message : String(error) };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function codexManagedHookPaths(options = {}) {
|
|
47
|
+
if ((options.platform ?? process.platform) !== 'win32')
|
|
48
|
+
return null;
|
|
49
|
+
const programData = options.programData || process.env.ProgramData || path.join(options.homeDir || os.homedir(), 'ProgramData');
|
|
50
|
+
const requirements = path.resolve(programData, 'OpenAI', 'Codex', 'requirements.toml');
|
|
51
|
+
const managedDir = path.join(path.dirname(requirements), 'EvolCore', 'hooks');
|
|
52
|
+
return { requirements, managedDir, hookPath: path.join(managedDir, 'pre-tool-use.mjs') };
|
|
53
|
+
}
|
|
54
|
+
function regularFileState(file) {
|
|
55
|
+
try {
|
|
56
|
+
const stat = fs.lstatSync(file);
|
|
57
|
+
if (!stat.isFile() || stat.isSymbolicLink())
|
|
58
|
+
return 'unsafe';
|
|
59
|
+
return 'ok';
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error?.code === 'ENOENT')
|
|
63
|
+
return 'missing';
|
|
64
|
+
return 'unavailable';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function realDirectoryState(directory) {
|
|
68
|
+
try {
|
|
69
|
+
const stat = fs.lstatSync(directory);
|
|
70
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
71
|
+
return 'unsafe';
|
|
72
|
+
return 'ok';
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error?.code === 'ENOENT')
|
|
76
|
+
return 'missing';
|
|
77
|
+
return 'unavailable';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/** Read-only inspection of the machine-wide Windows Codex managed hook. */
|
|
81
|
+
export function inspectCodexManagedHook(options = {}) {
|
|
82
|
+
const paths = codexManagedHookPaths(options);
|
|
83
|
+
if (!paths)
|
|
84
|
+
return { status: 'skipped', reason: 'Windows managed hooks are not applicable on this platform' };
|
|
85
|
+
const requirements = path.resolve(options.requirements || paths.requirements);
|
|
86
|
+
const managedDir = path.resolve(options.managedDir || paths.managedDir);
|
|
87
|
+
const hookPath = path.join(managedDir, 'pre-tool-use.mjs');
|
|
88
|
+
const configDirState = realDirectoryState(path.dirname(requirements));
|
|
89
|
+
const managedDirState = realDirectoryState(managedDir);
|
|
90
|
+
if ([configDirState, managedDirState].includes('unsafe')) {
|
|
91
|
+
return { status: 'unsafe', requirements, managedDir, hookPath, reason: 'requirements or managed-hook directory is not a real directory' };
|
|
92
|
+
}
|
|
93
|
+
if ([configDirState, managedDirState].includes('unavailable')) {
|
|
94
|
+
return { status: 'unavailable', requirements, managedDir, hookPath, reason: 'unable to inspect requirements or managed-hook directory' };
|
|
95
|
+
}
|
|
96
|
+
const requirementState = regularFileState(requirements);
|
|
97
|
+
const hookState = regularFileState(hookPath);
|
|
98
|
+
if ([requirementState, hookState].includes('unsafe')) {
|
|
99
|
+
return { status: 'unsafe', requirements, managedDir, hookPath, reason: 'requirements.toml or launcher is not a regular file' };
|
|
100
|
+
}
|
|
101
|
+
if ([requirementState, hookState].includes('unavailable')) {
|
|
102
|
+
return { status: 'unavailable', requirements, managedDir, hookPath, reason: 'unable to read requirements.toml or launcher' };
|
|
103
|
+
}
|
|
104
|
+
if ([requirementState, hookState].includes('missing')) {
|
|
105
|
+
return { status: 'missing', requirements, managedDir, hookPath, reason: 'requirements.toml or launcher is missing' };
|
|
106
|
+
}
|
|
107
|
+
let config;
|
|
108
|
+
let launcher;
|
|
109
|
+
let source;
|
|
110
|
+
try {
|
|
111
|
+
source = fs.readFileSync(requirements, 'utf8');
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
return { status: 'unavailable', requirements, managedDir, hookPath, reason: error instanceof Error ? error.message : String(error) };
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
config = parseToml(source);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return { status: 'unsafe', requirements, managedDir, hookPath, reason: `requirements.toml is invalid: ${error instanceof Error ? error.message : String(error)}` };
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
launcher = fs.readFileSync(hookPath, 'utf8');
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return { status: 'unavailable', requirements, managedDir, hookPath, reason: error instanceof Error ? error.message : String(error) };
|
|
127
|
+
}
|
|
128
|
+
const normalized = (value) => path.normalize(String(value || '')).toLowerCase();
|
|
129
|
+
const expectedPackageRoot = path.resolve(options.packageRoot || process.cwd());
|
|
130
|
+
const launcherValid = launcher.includes('EVOLCORE_MANAGED_HOOK_LAUNCHER')
|
|
131
|
+
&& launcher.toLowerCase().includes(JSON.stringify(expectedPackageRoot).toLowerCase());
|
|
132
|
+
const configuredDir = config.hooks?.windows_managed_dir ?? config.hooks?.managed_dir;
|
|
133
|
+
const groups = config.hooks?.PreToolUse;
|
|
134
|
+
const canonicalCommand = (value) => {
|
|
135
|
+
if (typeof value !== 'string' || !value || /[\r\n;&|<>]/.test(value))
|
|
136
|
+
return false;
|
|
137
|
+
const withoutSocket = value.replace(/\s+%EVOLCORE_INSTANCE_SOCKET%\s*$/i, '').trim();
|
|
138
|
+
return withoutSocket.replace(/["']+$/, '').toLowerCase().endsWith(normalized(hookPath));
|
|
139
|
+
};
|
|
140
|
+
const hookLoaded = Array.isArray(groups) && groups.some((group) => group?.matcher === '*'
|
|
141
|
+
&& Array.isArray(group.hooks) && group.hooks.some((handler) => {
|
|
142
|
+
const command = typeof handler?.command === 'string' ? handler.command : '';
|
|
143
|
+
const windowsCommand = typeof handler?.command_windows === 'string' ? handler.command_windows : '';
|
|
144
|
+
return handler?.type === 'command' && handler.async !== true
|
|
145
|
+
&& canonicalCommand(command) && canonicalCommand(windowsCommand);
|
|
146
|
+
}));
|
|
147
|
+
const valid = config.allow_managed_hooks_only === true
|
|
148
|
+
&& config.features?.hooks === true
|
|
149
|
+
&& normalized(configuredDir) === normalized(managedDir)
|
|
150
|
+
&& launcherValid && hookLoaded;
|
|
151
|
+
return valid
|
|
152
|
+
? { status: 'installed', requirements, managedDir, hookPath }
|
|
153
|
+
: { status: 'unsafe', requirements, managedDir, hookPath, reason: 'managed-hook policy is missing, altered, or points outside the canonical target' };
|
|
154
|
+
}
|