evolcore 0.0.43-test.2 → 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 +8 -1
- package/dist/agents/ecagent-runner.js +13 -6
- package/dist/aun/aid/agentmd.js +21 -1
- package/dist/aun/msg/p2p.js +4 -2
- package/dist/channels/aun.js +79 -48
- package/dist/channels/daemon.js +4 -0
- package/dist/cli/agent-create.js +3 -5
- package/dist/cli/aun-commands.js +17 -19
- package/dist/cli/directory.js +101 -56
- package/dist/cli/index.js +1 -1
- package/dist/cli/peer.js +2 -1
- package/dist/cli/task-context.js +3 -1
- package/dist/config/access-policy.js +0 -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 +5 -0
- package/dist/config/config-manager.js +25 -10
- package/dist/config/peer-role-resolver.js +23 -1
- package/dist/config/role-schema.js +26 -2
- package/dist/config/role-service.js +9 -4
- package/dist/config/role-store.js +30 -8
- package/dist/core/auth/auth-gateway.js +14 -4
- package/dist/core/auth/operation-authorizer.js +17 -0
- package/dist/core/auth/operation-catalog.js +12 -2
- package/dist/core/channel-runtime.js +5 -0
- package/dist/core/command/agent-control.js +1 -1
- package/dist/core/command/agentmd-menu-request.js +50 -0
- package/dist/core/command/agentmd-menu.js +156 -0
- package/dist/core/command/command-handler.js +39 -3
- package/dist/core/command/menu-catalog.js +13 -0
- package/dist/core/command/menu-handler.js +59 -9
- 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 +48 -21
- package/dist/core/daemon-lifecycle.js +9 -1
- package/dist/core/evolagent.js +5 -4
- 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 +64 -28
- package/dist/core/message/message-admission.js +15 -65
- 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 +56 -35
- package/dist/core/ownership/owner-resolver.js +72 -34
- package/dist/core/permission/ec-command-parser.js +24 -10
- package/dist/core/relation/pa-team.js +127 -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 +197 -15
- 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 +219 -97
- 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/index.js +11 -0
- package/dist/paths.js +4 -2
- package/dist/product.js +1 -0
- package/dist/response-system/engines/v1/index.js +2 -4
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/trigger/scheduler.js +8 -3
- package/dist/utils/error-utils.js +7 -5
- 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/compaction.js +3 -0
- 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 +4 -1
- package/kits/docs/evolcore/directory.md +125 -35
- package/kits/docs/evolcore/ecweb-lifecycle.md +26 -0
- package/kits/docs/evolcore/file-navigation.md +265 -0
- package/kits/docs/evolcore/msg.md +1 -0
- package/kits/docs/evolcore/peer.md +2 -1
- package/kits/docs/evolcore/response.md +2 -2
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +1 -1
- package/kits/docs/identity/ROLE_DETAIL.md +2 -0
- package/kits/eck_manifest.json +7 -3
- package/kits/eck_manifest.memory.json +26 -1
- package/kits/schemas/_meta.json +16 -3
- package/kits/schemas/agent-config.schema.20.json +925 -0
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/schemas/role-config.schema.3.json +1038 -0
- package/kits/schemas/role-registry.schema.1.json +3 -2
- 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/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 +2 -2
- 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
|
@@ -2,10 +2,10 @@ import fs from 'fs';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { atomicReadJson } from '../utils/atomic-write.js';
|
|
4
4
|
import { agentRoleConfig, agentRolesDir, agentRolesIndex, kitsRoleTemplatesDir, resolvePaths, } from '../paths.js';
|
|
5
|
-
import { applyManagementRoleCeiling, expectedRoleRank, getManagementRoleDefinition } from './builtin-roles.js';
|
|
5
|
+
import { applyManagementRoleCeiling, DEFAULT_PA_TEAM_ROLE, expectedRoleRank, getManagementRoleDefinition } from './builtin-roles.js';
|
|
6
6
|
import { readBuiltinRoleTemplate } from './builtin-role-templates.js';
|
|
7
7
|
import { loadSchema } from './schema-registry.js';
|
|
8
|
-
import { normalizeRoleEffortCompat, validateRoleConfig } from './role-schema.js';
|
|
8
|
+
import { normalizeRoleEffortCompat, normalizeRoleGroupChatmodeCompat, validateRoleConfig } from './role-schema.js';
|
|
9
9
|
const ROLE_NAME_RE = /^[a-z0-9_-]+$/;
|
|
10
10
|
const BUILTIN_ROLES = ['owner', 'admin', 'member', 'visitor'];
|
|
11
11
|
const cache = new Map();
|
|
@@ -88,6 +88,7 @@ export function roleIsAssignable(selfAid, roleId) {
|
|
|
88
88
|
function readRegistry(selfAid, diagnostics) {
|
|
89
89
|
const file = agentRolesIndex(selfAid);
|
|
90
90
|
let raw;
|
|
91
|
+
let invalidPaTeam = false;
|
|
91
92
|
try {
|
|
92
93
|
raw = atomicReadJson(file);
|
|
93
94
|
}
|
|
@@ -101,11 +102,30 @@ function readRegistry(selfAid, diagnostics) {
|
|
|
101
102
|
}
|
|
102
103
|
if (raw !== null) {
|
|
103
104
|
const schema = loadSchema('role-registry');
|
|
105
|
+
if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
|
|
106
|
+
const record = raw;
|
|
107
|
+
if (record.defaultRoles && typeof record.defaultRoles === 'object' && !Array.isArray(record.defaultRoles)
|
|
108
|
+
&& !schema.validate(raw)) {
|
|
109
|
+
const defaults = { ...record.defaultRoles };
|
|
110
|
+
if (Object.hasOwn(defaults, 'paTeam')) {
|
|
111
|
+
delete defaults.paTeam;
|
|
112
|
+
const compatible = { ...record, defaultRoles: defaults };
|
|
113
|
+
if (schema.validate(compatible)) {
|
|
114
|
+
diagnostics.push({ code: 'INVALID_ROLE_ASSIGNMENT', file: path.relative(resolvePaths().root, file),
|
|
115
|
+
message: 'defaultRoles.paTeam is invalid; PA team authorization is disabled' });
|
|
116
|
+
raw = compatible;
|
|
117
|
+
invalidPaTeam = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
104
122
|
if (schema.validate(raw)) {
|
|
105
123
|
const value = raw;
|
|
106
124
|
const roles = [...new Set(value.roles)];
|
|
107
|
-
const defaultRoles = { ...value.defaultRoles };
|
|
108
|
-
for (const scene of ['private', 'group']) {
|
|
125
|
+
const defaultRoles = { ...value.defaultRoles, paTeam: invalidPaTeam ? '' : value.defaultRoles.paTeam ?? DEFAULT_PA_TEAM_ROLE };
|
|
126
|
+
for (const scene of ['private', 'group', 'paTeam']) {
|
|
127
|
+
if (scene === 'paTeam' && invalidPaTeam)
|
|
128
|
+
continue;
|
|
109
129
|
const selected = defaultRoles[scene];
|
|
110
130
|
if (selected === null || (roles.includes(selected) && selected !== 'owner'))
|
|
111
131
|
continue;
|
|
@@ -113,9 +133,11 @@ function readRegistry(selfAid, diagnostics) {
|
|
|
113
133
|
code: 'INVALID_ROLE_ASSIGNMENT',
|
|
114
134
|
roleId: selected,
|
|
115
135
|
file: path.relative(resolvePaths().root, file),
|
|
116
|
-
message: `defaultRoles.${scene} references invalid or unregistered role ${selected};
|
|
136
|
+
message: `defaultRoles.${scene} references invalid or unregistered role ${selected}; ${scene === 'paTeam'
|
|
137
|
+
? 'PA team authorization is disabled' : `using ${scene === 'group' ? 'member' : 'visitor'} fallback`}`,
|
|
117
138
|
});
|
|
118
|
-
|
|
139
|
+
if (scene !== 'paTeam')
|
|
140
|
+
defaultRoles[scene] = null;
|
|
119
141
|
}
|
|
120
142
|
return { ...value, roles, defaultRoles };
|
|
121
143
|
}
|
|
@@ -134,7 +156,7 @@ function readRegistry(selfAid, diagnostics) {
|
|
|
134
156
|
return fallbackRegistry();
|
|
135
157
|
}
|
|
136
158
|
function fallbackRegistry() {
|
|
137
|
-
return { $schema_version: 1, roles: [...BUILTIN_ROLES], defaultRoles: { private: null, group: null } };
|
|
159
|
+
return { $schema_version: 1, roles: [...BUILTIN_ROLES], defaultRoles: { private: null, group: null, paTeam: DEFAULT_PA_TEAM_ROLE } };
|
|
138
160
|
}
|
|
139
161
|
function readDefinition(selfAid, roleId, diagnostics) {
|
|
140
162
|
const local = agentRoleConfig(selfAid, roleId);
|
|
@@ -154,7 +176,7 @@ function readDefinition(selfAid, roleId, diagnostics) {
|
|
|
154
176
|
}
|
|
155
177
|
if (raw === null)
|
|
156
178
|
continue;
|
|
157
|
-
const normalizedRaw = normalizeRoleEffortCompat(raw);
|
|
179
|
+
const normalizedRaw = normalizeRoleGroupChatmodeCompat(normalizeRoleEffortCompat(raw));
|
|
158
180
|
const issues = validateRoleConfig(normalizedRaw);
|
|
159
181
|
if (issues.length === 0) {
|
|
160
182
|
const { $schema_version: _schemaVersion, ...definition } = normalizedRaw;
|
|
@@ -8,6 +8,7 @@ import { ownerResolver, refreshOwnershipForAuthorization, OWNERSHIP_CACHE_MAX_AG
|
|
|
8
8
|
import { getOperationMeta } from './operation-catalog.js';
|
|
9
9
|
import { constrainRuntimePermissionMode, resolveRuntimePermissionMode } from '../role/runtime-policy.js';
|
|
10
10
|
import { buildAuthorizationEventKey } from '../audit/event-key.js';
|
|
11
|
+
import { preparePaTeamQualification, paTeamQualification, requiresPaTeamVerification } from '../relation/pa-team.js';
|
|
11
12
|
export function isCrossAgentTriggerOperationAllowed(input) {
|
|
12
13
|
return input.control || input.daemonOwner === true || input.taskAgentAid === input.targetAgentAid;
|
|
13
14
|
}
|
|
@@ -41,7 +42,10 @@ export function buildAuthSubject(input) {
|
|
|
41
42
|
actor: roleDetail.actor,
|
|
42
43
|
processOwners,
|
|
43
44
|
}));
|
|
44
|
-
const
|
|
45
|
+
const teamContext = roleDetail.source === 'pa-team-default'
|
|
46
|
+
|| (input.channelType === 'aun' && chatType === 'private' && input.selfAid && actorId
|
|
47
|
+
&& (paTeamQualification(input.selfAid, actorId) === 'matched' || requiresPaTeamVerification(input.selfAid, actorId)));
|
|
48
|
+
const suppliedRole = !teamContext && input.identity?.role && input.identity.role !== 'none' ? input.identity.role : undefined;
|
|
45
49
|
const role = suppliedRole ?? roleDetail.effectiveRole ?? 'none';
|
|
46
50
|
const processRole = isFullAccessRun
|
|
47
51
|
? 'fullaccess-run'
|
|
@@ -111,16 +115,21 @@ export async function authorizeFreshOperation(params) {
|
|
|
111
115
|
&& ['owner', 'owners'].includes(configCommand.field.split('.')[0]);
|
|
112
116
|
const force = changesOwner || ['ec.aid.bind', 'ec.aid.unbind', 'ec.aid.transfer']
|
|
113
117
|
.includes(params.intent.operation) || params.intent.operation === 'config.restore';
|
|
118
|
+
const forceAgentMdEditor = params.source === 'menu'
|
|
119
|
+
&& ['ec.aid.agentmd.get', 'ec.aid.agentmd.put'].includes(params.intent.operation);
|
|
114
120
|
const operation = getOperationMeta(params.intent.operation);
|
|
115
121
|
const sensitive = force || params.intent.dangerous || operation?.dangerous || operation?.category !== 'read'
|
|
116
122
|
|| configCommand?.dangerous || subject.processRole === 'fullaccess-run';
|
|
117
123
|
try {
|
|
124
|
+
if (subject.channelType === 'aun' && subject.chatType === 'private') {
|
|
125
|
+
await preparePaTeamQualification(subject.selfAid, subject.actorId);
|
|
126
|
+
}
|
|
118
127
|
await refreshOwnershipForAuthorization(subject.selfAid, {
|
|
119
|
-
force,
|
|
128
|
+
force: force || forceAgentMdEditor,
|
|
120
129
|
...(sensitive ? {} : { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS }),
|
|
121
130
|
includeDaemon: subject.isDaemonOwner || subject.processRole === 'fullaccess-run'
|
|
122
131
|
|| params.intent.scope === 'process' || params.intent.scope === 'control' || force,
|
|
123
|
-
allowTransient: !force,
|
|
132
|
+
allowTransient: !force && !forceAgentMdEditor,
|
|
124
133
|
});
|
|
125
134
|
const targetAid = operation?.authorizationTarget === 'same-owner-agent'
|
|
126
135
|
&& subject.processRole !== 'fullaccess-run'
|
|
@@ -143,7 +152,8 @@ export async function authorizeFreshOperation(params) {
|
|
|
143
152
|
channel: subject.channel, channelType: subject.channelType, channelId: subject.channelId,
|
|
144
153
|
chatType: subject.chatType, conversationId: subject.conversationId,
|
|
145
154
|
fromControlChannel: subject.fromControlChannel,
|
|
146
|
-
identity: subject.
|
|
155
|
+
identity: subject.roleSource === 'pa-team-default' || (subject.role === 'owner' && subject.principalId)
|
|
156
|
+
? undefined : subject.identity,
|
|
147
157
|
});
|
|
148
158
|
if (subject.processRole === 'fullaccess-run') {
|
|
149
159
|
if (!subject.authorizedBy || !ownerResolver.daemonOwners().includes(subject.authorizedBy)) {
|
|
@@ -111,6 +111,23 @@ function authorizeCommandInternal(ctx, resolvedConfigCommand) {
|
|
|
111
111
|
if (!opMeta) {
|
|
112
112
|
return denyDecision(ctx, 'NOT_ALLOWED', `Unknown operation: ${operation}`, operation, intent.scope);
|
|
113
113
|
}
|
|
114
|
+
// The App editor is narrower than public Agent-tool reads and daemon management.
|
|
115
|
+
// No configured role, control token or daemon Owner may impersonate the protocol Owner.
|
|
116
|
+
if (['ec.aid.agentmd.get', 'ec.aid.agentmd.put'].includes(operation) && ctx.source !== 'agent-tool') {
|
|
117
|
+
const view = ctx.selfAid ? ownerResolver.snapshot(ctx.selfAid) : undefined;
|
|
118
|
+
const c = view?.consensus;
|
|
119
|
+
const target = intent.args.aid ?? intent.args.targetAgentAid ?? ctx.selfAid;
|
|
120
|
+
const allowed = ctx.source === 'menu' && intent.scope === 'agent' && ctx.chatType === 'private'
|
|
121
|
+
&& !ctx.fromControlChannel && target === ctx.selfAid
|
|
122
|
+
&& !!ctx.principalId && ctx.actorId === ctx.principalId
|
|
123
|
+
&& view?.consensusStatus === 'consensus' && !view.refreshFailure
|
|
124
|
+
&& c?.status === 'consensus' && c.sub_aid === ctx.selfAid && c.lock === 'locked'
|
|
125
|
+
&& Number.isSafeInteger(c.relation_version) && c.relation_version > 0
|
|
126
|
+
&& ownerResolver.owner(ctx.selfAid) === ctx.principalId && c.owner_aid === ctx.principalId;
|
|
127
|
+
return allowed
|
|
128
|
+
? { allow: true, operation, scope: intent.scope, role, dangerous: opMeta.dangerous, matchedRule: 'agentmd-protocol-owner' }
|
|
129
|
+
: denyDecision(ctx, 'NOT_ALLOWED', 'AgentMD editor requires the current protocol Owner on its Agent channel', operation, intent.scope, opMeta.dangerous);
|
|
130
|
+
}
|
|
114
131
|
if (isFieldConfigOperation(operation) && !resolvedConfigCommand) {
|
|
115
132
|
return denyDecision(ctx, 'NOT_ALLOWED', 'Resolved config operation is required', operation, intent.scope, opMeta.dangerous);
|
|
116
133
|
}
|
|
@@ -169,6 +169,16 @@ const OPERATIONS = [
|
|
|
169
169
|
authorizationTarget: 'same-owner-agent',
|
|
170
170
|
authorizationPolicy: { authority: 'agent-owner', permissionMode: 'bypass', mode: 'require' },
|
|
171
171
|
},
|
|
172
|
+
{
|
|
173
|
+
id: 'ec.directory.request',
|
|
174
|
+
category: 'write-own',
|
|
175
|
+
dangerous: false,
|
|
176
|
+
defaultScopes: ['agent'],
|
|
177
|
+
description: 'Send an encrypted app-v1 friend invitation to a target AID',
|
|
178
|
+
sources: ['agent-tool'],
|
|
179
|
+
authorizationTarget: 'current-agent',
|
|
180
|
+
authorizationPolicy: { authority: 'agent-owner', permissionMode: 'bypass', mode: 'require' },
|
|
181
|
+
},
|
|
172
182
|
...PROVIDER_OPERATIONS,
|
|
173
183
|
{
|
|
174
184
|
id: 'proxy.read',
|
|
@@ -1279,7 +1289,7 @@ const OPERATIONS = [
|
|
|
1279
1289
|
dangerous: false,
|
|
1280
1290
|
defaultScopes: ['relation', 'agent'],
|
|
1281
1291
|
description: 'Read and verify a public Agent agent.md',
|
|
1282
|
-
sources: ['agent-tool'],
|
|
1292
|
+
sources: ['agent-tool', 'menu'],
|
|
1283
1293
|
},
|
|
1284
1294
|
{
|
|
1285
1295
|
id: 'ec.aid.agentmd.put',
|
|
@@ -1287,7 +1297,7 @@ const OPERATIONS = [
|
|
|
1287
1297
|
dangerous: true,
|
|
1288
1298
|
defaultScopes: ['agent'],
|
|
1289
1299
|
description: 'Sign and publish the current Agent local agent.md',
|
|
1290
|
-
sources: ['agent-tool'],
|
|
1300
|
+
sources: ['agent-tool', 'menu'],
|
|
1291
1301
|
minimumPermissionMode: 'request',
|
|
1292
1302
|
authorizationTarget: 'current-agent',
|
|
1293
1303
|
},
|
|
@@ -93,6 +93,7 @@ export function createChannelConnectionRuntime(dependencies) {
|
|
|
93
93
|
}),
|
|
94
94
|
agent ? dependencies.ensureTriggerSchedulerStarted(agent) : Promise.resolve(),
|
|
95
95
|
Promise.resolve().then(() => dependencies.sendOnlineNoticeForChannel(instance)),
|
|
96
|
+
Promise.resolve().then(() => dependencies.sendLifecycleNoticeForChannel?.(instance)),
|
|
96
97
|
dependencies.trySendPendingRestartNotice(),
|
|
97
98
|
]);
|
|
98
99
|
};
|
|
@@ -168,6 +169,10 @@ export function createChannelStartupNotifications({ channelInstances, agentRegis
|
|
|
168
169
|
let pendingRestartNoticeSent = false;
|
|
169
170
|
let pendingRestartRetry;
|
|
170
171
|
const sendOnlineNoticeForChannel = (inst) => {
|
|
172
|
+
// AUN 的上线提示改走 volatile 生命周期通知(见 lifecycle-notice.ts),
|
|
173
|
+
// 这里只保留非 AUN 渠道的 durable 通知,避免同时开启时重复两条。
|
|
174
|
+
if (inst.channelType === 'aun')
|
|
175
|
+
return;
|
|
171
176
|
const name = inst.adapter.channelName;
|
|
172
177
|
const agent = agentRegistry.resolveByChannel(inst.adapter.channelKey) ?? agentRegistry.resolveByChannel(name);
|
|
173
178
|
if (!agent || !upmsg)
|
|
@@ -146,7 +146,7 @@ async function execOneShotCreate(a, peerId, service, subject) {
|
|
|
146
146
|
}
|
|
147
147
|
if (a.chatmode !== undefined && (!a.chatmode || typeof a.chatmode !== 'object' || Array.isArray(a.chatmode)
|
|
148
148
|
|| Object.entries(a.chatmode).some(([key, value]) => !['private', 'group', 'nothuman'].includes(key)
|
|
149
|
-
|| !['interactive', 'proactive', ...(key === 'private' ? ['paactive'] : [])].includes(value)))) {
|
|
149
|
+
|| !(key === 'group' ? ['proactive'] : ['interactive', 'proactive', ...(key === 'private' ? ['paactive'] : [])]).includes(value)))) {
|
|
150
150
|
return { error: 'chatmode 必须包含有效的 private/group/nothuman 模式', code: 'INVALID_ARGS' };
|
|
151
151
|
}
|
|
152
152
|
let avatarUrl;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Includes value batches containing the AgentMD entry, for replay and E2EE guards. */
|
|
2
|
+
export function containsAgentMdMenuRequest(request) {
|
|
3
|
+
const args = request.args;
|
|
4
|
+
const command = typeof request.cmd === 'string' ? request.cmd.trim().split(/\s+/)[0] : '';
|
|
5
|
+
if (request.name === 'aid' || command === '/aid') {
|
|
6
|
+
return (request.type === 'menu.query' && args?.view === 'agentmd')
|
|
7
|
+
|| (request.type === 'menu.action' && request.action === 'agentmd.publish');
|
|
8
|
+
}
|
|
9
|
+
return request.type === 'menu.query' && request.name === 'menu' && args?.view === 'values'
|
|
10
|
+
&& Array.isArray(args.items) && args.items.some(item => item?.entryId === 'aid.agentmd');
|
|
11
|
+
}
|
|
12
|
+
/** Shared by the JSON validator and direct Menu execution entry points. */
|
|
13
|
+
export function validateAgentMdMenuRequest(request) {
|
|
14
|
+
const fail = (message) => ({ code: 'INVALID_ARGUMENT', message });
|
|
15
|
+
const args = request.args;
|
|
16
|
+
if (!args || typeof args !== 'object' || Array.isArray(args))
|
|
17
|
+
return fail('agentmd requires args');
|
|
18
|
+
const a = args;
|
|
19
|
+
const query = request.type === 'menu.query' && a.view === 'agentmd';
|
|
20
|
+
const publish = request.type === 'menu.action' && request.action === 'agentmd.publish';
|
|
21
|
+
if (!query && !publish)
|
|
22
|
+
return { code: 'NOT_SUPPORTED', message: 'Unsupported agentmd Menu operation' };
|
|
23
|
+
const allowed = query ? ['aid', 'view', 'protocolVersion', 'scope', 'self']
|
|
24
|
+
: ['aid', 'content', 'expectedEtag', 'expectedRelationVersion', 'protocolVersion', 'scope', 'self'];
|
|
25
|
+
if (Object.keys(a).some(key => !allowed.includes(key)))
|
|
26
|
+
return fail('Unsupported agentmd argument');
|
|
27
|
+
if (a.protocolVersion !== undefined && a.protocolVersion !== 1) {
|
|
28
|
+
return { code: 'SCHEMA_VERSION_UNSUPPORTED', message: 'Only agentmd protocol version 1 is supported' };
|
|
29
|
+
}
|
|
30
|
+
if (a.aid !== undefined && (typeof a.aid !== 'string' || !a.aid.trim()))
|
|
31
|
+
return fail('aid must be a non-empty string');
|
|
32
|
+
if (a.self !== undefined && (typeof a.self !== 'string' || !a.self.trim()))
|
|
33
|
+
return fail('self must be a non-empty string');
|
|
34
|
+
if (a.scope !== undefined && a.scope !== 'agent')
|
|
35
|
+
return fail('agentmd requires Agent scope');
|
|
36
|
+
if (publish) {
|
|
37
|
+
if (typeof a.content !== 'string' || !a.content.trim())
|
|
38
|
+
return fail('content must be non-empty Markdown');
|
|
39
|
+
// Includes a possible SDK tail signature. The payload has a separate 4096-byte limit.
|
|
40
|
+
if (Buffer.byteLength(a.content, 'utf8') > 6144)
|
|
41
|
+
return fail('agent.md document exceeds 6144 bytes');
|
|
42
|
+
if (typeof a.expectedEtag !== 'string' || !a.expectedEtag.trim()
|
|
43
|
+
|| a.expectedEtag.length > 512 || /[\r\n]/.test(a.expectedEtag))
|
|
44
|
+
return fail('expectedEtag is required');
|
|
45
|
+
if (!Number.isSafeInteger(a.expectedRelationVersion) || a.expectedRelationVersion < 1) {
|
|
46
|
+
return fail('expectedRelationVersion must be a positive integer');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { validateAgentMdDocument } from '@agentunion/fastaun';
|
|
3
|
+
import { agentmdGet, agentmdUpdate, AGENT_MD_MAX_PAYLOAD_BYTES, AGENT_DESCRIPTION_MAX_LENGTH, } from '../../aun/aid/agentmd.js';
|
|
4
|
+
import { ownerResolver } from '../ownership/owner-resolver.js';
|
|
5
|
+
import { validateAgentMdMenuRequest } from './agentmd-menu-request.js';
|
|
6
|
+
export const AGENT_MD_PROTECTED_FIELDS = [
|
|
7
|
+
'aid', 'type', 'owner', 'ownership', 'ownership_proof', 'ownership_release', 'entity_cert_fingerprint',
|
|
8
|
+
];
|
|
9
|
+
function fail(code, message) {
|
|
10
|
+
throw Object.assign(new Error(message), { code });
|
|
11
|
+
}
|
|
12
|
+
function parse(content, aid) {
|
|
13
|
+
try {
|
|
14
|
+
return validateAgentMdDocument(content, { expectedAid: aid, validateOwnership: false });
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return fail('INVALID_ARGUMENT', error instanceof Error ? error.message : 'Invalid agent.md document');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const defaults = {
|
|
21
|
+
refresh: (aid) => ownerResolver.refresh(aid, { force: true, allowTransient: false, source: 'agentmd-menu' }),
|
|
22
|
+
read: (aid) => agentmdGet(aid, { withVerification: true, remoteOnly: true }),
|
|
23
|
+
update: agentmdUpdate,
|
|
24
|
+
};
|
|
25
|
+
/** Only protocol Ownership authorizes this editor; configured Owners and roles cannot grant it. */
|
|
26
|
+
export class AgentMdMenuService {
|
|
27
|
+
deps;
|
|
28
|
+
constructor(deps = defaults) {
|
|
29
|
+
this.deps = deps;
|
|
30
|
+
}
|
|
31
|
+
target(subject, args) {
|
|
32
|
+
const aid = subject.selfAid;
|
|
33
|
+
if (!aid || (args.aid !== undefined && args.aid !== aid) || (args.self !== undefined && args.self !== aid)) {
|
|
34
|
+
fail('FORBIDDEN', 'AgentMD must target the receiving Agent');
|
|
35
|
+
}
|
|
36
|
+
if (subject.channelType !== 'aun' || subject.chatType !== 'private'
|
|
37
|
+
|| (subject.menuTransportChatType ?? subject.chatType) !== 'private' || subject.menuEncrypted !== true
|
|
38
|
+
|| subject.fromControlChannel || subject.ecwebManagement
|
|
39
|
+
|| !subject.principalId || subject.actorId !== subject.principalId || subject.processRole === 'daemon-service') {
|
|
40
|
+
fail('FORBIDDEN', 'AgentMD editing requires an encrypted AUN request from the authenticated Owner');
|
|
41
|
+
}
|
|
42
|
+
return aid;
|
|
43
|
+
}
|
|
44
|
+
/** Cached Menu responses must still require the current protocol Owner. */
|
|
45
|
+
async preflight(subject) {
|
|
46
|
+
await this.authorize(this.target(subject, {}), subject);
|
|
47
|
+
}
|
|
48
|
+
async authorize(aid, subject, relationVersion) {
|
|
49
|
+
let view;
|
|
50
|
+
try {
|
|
51
|
+
view = await this.deps.refresh(aid);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return fail('OWNER_UNAVAILABLE', 'Fresh Ownership consensus is unavailable');
|
|
55
|
+
}
|
|
56
|
+
const c = view.consensus;
|
|
57
|
+
if (view.refreshFailure || view.consensusStatus === 'unavailable' || !c) {
|
|
58
|
+
fail('OWNER_UNAVAILABLE', 'Fresh Ownership consensus is unavailable');
|
|
59
|
+
}
|
|
60
|
+
if (view.consensusStatus !== 'consensus' || c.status !== 'consensus' || c.sub_aid !== aid
|
|
61
|
+
|| c.lock !== 'locked' || !Number.isSafeInteger(c.relation_version) || c.relation_version < 1
|
|
62
|
+
|| c.owner_aid !== subject.principalId) {
|
|
63
|
+
fail('FORBIDDEN', 'Only the current protocol Owner can edit this AgentMD');
|
|
64
|
+
}
|
|
65
|
+
if (relationVersion !== undefined && c.relation_version !== relationVersion) {
|
|
66
|
+
fail('OWNERSHIP_CONFLICT', 'Ownership changed; reopen the editor');
|
|
67
|
+
}
|
|
68
|
+
return c;
|
|
69
|
+
}
|
|
70
|
+
card(current, aid, consensus) {
|
|
71
|
+
if (current.source !== 'remote' || current.verification.status !== 'verified') {
|
|
72
|
+
fail('AGENTMD_UNVERIFIED', 'A verified remote AgentMD is required');
|
|
73
|
+
}
|
|
74
|
+
const parsed = parse(current.content, aid);
|
|
75
|
+
const fields = parsed.frontmatter;
|
|
76
|
+
if (['human', 'group', 'org', 'host'].includes(String(fields.type).trim().toLowerCase())) {
|
|
77
|
+
fail('NOT_SUPPORTED', 'This editor supports ordinary Agents only');
|
|
78
|
+
}
|
|
79
|
+
if (fields.owner !== consensus.owner_aid)
|
|
80
|
+
fail('OWNERSHIP_CONFLICT', 'AgentMD Owner does not match consensus');
|
|
81
|
+
const etag = current.remoteVersion?.etag;
|
|
82
|
+
if (!etag)
|
|
83
|
+
fail('REMOTE_VERSION_UNAVAILABLE', 'Remote AgentMD has no ETag');
|
|
84
|
+
if (consensus.agent_md_etag !== etag)
|
|
85
|
+
fail('REMOTE_VERSION_CONFLICT', 'AgentMD changed during ownership verification; reload');
|
|
86
|
+
return { ...parsed, etag };
|
|
87
|
+
}
|
|
88
|
+
async query(subject, args) {
|
|
89
|
+
const invalid = validateAgentMdMenuRequest({ type: 'menu.query', args });
|
|
90
|
+
if (invalid)
|
|
91
|
+
fail(invalid.code, invalid.message);
|
|
92
|
+
const aid = this.target(subject, args);
|
|
93
|
+
await this.authorize(aid, subject);
|
|
94
|
+
const current = await this.deps.read(aid);
|
|
95
|
+
const c = await this.authorize(aid, subject);
|
|
96
|
+
const card = this.card(current, aid, c);
|
|
97
|
+
return {
|
|
98
|
+
protocol: 'evol.agentmd', protocolVersion: 1, aid,
|
|
99
|
+
content: card.payload, etag: card.etag, relationVersion: c.relation_version,
|
|
100
|
+
verification: 'verified', protectedFields: AGENT_MD_PROTECTED_FIELDS,
|
|
101
|
+
limits: { maxPayloadBytes: AGENT_MD_MAX_PAYLOAD_BYTES, maxDescriptionCharacters: AGENT_DESCRIPTION_MAX_LENGTH },
|
|
102
|
+
atomicVersionCheck: false,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async publish(subject, args) {
|
|
106
|
+
const invalid = validateAgentMdMenuRequest({ type: 'menu.action', action: 'agentmd.publish', args });
|
|
107
|
+
if (invalid)
|
|
108
|
+
fail(invalid.code, invalid.message);
|
|
109
|
+
const aid = this.target(subject, args);
|
|
110
|
+
const version = args.expectedRelationVersion;
|
|
111
|
+
await this.authorize(aid, subject, version);
|
|
112
|
+
const candidate = parse(args.content, aid);
|
|
113
|
+
let previousFields = {};
|
|
114
|
+
let result;
|
|
115
|
+
try {
|
|
116
|
+
result = await this.deps.update(aid, async (current) => {
|
|
117
|
+
const consensus = await this.authorize(aid, subject, version);
|
|
118
|
+
const base = this.card(current, aid, consensus);
|
|
119
|
+
if (base.etag !== args.expectedEtag)
|
|
120
|
+
fail('REMOTE_VERSION_CONFLICT', 'AgentMD changed; reload before publishing');
|
|
121
|
+
previousFields = base.frontmatter;
|
|
122
|
+
for (const field of AGENT_MD_PROTECTED_FIELDS) {
|
|
123
|
+
if (Object.hasOwn(base.frontmatter, field) !== Object.hasOwn(candidate.frontmatter, field)
|
|
124
|
+
|| !isDeepStrictEqual(base.frontmatter[field], candidate.frontmatter[field])) {
|
|
125
|
+
fail('PROTECTED_FIELD', `AgentMD field ${field} cannot be changed by this editor`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return candidate.payload;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
// Keep SDK conditional-upload conflicts actionable at the Menu boundary.
|
|
133
|
+
if (String(error?.code ?? '').toLowerCase() === 'conflict') {
|
|
134
|
+
fail('REMOTE_VERSION_CONFLICT', 'AgentMD changed during upload; reload before retrying');
|
|
135
|
+
}
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
// SDK acknowledgement is insufficient: confirm the actual remotely verified document.
|
|
139
|
+
const published = await this.deps.read(aid);
|
|
140
|
+
const consensus = await this.authorize(aid, subject, version);
|
|
141
|
+
const accepted = this.card(published, aid, consensus);
|
|
142
|
+
const body = (payload) => payload.replace(/\r\n/g, '\n')
|
|
143
|
+
.replace(/^---\n[\s\S]*?\n---(?:\n|$)/, '').trim();
|
|
144
|
+
if (!isDeepStrictEqual(candidate.frontmatter, accepted.frontmatter) || body(candidate.payload) !== body(accepted.payload)) {
|
|
145
|
+
fail('PUBLISH_NOT_CONFIRMED', 'The remote AgentMD does not confirm this edit; refresh before retrying');
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
protocol: 'evol.agentmd', protocolVersion: 1, aid, published: true,
|
|
149
|
+
content: accepted.payload, etag: accepted.etag, relationVersion: consensus.relation_version,
|
|
150
|
+
verification: 'verified', versionChecked: result.versionChecked, atomicVersionCheck: false,
|
|
151
|
+
nameChanged: previousFields.name !== accepted.frontmatter.name,
|
|
152
|
+
...(previousFields.avatar !== accepted.frontmatter.avatar ? { avatar: accepted.frontmatter.avatar ?? '' } : {}),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export const agentMdMenuService = new AgentMdMenuService();
|
|
@@ -39,6 +39,7 @@ import { auditCommandAuthorization, auditFullAccessEvent, hashArgv } from '../au
|
|
|
39
39
|
import { ResponseModeRegistry } from '../../response-system/registry.js';
|
|
40
40
|
import { registerBuiltinModes } from '../../response-system/modes/index.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';
|
|
@@ -2154,7 +2155,7 @@ export class CommandHandler {
|
|
|
2154
2155
|
}
|
|
2155
2156
|
}
|
|
2156
2157
|
/**
|
|
2157
|
-
* `ec directory
|
|
2158
|
+
* `ec directory ...`:查询、重算注入与向当前 Agent 的 Owner 申请入录。
|
|
2158
2159
|
*
|
|
2159
2160
|
* 备注不走命令——它是自己的 agent 目录下的一个 markdown 文件,由 Agent 直接读写。
|
|
2160
2161
|
* 权限边界:目标 Agent 必须是调用方自身,或者与调用方同属一个 Owner。
|
|
@@ -2170,12 +2171,18 @@ export class CommandHandler {
|
|
|
2170
2171
|
if (!session)
|
|
2171
2172
|
return { ok: false, code: 'INVALID_SESSION', error: 'Invalid session' };
|
|
2172
2173
|
// argv 形如 ['directory', '<sub>', ...]
|
|
2173
|
-
const
|
|
2174
|
+
const rawSubArgv = argv.slice(1);
|
|
2174
2175
|
const grantSelfAid = delegation.grant.selfAid.replace(/^@/, '');
|
|
2175
2176
|
const sessionSelfAid = session.selfAID?.replace(/^@/, '');
|
|
2176
2177
|
if (sessionSelfAid && sessionSelfAid !== grantSelfAid) {
|
|
2177
2178
|
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation self agent does not match the active session' };
|
|
2178
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];
|
|
2179
2186
|
const selfIndex = subArgv.indexOf('--self');
|
|
2180
2187
|
const targetAid = selfIndex >= 0 && selfIndex === subArgv.lastIndexOf('--self')
|
|
2181
2188
|
? subArgv[selfIndex + 1]
|
|
@@ -2190,7 +2197,11 @@ export class CommandHandler {
|
|
|
2190
2197
|
catch {
|
|
2191
2198
|
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation contains an invalid relation key' };
|
|
2192
2199
|
}
|
|
2193
|
-
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';
|
|
2194
2205
|
const subject = buildAuthSubject({
|
|
2195
2206
|
selfAid: grantSelfAid,
|
|
2196
2207
|
sessionId,
|
|
@@ -2219,6 +2230,31 @@ export class CommandHandler {
|
|
|
2219
2230
|
messageId: delegation.grant.messageId,
|
|
2220
2231
|
},
|
|
2221
2232
|
}, async (onExecutionStarted) => {
|
|
2233
|
+
if (isRequest) {
|
|
2234
|
+
try {
|
|
2235
|
+
const command = resolveDirectoryRequestCommand(subArgv);
|
|
2236
|
+
if (command.selfAid !== grantSelfAid) {
|
|
2237
|
+
return { ok: false, code: 'SCOPE_MISMATCH', error: '加好友申请只能使用当前任务所属 Agent AID' };
|
|
2238
|
+
}
|
|
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 };
|
|
2252
|
+
}
|
|
2253
|
+
catch (error) {
|
|
2254
|
+
return { ok: false, code: error instanceof DirectoryQueryError ? error.code : 'FRIEND_INVITE_FAILED',
|
|
2255
|
+
error: error instanceof Error ? error.message : String(error) };
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2222
2258
|
let command;
|
|
2223
2259
|
try {
|
|
2224
2260
|
command = resolveDirectoryQueryCommand(subArgv);
|
|
@@ -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,
|
|
@@ -389,6 +396,12 @@ async function operationView(binding, context, options = {}) {
|
|
|
389
396
|
return undefined;
|
|
390
397
|
if (binding.supported === false)
|
|
391
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
|
+
}
|
|
392
405
|
if (binding.operation === 'system.paircode' && options.paircodeAllowed === false) {
|
|
393
406
|
return {
|
|
394
407
|
supported: true,
|