evolcore 0.0.49 → 0.0.50

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 (250) hide show
  1. package/CHANGELOG.md +64 -1
  2. package/bin/ecmsg.js +9 -4
  3. package/dist/ability/caller/authorization.js +21 -0
  4. package/dist/ability/caller/command.js +164 -0
  5. package/dist/ability/caller/contract.js +102 -0
  6. package/dist/ability/caller/daemon.js +158 -0
  7. package/dist/ability/caller/service.js +380 -0
  8. package/dist/ability/command-contract.js +5 -0
  9. package/dist/ability/daemon.js +5 -1
  10. package/dist/ability/interop-v1.js +10 -3
  11. package/dist/ability/management.js +1 -0
  12. package/dist/agent-template/jobs.js +173 -1
  13. package/dist/agent-template/runtime.js +280 -6
  14. package/dist/agent-template/service.js +1159 -40
  15. package/dist/agent-template/types.js +2 -1
  16. package/dist/agents/baseagent-availability.js +27 -3
  17. package/dist/agents/baseagent-capability-adapter.js +102 -0
  18. package/dist/agents/baseagent-plugin-descriptor.js +274 -0
  19. package/dist/agents/baseagent-plugin-loader.js +145 -0
  20. package/dist/agents/baseagent.js +68 -2
  21. package/dist/agents/claude-gateway/agent-registration.js +389 -0
  22. package/dist/agents/claude-gateway/binding.js +96 -0
  23. package/dist/agents/claude-gateway/inbox.js +138 -0
  24. package/dist/agents/claude-gateway/index.js +125 -0
  25. package/dist/agents/claude-gateway/listing.js +330 -0
  26. package/dist/agents/claude-gateway/router.js +328 -0
  27. package/dist/agents/claude-gateway/sessions.js +128 -0
  28. package/dist/agents/claude-gateway/terminal.js +250 -0
  29. package/dist/agents/claude-gateway/transcript.js +272 -0
  30. package/dist/agents/claude-gateway/types.js +14 -0
  31. package/dist/agents/claude-runner.js +6 -10
  32. package/dist/agents/codex-runner.js +4 -1
  33. package/dist/agents/{gemini-runner.js → gemini/gemini-runner.js} +17 -17
  34. package/dist/{core/session/adapters → agents/gemini}/gemini-session-file-adapter.js +2 -2
  35. package/dist/agents/gemini/index.js +51 -0
  36. package/dist/aun/aid/control-aid.js +52 -32
  37. package/dist/aun/group/invite-service.js +6 -36
  38. package/dist/aun/group/operations.js +6 -0
  39. package/dist/aun/msg/mention-schema.js +1 -1
  40. package/dist/aun/msg/p2p.js +29 -1
  41. package/dist/aun/msg/upload.js +126 -3
  42. package/dist/build-identity.json +1 -1
  43. package/dist/channels/aun.js +537 -189
  44. package/dist/cli/ability-command.js +42 -0
  45. package/dist/cli/agent-command.js +20 -1
  46. package/dist/cli/agent-create.js +78 -18
  47. package/dist/cli/agent-template.js +5 -3
  48. package/dist/cli/agent.js +91 -0
  49. package/dist/cli/aun-commands.js +92 -34
  50. package/dist/cli/bench.js +5 -2
  51. package/dist/cli/config.js +22 -6
  52. package/dist/cli/daemon-commands.js +245 -101
  53. package/dist/cli/ecmsg-gateway.js +11 -9
  54. package/dist/cli/index.js +23 -4
  55. package/dist/cli/init.js +39 -63
  56. package/dist/cli/managed-command-guard.js +1 -0
  57. package/dist/cli/menu-client.js +32 -7
  58. package/dist/cli/pay-command.js +30 -0
  59. package/dist/cli/provider-command.js +6 -2
  60. package/dist/cli/restart-monitor.js +2 -2
  61. package/dist/cli/services-command.js +11 -9
  62. package/dist/cli/thread-command.js +78 -12
  63. package/dist/config/access-policy.js +16 -3
  64. package/dist/config/config-field-policy.js +17 -8
  65. package/dist/config/config-manager.js +86 -46
  66. package/dist/config/config-operation-service.js +22 -1
  67. package/dist/config/gateway-config.js +9 -8
  68. package/dist/config/owner-config.js +0 -16
  69. package/dist/config/peer-role-resolver.js +1 -7
  70. package/dist/config/providers-config.js +99 -16
  71. package/dist/config/providers-management.js +35 -19
  72. package/dist/config/resolved-config-op.js +1 -42
  73. package/dist/config/schema-migration.js +78 -5
  74. package/dist/config/schema-registry.js +52 -7
  75. package/dist/config-store.js +1309 -17
  76. package/dist/core/agent-application-service.js +220 -1
  77. package/dist/core/agent-ipc-registration.js +19 -2
  78. package/dist/core/agent-reload-coordinator.js +5 -0
  79. package/dist/core/agent-runtime.js +198 -54
  80. package/dist/core/auth/agent-delegation.js +14 -0
  81. package/dist/core/auth/operation-authorizer.js +16 -1
  82. package/dist/core/auth/operation-catalog.js +50 -7
  83. package/dist/core/baseagent-loader.js +30 -3
  84. package/dist/core/capability/capability-manager.js +16 -7
  85. package/dist/core/channel-runtime.js +4 -2
  86. package/dist/core/command/agent-control.js +20 -2
  87. package/dist/core/command/agent-template-menu.js +4 -3
  88. package/dist/core/command/cli-intent-parser.js +15 -0
  89. package/dist/core/command/menu-catalog.js +20 -4
  90. package/dist/core/command/menu-file-path.js +70 -0
  91. package/dist/core/command/menu-handler.js +91 -72
  92. package/dist/core/command/menu-protocol.js +5 -0
  93. package/dist/core/command/menu-query-batch.js +2 -2
  94. package/dist/core/command/private-mention-menu.js +71 -0
  95. package/dist/core/command/slash-handler.js +17 -26
  96. package/dist/core/command/team-workspace-bootstrap.js +2 -1
  97. package/dist/core/command/topic-slash.js +7 -1
  98. package/dist/core/daemon-bootstrap.js +0 -4
  99. package/dist/core/daemon-control.js +2 -1
  100. package/dist/core/daemon-lifecycle.js +13 -5
  101. package/dist/core/evolagent-registry.js +12 -7
  102. package/dist/core/handoff/runtime.js +1 -1
  103. package/dist/core/host-snapshot.js +8 -3
  104. package/dist/core/initialization/service.js +3 -0
  105. package/dist/core/interaction-router.js +130 -0
  106. package/dist/core/ipc-registration.js +4 -0
  107. package/dist/core/memory/consolidation-context.js +2 -1
  108. package/dist/core/memory/consolidation.js +35 -64
  109. package/dist/core/message/aun-ipc-sender.js +98 -21
  110. package/dist/core/message/aun-request-registry.js +31 -0
  111. package/dist/core/message/message-bridge.js +105 -6
  112. package/dist/core/message/message-log.js +8 -0
  113. package/dist/core/message/message-queue.js +5 -3
  114. package/dist/core/message/peer-mode.js +15 -4
  115. package/dist/core/message/response-engine.js +23 -8
  116. package/dist/core/message/send-options.js +37 -3
  117. package/dist/core/message/send-routing.js +11 -7
  118. package/dist/core/model/model-catalog.js +5 -5
  119. package/dist/core/ownership/owner-resolver.js +12 -86
  120. package/dist/core/pack-auth.js +4 -0
  121. package/dist/core/permission/ec-command-parser.js +182 -58
  122. package/dist/core/permission/protected-paths.js +64 -9
  123. package/dist/core/permission/services-path-acl.js +9 -2
  124. package/dist/core/permission/tool-policy.js +21 -9
  125. package/dist/core/session/adapters/claude-session-file-adapter.js +6 -2
  126. package/dist/core/session/adapters/codex-session-file-adapter.js +4 -0
  127. package/dist/core/session/session-manager.js +47 -10
  128. package/dist/core/session/session-mapper.js +16 -0
  129. package/dist/core/skill/index-generator.js +2 -3
  130. package/dist/core/skill/switch-resolver.js +3 -0
  131. package/dist/core/thread/command-parser.js +4 -1
  132. package/dist/core/thread/ipc-operation.js +4 -2
  133. package/dist/core/thread/thread-operation.js +25 -10
  134. package/dist/core/thread/thread-service.js +294 -55
  135. package/dist/core/thread/topic-id.js +52 -2
  136. package/dist/core/thread/types.js +15 -1
  137. package/dist/eck/kit-renderer.js +2 -1
  138. package/dist/ecweb/basic-settings-service.js +5 -9
  139. package/dist/ecweb/providers-service.js +4 -2
  140. package/dist/index.js +116 -41
  141. package/dist/ipc.js +58 -2
  142. package/dist/paths.js +48 -1
  143. package/dist/pay/command.js +38 -0
  144. package/dist/pay/protocol.js +136 -0
  145. package/dist/pay/runtime.js +188 -0
  146. package/dist/pay/service.js +384 -0
  147. package/dist/pay/store.js +81 -0
  148. package/dist/response-system/engines/v1/proactive-flow.js +29 -2
  149. package/dist/services/dispatcher.js +23 -5
  150. package/dist/services/host/main.js +388 -0
  151. package/dist/services/host/protocol.js +118 -0
  152. package/dist/services/host/resident.js +310 -0
  153. package/dist/services/host-client.js +386 -0
  154. package/dist/services/host-deploy.js +180 -0
  155. package/dist/services/host-launch.js +117 -0
  156. package/dist/services/host-recycle.js +203 -0
  157. package/dist/services/host-runtime.js +802 -0
  158. package/dist/services/idempotency.js +44 -86
  159. package/dist/services/index-generator.js +4 -3
  160. package/dist/services/index.js +176 -18
  161. package/dist/services/ipc-operation.js +204 -44
  162. package/dist/services/script-runner.js +515 -83
  163. package/dist/services/validation.js +109 -4
  164. package/dist/trigger/application-service.js +6 -4
  165. package/dist/trigger/local-files.js +19 -9
  166. package/dist/trigger/scheduler.js +22 -12
  167. package/dist/trigger/script-sandbox.js +51 -20
  168. package/dist/utils/aid-bind.js +3 -0
  169. package/dist/utils/evolcore-version.js +2 -2
  170. package/dist/utils/host-info.js +73 -0
  171. package/dist/utils/logger.js +2 -2
  172. package/dist/utils/media-cache.js +190 -43
  173. package/dist/utils/restart-safety.js +14 -1
  174. package/dist/utils/system-memory.js +113 -25
  175. package/dist/utils/systemd-lifecycle.js +154 -0
  176. package/dist/utils/windows-shell-trust.js +7 -3
  177. package/kits/docs/INDEX.md +3 -2
  178. package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +1 -0
  179. package/kits/docs/channels/aun.md +1 -1
  180. package/kits/docs/evolcore/INDEX.md +7 -6
  181. package/kits/docs/evolcore/agent.md +36 -1
  182. package/kits/docs/evolcore/aid.md +20 -3
  183. package/kits/docs/evolcore/config.md +1 -1
  184. package/kits/docs/evolcore/group.md +2 -1
  185. package/kits/docs/evolcore/memory-tags.md +2 -0
  186. package/kits/docs/evolcore/menu-client.md +3 -3
  187. package/kits/docs/evolcore/menu-protocol.md +7 -0
  188. package/kits/docs/evolcore/model.md +3 -0
  189. package/kits/docs/evolcore/msg.md +68 -10
  190. package/kits/docs/evolcore/pay.md +34 -0
  191. package/kits/docs/evolcore/provider.md +21 -0
  192. package/kits/docs/evolcore/services.md +46 -18
  193. package/kits/docs/evolcore/thread-chain.md +2 -0
  194. package/kits/docs/evolcore/tool-authorization.md +10 -0
  195. package/kits/rules/01-overview.md +11 -32
  196. package/kits/rules/02-navigation.md +7 -0
  197. package/kits/rules/06-channel.md +3 -3
  198. package/kits/schemas/_meta.json +38 -5
  199. package/kits/schemas/agent-config.schema.21.json +974 -0
  200. package/kits/schemas/agent-config.schema.22.json +977 -0
  201. package/kits/schemas/agent-config.schema.23.json +958 -0
  202. package/kits/schemas/daemon.schema.10.json +373 -0
  203. package/kits/schemas/daemon.schema.9.json +12 -0
  204. package/kits/schemas/defaults.schema.7.json +472 -0
  205. package/kits/schemas/providers.schema.3.json +18 -2
  206. package/kits/schemas/relation-config.schema.13.json +289 -0
  207. package/kits/skills/.switches.json +13 -1
  208. package/kits/skills/ability/SKILL.md +229 -34
  209. package/kits/skills/ability/STRUCTURE.md +333 -0
  210. package/kits/skills/ability/references/cli.md +208 -0
  211. package/kits/skills/ability/references/development.md +107 -37
  212. package/kits/skills/ability/references/management.md +106 -46
  213. package/kits/skills/ability/references/runtime-protocol.md +65 -63
  214. package/kits/skills/agent-output-cards/SKILL.md +12 -5
  215. package/kits/skills/ec-group/SKILL.md +8 -6
  216. package/kits/skills/ec-group/TASK.md +186 -0
  217. package/kits/skills/ec-group/WORKLOG.md +180 -0
  218. package/kits/skills/ec-group-collaboration/SKILL.md +3 -3
  219. package/kits/skills/ec-pay/SKILL.md +101 -0
  220. package/kits/skills/ec-pay/references/pay-cli.md +110 -0
  221. package/kits/skills/ec-provider/SKILL.md +1 -1
  222. package/kits/skills/{ec-service-proxy → ec-proxy}/SKILL.md +8 -5
  223. package/kits/skills/ec-service-call/SKILL.md +135 -0
  224. package/kits/skills/ec-service-pack/SKILL.md +277 -0
  225. package/kits/skills/ec-trigger/SKILL.md +1 -1
  226. package/kits/templates/memory-consolidation/notes.md +2 -2
  227. package/kits/templates/memory-consolidation/workflow.md +46 -0
  228. package/kits/templates/system-fragments/channel.md +13 -4
  229. package/kits/templates/system-fragments/commands.md +4 -3
  230. package/kits/templates/system-fragments/reply.md +1 -0
  231. package/kits/templates/system-fragments/session.md +1 -1
  232. package/kits/templates/system-fragments/thread.md +27 -129
  233. package/kits/templates/system-fragments/venue.md +16 -0
  234. package/package.json +4 -5
  235. package/scripts/agent-template/inspect.mjs +37 -23
  236. package/scripts/agent-template/overlay.mjs +20 -2
  237. package/scripts/agent-template/shared/common.mjs +16 -4
  238. package/scripts/agent-template/shared/team-schema.json +20 -4
  239. package/scripts/agent-template/shared/template-contract.mjs +53 -13
  240. package/scripts/agent-template/shared/template-package.mjs +90 -26
  241. package/scripts/agent-template/shared/template-runtime.mjs +111 -1
  242. package/scripts/agent-template/shared/template.mjs +65 -7
  243. package/scripts/agent-template/team-pack.mjs +89 -33
  244. package/scripts/agent-template/team-preview.mjs +249 -5
  245. package/kits/docs/aun/ABILITY_CALLING.md +0 -280
  246. package/kits/docs/evolcore/ability.md +0 -185
  247. package/kits/skills/ability/references/calling.md +0 -56
  248. package/kits/skills/ability/references/contract-checklist.md +0 -37
  249. package/kits/skills/ability/references/recovery.md +0 -27
  250. /package/dist/{core/capability/providers → agents/gemini}/gemini-capability-provider.js +0 -0
@@ -727,6 +727,23 @@ async function runCreateInBackground(opts, w, service) {
727
727
  * 调用方负责传入已兜底的 args.project(见 command-handler 装配)。 */
728
728
  export async function execAgentAction(action, args, peerId, eventBus, service, subject) {
729
729
  const a = args ?? {};
730
+ if (action === 'project') {
731
+ if (!service || !subject?.isDaemonOwner || !subject.fromControlChannel && !subject.ecwebManagement) {
732
+ return { error: 'Project changes require DaemonOwner management context', code: 'NOT_ALLOWED' };
733
+ }
734
+ if (!subject.ecwebManagement && subject.menuEncrypted !== true) {
735
+ return { error: 'Remote project changes require encryption', code: 'NOT_ALLOWED' };
736
+ }
737
+ if (typeof a.aid !== 'string' || !isValidAid(a.aid))
738
+ return { error: 'Invalid Agent AID', code: 'INVALID_ARGUMENT' };
739
+ const { ownerResolver } = await import('../ownership/owner-resolver.js');
740
+ const ownership = await ownerResolver.refreshForAuthorization(a.aid);
741
+ if (ownership.refreshFailure || ownership.consensusStatus !== 'consensus' || ownership.ownerAid !== peerId) {
742
+ return { error: 'Fresh Agent Owner consensus is required', code: 'NOT_ALLOWED' };
743
+ }
744
+ const result = await service.project(a.aid, peerId, a);
745
+ return result.ok ? { data: result } : { error: result.error, code: result.code ?? 'PROJECT_CHANGE_FAILED' };
746
+ }
730
747
  if (action === 'set-access') {
731
748
  const resources = ['allowInternalContacts', 'allowExternalContacts', 'allowAllContacts', 'allowedAids', 'deniedAids', 'requestLimit'];
732
749
  if (!isValidAid(a.aid ?? '') || !resources.includes(a.resource)
@@ -1276,8 +1293,9 @@ export async function execAgentQuery(args, service, subject, runtime) {
1276
1293
  active_baseagent: safeAgentConfig.active_baseagent ?? res.config?.baseagent ?? null,
1277
1294
  projects: safeAgentConfig.projects ?? {},
1278
1295
  baseagents: safeAgentConfig.baseagents ?? {},
1279
- owner: safeConfig ? safeAgentConfig.owner : res.config?.owner ?? null,
1280
- owners: safeAgentConfig.owners ?? res.config?.owners ?? [],
1296
+ // Owner is protocol-only now; there is no configured fallback to display.
1297
+ owner: ownerResolver.knownOwner(aid) ?? null,
1298
+ owners: ownerResolver.knownOwners(aid),
1281
1299
  },
1282
1300
  safeConfig,
1283
1301
  ownership: {
@@ -13,10 +13,10 @@ export function templateMenuAction(request) {
13
13
  const args = { ...request.args };
14
14
  let action = request.action;
15
15
  if (request.type === 'menu.query') {
16
- action = args.view === 'job' ? 'status' : args.view === 'capabilities' ? 'capabilities' : undefined;
16
+ action = args.view === 'job' ? 'status' : ['capabilities', 'team-members', 'update-status'].includes(args.view) ? args.view : undefined;
17
17
  delete args.view;
18
18
  }
19
- else if (request.type !== 'menu.action' || ['status', 'capabilities'].includes(action)) {
19
+ else if (request.type !== 'menu.action' || ['status', 'capabilities', 'team-members', 'update-status'].includes(action)) {
20
20
  throw templateError('INVALID_ARGUMENT', 'Use the defined template Menu action or query');
21
21
  }
22
22
  if (!TEMPLATE_ACTIONS.includes(action))
@@ -35,7 +35,8 @@ export function validateTemplateRequest(request) {
35
35
  return null;
36
36
  }
37
37
  catch (error) {
38
- return { code: 'INVALID_ARGUMENT', message: error.message };
38
+ return { code: 'INVALID_ARGUMENT', message: error.message,
39
+ ...(error.details ? { data: error.details } : {}) };
39
40
  }
40
41
  }
41
42
  export async function executeTemplateMenu(request, subject, source) {
@@ -217,6 +217,21 @@ function parseStatsCommand(argv, source) {
217
217
  }
218
218
  function parseAgentCommand(argv, source) {
219
219
  const subcmd = argv[1];
220
+ if (subcmd === 'stop' || subcmd === 'start') {
221
+ const parsed = parseArgs(argv.slice(2));
222
+ const [aid] = parsed.positionals;
223
+ if (!aid || parsed.positionals.length !== 1)
224
+ return raw(source, argv, 'An Agent AID is required');
225
+ return recognized('agent.' + subcmd, 'process', source, { ...parsed.args, aid }, argv, true);
226
+ }
227
+ if (subcmd === 'project') {
228
+ const parsed = parseArgs(argv.slice(2));
229
+ const [aid, operation] = parsed.positionals;
230
+ if (!aid || !['preview', 'move', 'status', 'recover', 'resolve'].includes(operation)
231
+ || parsed.positionals.length !== 2)
232
+ return raw(source, argv, 'Invalid Agent project command');
233
+ return recognized('agent.project.' + operation, 'process', source, { ...parsed.args, aid }, argv, true);
234
+ }
220
235
  let createMode;
221
236
  if (subcmd === 'new') {
222
237
  try {
@@ -115,6 +115,11 @@ const ENTRIES = [
115
115
  { id: 'chatmode.agent.group', type: 'setting', contexts: ['agent'], name: 'chatmode', label: 'Agent 群聊模式', section: 'agent', order: 42, query: { cmd: '/chatmode', args: { scope: 'agent', field: 'group' }, operation: 'chatmode.current', scope: 'agent' }, options: { cmd: '/chatmode', args: { scope: 'agent', field: 'group' }, operation: 'chatmode.current', scope: 'agent' }, update: { cmd: '/chatmode', args: { scope: 'agent', field: 'group' }, operation: 'chatmode.update', scope: 'agent' }, control: 'select' },
116
116
  { id: 'chatmode.agent.nothuman', type: 'setting', contexts: ['agent'], name: 'chatmode', label: 'Agent 非人类对话模式', section: 'agent', order: 43, query: { cmd: '/chatmode', args: { scope: 'agent', field: 'nothuman' }, operation: 'chatmode.current', scope: 'agent' }, options: { cmd: '/chatmode', args: { scope: 'agent', field: 'nothuman' }, operation: 'chatmode.current', scope: 'agent' }, update: { cmd: '/chatmode', args: { scope: 'agent', field: 'nothuman' }, operation: 'chatmode.update', scope: 'agent' }, control: 'select' },
117
117
  { id: 'activity.agent', type: 'setting', contexts: ['agent'], name: 'activity', label: 'Agent 中间输出', section: 'agent', order: 50, query: { cmd: '/activity', args: { scope: 'agent' }, operation: 'activity.current', scope: 'agent' }, options: { cmd: '/activity', args: { scope: 'agent' }, operation: 'activity.current', scope: 'agent' }, update: { cmd: '/activity', args: { scope: 'agent' }, operation: 'activity.update', scope: 'agent' }, control: 'select' },
118
+ { id: 'privateMentionMode.agent', type: 'setting', contexts: ['agent'], name: 'private-mention-mode', label: '私聊提及模式', section: 'agent', order: 55,
119
+ query: { cmd: '/private-mention-mode', args: { scope: 'agent' }, operation: 'privatementionmode.current', scope: 'agent' },
120
+ options: { cmd: '/private-mention-mode', args: { scope: 'agent' }, operation: 'privatementionmode.current', scope: 'agent', mode: 'dynamic' },
121
+ update: { cmd: '/private-mention-mode', args: { scope: 'agent' }, operation: 'privatementionmode.update', scope: 'agent' },
122
+ valueSchema: { type: 'string', enum: ['disabled', 'mention-only'] }, control: 'select' },
118
123
  { id: 'observable.agent', type: 'setting', contexts: ['agent'], name: 'observable', label: '观察模式', section: 'agent', order: 60, query: { cmd: '/observable', operation: 'observable.current', scope: 'agent' }, update: { cmd: '/observable', operation: 'observable.update', scope: 'agent' }, valueSchema: { type: 'boolean' }, control: 'toggle' },
119
124
  { id: 'aid.avatar', type: 'action', contexts: ['agent'], name: 'aid', label: '更换头像', section: 'agent', order: 70, action: { cmd: '/aid', action: 'avatar', operation: 'ec.aid.avatar', scope: 'agent' }, valueSchema: { type: 'object', properties: { data: { type: 'string' }, url: { type: 'string', format: 'uri' } }, oneOf: [{ required: ['data'] }, { required: ['url'] }] }, control: 'action' },
120
125
  { id: 'aid.agentmd', type: 'setting', contexts: ['agent'], name: 'aid', label: 'AgentMD', section: 'agent', order: 71,
@@ -144,14 +149,22 @@ const ENTRIES = [
144
149
  { id: 'agent.create', type: 'action', contexts: ['process'], name: 'agent', label: '创建 Agent', section: 'process', order: 50, action: { cmd: '/agent', action: 'create', operation: 'agent.create', scope: 'control' } },
145
150
  { id: 'agent.initialize', type: 'action', contexts: ['process'], name: 'agent', label: '初始化 Agent', section: 'process', order: 55, action: { cmd: '/agent', action: 'initialize', operation: 'agent.initialize', scope: 'control' } },
146
151
  { id: 'agent.reload', type: 'action', contexts: ['process'], name: 'agent', label: '重载 Agent', section: 'process', order: 60, action: { cmd: '/agent', action: 'reload', operation: 'agent.reload', scope: 'control' } },
147
- ...['inspect', 'build', 'push', 'pull', 'preview', 'deploy', 'resume', 'cancel'].map((action, index) => ({
152
+ ...['preview', 'move', 'status', 'recover', 'resolve'].map((operation, index) => ({
153
+ id: 'agent.project.' + operation, type: 'action', contexts: ['process'],
154
+ name: 'agent', label: '项目地址 ' + operation, section: 'process', order: 61 + index / 10,
155
+ action: { cmd: '/agent', action: 'project', args: { operation }, operation: 'agent.project.' + operation, scope: 'process' },
156
+ })),
157
+ ...['inspect', 'build', 'push', 'pull', 'preview', 'deploy', 'resume', 'cancel', 'register-team', 'prepare-member-install', 'resume-member-join',
158
+ 'check-update', 'bind-update-source', 'confirm-update-source', 'preview-update', 'read-update-notice'].map((action, index) => ({
148
159
  id: 'agent.template.' + action, type: 'action', contexts: ['process'], name: 'template',
149
- label: '模板 ' + action, section: 'process', order: 65 + index,
160
+ label: { 'check-update': '检查 Agent 更新', 'bind-update-source': '选择更新源', 'confirm-update-source': '确认更新源',
161
+ 'preview-update': '预览 Agent 升级', 'read-update-notice': '标记升级提醒已读' }[action] ?? '模板 ' + action,
162
+ section: 'process', order: 65 + index,
150
163
  action: { cmd: '/template', action, operation: 'agent.template.' + action, scope: 'process' },
151
164
  })),
152
- ...['job', 'capabilities'].map(view => ({
165
+ ...['job', 'capabilities', 'team-members', 'update-status'].map(view => ({
153
166
  id: 'agent.template.' + (view === 'job' ? 'status' : view), type: 'list', contexts: ['process'],
154
- name: 'template', label: '模板 ' + view, section: 'process', order: 74,
167
+ name: 'template', label: view === 'update-status' ? 'Agent 更新' : '模板 ' + view, section: 'process', order: 74,
155
168
  query: { cmd: '/template', args: { view }, operation: 'agent.template.' + (view === 'job' ? 'status' : view), scope: 'process' },
156
169
  control: 'list',
157
170
  })),
@@ -444,6 +457,9 @@ async function operationView(binding, context, options = {}) {
444
457
  if (binding.operation === 'group.rulespolicy.update' && context.subject.role !== 'owner') {
445
458
  return { supported: true, allowed: false, reason: { code: 'PERMISSION_DENIED', message: 'rulesPolicy can only be changed by an Agent owner' } };
446
459
  }
460
+ if (binding.operation === 'privatementionmode.update' && context.subject.role !== 'owner') {
461
+ return { supported: true, allowed: false, reason: { code: 'FORBIDDEN', message: 'Private mention mode can only be changed by the Agent Owner' } };
462
+ }
447
463
  const decision = authorizeOperation({ source: 'menu', intent: intentFor(binding, context), subject: context.subject, audit: false });
448
464
  return { supported: true, allowed: decision.allow, ...(binding.mode ? { mode: binding.mode } : {}), ...(binding.items ? { items: binding.items } : {}), ...(binding.dependsOn ? { dependsOn: binding.dependsOn } : {}), ...(decision.allow ? {} : { reason: { code: decision.code, message: decision.reason } }) };
449
465
  }
@@ -0,0 +1,70 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { agentDir, agentRelationDir, getPackageRoot, resolveRoot } from '../../paths.js';
4
+ /** Only trusted Menu context selects the Agent and current relation. */
5
+ export function menuFileFallbackRoots(subject) {
6
+ if (!subject.selfAid)
7
+ return [];
8
+ return [
9
+ ...(subject.peerKey ? [agentRelationDir(subject.selfAid, subject.peerKey)] : []),
10
+ agentDir(subject.selfAid),
11
+ resolveRoot(),
12
+ getPackageRoot(),
13
+ ];
14
+ }
15
+ /**
16
+ * Resolve Menu file reads on the host. Relative file references try the project
17
+ * first, then the current relation, Agent, runtime home and installed source.
18
+ * Outside-project reads retain the existing Owner restriction. Directory
19
+ * browsing and explicit absolute paths do not use the fallback roots.
20
+ */
21
+ export function resolveMenuFilePath(input, projectPath, role, expectType, fallbackRoots = []) {
22
+ const raw = String(input ?? '').trim();
23
+ if (!raw)
24
+ return { error: '缺少 path 参数', code: 'MISSING_VALUE' };
25
+ if (raw.includes('\0') || raw.split(/[\\/]+/).includes('..')) {
26
+ return { error: '不支持 .. 路径穿越或无效路径', code: 'NO_PERMISSION' };
27
+ }
28
+ const absolute = path.isAbsolute(raw) || path.win32.isAbsolute(raw);
29
+ const canInfer = !absolute && expectType === 'file' && role === 'owner';
30
+ const roots = [...new Set([
31
+ ...(projectPath ? [projectPath] : []),
32
+ ...(canInfer ? fallbackRoots : []),
33
+ ])];
34
+ if (!projectPath && role !== 'owner')
35
+ return { error: '无法解析当前 agent projectPath', code: 'NO_PROJECT' };
36
+ // Both path separators occur in messages, regardless of the host OS.
37
+ const relative = raw.replace(/[\\/]/g, path.sep);
38
+ const candidates = absolute ? [raw] : roots.map(root => path.resolve(root, relative));
39
+ for (const candidate of candidates) {
40
+ let realPath;
41
+ let stat;
42
+ try {
43
+ realPath = fs.realpathSync(candidate);
44
+ stat = fs.statSync(realPath);
45
+ }
46
+ catch (error) {
47
+ const code = error.code;
48
+ if (code === 'ENOENT' || code === 'ENOTDIR')
49
+ continue;
50
+ return { error: '无法读取文件', code: code === 'EACCES' || code === 'EPERM' ? 'NO_PERMISSION' : 'EXEC_FAILED' };
51
+ }
52
+ let realProjectPath = '';
53
+ if (projectPath) {
54
+ try {
55
+ realProjectPath = fs.realpathSync(projectPath);
56
+ }
57
+ catch { /* An Owner may still resolve a file from the remaining roots. */ }
58
+ }
59
+ const inProject = !!realProjectPath && (realPath === realProjectPath || realPath.startsWith(realProjectPath + path.sep));
60
+ if (!inProject && role !== 'owner') {
61
+ return { error: '无权限:项目外文件仅 owner 可取', code: 'NO_PERMISSION' };
62
+ }
63
+ if (expectType === 'file' && !stat.isFile())
64
+ return { error: '暂不支持目录或非普通文件', code: 'NOT_SUPPORTED' };
65
+ if (expectType === 'directory' && !stat.isDirectory())
66
+ return { error: '不是目录', code: 'NOT_A_DIRECTORY' };
67
+ return { realPath, projectPath: realProjectPath, stat };
68
+ }
69
+ return { error: '文件不存在', code: 'NOT_FOUND' };
70
+ }
@@ -1,5 +1,6 @@
1
1
  import { memoryHelpEntries } from './memory-slash.js';
2
2
  import { executeProviderMenu } from './provider-menu.js';
3
+ import { executePrivateMentionMenu, validatePrivateMentionMenuRequest } from './private-mention-menu.js';
3
4
  import { executeTemplateMenu, executeProviderModelCatalog } from './agent-template-menu.js';
4
5
  import { getBaseagentSnapshot, loadedBaseagentIds } from '../../agents/baseagent-availability.js';
5
6
  import { resolveBaseagentModelSelection } from '../../agents/baseagent.js';
@@ -15,8 +16,10 @@ import { isMainSession, isTopicSession, sessionLocalTopicId, sessionTopicThreadI
15
16
  import path from 'path';
16
17
  import fs from 'fs';
17
18
  import { parseFileSearchArgs, searchProjectFiles } from './file-search.js';
19
+ import { menuFileFallbackRoots, resolveMenuFilePath } from './menu-file-path.js';
18
20
  import os from 'os';
19
21
  import { readEffectiveCpuCount } from '../../utils/host-info.js';
22
+ import { readSystemMemoryUsage } from '../../utils/system-memory.js';
20
23
  import crypto from 'crypto';
21
24
  import { CronExpressionParser } from 'cron-parser';
22
25
  import { parseDuration } from '../../trigger/parser.js';
@@ -29,6 +32,7 @@ import { loadDefaults, loadDaemonConfig } from '../../config-store.js';
29
32
  import { buildEcwebPairingUrl } from '../../ecweb/pairing.js';
30
33
  import { WEB_PACKAGE_NAME, RESTART_REQUEST_ID_ENV, RUNTIME_HOME_ENV, SESSION_ID_ENV } from '../../product.js';
31
34
  import { read as cfgRead, resolveEffective, resolveEffectiveFieldWithSource, routeFieldPath, write as cfgWrite, ConfigTarget, } from '../../config/config-manager.js';
35
+ import { fieldSchemaDefault } from '../../config/schema-registry.js';
32
36
  import { agentCreateCapabilities, execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
33
37
  import { readInitialization } from '../../cli/agent-create.js';
34
38
  import { agentMdMenuService } from './agentmd-menu.js';
@@ -277,60 +281,6 @@ async function resolveTopicForkSource(sessionManager, channel, channelId, source
277
281
  const active = await sessionManager.getActiveSession(channel, channelId);
278
282
  return active && isMainSession(active) ? active : undefined;
279
283
  }
280
- /**
281
- * 解析并校验 menu `name=file` 的目标路径(query/fetch 共用)。
282
- *
283
- * 与文本 `/file` 的差异(见设计文档 §6.2):
284
- * - 接受项目内**绝对路径**(文本 /file 仍拒绝绝对路径)
285
- * - 项目外文件仅 aid channel owner(identity.role === 'owner')可取
286
- *
287
- * 沿用 /file 的安全校验链:拒绝 `..` 穿越、realpathSync 后验证落点。
288
- * 成功返回 `{ realPath, projectPath, stat }`;失败返回 `{ error, code }`。
289
- */
290
- function resolveMenuFilePath(input, projectPath, role, expectType) {
291
- if (!projectPath)
292
- return { error: '无法解析当前 agent projectPath', code: 'NO_PROJECT' };
293
- const raw = (input ?? '').toString().trim();
294
- if (!raw)
295
- return { error: '缺少 path 参数', code: 'MISSING_VALUE' };
296
- // 拒绝 .. 路径穿越(兼容两种分隔符)
297
- if (raw.split(path.sep).includes('..') || raw.split('/').includes('..')) {
298
- return { error: '不支持 .. 路径穿越', code: 'NO_PERMISSION' };
299
- }
300
- // 相对路径基于 projectPath 解析;绝对路径原样
301
- const resolved = path.isAbsolute(raw) ? raw : path.resolve(projectPath, raw);
302
- if (!fs.existsSync(resolved)) {
303
- return { error: '文件不存在', code: 'NOT_FOUND' };
304
- }
305
- let realPath;
306
- let realProjectPath;
307
- try {
308
- realPath = fs.realpathSync(resolved);
309
- realProjectPath = fs.realpathSync(projectPath);
310
- }
311
- catch {
312
- return { error: '文件不存在', code: 'NOT_FOUND' };
313
- }
314
- const inProject = realPath === realProjectPath || realPath.startsWith(realProjectPath + path.sep);
315
- // 项目外文件:仅 aid channel owner 可取(§6.2)
316
- if (!inProject && role !== 'owner') {
317
- return { error: '无权限:项目外文件仅 owner 可取', code: 'NO_PERMISSION' };
318
- }
319
- let stat;
320
- try {
321
- stat = fs.statSync(realPath);
322
- }
323
- catch {
324
- return { error: '文件不存在', code: 'NOT_FOUND' };
325
- }
326
- if (expectType === 'file' && stat.isDirectory()) {
327
- return { error: '暂不支持目录', code: 'NOT_SUPPORTED' };
328
- }
329
- if (expectType === 'directory' && !stat.isDirectory()) {
330
- return { error: '不是目录', code: 'NOT_A_DIRECTORY' };
331
- }
332
- return { realPath, projectPath: realProjectPath, stat };
333
- }
334
284
  function parseProjectRelativePath(input) {
335
285
  if (typeof input !== 'string' || !input.trim()) {
336
286
  return { error: '缺少 path 参数', code: 'MISSING_VALUE' };
@@ -710,7 +660,14 @@ function menuChatmodeField(args, session, explicitChatType) {
710
660
  }
711
661
  return chatmodeFieldForPeer(session?.chatType ?? explicitChatType, session?.metadata?.peerType);
712
662
  }
663
+ /**
664
+ * chatmode 未配置时的展示值:优先取 agent-config schema 的 `chatmode.<field>.default`
665
+ * (v22 起三个子字段各自有声明),schema 没声明才回落到内置表。
666
+ */
713
667
  function defaultChatmodeForField(field) {
668
+ const fromSchema = fieldSchemaDefault('agent-config', `chatmode.${field}`);
669
+ if (isChatMode(fromSchema))
670
+ return fromSchema;
714
671
  return field === 'private' ? 'interactive' : 'proactive';
715
672
  }
716
673
  function normalizeMenuPeer(input) {
@@ -851,7 +808,14 @@ function readMenuMentionMode(target, fallback = null, fallbackSource = null) {
851
808
  }
852
809
  }
853
810
  catch { }
854
- return { value: fallback, source: fallback === null ? null : fallbackSource };
811
+ if (fallback !== null)
812
+ return { value: fallback, source: fallbackSource };
813
+ // 配置链与会话元数据都未设:展示 schema 声明的出厂默认(v22 起 mentionMode 有 default)。
814
+ const fromSchema = fieldSchemaDefault(target.scope === 'agent' ? 'agent-config' : 'relation-config', target.fieldPath);
815
+ if (fromSchema === 'disabled' || fromSchema === 'mention-only' || fromSchema === 'auto') {
816
+ return { value: fromSchema, source: 'builtin' };
817
+ }
818
+ return { value: null, source: null };
855
819
  }
856
820
  function writeMenuMentionMode(target, value) {
857
821
  const route = routeFieldPath(target.fieldPath, target.scope);
@@ -1051,7 +1015,7 @@ export function isProcessLevelOwner(peerId, owners) {
1051
1015
  // ── 控制面双轨鉴权(见 docs/.../2026-06-10-control-channel-auth-design.md)──
1052
1016
  // 白名单而非黑名单:默认安全,新增进程级 action 需显式加入。
1053
1017
  /** /agent 的进程级 action:仅控制 channel 可执行。 */
1054
- export const PROCESS_LEVEL_AGENT_ACTIONS = new Set(['create', 'initialize', 'delete', 'enable', 'disable']);
1018
+ export const PROCESS_LEVEL_AGENT_ACTIONS = new Set(['create', 'initialize', 'delete', 'enable', 'disable', 'project']);
1055
1019
  /** /agent 的「本 agent 自管理」action:agent channel 仅 owner/admin 可对自身 aid 执行;update 另行收紧为 owner。 */
1056
1020
  export const SELF_MANAGE_AGENT_ACTIONS = new Set(['update', 'reload']);
1057
1021
  /** 判断 (cmdBase, action) 是否为进程级操作(仅控制 channel 可执行)。
@@ -1102,6 +1066,10 @@ function gateControlScope(opts) {
1102
1066
  function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel = false) {
1103
1067
  if (cmdBase === '/agent-data-root' || cmdBase === '/relation-data-root')
1104
1068
  return null;
1069
+ if (cmdBase === '/private-mention-mode' && ['query', 'options', 'update'].includes(verb)) {
1070
+ return { operation: `privatementionmode.${verb === 'update' ? 'update' : 'current'}`,
1071
+ scope: 'agent', source: 'menu', args: { ...(args ?? {}), ...(value !== undefined ? { value } : {}) } };
1072
+ }
1105
1073
  if (cmdBase === '/file' && args?.rootId !== undefined)
1106
1074
  return null;
1107
1075
  const payload = { ...(args ?? {}), ...(value !== undefined ? { value } : {}) };
@@ -1250,6 +1218,8 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
1250
1218
  if (cmdBase === '/agent') {
1251
1219
  if (action === 'set-access')
1252
1220
  return intent('agent.access.write', 'agent', { action });
1221
+ if (action === 'project')
1222
+ return intent('agent.project.' + String(args?.operation ?? ''), 'process', { action });
1253
1223
  if (action === 'update' && args?.patch && Object.hasOwn(args.patch, 'avatar')) {
1254
1224
  return intent('ec.aid.avatar', 'agent', { action });
1255
1225
  }
@@ -1831,7 +1801,7 @@ async function loadMenuTopicSession(sessionManager, channel, channelId, threadId
1831
1801
  }
1832
1802
  /** 动态子菜单:根据 cmd 路径返回选项列表(供 menu.query + cmd 使用) */
1833
1803
  export async function getSubMenuItems(cmd, channel, channelId, userId, args, overrideIdentity, explicitChatType, fromControlChannel = false, authSubject, source = 'menu', transportReplyContext) {
1834
- const session = transportReplyContext?.threadId
1804
+ const session = transportReplyContext?.threadId && cmd.trim().split(' ')[0] !== '/private-mention-mode'
1835
1805
  ? await loadMenuTopicSession(this.sessionManager, channel, channelId, transportReplyContext.threadId)
1836
1806
  : await this.sessionManager.getActiveSession(channel, channelId);
1837
1807
  const subject = buildMenuAuthSubject(this, {
@@ -1892,6 +1862,9 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
1892
1862
  });
1893
1863
  if (optionsAuthDenied)
1894
1864
  throw { code: optionsAuthDenied.code, message: optionsAuthDenied.error, data: optionsAuthDenied.data };
1865
+ if (cmdBase0 === '/private-mention-mode') {
1866
+ return executePrivateMentionMenu('options', subject.selfAid, subject.role, args);
1867
+ }
1895
1868
  if (cmdBase0 === '/system') {
1896
1869
  if (args?.option !== 'logs')
1897
1870
  throw { code: 'NOT_SUPPORTED', message: `Unsupported system option: ${String(args?.option ?? '')}` };
@@ -2256,6 +2229,11 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
2256
2229
  const cmdBase = cmd.trim().split(' ')[0];
2257
2230
  if (!cmdBase)
2258
2231
  return { error: '缺少命令', code: 'MISSING_CMD' };
2232
+ if (cmdBase === '/private-mention-mode') {
2233
+ const invalid = validatePrivateMentionMenuRequest({ type: 'menu.query', args });
2234
+ if (invalid)
2235
+ return { error: invalid.message, code: invalid.code };
2236
+ }
2259
2237
  if (cmdBase === '/template') {
2260
2238
  return executeTemplateMenu({ name: 'template', type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
2261
2239
  }
@@ -2299,7 +2277,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
2299
2277
  }
2300
2278
  }
2301
2279
  }
2302
- if (transportReplyContext?.threadId && !groupResourceSession) {
2280
+ if (transportReplyContext?.threadId && !groupResourceSession && cmdBase !== '/private-mention-mode') {
2303
2281
  try {
2304
2282
  session = await loadMenuTopicSession(this.sessionManager, channel, channelId, transportReplyContext.threadId);
2305
2283
  }
@@ -2628,6 +2606,14 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
2628
2606
  });
2629
2607
  if (authDenied)
2630
2608
  return authDenied;
2609
+ if (cmdBase === '/private-mention-mode') {
2610
+ try {
2611
+ return { data: executePrivateMentionMenu('query', subject.selfAid, subject.role, args) };
2612
+ }
2613
+ catch (error) {
2614
+ return menuResultFailure(error);
2615
+ }
2616
+ }
2631
2617
  if (cmdBase === '/aid' && args?.view === 'agentmd') {
2632
2618
  try {
2633
2619
  return { data: await agentMdMenuService.query(subject, args) };
@@ -3238,7 +3224,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
3238
3224
  osRelease: os.release(),
3239
3225
  cpuModel: cpus[0]?.model ?? null,
3240
3226
  cpuCount: readEffectiveCpuCount(),
3241
- memoryTotalBytes: os.totalmem(),
3227
+ memoryTotalBytes: readSystemMemoryUsage().memTotal,
3242
3228
  systemUptime: Math.floor(os.uptime()),
3243
3229
  };
3244
3230
  // 首屏只读本机基本信息,不定位全局 npm 包,也不等待 CLI 可用性探测。
@@ -3283,10 +3269,20 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
3283
3269
  else {
3284
3270
  const role = identity.role;
3285
3271
  const projectPath = session?.projectPath ?? evolagent?.projectPath ?? this.getOwningAgent?.(channel)?.projectPath;
3286
- const resolved = resolveMenuFilePath(args?.path, projectPath, role, 'file');
3272
+ const resolved = resolveMenuFilePath(args?.path, projectPath, role, 'file', menuFileFallbackRoots(subject));
3287
3273
  if ('error' in resolved)
3288
3274
  return resolved;
3289
3275
  ({ realPath, stat } = resolved);
3276
+ if (role === 'owner') {
3277
+ const denied = await authorizeMenuIntent.call(this, {
3278
+ intent: buildMenuIntent('query', cmdBase, { ...args, path: realPath }),
3279
+ identity, subject, session, explicitChatType, channel, channelId, userId, fromControlChannel, source,
3280
+ });
3281
+ if (denied)
3282
+ return denied;
3283
+ // Pin the subsequent fetch/cache to the file that actually matched.
3284
+ responsePath = realPath;
3285
+ }
3290
3286
  }
3291
3287
  // sha256 仅对 ≤ 2 MB 文件计算,超过返回 null,客户端降级到 size+mtime(§4、§7 决策 2)
3292
3288
  let sha256 = null;
@@ -3323,6 +3319,11 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
3323
3319
  const cmdBase = cmd.trim().split(' ')[0];
3324
3320
  if (!cmdBase)
3325
3321
  return { error: '缺少命令', code: 'MISSING_CMD' };
3322
+ if (cmdBase === '/private-mention-mode') {
3323
+ const invalid = validatePrivateMentionMenuRequest({ type: 'menu.update', args, value });
3324
+ if (invalid)
3325
+ return { error: invalid.message, code: invalid.code };
3326
+ }
3326
3327
  if (cmdBase === '/provider') {
3327
3328
  return executeProviderMenu({ name: 'provider', cmd, type: 'menu.update', args, value }, fromControlChannel ? authSubject : undefined, source);
3328
3329
  }
@@ -3363,7 +3364,7 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
3363
3364
  let session = loadedContext.session;
3364
3365
  const evolagent = loadedContext.evolagent;
3365
3366
  if (transportReplyContext?.threadId) {
3366
- const modelAgentScope = (cmdBase === '/model' || cmdBase === '/effort')
3367
+ const modelAgentScope = (cmdBase === '/model' || cmdBase === '/effort' || cmdBase === '/private-mention-mode')
3367
3368
  && (menuStringArg(args, 'scope') ?? 'agent') === 'agent';
3368
3369
  if (modelAgentScope) {
3369
3370
  // Model settings belong to the Agent and can be changed from a locally
@@ -3538,6 +3539,14 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
3538
3539
  });
3539
3540
  if (authDenied)
3540
3541
  return authDenied;
3542
+ if (cmdBase === '/private-mention-mode') {
3543
+ try {
3544
+ return { data: executePrivateMentionMenu('update', subject.selfAid, subject.role, args, value) };
3545
+ }
3546
+ catch (error) {
3547
+ return menuResultFailure(error);
3548
+ }
3549
+ }
3541
3550
  // ── 进程级 /gateway update(网关配置,value 为 JSON:{scope,type,patch}) ──
3542
3551
  if (cmdBase === '/gateway') {
3543
3552
  let body;
@@ -4110,6 +4119,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
4110
4119
  args = { ...(args ?? {}), aid: selfAid };
4111
4120
  }
4112
4121
  const a = { ...(args ?? {}) };
4122
+ if (action === 'project') {
4123
+ return execAgentAction(action, a, userId ?? '', this.eventBus, this.agentApplicationService, agentFullAccessMenuSubject(subject, source));
4124
+ }
4113
4125
  if (action === 'create' && a.resume !== true && a.cancel !== true) {
4114
4126
  if (a.project !== undefined && typeof a.project !== 'string')
4115
4127
  return { error: 'project 必须是字符串', code: 'INVALID_ARGS' };
@@ -4218,10 +4230,6 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
4218
4230
  if (!result.ok)
4219
4231
  return { error: result.error, code: result.code || 'INTERNAL' };
4220
4232
  this.eventBus.publish({ type: 'agent:stopped', aid: a.aid, timestamp: Date.now() });
4221
- // 中断该 agent 正在执行的大模型调用
4222
- const handle = this.agentRegistry?.get(a.aid);
4223
- if (handle)
4224
- this.messageQueue.interruptByAgent(handle.name);
4225
4233
  }
4226
4234
  else {
4227
4235
  const result = this.agentApplicationService
@@ -4947,7 +4955,8 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
4947
4955
  isPendingInRegistry: () => hasLiveRestartMonitor({ requestId }),
4948
4956
  });
4949
4957
  if (!restartLaunch.ok) {
4950
- if (restartLaunch.pending) {
4958
+ const pending = readRestartRequest(pendingFile, requestId);
4959
+ if (restartLaunch.pending || (pending?.backend === 'systemd' && ['requested', 'accepted'].includes(pending.status))) {
4951
4960
  logger.error(`[System] Restart ownership is still unconfirmed (requestId=${restartRequestId}, PID=${restartLaunch.pid ?? 'unknown'})`);
4952
4961
  return {
4953
4962
  error: `重启请求状态暂不可确认(requestId=${restartRequestId})。启动链仍在运行,可能继续执行;请勿立即重复发起。诊断日志:${logFilePath},monitor 记录见 restart.log。`,
@@ -4961,13 +4970,14 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
4961
4970
  },
4962
4971
  };
4963
4972
  }
4964
- removeRestartRequest(pendingFile, requestId);
4973
+ if (pending?.backend !== 'systemd')
4974
+ removeRestartRequest(pendingFile, requestId);
4965
4975
  logger.error(`[System] Refusing menu restart: restart-monitor did not take ownership (${restartLaunch.reason})`);
4966
4976
  for (const line of (restartLaunch.stderrTail ?? '').split(/\r?\n/).filter(Boolean).slice(-8)) {
4967
4977
  logger.error(`[System] | ${line}`);
4968
4978
  }
4969
4979
  return {
4970
- error: `重启已中止:重启监控未接管(${restartLaunch.reason})。服务未停止,仍在运行当前版本。`,
4980
+ error: `重启未确认完成:${pending?.reason ?? restartLaunch.reason}。请检查重启日志和所属服务状态。`,
4971
4981
  code: 'RESTART_MONITOR_DEAD',
4972
4982
  data: {
4973
4983
  reasonCode: 'RESTART_MONITOR_DEAD',
@@ -4977,7 +4987,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
4977
4987
  },
4978
4988
  };
4979
4989
  }
4980
- logger.info(`[System] Restart monitor accepted request ${restartRequestId} (PID ${restartLaunch.pid ?? 'unknown'})`);
4990
+ logger.info(`[System] Restart lifecycle accepted request ${restartRequestId} (PID ${restartLaunch.pid ?? 'unknown'})`);
4981
4991
  }
4982
4992
  else {
4983
4993
  logger.info('[System] Suppressed real menu restart in test runtime');
@@ -5386,10 +5396,19 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
5386
5396
  }
5387
5397
  else {
5388
5398
  const projectPath = session?.projectPath ?? evolagent?.projectPath ?? this.getOwningAgent?.(channel)?.projectPath;
5389
- const resolved = resolveMenuFilePath(args?.path, projectPath, identity.role, 'file');
5399
+ const resolved = resolveMenuFilePath(args?.path, projectPath, identity.role, 'file', menuFileFallbackRoots(subject));
5390
5400
  if ('error' in resolved)
5391
5401
  return resolved;
5392
5402
  ({ realPath, stat } = resolved);
5403
+ if (identity.role === 'owner') {
5404
+ const denied = await authorizeMenuIntent.call(this, {
5405
+ intent: buildMenuIntent('action', cmdBase, { ...args, path: realPath }, 'fetch'),
5406
+ identity: authIdentity, subject, session: authSession, explicitChatType,
5407
+ channel, channelId, userId, fromControlChannel, source,
5408
+ });
5409
+ if (denied)
5410
+ return denied;
5411
+ }
5393
5412
  }
5394
5413
  if (stat.size > FILE_FETCH_MAX_SIZE) {
5395
5414
  return { error: `文件过大: ${(stat.size / 1024 / 1024).toFixed(1)} MB (限制 ${FILE_FETCH_MAX_SIZE / 1024 / 1024} MB)`, code: 'FILE_TOO_LARGE' };
@@ -5533,9 +5552,9 @@ async function execMenuForSystemControl(payload, context) {
5533
5552
  const isConnectRequest = name === 'connect' || compatCmd === '/connect';
5534
5553
  const requiresAgentTarget = (name === 'menu' && payload?.type === 'menu.query' && payload?.args?.view === 'queries')
5535
5554
  || isRoleRequest || isConnectRequest || [
5536
- 'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'team-workspace', 'slash-commands', 'events',
5555
+ 'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'team-workspace', 'slash-commands', 'events', 'private-mention-mode',
5537
5556
  ].includes(name)
5538
- || ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/team-workspace', '/evolhelp', '/events'].includes(compatCmd ?? '')
5557
+ || ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/team-workspace', '/evolhelp', '/events', '/private-mention-mode'].includes(compatCmd ?? '')
5539
5558
  || (!isProcessLevel && requestedContextKind !== undefined && requestedContextKind !== 'process');
5540
5559
  const target = isProcessLevel
5541
5560
  ? { channel: SYSTEM_CONTROL_CHANNEL }
@@ -12,6 +12,7 @@ import { validateTeamWorkspaceItemsArgs } from './team-workspace-items.js';
12
12
  import { isTeamMembersMenuRequest, validateTeamMembersMenuRequest } from './team-workspace-members-menu.js';
13
13
  import { validateAgentMdMenuRequest } from './agentmd-menu-request.js';
14
14
  import { validateEventsMenuRequest } from './eventcenter-menu.js';
15
+ import { validatePrivateMentionMenuRequest } from './private-mention-menu.js';
15
16
  const RETRY_DELAYS_MS = [250, 750, 2_000];
16
17
  const RETRY_WINDOW_MS = 5_000;
17
18
  export function isRetryableMenuTransportError(error) {
@@ -194,6 +195,7 @@ export const MENU_NAME_COMMANDS = Object.freeze({
194
195
  effort: '/effort',
195
196
  chatmode: '/chatmode',
196
197
  mentionmode: '/mention',
198
+ 'private-mention-mode': '/private-mention-mode',
197
199
  group: '/group',
198
200
  permission: '/perm',
199
201
  activity: '/activity',
@@ -425,6 +427,9 @@ export function validateMenuRequest(request) {
425
427
  }
426
428
  if (isTemplateRequest(request))
427
429
  return validateTemplateRequest(request);
430
+ if (request.name === 'private-mention-mode' || firstCommandToken(request.cmd) === '/private-mention-mode') {
431
+ return validatePrivateMentionMenuRequest(request);
432
+ }
428
433
  if ((request.name === 'aid' || firstCommandToken(request.cmd) === '/aid')
429
434
  && (request.args?.view === 'agentmd'
430
435
  || (typeof request.action === 'string' && request.action.startsWith('agentmd.')))) {
@@ -4,7 +4,7 @@ export const MENU_QUERY_BATCH_MAX_ITEMS = 32;
4
4
  export const MENU_QUERY_BATCH_CONCURRENCY = 6;
5
5
  // An explicit read-only surface. Never dispatch a client-supplied cmd or verb.
6
6
  export const MENU_QUERY_BATCH_NAMES = [
7
- 'role', 'agent', 'baseagent', 'activity', 'effort', 'model', 'chatmode', 'team-workspace',
7
+ 'role', 'agent', 'baseagent', 'activity', 'effort', 'model', 'chatmode', 'team-workspace', 'private-mention-mode',
8
8
  ];
9
9
  const QUERY_NAMES = new Set(MENU_QUERY_BATCH_NAMES);
10
10
  const ROLE_VIEWS = new Set(['capabilities', 'target', 'role', 'requester']);
@@ -168,7 +168,7 @@ export async function execMenuQueryBatch(input) {
168
168
  subject = context.subject;
169
169
  channelId = context.channelId;
170
170
  // These resource queries have their own exact argument contracts.
171
- if (!['role', 'agent', 'team-workspace'].includes(item.name)) {
171
+ if (!['role', 'agent', 'team-workspace', 'private-mention-mode'].includes(item.name)) {
172
172
  queryArgs = bindMenuExecutionContextArgs(args, context) ?? {};
173
173
  }
174
174
  }