evolcore 0.0.41-test.0 → 0.0.41-test.1

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 (177) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/agents/baseagent-availability.js +1 -1
  3. package/dist/agents/baseagent.js +20 -43
  4. package/dist/agents/claude-runner.js +177 -92
  5. package/dist/agents/codex-runner.js +84 -28
  6. package/dist/agents/ecagent-runner.js +1 -1
  7. package/dist/agents/gemini-runner.js +1 -1
  8. package/dist/aun/group/fs-download.js +39 -0
  9. package/dist/aun/group/identity.js +36 -21
  10. package/dist/aun/group/operations.js +5 -0
  11. package/dist/aun/msg/managed-operation.js +68 -7
  12. package/dist/aun/msg/p2p.js +5 -0
  13. package/dist/aun/service-proxy.js +36 -12
  14. package/dist/channels/aun.js +334 -20
  15. package/dist/channels/daemon.js +15 -1
  16. package/dist/cli/aun-commands.js +4 -20
  17. package/dist/cli/daemon-commands.js +678 -697
  18. package/dist/cli/fs-command.js +64 -2
  19. package/dist/cli/index.js +48 -4
  20. package/dist/cli/managed-command-guard.js +4 -0
  21. package/dist/cli/model.js +40 -40
  22. package/dist/cli/proxy-command.js +92 -0
  23. package/dist/cli/role.js +85 -0
  24. package/dist/config/access-policy.js +7 -2
  25. package/dist/config/boot-log.js +38 -1
  26. package/dist/config/config-field-policy.js +5 -32
  27. package/dist/config/config-manager.js +46 -39
  28. package/dist/config/config-operation-service.js +5 -19
  29. package/dist/config/contact-book-store.js +47 -21
  30. package/dist/config/contact-book.js +18 -12
  31. package/dist/config/contact-operation-service.js +3 -4
  32. package/dist/config/contact-request-service.js +11 -0
  33. package/dist/config/daemon-services.js +11 -0
  34. package/dist/config/gateway-config.js +88 -594
  35. package/dist/config/peer-role-resolver.js +13 -11
  36. package/dist/config/providers-config.js +12 -7
  37. package/dist/config/providers-import.js +3 -21
  38. package/dist/config/resolved-config-op.js +3 -0
  39. package/dist/config/role-command-service.js +166 -0
  40. package/dist/config/role-request-service.js +193 -0
  41. package/dist/config/schema-migration.js +686 -25
  42. package/dist/config-store.js +79 -3
  43. package/dist/contracts/ecweb-instance.js +41 -0
  44. package/dist/contracts/ecweb-service-protocol.js +3 -1
  45. package/dist/core/agent-runtime.js +1 -1
  46. package/dist/core/auth/agent-delegation.js +2 -1
  47. package/dist/core/auth/auth-gateway.js +1 -1
  48. package/dist/core/auth/authorization-audit.js +17 -6
  49. package/dist/core/auth/delegation-authorization.js +3 -1
  50. package/dist/core/auth/operation-authorizer.js +15 -0
  51. package/dist/core/auth/operation-catalog.js +31 -6
  52. package/dist/core/command/agent-control.js +3 -7
  53. package/dist/core/command/agent-storage-menu.js +5 -3
  54. package/dist/core/command/cli-intent-parser.js +2 -1
  55. package/dist/core/command/command-handler.js +48 -99
  56. package/dist/core/command/connect-menu.js +11 -3
  57. package/dist/core/command/data-root-resolver.js +5 -4
  58. package/dist/core/command/memory-slash.js +16 -8
  59. package/dist/core/command/menu-catalog.js +5 -6
  60. package/dist/core/command/menu-handler.js +49 -62
  61. package/dist/core/command/role-menu.js +147 -30
  62. package/dist/core/command/slash-handler.js +123 -254
  63. package/dist/core/daemon-control.js +8 -14
  64. package/dist/core/evolagent-registry.js +4 -4
  65. package/dist/core/evolagent.js +2 -2
  66. package/dist/core/inference/text-inference.js +31 -40
  67. package/dist/core/ipc-registration.js +6 -2
  68. package/dist/core/memory/consolidation-context.js +51 -5
  69. package/dist/core/memory/consolidation-ops-records.js +1 -1
  70. package/dist/core/memory/consolidation-trigger.js +189 -189
  71. package/dist/core/memory/consolidation.js +316 -29
  72. package/dist/core/memory/forget-log.js +96 -0
  73. package/dist/core/memory/index-manager.js +27 -5
  74. package/dist/core/memory/memory-admin.js +45 -5
  75. package/dist/core/memory/memory-writer.js +163 -18
  76. package/dist/core/memory/relation-idle-monitor.js +119 -58
  77. package/dist/core/memory/relation-sweep.js +44 -39
  78. package/dist/core/message/aun-ipc-sender.js +8 -2
  79. package/dist/core/message/im-renderer.js +7 -4
  80. package/dist/core/message/message-admission.js +89 -4
  81. package/dist/core/message/message-bridge.js +31 -18
  82. package/dist/core/message/response-engine.js +77 -8
  83. package/dist/core/model/catalog-service.js +4 -2
  84. package/dist/core/model/config-scope.js +24 -64
  85. package/dist/core/model/field-scope.js +1 -1
  86. package/dist/core/model/model-catalog.js +30 -41
  87. package/dist/core/model/model-diagnostics.js +4 -3
  88. package/dist/core/model/model-fallback.js +10 -7
  89. package/dist/core/model/model-permission.js +3 -2
  90. package/dist/core/ownership/owner-resolver.js +23 -21
  91. package/dist/core/permission/ec-command-parser.js +30 -2
  92. package/dist/core/permission/sandbox-runtime.js +18 -1
  93. package/dist/core/permission/tool-policy.js +14 -3
  94. package/dist/core/relation/peer-identity.js +64 -1
  95. package/dist/core/role/runtime-policy.js +72 -13
  96. package/dist/core/session/session-capsule.js +1 -1
  97. package/dist/core/session/session-idle-monitor.js +1 -1
  98. package/dist/core/session/session-manager.js +20 -0
  99. package/dist/core/session/session-renew.js +3 -3
  100. package/dist/core/skill/index-generator.js +15 -5
  101. package/dist/core/system-session/memory.js +6 -1
  102. package/dist/core/thread/thread-service.js +19 -6
  103. package/dist/directory/owner-directory-admission.js +95 -0
  104. package/dist/directory/owner-directory-authorization.js +309 -0
  105. package/dist/directory/owner-directory-cache.js +635 -0
  106. package/dist/eck/kit-renderer.js +2 -2
  107. package/dist/ecweb/basic-settings-service.js +33 -40
  108. package/dist/ecweb/message-context-service.js +110 -0
  109. package/dist/index.js +76 -14
  110. package/dist/ipc.js +170 -12
  111. package/dist/paths.js +4 -0
  112. package/dist/proxy/command.js +122 -0
  113. package/dist/proxy/ipc-service.js +68 -0
  114. package/dist/proxy/manager.js +485 -0
  115. package/dist/proxy/service-supervisor.js +603 -0
  116. package/dist/response-system/engines/v1/proactive-flow.js +16 -6
  117. package/dist/utils/cross-platform.js +14 -0
  118. package/dist/utils/ecweb-supervisor.js +258 -83
  119. package/dist/utils/error-utils.js +2 -2
  120. package/dist/utils/logger.js +24 -5
  121. package/dist/utils/package-version-info.js +4 -2
  122. package/kits/docs/channels/aun.md +9 -0
  123. package/kits/docs/evolcore/agent.md +1 -1
  124. package/kits/docs/evolcore/config.md +17 -6
  125. package/kits/docs/evolcore/contact.md +3 -0
  126. package/kits/docs/evolcore/fs.md +11 -0
  127. package/kits/docs/evolcore/memory-architecture.md +2 -2
  128. package/kits/docs/evolcore/memory-consolidation.md +32 -8
  129. package/kits/docs/evolcore/memory.md +1 -1
  130. package/kits/docs/evolcore/menu-protocol.md +4 -0
  131. package/kits/docs/evolcore/model.md +23 -20
  132. package/kits/docs/evolcore/msg.md +4 -7
  133. package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
  134. package/kits/schemas/_meta.json +37 -4
  135. package/kits/schemas/agent-config.schema.13.json +8 -3
  136. package/kits/schemas/agent-config.schema.16.json +891 -0
  137. package/kits/schemas/daemon.schema.9.json +366 -0
  138. package/kits/schemas/defaults.schema.5.json +406 -127
  139. package/kits/schemas/relation-config.schema.11.json +260 -0
  140. package/kits/schemas/role-config.schema.1.json +7 -7
  141. package/kits/skills/.switches.json +3 -7
  142. package/kits/skills/ec-service-proxy/SKILL.md +118 -0
  143. package/kits/skills/ec-trigger/SKILL.md +13 -5
  144. package/kits/skills/personal-assistant/SKILL.md +176 -0
  145. package/kits/skills/personal-assistant/references/01-workspace-spec.md +333 -0
  146. package/kits/skills/personal-assistant/references/02-bootstrap.md +205 -0
  147. package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +177 -0
  148. package/kits/skills/personal-assistant/references/04-frontend-contract.md +439 -0
  149. package/kits/skills/personal-assistant/references/05-directory-reference.md +292 -0
  150. package/kits/skills/personal-assistant/references/06-render-config.md +350 -0
  151. package/kits/skills/personal-assistant/schema/workspace.schema.json +85 -0
  152. package/kits/skills/personal-assistant/schema/workspace.v1.json +66 -0
  153. package/kits/skills/personal-assistant/scripts/archive.mjs +154 -0
  154. package/kits/skills/personal-assistant/scripts/check.mjs +114 -0
  155. package/kits/skills/personal-assistant/scripts/index-rebuild.mjs +252 -0
  156. package/kits/skills/personal-assistant/scripts/ingest.mjs +344 -0
  157. package/kits/skills/personal-assistant/scripts/init.mjs +270 -0
  158. package/kits/skills/personal-assistant/scripts/lib/apply.mjs +92 -0
  159. package/kits/skills/personal-assistant/scripts/lib/schema.mjs +96 -0
  160. package/kits/skills/personal-assistant/scripts/lib/time.mjs +28 -0
  161. package/kits/skills/personal-assistant/scripts/migrate.mjs +172 -0
  162. package/kits/skills/personal-assistant/scripts/search.mjs +172 -0
  163. package/kits/skills/personal-assistant/scripts/verify.mjs +196 -0
  164. package/kits/skills/personal-assistant/templates/INDEX.md.tpl +24 -0
  165. package/kits/skills/personal-assistant/templates/README.md.tpl +108 -0
  166. package/kits/skills/personal-assistant/triggers/ingest-daily.json +23 -0
  167. package/kits/skills/personal-assistant/triggers/memory-consolidate.json +23 -0
  168. package/kits/skills/personal-assistant/triggers/report-daily.json +23 -0
  169. package/kits/skills/personal-assistant/triggers/report-weekly.json +23 -0
  170. package/kits/templates/memory-consolidation/forget.md +19 -6
  171. package/kits/templates/memory-consolidation/notes.md +1 -1
  172. package/kits/templates/memory-consolidation/profile.md +2 -2
  173. package/kits/templates/memory-consolidation/promote.md +20 -3
  174. package/kits/templates/roles/member.json +8 -1
  175. package/kits/templates/system-fragments/baseagent.md +2 -2
  176. package/kits/templates/system-fragments/memory.md +4 -4
  177. package/package.json +6 -2
@@ -12,7 +12,7 @@ import fs from 'fs';
12
12
  import { ensureFreshPackageVersionInfo, refreshManagedPackageVersions } from '../../utils/package-version-info.js';
13
13
  import { loadDaemonConfig } from '../../config-store.js';
14
14
  import { remoteAccessService } from '../auth/remote-access-store.js';
15
- import { read as cfgRead, resolveEffective, routeFieldPath, write as cfgWrite, ConfigTarget, } from '../../config/config-manager.js';
15
+ import { read as cfgRead, resolveEffective, routeFieldPath, write as cfgWrite, } from '../../config/config-manager.js';
16
16
  import { execAgentAction } from './agent-control.js';
17
17
  import { handleMemorySlash, memoryHelpEntries } from './memory-slash.js';
18
18
  import { handleSkillSlash, skillHelpEntries } from './skill-slash.js';
@@ -20,14 +20,14 @@ import { handleTopicSlash, topicHelpEntries, canUseTopicSlash } from './topic-sl
20
20
  import { authorizeOperation, authorizeFreshOperation, buildAuthSubject } from '../auth/auth-gateway.js';
21
21
  import { getDaemonOwners, ownerResolver, refreshOwnershipForAuthorization, OWNERSHIP_CACHE_MAX_AGE_MS } from '../ownership/owner-resolver.js';
22
22
  import { authorizationNextStep, formatAuthorizationDenial } from '../auth/authorization-denial.js';
23
- import { resolvePermissionMode, writeScope } from '../model/config-scope.js';
23
+ import { resolvePermissionMode, writeAgentModelConfig } from '../model/config-scope.js';
24
24
  import { formatPeerKey } from '../relation/peer-identity.js';
25
25
  import { auditFullAccessEvent } from '../auth/authorization-audit.js';
26
26
  import { isMainSession, isTopicSession, isTopicThreadId, sessionTopicThreadId } from '../thread/topic-id.js';
27
27
  import { modelMatches, getCatalog, assertCatalogSelectable, resolveCatalogModel, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
28
28
  import { formatModelCheck, runModelCheck } from '../model/model-diagnostics.js';
29
29
  import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole } from '../model/model-permission.js';
30
- import { isAgentFullAccessOwner, resolveRuntimeStringField, sessionFullAccessStatus, } from '../role/runtime-policy.js';
30
+ import { isAgentFullAccessOwner, resolveRuntimeStringField, sessionFullAccessStatus, updateRelationSessionFullAccess, } from '../role/runtime-policy.js';
31
31
  import { displaySessionTitle } from '../session/session-title.js';
32
32
  import { chatmodeFieldForPeer, isPrivateChatmodeRoleLocked, resolveChatModeForField } from '../message/peer-mode.js';
33
33
  import { normalizePermissionMode as normalizePermissionModeContract, PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
@@ -511,7 +511,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
511
511
  const canAccessSlashOperation = (operation, scope) => {
512
512
  const args = scope === 'relation'
513
513
  ? buildSlashRelationIntentArgs({ selfAid: authSubject.selfAid, peerKey: authSubject.peerKey })
514
- : {};
514
+ : scope === 'agent' && authSubject.selfAid ? { self: authSubject.selfAid } : {};
515
515
  return authorizeOperation({
516
516
  source: 'slash',
517
517
  intent: { operation, scope, source: 'slash', args },
@@ -643,21 +643,26 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
643
643
  if (!commandSession || !agentAid) {
644
644
  return { kind: 'command.error', text: '❌ 当前没有可绑定的 EC 会话' };
645
645
  }
646
- if (this.messageQueue.isProcessing(commandSession.id) || this.messageQueue.getQueueLength(commandSession.id) > 0) {
647
- return { kind: 'command.error', text: '❌ 当前会话有任务执行中,结束后再修改 fullaccess' };
648
- }
649
646
  if (!principalId || !authSubject.isDaemonOwner || !isAgentFullAccessOwner(agentAid, principalId)) {
650
647
  return { kind: 'command.error', text: '❌ /fa 需要同一身份同时具备 Agent Owner 和 daemon Owner 权限' };
651
648
  }
649
+ const status = sessionFullAccessStatus(commandSession, principalId);
652
650
  if (fullAccessControl.action === 'status') {
653
- const status = sessionFullAccessStatus(commandSession, principalId);
654
- const scope = isTopicSession(commandSession) ? 'session' : 'agent';
651
+ const scope = isTopicSession(commandSession) ? 'session' : 'relation';
655
652
  return {
656
653
  kind: 'command.result',
657
654
  text: '当前 fullaccess(' + scope + ',session=' + commandSession.id + '):'
658
- + (status.effective ? '开启' : '关闭'),
655
+ + (status.effective ? '开启' : '关闭')
656
+ + '\nAgent 全局:' + (status.globalEnabled ? '开启(局部开关不生效)' : '关闭')
657
+ + '\n局部开关:' + (status.localEnabled ? '开启' : '关闭'),
659
658
  };
660
659
  }
660
+ if (status.globalEnabled) {
661
+ return { kind: 'command.result', text: 'Agent 全局 fullaccess 已开启,/fa on/off 不生效;局部设置未修改。' };
662
+ }
663
+ if (this.messageQueue.isProcessing(commandSession.id) || this.messageQueue.getQueueLength(commandSession.id) > 0) {
664
+ return { kind: 'command.error', text: '❌ 当前会话有任务执行中,结束后再修改 fullaccess' };
665
+ }
661
666
  const enabled = fullAccessControl.action === 'on';
662
667
  try {
663
668
  if (isTopicSession(commandSession)) {
@@ -672,11 +677,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
672
677
  if (!latest || latest.id !== commandSession.id || !isMainSession(latest)) {
673
678
  return { kind: 'command.error', text: '❌ 当前主会话已发生变化,请重新执行 /fa' };
674
679
  }
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
+ updateRelationSessionFullAccess(latest, { enabled, authorizedBy: principalId });
680
681
  }
681
682
  auditFullAccessEvent({
682
683
  event: enabled ? 'fullaccess.session-policy.configured' : 'fullaccess.session-policy.deescalated',
@@ -686,11 +687,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
686
687
  agentAid,
687
688
  sessionId: commandSession.id,
688
689
  authorizedBy: principalId,
689
- reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : 'Agent main-session fullaccess updated',
690
+ reason: isTopicSession(commandSession) ? 'topic session fullaccess updated' : 'relation main-session fullaccess updated',
690
691
  });
691
692
  return {
692
693
  kind: 'command.result',
693
- text: '✅ 当前 EC 会话 fullaccess 已' + (enabled ? '开启' : '关闭'),
694
+ text: '✅ 当前' + (isTopicSession(commandSession) ? '话题 EC 会话' : '主会话')
695
+ + ' fullaccess 已' + (enabled ? '开启' : '关闭'),
694
696
  };
695
697
  }
696
698
  catch (error) {
@@ -839,8 +841,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
839
841
  }
840
842
  const canReadModel = canAccessSlashOperation('model.current', 'relation')
841
843
  || canAccessSlashOperation('model.list', 'relation');
842
- const canUseModel = canAccessSlashOperation('model.use', 'relation');
843
- const canSetEffort = canAccessSlashOperation('model.effort', 'relation');
844
+ const canUseModel = canAccessSlashOperation('model.use', 'agent');
845
+ const canSetEffort = canAccessSlashOperation('model.effort', 'agent');
844
846
  const canReadPermission = canAccessSlashOperation('permission.current', 'relation');
845
847
  const canAnswerPermission = canAccessSlashOperation('permission.answer', 'relation');
846
848
  const canReadChatmode = canAccessSlashOperation('chatmode.current', 'relation');
@@ -1076,8 +1078,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1076
1078
  const cmds = [...loopHelp];
1077
1079
  const canReadModel = canAccessSlashOperation('model.current', 'relation')
1078
1080
  || canAccessSlashOperation('model.list', 'relation');
1079
- const canUseModel = canAccessSlashOperation('model.use', 'relation');
1080
- const canSetEffort = canAccessSlashOperation('model.effort', 'relation');
1081
+ const canUseModel = canAccessSlashOperation('model.use', 'agent');
1082
+ const canSetEffort = canAccessSlashOperation('model.effort', 'agent');
1081
1083
  const canReadPermission = canAccessSlashOperation('permission.current', 'relation');
1082
1084
  const canAnswerPermission = canAccessSlashOperation('permission.answer', 'relation');
1083
1085
  const canReadChatmode = canAccessSlashOperation('chatmode.current', 'relation');
@@ -1465,7 +1467,6 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1465
1467
  try {
1466
1468
  const result = await runModelCheck({
1467
1469
  self,
1468
- peerKey,
1469
1470
  role: modelSession?.identity?.role || identity.role,
1470
1471
  baseagent: modelAgent.name,
1471
1472
  });
@@ -1486,12 +1487,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1486
1487
  return { kind: 'command.error', text: `模型网关检查失败: ${error instanceof Error ? error.message : String(error)}` };
1487
1488
  }
1488
1489
  }
1490
+ // 模型参数只在 Agent 级:reset 直接清除 Agent 级配置(鉴权用 agent scope)。
1489
1491
  const resetAuthDenied = await authorizeIntent({
1490
1492
  intent: {
1491
1493
  operation: 'model.reset',
1492
- scope: 'relation',
1494
+ scope: 'agent',
1493
1495
  source: 'slash',
1494
- args: buildSlashRelationIntentArgs({ selfAid: self, peerKey }),
1496
+ args: { self: selfAID ?? this.resolveSelfAID(channel) },
1495
1497
  },
1496
1498
  identity,
1497
1499
  session: modelSession,
@@ -1499,27 +1501,16 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1499
1501
  channel,
1500
1502
  channelId,
1501
1503
  userId,
1502
- selfAid: self,
1504
+ selfAid: selfAID ?? this.resolveSelfAID(channel),
1503
1505
  isDaemonOwner,
1504
1506
  });
1505
1507
  if (resetAuthDenied)
1506
1508
  return resetAuthDenied;
1507
- const target = resolveSlashRelationTarget.call(this, {
1508
- session: modelSession,
1509
- channel,
1510
- channelId,
1511
- userId,
1512
- selfAID: self,
1513
- role: modelSession?.identity?.role || identity.role,
1514
- chatType: modelChatType,
1515
- });
1516
- if ('error' in target)
1517
- return { kind: 'command.error', text: `Cannot locate relation scope: ${target.error}` };
1518
1509
  try {
1519
- writeScope('relation', target, modelAgent.name, { model: null, effort: null });
1510
+ writeAgentModelConfig(selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel), modelAgent.name, { model: null, effort: null });
1520
1511
  }
1521
1512
  catch (error) {
1522
- return { kind: 'command.error', text: `Failed to reset relation model settings: ${error?.message || error}` };
1513
+ return { kind: 'command.error', text: `Failed to reset Agent model settings: ${error?.message || error}` };
1523
1514
  }
1524
1515
  this.eventBus.publish({
1525
1516
  type: 'runner:model-changed',
@@ -1530,8 +1521,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1530
1521
  });
1531
1522
  return {
1532
1523
  kind: 'command.result',
1533
- text: '✓ 已清除当前关系的模型和推理强度设置',
1534
- structured: { ok: true, scope: 'relation', self: target.self, peerKey: target.peerKey },
1524
+ text: '✓ 已清除当前 Agent 的模型和推理强度设置',
1525
+ structured: { ok: true, scope: 'agent', self: selfAID ?? this.resolveSelfAID(channel) },
1535
1526
  };
1536
1527
  }
1537
1528
  if (!args || args === 'list' || args === 'current') {
@@ -1585,9 +1576,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1585
1576
  const models = hasModelSwitcher(modelAgent)
1586
1577
  ? filterModelsForRole(identity.role, fallbackBaseagent, rawModels, model => resolveCatalogModel(catalog, model), modelSelector.self)
1587
1578
  : rawModels;
1588
- const currentModel = hasModelSwitcher(modelAgent) ? (configuredModel || modelAgent.getModel()) : modelAgent.name;
1589
- const efforts = await getAvailableEfforts(modelAgent, currentModel);
1590
- const currentEffort = configuredEffort ?? modelAgent.getEffort?.() ?? 'auto';
1579
+ // 模型只在 Agent 级:未配置就是没有模型,不显示 runner 内置默认值。
1580
+ const currentModel = configuredModel ?? '';
1581
+ const currentModelLabel = currentModel ? modelDisplayLabel(modelAgent, currentModel) : '未配置(Agent 级未设置模型,无模型可用)';
1582
+ const efforts = currentModel ? await getAvailableEfforts(modelAgent, currentModel) : [];
1583
+ const currentEffort = configuredEffort ?? 'auto';
1591
1584
  const canReadModelList = await canReadSlashModelList({
1592
1585
  subject: authSubject,
1593
1586
  identity,
@@ -1636,7 +1629,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1636
1629
  if (args === 'current') {
1637
1630
  return {
1638
1631
  kind: 'command.result',
1639
- text: `当前模型: ${modelDisplayLabel(modelAgent, currentModel)}${effortHint}`,
1632
+ text: `当前模型: ${currentModelLabel}${effortHint}`,
1640
1633
  structured: { ok: true, model: currentModel, effort: currentEffort, baseagent: fallbackBaseagent },
1641
1634
  };
1642
1635
  }
@@ -1644,11 +1637,11 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1644
1637
  const usage = !groupSlash && !args && isAdmin ? '\n\n用法: /model <模型>' : '';
1645
1638
  return {
1646
1639
  kind: 'command.result',
1647
- text: `当前模型: ${modelDisplayLabel(modelAgent, currentModel)}${effortHint}${rawModels.includes(currentModel) ? '' : ' [当前配置,未列入目录]'}\n${catalogHint}\n\n可用模型:\n${modelList}${usage}`,
1640
+ text: `当前模型: ${currentModelLabel}${effortHint}${!currentModel || rawModels.includes(currentModel) ? '' : ' [当前配置,未列入目录]'}\n${catalogHint}\n\n可用模型:\n${modelList}${usage}`,
1648
1641
  ...(args === 'list' ? { structured: { ok: true, model: currentModel, effort: currentEffort, baseagent: fallbackBaseagent, models, revision: catalog.revision, source: catalog.source, freshness: catalog.freshness, diagnostics: catalog.diagnostics } } : {}),
1649
1642
  };
1650
1643
  }
1651
- return { kind: 'command.result', text: `当前模型: ${modelDisplayLabel(modelAgent, currentModel)}${effortHint}` };
1644
+ return { kind: 'command.result', text: `当前模型: ${currentModelLabel}${effortHint}` };
1652
1645
  }
1653
1646
  const modelSession = await getExistingSessionForCommand();
1654
1647
  const modelChatType = modelSession?.chatType
@@ -1661,13 +1654,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1661
1654
  const earlyUseAuthDenied = await authorizeIntent({
1662
1655
  intent: {
1663
1656
  operation: 'model.use',
1664
- scope: 'relation',
1657
+ scope: 'agent',
1665
1658
  source: 'slash',
1666
- args: buildSlashRelationIntentArgs({
1667
- args: { model: args.split(/\s+/)[0] },
1668
- selfAid: selfAID ?? this.resolveSelfAID(channel),
1669
- peerKey,
1670
- }),
1659
+ args: { self: selfAID ?? this.resolveSelfAID(channel), model: args.split(/\s+/)[0] },
1671
1660
  },
1672
1661
  identity,
1673
1662
  session: modelSession,
@@ -1684,21 +1673,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1684
1673
  text: earlyUseAuthDenied.text.includes('无权限') ? earlyUseAuthDenied.text : `❌ 无权限:${earlyUseAuthDenied.text}`,
1685
1674
  };
1686
1675
  }
1687
- // 切换模型写入 agent/baseagent 配置;没有活跃会话时也不应创建空会话。
1676
+ // 切换模型写入 Agent 级 baseagents 配置;没有活跃会话时也不应创建空会话。
1688
1677
  const fallbackBaseagent = modelSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
1689
1678
  const modelAgent = this.getAgent(channel, fallbackBaseagent);
1690
- const relationTarget = resolveSlashRelationTarget.call(this, {
1691
- session: modelSession,
1692
- channel,
1693
- channelId,
1694
- userId,
1695
- selfAID,
1696
- role: modelSession?.identity?.role || identity.role,
1697
- chatType: modelChatType,
1698
- });
1699
- const modelSelector = 'error' in relationTarget
1700
- ? { self: selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel) }
1701
- : relationTarget;
1679
+ const modelSelector = { self: selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel) };
1702
1680
  let configuredModel;
1703
1681
  try {
1704
1682
  configuredModel = (resolveEffective(modelSelector, { cache: true }).baseagents || {})[fallbackBaseagent]?.model;
@@ -1713,8 +1691,8 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1713
1691
  let newEffort;
1714
1692
  if (parts.length === 1) {
1715
1693
  const arg = parts[0];
1716
- const currentModel = hasModelSwitcher(modelAgent) ? (configuredModel || modelAgent.getModel()) : modelAgent.name;
1717
- const efforts = await getAvailableEfforts(modelAgent, currentModel);
1694
+ const currentModel = configuredModel ?? '';
1695
+ const efforts = currentModel ? await getAvailableEfforts(modelAgent, currentModel) : [];
1718
1696
  // effort 相关参数统一转发到 /effort
1719
1697
  if (efforts.includes(arg) || arg === 'auto') {
1720
1698
  const delegated = await this.handle(`/effort ${arg}`, channel, channelId, undefined, userId, threadId);
@@ -1755,25 +1733,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1755
1733
  newModel = modelArgRaw;
1756
1734
  newEffort = effortArg;
1757
1735
  }
1758
- // 优先写关系级覆盖;只有无法定位关系且具备管理权限时才回退到 runner/agent 级。
1759
1736
  if (newModel) {
1760
- const modelChatType = modelSession?.chatType
1761
- ?? (chatType === 'private' || chatType === 'group' ? chatType : undefined);
1762
- const peerKeyId = modelChatType === 'group'
1763
- ? (modelSession?.metadata?.groupId || channelId)
1764
- : userId;
1765
- const channelType = this.resolveChannelType(channel);
1766
- const peerKey = channelType && peerKeyId ? formatPeerKey(channelType, peerKeyId) : undefined;
1767
1737
  const useAuthDenied = await authorizeIntent({
1768
1738
  intent: {
1769
1739
  operation: 'model.use',
1770
- scope: 'relation',
1740
+ scope: 'agent',
1771
1741
  source: 'slash',
1772
- args: buildSlashRelationIntentArgs({
1773
- args: { model: newModel },
1774
- selfAid: selfAID ?? this.resolveSelfAID(channel),
1775
- peerKey,
1776
- }),
1742
+ args: { self: modelSelector.self, model: newModel },
1777
1743
  },
1778
1744
  identity,
1779
1745
  session: modelSession,
@@ -1801,78 +1767,32 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1801
1767
  // for configuration and replies, just like menu.update and local model use.
1802
1768
  }
1803
1769
  const changes = [];
1804
- if (!('error' in relationTarget)) {
1805
- try {
1806
- writeScope('relation', {
1807
- self: relationTarget.self,
1808
- peerKey: relationTarget.peerKey,
1809
- role: relationTarget.role,
1810
- }, modelAgent.name, {
1811
- model: newModel,
1812
- effort: newEffort,
1813
- });
1814
- }
1815
- catch (e) {
1816
- return { kind: 'command.error', text: `Failed to update relation model settings: ${e?.message || e}` };
1817
- }
1818
- if (newModel)
1819
- changes.push(`模型: ${newModel}`);
1820
- if (newEffort)
1821
- changes.push(`推理强度: ${newEffort}`);
1822
- this.eventBus.publish({
1823
- type: 'runner:model-changed',
1824
- sessionId: modelSession?.id,
1825
- agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
1826
- baseagent: modelSession?.baseagent || modelAgent.name,
1827
- model: newModel,
1828
- effort: newEffort,
1829
- timestamp: Date.now()
1830
- });
1831
- if (this.shouldSuppressCardTriggerResult(source, channel))
1832
- return null;
1833
- return { kind: 'command.result', text: `✓ 已切换\n ${changes.join('\n ')}` };
1770
+ const agentSelf = selfAID ?? modelSession?.selfAID ?? this.resolveSelfAID(channel);
1771
+ // 模型参数只在 Agent 级:直接写 Agent config,不再走关系级。
1772
+ // 鉴权已在 earlyUseAuthDenied 完成(agent scope, owner/admin only)。
1773
+ try {
1774
+ writeAgentModelConfig(agentSelf, modelAgent.name, { model: newModel ?? null, effort: newEffort ?? null });
1834
1775
  }
1835
- if (!isAdmin) {
1836
- return { kind: 'command.error', text: `Cannot locate relation scope: ${relationTarget.error}` };
1776
+ catch (e) {
1777
+ return { kind: 'command.error', text: `Failed to update Agent model settings: ${e?.message || e}` };
1837
1778
  }
1838
1779
  if (newModel) {
1839
1780
  modelAgent.setModel?.(newModel);
1840
- this.eventBus.publish({
1841
- type: 'runner:model-changed',
1842
- sessionId: modelSession?.id,
1843
- agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
1844
- baseagent: modelSession?.baseagent || modelAgent.name,
1845
- model: newModel,
1846
- effort: newEffort,
1847
- timestamp: Date.now()
1848
- });
1849
1781
  changes.push(`模型: ${newModel}`);
1850
1782
  }
1851
1783
  if (newEffort) {
1852
1784
  modelAgent.setEffort?.(newEffort);
1853
- if (!newModel) {
1854
- this.eventBus.publish({
1855
- type: 'runner:model-changed',
1856
- sessionId: modelSession?.id,
1857
- agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
1858
- baseagent: modelSession?.baseagent || modelAgent.name,
1859
- effort: newEffort,
1860
- timestamp: Date.now(),
1861
- });
1862
- }
1863
1785
  changes.push(`推理强度: ${newEffort}`);
1864
1786
  }
1865
- // 持久化:agent-owned channel 写到 agent.json;default 走原"就近原则"
1866
- if (newModel) {
1867
- const err = this.persistBaseagentModel(channel, modelAgent.name, newModel);
1868
- if (err)
1869
- return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
1870
- }
1871
- if (newEffort) {
1872
- const err = this.persistBaseagentEffort(channel, modelAgent.name, newEffort);
1873
- if (err)
1874
- return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
1875
- }
1787
+ this.eventBus.publish({
1788
+ type: 'runner:model-changed',
1789
+ sessionId: modelSession?.id,
1790
+ agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
1791
+ baseagent: modelSession?.baseagent || modelAgent.name,
1792
+ model: newModel,
1793
+ effort: newEffort,
1794
+ timestamp: Date.now(),
1795
+ });
1876
1796
  if (this.shouldSuppressCardTriggerResult(source, channel))
1877
1797
  return null;
1878
1798
  return { kind: 'command.result', text: `✓ 已切换\n ${changes.join('\n ')}` };
@@ -1884,18 +1804,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1884
1804
  const effortSession = await getExistingSessionForCommand();
1885
1805
  const fallbackBaseagent = effortSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
1886
1806
  const effortAgent = this.getAgent(channel, fallbackBaseagent);
1887
- const effortTarget = resolveSlashRelationTarget.call(this, {
1888
- session: effortSession,
1889
- channel,
1890
- channelId,
1891
- userId,
1892
- selfAID,
1893
- role: effortSession?.identity?.role || identity.role,
1894
- chatType,
1895
- });
1896
- const effortSelector = 'error' in effortTarget
1897
- ? { self: selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel) }
1898
- : effortTarget;
1807
+ const effortSelector = { self: selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel) };
1899
1808
  let modelConfig = {};
1900
1809
  try {
1901
1810
  modelConfig = (resolveEffective(effortSelector, { cache: true }).baseagents || {})[fallbackBaseagent] || {};
@@ -1903,9 +1812,12 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1903
1812
  catch { }
1904
1813
  const configuredModel = modelConfig.model;
1905
1814
  const configuredEffort = modelConfig.effort;
1906
- const currentModel = hasModelSwitcher(effortAgent) ? (configuredModel || effortAgent.getModel()) : effortAgent.name;
1815
+ if (!configuredModel) {
1816
+ return { kind: 'command.error', text: '⚠️ 当前 Agent 未配置模型,请 owner/admin 先用 /model 设置模型' };
1817
+ }
1818
+ const currentModel = configuredModel;
1907
1819
  const efforts = await getAvailableEfforts(effortAgent, currentModel);
1908
- const currentEffort = configuredEffort ?? effortAgent.getEffort?.() ?? 'auto';
1820
+ const currentEffort = configuredEffort ?? 'auto';
1909
1821
  if (efforts.length === 0) {
1910
1822
  return { kind: 'command.error', text: '⚠️ 当前模型不支持推理强度设置' };
1911
1823
  }
@@ -1946,63 +1858,49 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
1946
1858
  const effortSession = await getExistingSessionForCommand();
1947
1859
  const fallbackBaseagent = effortSession?.baseagent || this.agentRegistry?.resolveByChannel(channel)?.baseagent || this.parseDefaultBaseagent();
1948
1860
  const effortAgent = this.getAgent(channel, fallbackBaseagent);
1949
- const relationTarget = resolveSlashRelationTarget.call(this, {
1950
- session: effortSession,
1951
- channel,
1952
- channelId,
1953
- userId,
1954
- selfAID,
1955
- role: effortSession?.identity?.role || identity.role,
1956
- chatType,
1957
- });
1958
- const effortSelector = 'error' in relationTarget
1959
- ? { self: selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel) }
1960
- : relationTarget;
1861
+ const effortSelf = selfAID ?? effortSession?.selfAID ?? this.resolveSelfAID(channel);
1961
1862
  let modelConfig = {};
1962
1863
  try {
1963
- modelConfig = (resolveEffective(effortSelector, { cache: true }).baseagents || {})[fallbackBaseagent] || {};
1864
+ modelConfig = (resolveEffective({ self: effortSelf }, { cache: true }).baseagents || {})[fallbackBaseagent] || {};
1964
1865
  }
1965
1866
  catch { }
1966
1867
  const configuredModel = modelConfig.model;
1967
- const configuredEffort = modelConfig.effort;
1968
- const currentModel = hasModelSwitcher(effortAgent) ? (configuredModel || effortAgent.getModel()) : effortAgent.name;
1868
+ if (!configuredModel) {
1869
+ return { kind: 'command.error', text: '⚠️ 当前 Agent 未配置模型,请 owner/admin 先用 /model 设置模型' };
1870
+ }
1871
+ const currentModel = configuredModel;
1969
1872
  const efforts = await getAvailableEfforts(effortAgent, currentModel);
1970
- const currentEffort = configuredEffort ?? effortAgent.getEffort?.() ?? 'auto';
1971
1873
  if (efforts.length === 0) {
1972
1874
  return { kind: 'command.error', text: '⚠️ 当前模型不支持推理强度设置' };
1973
1875
  }
1974
- // Non-admin users write effort overrides to their relation scope below.
1975
- // /effort auto:恢复 SDK 默认
1876
+ // 模型参数只在 Agent 级:写操作按 agent scope 鉴权(owner/admin)。
1877
+ const effortAuthDenied = await authorizeIntent({
1878
+ intent: {
1879
+ operation: 'model.effort',
1880
+ scope: 'agent',
1881
+ source: 'slash',
1882
+ args: { self: effortSelf, effort: args },
1883
+ },
1884
+ identity,
1885
+ session: effortSession,
1886
+ explicitChatType: effortSession?.chatType,
1887
+ channel,
1888
+ channelId,
1889
+ userId,
1890
+ selfAid: effortSelf,
1891
+ isDaemonOwner,
1892
+ });
1893
+ if (effortAuthDenied)
1894
+ return effortAuthDenied;
1895
+ // /effort auto:清除 Agent 级 effort(恢复 SDK 默认)
1976
1896
  if (args === 'auto') {
1977
- if (!('error' in relationTarget)) {
1978
- try {
1979
- writeScope('relation', {
1980
- self: relationTarget.self,
1981
- peerKey: relationTarget.peerKey,
1982
- role: relationTarget.role,
1983
- }, effortAgent.name, { effort: null });
1984
- }
1985
- catch (e) {
1986
- return { kind: 'command.error', text: `Failed to update relation effort: ${e?.message || e}` };
1987
- }
1988
- this.eventBus.publish({
1989
- type: 'runner:model-changed',
1990
- sessionId: effortSession?.id,
1991
- agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
1992
- baseagent: effortSession?.baseagent || effortAgent.name,
1993
- effort: 'auto',
1994
- timestamp: Date.now(),
1995
- });
1996
- if (this.shouldSuppressCardTriggerResult(source, channel))
1997
- return null;
1998
- return { kind: 'command.result', text: '✓ 推理强度已恢复为 auto (SDK默认)' };
1897
+ try {
1898
+ writeAgentModelConfig(effortSelf, effortAgent.name, { effort: null });
1899
+ }
1900
+ catch (e) {
1901
+ return { kind: 'command.error', text: `Failed to clear Agent effort: ${e?.message || e}` };
1999
1902
  }
2000
- if (!isAdmin)
2001
- return { kind: 'command.error', text: `Cannot locate relation scope: ${relationTarget.error}` };
2002
1903
  effortAgent.setEffort?.(undefined);
2003
- const err = this.persistBaseagentEffort(channel, effortAgent.name, undefined);
2004
- if (err)
2005
- return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
2006
1904
  this.eventBus.publish({
2007
1905
  type: 'runner:model-changed',
2008
1906
  sessionId: effortSession?.id,
@@ -2023,35 +1921,13 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2023
1921
  return { kind: 'command.error', text: `❌ 无效参数: ${args}\n可选: ${efforts.join(' / ')} / auto` };
2024
1922
  }
2025
1923
  const newEffort = args;
2026
- if (!('error' in relationTarget)) {
2027
- try {
2028
- writeScope('relation', {
2029
- self: relationTarget.self,
2030
- peerKey: relationTarget.peerKey,
2031
- role: relationTarget.role,
2032
- }, effortAgent.name, { effort: newEffort });
2033
- }
2034
- catch (e) {
2035
- return { kind: 'command.error', text: `Failed to update relation effort: ${e?.message || e}` };
2036
- }
2037
- this.eventBus.publish({
2038
- type: 'runner:model-changed',
2039
- sessionId: effortSession?.id,
2040
- agentName: this.agentRegistry?.resolveByChannel(channel)?.name,
2041
- baseagent: effortSession?.baseagent || effortAgent.name,
2042
- effort: newEffort,
2043
- timestamp: Date.now(),
2044
- });
2045
- if (this.shouldSuppressCardTriggerResult(source, channel))
2046
- return null;
2047
- return { kind: 'command.result', text: `✓ 推理强度: ${newEffort}` };
1924
+ try {
1925
+ writeAgentModelConfig(effortSelf, effortAgent.name, { effort: newEffort });
1926
+ }
1927
+ catch (e) {
1928
+ return { kind: 'command.error', text: `Failed to update Agent effort: ${e?.message || e}` };
2048
1929
  }
2049
- if (!isAdmin)
2050
- return { kind: 'command.error', text: `Cannot locate relation scope: ${relationTarget.error}` };
2051
1930
  effortAgent.setEffort?.(newEffort);
2052
- const err = this.persistBaseagentEffort(channel, effortAgent.name, newEffort);
2053
- if (err)
2054
- return { kind: 'command.result', text: `${err}\n已更新运行时配置,但未持久化` };
2055
1931
  this.eventBus.publish({
2056
1932
  type: 'runner:model-changed',
2057
1933
  sessionId: effortSession?.id,
@@ -2636,6 +2512,9 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
2636
2512
  catch {
2637
2513
  compactConfig = {};
2638
2514
  }
2515
+ if (typeof compactConfig.model !== 'string' || !compactConfig.model.trim()) {
2516
+ return { kind: 'command.error', text: `⚠️ 当前 Agent 未配置模型(baseagents.${compactBaseagent}.model),无法压缩。请 owner/admin 先用 /model 设置模型。` };
2517
+ }
2639
2518
  const compactModelDecision = constrainResolvedModelForRole({
2640
2519
  role: session.identity?.role || identity.role,
2641
2520
  baseagent: compactBaseagent,
@@ -3174,12 +3053,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
3174
3053
  }
3175
3054
  // Archiving only changes list visibility; pending work must still be checked.
3176
3055
  const allSessions = await this.sessionManager.listSessions(channel, channelId, { archiveFilter: 'all' });
3177
- const sessionsWithMessages = allSessions
3178
- .filter((s) => this.messageCache.hasMessages(s.id))
3179
- .map((s) => {
3180
- const count = this.messageCache.getCount(s.id);
3181
- return `${s.projectPath} 有 ${count} 条新消息`;
3182
- });
3056
+ const pendingResultCount = allSessions.reduce((count, session) => count + this.messageCache.getCount(session.id), 0);
3183
3057
  const executeRestart = async () => {
3184
3058
  const suppressRealRestart = shouldSuppressRealRestart();
3185
3059
  let restartReplyContext = replyContext;
@@ -3347,26 +3221,20 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
3347
3221
  return true;
3348
3222
  };
3349
3223
  // 文本确认流程
3350
- if (sessionsWithMessages.length > 0) {
3351
- const restartKey = `${channel}-${channelId}`;
3352
- const controlDir = daemonControlDir();
3224
+ const restartKey = `${channel}-${channelId}`;
3225
+ const controlDir = daemonControlDir();
3226
+ const restartConfirmFile = path.join(controlDir, `restart-confirm-${restartKey}.json`);
3227
+ if (fs.existsSync(restartConfirmFile)) {
3228
+ // 确认不设有效期;即使后台结果已读,下一次 /restart 也会消费确认。
3229
+ fs.unlinkSync(restartConfirmFile);
3230
+ }
3231
+ else if (pendingResultCount > 0) {
3353
3232
  fs.mkdirSync(controlDir, { recursive: true });
3354
- const restartConfirmFile = path.join(controlDir, `restart-confirm-${restartKey}.json`);
3355
- if (fs.existsSync(restartConfirmFile)) {
3356
- const confirmInfo = JSON.parse(fs.readFileSync(restartConfirmFile, 'utf-8'));
3357
- const now = Date.now();
3358
- if (now - confirmInfo.timestamp < 10000) {
3359
- fs.unlinkSync(restartConfirmFile);
3360
- }
3361
- else {
3362
- fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: now }));
3363
- return { kind: 'command.result', text: sessionsWithMessages.join('\n') + '\n再次输入 /restart 将强制重启。' };
3364
- }
3365
- }
3366
- else {
3367
- fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: Date.now() }));
3368
- return { kind: 'command.result', text: sessionsWithMessages.join('\n') + '\n再次输入 /restart 将强制重启。' };
3369
- }
3233
+ fs.writeFileSync(restartConfirmFile, JSON.stringify({ timestamp: Date.now() }));
3234
+ return {
3235
+ kind: 'command.result',
3236
+ text: `当前Agent对话有 ${pendingResultCount} 条后台结果待查看。再次输入 /restart 将强制重启服务。`,
3237
+ };
3370
3238
  }
3371
3239
  const restarted = await executeRestart();
3372
3240
  if (typeof restarted === 'object' && restarted.code === 'RESTART_ENTRY_MISSING') {
@@ -4149,6 +4017,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
4149
4017
  isAdmin,
4150
4018
  isOwnerSelf: isOwner && !!memoryOwnerAid && (authSubject.principalId ?? userId) === memoryOwnerAid,
4151
4019
  ownerAid: memoryOwnerAid,
4020
+ actorAid: authSubject.principalId ?? userId,
4152
4021
  memoryConfig: memoryAgent?.config?.memory,
4153
4022
  channelType: authSubject.channelType,
4154
4023
  peerId: activeChatType === 'group' ? channelId : (userId ?? channelId),