evolcore 0.0.43-test.0 → 0.0.43-test.2

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 (172) hide show
  1. package/CHANGELOG.md +31 -2
  2. package/README.md +22 -0
  3. package/dist/agents/claude-runner.js +26 -2
  4. package/dist/agents/codex/app-server-client.js +12 -0
  5. package/dist/agents/codex-runner.js +49 -8
  6. package/dist/agents/ecagent-runner.js +26 -9
  7. package/dist/agents/gemini-runner.js +15 -12
  8. package/dist/agents/tool-time-context.js +55 -0
  9. package/dist/aun/aid/client.js +1 -1
  10. package/dist/aun/menu/client.js +1 -1
  11. package/dist/aun/model-headers.js +17 -0
  12. package/dist/aun/msg/p2p.js +3 -0
  13. package/dist/channels/aun.js +484 -43
  14. package/dist/channels/builtin-plugins.js +16 -11
  15. package/dist/channels/dingtalk.js +83 -31
  16. package/dist/channels/feishu.js +29 -13
  17. package/dist/channels/qqbot.js +32 -11
  18. package/dist/channels/wechat.js +13 -3
  19. package/dist/channels/wecom.js +67 -27
  20. package/dist/cli/agent-command.js +3 -86
  21. package/dist/cli/agent-create.js +22 -6
  22. package/dist/cli/agent.js +1 -79
  23. package/dist/cli/aun-commands.js +1 -0
  24. package/dist/cli/config.js +1 -1
  25. package/dist/cli/daemon-commands.js +47 -2
  26. package/dist/cli/data-command.js +9 -1
  27. package/dist/cli/debug-mode.js +1 -1
  28. package/dist/cli/diag.js +1 -1
  29. package/dist/cli/directory.js +77 -64
  30. package/dist/cli/getmeta-command.js +1 -1
  31. package/dist/cli/index.js +79 -22
  32. package/dist/cli/init.js +1 -23
  33. package/dist/cli/link-rules.js +1 -1
  34. package/dist/cli/managed-command-guard.js +0 -1
  35. package/dist/cli/pa-workspace-command.js +36 -2
  36. package/dist/cli/peer.js +1 -1
  37. package/dist/cli/restart-monitor.js +17 -3
  38. package/dist/cli/role.js +1 -1
  39. package/dist/cli/session-command.js +1 -1
  40. package/dist/cli/stats.js +2 -2
  41. package/dist/cli/thread-command.js +1 -1
  42. package/dist/cli/watch-msg.js +1 -1
  43. package/dist/config/access-policy.js +1 -0
  44. package/dist/config/config-field-policy.js +2 -2
  45. package/dist/config/config-manager.js +7 -0
  46. package/dist/config/role-schema.js +4 -3
  47. package/dist/config/role-service.js +3 -3
  48. package/dist/config-store.js +75 -4
  49. package/dist/core/agent-ipc-registration.js +16 -59
  50. package/dist/core/agent-runtime.js +2 -1
  51. package/dist/core/auth/authorization-audit.js +52 -14
  52. package/dist/core/auth/operation-authorizer.js +0 -11
  53. package/dist/core/auth/operation-catalog.js +0 -18
  54. package/dist/core/channel-loader.js +152 -16
  55. package/dist/core/command/agent-control.js +2 -1
  56. package/dist/core/command/cli-intent-parser.js +0 -8
  57. package/dist/core/command/command-handler.js +17 -46
  58. package/dist/core/command/connect-menu.js +7 -3
  59. package/dist/core/command/menu-catalog.js +3 -2
  60. package/dist/core/command/menu-handler.js +51 -8
  61. package/dist/core/command/menu-protocol.js +20 -0
  62. package/dist/core/command/slash-handler.js +101 -40
  63. package/dist/core/daemon-file-cache.js +3 -3
  64. package/dist/core/evolagent-registry.js +5 -4
  65. package/dist/core/evolagent.js +5 -8
  66. package/dist/core/handoff/argv-parse.js +115 -0
  67. package/dist/core/handoff/ipc-registration.js +1 -1
  68. package/dist/core/ipc-registration.js +19 -2
  69. package/dist/core/memory/consolidation.js +8 -1
  70. package/dist/core/memory/relation-sweep.js +20 -8
  71. package/dist/core/message/aun-ipc-sender.js +28 -1
  72. package/dist/core/message/contact-admission.js +548 -0
  73. package/dist/core/message/im-renderer.js +69 -10
  74. package/dist/core/message/message-admission.js +28 -3
  75. package/dist/core/message/message-bridge.js +46 -5
  76. package/dist/core/message/message-utils.js +0 -5
  77. package/dist/core/message/peer-mode.js +44 -10
  78. package/dist/core/message/response-engine.js +268 -69
  79. package/dist/core/message/retry-scheduler.js +4 -0
  80. package/dist/core/permission/ec-command-parser.js +1 -28
  81. package/dist/core/permission/readonly-shell-query.js +34 -8
  82. package/dist/core/permission/tool-policy.js +50 -5
  83. package/dist/core/role/runtime-policy.js +14 -2
  84. package/dist/core/session/session-manager.js +9 -1
  85. package/dist/core/soul.js +66 -0
  86. package/dist/core/system-session/memory.js +2 -2
  87. package/dist/directory/contact-admission-paths.js +9 -0
  88. package/dist/directory/owner-directory-admission.js +128 -29
  89. package/dist/directory/owner-directory-cache.js +364 -50
  90. package/dist/directory/owner-directory-identity.js +60 -0
  91. package/dist/directory/owner-directory-markdown.js +120 -47
  92. package/dist/directory/owner-directory-policy.js +108 -0
  93. package/dist/directory/owner-directory-query-operation.js +219 -32
  94. package/dist/directory/owner-directory-remarks.js +29 -2
  95. package/dist/directory/owner-directory-search.js +50 -18
  96. package/dist/directory/owner-directory-store.js +150 -30
  97. package/dist/eck/kit-renderer.js +12 -5
  98. package/dist/eck/manifest-engine.js +55 -6
  99. package/dist/eck/message-renderer.js +5 -2
  100. package/dist/eck/paactive-context.js +45 -0
  101. package/dist/ecweb/basic-settings-service.js +2 -2
  102. package/dist/ecweb/message-context-service.js +24 -16
  103. package/dist/index.js +9 -5
  104. package/dist/ipc.js +1 -1
  105. package/dist/paths.js +26 -0
  106. package/dist/response-system/config-resolver.js +1 -1
  107. package/dist/response-system/engines/v1/index.js +4 -1
  108. package/dist/response-system/engines/v1/paactive-flow.js +18 -0
  109. package/dist/response-system/modes/single-session/index.js +7 -2
  110. package/dist/trigger/scheduler.js +3 -5
  111. package/dist/trigger/validation.js +4 -0
  112. package/dist/utils/error-utils.js +5 -2
  113. package/dist/utils/logger.js +13 -4
  114. package/dist/utils/npm-ops.js +2 -2
  115. package/dist/utils/windows-autostart.js +1 -1
  116. package/ecagent/dist/agent-loop.js +43 -1
  117. package/kits/docs/INDEX.md +1 -0
  118. package/kits/docs/context-assembly.md +21 -6
  119. package/kits/docs/eck_templates/INDEX.template.md +1 -2
  120. package/kits/docs/evolcore/INDEX.md +1 -1
  121. package/kits/docs/evolcore/agent-create.md +5 -5
  122. package/kits/docs/evolcore/agent.md +4 -9
  123. package/kits/docs/evolcore/directory.md +137 -0
  124. package/kits/docs/evolcore/menu-protocol.md +55 -0
  125. package/kits/docs/evolcore/response.md +7 -1
  126. package/kits/docs/evolcore/tool-authorization.md +1 -1
  127. package/kits/docs/evolcore/trigger.md +4 -0
  128. package/kits/docs/prompt-loading-architecture.md +6 -2
  129. package/kits/eck_manifest.auxiliary.json +1 -0
  130. package/kits/eck_manifest.json +57 -4
  131. package/kits/eck_manifest.memory.json +67 -3
  132. package/kits/eck_manifest.paactive.json +528 -0
  133. package/kits/eck_message_manifest.paactive.json +233 -0
  134. package/kits/rules/01-overview.md +2 -2
  135. package/kits/rules/03-identity.md +10 -9
  136. package/kits/rules/05-venue.md +2 -4
  137. package/kits/rules/06-channel.md +1 -1
  138. package/kits/schemas/_meta.json +31 -3
  139. package/kits/schemas/agent-config.schema.18.json +5 -0
  140. package/kits/schemas/agent-config.schema.19.json +924 -0
  141. package/kits/schemas/relation-config.schema.12.json +289 -0
  142. package/kits/schemas/role-config.schema.2.json +215 -0
  143. package/kits/skills/ec-skill/scripts/cli.mjs +3 -2
  144. package/kits/skills/ec-trigger/SKILL.md +4 -4
  145. package/kits/skills/personal-assistant/SKILL.md +109 -53
  146. package/kits/skills/personal-assistant/references/02-bootstrap.md +73 -30
  147. package/kits/skills/personal-assistant/scripts/clean.mjs +35 -18
  148. package/kits/skills/personal-assistant/scripts/init.mjs +41 -2
  149. package/kits/skills/personal-assistant/scripts/lib/persona.mjs +185 -0
  150. package/kits/skills/personal-assistant/scripts/migrate.mjs +55 -4
  151. package/kits/skills/personal-assistant/scripts/pa.mjs +173 -0
  152. package/kits/skills/personal-assistant/scripts/uninstall.mjs +130 -0
  153. package/kits/skills/personal-assistant/templates/persona-section.md +3 -3
  154. package/kits/templates/message-fragments/handoff-request-to-target.md +1 -1
  155. package/kits/templates/message-fragments/paactive/item.md +3 -0
  156. package/kits/templates/soul/00-GUIDE.md +61 -0
  157. package/kits/templates/soul/01-identity.md +5 -0
  158. package/kits/templates/soul/02-persona.md +11 -0
  159. package/kits/templates/soul/03-duties.md +5 -0
  160. package/kits/templates/soul/04-working-style.md +5 -0
  161. package/kits/templates/system-fragments/bootstrap.md +7 -7
  162. package/kits/templates/system-fragments/commands.md +3 -2
  163. package/kits/templates/system-fragments/directory-contacts.md +9 -0
  164. package/kits/templates/system-fragments/memory.md +1 -1
  165. package/kits/templates/system-fragments/paactive/channel.md +25 -0
  166. package/kits/templates/system-fragments/paactive/reply.md +25 -0
  167. package/kits/templates/system-fragments/paactive/session.md +32 -0
  168. package/kits/templates/system-fragments/personal-assistant.md +65 -0
  169. package/package.json +4 -3
  170. package/dist/cli/handoff-command.js +0 -353
  171. package/dist/directory/owner-directory-remark-operation.js +0 -147
  172. package/kits/docs/evolcore/self-summary.md +0 -29
@@ -124,6 +124,7 @@ export function parseMenuResponse(value) {
124
124
  return value;
125
125
  }
126
126
  export const MENU_NAME_COMMANDS = Object.freeze({
127
+ 'slash-commands': '/evolhelp',
127
128
  pwd: '/pwd',
128
129
  session: '/session',
129
130
  topic: '/topic',
@@ -323,6 +324,20 @@ export function parseMenuControl(content) {
323
324
  export function hasValidMenuId(parsed) {
324
325
  return typeof parsed.id === 'string' && parsed.id.trim().length > 0;
325
326
  }
327
+ export function validateSlashCommandsQueryArgs(args) {
328
+ if (args !== undefined && (!args || typeof args !== 'object' || Array.isArray(args))) {
329
+ return { code: 'INVALID_ARGUMENT', message: 'slash-commands args must be an object' };
330
+ }
331
+ const unknown = Object.keys(args ?? {}).find(key => !['view', 'level', 'context'].includes(key));
332
+ if (unknown)
333
+ return { code: 'INVALID_ARGUMENT', message: `slash-commands does not accept args.${unknown}` };
334
+ if (args?.view !== 'commands')
335
+ return { code: 'INVALID_ARGUMENT', message: 'slash-commands requires args.view=commands' };
336
+ if (args.level !== undefined && (typeof args.level !== 'string' || !['common', 'normal', 'all'].includes(args.level))) {
337
+ return { code: 'INVALID_ARGUMENT', message: 'level must be common, normal or all' };
338
+ }
339
+ return null;
340
+ }
326
341
  export function validateMenuRequest(request) {
327
342
  const type = request.type;
328
343
  if (!MENU_REQUEST_TYPES.has(type)) {
@@ -338,6 +353,11 @@ export function validateMenuRequest(request) {
338
353
  if (request.args !== undefined && (!request.args || typeof request.args !== 'object' || Array.isArray(request.args))) {
339
354
  return { code: 'INVALID_ARGUMENT', message: 'Menu request args must be an object' };
340
355
  }
356
+ if (request.name === 'slash-commands' || firstCommandToken(request.cmd) === '/evolhelp') {
357
+ if (type !== 'menu.query')
358
+ return { code: 'NOT_SUPPORTED', message: 'slash-commands only supports menu.query' };
359
+ return validateSlashCommandsQueryArgs(request.args);
360
+ }
341
361
  if (request.name === 'provider' || firstCommandToken(request.cmd) === '/provider') {
342
362
  return validateProviderMenuRequest(request);
343
363
  }
@@ -31,7 +31,7 @@ import { formatModelCheck, runModelCheck } from '../model/model-diagnostics.js';
31
31
  import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
32
32
  import { isAgentFullAccessOwner, resolveRuntimeStringField, sessionFullAccessStatus, updateRelationSessionFullAccess, } from '../role/runtime-policy.js';
33
33
  import { displaySessionTitle } from '../session/session-title.js';
34
- import { chatmodeFieldForPeer, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
34
+ import { chatmodeFieldForPeer, isChatMode, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
35
35
  import { normalizePermissionMode as normalizePermissionModeContract, PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
36
36
  import { isManagementRole } from '../../config/builtin-roles.js';
37
37
  import { isSystemControlChannel } from '../system-channels.js';
@@ -88,7 +88,7 @@ function resolveSlashChatmodeTarget(params) {
88
88
  function readSlashChatmode(target) {
89
89
  try {
90
90
  const mode = resolveChatModeForField({ ...target.sel, role: target.role, field: target.field });
91
- return mode === 'interactive' || mode === 'proactive'
91
+ return isChatMode(mode)
92
92
  ? mode
93
93
  : defaultSlashChatmode(target.field);
94
94
  }
@@ -621,7 +621,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
621
621
  try {
622
622
  const current = await refreshSessionLoopTarget(this.sessionManager, route, target);
623
623
  const payload = sessionLoopPayload(current);
624
- return { kind: 'command.result', text: `当前 idle 触发(${current.level},session=${current.session.id}):${payload.value ? `开启,${payload.idleSeconds} 秒` : '关闭'}` };
624
+ return {
625
+ kind: 'system.notice',
626
+ text: `当前 idle 触发(${current.level},session=${current.session.id}):${payload.value ? `开启,${payload.idleSeconds} 秒` : '关闭'}`,
627
+ subtype: 'session.loop.current',
628
+ };
625
629
  }
626
630
  catch (error) {
627
631
  return { kind: 'command.error', text: `❌ ${error instanceof Error ? error.message : String(error)}` };
@@ -649,7 +653,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
649
653
  const payload = sessionLoopPayload(updated);
650
654
  if (this.shouldSuppressCardTriggerResult(source, channel))
651
655
  return null;
652
- return { kind: 'command.result', text: `✅ idle 触发(${updated.level},session=${updated.session.id})已${payload.value ? `开启(${payload.idleSeconds} 秒)` : '关闭'}` };
656
+ return {
657
+ kind: 'system.notice',
658
+ text: `✅ idle 触发(${updated.level},session=${updated.session.id})已${payload.value ? `开启(${payload.idleSeconds} 秒)` : '关闭'}`,
659
+ subtype: 'session.loop.updated',
660
+ };
653
661
  }
654
662
  catch (error) {
655
663
  return { kind: 'command.error', text: `❌ ${error instanceof Error ? error.message : String(error)}` };
@@ -676,15 +684,20 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
676
684
  if (fullAccessControl.action === 'status') {
677
685
  const scope = isTopicSession(commandSession) ? 'session' : 'relation';
678
686
  return {
679
- kind: 'command.result',
687
+ kind: 'system.notice',
680
688
  text: '当前 fullaccess(' + scope + ',session=' + commandSession.id + '):'
681
689
  + (status.effective ? '开启' : '关闭')
682
690
  + '\nAgent 全局:' + (status.globalEnabled ? '开启(局部开关不生效)' : '关闭')
683
691
  + '\n局部开关:' + (status.localEnabled ? '开启' : '关闭'),
692
+ subtype: 'session.fullaccess.current',
684
693
  };
685
694
  }
686
695
  if (status.globalEnabled) {
687
- return { kind: 'command.result', text: 'Agent 全局 fullaccess 已开启,/fa on/off 不生效;局部设置未修改。' };
696
+ return {
697
+ kind: 'system.notice',
698
+ text: 'Agent 全局 fullaccess 已开启,/fa on/off 不生效;局部设置未修改。',
699
+ subtype: 'session.fullaccess.unchanged',
700
+ };
688
701
  }
689
702
  if (this.messageQueue.isProcessing(commandSession.id) || this.messageQueue.getQueueLength(commandSession.id) > 0) {
690
703
  return { kind: 'command.error', text: '❌ 当前会话有任务执行中,结束后再修改 fullaccess' };
@@ -716,9 +729,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
716
729
  reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : 'relation main-session fullaccess updated',
717
730
  });
718
731
  return {
719
- kind: 'command.result',
732
+ kind: 'system.notice',
720
733
  text: '✅ 当前' + (isTopicSession(commandSession) ? '话题 EC 会话' : '主会话')
721
734
  + ' fullaccess 已' + (enabled ? '开启' : '关闭'),
735
+ subtype: 'session.fullaccess.updated',
722
736
  };
723
737
  }
724
738
  catch (error) {
@@ -894,7 +908,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
894
908
  ...((canReadChatmode || canSetChatmode || canReadMentionmode || canSetMentionmode) ? [
895
909
  '',
896
910
  '💬 聊天设置:',
897
- ...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ? ' [interactive|proactive]' : ''} - 查看${canSetChatmode ? '或切换' : ''}会话模式`] : []),
911
+ ...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ? ' [interactive|proactive|paactive]' : ''} - 查看${canSetChatmode ? '或切换' : ''}会话模式`] : []),
898
912
  ...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
899
913
  ...(canReadMentionmode || canSetMentionmode ? [` /mention${canSetMentionmode ? ' [mention-only|disabled]' : ''} - 查看${canSetMentionmode ? '或切换' : ''}群聊 @ 处理模式`] : []),
900
914
  ] : []),
@@ -938,7 +952,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
938
952
  ...((canReadChatmode || canSetChatmode) ? [
939
953
  '',
940
954
  '💬 聊天设置:',
941
- ` /chatmode${canSetChatmode ? ' [interactive|proactive]' : ''} - 查看${canSetChatmode ? '或切换' : ''}会话模式`,
955
+ ` /chatmode${canSetChatmode ? ' [interactive|proactive|paactive]' : ''} - 查看${canSetChatmode ? '或切换' : ''}会话模式`,
942
956
  ] : []),
943
957
  ...(canReadLoop ? ['', ` /loop${canUpdateLoop ? ' [on [seconds]|off]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
944
958
  ...(canReadPermission || canAnswerPermission ? [
@@ -986,7 +1000,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
986
1000
  '',
987
1001
  '💬 聊天设置:',
988
1002
  ' /activity [all|text|none] - 查看/控制中间输出显示模式',
989
- ...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ? ' [interactive|proactive]' : ''} - 查看${canSetChatmode ? '/切换' : ''}会话模式(被动响应或主动推进)`] : []),
1003
+ ...(canReadChatmode || canSetChatmode ? [` /chatmode${canSetChatmode ? ' [interactive|proactive|paactive]' : ''} - 查看${canSetChatmode ? '/切换' : ''}会话模式(被动响应或主动推进)`] : []),
990
1004
  ...(canReadMentionmode || canSetMentionmode ? [` /mention${canSetMentionmode ? ' [mention-only|disabled]' : ''} - 查看${canSetMentionmode ? '/切换' : ''}群聊 @ 处理模式`] : []),
991
1005
  ...(canReadLoop ? [` /loop${canUpdateLoop ? ' [on [seconds]|off]' : ''} - 查看${canUpdateLoop ? '或设置' : ''}当前会话的单次闲置触发`] : []),
992
1006
  '',
@@ -1055,6 +1069,18 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1055
1069
  }
1056
1070
  // /evolhelp 命令:返回 JSON 格式的命令列表(供程序解析)
1057
1071
  if (normalizedContent === '/evolhelp') {
1072
+ const commonCommands = new Set([
1073
+ '/new', '/status', '/pause', '/resume', '/stop', '/compact', '/model', '/effort',
1074
+ '/thread', '/thread rename', '/thread summary', '/thread summary set',
1075
+ ]);
1076
+ // 常用是筛选分类;保留原分类和顺序,不复制条目或改变现有可见范围。
1077
+ const commandList = (commands) => ({
1078
+ kind: 'command.result',
1079
+ text: JSON.stringify({
1080
+ commands: commands.map(entry => commonCommands.has(entry.command) ? { ...entry, common: true } : entry),
1081
+ categories: ['常用', ...new Set(commands.map(entry => entry.category))],
1082
+ }),
1083
+ });
1058
1084
  const canReadLoop = canAccessSlashOperation('session.loop.current', 'relation');
1059
1085
  const canUpdateLoop = canAccessSlashOperation('session.loop.update', 'relation');
1060
1086
  const loopHelp = canReadLoop || canUpdateLoop ? [{
@@ -1099,7 +1125,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1099
1125
  }),
1100
1126
  ];
1101
1127
  commands.splice(insertAt + groupMemoryEntries.length, 0, ...groupExtras);
1102
- return { kind: 'command.result', text: JSON.stringify({ commands, categories: [...new Set(commands.map(c => c.category))] }) };
1128
+ return commandList(commands);
1103
1129
  }
1104
1130
  const cmds = [...loopHelp];
1105
1131
  const canReadModel = canAccessSlashOperation('model.current', 'relation')
@@ -1186,15 +1212,14 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1186
1212
  cmds.push({ command: '/file', args: isOwner ? '[channel] <path>' : '<path>', description: '发送项目内文件', category: '工具', roles: [identity.role] });
1187
1213
  // 聊天设置
1188
1214
  if (canReadChatmode || canSetChatmode)
1189
- cmds.push({ command: '/chatmode', ...(canSetChatmode ? { args: '[interactive|proactive]' } : {}), description: `查看${canSetChatmode ? '/切换' : ''}会话模式(被动响应或主动推进)`, category: '聊天设置', roles: [identity.role] });
1215
+ cmds.push({ command: '/chatmode', ...(canSetChatmode ? { args: '[interactive|proactive|paactive]' } : {}), description: `查看${canSetChatmode ? '/切换' : ''}会话模式(被动响应或主动推进)`, category: '聊天设置', roles: [identity.role] });
1190
1216
  if (canReadMentionmode || canSetMentionmode)
1191
1217
  cmds.push({ command: '/mention', ...(canSetMentionmode ? { args: '[mention-only|disabled]' } : {}), description: `查看${canSetMentionmode ? '/切换' : ''}群聊 @ 处理模式`, category: '聊天设置', roles: [identity.role] });
1192
1218
  // 交互
1193
1219
  cmds.push({ command: '/ask', args: '<选项>', description: '回答 Agent 的交互式问题', category: '运维', roles: ['visitor', 'member', 'admin', 'owner'] });
1194
1220
  // 帮助
1195
1221
  cmds.push({ command: '/help', description: '显示帮助信息', category: '帮助', roles: ['visitor', 'member', 'admin', 'owner'] });
1196
- const categories = [...new Set(cmds.map(c => c.category))];
1197
- return { kind: 'command.result', text: JSON.stringify({ commands: cmds, categories }) };
1222
+ return commandList(cmds);
1198
1223
  }
1199
1224
  // /perm 命令:权限模式查询 + 权限审批(快速路径,不进入消息队列)
1200
1225
  if (normalizedContent.startsWith('/perm')) {
@@ -1358,19 +1383,22 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1358
1383
  }
1359
1384
  if (normalizedContent === '/pause') {
1360
1385
  const pauseSession = await getExistingSessionForCommand();
1361
- if (!pauseSession)
1362
- return { kind: 'command.result', text: '当前没有活跃会话' };
1386
+ if (!pauseSession) {
1387
+ return { kind: 'system.notice', text: '当前没有活跃会话', subtype: 'session.pause.idle' };
1388
+ }
1363
1389
  const pauseAgent = this.getAgent(channel, pauseSession.baseagent);
1364
1390
  const hasActiveTask = pauseAgent.hasActiveStream(pauseSession.id)
1365
1391
  || this.messageQueue.isProcessing(pauseSession.id);
1366
- if (!hasActiveTask)
1367
- return { kind: 'command.result', text: '当前没有正在处理的任务' };
1392
+ if (!hasActiveTask) {
1393
+ return { kind: 'system.notice', text: '当前没有正在处理的任务', subtype: 'session.pause.idle' };
1394
+ }
1368
1395
  const requested = this.processor.pauseSession(pauseSession.id);
1369
1396
  return {
1370
- kind: 'command.result',
1397
+ kind: 'system.notice',
1371
1398
  text: requested
1372
1399
  ? '✓ 已请求暂停,任务将在下一次工具调用前暂停'
1373
1400
  : '当前任务已请求暂停或正在暂停',
1401
+ subtype: 'session.pause.requested',
1374
1402
  };
1375
1403
  }
1376
1404
  if (normalizedContent.startsWith('/resume ')) {
@@ -1378,18 +1406,22 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1378
1406
  }
1379
1407
  if (normalizedContent === '/resume') {
1380
1408
  const resumeSession = await getExistingSessionForCommand();
1381
- if (!resumeSession)
1382
- return { kind: 'command.result', text: '当前没有活跃会话' };
1409
+ if (!resumeSession) {
1410
+ return { kind: 'system.notice', text: '当前没有活跃会话', subtype: 'session.resume.idle' };
1411
+ }
1383
1412
  const resumed = await this.processor.recoverTask({
1384
1413
  sessionId: resumeSession.id,
1385
1414
  agentAid: resumeSession.selfAID,
1386
1415
  peerId: userId,
1387
1416
  encrypted: replyContext?.metadata?.encrypted,
1388
1417
  });
1389
- return {
1390
- kind: resumed.ok ? 'command.result' : 'command.error',
1391
- text: resumed.message ?? (resumed.ok ? '已继续当前任务' : '任务恢复失败'),
1392
- };
1418
+ return resumed.ok
1419
+ ? {
1420
+ kind: 'system.notice',
1421
+ text: resumed.message ?? '已继续当前任务',
1422
+ subtype: 'session.resumed',
1423
+ }
1424
+ : { kind: 'command.error', text: resumed.message ?? '任务恢复失败' };
1393
1425
  }
1394
1426
  // /baseagent 命令:查看或切换 Agent 后端
1395
1427
  if (normalizedContent === '/baseagent' || normalizedContent.startsWith('/baseagent ')) {
@@ -2037,7 +2069,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2037
2069
  const res = await execAgentAction('reload', { aid: targetAid }, userId ?? '', this.eventBus, this.agentApplicationService);
2038
2070
  if ('error' in res)
2039
2071
  return { kind: 'command.error', text: `❌ reload 失败:${res.error}` };
2040
- return { kind: 'command.result', text: `✅ Agent ${targetAid} 配置已重载` };
2072
+ return {
2073
+ kind: 'system.notice',
2074
+ text: `✅ Agent ${targetAid} 配置已重载`,
2075
+ subtype: 'agent.reloaded',
2076
+ };
2041
2077
  }
2042
2078
  // /agent, /aid, /rpc, /storage — 仅限顶级 CLI 调用,slash 输入拒绝
2043
2079
  if (normalizedContent === '/agent' || normalizedContent.startsWith('/agent ') ||
@@ -2162,6 +2198,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2162
2198
  const modes = [
2163
2199
  { key: 'interactive', name: '交互模式', desc: '被动响应:收到消息时才回复,回复直接显示' },
2164
2200
  { key: 'proactive', name: '主动模式', desc: '主动推进:流式输出静默,由 Agent 自调 ctl send 发声' },
2201
+ ...((existingChatmodeSession?.channelType ?? this.resolveChannelType?.(channel)) === 'aun'
2202
+ && activeChatType === 'private' && !isPrivateChatmodeRoleLocked('private', identity.role)
2203
+ ? [{ key: 'paactive', name: 'PA 模式', desc: '自动文本显示为 activity,正式回复由 Agent 显式发送' }] : []),
2165
2204
  ];
2166
2205
  const interaction = {
2167
2206
  type: 'interaction',
@@ -2193,10 +2232,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2193
2232
  return null;
2194
2233
  // 卡片降级:fall through 到下方文本输出
2195
2234
  // 降级:文本
2196
- return { kind: 'command.result', text: `会话模式: ${currentMode} 用法: /chatmode <interactive|proactive>` };
2235
+ return { kind: 'command.result', text: `会话模式: ${currentMode} 用法: /chatmode <interactive|proactive|paactive>` };
2197
2236
  }
2198
- if (arg !== 'interactive' && arg !== 'proactive') {
2199
- return { kind: 'command.error', text: `❌ 无效模式: ${arg}\n可选: interactive / proactive` };
2237
+ if (!isChatMode(arg)) {
2238
+ return { kind: 'command.error', text: `❌ 无效模式: ${arg}\n可选: interactive / proactive / paactive` };
2200
2239
  }
2201
2240
  if (activeChatType === 'group' && !isAdmin) {
2202
2241
  return { kind: 'command.error', text: '❌ 群聊中切换会话模式仅限管理员使用' };
@@ -2218,9 +2257,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2218
2257
  if (arg === currentMode) {
2219
2258
  return { kind: 'command.result', text: `📋 当前会话模式已是 ${arg}` };
2220
2259
  }
2221
- if (arg === 'interactive' && isPrivateChatmodeRoleLocked(target.field, target.role)) {
2260
+ if ((arg === 'interactive' || arg === 'paactive') && isPrivateChatmodeRoleLocked(target.field, target.role)) {
2222
2261
  return { kind: 'command.error', text: '❌ 私聊交互模式仅限 owner/admin,当前角色固定为 proactive' };
2223
2262
  }
2263
+ if (arg === 'paactive' && (target.field !== 'private' || !target.sel.peerKey?.startsWith('aun#'))) {
2264
+ return { kind: 'command.error', text: '❌ paactive 仅支持 AUN 人类私聊' };
2265
+ }
2224
2266
  // 仅在真正需要切换时才要求会话空闲
2225
2267
  if (chatmodeSession && threadId) {
2226
2268
  const threadSession = await this.sessionManager.getThreadSession(channel, channelId, threadId);
@@ -2373,8 +2415,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2373
2415
  }
2374
2416
  if (normalizedContent === '/stop') {
2375
2417
  const stopSession = await getExistingSessionForCommand();
2376
- if (!stopSession)
2377
- return { kind: 'command.result', text: '当前没有正在处理的任务' };
2418
+ if (!stopSession) {
2419
+ return { kind: 'system.notice', text: '当前没有正在处理的任务', subtype: 'session.stop.idle' };
2420
+ }
2378
2421
  const stopAgent = this.getAgent(channel, stopSession.baseagent);
2379
2422
  const sessionKey = stopSession.id;
2380
2423
  this.processor?.clearPauseSession?.(sessionKey);
@@ -2385,7 +2428,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2385
2428
  // Even an idle session can have an undelivered task:error recovery.
2386
2429
  // Persist the stop fence before acknowledging that nothing is running.
2387
2430
  await this.processor.interruptSession(sessionKey, 'stop');
2388
- return { kind: 'command.result', text: '当前没有正在处理的任务' };
2431
+ return { kind: 'system.notice', text: '当前没有正在处理的任务', subtype: 'session.stop.idle' };
2389
2432
  }
2390
2433
  // 发布中断事件,让 MessageProcessor 标记为 interrupted(而非 done)
2391
2434
  this.eventBus.publish({
@@ -2396,7 +2439,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2396
2439
  agentAid: stopSession.selfAID,
2397
2440
  });
2398
2441
  await this.processor.interruptSession(sessionKey, 'stop');
2399
- return { kind: 'command.result', text: '✓ 已发送中断信号,任务将尽快停止' };
2442
+ return {
2443
+ kind: 'system.notice',
2444
+ text: '✓ 已发送中断信号,任务将尽快停止',
2445
+ subtype: 'session.stopped',
2446
+ };
2400
2447
  }
2401
2448
  // /clear 已移除:Claude/Codex/Gemini 对“清空当前 backend 历史”的语义不一致。
2402
2449
  // 统一使用 /new 创建新会话来开始全新上下文。
@@ -2596,8 +2643,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2596
2643
  const compactResult = compacted;
2597
2644
  if (compactResult === true || compactResult?.ok === true) {
2598
2645
  return {
2599
- kind: 'command.result',
2646
+ kind: 'system.notice',
2600
2647
  text: '✅ 会话压缩完成',
2648
+ subtype: 'session.compacted',
2601
2649
  };
2602
2650
  }
2603
2651
  else {
@@ -3248,7 +3296,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
3248
3296
  },
3249
3297
  },
3250
3298
  });
3251
- await adapter.send(envelope, { kind: 'command.result', text: '🔄 重启监控已接管,服务正在重启;完成后会另行通知。' });
3299
+ await adapter.send(envelope, {
3300
+ kind: 'system.notice',
3301
+ text: '🔄 重启监控已接管,服务正在重启;完成后会另行通知。',
3302
+ subtype: 'system.restart.pending',
3303
+ });
3252
3304
  // 等待消息发送完成后再延迟 kill
3253
3305
  await new Promise(resolve => setTimeout(resolve, 500));
3254
3306
  }
@@ -3274,8 +3326,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
3274
3326
  fs.mkdirSync(controlDir, { recursive: true });
3275
3327
  fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: Date.now() }));
3276
3328
  return {
3277
- kind: 'command.result',
3329
+ kind: 'system.notice',
3278
3330
  text: `当前Agent对话有 ${pendingResultCount} 条后台结果待查看。再次输入 /restart 将强制重启服务。`,
3331
+ subtype: 'system.restart.confirmation_required',
3279
3332
  };
3280
3333
  }
3281
3334
  const restarted = await executeRestart();
@@ -3493,9 +3546,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
3493
3546
  const sizeStr = stat.size < 1024 ? `${stat.size} B`
3494
3547
  : stat.size < 1024 * 1024 ? `${(stat.size / 1024).toFixed(1)} KB`
3495
3548
  : `${(stat.size / 1024 / 1024).toFixed(1)} MB`;
3496
- return { kind: 'command.result', text: isCrossChannel
3549
+ return {
3550
+ kind: 'system.notice',
3551
+ text: isCrossChannel
3497
3552
  ? `📎 文件已通过 ${targetLabel} 发送: ${filePath} (${sizeStr})`
3498
- : `✅ 已发送: ${filePath} (${sizeStr})` };
3553
+ : `✅ 已发送: ${filePath} (${sizeStr})`,
3554
+ subtype: 'file.sent',
3555
+ };
3499
3556
  }
3500
3557
  catch (error) {
3501
3558
  logger.error('[CommandHandler] /file failed:', error);
@@ -3820,7 +3877,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
3820
3877
  return { kind: 'command.error', text: `❌ 重命名失败` };
3821
3878
  }
3822
3879
  this.eventBus.publish({ type: 'session:renamed', sessionId: session.id, oldName, newName });
3823
- return { kind: 'command.result', text: `✓ 已将当前会话重命名为: ${newName}` };
3880
+ return {
3881
+ kind: 'system.notice',
3882
+ text: `✓ 已将当前会话重命名为: ${newName}`,
3883
+ subtype: 'session.renamed',
3884
+ };
3824
3885
  }
3825
3886
  // /del 命令:删除指定会话(仅解绑,不删除文件)
3826
3887
  if (normalizedContent.startsWith('/del ')) {
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * FileCache —— 统一的文件缓存(daemon-only)。
3
3
  *
4
- * daemon 每条消息处理时读大量文件(manifest、fragment、md、working memory、
5
- * 关系级 preferences 等)。本类统一缓存"文件 → 解析后内容",按策略门控变化检查。
4
+ * daemon 每条消息处理时读大量文件(manifest、fragment、md、persona 等)。
5
+ * 本类统一缓存"文件 → 解析后内容",按策略门控变化检查。
6
6
  *
7
7
  * 设计与边界详见 docs/file-cache-design.md:
8
8
  * - 不接管 EvolAgent 的 merged config(agent/defaults 由 EvolAgent 持有权威副本)。
@@ -12,7 +12,7 @@
12
12
  * 策略(reload/重启永远全量失效,无视策略;策略只决定"平时每次读怎么检查"):
13
13
  * - on-reload:平时不检查,直接用缓存(kits 文件)。靠 reload/重启刷新。
14
14
  * - manual:同 on-reload,额外支持显式 invalidate(file) 单刷。
15
- * - mtime:每次读 statSync 门控 size + mtime,变了自动重读(working.md、config.json)。
15
+ * - mtime:每次读 statSync 门控 size + mtime,变了自动重读(soul/*.md、config.json)。
16
16
  *
17
17
  * 容量:项数可无界增长的组(如 relation-prefs,每 peer 一文件)设 LRU 硬上限
18
18
  * (见 GROUP_CAPS),命中/写入移到末尾、超限驱逐同组最旧项;无 timer。
@@ -2,7 +2,8 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
  import { EvolAgent } from './evolagent.js';
4
4
  import { logger } from '../utils/logger.js';
5
- import { agentPersonalDir, aidLocalDir } from '../paths.js';
5
+ import { aidLocalDir } from '../paths.js';
6
+ import { readSoulContent } from './soul.js';
6
7
  import { invalidateAgentDisplayName, resolveAgentDisplayName } from '../aun/aid/agentmd.js';
7
8
  import { loadAllAgents, ensureAgentDirSkeleton, loadAgent, validateAgentConfig, } from '../config-store.js';
8
9
  import { ConfigTarget, assertAgentAidAvailable, read as readConfig, resolveEffective } from '../config/config-manager.js';
@@ -585,9 +586,9 @@ export class EvolAgentRegistry {
585
586
  if (cached !== undefined)
586
587
  return cached;
587
588
  try {
588
- const personaPath = path.join(agentPersonalDir(aid), 'persona.md');
589
- if (fs.existsSync(personaPath)) {
590
- const content = fs.readFileSync(personaPath, 'utf-8');
589
+ // 只从 soul 里真正写了内容的文件抠名字;指南与空分册不参与。
590
+ const content = readSoulContent(aid);
591
+ if (content) {
591
592
  const bold = content.match(/我[叫是]\s*\*{1,2}(.+?)\*{1,2}/);
592
593
  if (bold?.[1] && bold[1] !== aid) {
593
594
  this.personalNameCache.set(aid, bold[1]);
@@ -1,7 +1,6 @@
1
- import path from 'path';
2
1
  import { formatChannelKey, tryParseChannelKey } from './channel-loader.js';
3
- import { agentPersonalDir } from '../paths.js';
4
2
  import { fileCache } from './daemon-file-cache.js';
3
+ import { readSoulContent } from './soul.js';
5
4
  import { ConfigTarget, assertAgentModelConfigured, read as cfgRead, write as cfgWrite, ensureFile as cfgEnsure, resolveEffective } from '../config/config-manager.js';
6
5
  import { withLifecycleForWrite } from '../config/lifecycle.js';
7
6
  import { isStaticAgentAdmin, isStaticAgentOwner } from '../config/peer-role-resolver.js';
@@ -270,14 +269,12 @@ export class EvolAgent {
270
269
  return `agent-files:${this.aid}`;
271
270
  }
272
271
  /**
273
- * 读取 personal/persona.md 内容。走 fileCache(mtime 门控):persona 可由
274
- * `ec agent persona` 或 agent 自己更新,与 working memory 一样改了即应生效,
275
- * 故每次读 stat 比对、变了自动重读。文件不存在返回 null。
272
+ * 读取 soul 目录里的自我定义内容(`personal/soul/*.md`,按文件名排序)。
273
+ * 具体过滤规则见 `readSoulContent`:跳过机制指南与空文件,剥掉 HTML 注释后判空。
274
+ * 走 fileCache 的 mtime 策略,改了下一轮即生效。
276
275
  */
277
276
  getPersona() {
278
- const personaPath = path.join(agentPersonalDir(this.aid), 'persona.md');
279
- const raw = fileCache.getText(personaPath, { policy: 'mtime', group: this.agentFilesGroup() });
280
- return raw === null ? null : (raw.trim() || null);
277
+ return readSoulContent(this.aid);
281
278
  }
282
279
  /** 清除本 agent 身份层缓存(reload 后重新读取)。只失效自己的文件组,不波及他人。 */
283
280
  invalidatePersonaCache() {
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Handoff argv 解析。
3
+ *
4
+ * `ec handoff` 命令入口已移除,但 daemon 侧仍通过 IPC 接收 handoff 报文
5
+ * (`handoff-return` / `handoff-recover-return` / `handoff-status` /
6
+ * `handoff-list` / `handoff-trace`),需要在 core 层解析这些 argv。
7
+ * 这里只放纯解析逻辑,不做任何 IPC 或输出。
8
+ */
9
+ import fs from 'fs';
10
+ import { HANDOFF_QUERY_DEFAULT_LIMIT, HANDOFF_QUERY_MAX_LIMIT, HANDOFF_STATES } from './types.js';
11
+ import { HANDOFF_ID_RE } from './store.js';
12
+ import { canonicalizeEvolcoreCommandArgv } from '../permission/ec-command-parser.js';
13
+ import { MAIN_CLI_BIN } from '../../product.js';
14
+ function parseLimit(value) {
15
+ const limit = Number(value);
16
+ if (!value || !Number.isInteger(limit) || limit < 1 || limit > HANDOFF_QUERY_MAX_LIMIT) {
17
+ throw new Error('INVALID_HANDOFF_LIMIT');
18
+ }
19
+ return limit;
20
+ }
21
+ export function parseList(args) {
22
+ const parsed = { limit: HANDOFF_QUERY_DEFAULT_LIMIT };
23
+ for (let index = 0; index < args.length; index++) {
24
+ const arg = args[index];
25
+ const value = args[index + 1];
26
+ if (arg === '--state') {
27
+ if (!value || !HANDOFF_STATES.includes(value))
28
+ throw new Error('INVALID_HANDOFF_STATE');
29
+ parsed.state = value;
30
+ index++;
31
+ }
32
+ else if (arg === '--session') {
33
+ if (!value)
34
+ throw new Error('HANDOFF_SESSION_REQUIRED');
35
+ parsed.sessionId = value;
36
+ index++;
37
+ }
38
+ else if (arg === '--agent') {
39
+ if (!value)
40
+ throw new Error('HANDOFF_AGENT_REQUIRED');
41
+ parsed.agent = value;
42
+ index++;
43
+ }
44
+ else if (arg === '--limit') {
45
+ parsed.limit = parseLimit(value);
46
+ index++;
47
+ }
48
+ else {
49
+ throw new Error(`UNKNOWN_HANDOFF_OPTION:${arg}`);
50
+ }
51
+ }
52
+ return parsed;
53
+ }
54
+ export function parseTrace(args) {
55
+ const handoffId = args[0];
56
+ if (!handoffId || !HANDOFF_ID_RE.test(handoffId))
57
+ throw new Error('INVALID_HANDOFF_ID');
58
+ const parsed = { handoffId, limit: HANDOFF_QUERY_DEFAULT_LIMIT };
59
+ for (let index = 1; index < args.length; index++) {
60
+ const arg = args[index];
61
+ const value = args[index + 1];
62
+ if (arg === '--agent') {
63
+ if (!value)
64
+ throw new Error('HANDOFF_AGENT_REQUIRED');
65
+ parsed.agent = value;
66
+ index++;
67
+ }
68
+ else if (arg === '--limit') {
69
+ parsed.limit = parseLimit(value);
70
+ index++;
71
+ }
72
+ else {
73
+ throw new Error(`UNKNOWN_HANDOFF_OPTION:${arg}`);
74
+ }
75
+ }
76
+ return parsed;
77
+ }
78
+ export function parseReturn(args, options = {}) {
79
+ if (!options.canonical)
80
+ args = canonicalizeEvolcoreCommandArgv([MAIN_CLI_BIN, 'handoff', 'return', ...args]).slice(3);
81
+ const dash = args.indexOf('--');
82
+ if (dash >= 0) {
83
+ const beforeDash = args.slice(0, dash);
84
+ const first = beforeDash[0];
85
+ if (first?.startsWith('h-') && !HANDOFF_ID_RE.test(first))
86
+ throw new Error(`INVALID_HANDOFF_ID:${first}`);
87
+ const handoffId = first && HANDOFF_ID_RE.test(first) ? first : undefined;
88
+ if (beforeDash.length > (handoffId ? 1 : 0))
89
+ throw new Error('HANDOFF_CONTENT_DELIMITER_CONFLICT');
90
+ return { handoffId, content: args.slice(dash + 1).join(' ') };
91
+ }
92
+ const fileIndex = args.indexOf('--text-from-file');
93
+ const filePath = fileIndex >= 0 ? args[fileIndex + 1] : undefined;
94
+ if (fileIndex >= 0 && !filePath)
95
+ throw new Error('HANDOFF_CONTENT_FILE_READ_FAILED');
96
+ const positional = args.filter((_, index) => fileIndex < 0 || (index !== fileIndex && index !== fileIndex + 1));
97
+ const first = positional[0];
98
+ if (first?.startsWith('h-') && !HANDOFF_ID_RE.test(first))
99
+ throw new Error(`INVALID_HANDOFF_ID:${first}`);
100
+ const handoffId = first && HANDOFF_ID_RE.test(first) ? first : undefined;
101
+ const contentArgs = handoffId ? positional.slice(1) : positional;
102
+ if (filePath && contentArgs.length > 0)
103
+ throw new Error('HANDOFF_CONTENT_FILE_CONFLICT');
104
+ if (filePath) {
105
+ if (options.deferFileRead)
106
+ return { handoffId, content: '' };
107
+ try {
108
+ return { handoffId, content: options.readFile ? options.readFile(filePath) : fs.readFileSync(filePath, 'utf8') };
109
+ }
110
+ catch {
111
+ throw new Error('HANDOFF_CONTENT_FILE_READ_FAILED');
112
+ }
113
+ }
114
+ return { handoffId, content: contentArgs.join(' ') };
115
+ }
@@ -2,7 +2,7 @@ import { isManagementRole } from '../../config/builtin-roles.js';
2
2
  import { hasTrustedFullAccessDelegation, trustedExecutionIdentityInput, } from '../auth/agent-delegation.js';
3
3
  import { authorizeFreshOperation as authorizeOperation, buildAuthSubject } from '../auth/auth-gateway.js';
4
4
  import { parsePeerKey } from '../relation/peer-identity.js';
5
- import { parseReturn } from '../../cli/handoff-command.js';
5
+ import { parseReturn } from './argv-parse.js';
6
6
  import { readTriggerLocalFile } from '../../trigger/local-files.js';
7
7
  export function registerHandoffIpc({ ipcServer, agentDelegationRegistry, responseEngine, sessionManager, agentRegistry, handoffRuntime, getProcessOwners, }) {
8
8
  const resolveManagedHandoffScope = async (params, operation) => {
@@ -313,15 +313,31 @@ export function createIpcStatusProvider(dependencies) {
313
313
  return () => {
314
314
  const channels = {};
315
315
  const channelsByType = {};
316
+ const channelRuntime = dependencies.getChannelRuntimeSnapshot?.();
316
317
  for (const instance of dependencies.channelInstances) {
317
318
  const name = instance.adapter.channelName;
318
- const status = instance.channel.getStatus?.() ?? { connected: true };
319
319
  const channelType = instance.channelType || name;
320
- channels[name] = { ...status, channelType };
320
+ try {
321
+ const status = instance.channel.getStatus?.() ?? { connected: false };
322
+ channels[name] = { ...status, channelType };
323
+ }
324
+ catch {
325
+ channels[name] = { connected: false, channelType, status: 'failed', reason: { code: 'STATUS_FAILED', message: '渠道状态读取失败' } };
326
+ }
321
327
  if (!channelsByType[channelType])
322
328
  channelsByType[channelType] = [];
323
329
  channelsByType[channelType].push(name);
324
330
  }
331
+ for (const instance of channelRuntime?.instances ?? []) {
332
+ const { channelName, channelType, status, reason, agentAid } = instance;
333
+ channels[channelName] = {
334
+ ...channels[channelName], channelType, agentAid, status, connected: status === 'connected',
335
+ ...(reason ? { reason } : {}),
336
+ };
337
+ const names = channelsByType[channelType] ??= [];
338
+ if (!names.includes(channelName))
339
+ names.push(channelName);
340
+ }
325
341
  const snapshot = dependencies.statsCollector.getSnapshot();
326
342
  const agents = dependencies.agentRegistry.list();
327
343
  const runtimeError = dependencies.getAgentRuntimeError();
@@ -361,6 +377,7 @@ export function createIpcStatusProvider(dependencies) {
361
377
  } : {}),
362
378
  channels,
363
379
  channelsByType,
380
+ ...(channelRuntime ? { channelRuntime } : {}),
364
381
  queue: { pending: dependencies.messageQueue.getGlobalQueueLength(), processing: dependencies.messageQueue.getGlobalProcessingCount() },
365
382
  ...(dependencies.getTriggerSummary ? { triggers: dependencies.getTriggerSummary() } : {}),
366
383
  ...(dependencies.getStatusSnapshot ? dependencies.getStatusSnapshot() : {}),