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
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { getArgValue, wantsHelp } from './help.js';
|
|
3
|
+
import { executeMenuClientRequest, MenuClientError } from '../aun/menu-client.js';
|
|
4
|
+
function parseDurationMs(value) {
|
|
5
|
+
if (value === undefined)
|
|
6
|
+
return undefined;
|
|
7
|
+
const match = value.trim().match(/^(\d+(?:\.\d+)?)(ms|s|m|h)$/i);
|
|
8
|
+
if (!match)
|
|
9
|
+
throw new MenuClientError('INVALID_ARGUMENT', `Invalid timeout: ${value}`);
|
|
10
|
+
const amount = Number(match[1]);
|
|
11
|
+
const unit = match[2].toLowerCase();
|
|
12
|
+
return amount * (unit === 'ms' ? 1 : unit === 's' ? 1_000 : unit === 'm' ? 60_000 : 3_600_000);
|
|
13
|
+
}
|
|
14
|
+
function readRequest(args) {
|
|
15
|
+
const file = getArgValue(args, '--request-file');
|
|
16
|
+
const inline = getArgValue(args, '--request-json');
|
|
17
|
+
if (!!file === !!inline)
|
|
18
|
+
throw new MenuClientError('INVALID_ARGUMENT', '--request-file and --request-json are mutually exclusive');
|
|
19
|
+
let raw;
|
|
20
|
+
try {
|
|
21
|
+
raw = file ? fs.readFileSync(file, 'utf8') : inline;
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw new MenuClientError('INVALID_ARGUMENT', `Unable to read request: ${error?.message ?? String(error)}`);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const parsed = JSON.parse(raw);
|
|
28
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
29
|
+
throw new Error('request must be a JSON object');
|
|
30
|
+
return parsed;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new MenuClientError('INVALID_ARGUMENT', `Invalid request JSON: ${error?.message ?? String(error)}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function validateOptions(args) {
|
|
37
|
+
const valueOptions = new Set(['--request-file', '--request-json', '--timeout', '--remote-token', '--ecweb-token', '--app', '--aun-path', '--format']);
|
|
38
|
+
const booleanOptions = new Set(['--encrypt', '--no-encrypt']);
|
|
39
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
40
|
+
const option = args[index];
|
|
41
|
+
if (booleanOptions.has(option))
|
|
42
|
+
continue;
|
|
43
|
+
if (!valueOptions.has(option))
|
|
44
|
+
throw new MenuClientError('INVALID_ARGUMENT', `Unknown menu-client option: ${option}`);
|
|
45
|
+
if (index + 1 >= args.length || args[index + 1].startsWith('--')) {
|
|
46
|
+
throw new MenuClientError('INVALID_ARGUMENT', `${option} requires a value`);
|
|
47
|
+
}
|
|
48
|
+
index += 1;
|
|
49
|
+
}
|
|
50
|
+
if (args.includes('--encrypt') && args.includes('--no-encrypt')) {
|
|
51
|
+
throw new MenuClientError('INVALID_ARGUMENT', '--encrypt and --no-encrypt are mutually exclusive');
|
|
52
|
+
}
|
|
53
|
+
const format = getArgValue(args, '--format');
|
|
54
|
+
if (format !== undefined && format !== 'json')
|
|
55
|
+
throw new MenuClientError('INVALID_ARGUMENT', '--format currently supports only json');
|
|
56
|
+
}
|
|
57
|
+
export async function cmdMenuClient(args) {
|
|
58
|
+
if (wantsHelp(args)) {
|
|
59
|
+
console.log(`用法: ec menu-client request <from-aid> <daemon-aid> [选项]
|
|
60
|
+
|
|
61
|
+
--request-file <path> 从 JSON 文件读取一个 menu.* 请求
|
|
62
|
+
--request-json <json> 直接传入一个 menu.* JSON 请求
|
|
63
|
+
--timeout <时长> 默认 15s,最大 120s
|
|
64
|
+
--encrypt 使用 E2EE(默认)
|
|
65
|
+
--no-encrypt 已拒绝:ec-menu-client 必须使用 E2EE
|
|
66
|
+
--remote-token <token> 使用 daemon 远程访问 token 临时授权
|
|
67
|
+
--ecweb-token <token> --remote-token 的兼容别名
|
|
68
|
+
--app <slot> 覆盖默认 evolcore-menu-client 消费槽位
|
|
69
|
+
--aun-path <path> 覆盖本地 AUN keystore 根目录
|
|
70
|
+
--format json 输出标准 menu.response JSON`);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (args[0] !== 'request')
|
|
74
|
+
throw new MenuClientError('INVALID_ARGUMENT', 'menu-client currently supports only the request subcommand');
|
|
75
|
+
const fromAid = args[1]?.trim();
|
|
76
|
+
const targetAid = args[2]?.trim();
|
|
77
|
+
if (!fromAid || !targetAid)
|
|
78
|
+
throw new MenuClientError('INVALID_ARGUMENT', 'request requires <from-aid> and <daemon-aid>');
|
|
79
|
+
const options = args.slice(3);
|
|
80
|
+
validateOptions(options);
|
|
81
|
+
const request = readRequest(options);
|
|
82
|
+
const timeoutMs = parseDurationMs(getArgValue(args, '--timeout'));
|
|
83
|
+
const encrypt = args.includes('--no-encrypt') ? false : true;
|
|
84
|
+
const response = await executeMenuClientRequest({
|
|
85
|
+
fromAid,
|
|
86
|
+
targetAid,
|
|
87
|
+
request,
|
|
88
|
+
timeoutMs,
|
|
89
|
+
encrypt,
|
|
90
|
+
remoteAccessToken: getArgValue(args, '--remote-token') ?? getArgValue(args, '--ecweb-token'),
|
|
91
|
+
slotId: getArgValue(args, '--app'),
|
|
92
|
+
aunPath: getArgValue(args, '--aun-path'),
|
|
93
|
+
});
|
|
94
|
+
console.log(JSON.stringify(response, null, 2));
|
|
95
|
+
}
|
package/dist/cli/model.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import { isHelpFlag, wantsHelp, getArgValue } from './help.js';
|
|
14
14
|
import { ModelScopeError, normalizePeer, determineScope, activeBaseagent, writeScope, clearScope, } from '../core/model/config-scope.js';
|
|
15
15
|
import { resolveEffectiveFieldWithSource } from '../config/config-manager.js';
|
|
16
|
-
import { getCatalog, getModelInfo } from '../core/model/model-catalog.js';
|
|
16
|
+
import { getCatalog, getModelInfo, catalogEfforts, resolveCatalogModel, assertCatalogSelectable } from '../core/model/model-catalog.js';
|
|
17
17
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole, } from '../core/model/model-permission.js';
|
|
18
18
|
import { resolvePaths } from '../paths.js';
|
|
19
19
|
import { ipcQuery } from '../ipc.js';
|
|
@@ -23,7 +23,7 @@ import { getFieldPermission } from '../config/roles.js';
|
|
|
23
23
|
import { AGENT_DELEGATION_TOKEN_ENV } from '../core/auth/agent-delegation.js';
|
|
24
24
|
import { formatModelCheck, runModelCheck } from '../core/model/model-diagnostics.js';
|
|
25
25
|
import { validateRuntimeStringFieldOverride } from '../core/role/runtime-policy.js';
|
|
26
|
-
const ALL_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max', 'auto'];
|
|
26
|
+
const ALL_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'auto'];
|
|
27
27
|
const SCOPE_LABEL = {
|
|
28
28
|
global: '全局', agent: 'agent级', role: '角色级', relation: '关系级',
|
|
29
29
|
};
|
|
@@ -298,7 +298,7 @@ async function cmdList(args, formatJson) {
|
|
|
298
298
|
const cat = await getCatalog(sel.self, ba);
|
|
299
299
|
const resolved = resolveModelConfig(effectiveSel, ba);
|
|
300
300
|
const allowedModelIds = role
|
|
301
|
-
? filterModelsForRole(role, ba, cat.models.map(m => m.id),
|
|
301
|
+
? filterModelsForRole(role, ba, cat.models.map(m => m.id), model => resolveCatalogModel(cat, model), sel.self)
|
|
302
302
|
: null;
|
|
303
303
|
const models = allowedModelIds
|
|
304
304
|
? allowedModelIds.map(id => cat.models.find(m => m.id === id) ?? { id })
|
|
@@ -308,15 +308,21 @@ async function cmdList(args, formatJson) {
|
|
|
308
308
|
effective: { model: resolved.model ?? null, source: resolved.source ?? null },
|
|
309
309
|
role: role ?? null,
|
|
310
310
|
catalogSource: cat.source,
|
|
311
|
+
freshness: cat.freshness,
|
|
312
|
+
revision: cat.revision,
|
|
313
|
+
fetchedAt: cat.fetchedAt,
|
|
314
|
+
diagnostics: cat.diagnostics,
|
|
311
315
|
models,
|
|
312
316
|
}, () => {
|
|
313
317
|
const lines = [];
|
|
314
318
|
lines.push(`当前生效: ${resolved.model ?? '(未设置,回落 SDK 默认)'}` +
|
|
315
319
|
(resolved.source ? ` (来源: ${SCOPE_LABEL[resolved.source]})` : ''));
|
|
316
320
|
lines.push('');
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
321
|
+
if (resolved.model && !cat.models.some(m => m.id === resolved.model))
|
|
322
|
+
lines.push('当前配置未列入目录');
|
|
323
|
+
lines.push(...cat.diagnostics.map(d => d.message));
|
|
324
|
+
const srcTag = cat.freshness === 'fallback' ? ` [${cat.source}/unverified]`
|
|
325
|
+
: cat.freshness === 'stale' ? ' [stale]' : '';
|
|
320
326
|
lines.push(`可用模型 (${models.length})${srcTag}:`);
|
|
321
327
|
for (const e of models) {
|
|
322
328
|
const live = resolved.model === e.id ? '✓' : ' ';
|
|
@@ -430,6 +436,7 @@ async function cmdUse(args, formatJson) {
|
|
|
430
436
|
const ba = activeBaseagent(sel.self);
|
|
431
437
|
// 校验模型在 catalog 中
|
|
432
438
|
const cat = await getCatalog(sel.self, ba);
|
|
439
|
+
assertCatalogSelectable(cat);
|
|
433
440
|
if (!cat.models.some(m => m.id === modelId)) {
|
|
434
441
|
fail(formatJson, 'UNKNOWN_MODEL', `模型不在目录中: ${modelId}(model list 查看可用模型)`);
|
|
435
442
|
}
|
|
@@ -439,14 +446,15 @@ async function cmdUse(args, formatJson) {
|
|
|
439
446
|
baseagent: ba,
|
|
440
447
|
requestedModel: modelId,
|
|
441
448
|
models: cat.models.map(m => m.id),
|
|
449
|
+
resolveModelId: model => resolveCatalogModel(cat, model),
|
|
442
450
|
selfAid: sel.self,
|
|
443
451
|
});
|
|
444
452
|
if (!decision.ok)
|
|
445
453
|
fail(formatJson, decision.code || 'MODEL_NOT_ALLOWED', decision.message || `model not allowed: ${modelId}`);
|
|
446
454
|
}
|
|
447
455
|
const effort = getArgValue(args, '--effort');
|
|
448
|
-
if (effort !== undefined && !
|
|
449
|
-
fail(formatJson, 'INVALID_EFFORT',
|
|
456
|
+
if (effort !== undefined && effort !== 'auto' && !catalogEfforts(cat, modelId, ba).includes(effort)) {
|
|
457
|
+
fail(formatJson, 'INVALID_EFFORT', `当前模型目录未声明支持推理强度: ${effort}`);
|
|
450
458
|
}
|
|
451
459
|
const effortVal = effort === 'auto' ? null : (effort ?? undefined);
|
|
452
460
|
if (isManagedTargetedWriteEnv(args)) {
|
|
@@ -492,6 +500,13 @@ async function cmdEffort(args, formatJson) {
|
|
|
492
500
|
const scope = determineWriteScope(sel, formatJson);
|
|
493
501
|
const ba = activeBaseagent(sel.self);
|
|
494
502
|
const val = level === 'auto' ? null : level;
|
|
503
|
+
if (val) {
|
|
504
|
+
const cat = await getCatalog(sel.self, ba);
|
|
505
|
+
assertCatalogSelectable(cat);
|
|
506
|
+
const model = resolveModelConfig(selectorWithRole(sel, explicitOrDerivedRole(args, sel)), ba).model;
|
|
507
|
+
if (!model || !catalogEfforts(cat, model, ba).includes(val))
|
|
508
|
+
fail(formatJson, 'INVALID_EFFORT', `当前模型目录未声明支持推理强度: ${val}`);
|
|
509
|
+
}
|
|
495
510
|
if (isManagedTargetedWriteEnv(args)) {
|
|
496
511
|
const effortKey = 'effort';
|
|
497
512
|
preflightManagedFieldOverride(sel, explicitOrDerivedRole(args, sel), `baseagents.${ba}.${effortKey}`, val, formatJson);
|