evolcore 0.0.43-test.2 → 0.0.43-test.4
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 +44 -1
- package/bin/ecmsg.js +229 -0
- package/bin/install-codex-managed-hooks.mjs +130 -8
- package/dist/ability/application-service.js +37 -0
- package/dist/ability/resources.js +28 -0
- package/dist/ability/runtime.js +6 -1
- package/dist/agents/claude-runner.js +7 -5
- package/dist/agents/codex/app-server-client.js +0 -12
- package/dist/agents/codex-runner.js +0 -37
- package/dist/agents/ecagent-runner.js +138 -36
- package/dist/aun/aid/agentmd.js +52 -13
- package/dist/aun/menu/client.js +8 -7
- package/dist/aun/menu/index.js +1 -1
- package/dist/aun/menu/transport.js +8 -5
- package/dist/aun/msg/p2p.js +4 -2
- package/dist/aun/service-proxy.js +3 -0
- package/dist/channels/aun.js +105 -53
- package/dist/channels/daemon.js +14 -2
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +31 -11
- package/dist/cli/agent.js +9 -3
- package/dist/cli/aun-commands.js +19 -21
- package/dist/cli/daemon-commands.js +30 -18
- package/dist/cli/directory.js +98 -56
- package/dist/cli/getmeta-command.js +2 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/init.js +13 -5
- package/dist/cli/peer.js +2 -1
- package/dist/cli/task-context.js +3 -1
- package/dist/cli/trigger-command.js +20 -14
- package/dist/config/access-policy.js +0 -1
- package/dist/config/boot-log.js +12 -2
- 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 -0
- package/dist/config/config-manager.js +30 -10
- package/dist/config/peer-role-resolver.js +23 -1
- package/dist/config/role-schema.js +25 -1
- package/dist/config/role-service.js +9 -4
- package/dist/config/role-store.js +30 -8
- package/dist/config/schema-migration.js +121 -0
- package/dist/core/agent-application-service.js +11 -0
- package/dist/core/agent-ipc-registration.js +2 -0
- package/dist/core/agent-runtime.js +41 -9
- package/dist/core/auth/auth-gateway.js +14 -4
- package/dist/core/auth/operation-authorizer.js +19 -1
- package/dist/core/auth/operation-catalog.js +12 -2
- package/dist/core/baseagent-loader.js +11 -3
- package/dist/core/bootstrap-service.js +8 -0
- package/dist/core/channel-loader.js +61 -23
- package/dist/core/channel-runtime.js +5 -0
- package/dist/core/command/agent-control.js +5 -2
- package/dist/core/command/agentmd-menu-request.js +50 -0
- package/dist/core/command/agentmd-menu.js +156 -0
- package/dist/core/command/chatmode-config.js +46 -0
- package/dist/core/command/command-handler.js +44 -17
- package/dist/core/command/daemon-diagnostics.js +2 -1
- package/dist/core/command/menu-catalog.js +14 -1
- package/dist/core/command/menu-handler.js +74 -24
- package/dist/core/command/menu-protocol.js +8 -0
- package/dist/core/command/role-menu.js +23 -9
- package/dist/core/command/slash-handler.js +52 -47
- package/dist/core/daemon-lifecycle.js +43 -17
- package/dist/core/event-catalog.js +19 -0
- package/dist/core/evolagent-registry.js +3 -0
- package/dist/core/evolagent.js +5 -4
- package/dist/core/ipc-registration.js +6 -0
- package/dist/core/lifecycle-notice.js +185 -0
- package/dist/core/message/aun-ipc-sender.js +30 -24
- package/dist/core/message/contact-admission.js +1 -19
- package/dist/core/message/im-renderer.js +81 -40
- package/dist/core/message/message-admission.js +21 -62
- package/dist/core/message/message-bridge.js +18 -5
- package/dist/core/message/message-utils.js +9 -0
- package/dist/core/message/peer-mode.js +16 -8
- package/dist/core/message/response-engine.js +67 -47
- package/dist/core/model/model-capabilities.js +37 -0
- package/dist/core/model/model-catalog.js +6 -2
- package/dist/core/ownership/owner-resolver.js +74 -36
- package/dist/core/permission/ec-command-parser.js +62 -13
- package/dist/core/plugin-lifecycle.js +6 -2
- package/dist/core/relation/pa-team.js +132 -0
- package/dist/core/role/runtime-policy.js +4 -3
- package/dist/core/thread/thread-service.js +6 -4
- package/dist/directory/owner-directory-admission.js +0 -3
- package/dist/directory/owner-directory-cache.js +201 -17
- package/dist/directory/owner-directory-markdown.js +44 -21
- package/dist/directory/owner-directory-policy.js +1 -1
- package/dist/directory/owner-directory-query-operation.js +218 -98
- 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 +76 -23
- package/dist/directory/owner-directory-store.js +5 -38
- package/dist/directory/owner-directory-text.js +60 -0
- package/dist/eck/kit-renderer.js +6 -3
- package/dist/eck/message-renderer.js +2 -5
- package/dist/ecweb/message-context-service.js +4 -0
- package/dist/ecweb/runtime/lifecycle.js +29 -5
- package/dist/ecweb/runtime/supervisor.js +83 -27
- package/dist/index.js +209 -38
- package/dist/paths.js +4 -2
- package/dist/product.js +1 -0
- package/dist/proxy/service-supervisor.js +377 -141
- package/dist/response-system/engines/v1/index.js +2 -4
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/trigger/audit.js +3 -2
- package/dist/trigger/authorization.js +2 -3
- package/dist/trigger/history.js +4 -3
- package/dist/trigger/ipc-service.js +24 -19
- package/dist/trigger/manager.js +3 -5
- package/dist/trigger/parser.js +4 -21
- package/dist/trigger/patch.js +3 -15
- package/dist/trigger/scheduler.js +53 -13
- package/dist/trigger/validation.js +0 -13
- package/dist/utils/error-utils.js +15 -5
- package/dist/utils/macos-autostart.js +31 -0
- package/dist/utils/model-prices.jsonl +15 -8
- package/dist/utils/process-introspect.js +21 -1
- package/dist/utils/startup-trace.js +7 -1
- package/dist/utils/windows-autostart.js +1 -0
- package/ecagent/README.md +18 -0
- package/ecagent/dist/harness/agent-harness.d.ts +2 -0
- package/ecagent/dist/harness/agent-harness.js +24 -8
- package/ecagent/dist/harness/compaction/branch-summarization.js +1 -1
- package/ecagent/dist/harness/compaction/compaction.js +7 -4
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +5 -2
- package/kits/docs/evolcore/directory.md +125 -35
- package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
- package/kits/docs/evolcore/file-navigation.md +279 -0
- package/kits/docs/evolcore/menu-protocol.md +1 -0
- package/kits/docs/evolcore/model.md +5 -3
- package/kits/docs/evolcore/msg.md +1 -0
- package/kits/docs/evolcore/peer.md +2 -1
- package/kits/docs/evolcore/response.md +4 -2
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/thread-chain.md +1 -1
- package/kits/docs/evolcore/tool-authorization.md +4 -1
- package/kits/docs/evolcore/trigger.md +10 -7
- package/kits/docs/identity/ROLE_DETAIL.md +2 -0
- package/kits/eck_manifest.json +6 -23
- package/kits/eck_manifest.memory.json +26 -1
- package/kits/rules/01-overview.md +42 -44
- package/kits/rules/02-navigation.md +44 -53
- package/kits/rules/03-identity.md +21 -25
- package/kits/rules/04-relation.md +23 -33
- package/kits/rules/05-venue.md +24 -25
- package/kits/schemas/_meta.json +10 -10
- package/kits/schemas/agent-config.schema.19.json +10 -6
- package/kits/schemas/relation-config.schema.12.json +2 -2
- package/kits/schemas/role-config.schema.2.json +5 -5
- package/kits/schemas/role-registry.schema.1.json +3 -2
- package/kits/skills/ec-service-proxy/SKILL.md +10 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/templates/soul/00-GUIDE.md +20 -42
- package/kits/templates/system-fragments/channel.md +2 -2
- package/kits/templates/system-fragments/commands.md +1 -1
- package/kits/templates/system-fragments/directory-contacts.md +1 -1
- package/kits/templates/system-fragments/identity.md +0 -1
- package/kits/templates/system-fragments/personal-assistant.md +2 -17
- package/kits/templates/system-fragments/reply.md +7 -0
- package/kits/templates/system-fragments/session.md +6 -2
- package/package.json +18 -13
- package/dist/eck/paactive-context.js +0 -45
- package/dist/response-system/engines/v1/paactive-flow.js +0 -18
- package/kits/eck_manifest.paactive.json +0 -528
- package/kits/eck_message_manifest.paactive.json +0 -233
- package/kits/templates/message-fragments/paactive/item.md +0 -3
- package/kits/templates/system-fragments/paactive/channel.md +0 -25
- package/kits/templates/system-fragments/paactive/reply.md +0 -25
- package/kits/templates/system-fragments/paactive/session.md +0 -32
|
@@ -4,6 +4,7 @@ import { getBaseagentSnapshot, loadedBaseagentIds } from '../../agents/baseagent
|
|
|
4
4
|
import { resolveBaseagentModelSelection } from '../../agents/baseagent.js';
|
|
5
5
|
import { normalizePeer, writeAgentModelConfig } from '../model/config-scope.js';
|
|
6
6
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
7
|
+
import { writeChatmodeConfig } from './chatmode-config.js';
|
|
7
8
|
import { modelMatches, getCatalog, getBaseagentCatalog, resolveCatalogModel, assertCatalogSelectable, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
|
|
8
9
|
import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
|
|
9
10
|
import { hasModelSwitcher } from '../../agents/runner-types.js';
|
|
@@ -28,6 +29,7 @@ import { WEB_PACKAGE_NAME, RESTART_REQUEST_ID_ENV, RUNTIME_HOME_ENV, SESSION_ID_
|
|
|
28
29
|
import { read as cfgRead, resolveEffective, resolveEffectiveFieldWithSource, routeFieldPath, write as cfgWrite, ConfigTarget, } from '../../config/config-manager.js';
|
|
29
30
|
import { agentCreateCapabilities, execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
|
|
30
31
|
import { readInitialization } from '../../cli/agent-create.js';
|
|
32
|
+
import { agentMdMenuService } from './agentmd-menu.js';
|
|
31
33
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
32
34
|
import { gatewayList, gatewayUpdate, gatewayDelete, gatewayTest, gatewayModels, gatewaySetPrice } from '../../config/gateway-config.js';
|
|
33
35
|
import { displaySessionTitle } from '../session/session-title.js';
|
|
@@ -731,6 +733,8 @@ function resolveMenuChatmodeTarget(params) {
|
|
|
731
733
|
};
|
|
732
734
|
}
|
|
733
735
|
function readMenuChatmode(target) {
|
|
736
|
+
if (target.field === 'group')
|
|
737
|
+
return { value: 'proactive', source: 'builtin' };
|
|
734
738
|
if (target.roleLocked)
|
|
735
739
|
return { value: 'proactive', source: 'role' };
|
|
736
740
|
try {
|
|
@@ -741,7 +745,8 @@ function readMenuChatmode(target) {
|
|
|
741
745
|
field: target.fieldPath,
|
|
742
746
|
configuredValue: resolved.value,
|
|
743
747
|
});
|
|
744
|
-
const mode = target.scope === 'agent'
|
|
748
|
+
const mode = target.scope === 'agent'
|
|
749
|
+
&& (decision.effectiveValue !== 'paactive' || target.role === 'owner') ? decision.effectiveValue
|
|
745
750
|
: resolveChatModeForField({ ...target.sel, role: target.role, field: target.field });
|
|
746
751
|
if (isChatMode(mode)) {
|
|
747
752
|
return {
|
|
@@ -750,7 +755,7 @@ function readMenuChatmode(target) {
|
|
|
750
755
|
? 'role'
|
|
751
756
|
: toMenuSource(resolved.source) ?? 'builtin',
|
|
752
757
|
...(resolved.value === 'paactive' && mode !== 'paactive' ? {
|
|
753
|
-
fallbackReason: 'paactive 仅在 active AUN 人类 owner
|
|
758
|
+
fallbackReason: 'paactive 仅在 active AUN 人类 owner 私聊主会话或话题生效,当前场景或角色策略未满足条件。',
|
|
754
759
|
} : {}),
|
|
755
760
|
};
|
|
756
761
|
}
|
|
@@ -758,16 +763,6 @@ function readMenuChatmode(target) {
|
|
|
758
763
|
catch { }
|
|
759
764
|
return { value: defaultChatmodeForField(target.field), source: 'builtin' };
|
|
760
765
|
}
|
|
761
|
-
function writeMenuChatmode(target, value) {
|
|
762
|
-
const route = routeFieldPath(target.fieldPath, target.scope);
|
|
763
|
-
const cur = cfgRead(route.target, target.sel) || {};
|
|
764
|
-
const block = cur.chatmode && typeof cur.chatmode === 'object' && !Array.isArray(cur.chatmode)
|
|
765
|
-
? { ...cur.chatmode }
|
|
766
|
-
: {};
|
|
767
|
-
block[target.field] = value;
|
|
768
|
-
cur.chatmode = block;
|
|
769
|
-
cfgWrite(route.target, cur, target.sel);
|
|
770
|
-
}
|
|
771
766
|
function menuMentionModeScope(args) {
|
|
772
767
|
const raw = menuStringArg(args, 'scope') ?? 'relation';
|
|
773
768
|
if (raw === 'agent' || raw === 'relation')
|
|
@@ -984,7 +979,10 @@ function resolveMenuActivityTarget(params) {
|
|
|
984
979
|
}
|
|
985
980
|
if (!peerKey)
|
|
986
981
|
return { error: 'relation scope 需要 peer/peerKey,或可推导的当前对端', code: 'MISSING_PEER' };
|
|
987
|
-
|
|
982
|
+
const relation = cfgRead(ConfigTarget.Relation, { ...sel, peerKey });
|
|
983
|
+
const chatType = relation?.targetKind
|
|
984
|
+
?? (!explicitPeer ? params.session?.chatType ?? params.explicitChatType : undefined);
|
|
985
|
+
return { scope, sel: { ...sel, peerKey }, fieldPath: 'show_activities', chatType };
|
|
988
986
|
}
|
|
989
987
|
function readMenuActivity(target, fallback = 'all') {
|
|
990
988
|
try {
|
|
@@ -994,7 +992,7 @@ function readMenuActivity(target, fallback = 'all') {
|
|
|
994
992
|
}
|
|
995
993
|
}
|
|
996
994
|
catch { }
|
|
997
|
-
return { value: fallback, source: 'builtin' };
|
|
995
|
+
return { value: target.chatType === 'group' ? 'none' : fallback, source: 'builtin' };
|
|
998
996
|
}
|
|
999
997
|
function writeMenuActivity(target, value) {
|
|
1000
998
|
const route = routeFieldPath(target.fieldPath, target.scope);
|
|
@@ -1083,6 +1081,8 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1083
1081
|
? 'agent'
|
|
1084
1082
|
: args?.scope === 'relation' ? 'relation' : 'agent';
|
|
1085
1083
|
if (verb === 'query') {
|
|
1084
|
+
if (cmdBase === '/aid' && args?.view === 'agentmd')
|
|
1085
|
+
return intent('ec.aid.agentmd.get', 'agent');
|
|
1086
1086
|
if (cmdBase === '/baseagent-models')
|
|
1087
1087
|
return intent('baseagent.models.list', 'process');
|
|
1088
1088
|
if (cmdBase === '/baseagents') {
|
|
@@ -1229,6 +1229,8 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
|
|
|
1229
1229
|
}
|
|
1230
1230
|
if (cmdBase === '/aid' && action === 'avatar')
|
|
1231
1231
|
return intent('ec.aid.avatar', 'agent', { action });
|
|
1232
|
+
if (cmdBase === '/aid' && action === 'agentmd.publish')
|
|
1233
|
+
return intent('ec.aid.agentmd.put', 'agent', { action });
|
|
1232
1234
|
if (cmdBase === '/trigger') {
|
|
1233
1235
|
if (action === 'create' || action === 'set')
|
|
1234
1236
|
return intent('trigger.create', 'relation', { action });
|
|
@@ -2148,7 +2150,7 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2148
2150
|
const fallback = this.agentRegistry?.getShowActivities?.(channel) ?? 'all';
|
|
2149
2151
|
const currentMode = readMenuActivity(target, fallback).value;
|
|
2150
2152
|
return [
|
|
2151
|
-
{ value: 'all', label: '
|
|
2153
|
+
{ value: 'all', label: '全部显示', selected: currentMode === 'all' },
|
|
2152
2154
|
{ value: 'text', label: '仅文字进展', selected: currentMode === 'text' },
|
|
2153
2155
|
{ value: 'none', label: '全部静默', selected: currentMode === 'none' },
|
|
2154
2156
|
];
|
|
@@ -2204,9 +2206,10 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
2204
2206
|
throw { code: target.code, message: target.error };
|
|
2205
2207
|
const currentMode = readMenuChatmode(target).value;
|
|
2206
2208
|
return [
|
|
2207
|
-
|
|
2209
|
+
...(target.field !== 'group'
|
|
2210
|
+
? [{ value: 'interactive', label: '交互模式', selected: currentMode === 'interactive' }] : []),
|
|
2208
2211
|
{ value: 'proactive', label: '主动模式', selected: currentMode === 'proactive' },
|
|
2209
|
-
...(target.field === 'private' &&
|
|
2212
|
+
...(target.field === 'private' && target.role === 'owner'
|
|
2210
2213
|
&& (target.scope === 'agent' || target.sel.peerKey?.startsWith('aun#'))
|
|
2211
2214
|
? [{ value: 'paactive', label: 'PA 模式', selected: currentMode === 'paactive' }] : []),
|
|
2212
2215
|
];
|
|
@@ -2593,6 +2596,14 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2593
2596
|
});
|
|
2594
2597
|
if (authDenied)
|
|
2595
2598
|
return authDenied;
|
|
2599
|
+
if (cmdBase === '/aid' && args?.view === 'agentmd') {
|
|
2600
|
+
try {
|
|
2601
|
+
return { data: await agentMdMenuService.query(subject, args) };
|
|
2602
|
+
}
|
|
2603
|
+
catch (error) {
|
|
2604
|
+
return menuResultFailure(error);
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2596
2607
|
if (cmdBase === '/trigger') {
|
|
2597
2608
|
if (args?.view !== 'detail' && args?.view !== 'history') {
|
|
2598
2609
|
return { error: 'Unsupported trigger query view', code: 'INVALID_ARGS' };
|
|
@@ -3293,11 +3304,25 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3293
3304
|
let session = loadedContext.session;
|
|
3294
3305
|
const evolagent = loadedContext.evolagent;
|
|
3295
3306
|
if (transportReplyContext?.threadId) {
|
|
3296
|
-
|
|
3297
|
-
|
|
3307
|
+
const modelAgentScope = (cmdBase === '/model' || cmdBase === '/effort')
|
|
3308
|
+
&& (menuStringArg(args, 'scope') ?? 'agent') === 'agent';
|
|
3309
|
+
if (modelAgentScope) {
|
|
3310
|
+
// Model settings belong to the Agent and can be changed from a locally
|
|
3311
|
+
// created topic before its first message has registered a Core session.
|
|
3312
|
+
try {
|
|
3313
|
+
session = await this.sessionManager.getThreadSession(channel, channelId, transportReplyContext.threadId) ?? session;
|
|
3314
|
+
}
|
|
3315
|
+
catch (error) {
|
|
3316
|
+
logger.debug(`[MenuHandler] topic context unavailable for Agent model update: thread=${transportReplyContext.threadId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
3317
|
+
}
|
|
3298
3318
|
}
|
|
3299
|
-
|
|
3300
|
-
|
|
3319
|
+
else {
|
|
3320
|
+
try {
|
|
3321
|
+
session = await loadMenuTopicSession(this.sessionManager, channel, channelId, transportReplyContext.threadId);
|
|
3322
|
+
}
|
|
3323
|
+
catch (error) {
|
|
3324
|
+
return menuResultFailure(error);
|
|
3325
|
+
}
|
|
3301
3326
|
}
|
|
3302
3327
|
}
|
|
3303
3328
|
if (cmdBase === '/baseagent-models')
|
|
@@ -3676,6 +3701,12 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3676
3701
|
});
|
|
3677
3702
|
if ('error' in target)
|
|
3678
3703
|
return target;
|
|
3704
|
+
if (target.field === 'group' && arg !== 'proactive') {
|
|
3705
|
+
return { error: '群聊仅支持 proactive 模式', code: 'NOT_APPLICABLE' };
|
|
3706
|
+
}
|
|
3707
|
+
if (arg === 'paactive' && identity.role !== 'owner') {
|
|
3708
|
+
return { error: 'paactive 模式仅限 owner', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3709
|
+
}
|
|
3679
3710
|
if ((arg === 'interactive' || arg === 'paactive') && target.roleLocked) {
|
|
3680
3711
|
return { error: '私聊交互模式仅限 owner/admin,当前角色固定为 proactive', code: 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3681
3712
|
}
|
|
@@ -3693,7 +3724,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
|
|
|
3693
3724
|
return { error: roleDecision.message || '当前角色不允许修改对话模式', code: roleDecision.code || 'ROLE_VALUE_NOT_ALLOWED' };
|
|
3694
3725
|
}
|
|
3695
3726
|
try {
|
|
3696
|
-
|
|
3727
|
+
writeChatmodeConfig(target, arg, subject);
|
|
3697
3728
|
}
|
|
3698
3729
|
catch (e) {
|
|
3699
3730
|
return { error: e?.message || String(e), code: e?.code || 'CONFIG_WRITE_FAILED', ...(e?.data !== undefined ? { data: e.data } : {}) };
|
|
@@ -3941,9 +3972,24 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
3941
3972
|
return { error: `不支持 gateway action: ${action}`, code: 'NOT_SUPPORTED' };
|
|
3942
3973
|
}
|
|
3943
3974
|
const isMenuAdmin = isManagementRole(authIdentity.role);
|
|
3944
|
-
// ── /aid avatar ──
|
|
3975
|
+
// ── /aid AgentMD and avatar ──
|
|
3945
3976
|
// Canonical avatar action; legacy agent/update patch.avatar reuses the same uploader.
|
|
3946
3977
|
if (cmdBase === '/aid') {
|
|
3978
|
+
if (action === 'agentmd.publish') {
|
|
3979
|
+
try {
|
|
3980
|
+
const data = await agentMdMenuService.publish(subject, args ?? {});
|
|
3981
|
+
this.eventBus?.publish({
|
|
3982
|
+
type: 'agent:updated', aid: data.aid, nameChanged: data.nameChanged, timestamp: Date.now(),
|
|
3983
|
+
});
|
|
3984
|
+
if (typeof data.avatar === 'string') {
|
|
3985
|
+
this.eventBus?.publish({ type: 'agent:avatar_updated', aid: data.aid, avatar: data.avatar, timestamp: Date.now() });
|
|
3986
|
+
}
|
|
3987
|
+
return { data };
|
|
3988
|
+
}
|
|
3989
|
+
catch (error) {
|
|
3990
|
+
return menuResultFailure(error);
|
|
3991
|
+
}
|
|
3992
|
+
}
|
|
3947
3993
|
if (action !== 'avatar')
|
|
3948
3994
|
return { error: `不支持 aid action: ${action}`, code: 'NOT_SUPPORTED' };
|
|
3949
3995
|
const result = await execAidAvatar(args);
|
|
@@ -4136,6 +4182,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4136
4182
|
return { error: 'Trigger details use menu.query with args.view="detail"', code: 'NOT_SUPPORTED' };
|
|
4137
4183
|
}
|
|
4138
4184
|
if (action === 'create' || action === 'set') {
|
|
4185
|
+
if (args && 'baseagent' in args) {
|
|
4186
|
+
return { error: 'Trigger 不支持覆盖 baseagent;使用所属 Agent 当前基座', code: 'INVALID_ARGS' };
|
|
4187
|
+
}
|
|
4139
4188
|
// args 结构化 → 直接组装 ParsedTriggerSet(绕过 parseTriggerSet 文本解析,无注入风险)
|
|
4140
4189
|
if (!args?.scheduleType || (args.scheduleType !== 'once' && !args?.scheduleValue) || !args?.prompt) {
|
|
4141
4190
|
return { error: '缺少必填参数:scheduleType / scheduleValue / prompt', code: 'INVALID_ARGS' };
|
|
@@ -4175,7 +4224,6 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4175
4224
|
effort: args.effort,
|
|
4176
4225
|
permissionMode: args.permissionMode,
|
|
4177
4226
|
triggerThread,
|
|
4178
|
-
baseagent: args.baseagent,
|
|
4179
4227
|
};
|
|
4180
4228
|
const r = await this.registerTriggerFromParsed(parsed, channel, channelId, userId ?? '', undefined, this.resolveMenuChatType(channel, channelId, explicitChatType), undefined, isAdmin, subject.isDaemonOwner, subject.canApprovePersistentFullAccess);
|
|
4181
4229
|
if (!r.ok) {
|
|
@@ -4621,6 +4669,8 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4621
4669
|
}
|
|
4622
4670
|
catch (err) {
|
|
4623
4671
|
logger.debug('[MenuHandler] Thread rename sync failed:', err);
|
|
4672
|
+
if (err?.code === 'RENAME_FAILED')
|
|
4673
|
+
return { error: '重命名失败', code: 'EXEC_FAILED' };
|
|
4624
4674
|
}
|
|
4625
4675
|
}
|
|
4626
4676
|
if (!renamedByThreadService) {
|
|
@@ -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',
|
|
@@ -353,6 +354,11 @@ export function validateMenuRequest(request) {
|
|
|
353
354
|
if (request.args !== undefined && (!request.args || typeof request.args !== 'object' || Array.isArray(request.args))) {
|
|
354
355
|
return { code: 'INVALID_ARGUMENT', message: 'Menu request args must be an object' };
|
|
355
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
|
+
}
|
|
356
362
|
if (request.name === 'slash-commands' || firstCommandToken(request.cmd) === '/evolhelp') {
|
|
357
363
|
if (type !== 'menu.query')
|
|
358
364
|
return { code: 'NOT_SUPPORTED', message: 'slash-commands only supports menu.query' };
|
|
@@ -644,6 +650,8 @@ const STABLE_CODES = new Set([
|
|
|
644
650
|
'INITIALIZE_AGENTMD_VERIFY_FAILED', 'INITIALIZE_OWNER_CONFLICT', 'INITIALIZE_AVATAR_FAILED',
|
|
645
651
|
'INITIALIZE_FAILED', 'MODEL_UNAVAILABLE', 'MODEL_NOT_CONFIGURED', 'BASEAGENT_REQUIRED',
|
|
646
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',
|
|
647
655
|
]);
|
|
648
656
|
export function normalizeMenuError(error) {
|
|
649
657
|
const source = error && typeof error === 'object' ? error : {};
|
|
@@ -5,6 +5,7 @@ import { ConfigTarget, read, resolveEffectiveWithSources, write } from '../../co
|
|
|
5
5
|
import { getBuiltinRolesConfig, getRoleDefinition, isValidUserRoleName, readRolesConfig, } from '../../config/roles.js';
|
|
6
6
|
import { BUILTIN_USER_ROLES, MANAGEMENT_ROLES, expectedRoleRank, isManagementRole } from '../../config/builtin-roles.js';
|
|
7
7
|
import { checkRoleAccess, isStaticAgentOwner, resolvePeerRoleDetail } from '../../config/peer-role-resolver.js';
|
|
8
|
+
import { preparePaTeamQualification } from '../relation/pa-team.js';
|
|
8
9
|
import { relationFieldWriteOperation, resolveRoleFieldPermission, } from '../../config/config-field-policy.js';
|
|
9
10
|
import { evaluateRoleOperationCapability } from '../auth/operation-authorizer.js';
|
|
10
11
|
import { listOperations } from '../auth/operation-catalog.js';
|
|
@@ -476,17 +477,19 @@ function updateDefaultRoles(context, args, value) {
|
|
|
476
477
|
const self = context.self;
|
|
477
478
|
if (!isObject(value))
|
|
478
479
|
throw invalidJsonType(self, 'defaultRoles', 'object');
|
|
479
|
-
assertOnlyKeys(value, ['private', 'group'], 'defaultRoles', self);
|
|
480
|
+
assertOnlyKeys(value, ['private', 'group', 'paTeam'], 'defaultRoles', self);
|
|
480
481
|
if (!Object.prototype.hasOwnProperty.call(value, 'private') || !Object.prototype.hasOwnProperty.call(value, 'group')) {
|
|
481
482
|
throw validationFailed(self, undefined, [{ field: 'defaultRoles', code: 'MISSING_FIELD', message: 'private and group are required' }]);
|
|
482
483
|
}
|
|
484
|
+
const registry = readRoleRegistry(self);
|
|
483
485
|
const nextDefaults = {
|
|
484
486
|
private: validateAssignableRole(value.private, self, 'defaultRoles.private'),
|
|
485
487
|
group: validateAssignableRole(value.group, self, 'defaultRoles.group'),
|
|
488
|
+
paTeam: validateAssignableRole(Object.prototype.hasOwnProperty.call(value, 'paTeam')
|
|
489
|
+
? value.paTeam ?? 'member' : registry.defaultRoles.paTeam ?? 'member', self, 'defaultRoles.paTeam'),
|
|
486
490
|
};
|
|
487
491
|
assertPolicyRevision(self, args);
|
|
488
|
-
const
|
|
489
|
-
const changesAdminDefault = ['private', 'group'].some(scene => registry.defaultRoles[scene] !== nextDefaults[scene]
|
|
492
|
+
const changesAdminDefault = ['private', 'group', 'paTeam'].some(scene => registry.defaultRoles[scene] !== nextDefaults[scene]
|
|
490
493
|
&& (registry.defaultRoles[scene] === 'admin' || nextDefaults[scene] === 'admin'));
|
|
491
494
|
if (!isDaemonOwnerControl(context) && context.actorRole !== 'owner' && changesAdminDefault) {
|
|
492
495
|
throw roleError('NOT_ALLOWED', 'Only an owner can set or replace an admin default role', self, {
|
|
@@ -741,9 +744,10 @@ async function deleteRole(context, args) {
|
|
|
741
744
|
const registry = readRoleRegistry(self);
|
|
742
745
|
const nextRegistry = clone(registry);
|
|
743
746
|
nextRegistry.roles = nextRegistry.roles.filter(item => item !== roleId);
|
|
744
|
-
for (const scene of ['private', 'group']) {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
+
for (const scene of ['private', 'group', 'paTeam']) {
|
|
748
|
+
const current = scene === 'paTeam' ? nextRegistry.defaultRoles[scene] ?? 'member' : nextRegistry.defaultRoles[scene];
|
|
749
|
+
if (current === roleId)
|
|
750
|
+
nextRegistry.defaultRoles[scene] = replacement ?? (scene === 'paTeam' ? 'member' : null);
|
|
747
751
|
}
|
|
748
752
|
const changes = [
|
|
749
753
|
{
|
|
@@ -775,7 +779,7 @@ async function assignmentInventory(context, args, policyRevision) {
|
|
|
775
779
|
const items = [];
|
|
776
780
|
if (args?.includeDefaults !== false) {
|
|
777
781
|
const defaults = effectiveDefaultRoles(self);
|
|
778
|
-
for (const scene of ['private', 'group']) {
|
|
782
|
+
for (const scene of ['private', 'group', 'paTeam']) {
|
|
779
783
|
const roleId = defaults[scene];
|
|
780
784
|
if (roleId && (!roleFilter || roleFilter === roleId)) {
|
|
781
785
|
items.push({ target: { kind: 'default', scene }, roleId, relationRevision: null });
|
|
@@ -819,6 +823,8 @@ async function targetSnapshot(context, args, policyRevision) {
|
|
|
819
823
|
const target = context.fromControlChannel
|
|
820
824
|
? normalized
|
|
821
825
|
: await validateTargetExists(context, normalized, { allowAuthenticatedPrivateActor: true });
|
|
826
|
+
if (target.kind === 'private')
|
|
827
|
+
await preparePaTeamQualification(self, target.peerAid);
|
|
822
828
|
const relation = readRelation(target.peerKey, self);
|
|
823
829
|
const roleView = targetRoleView(self, target, relation?.config ?? null);
|
|
824
830
|
const override = target.kind === 'private'
|
|
@@ -1306,7 +1312,7 @@ function readAgent(self) {
|
|
|
1306
1312
|
}
|
|
1307
1313
|
function effectiveDefaultRoles(self) {
|
|
1308
1314
|
const defaults = readRolesConfig(self).defaultRoles ?? {};
|
|
1309
|
-
return { private: defaults.private ?? null, group: defaults.group ?? null };
|
|
1315
|
+
return { private: defaults.private ?? null, group: defaults.group ?? null, paTeam: defaults.paTeam ?? 'member' };
|
|
1310
1316
|
}
|
|
1311
1317
|
function policyDocument(agent) {
|
|
1312
1318
|
const store = readRoleStore(agent.aid);
|
|
@@ -1488,7 +1494,7 @@ function relationTargetKind(self, config, channelId, known = { groups: new Set()
|
|
|
1488
1494
|
}
|
|
1489
1495
|
function countRoleUsage(self, relations, roleId) {
|
|
1490
1496
|
const configuredDefaults = effectiveDefaultRoles(self);
|
|
1491
|
-
const defaultScenes = ['private', 'group'].filter(scene => configuredDefaults[scene] === roleId);
|
|
1497
|
+
const defaultScenes = ['private', 'group', 'paTeam'].filter(scene => configuredDefaults[scene] === roleId);
|
|
1492
1498
|
let privateRelations = 0;
|
|
1493
1499
|
let groupRelations = 0;
|
|
1494
1500
|
for (const relation of relations) {
|
|
@@ -1525,6 +1531,14 @@ function validateRoleDomainTransactionChanges(self, registry, changes) {
|
|
|
1525
1531
|
field: 'registry', code: 'SCHEMA_INVALID', message: error.message ?? 'invalid role registry',
|
|
1526
1532
|
})));
|
|
1527
1533
|
}
|
|
1534
|
+
const validatedRegistry = registry;
|
|
1535
|
+
for (const scene of ['private', 'group', 'paTeam']) {
|
|
1536
|
+
const roleId = scene === 'paTeam' ? validatedRegistry.defaultRoles[scene] ?? 'member' : validatedRegistry.defaultRoles[scene];
|
|
1537
|
+
if (roleId !== null && (roleId === 'owner' || !validatedRegistry.roles.includes(roleId))) {
|
|
1538
|
+
throw validationFailed(self, roleId, [{ field: `defaultRoles.${scene}`, code: 'INVALID_ROLE',
|
|
1539
|
+
message: 'Default role must reference an assignable registered role' }]);
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1528
1542
|
for (const change of changes) {
|
|
1529
1543
|
if (!change.after || !change.file.endsWith('.json') || change.file.endsWith('index.json'))
|
|
1530
1544
|
continue;
|