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
@@ -43,19 +43,29 @@ export function probeSessionActivity(evidence, probes) {
43
43
  return evaluateSessionActivity(collected);
44
44
  }
45
45
  // 支持的命令列表
46
- const commands = ['/new', '/pwd', '/help', '/evolhelp', '/status', '/restart', '/reload', '/model', '/effort', '/baseagent', '/slist', '/session', '/rename', '/stop', '/pause', '/compact', '/renew', '/repair', '/fork', '/del', '/perm', '/file', '/check', '/rewind', '/activity', '/observable', '/chatmode', '/mention', '/loop', '/ask', '/resume', '/aid', '/rpc', '/storage', '/agent', '/trigger', '/upgrade', '/pair', '/memory', '/skill', '/thread'];
46
+ const commands = ['/new', '/pwd', '/help', '/evolhelp', '/status', '/restart', '/reload', '/model', '/effort', '/baseagent', '/slist', '/session', '/rename', '/stop', '/pause', '/compact', '/renew', '/repair', '/fork', '/del', '/perm', '/file', '/check', '/rewind', '/activity', '/observable', '/chatmode', '/mention', '/loop', '/fa', '/fullaccess', '/ask', '/resume', '/aid', '/rpc', '/storage', '/agent', '/trigger', '/upgrade', '/pair', '/memory', '/skill', '/thread'];
47
47
  const deprecatedCommands = ['/clear'];
48
48
  commands.push('/diag');
49
49
  const exactBoundaryCommands = new Set(['/pause', '/resume', '/stop', '/pair', '/diag']);
50
- /** Parse the execution command without treating it as a quick/result command. */
50
+ /** Parse fullaccess controls and one-shot prompts without command-prefix ambiguity. */
51
51
  export function parseFullAccessCommand(content) {
52
52
  const match = content.match(/^\s*(\/fa|\/fullaccess)(?=\s|$)([\s\S]*)$/);
53
53
  if (!match)
54
54
  return { matched: false };
55
+ const raw = match[2].trim();
56
+ const command = match[1];
57
+ if (raw === '')
58
+ return { matched: true, command, action: 'status', raw };
59
+ if (raw === 'on')
60
+ return { matched: true, command, action: 'on', raw };
61
+ if (raw === 'off')
62
+ return { matched: true, command, action: 'off', raw };
55
63
  return {
56
64
  matched: true,
57
- command: match[1],
58
- prompt: match[2].trim(),
65
+ command,
66
+ action: 'prompt',
67
+ prompt: raw,
68
+ raw,
59
69
  };
60
70
  }
61
71
  // 命令别名映射
@@ -78,6 +88,13 @@ export function guardGroupSlashCommand(content, chatType) {
78
88
  return undefined;
79
89
  const [inputCommand, ...args] = content.trim().split(/\s+/);
80
90
  const command = aliases[inputCommand] ?? inputCommand;
91
+ if (command === '/fa' || command === '/fullaccess') {
92
+ return {
93
+ kind: 'command.error',
94
+ text: '❌ 群聊中不支持 /fa,请在私聊会话操作',
95
+ reason: 'GROUP_COMMAND_UNSUPPORTED',
96
+ };
97
+ }
81
98
  if (GROUP_READ_ONLY_COMMANDS.has(command)) {
82
99
  if (!args.length || (command === '/model' && args.length === 1 && ['current', 'list', 'check'].includes(args[0]))) {
83
100
  return undefined;
@@ -97,7 +114,7 @@ export function guardGroupSlashCommand(content, chatType) {
97
114
  };
98
115
  }
99
116
  // 命令快速路径前缀(所有命令都不进入消息队列)
100
- const quickCommandPrefixes = ['/new', '/pwd', '/help', '/evolhelp', '/status', '/restart', '/reload', '/model', '/effort', '/baseagent', '/slist', '/session', '/rename', '/repair', '/fork', '/stop', '/pause', '/clear', '/compact', '/renew', '/del', '/perm', '/file', '/check', '/s ', '/name', '/rewind', '/rw', '/rw ', '/activity', '/observable', '/chatmode', '/mention', '/loop', '/ask', '/resume', '/base ', '/aid', '/rpc', '/storage', '/agent', '/trigger', '/upgrade', '/pair', '/memory', '/skill', '/thread'];
117
+ const quickCommandPrefixes = ['/new', '/pwd', '/help', '/evolhelp', '/status', '/restart', '/reload', '/model', '/effort', '/baseagent', '/slist', '/session', '/rename', '/repair', '/fork', '/stop', '/pause', '/clear', '/compact', '/renew', '/del', '/perm', '/file', '/check', '/s ', '/name', '/rewind', '/rw', '/rw ', '/activity', '/observable', '/chatmode', '/mention', '/loop', '/fa', '/fullaccess', '/ask', '/resume', '/base ', '/aid', '/rpc', '/storage', '/agent', '/trigger', '/upgrade', '/pair', '/memory', '/skill', '/thread'];
101
118
  quickCommandPrefixes.push('/diag');
102
119
  /**
103
120
  * 计算两个字符串的 Levenshtein 距离(编辑距离)
@@ -10,8 +10,9 @@ import crypto from 'crypto';
10
10
  import path from 'path';
11
11
  import fs from 'fs';
12
12
  import { ensureFreshPackageVersionInfo, refreshManagedPackageVersions } from '../../utils/package-version-info.js';
13
+ import { loadDaemonConfig } from '../../config-store.js';
13
14
  import { remoteAccessService } from '../auth/remote-access-store.js';
14
- import { read as cfgRead, resolveEffective, routeFieldPath, write as cfgWrite, } from '../../config/config-manager.js';
15
+ import { read as cfgRead, resolveEffective, routeFieldPath, write as cfgWrite, ConfigTarget, } from '../../config/config-manager.js';
15
16
  import { execAgentAction } from './agent-control.js';
16
17
  import { handleMemorySlash, memoryHelpEntries } from './memory-slash.js';
17
18
  import { handleSkillSlash, skillHelpEntries } from './skill-slash.js';
@@ -21,11 +22,12 @@ import { getDaemonOwners, ownerResolver, refreshOwnershipForAuthorization, OWNER
21
22
  import { authorizationNextStep, formatAuthorizationDenial } from '../auth/authorization-denial.js';
22
23
  import { resolvePermissionMode, writeScope } from '../model/config-scope.js';
23
24
  import { formatPeerKey } from '../relation/peer-identity.js';
25
+ import { auditFullAccessEvent } from '../auth/authorization-audit.js';
24
26
  import { isMainSession, isTopicSession, isTopicThreadId, sessionTopicThreadId } from '../thread/topic-id.js';
25
27
  import { modelMatches, getCatalog, assertCatalogSelectable, resolveCatalogModel, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
26
28
  import { formatModelCheck, runModelCheck } from '../model/model-diagnostics.js';
27
29
  import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
28
- import { resolveRuntimeStringField } from '../role/runtime-policy.js';
30
+ import { isAgentFullAccessOwner, resolveRuntimeStringField, sessionFullAccessStatus, } from '../role/runtime-policy.js';
29
31
  import { displaySessionTitle } from '../session/session-title.js';
30
32
  import { chatmodeFieldForPeer, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
31
33
  import { normalizePermissionMode as normalizePermissionModeContract, PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
@@ -33,9 +35,9 @@ import { isManagementRole } from '../../config/builtin-roles.js';
33
35
  import { isSystemControlChannel } from '../system-channels.js';
34
36
  import { launchMonitorAndConfirm, resolveMonitorLaunch, cleanupMonitorStage, isProcessRunning } from '../../utils/cross-platform.js';
35
37
  import { scanInstances } from '../../utils/instance-registry.js';
36
- import { guardIdleCommand, guardGroupSlashCommand, guardKnownCommand, guardRoleCommand, guardThreadCommand, isRecognizedSlashCommand, normalizeSlashContent, probeSessionActivity, } from './slash-gate.js';
38
+ import { guardIdleCommand, guardGroupSlashCommand, guardKnownCommand, guardRoleCommand, guardThreadCommand, isRecognizedSlashCommand, normalizeSlashContent, parseFullAccessCommand, probeSessionActivity, } from './slash-gate.js';
37
39
  import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
38
- import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
40
+ import { DEFAULT_SESSION_LOOP_SECONDS, MAX_SESSION_LOOP_SECONDS, MIN_SESSION_LOOP_SECONDS, refreshSessionLoopTarget, resolveCurrentSessionLoopTarget, resolveSessionLoopTarget, sessionLoopPayload, validateIdleSeconds, writeSessionLoopConfig, } from '../session/session-idle-monitor.js';
39
41
  const allEfforts = CONFIGURABLE_EFFORTS;
40
42
  const PERMISSION_MODE_KEYS = PUBLIC_PERMISSION_MODES;
41
43
  function defaultSlashChatmode(field) {
@@ -400,6 +402,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
400
402
  const narrowedChatType = chatType === 'group' ? 'group' : chatType === 'private' ? 'private' : undefined;
401
403
  await refreshOwnershipForAuthorization(selfAID ?? this.agentRegistry?.resolveByChannel(channel)?.aid ?? this.resolveSelfAID(channel), {
402
404
  maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS,
405
+ allowTransient: true,
403
406
  });
404
407
  const identityConversationId = narrowedChatType === 'group' ? channelId : userId;
405
408
  const resolvedIdentity = overrideIdentity ?? this.sessionManager.resolveIdentity(channel, userId, narrowedChatType, identityConversationId);
@@ -523,6 +526,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
523
526
  || normalizedContent === '/reload'
524
527
  || normalizedContent.startsWith('/reload ')
525
528
  || normalizedContent === '/pair'
529
+ || normalizedContent === '/fa'
530
+ || normalizedContent === '/fullaccess'
531
+ || normalizedContent.startsWith('/fa ')
532
+ || normalizedContent.startsWith('/fullaccess ')
526
533
  || /^\/diag(?:\s|$)/.test(normalizedContent);
527
534
  const roleGuard = guardRoleCommand(normalizedContent, activeChatType, isAdmin || (isDaemonOwner && isProcessLevelSlash));
528
535
  if (roleGuard)
@@ -622,6 +629,74 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
622
629
  return { kind: 'command.error', text: `❌ ${error instanceof Error ? error.message : String(error)}` };
623
630
  }
624
631
  }
632
+ const fullAccessControl = parseFullAccessCommand(normalizedContent);
633
+ if (fullAccessControl.matched) {
634
+ if (fullAccessControl.action === 'prompt') {
635
+ return { kind: 'command.error', text: '❌ /fa <任务信息> 只能由用户直接发送' };
636
+ }
637
+ if (activeChatType === 'group' || source === 'card-trigger') {
638
+ return { kind: 'command.error', text: '❌ /fa 仅支持私聊中的当前 EC 会话' };
639
+ }
640
+ const commandSession = await getExistingSessionForCommand();
641
+ const agentAid = authSubject.selfAid ?? selfAID;
642
+ const principalId = authSubject.principalId;
643
+ if (!commandSession || !agentAid) {
644
+ return { kind: 'command.error', text: '❌ 当前没有可绑定的 EC 会话' };
645
+ }
646
+ if (this.messageQueue.isProcessing(commandSession.id) || this.messageQueue.getQueueLength(commandSession.id) > 0) {
647
+ return { kind: 'command.error', text: '❌ 当前会话有任务执行中,结束后再修改 fullaccess' };
648
+ }
649
+ if (!principalId || !authSubject.isDaemonOwner || !isAgentFullAccessOwner(agentAid, principalId)) {
650
+ return { kind: 'command.error', text: '❌ /fa 需要同一身份同时具备 Agent Owner 和 daemon Owner 权限' };
651
+ }
652
+ if (fullAccessControl.action === 'status') {
653
+ const status = sessionFullAccessStatus(commandSession, principalId);
654
+ const scope = isTopicSession(commandSession) ? 'session' : 'agent';
655
+ return {
656
+ kind: 'command.result',
657
+ text: '当前 fullaccess(' + scope + ',session=' + commandSession.id + '):'
658
+ + (status.effective ? '开启' : '关闭'),
659
+ };
660
+ }
661
+ const enabled = fullAccessControl.action === 'on';
662
+ try {
663
+ if (isTopicSession(commandSession)) {
664
+ const latest = await this.sessionManager.getThreadSession(channel, channelId, threadId);
665
+ if (!latest || latest.id !== commandSession.id || !isTopicSession(latest)) {
666
+ return { kind: 'command.error', text: '❌ 当前话题已发生变化,请重新执行 /fa' };
667
+ }
668
+ this.sessionManager.updateSessionFullAccess(latest.id, { enabled, authorizedBy: principalId });
669
+ }
670
+ else {
671
+ const latest = await this.sessionManager.getActiveSession(channel, channelId);
672
+ if (!latest || latest.id !== commandSession.id || !isMainSession(latest)) {
673
+ return { kind: 'command.error', text: '❌ 当前主会话已发生变化,请重新执行 /fa' };
674
+ }
675
+ const config = cfgRead(ConfigTarget.Agent, { self: agentAid }, { cache: false });
676
+ if (!config)
677
+ return { kind: 'command.error', text: '❌ 找不到当前 Agent 配置' };
678
+ config.fullaccess = { enabled };
679
+ cfgWrite(ConfigTarget.Agent, config, { self: agentAid });
680
+ }
681
+ auditFullAccessEvent({
682
+ event: enabled ? 'fullaccess.session-policy.configured' : 'fullaccess.session-policy.deescalated',
683
+ source: 'session-policy',
684
+ actorId: principalId,
685
+ processRole: 'daemon-owner',
686
+ agentAid,
687
+ sessionId: commandSession.id,
688
+ authorizedBy: principalId,
689
+ reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : 'Agent main-session fullaccess updated',
690
+ });
691
+ return {
692
+ kind: 'command.result',
693
+ text: '✅ 当前 EC 会话 fullaccess 已' + (enabled ? '开启' : '关闭'),
694
+ };
695
+ }
696
+ catch (error) {
697
+ return { kind: 'command.error', text: '❌ ' + (error instanceof Error ? error.message : String(error)) };
698
+ }
699
+ }
625
700
  const interruptPausedSessionBeforeReplacement = async (commandSession) => {
626
701
  if (commandSession && (this.processor?.isPauseRequested?.(commandSession.id) ?? false)) {
627
702
  this.eventBus.publish({
@@ -629,6 +704,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
629
704
  sessionId: commandSession.id,
630
705
  reason: 'stop',
631
706
  agentName: this.agentRegistry?.resolveByChannel(channel)?.name ?? '<unknown>',
707
+ agentAid: commandSession.selfAID,
632
708
  });
633
709
  await this.processor.interruptSession(commandSession.id, 'stop');
634
710
  this.processor?.clearPauseSession?.(commandSession.id);
@@ -775,7 +851,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
775
851
  const appendProcessCommands = (lines) => {
776
852
  if (!isDaemonOwner)
777
853
  return;
778
- lines.push('', '🛠️ 进程级运维:', ' /restart - 重启服务', ' /upgrade - 检查版本更新', ' /reload [aid] - 热重载 Agent 配置', ' /fa <提示词> - 单次使用宿主级 fullaccess 执行(别名: /fullaccess)', ' /pair - 获取远程控制配对码', ' /diag <问题描述> - 邀请或追加远程诊断;/diag stop 撤销授权');
854
+ lines.push('', '🛠️ 进程级运维:', ' /restart - 重启服务', ' /upgrade - 检查版本更新', ' /reload [aid] - 热重载 Agent 配置', ' /fa [on|off|<任务信息>] - 查看/切换会话 fullaccess,或单次执行任务', ' /pair - 获取远程控制配对码', ' /diag <问题描述> - 邀请或追加远程诊断;/diag stop 撤销授权');
779
855
  };
780
856
  if (!isAdmin && activeChatType === 'group') {
781
857
  const lines = [
@@ -907,7 +983,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
907
983
  ...(isDaemonOwner ? [
908
984
  ' /restart - 重启服务',
909
985
  ' /reload [aid] - 热重载 Agent 配置',
910
- ' /fa <提示词> - 单次使用宿主级 fullaccess 执行(别名: /fullaccess)',
986
+ ' /fa [on|off|<任务信息>] - 查看/切换会话 fullaccess,或单次执行任务',
911
987
  ' /pair - 获取远程控制配对码',
912
988
  ] : []),
913
989
  ...(!isDaemonOwner && isAdmin ? [
@@ -1067,7 +1143,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1067
1143
  cmds.push({ command: '/observable', args: '[true|false]', description: '查看或切换观察者模式', category: '运维', roles: ['owner'] });
1068
1144
  }
1069
1145
  if (isDaemonOwner) {
1070
- cmds.push({ command: '/fa', aliases: ['/fullaccess'], args: '<提示词>', description: '仅让当前提示词对应的 run 使用宿主级 fullaccess', category: '权限管理', roles: ['daemon-owner'] });
1146
+ cmds.push({ command: '/fa', aliases: ['/fullaccess'], args: '[on|off|<任务信息>]', description: '查看/切换当前 EC 会话 fullaccess,或单次执行 fullaccess 任务', category: '权限管理', roles: ['daemon-owner'] });
1071
1147
  cmds.push({ command: '/restart', description: '重启服务', category: '运维', roles: ['daemon-owner'] });
1072
1148
  cmds.push({ command: '/upgrade', description: '检查版本更新', category: '运维', roles: ['daemon-owner'] });
1073
1149
  cmds.push({ command: '/reload', args: '[aid]', description: '热重载 Agent 配置', category: '运维', roles: ['daemon-owner'] });
@@ -1308,7 +1384,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1308
1384
  initiatorId: userId,
1309
1385
  kind: {
1310
1386
  kind: 'command-card',
1311
- title: '🔌 切换 Agent',
1387
+ title: '🔌 新会话默认 Baseagent',
1312
1388
  buttons: available.map((a) => ({
1313
1389
  label: a === activeBaseagent ? `✓ ${a}` : a,
1314
1390
  command: `/baseagent ${a}`,
@@ -1327,9 +1403,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1327
1403
  const list = available.map((a) => `${a === activeBaseagent ? ' ✓' : ' '} ${a}`).join('\n');
1328
1404
  const canSwitchAgent = isOwner && !groupSlash;
1329
1405
  if (canSwitchAgent) {
1330
- return { kind: 'command.result', text: `当前 Baseagent: ${activeBaseagent}\n\n可用:\n${list}\n用法: /baseagent <name>` };
1406
+ return { kind: 'command.result', text: `新会话默认 Baseagent: ${activeBaseagent}\n\n可用:\n${list}\n用法: /baseagent <name>` };
1331
1407
  }
1332
- return { kind: 'command.result', text: `当前 Baseagent: ${activeBaseagent}` };
1408
+ return { kind: 'command.result', text: `新会话默认 Baseagent: ${activeBaseagent}` };
1333
1409
  }
1334
1410
  if (!available.includes(args)) {
1335
1411
  return { kind: 'command.error', text: `❌ 未知 Agent: ${args}\n可用: ${available.join(', ')}` };
@@ -1339,103 +1415,17 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1339
1415
  }
1340
1416
  const currentSession = await getExistingSessionForCommand();
1341
1417
  const previousBaseagent = owningAgent.baseagent || this.parseDefaultBaseagent();
1342
- const currentTopicThreadId = sessionTopicThreadId(currentSession);
1343
- if (currentSession && currentTopicThreadId) {
1344
- const rotation = await withIdleTopicBackend(currentSession.id, currentTopicThreadId, async (current) => {
1345
- try {
1346
- owningAgent.setActiveBaseagent(args);
1347
- }
1348
- catch (error) {
1349
- return { ok: false, error: error instanceof Error ? error.message : String(error) };
1350
- }
1351
- try {
1352
- const result = await this.sessionManager.rotateTopicBackend({
1353
- sessionId: current.id,
1354
- // withIdleTopicBackend 已校验 sessionTopicThreadId(current) === currentTopicThreadId
1355
- expectedThreadId: currentTopicThreadId,
1356
- baseagent: args,
1357
- });
1358
- return { ok: true, result };
1359
- }
1360
- catch (error) {
1361
- try {
1362
- owningAgent.setActiveBaseagent(previousBaseagent);
1363
- }
1364
- catch { }
1365
- return { ok: false, error: error instanceof Error ? error.message : String(error) };
1366
- }
1367
- }, currentSession);
1368
- if (!rotation.ok) {
1369
- if (rotation.reason === 'busy')
1370
- return { kind: 'command.error', text: '⚠️ 当前话题会话忙碌,无法切换 baseagent,请稍后再试' };
1371
- if (rotation.reason === 'unknown')
1372
- return { kind: 'command.error', text: '⚠️ 当前话题会话状态未知,无法安全切换 baseagent,请稍后再试' };
1373
- return { kind: 'command.error', text: `❌ baseagent 切换失败:${rotation.reason === 'missing' ? '当前话题会话不存在' : '状态未知'}` };
1374
- }
1375
- if (!rotation.value.ok)
1376
- return { kind: 'command.error', text: `❌ baseagent 切换失败:${rotation.value.error}` };
1377
- this.eventBus.publish({ type: 'agent:baseagent-changed', aid: owningAgent.aid, baseagent: args, previousBaseagent, scope: 'agent', timestamp: Date.now() });
1378
- return {
1379
- kind: 'system.notice',
1380
- text: `✓ 当前话题已切换 Baseagent: ${previousBaseagent} → ${args}\n 话题会话 ID 保持不变: ${currentSession.id}`,
1381
- subtype: 'session.created',
1382
- };
1383
- }
1384
- await interruptPausedSessionBeforeReplacement(currentSession);
1385
1418
  try {
1386
1419
  owningAgent.setActiveBaseagent(args);
1387
1420
  }
1388
1421
  catch (error) {
1389
1422
  return { kind: 'command.error', text: `❌ ${error instanceof Error ? error.message : String(error)}` };
1390
1423
  }
1391
- let newSession;
1392
- try {
1393
- newSession = await this.sessionManager.createNewSession(channel, channelId, owningAgent.projectPath, undefined, args, currentSession?.metadata, { previousBaseagent, baseagentChanged: previousBaseagent !== args });
1394
- }
1395
- catch (error) {
1396
- try {
1397
- owningAgent.setActiveBaseagent(previousBaseagent);
1398
- }
1399
- catch { }
1400
- return { kind: 'command.error', text: `❌ 创建新会话失败:${error instanceof Error ? error.message : String(error)}` };
1401
- }
1402
- if (currentSession) {
1403
- const previousAgent = getActiveAgentIfAvailable();
1404
- if (previousAgent) {
1405
- await previousAgent.clearSession(currentSession.id, currentSession.agentSessionId || '', currentSession.projectPath);
1406
- await previousAgent.closeSession(currentSession.id);
1407
- }
1408
- }
1409
1424
  this.eventBus.publish({ type: 'agent:baseagent-changed', aid: owningAgent.aid, baseagent: args, previousBaseagent, scope: 'agent', timestamp: Date.now() });
1410
- // 与 /new 一致:按 关系>角色>agent 解析新 backend 实际生效的 model/effort,
1411
- // 而不是只显示 baseagent 名。
1412
- const newBaseagentRunner = this.getAgent(channel, newSession.baseagent);
1413
- const newModelTarget = resolveSlashRelationTarget.call(this, {
1414
- session: newSession,
1415
- channel,
1416
- channelId,
1417
- userId,
1418
- selfAID,
1419
- role: newSession.identity?.role || identity.role,
1420
- chatType,
1421
- });
1422
- const newModelSelector = 'error' in newModelTarget
1423
- ? { self: selfAID ?? newSession.selfAID ?? this.resolveSelfAID(channel) }
1424
- : newModelTarget;
1425
- let sessionModelConfig = {};
1426
- try {
1427
- sessionModelConfig = (resolveEffective(newModelSelector, { cache: true }).baseagents || {})[args] || {};
1428
- }
1429
- catch { }
1430
- const sessionBackendModel = sessionModelConfig.model || newBaseagentRunner?.getModel?.() || owningAgent?.model;
1431
- const sessionBackendEffort = sessionModelConfig.effort
1432
- ?? newBaseagentRunner?.getEffort?.()
1433
- ?? owningAgent?.effort;
1434
- const sessionBackendBits = [args, sessionBackendModel, sessionBackendEffort].filter(Boolean).join(' · ');
1435
1425
  return {
1436
- kind: 'system.notice',
1437
- text: `✓ 已切换新后端 : ${sessionBackendBits}`,
1438
- subtype: 'session.created',
1426
+ kind: 'command.result',
1427
+ text: `✓ 新会话默认 Baseagent: ${previousBaseagent} → ${args}`
1428
+ + (currentSession ? `\n当前会话继续使用 ${currentSession.baseagent}。` : ''),
1439
1429
  };
1440
1430
  }
1441
1431
  // /model 命令:查看或切换模型/推理强度
@@ -2475,6 +2465,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2475
2465
  sessionId: sessionKey,
2476
2466
  reason: 'stop',
2477
2467
  agentName: this.agentRegistry?.resolveByChannel(channel)?.name ?? '<unknown>',
2468
+ agentAid: stopSession.selfAID,
2478
2469
  });
2479
2470
  await this.processor.interruptSession(sessionKey, 'stop');
2480
2471
  return { kind: 'command.result', text: '✓ 已发送中断信号,任务将尽快停止' };
@@ -2780,13 +2771,32 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2780
2771
  : mentionModeTarget.scope === 'relation' ? '本群' : 'Agent 全局';
2781
2772
  const chatModeLine = `会话模式: ${chatMode}`;
2782
2773
  const mentionModeLine = `@ 处理模式(${mentionScopeLabel}): ${mentionMode}`;
2774
+ const statusControlLines = [];
2775
+ const fullAccessPrincipalId = authSubject.principalId;
2776
+ if (session.chatType === 'private'
2777
+ && authSubject.isDaemonOwner
2778
+ && fullAccessPrincipalId
2779
+ && session.selfAID
2780
+ && isAgentFullAccessOwner(session.selfAID, fullAccessPrincipalId)
2781
+ && sessionFullAccessStatus(session, fullAccessPrincipalId).effective) {
2782
+ statusControlLines.push('fullaccess: 开启');
2783
+ }
2784
+ if (canAccessSlashOperation('session.loop.current', 'relation')) {
2785
+ const loopTarget = resolveSessionLoopTarget(session);
2786
+ if (loopTarget) {
2787
+ const loopStatus = sessionLoopPayload(loopTarget);
2788
+ if (loopStatus.value === true && typeof loopStatus.idleSeconds === 'number') {
2789
+ statusControlLines.push(`loop 周期: ${loopStatus.idleSeconds} 秒`);
2790
+ }
2791
+ }
2792
+ }
2783
2793
  if (isAdmin) {
2784
2794
  const gitInfo = await getGitWorkingDirInfo(session.projectPath);
2785
2795
  lines.push(`📊 ${isThread ? '话题' : '会话'}状态 (Agent: ${agentName}):`, `渠道: ${this.resolveChannelType(channel)} / 项目: ${projectName} / 会话: ${displaySessionTitle(session.name, '(未命名)')}`, `会话ID: ${session.id}`, `项目路径: ${session.projectPath}`);
2786
2796
  if (gitInfo) {
2787
2797
  lines.push(`Git: ${gitInfo}`);
2788
2798
  }
2789
- lines.push(`会话状态: ${sessionStatus} / 轮数: ${sessionTurns} / 已记录子任务数: ${sessionSubtasks}`, sessionRoleLine, chatModeLine, mentionModeLine);
2799
+ lines.push(`会话状态: ${sessionStatus} / 轮数: ${sessionTurns} / 已记录子任务数: ${sessionSubtasks}`, sessionRoleLine, chatModeLine, mentionModeLine, ...statusControlLines);
2790
2800
  if (health.consecutiveErrors > 0) {
2791
2801
  lines.push(`异常计数: ${health.consecutiveErrors}`);
2792
2802
  }
@@ -2794,7 +2804,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2794
2804
  }
2795
2805
  else {
2796
2806
  lines.push(`📊 ${isThread ? '话题' : '会话'}状态 (Agent: ${agentName}):`, `渠道: ${channel} / 项目: ${projectName} / ${session.baseagent}会话`);
2797
- lines.push(`状态: ${sessionStatus} / 轮数: ${sessionTurns} / 已记录子任务数: ${sessionSubtasks}`, sessionRoleLine, chatModeLine, mentionModeLine, `最后活跃: ${timeStr}`);
2807
+ lines.push(`状态: ${sessionStatus} / 轮数: ${sessionTurns} / 已记录子任务数: ${sessionSubtasks}`, sessionRoleLine, chatModeLine, mentionModeLine, ...statusControlLines, `最后活跃: ${timeStr}`);
2798
2808
  }
2799
2809
  if (health.lastError) {
2800
2810
  lines.push('');
@@ -3214,7 +3224,16 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
3214
3224
  logger.warn(`[System] Refusing restart without a valid explicit delivery route: channel=${channel} channelId=${channelId}`);
3215
3225
  return false;
3216
3226
  }
3227
+ let autoUpgrade = true;
3217
3228
  if (!suppressRealRestart) {
3229
+ try {
3230
+ autoUpgrade = loadDaemonConfig().upgrade?.autoOnStart !== false;
3231
+ }
3232
+ catch {
3233
+ autoUpgrade = false;
3234
+ }
3235
+ }
3236
+ if (!suppressRealRestart && autoUpgrade) {
3218
3237
  await ensureFreshPackageVersionInfo(undefined, {
3219
3238
  source: 'slash-restart',
3220
3239
  log: message => logger.info(`[System] ${message}`),
@@ -3251,7 +3270,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
3251
3270
  cleanupMonitorStage(monitorEntry.stageDir);
3252
3271
  return { code: 'RESTART_PENDING_CONFIRMATION', reason: '已有重启请求正在处理', requestId: restartInfo.requestId };
3253
3272
  }
3254
- const confirmation = await launchMonitorAndConfirm([...monitorEntry.args, 'restart-monitor'], { EVOLCORE_HOME: resolvePaths().root, ...monitorEntry.env, [RESTART_REQUEST_ID_ENV]: restartInfo.requestId }, pid => scanInstances().restartMonitors.some(m => m.alive && m.record.pid === pid
3273
+ const confirmation = await launchMonitorAndConfirm([...monitorEntry.args, 'restart-monitor', autoUpgrade ? '--apply-package-upgrades' : '--skip-package-upgrades'], { EVOLCORE_HOME: resolvePaths().root, ...monitorEntry.env, [RESTART_REQUEST_ID_ENV]: restartInfo.requestId }, pid => scanInstances().restartMonitors.some(m => m.alive && m.record.pid === pid
3255
3274
  && m.record.requestId === restartInfo.requestId && m.record.phase === 'accepted'), pid => scanInstances().restartMonitors.some(m => m.alive && m.record.pid !== pid
3256
3275
  && m.record.requestId === restartInfo.requestId && m.record.phase === 'accepted'), {
3257
3276
  requestId: restartInfo.requestId,
@@ -124,6 +124,21 @@ const CATALOG = [
124
124
  { path: 'timestamp', type: 'number' },
125
125
  ],
126
126
  },
127
+ {
128
+ type: 'session:backend-recovery',
129
+ namespace: 'session',
130
+ name: 'backend-recovery',
131
+ description: '底层会话异常恢复完成并接收恢复摘要',
132
+ fields: [
133
+ { path: 'sessionId', type: 'string' },
134
+ { path: 'agentAid', type: 'string', optional: true },
135
+ { path: 'baseagent', type: 'string' },
136
+ { path: 'sourceAgentSessionId', type: 'string', optional: true },
137
+ { path: 'agentSessionId', type: 'string' },
138
+ { path: 'capsuleId', type: 'string' },
139
+ { path: 'timestamp', type: 'number' },
140
+ ],
141
+ },
127
142
  {
128
143
  type: 'session:switched',
129
144
  namespace: 'session',
@@ -318,6 +333,7 @@ const CATALOG = [
318
333
  { path: 'durationMs', type: 'number', optional: true },
319
334
  { path: 'terminalReason', type: 'string', optional: true },
320
335
  { path: 'agentName', type: 'string', optional: true },
336
+ { path: 'agentAid', type: 'string', optional: true },
321
337
  { path: 'numTurns', type: 'number', optional: true },
322
338
  { path: 'encrypted', type: 'boolean', optional: true },
323
339
  { path: 'timestamp', type: 'number', optional: true },
@@ -354,6 +370,7 @@ const CATALOG = [
354
370
  { path: 'generation', type: 'number', optional: true },
355
371
  { path: 'reason', type: 'string', optional: true },
356
372
  { path: 'agentName', type: 'string', optional: true },
373
+ { path: 'agentAid', type: 'string', optional: true },
357
374
  { path: 'encrypted', type: 'boolean', optional: true },
358
375
  ],
359
376
  },
@@ -290,7 +290,8 @@ export function renderActionAsText(req) {
290
290
  lines.push('', '回复:');
291
291
  for (const btn of action.buttons) {
292
292
  const arg = fb.buttonArgMap?.[btn.key] ?? btn.key;
293
- lines.push(` /${fb.command} ${arg} ← ${btn.label}`);
293
+ const label = action.recommendedOption === btn.key ? `💡 ${btn.label}` : btn.label;
294
+ lines.push(` /${fb.command} ${arg} ← ${label}`);
294
295
  }
295
296
  if (fb.acceptFreeText && fb.freeTextHint) {
296
297
  lines.push(` ${fb.freeTextHint}`);
@@ -11,7 +11,6 @@ import { agentDir } from '../paths.js';
11
11
  import { parsePeerKey } from './relation/peer-identity.js';
12
12
  import { resolvePeerRoleDetail } from '../config/peer-role-resolver.js';
13
13
  import { buildDebugTaskContext } from './auth/debug-context.js';
14
- import { computeBuildId } from '../utils/evolcore-version.js';
15
14
  import { loadAgent } from '../config-store.js';
16
15
  import { executeLocalInitializationCommand, hasSuppliedInitialization } from '../cli/agent-create.js';
17
16
  import { remoteAccessService } from './auth/remote-access-store.js';
@@ -25,7 +24,7 @@ import { createTriggerBaseagentResolver, registerTriggerIpcExecutor } from '../t
25
24
  import { createThreadOperationExecutor } from './thread/ipc-operation.js';
26
25
  import { isLinkedInstall } from '../utils/npm-ops.js';
27
26
  import { buildSystemSessionContext, getSystemSessionModule } from './system-session/registry.js';
28
- export function registerDaemonIpc({ ipcServer, agentRegistry, agentDelegationRegistry, sessionManager, statsCollector, aidStatsCollector, responseEngine, messageQueue, agentMap, commandHandler, channelInstances, eventBus, handoffRuntime, reloadCoordinator, agentApplicationService, agentInitializationService, enqueueConsolidation, completeAgentBootstrap, contactBinds, bindService, diagService, getProcessOwners, getControlAidState, daemonAid, triggerControlToken, triggerSchedulers, daemonTriggerOwner, primaryAgent, triggerAuthorization, }) {
27
+ export function registerDaemonIpc({ ipcServer, agentRegistry, agentDelegationRegistry, sessionManager, statsCollector, aidStatsCollector, responseEngine, messageQueue, agentMap, commandHandler, channelInstances, eventBus, handoffRuntime, reloadCoordinator, agentApplicationService, agentInitializationService, enqueueConsolidation, requestRelationSweep, completeAgentBootstrap, contactBinds, bindService, diagService, getProcessOwners, getControlAidState, daemonAid, triggerControlToken, triggerSchedulers, daemonTriggerOwner, primaryAgent, triggerAuthorization, }) {
29
28
  const authorizeManagedAgentOperation = createDelegationAuthorizer({
30
29
  agentDelegationRegistry,
31
30
  sessionManager,
@@ -229,7 +228,7 @@ export function registerDaemonIpc({ ipcServer, agentRegistry, agentDelegationReg
229
228
  });
230
229
  registerAunIpcSender({ ipcServer, channelInstances, agentDelegationRegistry, responseEngine, handoffRuntime, triggerSchedulers, sessionManager });
231
230
  ipcServer.setAgentReloadExecutor((aid, options) => reloadCoordinator.reload(aid, options));
232
- registerConsolidationCheckExecutor({ ipcServer, agentRegistry, enqueueConsolidation });
231
+ registerConsolidationCheckExecutor({ ipcServer, agentRegistry, enqueueConsolidation, requestRelationSweep });
233
232
  ipcServer.setInitializationExecutor(async (command) => executeLocalInitializationCommand(agentInitializationService, command));
234
233
  ipcServer.setAgentApplicationService(agentApplicationService);
235
234
  registerQueueIpcProviders({ ipcServer, statsCollector, agentRegistry, messageQueue });
@@ -288,10 +287,12 @@ export function createIpcStatusProvider(dependencies) {
288
287
  return {
289
288
  pid: process.pid,
290
289
  uptime: snapshot.uptimeMs,
290
+ ...(dependencies.runMode ? { runMode: dependencies.runMode } : {}),
291
+ ...(dependencies.host ? { host: dependencies.host } : {}),
291
292
  build: {
292
293
  runtimeMode: dependencies.runtimeIsDist ? 'dist' : 'source',
293
294
  runtimeId: dependencies.runtimeBuildIdentity.id,
294
- diskDistId: computeBuildId(dependencies.diskDistDir),
295
+ diskDistId: dependencies.diskDistId ?? null,
295
296
  entry: dependencies.runtimeBuildIdentity.entry,
296
297
  version: dependencies.runtimeBuildIdentity.version,
297
298
  },
@@ -302,9 +303,26 @@ export function createIpcStatusProvider(dependencies) {
302
303
  runningAgents: agents.filter(agent => agent.status === 'running').length,
303
304
  ...(runtimeError ? { error: runtimeError } : {}),
304
305
  },
306
+ ...(dependencies.baseagents ? {
307
+ baseagents: {
308
+ source: 'runtime-cache',
309
+ items: dependencies.baseagents.baseagents.map(baseagent => ({
310
+ ...baseagent,
311
+ state: baseagent.loaded === true
312
+ ? 'ready'
313
+ : baseagent.detected === true
314
+ ? 'available'
315
+ : baseagent.detected === false
316
+ ? 'unavailable'
317
+ : 'unknown',
318
+ })),
319
+ },
320
+ } : {}),
305
321
  channels,
306
322
  channelsByType,
307
323
  queue: { pending: dependencies.messageQueue.getGlobalQueueLength(), processing: dependencies.messageQueue.getGlobalProcessingCount() },
324
+ ...(dependencies.getTriggerSummary ? { triggers: dependencies.getTriggerSummary() } : {}),
325
+ ...(dependencies.getStatusSnapshot ? dependencies.getStatusSnapshot() : {}),
308
326
  stats: {
309
327
  received: snapshot.lastHour.received,
310
328
  sent: snapshot.lastHour.sent,
@@ -455,6 +473,7 @@ export function registerQueueIpcProviders({ ipcServer, statsCollector, agentRegi
455
473
  const snapshots = statsCollector.getSnapshots(agents.map(agent => agent.aid));
456
474
  return agents.map((agent) => {
457
475
  const snapshot = snapshots.get(agent.aid);
476
+ const queueAgentName = agentRegistry.get(agent.aid)?.name ?? agent.aid;
458
477
  return {
459
478
  aid: agent.aid,
460
479
  received: snapshot.lastHour.received,
@@ -463,9 +482,9 @@ export function registerQueueIpcProviders({ ipcServer, statsCollector, agentRegi
463
482
  errors: snapshot.lastHour.errors,
464
483
  interrupts: snapshot.lastHour.interrupts,
465
484
  avgResponseMs: snapshot.lastHour.avgResponseMs,
466
- processing: messageQueue.getProcessingCountByAgent(agent.aid),
467
- queued: messageQueue.getQueueLengthByAgent(agent.aid),
468
- muted: messageQueue.isAgentMuted(agent.aid),
485
+ processing: messageQueue.getProcessingCountByAgent(queueAgentName),
486
+ queued: messageQueue.getQueueLengthByAgent(queueAgentName),
487
+ muted: messageQueue.isAgentMuted(queueAgentName),
469
488
  };
470
489
  });
471
490
  });
@@ -644,7 +663,7 @@ export function registerOperationIpcProviders({ ipcServer, sessionManager, messa
644
663
  const authorization = await authorizeManagedAgentOperation({ ...params, targetAid: command.aid }, command.operation);
645
664
  if (!authorization.ok)
646
665
  return authorization;
647
- const { storageDownload, storageLs, storageRm, storageQuota } = await import('../aun/storage/index.js');
666
+ const { storageDownload, storageGetByShare, storageLs, storageRm, storageQuota } = await import('../aun/storage/index.js');
648
667
  if (command.sub === 'ls')
649
668
  return storageLs(authorization.aid, command.prefix);
650
669
  if (command.sub === 'quota')
@@ -656,6 +675,23 @@ export function registerOperationIpcProviders({ ipcServer, sessionManager, messa
656
675
  const session = await sessionManager.getSessionById(params.sessionId);
657
676
  if (!session)
658
677
  return { ok: false, code: 'SESSION_NOT_FOUND', error: 'current session not found' };
678
+ if (command.sub === 'get-by-share') {
679
+ if (!command.shareId)
680
+ return { ok: false, code: 'INVALID_ARGUMENT', error: 'get-by-share requires a share_id' };
681
+ const defaultName = `share-${command.shareId}`;
682
+ const destination = path.resolve(authorization.sessionRuntimeDir ?? session.projectPath, command.localPath ?? defaultName);
683
+ const roots = [session.projectPath, authorization.sessionRuntimeDir].filter((root) => !!root).map(root => fs.realpathSync(root));
684
+ let parent = path.dirname(destination);
685
+ while (!fs.existsSync(parent) && path.dirname(parent) !== parent)
686
+ parent = path.dirname(parent);
687
+ const realParent = fs.realpathSync(parent);
688
+ if (!roots.some(root => isSameOrDescendant(destination, root) && isSameOrDescendant(realParent, root))
689
+ || isHClassPath(destination) || isLClassPath(destination)
690
+ || (fs.existsSync(destination) && (!fs.lstatSync(destination).isFile() || fs.lstatSync(destination).isSymbolicLink()))) {
691
+ return { ok: false, code: 'INVALID_LOCAL_PATH', error: 'Download destination must be an unprotected project/TMPDIR file' };
692
+ }
693
+ return storageGetByShare(authorization.aid, command.shareId, destination);
694
+ }
659
695
  const defaultName = path.basename(command.url.replace(/^https?:\/\//, '').split('/').slice(1).join('/'));
660
696
  const destination = path.resolve(session.projectPath, command.localPath ?? defaultName);
661
697
  const roots = [session.projectPath, authorization.sessionRuntimeDir].filter((root) => !!root).map(root => fs.realpathSync(root));
@@ -95,6 +95,8 @@ export function updateBatchMeta(batchDir, updates) {
95
95
  finishedAt: updates.finishedAt,
96
96
  success: updates.success,
97
97
  ...(updates.agentSessionId ? { agentSessionId: updates.agentSessionId } : {}),
98
+ ...(updates.requestedModel ? { requestedModel: updates.requestedModel } : {}),
99
+ ...(updates.actualModel ? { actualModel: updates.actualModel } : {}),
98
100
  ...(updates.failureReason ? { failureReason: updates.failureReason } : {}),
99
101
  };
100
102
  // 更新 feedback 正文