evolcore 0.0.39 → 0.0.41-test.0

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.
Files changed (153) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +31 -20
  3. package/bin/codex-managed-hook.mjs +11 -0
  4. package/bin/ec-safe-output.js +25 -3
  5. package/dist/agents/baseagent-availability.js +1 -0
  6. package/dist/agents/claude-runner.js +53 -152
  7. package/dist/agents/codex-runner.js +485 -241
  8. package/dist/agents/ecagent-runner.js +48 -18
  9. package/dist/agents/gemini-runner.js +27 -8
  10. package/dist/agents/runner-types.js +39 -9
  11. package/dist/aun/ability-device-routing.js +26 -0
  12. package/dist/aun/aid/client.js +1 -1
  13. package/dist/aun/aid/control-aid.js +23 -98
  14. package/dist/aun/aid/ownership-operation.js +1 -3
  15. package/dist/aun/group/identity.js +8 -0
  16. package/dist/aun/group/invite-service.js +6 -0
  17. package/dist/aun/msg/managed-operation.js +4 -4
  18. package/dist/aun/msg/p2p.js +28 -12
  19. package/dist/aun/storage/download.js +30 -0
  20. package/dist/aun/storage/index.js +14 -6
  21. package/dist/channels/aun.js +99 -52
  22. package/dist/channels/daemon.js +24 -4
  23. package/dist/channels/dingtalk.js +8 -2
  24. package/dist/channels/feishu.js +6 -1
  25. package/dist/channels/wecom.js +7 -3
  26. package/dist/cli/agent-command.js +2 -0
  27. package/dist/cli/agent-create.js +121 -23
  28. package/dist/cli/agent.js +10 -3
  29. package/dist/cli/aid-bind-command.js +4 -1
  30. package/dist/cli/aun-commands.js +82 -22
  31. package/dist/cli/daemon-commands.js +260 -26
  32. package/dist/cli/index.js +25 -13
  33. package/dist/cli/memory-command.js +33 -14
  34. package/dist/cli/restart-monitor.js +52 -13
  35. package/dist/cli/session-command.js +128 -13
  36. package/dist/cli/stats.js +60 -4
  37. package/dist/cli/task-context.js +1 -0
  38. package/dist/cli/trigger-command.js +2 -2
  39. package/dist/config/access-policy.js +2 -0
  40. package/dist/config/config-field-policy.js +1 -0
  41. package/dist/config/config-operation-service.js +17 -6
  42. package/dist/config/gateway-config.js +1 -1
  43. package/dist/config/peer-role-resolver.js +10 -8
  44. package/dist/contracts/ecweb-service-protocol.js +44 -0
  45. package/dist/core/agent-application-service.js +11 -1
  46. package/dist/core/agent-ipc-registration.js +4 -0
  47. package/dist/core/agent-runtime.js +6 -0
  48. package/dist/core/auth/agent-delegation.js +87 -9
  49. package/dist/core/auth/auth-gateway.js +3 -1
  50. package/dist/core/auth/authorization-audit.js +25 -4
  51. package/dist/core/auth/debug-context.js +5 -1
  52. package/dist/core/auth/operation-catalog.js +24 -0
  53. package/dist/core/command/agent-control.js +91 -12
  54. package/dist/core/command/command-handler.js +64 -47
  55. package/dist/core/command/connect-menu.js +23 -2
  56. package/dist/core/command/menu-catalog.js +49 -12
  57. package/dist/core/command/menu-handler.js +110 -105
  58. package/dist/core/command/menu-protocol.js +29 -3
  59. package/dist/core/command/role-menu.js +7 -6
  60. package/dist/core/command/slash-gate.js +22 -5
  61. package/dist/core/command/slash-handler.js +121 -102
  62. package/dist/core/event-catalog.js +17 -0
  63. package/dist/core/interaction-router.js +2 -1
  64. package/dist/core/ipc-registration.js +44 -8
  65. package/dist/core/memory/batch-meta.js +2 -0
  66. package/dist/core/memory/consolidation-context.js +42 -51
  67. package/dist/core/memory/consolidation-ops-records.js +39 -7
  68. package/dist/core/memory/consolidation-trigger.js +72 -65
  69. package/dist/core/memory/consolidation.js +226 -20
  70. package/dist/core/memory/memory-writer.js +160 -34
  71. package/dist/core/memory/relation-idle-monitor.js +287 -0
  72. package/dist/core/memory/relation-sweep.js +206 -0
  73. package/dist/core/message/aun-ipc-sender.js +31 -5
  74. package/dist/core/message/aun-request-registry.js +97 -3
  75. package/dist/core/message/im-renderer.js +4 -0
  76. package/dist/core/message/message-admission.js +8 -4
  77. package/dist/core/message/message-bridge.js +96 -53
  78. package/dist/core/message/message-log.js +72 -0
  79. package/dist/core/message/message-queue.js +11 -5
  80. package/dist/core/message/outbound.js +70 -0
  81. package/dist/core/message/peer-mode.js +7 -2
  82. package/dist/core/message/response-engine.js +633 -191
  83. package/dist/core/model/model-catalog.js +7 -6
  84. package/dist/core/ownership/owner-resolver.js +384 -178
  85. package/dist/core/permission/ec-command-parser.js +129 -8
  86. package/dist/core/permission/tool-policy.js +35 -14
  87. package/dist/core/role/runtime-policy.js +64 -0
  88. package/dist/core/session/session-capsule.js +197 -0
  89. package/dist/core/session/session-manager.js +172 -18
  90. package/dist/core/session/session-mapper.js +2 -0
  91. package/dist/core/system-session/memory.js +3 -18
  92. package/dist/ecweb/basic-settings-service.js +709 -0
  93. package/dist/ecweb/providers-service.js +172 -0
  94. package/dist/index.js +95 -7
  95. package/dist/ipc.js +100 -19
  96. package/dist/stats/budget.js +1 -1
  97. package/dist/stats/db.js +48 -0
  98. package/dist/stats/index.js +3 -3
  99. package/dist/stats/price-resolver.js +304 -5
  100. package/dist/stats/query.js +328 -3
  101. package/dist/stats/writer.js +79 -6
  102. package/dist/trigger/application-service.js +12 -0
  103. package/dist/trigger/authorization.js +2 -2
  104. package/dist/trigger/feedback.js +18 -7
  105. package/dist/trigger/history.js +36 -0
  106. package/dist/trigger/manager.js +20 -3
  107. package/dist/trigger/parser.js +6 -3
  108. package/dist/trigger/patch.js +1 -1
  109. package/dist/trigger/scheduler.js +3 -0
  110. package/dist/trigger/system-definitions.js +43 -7
  111. package/dist/trigger/validation.js +13 -5
  112. package/dist/utils/ecweb-supervisor.js +31 -10
  113. package/dist/utils/error-utils.js +22 -4
  114. package/dist/utils/evolcore-version.js +3 -2
  115. package/dist/utils/host-info.js +52 -0
  116. package/dist/utils/npm-ops.js +2 -1
  117. package/dist/utils/package-version-info.js +1 -1
  118. package/dist/utils/upgrade-jobs.js +45 -5
  119. package/ecagent/dist/harness/agent-harness.js +4 -1
  120. package/kits/docs/INDEX.md +1 -1
  121. package/kits/docs/aun/ABILITY_CALLING.md +20 -2
  122. package/kits/docs/evolcore/INDEX.md +3 -2
  123. package/kits/docs/evolcore/agent-create.md +3 -2
  124. package/kits/docs/evolcore/agent.md +1 -1
  125. package/kits/docs/evolcore/aid.md +29 -12
  126. package/kits/docs/evolcore/config.md +9 -7
  127. package/kits/docs/evolcore/event.md +1 -0
  128. package/kits/docs/evolcore/fs.md +5 -0
  129. package/kits/docs/evolcore/memory-architecture.md +3 -4
  130. package/kits/docs/evolcore/memory-consolidation.md +28 -7
  131. package/kits/docs/evolcore/memory-tags.md +1 -1
  132. package/kits/docs/evolcore/memory.md +1 -1
  133. package/kits/docs/evolcore/menu-client.md +1 -1
  134. package/kits/docs/evolcore/menu-protocol.md +38 -0
  135. package/kits/docs/evolcore/msg.md +18 -2
  136. package/kits/docs/evolcore/session.md +14 -0
  137. package/kits/eck_manifest.json +3 -3
  138. package/kits/rules/04-relation.md +3 -2
  139. package/kits/schemas/agent-config.schema.13.json +20 -1
  140. package/kits/skills/aid-ability/SKILL.md +35 -6
  141. package/kits/templates/memory-consolidation/generalize.md +32 -4
  142. package/kits/templates/memory-consolidation/notes.md +2 -2
  143. package/kits/templates/memory-consolidation/promote.md +10 -2
  144. package/kits/templates/session-capsule/recovery.md +5 -0
  145. package/kits/templates/session-capsule/renew.md +5 -0
  146. package/kits/templates/system-fragments/baseagent.md +5 -0
  147. package/kits/templates/system-fragments/bootstrap.md +6 -6
  148. package/kits/templates/system-fragments/channel.md +1 -1
  149. package/kits/templates/system-fragments/memory.md +12 -3
  150. package/kits/templates/system-fragments/session.md +1 -1
  151. package/kits/{rules/07-memory-and-thread.md → templates/system-fragments/thread.md} +17 -80
  152. package/package.json +3 -3
  153. package/dist/stats/billing.js +0 -215
@@ -3,6 +3,7 @@ import { getContactSnapshot, resolveContactView } from '../../config/contact-boo
3
3
  import { mutateAccessPolicy, readAccessPolicySnapshot, } from '../../config/access-policy.js';
4
4
  import { expirePendingContactRequests, addContact, mutateContactWithOperation, reviewContactRequest, } from '../../config/contact-request-service.js';
5
5
  import { formatPeerKey, parsePeerKey } from '../relation/peer-identity.js';
6
+ import { isValidAid } from '../../aun/aid/validation.js';
6
7
  /**
7
8
  * Connect Menu — 联系人与关系管理协议
8
9
  *
@@ -31,7 +32,7 @@ export function connectMenuOperation(kind, args, value) {
31
32
  if (kind === 'action')
32
33
  return 'connect.write';
33
34
  const resource = String(args?.resource ?? '');
34
- if (resource === 'policyMode' || resource === 'requestLimit') {
35
+ if (isAccessUpdateResource(resource)) {
35
36
  return 'connect.access.write';
36
37
  }
37
38
  if (resource === 'admin')
@@ -100,7 +101,7 @@ async function handleOptions(self, args, context) {
100
101
  {
101
102
  option: 'access',
102
103
  label: '访问设置',
103
- description: '设置消息准入模式和准入控制消息限额',
104
+ description: '设置外部联系开关、指定 AID 名单、消息准入模式和准入控制消息限额',
104
105
  },
105
106
  ],
106
107
  });
@@ -265,6 +266,8 @@ async function handleAction(req, self, context) {
265
266
  }
266
267
  function isAccessUpdateResource(resource) {
267
268
  return resource === 'policyMode'
269
+ || resource === 'allowExternalContacts'
270
+ || resource === 'allowedAids'
268
271
  || resource === 'requestLimit';
269
272
  }
270
273
  function updateAccessResource(req, context, resource) {
@@ -281,6 +284,18 @@ function updateAccessResource(req, context, resource) {
281
284
  return fail('INVALID_ARGUMENT', 'policyMode must be open, contacts, or owners');
282
285
  }
283
286
  }
287
+ else if (resource === 'allowExternalContacts') {
288
+ if (typeof decoded !== 'boolean') {
289
+ return fail('INVALID_ARGUMENT', 'allowExternalContacts must be a JSON boolean');
290
+ }
291
+ }
292
+ else if (resource === 'allowedAids') {
293
+ if (!Array.isArray(decoded)
294
+ || decoded.some(aid => typeof aid !== 'string' || !isValidAid(aid))
295
+ || new Set(decoded).size !== decoded.length) {
296
+ return fail('INVALID_ARGUMENT', 'allowedAids must be a JSON array of unique valid AIDs');
297
+ }
298
+ }
284
299
  else {
285
300
  const requestLimit = decoded;
286
301
  if (!requestLimit || typeof requestLimit !== 'object' || Array.isArray(requestLimit)
@@ -534,6 +549,12 @@ function accessPolicyWithUpdate(current, resource, decoded) {
534
549
  if (resource === 'policyMode') {
535
550
  return { ...current, policyMode: decoded };
536
551
  }
552
+ if (resource === 'allowExternalContacts') {
553
+ return { ...current, allowExternalContacts: decoded };
554
+ }
555
+ if (resource === 'allowedAids') {
556
+ return { ...current, allowedAids: [...decoded] };
557
+ }
537
558
  const requestLimit = decoded;
538
559
  return {
539
560
  ...current,
@@ -6,6 +6,7 @@ import { authorizationDenialData, formatAuthorizationDenial } from '../auth/auth
6
6
  import { ConfigTarget, read as readConfig } from '../../config/config-manager.js';
7
7
  import { readRolesConfig } from '../../config/roles.js';
8
8
  import { normalizeMenuError } from './menu-protocol.js';
9
+ import { isAgentFullAccessOwner } from '../role/runtime-policy.js';
9
10
  import { isValidAid } from '../../aun/aid/validation.js';
10
11
  import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS } from '../session/session-idle-monitor.js';
11
12
  const DEFAULT_DIRECTORY = { getGroup: groupInfo, getMembers: groupMembers };
@@ -79,6 +80,19 @@ const ENTRIES = [
79
80
  valueSchema: { type: 'boolean' },
80
81
  control: 'toggle-with-number',
81
82
  },
83
+ {
84
+ id: 'session.fullaccess',
85
+ type: 'setting',
86
+ contexts: ['private_relation'],
87
+ name: 'session',
88
+ label: '当前 EC 会话 fullaccess',
89
+ section: 'relation_behavior',
90
+ order: 6,
91
+ query: { cmd: '/session', args: { view: 'fullaccess' }, operation: 'session.fullaccess.current', scope: 'relation' },
92
+ update: { cmd: '/session', args: { resource: 'fullaccess' }, operation: 'session.fullaccess.update', scope: 'relation' },
93
+ valueSchema: { type: 'boolean' },
94
+ control: 'toggle',
95
+ },
82
96
  relation('model.relation', 'model', '模型', 10, '/model', 'model.current', { options: { cmd: '/model', operation: 'model.list', scope: 'relation', mode: 'dynamic' }, update: { cmd: '/model', operation: 'model.use', scope: 'relation' }, control: 'select' }),
83
97
  relation('effort.relation', 'effort', '推理强度', 20, '/effort', 'model.effort.current', { options: { cmd: '/effort', operation: 'model.effort.current', scope: 'relation', mode: 'dynamic', dependsOn: ['model.relation'] }, update: { cmd: '/effort', operation: 'model.effort', scope: 'relation' }, control: 'select' }),
84
98
  relation('chatmode.relation', 'chatmode', '对话模式', 30, '/chatmode', 'chatmode.current', { options: { cmd: '/chatmode', operation: 'chatmode.current', scope: 'relation', mode: 'static', items: [{ value: 'interactive', label: '交互模式' }, { value: 'proactive', label: '主动模式' }] }, update: { cmd: '/chatmode', operation: 'chatmode.update', scope: 'relation' }, control: 'select' }),
@@ -107,6 +121,7 @@ const ENTRIES = [
107
121
  { id: 'system.paircode', type: 'action', contexts: ['process'], name: 'system', label: '获取配对码', section: 'process', order: 35, action: { cmd: '/system', action: 'paircode', operation: 'system.paircode', scope: 'process' } },
108
122
  { id: 'agent.list', type: 'list', contexts: ['process'], name: 'agent', label: 'Agent 列表', section: 'process', order: 40, options: { cmd: '/agent', args: { options: 'all' }, operation: 'agent.list', scope: 'control', mode: 'dynamic' }, control: 'list' },
109
123
  { id: 'agent.create', type: 'action', contexts: ['process'], name: 'agent', label: '创建 Agent', section: 'process', order: 50, action: { cmd: '/agent', action: 'create', operation: 'agent.create', scope: 'control' } },
124
+ { id: 'agent.initialize', type: 'action', contexts: ['process'], name: 'agent', label: '初始化 Agent', section: 'process', order: 55, action: { cmd: '/agent', action: 'initialize', operation: 'agent.initialize', scope: 'control' } },
110
125
  { id: 'agent.reload', type: 'action', contexts: ['process'], name: 'agent', label: '重载 Agent', section: 'process', order: 60, action: { cmd: '/agent', action: 'reload', operation: 'agent.reload', scope: 'control' } },
111
126
  { id: 'agent.delete', type: 'action', contexts: ['process'], name: 'agent', label: '删除 Agent', section: 'process', order: 70, action: { cmd: '/agent', action: 'delete', operation: 'agent.delete', scope: 'control' } },
112
127
  ];
@@ -290,8 +305,8 @@ export function bindMenuExecutionContextArgs(args, context) {
290
305
  if (!args && context.kind !== 'group_relation')
291
306
  return args;
292
307
  const { context: _context, ...bound } = args ?? {};
293
- const isSessionLoop = bound.resource === 'loop' || bound.view === 'loop';
294
- if (isSessionLoop)
308
+ const isSessionScoped = ['loop', 'fullaccess'].includes(String(bound.resource ?? bound.view ?? ''));
309
+ if (isSessionScoped)
295
310
  return bound;
296
311
  if (context.kind === 'private_relation' || context.kind === 'group_relation') {
297
312
  if (bound.scope !== 'role')
@@ -368,6 +383,17 @@ async function operationView(binding, context, options = {}) {
368
383
  reason: { code: 'NOT_ALLOWED', message: 'Pairing code issuance requires encrypted DaemonOwner authentication' },
369
384
  };
370
385
  }
386
+ if (binding.operation.startsWith('session.fullaccess.')) {
387
+ const allowed = context.kind === 'private_relation'
388
+ && context.subject.chatType === 'private'
389
+ && context.subject.isDaemonOwner === true
390
+ && isAgentFullAccessOwner(context.subject.selfAid ?? '', context.subject.principalId);
391
+ return {
392
+ supported: true,
393
+ allowed,
394
+ ...(allowed ? {} : { reason: { code: 'FORBIDDEN', message: 'session fullaccess requires the Agent Owner and daemon Owner identity' } }),
395
+ };
396
+ }
371
397
  if (binding.operation === 'group.rulespolicy.update' && context.subject.role !== 'owner') {
372
398
  return { supported: true, allowed: false, reason: { code: 'PERMISSION_DENIED', message: 'rulesPolicy can only be changed by an Agent owner' } };
373
399
  }
@@ -377,7 +403,7 @@ async function operationView(binding, context, options = {}) {
377
403
  function wireBinding(binding, context) {
378
404
  if (!binding || binding.supported === false)
379
405
  return undefined;
380
- if (binding.operation.startsWith('session.loop.'))
406
+ if (binding.operation.startsWith('session.loop.') || binding.operation.startsWith('session.fullaccess.'))
381
407
  return {
382
408
  args: context.kind === 'group_relation'
383
409
  ? { ...(binding.args ?? {}), context: { kind: context.kind, ...(context.groupId ? { groupId: context.groupId } : {}) } }
@@ -406,10 +432,10 @@ export async function getMenuCatalog(input) {
406
432
  operations[key] = view;
407
433
  }
408
434
  entries.push({ id: entry.id, type: entry.type, name: entry.name, label: entry.label, section: entry.section, order: entry.order, target: { scope: context.kind === 'agent' ? 'agent' : context.kind === 'process' ? 'process' : 'relation', ...(context.self ? { self: context.self } : {}), ...(context.peerKey ? { peerKey: context.peerKey } : {}) }, valueSchema: entry.valueSchema ?? { type: 'object' }, operations, wire: { name: entry.name, operations: { ...(wireBinding(entry.query, context) ? { query: wireBinding(entry.query, context) } : {}), ...(wireBinding(entry.options, context) ? { options: wireBinding(entry.options, context) } : {}), ...(wireBinding(entry.update, context) ? { update: wireBinding(entry.update, context) } : {}), ...(wireBinding(entry.action, context) ? { action: wireBinding(entry.action, context) } : {}) } }, ui: { control: entry.control ?? 'action' } });
409
- if (entry.id === 'session.loop') {
435
+ if (entry.id === 'session.loop' || entry.id === 'session.fullaccess') {
410
436
  const loopEntry = entries[entries.length - 1];
411
- let target = { level: 'relation-main' };
412
- if (input.resolveLoopTarget) {
437
+ let target = { level: 'relation-main', scope: 'agent' };
438
+ if ((entry.id === 'session.loop' || entry.id === 'session.fullaccess') && input.resolveLoopTarget) {
413
439
  try {
414
440
  target = await input.resolveLoopTarget(context);
415
441
  }
@@ -420,12 +446,23 @@ export async function getMenuCatalog(input) {
420
446
  }
421
447
  }
422
448
  }
423
- loopEntry.target = target;
424
- loopEntry.label = target.level === 'topic-session' ? '当前话题闲置触发' : '关系主会话闲置触发';
425
- loopEntry.ui = {
426
- control: entry.control,
427
- idleSeconds: { type: 'integer', minimum: MIN_SESSION_LOOP_SECONDS, maximum: MAX_SESSION_LOOP_SECONDS, default: DEFAULT_SESSION_LOOP_SECONDS, unit: 'seconds' },
428
- };
449
+ if (entry.id === 'session.loop') {
450
+ loopEntry.target = target;
451
+ loopEntry.label = target.level === 'topic-session' ? '当前话题闲置触发' : '关系主会话闲置触发';
452
+ loopEntry.ui = {
453
+ control: entry.control,
454
+ idleSeconds: { type: 'integer', minimum: MIN_SESSION_LOOP_SECONDS, maximum: MAX_SESSION_LOOP_SECONDS, default: DEFAULT_SESSION_LOOP_SECONDS, unit: 'seconds' },
455
+ };
456
+ }
457
+ else {
458
+ loopEntry.target = {
459
+ level: target.level,
460
+ sessionId: target.sessionId,
461
+ scope: target.level === 'topic-session' ? 'session' : 'agent',
462
+ };
463
+ loopEntry.label = '当前 EC 会话 fullaccess';
464
+ loopEntry.ui = { control: entry.control };
465
+ }
429
466
  }
430
467
  }
431
468
  const policyRevision = hash({ role: context.subject.role, self: context.subject.selfAid, peerKey: context.subject.peerKey, groupMembershipRole: context.groupMembershipRole, baselineRole: context.baselineRole, paircodeAllowed, roles: readRolesConfig(context.subject.selfAid) });
@@ -26,6 +26,8 @@ import { loadDefaults, loadDaemonConfig } from '../../config-store.js';
26
26
  import { WEB_PACKAGE_NAME, RESTART_REQUEST_ID_ENV, RUNTIME_HOME_ENV, SESSION_ID_ENV } from '../../product.js';
27
27
  import { read as cfgRead, resolveEffective, resolveEffectiveFieldWithSource, routeFieldPath, write as cfgWrite, ConfigTarget, } from '../../config/config-manager.js';
28
28
  import { execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
29
+ import { readInitialization } from '../../cli/agent-create.js';
30
+ import { isValidAid } from '../../aun/aid/validation.js';
29
31
  import { gatewayList, gatewayUpdate, gatewayDelete, gatewayTest, gatewayModels, gatewaySetPrice, gatewaySyncEnv } from '../../config/gateway-config.js';
30
32
  import { displaySessionTitle } from '../session/session-title.js';
31
33
  import { buildTranscriptTurns } from '../session/session-transcript.js';
@@ -42,7 +44,7 @@ import { isUnsupportedBaseagentConfigField } from '../../config/config-field-pol
42
44
  import { splitConfigBatchGetArgv } from '../../cli/cli-argv.js';
43
45
  import { chatmodeFieldForPeer, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
44
46
  import { PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
45
- import { resolveRuntimePermissionMode, resolveRuntimeStringField, validateRuntimeStringFieldOverride, } from '../role/runtime-policy.js';
47
+ import { isAgentFullAccessOwner, resolveRuntimePermissionMode, resolveRuntimeStringField, sessionFullAccessStatus, validateRuntimeStringFieldOverride, } from '../role/runtime-policy.js';
46
48
  import { isManagementRole } from '../../config/builtin-roles.js';
47
49
  import { SYSTEM_CONTROL_CHANNEL } from '../system-channels.js';
48
50
  import { logger } from '../../utils/logger.js';
@@ -2149,6 +2151,21 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
2149
2151
  return menuResultFailure(error);
2150
2152
  }
2151
2153
  }
2154
+ if (cmdBase === '/session' && args?.view === 'fullaccess') {
2155
+ if (Object.keys(args).some(key => key !== 'view' && key !== 'context')) {
2156
+ return { error: 'session.fullaccess query only accepts args.view', code: 'INVALID_ARGUMENT' };
2157
+ }
2158
+ if (!session || !subject.selfAid)
2159
+ return { error: '当前没有可绑定的 EC 会话', code: 'NO_ACTIVE_SESSION' };
2160
+ if (session.chatType !== 'private')
2161
+ return { error: '/fa 仅支持私聊中的当前 EC 会话', code: 'NOT_SUPPORTED' };
2162
+ const principalId = subject.principalId;
2163
+ if (!principalId || !subject.isDaemonOwner || !isAgentFullAccessOwner(subject.selfAid, principalId)) {
2164
+ return { error: '/fa 需要同一身份同时具备 Agent Owner 和 daemon Owner 权限', code: 'FORBIDDEN' };
2165
+ }
2166
+ const status = sessionFullAccessStatus(session, principalId);
2167
+ return { data: { ...status, sessionId: session.id, scope: isTopicSession(session) ? 'session' : 'agent' } };
2168
+ }
2152
2169
  const storageRequest = { type: 'menu.query', cmd, args };
2153
2170
  if (isAgentStorageMenuRequest(storageRequest)) {
2154
2171
  try {
@@ -2948,6 +2965,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
2948
2965
  if (!cmdBase)
2949
2966
  return { error: '缺少命令', code: 'MISSING_CMD' };
2950
2967
  const isLoopUpdate = cmdBase === '/session' && args?.resource === 'loop';
2968
+ const isFullAccessUpdate = cmdBase === '/session' && args?.resource === 'fullaccess';
2951
2969
  if (isLoopUpdate) {
2952
2970
  if (typeof value !== 'boolean' || Object.keys(args ?? {}).some(key => key !== 'resource' && key !== 'idleSeconds' && key !== 'context')) {
2953
2971
  return { error: 'session.loop requires a boolean value and only accepts resource / idleSeconds', code: 'INVALID_ARGUMENT' };
@@ -2959,9 +2977,13 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
2959
2977
  return { error: `idleSeconds 必须是 ${MIN_SESSION_LOOP_SECONDS}-${MAX_SESSION_LOOP_SECONDS} 的整数`, code: 'INVALID_ARGUMENT' };
2960
2978
  }
2961
2979
  }
2962
- else if (typeof value !== 'string') {
2980
+ else if (!isFullAccessUpdate && typeof value !== 'string') {
2963
2981
  return { error: 'value 必须是字符串', code: 'INVALID_ARGUMENT' };
2964
2982
  }
2983
+ if (isFullAccessUpdate && (typeof value !== 'boolean'
2984
+ || Object.keys(args ?? {}).some(key => key !== 'resource' && key !== 'context'))) {
2985
+ return { error: 'session.fullaccess requires a boolean value and only accepts resource', code: 'INVALID_ARGUMENT' };
2986
+ }
2965
2987
  if (cmdBase === '/perm') {
2966
2988
  return { error: 'permissionMode 只能通过角色策略编辑器修改', code: 'ROLE_POLICY_MANAGED' };
2967
2989
  }
@@ -3020,6 +3042,53 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
3020
3042
  return menuResultFailure(error);
3021
3043
  }
3022
3044
  }
3045
+ if (isFullAccessUpdate) {
3046
+ if (!session || !subject.selfAid)
3047
+ return { error: '当前没有可绑定的 EC 会话', code: 'NO_ACTIVE_SESSION' };
3048
+ const route = { channel, channelId, selfAid: subject.selfAid, threadId: transportReplyContext?.threadId };
3049
+ let target;
3050
+ try {
3051
+ target = await resolveCurrentSessionLoopTarget(this.sessionManager, route);
3052
+ if (target.session.id !== session.id)
3053
+ return { error: '当前会话已发生变化,请重新查询', code: 'CONFLICT' };
3054
+ target = await refreshSessionLoopTarget(this.sessionManager, route, target);
3055
+ session = target.session;
3056
+ }
3057
+ catch (error) {
3058
+ return menuResultFailure(error);
3059
+ }
3060
+ const principalId = subject.principalId;
3061
+ if (session.chatType !== 'private' || !principalId || !subject.isDaemonOwner
3062
+ || !isAgentFullAccessOwner(subject.selfAid, principalId)) {
3063
+ return { error: '/fa 需要私聊中同一身份同时具备 Agent Owner 和 daemon Owner 权限', code: 'FORBIDDEN' };
3064
+ }
3065
+ try {
3066
+ if (isTopicSession(session)) {
3067
+ this.sessionManager.updateSessionFullAccess(session.id, { enabled: value, authorizedBy: principalId });
3068
+ }
3069
+ else {
3070
+ const config = cfgRead(ConfigTarget.Agent, { self: subject.selfAid }, { cache: false });
3071
+ if (!config)
3072
+ return { error: '找不到当前 Agent 配置', code: 'NOT_FOUND' };
3073
+ config.fullaccess = { enabled: value };
3074
+ cfgWrite(ConfigTarget.Agent, config, { self: subject.selfAid });
3075
+ }
3076
+ auditFullAccessEvent({
3077
+ event: value ? 'fullaccess.session-policy.configured' : 'fullaccess.session-policy.deescalated',
3078
+ source: 'session-policy',
3079
+ actorId: principalId,
3080
+ processRole: 'daemon-owner',
3081
+ agentAid: subject.selfAid,
3082
+ sessionId: session.id,
3083
+ authorizedBy: principalId,
3084
+ reason: isTopicSession(session) ? 'topic session fullaccess updated via Menu' : 'Agent main-session fullaccess updated via Menu',
3085
+ });
3086
+ return { data: { enabled: value, sessionId: session.id, scope: isTopicSession(session) ? 'session' : 'agent' } };
3087
+ }
3088
+ catch (error) {
3089
+ return menuResultFailure(error);
3090
+ }
3091
+ }
3023
3092
  const arg = value.trim();
3024
3093
  if (!arg)
3025
3094
  return { error: '缺少 value 参数', code: 'MISSING_VALUE' };
@@ -3162,113 +3231,20 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
3162
3231
  return { error: `无效 baseagent: ${arg},可选: ${valid.join(' / ')}`, code: 'INVALID_VALUE' };
3163
3232
  }
3164
3233
  const previousBaseagent = evolagent.baseagent;
3165
- const sessionTopicId = sessionTopicThreadId(session);
3166
- if (session && sessionTopicId) {
3167
- if (transportReplyContext?.threadId !== sessionTopicId) {
3168
- return { error: '话题路由上下文不匹配,拒绝切换', code: 'THREAD_CONTEXT_MISMATCH' };
3169
- }
3170
- if (typeof this.messageQueue.withSessionBarrier !== 'function') {
3171
- return { error: '当前运行环境不支持安全话题切换', code: 'NOT_SUPPORTED' };
3172
- }
3173
- const sessionKey = this.getQueueKey(session, channel, channelId);
3174
- const currentAgent = this.getAgent(channel, session.baseagent);
3175
- const outcome = await this.messageQueue.withSessionBarrier(sessionKey, async (snapshot) => {
3176
- const latest = await this.sessionManager.getSessionById?.(session.id);
3177
- if (!latest || sessionTopicThreadId(latest) !== sessionTopicId) {
3178
- return { error: '话题会话不存在或归属已变化', code: 'NOT_FOUND' };
3179
- }
3180
- const busy = !!latest.processingState
3181
- || !!latest.metadata?.turnState?.active
3182
- || snapshot.active
3183
- || snapshot.queued > 0
3184
- || snapshot.dispatching
3185
- || this.messageQueue.isProcessing?.(sessionKey)
3186
- || (this.messageQueue.getQueueLength?.(sessionKey) ?? 0) > 0
3187
- || currentAgent.hasActiveStream(sessionKey);
3188
- if (busy) {
3189
- return { error: '当前话题会话忙碌,无法切换 baseagent', code: 'BUSY' };
3190
- }
3191
- try {
3192
- evolagent.setActiveBaseagent(arg);
3193
- await this.sessionManager.rotateTopicBackend({
3194
- sessionId: latest.id,
3195
- expectedThreadId: sessionTopicId,
3196
- baseagent: arg,
3197
- });
3198
- return { ok: true };
3199
- }
3200
- catch (error) {
3201
- try {
3202
- evolagent.setActiveBaseagent(previousBaseagent);
3203
- }
3204
- catch { }
3205
- return { error: error instanceof Error ? error.message : String(error), code: 'EXEC_FAILED' };
3206
- }
3207
- });
3208
- if ('error' in outcome)
3209
- return outcome;
3210
- this.eventBus.publish({
3211
- type: 'agent:baseagent-changed',
3212
- aid: evolagent.aid,
3213
- baseagent: arg,
3214
- previousBaseagent,
3215
- scope: 'agent',
3216
- timestamp: Date.now(),
3217
- });
3218
- return { data: {
3219
- baseagent: arg,
3220
- previousBaseagent,
3221
- baseagentChanged: previousBaseagent !== arg,
3222
- scope: 'agent',
3223
- sessionId: session.id,
3224
- threadId: sessionTopicId,
3225
- sessionIdChanged: false,
3226
- notice: '已切换 Baseagent: ' + previousBaseagent + ' → ' + arg + ',话题会话 ID 保持不变',
3227
- } };
3228
- }
3229
3234
  try {
3230
3235
  evolagent.setActiveBaseagent(arg);
3231
3236
  }
3232
3237
  catch (error) {
3233
3238
  return { error: error instanceof Error ? error.message : String(error), code: 'INVALID_VALUE' };
3234
3239
  }
3235
- try {
3236
- const newSession = await this.sessionManager.createNewSession(channel, channelId, evolagent.projectPath, undefined, arg, session?.metadata, { previousBaseagent, baseagentChanged: previousBaseagent !== arg });
3237
- if (session) {
3238
- try {
3239
- const previousAgent = this.getAgent(channel, session.baseagent);
3240
- await previousAgent.clearSession(session.id, session.agentSessionId || '', session.projectPath);
3241
- await previousAgent.closeSession(session.id);
3242
- }
3243
- catch (error) {
3244
- // The new Evolcore session is already active; backend cleanup is best effort.
3245
- logger.warn(`[Menu] baseagent switch cleanup failed: session=${session.id}: ${error instanceof Error ? error.message : String(error)}`);
3246
- }
3247
- }
3248
- this.eventBus.publish({
3249
- type: 'agent:baseagent-changed',
3250
- aid: evolagent.aid,
3251
- baseagent: arg,
3252
- previousBaseagent,
3253
- scope: 'agent',
3254
- timestamp: Date.now(),
3255
- });
3256
- return { data: {
3257
- baseagent: arg,
3258
- previousBaseagent,
3259
- baseagentChanged: previousBaseagent !== arg,
3260
- scope: 'agent',
3261
- sessionId: newSession.id,
3262
- notice: `已切换 Baseagent: ${previousBaseagent} → ${arg},已创建新的主会话`,
3263
- } };
3264
- }
3265
- catch (error) {
3266
- try {
3267
- evolagent.setActiveBaseagent(previousBaseagent);
3268
- }
3269
- catch { }
3270
- return { error: `创建新会话失败:${error instanceof Error ? error.message : String(error)}`, code: 'EXEC_FAILED' };
3271
- }
3240
+ this.eventBus.publish({ type: 'agent:baseagent-changed', aid: evolagent.aid,
3241
+ baseagent: arg, previousBaseagent, scope: 'agent', timestamp: Date.now() });
3242
+ return { data: {
3243
+ baseagent: arg, previousBaseagent, baseagentChanged: previousBaseagent !== arg, scope: 'agent',
3244
+ sessionId: session?.id, sessionIdChanged: false,
3245
+ notice: `新会话默认 Baseagent: ${previousBaseagent} → ${arg}`
3246
+ + (session ? `,当前会话继续使用 ${session.baseagent}` : ''),
3247
+ } };
3272
3248
  }
3273
3249
  if (cmdBase === '/model') {
3274
3250
  const target = resolveMenuModelTarget.call(this, {
@@ -3700,6 +3676,34 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
3700
3676
  if (action === 'create') {
3701
3677
  a.project = resolveProjectPath(a.project, a.aid ?? '', loadDefaults());
3702
3678
  }
3679
+ else if (action === 'initialize' && a.resume !== true) {
3680
+ const suppliedPlan = a.plan && typeof a.plan === 'object' && !Array.isArray(a.plan) ? a.plan : undefined;
3681
+ const aid = suppliedPlan?.aid ?? a.aid ?? '';
3682
+ if (typeof aid !== 'string' || !isValidAid(aid))
3683
+ return { error: '无效 Agent AID', code: 'INVALID_ARGS' };
3684
+ if ([suppliedPlan?.project, a.project].some(project => project !== undefined && typeof project !== 'string')) {
3685
+ return { error: 'project 必须是字符串', code: 'INVALID_ARGS' };
3686
+ }
3687
+ const explicitProject = typeof suppliedPlan?.project === 'string' && suppliedPlan.project.trim()
3688
+ ? suppliedPlan.project
3689
+ : typeof a.project === 'string' && a.project.trim()
3690
+ ? a.project
3691
+ : undefined;
3692
+ let previousProject;
3693
+ if (!explicitProject) {
3694
+ try {
3695
+ previousProject = readInitialization(aid)?.plan.project;
3696
+ }
3697
+ catch {
3698
+ return { error: '初始化状态无效', code: 'INITIALIZE_STATE_INVALID' };
3699
+ }
3700
+ }
3701
+ const project = previousProject ?? resolveProjectPath(explicitProject, aid, loadDefaults());
3702
+ if (suppliedPlan)
3703
+ a.plan = { ...suppliedPlan, project };
3704
+ else
3705
+ a.project = project;
3706
+ }
3703
3707
  // queue-clear:清空指定 agent 的待处理消息(不影响处理中),直接走 messageQueue。
3704
3708
  if (action === 'queue-clear') {
3705
3709
  if (!a.aid)
@@ -4325,6 +4329,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
4325
4329
  sessionId: sessionKey,
4326
4330
  reason: 'stop',
4327
4331
  agentName: this.agentRegistry?.resolveByChannel(channel)?.name ?? '<unknown>',
4332
+ agentAid: session.selfAID,
4328
4333
  });
4329
4334
  await this.processor.interruptSession(sessionKey, 'stop');
4330
4335
  return { data: { action: 'stop', success: true } };
@@ -5156,7 +5161,7 @@ async function execMenuForSystemControl(payload, context) {
5156
5161
  }
5157
5162
  /** ECWeb 专用入口:只信任 IPC 信封中的服务端认证上下文,不信任 Menu payload 自报身份。 */
5158
5163
  export async function execMenuForEcweb(payload, trusted) {
5159
- await refreshOwnershipForAuthorization(undefined, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS });
5164
+ await refreshOwnershipForAuthorization(undefined, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
5160
5165
  const id = payload?.id ?? '';
5161
5166
  const name = payload?.name;
5162
5167
  const validationError = validateMenuRequest(payload ?? {});
@@ -5200,7 +5205,7 @@ export async function execMenuForEcweb(payload, trusted) {
5200
5205
  * process authorization path. The authenticated envelope peerId remains the
5201
5206
  * requester; token mode maps to a configured owner as its management actor. */
5202
5207
  export async function execMenuForControl(payload, peerId, auth = {}) {
5203
- await refreshOwnershipForAuthorization(undefined, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS });
5208
+ await refreshOwnershipForAuthorization(undefined, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
5204
5209
  const id = payload?.id ?? '';
5205
5210
  const name = payload?.name;
5206
5211
  const validationError = validateMenuRequest(payload ?? {});
@@ -31,7 +31,8 @@ export function parseMenuEvent(value) {
31
31
  export function buildMenuClientProtectedHeaders(input) {
32
32
  const clientName = input.clientName ?? 'evol';
33
33
  if (clientName === 'ec-menu-client') {
34
- const clientVersion = input.clientVersion?.trim();
34
+ // Menu compatibility uses the base version; installed/logged versions retain the test suffix.
35
+ const clientVersion = input.clientVersion?.trim().replace(/-test\.(0|[1-9]\d*)$/, '');
35
36
  if (!parseStableSemver(clientVersion)) {
36
37
  throw Object.assign(new Error('ec-menu-client requires a stable X.Y.Z client version'), { code: 'INVALID_CLIENT' });
37
38
  }
@@ -367,14 +368,33 @@ export function validateMenuRequest(request) {
367
368
  return { code: 'INVALID_ARGUMENT', message: 'idleSeconds is not allowed when session.loop is disabled' };
368
369
  }
369
370
  }
370
- else if (type === 'menu.update' && (typeof request.value !== 'string' || request.value.length === 0)) {
371
+ else if (type === 'menu.update'
372
+ && !((request.name === 'session' || request.cmd === '/session')
373
+ && request.args?.resource === 'fullaccess')
374
+ && (typeof request.value !== 'string' || request.value.length === 0)) {
371
375
  return { code: 'INVALID_ARGUMENT', message: 'Menu request value is required' };
372
376
  }
377
+ const isSessionFullAccessUpdate = type === 'menu.update'
378
+ && (request.name === 'session' || request.cmd === '/session')
379
+ && request.args?.resource === 'fullaccess';
380
+ if (isSessionFullAccessUpdate) {
381
+ if (typeof request.value !== 'boolean')
382
+ return { code: 'INVALID_ARGUMENT', message: 'session.fullaccess value must be a boolean' };
383
+ const args = request.args;
384
+ const unknown = Object.keys(args ?? {}).find(key => !['resource', 'context'].includes(key));
385
+ if (unknown)
386
+ return { code: 'INVALID_ARGUMENT', message: 'session.fullaccess update does not accept args.' + unknown };
387
+ }
373
388
  if (type === 'menu.query' && (request.name === 'session' || request.cmd === '/session')
374
389
  && request.args?.view === 'loop'
375
390
  && Object.keys(request.args).some(key => key !== 'view' && key !== 'context')) {
376
391
  return { code: 'INVALID_ARGUMENT', message: 'session.loop query only accepts args.view' };
377
392
  }
393
+ if (type === 'menu.query' && (request.name === 'session' || request.cmd === '/session')
394
+ && request.args?.view === 'fullaccess'
395
+ && Object.keys(request.args).some(key => key !== 'view' && key !== 'context')) {
396
+ return { code: 'INVALID_ARGUMENT', message: 'session.fullaccess query only accepts args.view' };
397
+ }
378
398
  if (type === 'menu.action' && (typeof request.action !== 'string' || request.action.trim().length === 0)) {
379
399
  return { code: 'INVALID_ARGUMENT', message: 'Menu request action is required' };
380
400
  }
@@ -479,7 +499,7 @@ const INVALID_ARGUMENT_CODES = new Set([
479
499
  'ARGUMENT_MISMATCH', 'INVALID_ARGS', 'INVALID_DELEGATION',
480
500
  'INVALID_FIELD', 'INVALID_REVISION', 'INVALID_SCOPE', 'INVALID_TYPE', 'INVALID_VALUE', 'MISSING_AID',
481
501
  'MISSING_ARGV', 'MISSING_BASEAGENT', 'MISSING_CMD', 'MISSING_PEER', 'MISSING_VALUE',
482
- 'REVISION_REQUIRED', 'ROLE_VIOLATION',
502
+ 'REVISION_REQUIRED', 'ROLE_VIOLATION', 'INITIALIZE_FIELDS_REQUIRED',
483
503
  ]);
484
504
  const STABLE_CODES = new Set([
485
505
  'ROLE_ACCESS_DENIED', 'PERMISSION_DENIED', 'UNAUTHORIZED', 'FORBIDDEN',
@@ -496,6 +516,12 @@ const STABLE_CODES = new Set([
496
516
  'LOOP_TRIGGER_NOT_FOUND', 'LOOP_TRIGGER_DISABLED', 'LOOP_TRIGGER_INVALID',
497
517
  'ROOT_NOT_FOUND', 'ROOT_FORBIDDEN', 'ROOT_EXPIRED', 'ROOT_SCOPE_MISMATCH', 'ROOT_PEER_MISMATCH',
498
518
  'INVALID_ROOT_ID', 'MISSING_ROOT_ID', 'INVALID_ROOT_PATH', 'NOT_A_DIRECTORY', 'FILE_TOO_LARGE',
519
+ // Agent initialization uses these codes to distinguish a retryable failure,
520
+ // an actor mismatch, and a plan/state conflict at the App boundary.
521
+ 'INITIALIZE_PLAN_CONFLICT', 'INITIALIZE_OWNER_MISMATCH', 'INITIALIZE_CANCELLED',
522
+ 'INITIALIZE_STATE_INVALID', 'INITIALIZE_TARGET_CHANGED', 'INITIALIZE_TARGET_EXISTS',
523
+ 'INITIALIZE_AGENTMD_VERIFY_FAILED', 'INITIALIZE_OWNER_CONFLICT', 'INITIALIZE_AVATAR_FAILED',
524
+ 'INITIALIZE_FAILED', 'MODEL_UNAVAILABLE',
499
525
  ]);
500
526
  export function normalizeMenuError(error) {
501
527
  const source = error && typeof error === 'object' ? error : {};
@@ -18,7 +18,7 @@ import { loadSchema } from '../../config/schema-registry.js';
18
18
  import { rolePermissionFields, rolePermissionFieldOptions, rolePermissionFieldPatterns, validateRoleConfig, } from '../../config/role-schema.js';
19
19
  import { groupInfo, groupList, groupDirectoryErrorCode } from '../../aun/group/index.js';
20
20
  import { aidLookup, isValidAid } from '../../aun/aid/identity.js';
21
- import { isExplicitGroupId } from '../../aun/group/index.js';
21
+ import { isExplicitGroupId, isLegacyNamedGroupIdHint } from '../../aun/group/index.js';
22
22
  import { readJsonFile, readLastJsonlLine, scanChatDirs, scanMetaFiles } from '../session/session-fs-store.js';
23
23
  import { constrainResolvedModelForRole } from '../model/model-permission.js';
24
24
  import { resolveRuntimePermissionMode, resolveRuntimeStringField } from '../role/runtime-policy.js';
@@ -992,15 +992,16 @@ function privateHistoryTargets(self) {
992
992
  }).sort((a, b) => a.peerKey.localeCompare(b.peerKey));
993
993
  }
994
994
  function chatIsGroup(chat) {
995
- if (isExplicitGroupId(chat.channelId))
996
- return true;
997
995
  const active = readJsonFile(path.join(chat.dirPath, 'active.json'));
998
996
  if (active?.chatType === 'group' || active?.metadata?.groupId)
999
997
  return true;
1000
- return scanMetaFiles(chat.dirPath).some(metaFile => {
998
+ if (active?.chatType === 'private')
999
+ return false;
1000
+ const historicalGroup = scanMetaFiles(chat.dirPath).some(metaFile => {
1001
1001
  const session = readLastJsonlLine(path.join(chat.dirPath, metaFile));
1002
1002
  return session?.chatType === 'group' || !!session?.metadata?.groupId;
1003
1003
  });
1004
+ return historicalGroup || isLegacyNamedGroupIdHint(chat.channelId);
1004
1005
  }
1005
1006
  function assignmentResponse(self, target, config, changed, relationRevision) {
1006
1007
  return {
@@ -1021,7 +1022,7 @@ function normalizeTarget(value, self) {
1021
1022
  const peerAid = stringArg(value.peerAid);
1022
1023
  if (!peerAid)
1023
1024
  throw invalidTarget(self, 'target.peerAid');
1024
- if (!isValidAid(peerAid) || isExplicitGroupId(peerAid))
1025
+ if (!isValidAid(peerAid))
1025
1026
  throw invalidTargetValue(self, 'target.peerAid');
1026
1027
  return { kind, peerAid, peerKey: formatPeerKey('aun', peerAid) };
1027
1028
  }
@@ -1362,7 +1363,7 @@ function readRelation(peerKey, self) {
1362
1363
  function relationTargetKind(config, channelId, known = { groups: new Set(), privates: new Set() }) {
1363
1364
  if (config.targetKind)
1364
1365
  return config.targetKind;
1365
- if (known.groups.has(channelId) || isExplicitGroupId(channelId))
1366
+ if (known.groups.has(channelId) || isLegacyNamedGroupIdHint(channelId))
1366
1367
  return 'group';
1367
1368
  if (known.privates.has(channelId))
1368
1369
  return 'private';