evolcore 0.0.43-test.1 → 0.0.43-test.3
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 +31 -1
- package/README.md +22 -0
- package/dist/agents/claude-runner.js +26 -2
- package/dist/agents/codex/app-server-client.js +12 -0
- package/dist/agents/codex-runner.js +49 -8
- package/dist/agents/ecagent-runner.js +39 -15
- package/dist/agents/gemini-runner.js +15 -12
- package/dist/agents/tool-time-context.js +55 -0
- package/dist/aun/aid/agentmd.js +21 -1
- package/dist/aun/menu/client.js +1 -1
- package/dist/aun/model-headers.js +17 -0
- package/dist/aun/msg/p2p.js +7 -2
- package/dist/channels/aun.js +522 -50
- package/dist/channels/builtin-plugins.js +16 -11
- package/dist/channels/daemon.js +4 -0
- package/dist/channels/dingtalk.js +83 -31
- package/dist/channels/feishu.js +29 -13
- package/dist/channels/qqbot.js +32 -11
- package/dist/channels/wechat.js +13 -3
- package/dist/channels/wecom.js +67 -27
- package/dist/cli/agent-command.js +3 -86
- package/dist/cli/agent-create.js +20 -6
- package/dist/cli/agent.js +1 -79
- package/dist/cli/aun-commands.js +18 -19
- package/dist/cli/config.js +1 -1
- package/dist/cli/daemon-commands.js +47 -2
- package/dist/cli/data-command.js +9 -1
- package/dist/cli/debug-mode.js +1 -1
- package/dist/cli/diag.js +1 -1
- package/dist/cli/directory.js +149 -91
- package/dist/cli/getmeta-command.js +1 -1
- package/dist/cli/index.js +79 -22
- package/dist/cli/init.js +1 -23
- package/dist/cli/link-rules.js +1 -1
- package/dist/cli/managed-command-guard.js +0 -1
- package/dist/cli/pa-workspace-command.js +36 -2
- package/dist/cli/peer.js +3 -2
- package/dist/cli/restart-monitor.js +17 -3
- package/dist/cli/role.js +1 -1
- package/dist/cli/session-command.js +1 -1
- package/dist/cli/stats.js +2 -2
- package/dist/cli/task-context.js +3 -1
- package/dist/cli/thread-command.js +1 -1
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/builtin-role-templates.js +2 -2
- package/dist/config/builtin-roles.js +2 -1
- package/dist/config/config-field-policy.js +7 -2
- package/dist/config/config-manager.js +32 -10
- package/dist/config/peer-role-resolver.js +23 -1
- package/dist/config/role-schema.js +29 -4
- package/dist/config/role-service.js +12 -7
- package/dist/config/role-store.js +30 -8
- package/dist/config-store.js +75 -4
- package/dist/core/agent-ipc-registration.js +16 -59
- package/dist/core/auth/auth-gateway.js +14 -4
- package/dist/core/auth/authorization-audit.js +52 -14
- package/dist/core/auth/operation-authorizer.js +17 -11
- package/dist/core/auth/operation-catalog.js +5 -13
- package/dist/core/channel-loader.js +152 -16
- package/dist/core/channel-runtime.js +5 -0
- package/dist/core/command/agent-control.js +2 -1
- package/dist/core/command/agentmd-menu-request.js +50 -0
- package/dist/core/command/agentmd-menu.js +156 -0
- package/dist/core/command/cli-intent-parser.js +0 -8
- package/dist/core/command/command-handler.js +47 -40
- package/dist/core/command/connect-menu.js +7 -3
- package/dist/core/command/menu-catalog.js +16 -2
- package/dist/core/command/menu-handler.js +107 -14
- package/dist/core/command/menu-protocol.js +28 -0
- package/dist/core/command/role-menu.js +23 -9
- package/dist/core/command/slash-handler.js +139 -51
- package/dist/core/daemon-file-cache.js +3 -3
- package/dist/core/daemon-lifecycle.js +9 -1
- package/dist/core/evolagent-registry.js +5 -4
- package/dist/core/evolagent.js +10 -12
- package/dist/core/handoff/argv-parse.js +115 -0
- package/dist/core/handoff/ipc-registration.js +1 -1
- package/dist/core/ipc-registration.js +19 -2
- package/dist/core/lifecycle-notice.js +185 -0
- package/dist/core/memory/consolidation.js +8 -1
- package/dist/core/memory/relation-sweep.js +20 -8
- package/dist/core/message/aun-ipc-sender.js +35 -2
- package/dist/core/message/contact-admission.js +530 -0
- package/dist/core/message/im-renderer.js +111 -16
- package/dist/core/message/message-admission.js +29 -54
- package/dist/core/message/message-bridge.js +62 -8
- package/dist/core/message/message-utils.js +9 -5
- package/dist/core/message/peer-mode.js +55 -13
- package/dist/core/message/response-engine.js +298 -78
- package/dist/core/message/retry-scheduler.js +4 -0
- package/dist/core/ownership/owner-resolver.js +72 -34
- package/dist/core/permission/ec-command-parser.js +25 -38
- package/dist/core/permission/readonly-shell-query.js +34 -8
- package/dist/core/permission/tool-policy.js +50 -5
- package/dist/core/relation/pa-team.js +127 -0
- package/dist/core/role/runtime-policy.js +18 -5
- package/dist/core/session/session-manager.js +9 -1
- package/dist/core/soul.js +66 -0
- package/dist/core/system-session/memory.js +2 -2
- package/dist/core/thread/thread-service.js +6 -4
- package/dist/directory/contact-admission-paths.js +9 -0
- package/dist/directory/owner-directory-admission.js +125 -29
- package/dist/directory/owner-directory-cache.js +554 -58
- package/dist/directory/owner-directory-identity.js +60 -0
- package/dist/directory/owner-directory-markdown.js +154 -58
- package/dist/directory/owner-directory-policy.js +108 -0
- package/dist/directory/owner-directory-query-operation.js +399 -90
- package/dist/directory/owner-directory-remarks.js +29 -2
- package/dist/directory/owner-directory-request-operation.js +76 -0
- package/dist/directory/owner-directory-scope.js +35 -4
- package/dist/directory/owner-directory-search.js +118 -33
- package/dist/directory/owner-directory-store.js +117 -30
- package/dist/directory/owner-directory-text.js +60 -0
- package/dist/eck/kit-renderer.js +18 -8
- package/dist/eck/manifest-engine.js +55 -6
- package/dist/ecweb/basic-settings-service.js +2 -2
- package/dist/ecweb/message-context-service.js +28 -16
- package/dist/index.js +20 -5
- package/dist/ipc.js +1 -1
- package/dist/paths.js +29 -1
- package/dist/product.js +1 -0
- package/dist/response-system/config-resolver.js +1 -1
- package/dist/response-system/engines/v1/index.js +2 -1
- package/dist/response-system/modes/single-session/index.js +7 -2
- package/dist/trigger/scheduler.js +7 -4
- package/dist/trigger/validation.js +4 -0
- package/dist/utils/error-utils.js +12 -7
- package/dist/utils/logger.js +13 -4
- package/dist/utils/npm-ops.js +2 -2
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +18 -0
- package/ecagent/dist/agent-loop.js +43 -1
- package/ecagent/dist/harness/agent-harness.d.ts +2 -0
- package/ecagent/dist/harness/agent-harness.js +24 -8
- package/ecagent/dist/harness/compaction/compaction.js +3 -0
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/context-assembly.md +21 -6
- package/kits/docs/eck_templates/INDEX.template.md +1 -2
- package/kits/docs/evolcore/INDEX.md +4 -1
- package/kits/docs/evolcore/agent-create.md +5 -5
- package/kits/docs/evolcore/agent.md +4 -9
- package/kits/docs/evolcore/directory.md +227 -0
- package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
- package/kits/docs/evolcore/file-navigation.md +265 -0
- package/kits/docs/evolcore/menu-protocol.md +55 -0
- package/kits/docs/evolcore/msg.md +1 -0
- package/kits/docs/evolcore/peer.md +2 -1
- package/kits/docs/evolcore/response.md +7 -1
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +1 -1
- package/kits/docs/evolcore/trigger.md +4 -0
- package/kits/docs/identity/ROLE_DETAIL.md +2 -0
- package/kits/docs/prompt-loading-architecture.md +6 -2
- package/kits/eck_manifest.auxiliary.json +1 -0
- package/kits/eck_manifest.json +64 -7
- package/kits/eck_manifest.memory.json +93 -4
- package/kits/rules/01-overview.md +2 -2
- package/kits/rules/03-identity.md +10 -9
- package/kits/rules/05-venue.md +2 -4
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +44 -3
- package/kits/schemas/agent-config.schema.18.json +5 -0
- package/kits/schemas/agent-config.schema.19.json +924 -0
- package/kits/schemas/agent-config.schema.20.json +925 -0
- package/kits/schemas/relation-config.schema.12.json +289 -0
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/schemas/role-config.schema.2.json +215 -0
- package/kits/schemas/role-config.schema.3.json +1038 -0
- package/kits/schemas/role-registry.schema.1.json +3 -2
- package/kits/skills/ec-skill/scripts/cli.mjs +3 -2
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +109 -53
- package/kits/skills/personal-assistant/references/02-bootstrap.md +73 -30
- package/kits/skills/personal-assistant/scripts/clean.mjs +35 -18
- package/kits/skills/personal-assistant/scripts/init.mjs +41 -2
- package/kits/skills/personal-assistant/scripts/lib/persona.mjs +185 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +55 -4
- package/kits/skills/personal-assistant/scripts/pa.mjs +173 -0
- package/kits/skills/personal-assistant/scripts/uninstall.mjs +130 -0
- package/kits/skills/personal-assistant/templates/persona-section.md +3 -3
- package/kits/templates/message-fragments/handoff-request-to-target.md +1 -1
- package/kits/templates/soul/00-GUIDE.md +39 -0
- package/kits/templates/soul/01-identity.md +5 -0
- package/kits/templates/soul/02-persona.md +11 -0
- package/kits/templates/soul/03-duties.md +5 -0
- package/kits/templates/soul/04-working-style.md +5 -0
- package/kits/templates/system-fragments/bootstrap.md +7 -7
- package/kits/templates/system-fragments/channel.md +2 -2
- package/kits/templates/system-fragments/commands.md +3 -2
- package/kits/templates/system-fragments/directory-contacts.md +9 -0
- package/kits/templates/system-fragments/memory.md +1 -1
- package/kits/templates/system-fragments/personal-assistant.md +50 -0
- package/kits/templates/system-fragments/reply.md +7 -0
- package/kits/templates/system-fragments/session.md +6 -2
- package/package.json +3 -2
- package/dist/cli/handoff-command.js +0 -353
- package/dist/directory/owner-directory-remark-operation.js +0 -147
- package/kits/docs/evolcore/self-summary.md +0 -29
|
@@ -15,6 +15,7 @@ import { logger } from '../../utils/logger.js';
|
|
|
15
15
|
import { resolvePeerRoleDetail, roleToSessionIdentity } from '../../config/peer-role-resolver.js';
|
|
16
16
|
import { ThreadService } from '../thread/thread-service.js';
|
|
17
17
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
18
|
+
import { resolveAgentLifecycle } from '../../config/lifecycle.js';
|
|
18
19
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
19
20
|
import { sameGroupAid } from '../../aun/group/index.js';
|
|
20
21
|
import crypto from 'crypto';
|
|
@@ -37,8 +38,8 @@ import { parseTimeArg, TIME_ARG_FORMATS, splitConfigBatchGetArgv } from '../../c
|
|
|
37
38
|
import { auditCommandAuthorization, auditFullAccessEvent, hashArgv } from '../auth/authorization-audit.js';
|
|
38
39
|
import { ResponseModeRegistry } from '../../response-system/registry.js';
|
|
39
40
|
import { registerBuiltinModes } from '../../response-system/modes/index.js';
|
|
40
|
-
import { DirectoryRemarkError, executeDirectoryRemarkCommand, resolveDirectoryRemarkCommand, } from '../../directory/owner-directory-remark-operation.js';
|
|
41
41
|
import { DirectoryQueryError, executeDirectoryQueryCommand, resolveDirectoryQueryCommand, } from '../../directory/owner-directory-query-operation.js';
|
|
42
|
+
import { executeDirectoryRequestCommand, resolveDirectoryRequestCommand, } from '../../directory/owner-directory-request-operation.js';
|
|
42
43
|
import { executeResolvedRoleCommand, resolveRoleCommand } from '../../config/role-command-service.js';
|
|
43
44
|
import { applyApprovedRoleAssignment } from './role-menu.js';
|
|
44
45
|
import { executeResolvedPeerCommand, resolvePeerCommand } from '../../config/peer-operation-service.js';
|
|
@@ -56,7 +57,7 @@ import { constrainRuntimePermissionMode, resolveRuntimePermissionMode, validateR
|
|
|
56
57
|
import { parsePeerKey } from '../relation/peer-identity.js';
|
|
57
58
|
import { isQuickCommand } from './slash-gate.js';
|
|
58
59
|
import { handleSlashCommand } from './slash-handler.js';
|
|
59
|
-
import { resolveChatMode } from '../message/peer-mode.js';
|
|
60
|
+
import { isChatMode, resolveChatMode } from '../message/peer-mode.js';
|
|
60
61
|
import { execMenuAction as menuExecMenuAction, execMenuForEcweb as menuExecMenuForEcweb, execMenuForControl as menuExecMenuForControl, execMenuQuery as menuExecMenuQuery, execMenuUpdate as menuExecMenuUpdate, getMenuItems as menuGetMenuItems, getSubMenuItems as menuGetSubMenuItems, buildTopicForkSourcePayload, } from './menu-handler.js';
|
|
61
62
|
import { getMenuCatalog, execMenuValueBatch, validateMenuValueBatchArgs } from './menu-catalog.js';
|
|
62
63
|
import { resolveCurrentSessionLoopTarget, sessionLoopError } from '../session/session-idle-monitor.js';
|
|
@@ -1838,7 +1839,10 @@ export class CommandHandler {
|
|
|
1838
1839
|
if (meta?.replyContext?.replyInThread)
|
|
1839
1840
|
ctx.replyInThread = meta.replyContext.replyInThread;
|
|
1840
1841
|
const taskId = this.sessionManager.getActiveTaskId(session.id);
|
|
1841
|
-
const
|
|
1842
|
+
const taskChatmode = taskId && meta?.turnState?.active?.taskId === taskId
|
|
1843
|
+
? meta.turnState.active.recoveryContext?.chatmode
|
|
1844
|
+
: undefined;
|
|
1845
|
+
const chatmode = isChatMode(taskChatmode) ? taskChatmode : this.resolveEffectiveChatmodeForSession(session);
|
|
1842
1846
|
const encrypted = this.sessionManager.getSessionEncrypt(session.id);
|
|
1843
1847
|
// 诊断日志:记录 task_id 解析结果
|
|
1844
1848
|
logger.info(`[CommandHandler] buildCtlReplyContext: sessionId=${session.id} taskId=${taskId ?? 'none'} chatmode=${chatmode} threadId=${ctx.threadId ?? 'none'} replyTo=${ctx.replyToMessageId ?? 'none'} inThread=${ctx.replyInThread ?? false}`);
|
|
@@ -1868,6 +1872,9 @@ export class CommandHandler {
|
|
|
1868
1872
|
role: session.identity?.role,
|
|
1869
1873
|
chatType: session.chatType,
|
|
1870
1874
|
peerType,
|
|
1875
|
+
channelType,
|
|
1876
|
+
lifecycle: resolveAgentLifecycle(this.getOwningAgent(session.channel)?.config ?? {}),
|
|
1877
|
+
sessionType: session.sessionType ?? session.metadata?.sessionType ?? 'main',
|
|
1871
1878
|
});
|
|
1872
1879
|
}
|
|
1873
1880
|
catch {
|
|
@@ -2148,13 +2155,10 @@ export class CommandHandler {
|
|
|
2148
2155
|
}
|
|
2149
2156
|
}
|
|
2150
2157
|
/**
|
|
2151
|
-
* `ec directory
|
|
2152
|
-
*
|
|
2153
|
-
* 备注写的是**目标 Agent** 的目录,不是调用方自己的目录——个人助理要维护
|
|
2154
|
-
* 别的 agent 的名录备注,沙箱权限写不进去,所以统一由 daemon 落盘。
|
|
2158
|
+
* `ec directory ...`:查询、重算注入与向当前 Agent 的 Owner 申请入录。
|
|
2155
2159
|
*
|
|
2160
|
+
* 备注不走命令——它是自己的 agent 目录下的一个 markdown 文件,由 Agent 直接读写。
|
|
2156
2161
|
* 权限边界:目标 Agent 必须是调用方自身,或者与调用方同属一个 Owner。
|
|
2157
|
-
* 这条限制防止一个 agent 借命令去改无关 Agent 的注入内容。
|
|
2158
2162
|
*/
|
|
2159
2163
|
async handleDirectoryOperation(argv, sessionId, delegationToken, delegationCommandHash) {
|
|
2160
2164
|
if (!this.agentDelegationRegistry) {
|
|
@@ -2166,14 +2170,19 @@ export class CommandHandler {
|
|
|
2166
2170
|
const session = await this.sessionManager.getSessionById(sessionId);
|
|
2167
2171
|
if (!session)
|
|
2168
2172
|
return { ok: false, code: 'INVALID_SESSION', error: 'Invalid session' };
|
|
2169
|
-
// argv 形如 ['directory', '<sub>', ...]
|
|
2170
|
-
const
|
|
2171
|
-
const subArgv = argv.slice(isRemark ? 2 : 1);
|
|
2173
|
+
// argv 形如 ['directory', '<sub>', ...]
|
|
2174
|
+
const rawSubArgv = argv.slice(1);
|
|
2172
2175
|
const grantSelfAid = delegation.grant.selfAid.replace(/^@/, '');
|
|
2173
2176
|
const sessionSelfAid = session.selfAID?.replace(/^@/, '');
|
|
2174
2177
|
if (sessionSelfAid && sessionSelfAid !== grantSelfAid) {
|
|
2175
2178
|
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation self agent does not match the active session' };
|
|
2176
2179
|
}
|
|
2180
|
+
// `--self` 缺省时回落到委托凭据里的本端 Agent:托管 runner 只注入任务上下文、
|
|
2181
|
+
// 不注入 EVOLCORE_SELF_AID,而调用方本来就只可能查自己(下面还会校验 target
|
|
2182
|
+
// 与凭据一致)。这与 peer / role 的补齐方式保持一致,不构成权限放宽。
|
|
2183
|
+
const subArgv = rawSubArgv.includes('--self')
|
|
2184
|
+
? rawSubArgv
|
|
2185
|
+
: [...rawSubArgv, '--self', grantSelfAid];
|
|
2177
2186
|
const selfIndex = subArgv.indexOf('--self');
|
|
2178
2187
|
const targetAid = selfIndex >= 0 && selfIndex === subArgv.lastIndexOf('--self')
|
|
2179
2188
|
? subArgv[selfIndex + 1]
|
|
@@ -2188,7 +2197,11 @@ export class CommandHandler {
|
|
|
2188
2197
|
catch {
|
|
2189
2198
|
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation contains an invalid relation key' };
|
|
2190
2199
|
}
|
|
2191
|
-
const
|
|
2200
|
+
const isRequest = subArgv[0] === 'request';
|
|
2201
|
+
if (isRequest && targetAid !== grantSelfAid) {
|
|
2202
|
+
return { ok: false, code: 'SCOPE_MISMATCH', error: '加好友申请只能由当前任务所属 Agent 发起' };
|
|
2203
|
+
}
|
|
2204
|
+
const operation = isRequest ? 'ec.directory.request' : 'ec.directory.query';
|
|
2192
2205
|
const subject = buildAuthSubject({
|
|
2193
2206
|
selfAid: grantSelfAid,
|
|
2194
2207
|
sessionId,
|
|
@@ -2217,41 +2230,37 @@ export class CommandHandler {
|
|
|
2217
2230
|
messageId: delegation.grant.messageId,
|
|
2218
2231
|
},
|
|
2219
2232
|
}, async (onExecutionStarted) => {
|
|
2220
|
-
|
|
2221
|
-
if (bodyFileIndex >= 0) {
|
|
2222
|
-
const rawBodyFile = subArgv[bodyFileIndex + 1];
|
|
2223
|
-
if (!rawBodyFile || rawBodyFile.startsWith('--') || bodyFileIndex !== subArgv.lastIndexOf('--body-file')) {
|
|
2224
|
-
return { ok: false, code: 'INVALID_ARGUMENT', error: '--body-file must occur once with a file path' };
|
|
2225
|
-
}
|
|
2233
|
+
if (isRequest) {
|
|
2226
2234
|
try {
|
|
2227
|
-
const
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
.map(root => fs.realpathSync(root));
|
|
2231
|
-
const requestedPath = path.resolve(projectPath, rawBodyFile);
|
|
2232
|
-
const stat = fs.lstatSync(requestedPath);
|
|
2233
|
-
const realPath = fs.realpathSync(requestedPath);
|
|
2234
|
-
const inManagedTemp = !!tempPath && isSameOrDescendant(realPath, fs.realpathSync(tempPath));
|
|
2235
|
-
if (stat.isSymbolicLink() || !stat.isFile() || stat.size > 16 * 1024
|
|
2236
|
-
|| !allowedRoots.some(root => isSameOrDescendant(realPath, root))
|
|
2237
|
-
|| (!hasTrustedFullAccessDelegation(delegation.grant) && (isHClassPath(realPath) || isLClassPath(realPath)))
|
|
2238
|
-
|| (inManagedTemp && stat.nlink > 1)) {
|
|
2239
|
-
return { ok: false, code: 'INVALID_ARGUMENT', error: '--body-file must be a small regular file in the session project or TMPDIR' };
|
|
2235
|
+
const command = resolveDirectoryRequestCommand(subArgv);
|
|
2236
|
+
if (command.selfAid !== grantSelfAid) {
|
|
2237
|
+
return { ok: false, code: 'SCOPE_MISMATCH', error: '加好友申请只能使用当前任务所属 Agent AID' };
|
|
2240
2238
|
}
|
|
2241
|
-
|
|
2239
|
+
onExecutionStarted();
|
|
2240
|
+
const result = await executeDirectoryRequestCommand(command, async (input) => {
|
|
2241
|
+
const channel = [...this.channelObjects.entries()].find(([name]) => this.resolveChannelType(name) === 'aun' && this.resolveSelfAID(name) === command.selfAid)?.[1];
|
|
2242
|
+
if (typeof channel?.sendDaemonMsg !== 'function') {
|
|
2243
|
+
return { ok: false, code: 'AUN_CHANNEL_NOT_FOUND', error: `找不到 ${command.selfAid} 的 AUN 发送渠道` };
|
|
2244
|
+
}
|
|
2245
|
+
const sent = await channel.sendDaemonMsg({
|
|
2246
|
+
to: input.to, payload: input.payload, rawPayload: true, encrypt: true,
|
|
2247
|
+
log: { content: '[friend.invite.v1]', threadId: '', msgType: 'custom', payloadType: 'friend.invite.v1', source: 'msg' },
|
|
2248
|
+
});
|
|
2249
|
+
return { ok: sent.ok, message_id: sent.message_id, error: sent.error, code: sent.code };
|
|
2250
|
+
});
|
|
2251
|
+
return result.ok ? { ok: true, result } : { ok: false, code: result.code, error: result.error };
|
|
2242
2252
|
}
|
|
2243
2253
|
catch (error) {
|
|
2244
|
-
return { ok: false, code:
|
|
2254
|
+
return { ok: false, code: error instanceof DirectoryQueryError ? error.code : 'FRIEND_INVITE_FAILED',
|
|
2255
|
+
error: error instanceof Error ? error.message : String(error) };
|
|
2245
2256
|
}
|
|
2246
2257
|
}
|
|
2247
2258
|
let command;
|
|
2248
2259
|
try {
|
|
2249
|
-
command =
|
|
2250
|
-
? resolveDirectoryRemarkCommand(subArgv)
|
|
2251
|
-
: resolveDirectoryQueryCommand(subArgv);
|
|
2260
|
+
command = resolveDirectoryQueryCommand(subArgv);
|
|
2252
2261
|
}
|
|
2253
2262
|
catch (error) {
|
|
2254
|
-
const known = error instanceof
|
|
2263
|
+
const known = error instanceof DirectoryQueryError;
|
|
2255
2264
|
return {
|
|
2256
2265
|
ok: false,
|
|
2257
2266
|
code: known ? error.code : 'INVALID_ARGUMENT',
|
|
@@ -2262,9 +2271,7 @@ export class CommandHandler {
|
|
|
2262
2271
|
return { ok: false, code: 'SCOPE_MISMATCH', error: 'Resolved Agent target does not match the authorized target' };
|
|
2263
2272
|
}
|
|
2264
2273
|
onExecutionStarted();
|
|
2265
|
-
const result =
|
|
2266
|
-
? executeDirectoryRemarkCommand(command)
|
|
2267
|
-
: await executeDirectoryQueryCommand(command);
|
|
2274
|
+
const result = await executeDirectoryQueryCommand(command);
|
|
2268
2275
|
return result.ok
|
|
2269
2276
|
? { ok: true, result }
|
|
2270
2277
|
: { ok: false, code: result.code, error: result.error };
|
|
@@ -265,6 +265,10 @@ async function handleAction(req, self, context) {
|
|
|
265
265
|
return actionReviewRequest(req, self, context, 'block');
|
|
266
266
|
return fail('NOT_SUPPORTED', `Unknown action: ${String(action)}`);
|
|
267
267
|
}
|
|
268
|
+
/** 会改变 `directory.md` / `identity.json` 内容的开关;改完必须重算注入。 */
|
|
269
|
+
const RENDER_AFFECTING_ACCESS_RESOURCES = new Set([
|
|
270
|
+
'allowInternalContacts', 'allowExternalContacts', 'allowAllContacts', 'allowedAids', 'deniedAids',
|
|
271
|
+
]);
|
|
268
272
|
function isAccessUpdateResource(resource) {
|
|
269
273
|
return resource === 'allowInternalContacts'
|
|
270
274
|
|| resource === 'allowExternalContacts'
|
|
@@ -315,9 +319,9 @@ function updateAccessResource(req, context, resource) {
|
|
|
315
319
|
expectedAccessRevision,
|
|
316
320
|
update: current => accessPolicyWithUpdate(current, resource, decoded),
|
|
317
321
|
});
|
|
318
|
-
//
|
|
319
|
-
//
|
|
320
|
-
if (result.changed && resource
|
|
322
|
+
// 影响 directory.md 的开关共五个:准入每次现读 config,立刻生效;注入内容是
|
|
323
|
+
// 渲染产物,不重算就停在旧版本。`requestLimit` 只控制拒绝提示的发送频率,不触发。
|
|
324
|
+
if (result.changed && RENDER_AFFECTING_ACCESS_RESOURCES.has(resource)) {
|
|
321
325
|
refreshDirectoryMarkdown(self);
|
|
322
326
|
}
|
|
323
327
|
return ok({
|
|
@@ -99,7 +99,7 @@ const ENTRIES = [
|
|
|
99
99
|
control: 'toggle',
|
|
100
100
|
},
|
|
101
101
|
// 模型与推理强度只在 Agent 级配置(见 model.agent / effort.agent),关系菜单不再提供。
|
|
102
|
-
relation('chatmode.relation', 'chatmode', '对话模式', 30, '/chatmode', 'chatmode.current', { options: { cmd: '/chatmode', operation: 'chatmode.current', scope: 'relation', mode: '
|
|
102
|
+
relation('chatmode.relation', 'chatmode', '对话模式', 30, '/chatmode', 'chatmode.current', { options: { cmd: '/chatmode', operation: 'chatmode.current', scope: 'relation', mode: 'dynamic' }, update: { cmd: '/chatmode', operation: 'chatmode.update', scope: 'relation' }, control: 'select' }),
|
|
103
103
|
relation('activity.relation', 'activity', '中间输出', 40, '/activity', 'activity.current', { options: { cmd: '/activity', operation: 'activity.current', scope: 'relation', mode: 'static', items: [{ value: 'all', label: '私聊显示' }, { value: 'text', label: '仅文字进展' }, { value: 'none', label: '全部静默' }] }, update: { cmd: '/activity', operation: 'activity.update', scope: 'relation' }, control: 'select' }),
|
|
104
104
|
{ id: 'task.activities', type: 'list', contexts: ['private_relation', 'group_relation'], name: 'task', label: '任务活动', section: 'relation_behavior', order: 45, query: { cmd: '/task', args: { view: 'activities' }, operation: 'task.activity.read', scope: 'relation', mode: 'dynamic' }, control: 'list' },
|
|
105
105
|
relation('permissionMode.relation', 'permission', '权限模式', 50, '/perm', 'permission.current', { query: { cmd: '/perm', args: { scope: 'role' }, operation: 'permission.current', scope: 'relation' }, options: undefined, update: { cmd: '/perm', operation: 'permission.current', scope: 'relation', supported: false }, control: 'select' }),
|
|
@@ -114,6 +114,12 @@ const ENTRIES = [
|
|
|
114
114
|
{ id: 'activity.agent', type: 'setting', contexts: ['agent'], name: 'activity', label: 'Agent 中间输出', section: 'agent', order: 50, query: { cmd: '/activity', args: { scope: 'agent' }, operation: 'activity.current', scope: 'agent' }, options: { cmd: '/activity', args: { scope: 'agent' }, operation: 'activity.current', scope: 'agent' }, update: { cmd: '/activity', args: { scope: 'agent' }, operation: 'activity.update', scope: 'agent' }, control: 'select' },
|
|
115
115
|
{ id: 'observable.agent', type: 'setting', contexts: ['agent'], name: 'observable', label: '观察模式', section: 'agent', order: 60, query: { cmd: '/observable', operation: 'observable.current', scope: 'agent' }, update: { cmd: '/observable', operation: 'observable.update', scope: 'agent' }, valueSchema: { type: 'boolean' }, control: 'toggle' },
|
|
116
116
|
{ id: 'aid.avatar', type: 'action', contexts: ['agent'], name: 'aid', label: '更换头像', section: 'agent', order: 70, action: { cmd: '/aid', action: 'avatar', operation: 'ec.aid.avatar', scope: 'agent' }, valueSchema: { type: 'object', properties: { data: { type: 'string' }, url: { type: 'string', format: 'uri' } }, oneOf: [{ required: ['data'] }, { required: ['url'] }] }, control: 'action' },
|
|
117
|
+
{ id: 'aid.agentmd', type: 'setting', contexts: ['agent'], name: 'aid', label: 'AgentMD', section: 'agent', order: 71,
|
|
118
|
+
query: { cmd: '/aid', args: { view: 'agentmd', protocolVersion: 1 }, operation: 'ec.aid.agentmd.get', scope: 'agent' },
|
|
119
|
+
action: { cmd: '/aid', action: 'agentmd.publish', args: { protocolVersion: 1 }, operation: 'ec.aid.agentmd.put', scope: 'agent' },
|
|
120
|
+
valueSchema: { type: 'object', required: ['content', 'expectedEtag', 'expectedRelationVersion'], properties: {
|
|
121
|
+
content: { type: 'string' }, expectedEtag: { type: 'string' }, expectedRelationVersion: { type: 'integer', minimum: 1 },
|
|
122
|
+
} }, control: 'markdown-editor' },
|
|
117
123
|
{ id: 'baseagents.inventory', type: 'list', contexts: ['process'], name: 'baseagents', label: 'Base Agent 清单', section: 'process', order: 9, query: { cmd: '/baseagents', operation: 'system.status', scope: 'process' }, control: 'list' },
|
|
118
124
|
{ id: 'system.status', type: 'list', contexts: ['process'], name: 'system', label: '系统状态', section: 'process', order: 10, query: { cmd: '/system', operation: 'system.status', scope: 'process' }, control: 'list' },
|
|
119
125
|
{ id: 'system.monitor', type: 'list', contexts: ['process'], name: 'system', label: '运行监控快照', section: 'process', order: 11, query: { cmd: '/system', args: { view: 'monitor' }, operation: 'system.status', scope: 'process' }, control: 'list' },
|
|
@@ -166,6 +172,7 @@ export async function resolveMenuCatalogContext(input) {
|
|
|
166
172
|
}
|
|
167
173
|
const bound = {
|
|
168
174
|
...subject,
|
|
175
|
+
menuTransportChatType: subject.menuTransportChatType ?? subject.chatType,
|
|
169
176
|
chatType: 'private',
|
|
170
177
|
conversationId: subject.selfAid,
|
|
171
178
|
channelId: subject.selfAid,
|
|
@@ -311,7 +318,8 @@ export function bindMenuExecutionContextArgs(args, context) {
|
|
|
311
318
|
return args;
|
|
312
319
|
const { context: _context, ...bound } = args ?? {};
|
|
313
320
|
const isSessionScoped = ['loop', 'fullaccess'].includes(String(bound.resource ?? bound.view ?? ''));
|
|
314
|
-
|
|
321
|
+
// Command inventories use the resolved subject, without configurable scope/peer selectors.
|
|
322
|
+
if (isSessionScoped || bound.view === 'commands')
|
|
315
323
|
return bound;
|
|
316
324
|
if (context.kind === 'private_relation' || context.kind === 'group_relation') {
|
|
317
325
|
if (bound.scope !== 'role')
|
|
@@ -388,6 +396,12 @@ async function operationView(binding, context, options = {}) {
|
|
|
388
396
|
return undefined;
|
|
389
397
|
if (binding.supported === false)
|
|
390
398
|
return { supported: false, allowed: false, reason: { code: 'NOT_SUPPORTED', message: 'operation is not supported' } };
|
|
399
|
+
if (['ec.aid.agentmd.get', 'ec.aid.agentmd.put'].includes(binding.operation)
|
|
400
|
+
&& (context.subject.channelType !== 'aun' || context.subject.menuEncrypted !== true
|
|
401
|
+
|| (context.subject.menuTransportChatType ?? context.subject.chatType) !== 'private'
|
|
402
|
+
|| context.subject.fromControlChannel || context.subject.ecwebManagement)) {
|
|
403
|
+
return { supported: true, allowed: false, reason: { code: 'FORBIDDEN', message: 'AgentMD requires an encrypted AUN private Agent channel' } };
|
|
404
|
+
}
|
|
391
405
|
if (binding.operation === 'system.paircode' && options.paircodeAllowed === false) {
|
|
392
406
|
return {
|
|
393
407
|
supported: true,
|
|
@@ -28,6 +28,7 @@ import { WEB_PACKAGE_NAME, RESTART_REQUEST_ID_ENV, RUNTIME_HOME_ENV, SESSION_ID_
|
|
|
28
28
|
import { read as cfgRead, resolveEffective, resolveEffectiveFieldWithSource, routeFieldPath, write as cfgWrite, ConfigTarget, } from '../../config/config-manager.js';
|
|
29
29
|
import { agentCreateCapabilities, execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
|
|
30
30
|
import { readInitialization } from '../../cli/agent-create.js';
|
|
31
|
+
import { agentMdMenuService } from './agentmd-menu.js';
|
|
31
32
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
32
33
|
import { gatewayList, gatewayUpdate, gatewayDelete, gatewayTest, gatewayModels, gatewaySetPrice } from '../../config/gateway-config.js';
|
|
33
34
|
import { displaySessionTitle } from '../session/session-title.js';
|
|
@@ -43,7 +44,7 @@ import { authorizationDenialData, formatAuthorizationDenial } from '../auth/auth
|
|
|
43
44
|
import { evaluateRoleOperationCapability } from '../auth/operation-authorizer.js';
|
|
44
45
|
import { isUnsupportedBaseagentConfigField } from '../../config/config-field-policy.js';
|
|
45
46
|
import { splitConfigBatchGetArgv } from '../../cli/cli-argv.js';
|
|
46
|
-
import { chatmodeFieldForPeer, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
|
|
47
|
+
import { chatmodeFieldForPeer, isChatMode, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
|
|
47
48
|
import { PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
|
|
48
49
|
import { isAgentFullAccessOwner, resolveRuntimePermissionMode, resolveRuntimeStringField, sessionFullAccessStatus, updateRelationSessionFullAccess, validateRuntimeStringFieldOverride, } from '../role/runtime-policy.js';
|
|
49
50
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
@@ -51,7 +52,7 @@ import { SYSTEM_CONTROL_CHANNEL } from '../system-channels.js';
|
|
|
51
52
|
import { logger } from '../../utils/logger.js';
|
|
52
53
|
import { shouldSuppressRealRestart, createRestartRequest, readRestartRequest, updateRestartRequest, removeRestartRequest } from '../../utils/restart-safety.js';
|
|
53
54
|
import { AGENT_DELEGATION_TOKEN_ENV } from '../auth/agent-delegation.js';
|
|
54
|
-
import { evolMenuResponseTransportMetadata, menuFailure, menuCommandForName, menuSuccess, normalizeMenuError, validateTaskActivityQueryArgs, validateConfigWriteScope, validateMenuRequest, } from './menu-protocol.js';
|
|
55
|
+
import { evolMenuResponseTransportMetadata, menuFailure, menuCommandForName, menuSuccess, normalizeMenuError, validateTaskActivityQueryArgs, validateSlashCommandsQueryArgs, validateConfigWriteScope, validateMenuRequest, } from './menu-protocol.js';
|
|
55
56
|
import { parseMenuClientProtectedHeaders } from './menu-protocol.js';
|
|
56
57
|
import { TaskActivityStore } from '../task/task-activity-store.js';
|
|
57
58
|
import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
|
|
@@ -731,6 +732,8 @@ function resolveMenuChatmodeTarget(params) {
|
|
|
731
732
|
};
|
|
732
733
|
}
|
|
733
734
|
function readMenuChatmode(target) {
|
|
735
|
+
if (target.field === 'group')
|
|
736
|
+
return { value: 'proactive', source: 'builtin' };
|
|
734
737
|
if (target.roleLocked)
|
|
735
738
|
return { value: 'proactive', source: 'role' };
|
|
736
739
|
try {
|
|
@@ -741,13 +744,18 @@ function readMenuChatmode(target) {
|
|
|
741
744
|
field: target.fieldPath,
|
|
742
745
|
configuredValue: resolved.value,
|
|
743
746
|
});
|
|
744
|
-
const mode =
|
|
745
|
-
|
|
747
|
+
const mode = target.scope === 'agent'
|
|
748
|
+
&& (decision.effectiveValue !== 'paactive' || target.role === 'owner') ? decision.effectiveValue
|
|
749
|
+
: resolveChatModeForField({ ...target.sel, role: target.role, field: target.field });
|
|
750
|
+
if (isChatMode(mode)) {
|
|
746
751
|
return {
|
|
747
752
|
value: mode,
|
|
748
753
|
source: decision.decidedBy === 'role'
|
|
749
754
|
? 'role'
|
|
750
755
|
: toMenuSource(resolved.source) ?? 'builtin',
|
|
756
|
+
...(resolved.value === 'paactive' && mode !== 'paactive' ? {
|
|
757
|
+
fallbackReason: 'paactive 仅在 active AUN 人类 owner 私聊主会话或话题生效,当前场景或角色策略未满足条件。',
|
|
758
|
+
} : {}),
|
|
751
759
|
};
|
|
752
760
|
}
|
|
753
761
|
}
|
|
@@ -1079,6 +1087,8 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1079
1087
|
? 'agent'
|
|
1080
1088
|
: args?.scope === 'relation' ? 'relation' : 'agent';
|
|
1081
1089
|
if (verb === 'query') {
|
|
1090
|
+
if (cmdBase === '/aid' && args?.view === 'agentmd')
|
|
1091
|
+
return intent('ec.aid.agentmd.get', 'agent');
|
|
1082
1092
|
if (cmdBase === '/baseagent-models')
|
|
1083
1093
|
return intent('baseagent.models.list', 'process');
|
|
1084
1094
|
if (cmdBase === '/baseagents') {
|
|
@@ -1225,6 +1235,8 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1225
1235
|
}
|
|
1226
1236
|
if (cmdBase === '/aid' && action === 'avatar')
|
|
1227
1237
|
return intent('ec.aid.avatar', 'agent', { action });
|
|
1238
|
+
if (cmdBase === '/aid' && action === 'agentmd.publish')
|
|
1239
|
+
return intent('ec.aid.agentmd.put', 'agent', { action });
|
|
1228
1240
|
if (cmdBase === '/trigger') {
|
|
1229
1241
|
if (action === 'create' || action === 'set')
|
|
1230
1242
|
return intent('trigger.create', 'relation', { action });
|
|
@@ -2200,8 +2212,12 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2200
2212
|
throw { code: target.code, message: target.error };
|
|
2201
2213
|
const currentMode = readMenuChatmode(target).value;
|
|
2202
2214
|
return [
|
|
2203
|
-
|
|
2215
|
+
...(target.field !== 'group'
|
|
2216
|
+
? [{ value: 'interactive', label: '交互模式', selected: currentMode === 'interactive' }] : []),
|
|
2204
2217
|
{ value: 'proactive', label: '主动模式', selected: currentMode === 'proactive' },
|
|
2218
|
+
...(target.field === 'private' && target.role === 'owner'
|
|
2219
|
+
&& (target.scope === 'agent' || target.sel.peerKey?.startsWith('aun#'))
|
|
2220
|
+
? [{ value: 'paactive', label: 'PA 模式', selected: currentMode === 'paactive' }] : []),
|
|
2205
2221
|
];
|
|
2206
2222
|
}
|
|
2207
2223
|
if (cmd === '/mention') {
|
|
@@ -2300,6 +2316,37 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2300
2316
|
fromControlChannel,
|
|
2301
2317
|
subject: authSubject,
|
|
2302
2318
|
});
|
|
2319
|
+
if (cmdBase === '/evolhelp') {
|
|
2320
|
+
const invalid = validateSlashCommandsQueryArgs(args);
|
|
2321
|
+
if (invalid)
|
|
2322
|
+
return { error: invalid.message, code: invalid.code };
|
|
2323
|
+
if (!subject.selfAid)
|
|
2324
|
+
return { error: 'slash-commands requires a target Agent', code: 'MISSING_AID' };
|
|
2325
|
+
if (!subject.allowAccess)
|
|
2326
|
+
return { error: '当前角色不能访问此 Agent', code: 'ROLE_ACCESS_DENIED' };
|
|
2327
|
+
try {
|
|
2328
|
+
const reply = await this._handleInternal('/evolhelp', channel, channelId, undefined, userId, transportReplyContext?.threadId, subject.chatType, undefined, undefined, subject.selfAid, subject.identity, subject, transportReplyContext, true);
|
|
2329
|
+
if (!reply || reply.kind !== 'command.result') {
|
|
2330
|
+
return {
|
|
2331
|
+
error: reply?.text || '无法获取 slash 指令清单',
|
|
2332
|
+
code: reply?.reasonCode || reply?.reason || 'EXEC_FAILED',
|
|
2333
|
+
};
|
|
2334
|
+
}
|
|
2335
|
+
const list = JSON.parse(reply.text);
|
|
2336
|
+
const level = args?.level ?? 'common';
|
|
2337
|
+
if (level === 'all')
|
|
2338
|
+
return { data: list };
|
|
2339
|
+
const commands = list.commands.filter(entry => level === 'common' ? entry.common === true : entry.common !== true);
|
|
2340
|
+
const categories = [
|
|
2341
|
+
...(level === 'common' ? ['常用'] : []),
|
|
2342
|
+
...new Set(commands.map(entry => entry.category)),
|
|
2343
|
+
];
|
|
2344
|
+
return { data: { commands, categories } };
|
|
2345
|
+
}
|
|
2346
|
+
catch (error) {
|
|
2347
|
+
return menuResultFailure(error);
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2303
2350
|
if (cmdBase === '/session' && args?.view === 'loop') {
|
|
2304
2351
|
if (Object.keys(args).some(key => key !== 'view' && key !== 'context')) {
|
|
2305
2352
|
return { error: 'session.loop query only accepts args.view', code: 'INVALID_ARGUMENT' };
|
|
@@ -2555,6 +2602,14 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2555
2602
|
});
|
|
2556
2603
|
if (authDenied)
|
|
2557
2604
|
return authDenied;
|
|
2605
|
+
if (cmdBase === '/aid' && args?.view === 'agentmd') {
|
|
2606
|
+
try {
|
|
2607
|
+
return { data: await agentMdMenuService.query(subject, args) };
|
|
2608
|
+
}
|
|
2609
|
+
catch (error) {
|
|
2610
|
+
return menuResultFailure(error);
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2558
2613
|
if (cmdBase === '/trigger') {
|
|
2559
2614
|
if (args?.view !== 'detail' && args?.view !== 'history') {
|
|
2560
2615
|
return { error: 'Unsupported trigger query view', code: 'INVALID_ARGS' };
|
|
@@ -2987,6 +3042,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2987
3042
|
return {
|
|
2988
3043
|
data: {
|
|
2989
3044
|
mode: current.value,
|
|
3045
|
+
...(current.fallbackReason ? { fallbackReason: current.fallbackReason } : {}),
|
|
2990
3046
|
source: current.source,
|
|
2991
3047
|
scope: target.scope,
|
|
2992
3048
|
override: readMenuScopeOverride(target.scope, target.fieldPath, target.sel),
|
|
@@ -3254,11 +3310,23 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3254
3310
|
let session = loadedContext.session;
|
|
3255
3311
|
const evolagent = loadedContext.evolagent;
|
|
3256
3312
|
if (transportReplyContext?.threadId) {
|
|
3257
|
-
|
|
3258
|
-
|
|
3313
|
+
if (cmdBase === '/model' || cmdBase === '/effort') {
|
|
3314
|
+
// Model settings belong to the Agent and can be changed from a locally
|
|
3315
|
+
// created topic before its first message has registered a Core session.
|
|
3316
|
+
try {
|
|
3317
|
+
session = await this.sessionManager.getThreadSession(channel, channelId, transportReplyContext.threadId) ?? session;
|
|
3318
|
+
}
|
|
3319
|
+
catch (error) {
|
|
3320
|
+
logger.debug(`[MenuHandler] topic context unavailable for Agent model update: thread=${transportReplyContext.threadId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
3321
|
+
}
|
|
3259
3322
|
}
|
|
3260
|
-
|
|
3261
|
-
|
|
3323
|
+
else {
|
|
3324
|
+
try {
|
|
3325
|
+
session = await loadMenuTopicSession(this.sessionManager, channel, channelId, transportReplyContext.threadId);
|
|
3326
|
+
}
|
|
3327
|
+
catch (error) {
|
|
3328
|
+
return menuResultFailure(error);
|
|
3329
|
+
}
|
|
3262
3330
|
}
|
|
3263
3331
|
}
|
|
3264
3332
|
if (cmdBase === '/baseagent-models')
|
|
@@ -3623,7 +3691,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3623
3691
|
};
|
|
3624
3692
|
}
|
|
3625
3693
|
if (cmdBase === '/chatmode') {
|
|
3626
|
-
if (arg
|
|
3694
|
+
if (!isChatMode(arg)) {
|
|
3627
3695
|
return { error: `无效模式: ${arg}`, code: 'INVALID_VALUE' };
|
|
3628
3696
|
}
|
|
3629
3697
|
const target = resolveMenuChatmodeTarget.call(this, {
|
|
@@ -3637,9 +3705,19 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3637
3705
|
});
|
|
3638
3706
|
if ('error' in target)
|
|
3639
3707
|
return target;
|
|
3640
|
-
if (
|
|
3708
|
+
if (target.field === 'group' && arg !== 'proactive') {
|
|
3709
|
+
return { error: '群聊仅支持 proactive 模式', code: 'NOT_APPLICABLE' };
|
|
3710
|
+
}
|
|
3711
|
+
if (arg === 'paactive' && identity.role !== 'owner') {
|
|
3712
|
+
return { error: 'paactive 模式仅限 owner', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3713
|
+
}
|
|
3714
|
+
if ((arg === 'interactive' || arg === 'paactive') && target.roleLocked) {
|
|
3641
3715
|
return { error: '私聊交互模式仅限 owner/admin,当前角色固定为 proactive', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3642
3716
|
}
|
|
3717
|
+
if (arg === 'paactive' && (target.field !== 'private'
|
|
3718
|
+
|| (target.scope === 'relation' && !target.sel.peerKey?.startsWith('aun#')))) {
|
|
3719
|
+
return { error: 'paactive 仅支持 AUN 人类私聊', code: 'NOT_APPLICABLE' };
|
|
3720
|
+
}
|
|
3643
3721
|
const roleDecision = validateRuntimeStringFieldOverride({
|
|
3644
3722
|
selfAid: target.sel.self,
|
|
3645
3723
|
role: target.role,
|
|
@@ -3898,9 +3976,24 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3898
3976
|
return { error: `不支持 gateway action: ${action}`, code: 'NOT_SUPPORTED' };
|
|
3899
3977
|
}
|
|
3900
3978
|
const isMenuAdmin = isManagementRole(authIdentity.role);
|
|
3901
|
-
// ── /aid avatar ──
|
|
3979
|
+
// ── /aid AgentMD and avatar ──
|
|
3902
3980
|
// Canonical avatar action; legacy agent/update patch.avatar reuses the same uploader.
|
|
3903
3981
|
if (cmdBase === '/aid') {
|
|
3982
|
+
if (action === 'agentmd.publish') {
|
|
3983
|
+
try {
|
|
3984
|
+
const data = await agentMdMenuService.publish(subject, args ?? {});
|
|
3985
|
+
this.eventBus?.publish({
|
|
3986
|
+
type: 'agent:updated', aid: data.aid, nameChanged: data.nameChanged, timestamp: Date.now(),
|
|
3987
|
+
});
|
|
3988
|
+
if (typeof data.avatar === 'string') {
|
|
3989
|
+
this.eventBus?.publish({ type: 'agent:avatar_updated', aid: data.aid, avatar: data.avatar, timestamp: Date.now() });
|
|
3990
|
+
}
|
|
3991
|
+
return { data };
|
|
3992
|
+
}
|
|
3993
|
+
catch (error) {
|
|
3994
|
+
return menuResultFailure(error);
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3904
3997
|
if (action !== 'avatar')
|
|
3905
3998
|
return { error: `不支持 aid action: ${action}`, code: 'NOT_SUPPORTED' };
|
|
3906
3999
|
const result = await execAidAvatar(args);
|
|
@@ -5374,9 +5467,9 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5374
5467
|
const isRoleRequest = name === 'role' || compatCmd === '/role';
|
|
5375
5468
|
const isConnectRequest = name === 'connect' || compatCmd === '/connect';
|
|
5376
5469
|
const requiresAgentTarget = isRoleRequest || isConnectRequest || [
|
|
5377
|
-
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'pa-workspace',
|
|
5470
|
+
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'pa-workspace', 'slash-commands',
|
|
5378
5471
|
].includes(name)
|
|
5379
|
-
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/pa-workspace'].includes(compatCmd ?? '')
|
|
5472
|
+
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/pa-workspace', '/evolhelp'].includes(compatCmd ?? '')
|
|
5380
5473
|
|| (!isProcessLevel && requestedContextKind !== undefined && requestedContextKind !== 'process');
|
|
5381
5474
|
const target = isProcessLevel
|
|
5382
5475
|
? { channel: SYSTEM_CONTROL_CHANNEL }
|
|
@@ -8,6 +8,7 @@ import { validateIdleSeconds } from '../session/session-idle-monitor.js';
|
|
|
8
8
|
import { parseFileSearchArgs } from './file-search.js';
|
|
9
9
|
import { validateProviderMenuRequest } from '../../config/provider-menu-request.js';
|
|
10
10
|
import { validatePaWorkspaceItemsArgs } from './pa-workspace-items.js';
|
|
11
|
+
import { validateAgentMdMenuRequest } from './agentmd-menu-request.js';
|
|
11
12
|
export const MENU_REQUEST_TYPES = new Set([
|
|
12
13
|
'menu.token.request',
|
|
13
14
|
'menu.list',
|
|
@@ -124,6 +125,7 @@ export function parseMenuResponse(value) {
|
|
|
124
125
|
return value;
|
|
125
126
|
}
|
|
126
127
|
export const MENU_NAME_COMMANDS = Object.freeze({
|
|
128
|
+
'slash-commands': '/evolhelp',
|
|
127
129
|
pwd: '/pwd',
|
|
128
130
|
session: '/session',
|
|
129
131
|
topic: '/topic',
|
|
@@ -323,6 +325,20 @@ export function parseMenuControl(content) {
|
|
|
323
325
|
export function hasValidMenuId(parsed) {
|
|
324
326
|
return typeof parsed.id === 'string' && parsed.id.trim().length > 0;
|
|
325
327
|
}
|
|
328
|
+
export function validateSlashCommandsQueryArgs(args) {
|
|
329
|
+
if (args !== undefined && (!args || typeof args !== 'object' || Array.isArray(args))) {
|
|
330
|
+
return { code: 'INVALID_ARGUMENT', message: 'slash-commands args must be an object' };
|
|
331
|
+
}
|
|
332
|
+
const unknown = Object.keys(args ?? {}).find(key => !['view', 'level', 'context'].includes(key));
|
|
333
|
+
if (unknown)
|
|
334
|
+
return { code: 'INVALID_ARGUMENT', message: `slash-commands does not accept args.${unknown}` };
|
|
335
|
+
if (args?.view !== 'commands')
|
|
336
|
+
return { code: 'INVALID_ARGUMENT', message: 'slash-commands requires args.view=commands' };
|
|
337
|
+
if (args.level !== undefined && (typeof args.level !== 'string' || !['common', 'normal', 'all'].includes(args.level))) {
|
|
338
|
+
return { code: 'INVALID_ARGUMENT', message: 'level must be common, normal or all' };
|
|
339
|
+
}
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
326
342
|
export function validateMenuRequest(request) {
|
|
327
343
|
const type = request.type;
|
|
328
344
|
if (!MENU_REQUEST_TYPES.has(type)) {
|
|
@@ -338,6 +354,16 @@ export function validateMenuRequest(request) {
|
|
|
338
354
|
if (request.args !== undefined && (!request.args || typeof request.args !== 'object' || Array.isArray(request.args))) {
|
|
339
355
|
return { code: 'INVALID_ARGUMENT', message: 'Menu request args must be an object' };
|
|
340
356
|
}
|
|
357
|
+
if ((request.name === 'aid' || firstCommandToken(request.cmd) === '/aid')
|
|
358
|
+
&& (request.args?.view === 'agentmd'
|
|
359
|
+
|| (typeof request.action === 'string' && request.action.startsWith('agentmd.')))) {
|
|
360
|
+
return validateAgentMdMenuRequest({ type: request.type, action: request.action, args: request.args });
|
|
361
|
+
}
|
|
362
|
+
if (request.name === 'slash-commands' || firstCommandToken(request.cmd) === '/evolhelp') {
|
|
363
|
+
if (type !== 'menu.query')
|
|
364
|
+
return { code: 'NOT_SUPPORTED', message: 'slash-commands only supports menu.query' };
|
|
365
|
+
return validateSlashCommandsQueryArgs(request.args);
|
|
366
|
+
}
|
|
341
367
|
if (request.name === 'provider' || firstCommandToken(request.cmd) === '/provider') {
|
|
342
368
|
return validateProviderMenuRequest(request);
|
|
343
369
|
}
|
|
@@ -624,6 +650,8 @@ const STABLE_CODES = new Set([
|
|
|
624
650
|
'INITIALIZE_AGENTMD_VERIFY_FAILED', 'INITIALIZE_OWNER_CONFLICT', 'INITIALIZE_AVATAR_FAILED',
|
|
625
651
|
'INITIALIZE_FAILED', 'MODEL_UNAVAILABLE', 'MODEL_NOT_CONFIGURED', 'BASEAGENT_REQUIRED',
|
|
626
652
|
'CONTROL_AID_RESERVED', 'CONTROL_AID_CONFLICT', 'HOST_AID_RESERVED', 'AGENT_IDENTITY_UNVERIFIED',
|
|
653
|
+
'OWNER_UNAVAILABLE', 'OWNERSHIP_CONFLICT', 'PROTECTED_FIELD', 'AGENTMD_UNVERIFIED', 'AGENTMD_NOT_FOUND',
|
|
654
|
+
'REMOTE_VERSION_UNAVAILABLE', 'REMOTE_VERSION_CONFLICT', 'PUBLISH_NOT_CONFIRMED',
|
|
627
655
|
]);
|
|
628
656
|
export function normalizeMenuError(error) {
|
|
629
657
|
const source = error && typeof error === 'object' ? error : {};
|