evolcore 0.0.7 → 0.0.9
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 +43 -0
- package/README.md +38 -4
- package/dist/agents/baseagent.js +117 -24
- package/dist/agents/claude-runner.js +31 -2
- package/dist/agents/codex-app-server-client.js +37 -2
- package/dist/agents/codex-runner.js +11 -3
- package/dist/aun/aid/control-aid.js +40 -27
- package/dist/aun/aid/domain.js +23 -0
- package/dist/aun/msg/group.js +9 -9
- package/dist/aun/msg/p2p.js +11 -6
- package/dist/aun/msg/upload.js +43 -29
- package/dist/aun/outbox.js +48 -5
- package/dist/channels/aun.js +225 -71
- package/dist/cli/aun-commands.js +10 -7
- package/dist/cli/bench.js +4 -3
- package/dist/cli/daemon-commands.js +208 -68
- package/dist/cli/data-command.js +62 -35
- package/dist/cli/index.js +11 -1
- package/dist/cli/init-channel.js +1 -1
- package/dist/cli/init.js +112 -17
- package/dist/cli/model.js +5 -5
- package/dist/cli/restart-monitor.js +102 -22
- package/dist/config/builtin-role-templates.js +4 -3
- package/dist/config/config-field-policy.js +6 -2
- package/dist/config/config-manager.js +79 -11
- package/dist/config/gateway-config.js +80 -35
- package/dist/config/role-schema.js +18 -3
- package/dist/config/role-service.js +3 -3
- package/dist/config/role-store.js +4 -3
- package/dist/config-store.js +19 -3
- package/dist/core/auth/operation-authorizer.js +3 -1
- package/dist/core/baseagent-loader.js +5 -3
- package/dist/core/bootstrap-service.js +0 -12
- package/dist/core/capability/providers/codex-capability-provider.js +2 -2
- package/dist/core/channel-loader.js +15 -2
- package/dist/core/command/command-handler.js +1 -1
- package/dist/core/command/evol-menu-version-gate.js +3 -2
- package/dist/core/command/menu-handler.js +50 -28
- package/dist/core/command/menu-protocol.js +7 -4
- package/dist/core/command/slash-handler.js +4 -4
- package/dist/core/data-migration.js +517 -24
- package/dist/core/inference/text-inference.js +18 -5
- package/dist/core/message/message-bridge.js +17 -6
- package/dist/core/message/response-engine.js +22 -3
- package/dist/core/model/config-scope.js +3 -3
- package/dist/core/permission/tool-policy.js +18 -0
- package/dist/core/protected-paths.js +12 -1
- package/dist/index.js +794 -725
- package/dist/ipc.js +3 -1
- package/dist/product.js +1 -0
- package/dist/utils/autostart.js +27 -0
- package/dist/utils/codex-cli.js +39 -0
- package/dist/utils/cross-platform.js +147 -18
- package/dist/utils/ecweb-utils.js +15 -2
- package/dist/utils/instance-registry.js +43 -6
- package/dist/utils/macos-autostart.js +179 -0
- package/dist/utils/process-introspect.js +7 -3
- package/dist/utils/windows-autostart.js +130 -0
- package/ecagent/dist/agent-loop.d.ts +1 -1
- package/ecagent/dist/agent-loop.js +1 -1
- package/ecagent/dist/agent.d.ts +1 -1
- package/ecagent/dist/agent.js +1 -1
- package/ecagent/dist/harness/agent-harness.d.ts +1 -1
- package/ecagent/dist/harness/compaction/branch-summarization.d.ts +1 -1
- package/ecagent/dist/harness/compaction/compaction.d.ts +1 -1
- package/ecagent/dist/harness/compaction/utils.d.ts +1 -1
- package/ecagent/dist/harness/messages.d.ts +1 -1
- package/ecagent/dist/harness/session/session.d.ts +1 -1
- package/ecagent/dist/harness/types.d.ts +1 -1
- package/ecagent/dist/proxy.d.ts +1 -1
- package/ecagent/dist/proxy.js +1 -1
- package/ecagent/dist/types.d.ts +1 -1
- package/kits/migrations/migrate-role-config-v5.mjs +27 -2
- package/kits/rules/01-overview.md +3 -2
- package/kits/schemas/_meta.json +2 -1
- package/kits/schemas/agent-config.schema.10.json +19 -1
- package/kits/schemas/daemon.schema.4.json +136 -0
- package/kits/schemas/defaults.schema.4.json +15 -1
- package/kits/schemas/relation-config.schema.8.json +22 -1
- package/kits/schemas/role-config.schema.1.json +2 -2
- package/package.json +2 -4
- package/ecagent/dist/agent-loop.d.ts.map +0 -1
- package/ecagent/dist/agent-loop.js.map +0 -1
- package/ecagent/dist/agent.d.ts.map +0 -1
- package/ecagent/dist/agent.js.map +0 -1
- package/ecagent/dist/harness/agent-harness.d.ts.map +0 -1
- package/ecagent/dist/harness/agent-harness.js.map +0 -1
- package/ecagent/dist/harness/compaction/branch-summarization.d.ts.map +0 -1
- package/ecagent/dist/harness/compaction/branch-summarization.js.map +0 -1
- package/ecagent/dist/harness/compaction/compaction.d.ts.map +0 -1
- package/ecagent/dist/harness/compaction/compaction.js.map +0 -1
- package/ecagent/dist/harness/compaction/utils.d.ts.map +0 -1
- package/ecagent/dist/harness/compaction/utils.js.map +0 -1
- package/ecagent/dist/harness/env/nodejs.d.ts.map +0 -1
- package/ecagent/dist/harness/env/nodejs.js.map +0 -1
- package/ecagent/dist/harness/messages.d.ts.map +0 -1
- package/ecagent/dist/harness/messages.js.map +0 -1
- package/ecagent/dist/harness/prompt-templates.d.ts.map +0 -1
- package/ecagent/dist/harness/prompt-templates.js.map +0 -1
- package/ecagent/dist/harness/session/jsonl-repo.d.ts.map +0 -1
- package/ecagent/dist/harness/session/jsonl-repo.js.map +0 -1
- package/ecagent/dist/harness/session/jsonl-storage.d.ts.map +0 -1
- package/ecagent/dist/harness/session/jsonl-storage.js.map +0 -1
- package/ecagent/dist/harness/session/memory-repo.d.ts.map +0 -1
- package/ecagent/dist/harness/session/memory-repo.js.map +0 -1
- package/ecagent/dist/harness/session/memory-storage.d.ts.map +0 -1
- package/ecagent/dist/harness/session/memory-storage.js.map +0 -1
- package/ecagent/dist/harness/session/repo-utils.d.ts.map +0 -1
- package/ecagent/dist/harness/session/repo-utils.js.map +0 -1
- package/ecagent/dist/harness/session/session.d.ts.map +0 -1
- package/ecagent/dist/harness/session/session.js.map +0 -1
- package/ecagent/dist/harness/session/uuid.d.ts.map +0 -1
- package/ecagent/dist/harness/session/uuid.js.map +0 -1
- package/ecagent/dist/harness/skills.d.ts.map +0 -1
- package/ecagent/dist/harness/skills.js.map +0 -1
- package/ecagent/dist/harness/system-prompt.d.ts.map +0 -1
- package/ecagent/dist/harness/system-prompt.js.map +0 -1
- package/ecagent/dist/harness/types.d.ts.map +0 -1
- package/ecagent/dist/harness/types.js.map +0 -1
- package/ecagent/dist/harness/utils/shell-output.d.ts.map +0 -1
- package/ecagent/dist/harness/utils/shell-output.js.map +0 -1
- package/ecagent/dist/harness/utils/truncate.d.ts.map +0 -1
- package/ecagent/dist/harness/utils/truncate.js.map +0 -1
- package/ecagent/dist/index.d.ts.map +0 -1
- package/ecagent/dist/index.js.map +0 -1
- package/ecagent/dist/node.d.ts.map +0 -1
- package/ecagent/dist/node.js.map +0 -1
- package/ecagent/dist/proxy.d.ts.map +0 -1
- package/ecagent/dist/proxy.js.map +0 -1
- package/ecagent/dist/runtime/api/lazy.d.ts.map +0 -1
- package/ecagent/dist/runtime/api/lazy.js.map +0 -1
- package/ecagent/dist/runtime/api/pi-messages.d.ts.map +0 -1
- package/ecagent/dist/runtime/api/pi-messages.js.map +0 -1
- package/ecagent/dist/runtime/api/pi-messages.lazy.d.ts.map +0 -1
- package/ecagent/dist/runtime/api/pi-messages.lazy.js.map +0 -1
- package/ecagent/dist/runtime/auth/context.d.ts.map +0 -1
- package/ecagent/dist/runtime/auth/context.js.map +0 -1
- package/ecagent/dist/runtime/auth/credential-store.d.ts.map +0 -1
- package/ecagent/dist/runtime/auth/credential-store.js.map +0 -1
- package/ecagent/dist/runtime/auth/helpers.d.ts.map +0 -1
- package/ecagent/dist/runtime/auth/helpers.js.map +0 -1
- package/ecagent/dist/runtime/auth/resolve.d.ts.map +0 -1
- package/ecagent/dist/runtime/auth/resolve.js.map +0 -1
- package/ecagent/dist/runtime/auth/types.d.ts.map +0 -1
- package/ecagent/dist/runtime/auth/types.js.map +0 -1
- package/ecagent/dist/runtime/compat.d.ts.map +0 -1
- package/ecagent/dist/runtime/compat.js.map +0 -1
- package/ecagent/dist/runtime/index.d.ts.map +0 -1
- package/ecagent/dist/runtime/index.js.map +0 -1
- package/ecagent/dist/runtime/models.d.ts.map +0 -1
- package/ecagent/dist/runtime/models.js.map +0 -1
- package/ecagent/dist/runtime/oauth.d.ts.map +0 -1
- package/ecagent/dist/runtime/oauth.js.map +0 -1
- package/ecagent/dist/runtime/providers/faux.d.ts.map +0 -1
- package/ecagent/dist/runtime/providers/faux.js.map +0 -1
- package/ecagent/dist/runtime/types.d.ts.map +0 -1
- package/ecagent/dist/runtime/types.js.map +0 -1
- package/ecagent/dist/runtime/utils/diagnostics.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/diagnostics.js.map +0 -1
- package/ecagent/dist/runtime/utils/event-stream.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/event-stream.js.map +0 -1
- package/ecagent/dist/runtime/utils/headers.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/headers.js.map +0 -1
- package/ecagent/dist/runtime/utils/json-parse.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/json-parse.js.map +0 -1
- package/ecagent/dist/runtime/utils/oauth/types.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/oauth/types.js.map +0 -1
- package/ecagent/dist/runtime/utils/overflow.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/overflow.js.map +0 -1
- package/ecagent/dist/runtime/utils/provider-env.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/provider-env.js.map +0 -1
- package/ecagent/dist/runtime/utils/retry.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/retry.js.map +0 -1
- package/ecagent/dist/runtime/utils/typebox-helpers.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/typebox-helpers.js.map +0 -1
- package/ecagent/dist/runtime/utils/validation.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/validation.js.map +0 -1
- package/ecagent/dist/types.d.ts.map +0 -1
- package/ecagent/dist/types.js.map +0 -1
- package/ecagent/package.json +0 -93
- package/ecagent/src/agent-loop.ts +0 -792
- package/ecagent/src/agent.ts +0 -575
- package/ecagent/src/harness/agent-harness.ts +0 -1029
- package/ecagent/src/harness/compaction/branch-summarization.ts +0 -261
- package/ecagent/src/harness/compaction/compaction.ts +0 -753
- package/ecagent/src/harness/compaction/utils.ts +0 -144
- package/ecagent/src/harness/env/nodejs.ts +0 -569
- package/ecagent/src/harness/messages.ts +0 -164
- package/ecagent/src/harness/prompt-templates.ts +0 -267
- package/ecagent/src/harness/session/jsonl-repo.ts +0 -179
- package/ecagent/src/harness/session/jsonl-storage.ts +0 -314
- package/ecagent/src/harness/session/memory-repo.ts +0 -50
- package/ecagent/src/harness/session/memory-storage.ts +0 -133
- package/ecagent/src/harness/session/repo-utils.ts +0 -51
- package/ecagent/src/harness/session/session.ts +0 -338
- package/ecagent/src/harness/session/uuid.ts +0 -54
- package/ecagent/src/harness/skills.ts +0 -375
- package/ecagent/src/harness/system-prompt.ts +0 -34
- package/ecagent/src/harness/types.ts +0 -838
- package/ecagent/src/harness/utils/shell-output.ts +0 -135
- package/ecagent/src/harness/utils/truncate.ts +0 -344
- package/ecagent/src/index.ts +0 -46
- package/ecagent/src/node.ts +0 -2
- package/ecagent/src/proxy.ts +0 -367
- package/ecagent/src/runtime/api/lazy.ts +0 -70
- package/ecagent/src/runtime/api/pi-messages.lazy.ts +0 -4
- package/ecagent/src/runtime/api/pi-messages.ts +0 -436
- package/ecagent/src/runtime/auth/context.ts +0 -45
- package/ecagent/src/runtime/auth/credential-store.ts +0 -47
- package/ecagent/src/runtime/auth/helpers.ts +0 -46
- package/ecagent/src/runtime/auth/resolve.ts +0 -141
- package/ecagent/src/runtime/auth/types.ts +0 -182
- package/ecagent/src/runtime/compat.ts +0 -158
- package/ecagent/src/runtime/index.ts +0 -31
- package/ecagent/src/runtime/models.ts +0 -452
- package/ecagent/src/runtime/oauth.ts +0 -1
- package/ecagent/src/runtime/providers/faux.ts +0 -538
- package/ecagent/src/runtime/types.ts +0 -718
- package/ecagent/src/runtime/utils/diagnostics.ts +0 -45
- package/ecagent/src/runtime/utils/event-stream.ts +0 -88
- package/ecagent/src/runtime/utils/headers.ts +0 -18
- package/ecagent/src/runtime/utils/json-parse.ts +0 -124
- package/ecagent/src/runtime/utils/oauth/types.ts +0 -79
- package/ecagent/src/runtime/utils/overflow.ts +0 -165
- package/ecagent/src/runtime/utils/provider-env.ts +0 -52
- package/ecagent/src/runtime/utils/retry.ts +0 -101
- package/ecagent/src/runtime/utils/typebox-helpers.ts +0 -24
- package/ecagent/src/runtime/utils/validation.ts +0 -310
- package/ecagent/src/types.ts +0 -430
- package/ecagent/tsconfig.build.json +0 -32
|
@@ -4,10 +4,12 @@ import { modelMatches } from '../model/model-catalog.js';
|
|
|
4
4
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
|
|
5
5
|
import { hasModelSwitcher } from '../../agents/runner-types.js';
|
|
6
6
|
import { getCodexEfforts } from '../../agents/codex-runner.js';
|
|
7
|
+
import { execCodexCliSync, resolveCodexCliPath } from '../../utils/codex-cli.js';
|
|
7
8
|
import { resolvePaths, getPackageRoot, daemonControlDir } from '../../paths.js';
|
|
8
9
|
import { buildEnvelope } from '../message/message-utils.js';
|
|
9
10
|
import path from 'path';
|
|
10
11
|
import fs from 'fs';
|
|
12
|
+
import os from 'os';
|
|
11
13
|
import crypto from 'crypto';
|
|
12
14
|
import { execFileSync } from 'child_process';
|
|
13
15
|
import { CronExpressionParser } from 'cron-parser';
|
|
@@ -45,15 +47,25 @@ import { groupMenuAuthorizationArgs, groupMenuIntent, handleGroupMenu, } from '.
|
|
|
45
47
|
*/
|
|
46
48
|
function getBaseagentVersion(cmd) {
|
|
47
49
|
try {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const executable = cmd === 'codex' ? resolveCodexCliPath() : cmd;
|
|
51
|
+
if (!executable)
|
|
52
|
+
return null;
|
|
53
|
+
const output = cmd === 'codex'
|
|
54
|
+
? execCodexCliSync(['--version'], {
|
|
55
|
+
encoding: 'utf-8',
|
|
56
|
+
timeout: 3000,
|
|
57
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
58
|
+
})
|
|
59
|
+
: execFileSync(executable, ['--version'], {
|
|
60
|
+
encoding: 'utf-8',
|
|
61
|
+
timeout: 3000,
|
|
62
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
63
|
+
});
|
|
64
|
+
const versionOutput = String(output).trim();
|
|
53
65
|
// claude: "2.1.187 (Claude Code)" → 提取 "2.1.187"
|
|
54
66
|
// gemini: "0.38.0" → 直接返回
|
|
55
67
|
// codex: "codex-cli 0.142.0" → 提取 "0.142.0"
|
|
56
|
-
const match =
|
|
68
|
+
const match = versionOutput.match(/(\d+\.\d+\.\d+)/);
|
|
57
69
|
return match ? match[1] : null;
|
|
58
70
|
}
|
|
59
71
|
catch {
|
|
@@ -441,9 +453,6 @@ function menuConfigSource(fieldPath, sel) {
|
|
|
441
453
|
return null;
|
|
442
454
|
}
|
|
443
455
|
function menuModelConfigFieldPath(target) {
|
|
444
|
-
if (target.field === 'effort' && target.baseagent === 'codex') {
|
|
445
|
-
return `baseagents.${target.baseagent}.reasoning`;
|
|
446
|
-
}
|
|
447
456
|
return target.fieldPath;
|
|
448
457
|
}
|
|
449
458
|
function menuChatmodeScope(args) {
|
|
@@ -1870,7 +1879,6 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
1870
1879
|
const target = resolveCapabilityTarget.call(this, { channel, args, session, evolagent, fromControlChannel });
|
|
1871
1880
|
if ('error' in target)
|
|
1872
1881
|
return target;
|
|
1873
|
-
const identity = this.sessionManager.resolveIdentity(channel, userId, ...menuIdentityArgs(session));
|
|
1874
1882
|
const data = queryCapabilityTypes(target.ctx, target.config, type);
|
|
1875
1883
|
return { data: sanitizeCapabilityQueryForRole(data, identity.role) };
|
|
1876
1884
|
}
|
|
@@ -2168,11 +2176,13 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2168
2176
|
if (!subject.isDaemonOwner) {
|
|
2169
2177
|
return { error: '操作需要 owner 权限', code: 'FORBIDDEN' };
|
|
2170
2178
|
}
|
|
2171
|
-
const owningAgent = this.getOwningAgent(channel);
|
|
2172
2179
|
const data = {
|
|
2173
2180
|
aid: loadDaemonConfig().aid ?? null,
|
|
2174
2181
|
pid: process.pid,
|
|
2175
|
-
|
|
2182
|
+
nodejs: process.version,
|
|
2183
|
+
hostname: os.hostname(),
|
|
2184
|
+
platform: process.platform,
|
|
2185
|
+
arch: process.arch,
|
|
2176
2186
|
uptime: Math.floor(process.uptime()),
|
|
2177
2187
|
};
|
|
2178
2188
|
try {
|
|
@@ -2193,14 +2203,6 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2193
2203
|
const ecwebPkg = resolveGlobalPkg(WEB_PACKAGE_NAME);
|
|
2194
2204
|
if (ecwebPkg?.version)
|
|
2195
2205
|
data.ecwebVersion = ecwebPkg.version;
|
|
2196
|
-
const channels = owningAgent?.channelInstanceNames?.() ?? [];
|
|
2197
|
-
if (channels.length) {
|
|
2198
|
-
// 将 channelKey 字符串(如 "feishu#aid#name")解析为对象 { type, instName }
|
|
2199
|
-
data.channels = channels.map((key) => {
|
|
2200
|
-
const parts = key.split('#');
|
|
2201
|
-
return { type: parts[0], instName: parts[2] || parts[0] };
|
|
2202
|
-
});
|
|
2203
|
-
}
|
|
2204
2206
|
// 收集主机级可用的所有 baseagent 类型(检测已安装的 CLI + 版本)
|
|
2205
2207
|
const baseagents = [];
|
|
2206
2208
|
for (const cmd of ['claude', 'gemini', 'codex']) {
|
|
@@ -2249,7 +2251,9 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
2249
2251
|
if (cmdBase === '/perm') {
|
|
2250
2252
|
return { error: 'permissionMode 只能通过角色策略编辑器修改', code: 'ROLE_POLICY_MANAGED' };
|
|
2251
2253
|
}
|
|
2252
|
-
|
|
2254
|
+
// JSON Menu 入口在 validateMenuRequest 中要求 activity 显式 scope;保留
|
|
2255
|
+
// 底层 execMenuUpdate 的旧默认行为,兼容旧版 slash/内部直调调用方。
|
|
2256
|
+
const scopeError = validateConfigWriteScope(cmdBase, args, { includeActivity: false });
|
|
2253
2257
|
if (scopeError)
|
|
2254
2258
|
return { error: scopeError.message, code: scopeError.code };
|
|
2255
2259
|
args = withoutLegacySessionConfigArgs(args);
|
|
@@ -3506,26 +3510,43 @@ const SYSTEM_CONTROL_NAME_MAP = {
|
|
|
3506
3510
|
config: '/config', capability: '/capability', role: '/role',
|
|
3507
3511
|
group: '/group', connect: '/connect',
|
|
3508
3512
|
};
|
|
3513
|
+
function menuCommandToken(cmd) {
|
|
3514
|
+
if (typeof cmd !== 'string')
|
|
3515
|
+
return undefined;
|
|
3516
|
+
return cmd.trim().split(/\s+/, 1)[0] || undefined;
|
|
3517
|
+
}
|
|
3509
3518
|
function isProcessLevelMenu(name, cmd) {
|
|
3519
|
+
const cmdToken = menuCommandToken(cmd);
|
|
3510
3520
|
return name === 'system' || name === 'agent' || name === 'gateway' || name === 'config'
|
|
3511
|
-
||
|
|
3521
|
+
|| cmdToken === '/system' || cmdToken === '/agent' || cmdToken === '/gateway' || cmdToken === '/config';
|
|
3512
3522
|
}
|
|
3513
3523
|
async function execMenuForSystemControl(payload, context) {
|
|
3514
3524
|
const id = payload?.id ?? '';
|
|
3515
3525
|
const name = payload?.name;
|
|
3516
|
-
|
|
3526
|
+
const compatCmd = menuCommandToken(payload?.cmd);
|
|
3527
|
+
// `menu.query(/file)` returns file metadata and is authorized as
|
|
3528
|
+
// `file.fetch`, while `menu.action(file/fetch)` sends the file. Neither
|
|
3529
|
+
// operation is available through Host/control: file operations must be
|
|
3530
|
+
// addressed to the current Agent AID so the Agent project boundary applies.
|
|
3531
|
+
const isFileFetch = (payload?.type === 'menu.query'
|
|
3532
|
+
|| (payload?.type === 'menu.action' && payload?.action === 'fetch'))
|
|
3533
|
+
&& (name === 'file' || compatCmd === '/file');
|
|
3534
|
+
if (isFileFetch) {
|
|
3535
|
+
return ecwebErr(id, name, 'NOT_SUPPORTED', 'Host/control 不支持 file.fetch,请通过目标 Agent AID 请求');
|
|
3536
|
+
}
|
|
3537
|
+
if (name === 'cli' || compatCmd === '/cli') {
|
|
3517
3538
|
const message = context.source === 'ecweb'
|
|
3518
3539
|
? 'cli 不在 ECWeb 控制范围'
|
|
3519
3540
|
: 'cli 不在控制 channel 范围';
|
|
3520
3541
|
return { type: 'menu.response', id, name, error: { code: 'NOT_SUPPORTED', message } };
|
|
3521
3542
|
}
|
|
3522
3543
|
const isProcessLevel = isProcessLevelMenu(name, payload?.cmd);
|
|
3523
|
-
const isRoleRequest = name === 'role' ||
|
|
3524
|
-
const isConnectRequest = name === 'connect' ||
|
|
3544
|
+
const isRoleRequest = name === 'role' || compatCmd === '/role';
|
|
3545
|
+
const isConnectRequest = name === 'connect' || compatCmd === '/connect';
|
|
3525
3546
|
const requiresAgentTarget = isRoleRequest || isConnectRequest || [
|
|
3526
3547
|
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group',
|
|
3527
3548
|
].includes(name)
|
|
3528
|
-
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group'].includes(
|
|
3549
|
+
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group'].includes(compatCmd ?? '');
|
|
3529
3550
|
const target = isProcessLevel
|
|
3530
3551
|
? { channel: SYSTEM_CONTROL_CHANNEL }
|
|
3531
3552
|
: resolveExternalMenuAgentChannel(this, payload, SYSTEM_CONTROL_CHANNEL, requiresAgentTarget);
|
|
@@ -3624,8 +3645,9 @@ export async function execMenuForControl(payload, peerId) {
|
|
|
3624
3645
|
if (validationError)
|
|
3625
3646
|
return menuFailure({ id, ...(name ? { name } : {}) }, validationError);
|
|
3626
3647
|
const owners = loadDaemonConfig().owners ?? [];
|
|
3627
|
-
const
|
|
3628
|
-
const
|
|
3648
|
+
const compatCmd = menuCommandToken(payload?.cmd);
|
|
3649
|
+
const isRoleRequest = name === 'role' || compatCmd === '/role';
|
|
3650
|
+
const isConnectRequest = name === 'connect' || compatCmd === '/connect';
|
|
3629
3651
|
if (!isRoleRequest && !isConnectRequest && !isProcessLevelOwner(peerId, owners)) {
|
|
3630
3652
|
return menuFailure({ id, ...(name ? { name } : {}) }, { code: 'ROLE_ACCESS_DENIED', message: '控制 channel 操作需要 owner 权限' });
|
|
3631
3653
|
}
|
|
@@ -15,6 +15,7 @@ const EXPLICIT_SCOPE_UPDATE_NAMES = new Set([
|
|
|
15
15
|
'mentionmode',
|
|
16
16
|
'group',
|
|
17
17
|
'permission',
|
|
18
|
+
'activity',
|
|
18
19
|
]);
|
|
19
20
|
const EXPLICIT_SCOPE_UPDATE_COMMANDS = new Set([
|
|
20
21
|
'/model',
|
|
@@ -24,18 +25,20 @@ const EXPLICIT_SCOPE_UPDATE_COMMANDS = new Set([
|
|
|
24
25
|
'/mentionmode',
|
|
25
26
|
'/group',
|
|
26
27
|
'/perm',
|
|
28
|
+
'/activity',
|
|
27
29
|
]);
|
|
28
30
|
function firstCommandToken(value) {
|
|
29
31
|
if (typeof value !== 'string')
|
|
30
32
|
return undefined;
|
|
31
33
|
return value.trim().split(/\s+/, 1)[0] || undefined;
|
|
32
34
|
}
|
|
33
|
-
function requiresExplicitConfigWriteScope(nameOrCmd) {
|
|
35
|
+
function requiresExplicitConfigWriteScope(nameOrCmd, includeActivity = true) {
|
|
34
36
|
const token = firstCommandToken(nameOrCmd);
|
|
35
|
-
return !!token && (EXPLICIT_SCOPE_UPDATE_NAMES.has(token) || EXPLICIT_SCOPE_UPDATE_COMMANDS.has(token))
|
|
37
|
+
return !!token && (EXPLICIT_SCOPE_UPDATE_NAMES.has(token) || EXPLICIT_SCOPE_UPDATE_COMMANDS.has(token))
|
|
38
|
+
&& (includeActivity || (token !== 'activity' && token !== '/activity'));
|
|
36
39
|
}
|
|
37
|
-
export function validateConfigWriteScope(nameOrCmd, args) {
|
|
38
|
-
if (!requiresExplicitConfigWriteScope(nameOrCmd))
|
|
40
|
+
export function validateConfigWriteScope(nameOrCmd, args, options) {
|
|
41
|
+
if (!requiresExplicitConfigWriteScope(nameOrCmd, options?.includeActivity ?? true))
|
|
39
42
|
return null;
|
|
40
43
|
const rawScope = args?.scope;
|
|
41
44
|
if (rawScope === undefined || rawScope === null || (typeof rawScope === 'string' && rawScope.trim().length === 0)) {
|
|
@@ -1146,7 +1146,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1146
1146
|
}
|
|
1147
1147
|
catch { }
|
|
1148
1148
|
const configuredModel = modelConfig.model;
|
|
1149
|
-
const configuredEffort = modelConfig
|
|
1149
|
+
const configuredEffort = modelConfig.effort;
|
|
1150
1150
|
const rawModels = hasModelSwitcher(modelAgent) ? await modelAgent.listModels() : [];
|
|
1151
1151
|
const models = hasModelSwitcher(modelAgent)
|
|
1152
1152
|
? filterModelsForRole(identity.role, fallbackBaseagent, rawModels, modelAgent.resolveModelId?.bind(modelAgent))
|
|
@@ -1468,7 +1468,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1468
1468
|
}
|
|
1469
1469
|
catch { }
|
|
1470
1470
|
const configuredModel = modelConfig.model;
|
|
1471
|
-
const configuredEffort = modelConfig
|
|
1471
|
+
const configuredEffort = modelConfig.effort;
|
|
1472
1472
|
const currentModel = hasModelSwitcher(effortAgent) ? (configuredModel || effortAgent.getModel()) : effortAgent.name;
|
|
1473
1473
|
const efforts = getAvailableEfforts(effortAgent, currentModel);
|
|
1474
1474
|
const currentEffort = configuredEffort ?? effortAgent.getEffort?.() ?? 'auto';
|
|
@@ -1530,7 +1530,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
1530
1530
|
}
|
|
1531
1531
|
catch { }
|
|
1532
1532
|
const configuredModel = modelConfig.model;
|
|
1533
|
-
const configuredEffort = modelConfig
|
|
1533
|
+
const configuredEffort = modelConfig.effort;
|
|
1534
1534
|
const currentModel = hasModelSwitcher(effortAgent) ? (configuredModel || effortAgent.getModel()) : effortAgent.name;
|
|
1535
1535
|
const efforts = getAvailableEfforts(effortAgent, currentModel);
|
|
1536
1536
|
const currentEffort = configuredEffort ?? effortAgent.getEffort?.() ?? 'auto';
|
|
@@ -2210,7 +2210,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2210
2210
|
}
|
|
2211
2211
|
catch { }
|
|
2212
2212
|
const backendModel = modelConfig.model || newRunner.getModel?.() || newAgent?.model;
|
|
2213
|
-
const backendEffort = modelConfig
|
|
2213
|
+
const backendEffort = modelConfig.effort
|
|
2214
2214
|
?? newRunner.getEffort?.()
|
|
2215
2215
|
?? newAgent?.effort;
|
|
2216
2216
|
const backendBits = [newBaseagent, backendModel, backendEffort].filter(Boolean).join(' · ');
|