evolcore 0.0.46 → 0.0.48

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 (237) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/bin/ec-build.mjs +86 -0
  3. package/dist/agent-template/jobs.js +12 -4
  4. package/dist/agent-template/runtime.js +139 -39
  5. package/dist/agent-template/service.js +66 -13
  6. package/dist/agents/baseagent.js +60 -20
  7. package/dist/agents/claude-runner.js +43 -18
  8. package/dist/agents/codex/app-server-client.js +32 -23
  9. package/dist/agents/codex-runner.js +31 -16
  10. package/dist/agents/ecagent-runner.js +7 -4
  11. package/dist/agents/gemini-runner.js +5 -2
  12. package/dist/agents/runner-types.js +5 -21
  13. package/dist/aun/aid/agentmd.js +5 -1
  14. package/dist/aun/group/fs-download.js +1 -1
  15. package/dist/aun/service-proxy.js +4 -2
  16. package/dist/build-identity.json +1 -0
  17. package/dist/channels/aun.js +100 -32
  18. package/dist/channels/daemon.js +10 -26
  19. package/dist/cli/aun-commands.js +86 -51
  20. package/dist/cli/code-stats.js +19 -8
  21. package/dist/cli/command-log.js +1 -1
  22. package/dist/cli/daemon-commands.js +65 -76
  23. package/dist/cli/daemon-lifecycle-client.js +17 -3
  24. package/dist/cli/directory.js +7 -1
  25. package/dist/cli/ecmsg-gateway.js +5 -2
  26. package/dist/cli/index.js +2 -8
  27. package/dist/cli/init-channel.js +6 -8
  28. package/dist/cli/init.js +74 -46
  29. package/dist/cli/invoke-command.js +1 -1
  30. package/dist/cli/provider-command.js +74 -13
  31. package/dist/cli/restart-monitor.js +104 -28
  32. package/dist/cli/role.js +61 -17
  33. package/dist/cli/stats.js +3 -3
  34. package/dist/cli/task-context.js +83 -15
  35. package/dist/cli/thread-command.js +16 -51
  36. package/dist/cli/upgrade-command.js +4 -2
  37. package/dist/config/boot-log.js +3 -9
  38. package/dist/config/builtin-roles.js +5 -7
  39. package/dist/config/config-manager.js +31 -23
  40. package/dist/config/daemon-services.js +30 -3
  41. package/dist/config/gateway-config.js +2 -2
  42. package/dist/config/invoke-ipc-service.js +6 -4
  43. package/dist/config/peer-bind-code.js +3 -4
  44. package/dist/config/peer-book-store.js +59 -218
  45. package/dist/config/peer-book.js +26 -27
  46. package/dist/config/peer-role-resolver.js +16 -1
  47. package/dist/config/provider-identity-migration.js +161 -6
  48. package/dist/config/provider-ipc-service.js +56 -11
  49. package/dist/config/provider-menu-request.js +24 -5
  50. package/dist/config/provider-templates.js +127 -0
  51. package/dist/config/providers-config.js +59 -8
  52. package/dist/config/providers-management.js +467 -49
  53. package/dist/config/role-command-service.js +248 -1
  54. package/dist/config/schema-migration.js +228 -20
  55. package/dist/config/schema-registry.js +6 -2
  56. package/dist/core/agent-application-service.js +6 -1
  57. package/dist/core/agent-runtime.js +10 -5
  58. package/dist/core/auth/agent-delegation.js +10 -4
  59. package/dist/core/auth/auth-gateway.js +2 -1
  60. package/dist/core/auth/delegation-authorization.js +3 -0
  61. package/dist/core/auth/delegation-diagnostics.js +56 -15
  62. package/dist/core/auth/operation-authorizer.js +26 -1
  63. package/dist/core/auth/operation-catalog.js +28 -64
  64. package/dist/core/capability/providers/codex-capability-provider.js +7 -8
  65. package/dist/core/channel-loader.js +18 -0
  66. package/dist/core/command/agent-control.js +32 -0
  67. package/dist/core/command/command-handler.js +81 -85
  68. package/dist/core/command/menu-catalog.js +1 -0
  69. package/dist/core/command/menu-handler.js +65 -153
  70. package/dist/core/command/menu-protocol.js +7 -1
  71. package/dist/core/command/provider-menu.js +13 -3
  72. package/dist/core/command/role-menu.js +47 -23
  73. package/dist/core/command/slash-handler.js +30 -49
  74. package/dist/core/command/team-workspace-items.js +81 -12
  75. package/dist/core/command/team-workspace-team.js +9 -71
  76. package/dist/core/command/topic-slash.js +9 -30
  77. package/dist/core/daemon-bootstrap.js +19 -10
  78. package/dist/core/daemon-control.js +8 -10
  79. package/dist/core/daemon-lifecycle.js +50 -40
  80. package/dist/core/evolagent-registry.js +22 -3
  81. package/dist/core/file-integrity/store.js +2 -0
  82. package/dist/core/handoff/runtime.js +37 -1
  83. package/dist/core/host-snapshot.js +9 -4
  84. package/dist/core/inference/text-inference.js +3 -1
  85. package/dist/core/initialization/service.js +31 -8
  86. package/dist/core/interaction-router.js +3 -0
  87. package/dist/core/invoke/executors/text.js +72 -19
  88. package/dist/core/ipc-registration.js +6 -4
  89. package/dist/core/memory/consolidation.js +6 -6
  90. package/dist/core/message/aun-ipc-sender.js +165 -55
  91. package/dist/core/message/im-renderer.js +1 -1
  92. package/dist/core/message/message-bridge.js +51 -334
  93. package/dist/core/message/message-log.js +5 -0
  94. package/dist/core/message/message-queue.js +22 -0
  95. package/dist/core/message/message-utils.js +8 -0
  96. package/dist/core/message/response-engine.js +429 -116
  97. package/dist/core/message/send-routing.js +5 -1
  98. package/dist/core/model/catalog-service.js +31 -11
  99. package/dist/core/model/model-capabilities.js +22 -4
  100. package/dist/core/model/model-catalog.js +1 -0
  101. package/dist/core/ownership/owner-resolver.js +355 -60
  102. package/dist/core/permission/protected-paths.js +6 -6
  103. package/dist/core/relation/peer-identity.js +28 -2
  104. package/dist/core/relation/same-owner-proof.js +81 -111
  105. package/dist/core/session/adapters/claude-session-file-adapter.js +1 -1
  106. package/dist/core/session/adapters/codex-session-file-adapter.js +96 -15
  107. package/dist/core/session/session-file-health.js +49 -14
  108. package/dist/core/session/session-fs-store.js +91 -35
  109. package/dist/core/session/session-manager.js +68 -24
  110. package/dist/core/session/session-mapper.js +14 -34
  111. package/dist/core/session/session-transcript.js +5 -1
  112. package/dist/core/task/task-activity-store.js +84 -0
  113. package/dist/core/task/task-image-resources.js +1 -1
  114. package/dist/core/task/task-recovery-service.js +12 -0
  115. package/dist/core/thread/command-parser.js +7 -12
  116. package/dist/core/thread/thread-context-storage.js +3 -2
  117. package/dist/core/thread/thread-operation.js +2 -13
  118. package/dist/core/thread/thread-service.js +15 -46
  119. package/dist/directory/owner-directory-admission.js +1 -1
  120. package/dist/directory/owner-directory-cache.js +45 -28
  121. package/dist/directory/owner-directory-markdown.js +13 -1
  122. package/dist/directory/owner-directory-query-operation.js +29 -3
  123. package/dist/directory/owner-directory-remarks.js +11 -3
  124. package/dist/eck/message-renderer.js +84 -24
  125. package/dist/ecweb/basic-settings-service.js +3 -1
  126. package/dist/ecweb/message-context-service.js +1 -1
  127. package/dist/ecweb/pairing.js +4 -3
  128. package/dist/ecweb/providers-service.js +26 -1
  129. package/dist/ecweb/runtime/lifecycle.js +82 -23
  130. package/dist/ecweb/runtime/proxy-access.js +74 -0
  131. package/dist/ecweb/runtime/supervisor.js +6 -17
  132. package/dist/event-center/registry.js +13 -2
  133. package/dist/event-center/runtime.js +103 -11
  134. package/dist/event-center/script-runner.js +5 -5
  135. package/dist/index.js +129 -93
  136. package/dist/ipc.js +15 -3
  137. package/dist/outputs/events.js +62 -0
  138. package/dist/outputs/protocol.js +102 -0
  139. package/dist/outputs/service.js +279 -0
  140. package/dist/paths.js +3 -0
  141. package/dist/proxy/manager.js +43 -13
  142. package/dist/services/index.js +89 -4
  143. package/dist/services/ipc-operation.js +4 -15
  144. package/dist/services/pack-manager.js +12 -1
  145. package/dist/services/router.js +21 -6
  146. package/dist/services/script-runner.js +5 -4
  147. package/dist/services/validation.js +1 -1
  148. package/dist/stats/budget.js +1 -1
  149. package/dist/stats/db.js +19 -0
  150. package/dist/stats/index.js +1 -1
  151. package/dist/stats/{price-resolver.js → model-resolver.js} +305 -24
  152. package/dist/stats/normalizer.js +2 -0
  153. package/dist/stats/query.js +35 -27
  154. package/dist/stats/role-budget.js +5 -2
  155. package/dist/stats/writer.js +10 -6
  156. package/dist/trigger/audit.js +7 -0
  157. package/dist/trigger/authorization.js +105 -11
  158. package/dist/trigger/feedback.js +10 -0
  159. package/dist/trigger/history.js +37 -11
  160. package/dist/trigger/ipc-service.js +12 -1
  161. package/dist/trigger/manager.js +1 -0
  162. package/dist/trigger/scheduler.js +11 -5
  163. package/dist/trigger/script-executor.js +2 -1
  164. package/dist/trigger/script-sandbox.js +9 -3
  165. package/dist/trigger/state.js +7 -0
  166. package/dist/trigger/validation.js +22 -0
  167. package/dist/utils/aid-bind.js +155 -18
  168. package/dist/utils/atomic-write.js +3 -3
  169. package/dist/utils/cross-platform.js +97 -31
  170. package/dist/utils/error-dict.json +94 -4
  171. package/dist/utils/error-utils.js +40 -4
  172. package/dist/utils/evolcore-version.js +36 -65
  173. package/dist/utils/instance-registry.js +61 -0
  174. package/dist/utils/msg-diag.js +1 -0
  175. package/dist/utils/process-introspect.js +158 -8
  176. package/dist/utils/process-tree.js +50 -2
  177. package/dist/utils/upgrade-jobs.js +4 -4
  178. package/dist/utils/windows-shell-trust.js +2 -0
  179. package/dist/workbench/protocol.js +80 -0
  180. package/dist/workbench/service.js +359 -0
  181. package/ecagent/dist/types.d.ts +6 -2
  182. package/kits/docs/context-assembly.md +1 -1
  183. package/kits/docs/evolcore/INDEX.md +2 -2
  184. package/kits/docs/evolcore/aid.md +3 -1
  185. package/kits/docs/evolcore/config.md +12 -0
  186. package/kits/docs/evolcore/directory.md +22 -3
  187. package/kits/docs/evolcore/ecweb-lifecycle.md +15 -0
  188. package/kits/docs/evolcore/model.md +10 -0
  189. package/kits/docs/evolcore/peer.md +19 -65
  190. package/kits/docs/evolcore/provider.md +133 -5
  191. package/kits/docs/evolcore/role.md +80 -0
  192. package/kits/docs/evolcore/services.md +6 -6
  193. package/kits/docs/evolcore/team-workspace.md +1 -1
  194. package/kits/docs/evolcore/thread-chain.md +14 -15
  195. package/kits/docs/evolcore/tool-authorization.md +5 -0
  196. package/kits/docs/evolcore/trigger.md +10 -0
  197. package/kits/eck_message_manifest.json +12 -0
  198. package/kits/provider-templates.json +1213 -0
  199. package/kits/rules/04-relation.md +3 -3
  200. package/kits/schemas/_meta.json +14 -2
  201. package/kits/schemas/contact-book.schema.4.json +52 -0
  202. package/kits/schemas/providers.schema.3.json +200 -0
  203. package/kits/skills/.switches.json +4 -0
  204. package/kits/skills/ability/references/calling.md +1 -1
  205. package/kits/skills/ec-group/SKILL.md +2 -2
  206. package/kits/skills/ec-identity/SKILL.md +19 -72
  207. package/kits/skills/ec-provider/SKILL.md +221 -0
  208. package/kits/skills/ec-provider/scripts/check-model.mjs +80 -0
  209. package/kits/skills/ec-trigger/SKILL.md +1 -1
  210. package/kits/skills/thread-ops/SKILL.md +34 -21
  211. package/kits/templates/message-fragments/group-batch-item.md +1 -1
  212. package/kits/templates/message-fragments/group-batch.md +1 -1
  213. package/kits/templates/message-fragments/inject-default.md +1 -1
  214. package/kits/templates/message-fragments/interrupt-insert.md +1 -0
  215. package/kits/templates/message-fragments/item-group.md +1 -1
  216. package/kits/templates/message-fragments/item-private.md +1 -1
  217. package/kits/templates/message-fragments/thread-context.md +1 -1
  218. package/kits/templates/message-fragments/trigger-session.md +1 -1
  219. package/kits/templates/message-fragments/trigger-thread-check.md +1 -1
  220. package/kits/templates/roles/admin.json +2 -19
  221. package/kits/templates/roles/member.json +0 -3
  222. package/kits/templates/system-fragments/baseagent.md +6 -0
  223. package/kits/templates/system-fragments/commands.md +3 -3
  224. package/kits/templates/system-fragments/managed-runtime.md +1 -1
  225. package/kits/templates/system-fragments/relation.md +1 -1
  226. package/kits/templates/system-fragments/thread.md +6 -5
  227. package/package.json +6 -4
  228. package/scripts/agent-template/inspect.mjs +4 -1
  229. package/scripts/agent-template/shared/common.mjs +2 -3
  230. package/scripts/agent-template/shared/template-contract.mjs +2 -1
  231. package/scripts/agent-template/shared/template-package.mjs +9 -2
  232. package/scripts/agent-template/shared/template-runtime.mjs +20 -5
  233. package/scripts/agent-template/team-pack.mjs +6 -3
  234. package/dist/cli/peer.js +0 -127
  235. package/dist/config/peer-operation-service.js +0 -132
  236. package/dist/config/peer-request-service.js +0 -532
  237. package/dist/core/command/connect-menu.js +0 -624
@@ -2,13 +2,13 @@ import { isValidAid } from '../../aun/aid/validation.js';
2
2
  import { parseTimeArg, TIME_ARG_FORMATS } from '../../cli/cli-argv.js';
3
3
  import { normalizeThreadPeer } from './thread-service.js';
4
4
  import { resolveThreadRef } from './topic-id.js';
5
- const STATUSES = new Set(['pending', 'in_progress', 'completed', 'archived']);
5
+ const STATUSES = new Set(['active', 'closed', 'archived']);
6
6
  const COMMON_OPTIONS = ['--self', '--format', '--json'];
7
- const VALUE_OPTIONS = new Set(['--self', '--agent', '--format', '--name', '--label', '--status', '--sort', '--page', '--limit', '--before', '--after', '--if-rev']);
7
+ const VALUE_OPTIONS = new Set(['--self', '--agent', '--format', '--name', '--status', '--sort', '--page', '--limit', '--before', '--after', '--if-rev']);
8
8
  const OPTIONS = {
9
- peers: [], list: ['--status', '--label', '--unlabeled', '--sort', '--page', '--limit'],
9
+ peers: [], list: ['--status', '--sort', '--page', '--limit'],
10
10
  show: [], history: ['--limit', '--before', '--after'],
11
- create: ['--name', '--label', '--status', '--group', '--private'], rename: [], label: ['--clear'], status: [],
11
+ create: ['--name', '--status', '--group', '--private'], rename: [], status: [],
12
12
  delete: [], 'rebuild-index': ['--check', '--agent'], 'check-index': ['--agent'],
13
13
  'summary-show': [], 'summary-set': ['--name', '--if-rev'], 'summary-log': [], 'summary-clear': [],
14
14
  };
@@ -77,7 +77,7 @@ export function resolveThreadCommandArgv(argv, context = {}) {
77
77
  if (sort !== undefined && sort !== 'recent' && sort !== 'created')
78
78
  throw new Error('Invalid sort order');
79
79
  const maximum = ['peers', 'rebuild-index', 'check-index'].includes(command) ? 0
80
- : ['rename', 'status', 'label'].includes(command) ? 2 : command === 'summary-set' ? Infinity : 1;
80
+ : ['rename', 'status'].includes(command) ? 2 : command === 'summary-set' ? Infinity : 1;
81
81
  const minimum = maximum === 0 ? 0 : ['rename', 'status', 'summary-set'].includes(command) ? 2 : 1;
82
82
  if (positional.length < minimum || positional.length > maximum)
83
83
  throw new Error('Invalid thread arguments');
@@ -112,7 +112,7 @@ export function resolveThreadCommandArgv(argv, context = {}) {
112
112
  }
113
113
  if (command === 'list')
114
114
  Object.assign(request, {
115
- status, label: text('--label'), unlabeled: options.has('--unlabeled'), sort,
115
+ status, sort,
116
116
  page: number('--page', 1), limit: number('--limit', 1),
117
117
  });
118
118
  if (command === 'history')
@@ -125,7 +125,7 @@ export function resolveThreadCommandArgv(argv, context = {}) {
125
125
  const explicitPeerKind = options.has('--group') ? 'group'
126
126
  : options.has('--private') ? 'private' : undefined;
127
127
  Object.assign(request, {
128
- name: text('--name'), label: text('--label'), topicStatus: status,
128
+ name: text('--name'), topicStatus: status,
129
129
  ...(explicitPeerKind ? { peerKind: explicitPeerKind } : {}),
130
130
  });
131
131
  }
@@ -134,11 +134,6 @@ export function resolveThreadCommandArgv(argv, context = {}) {
134
134
  throw new Error('Topic name is required');
135
135
  request.name = positional[1];
136
136
  }
137
- if (command === 'label') {
138
- if (options.has('--clear') ? positional.length !== 1 : positional.length !== 2)
139
- throw new Error('Specify a label or --clear');
140
- request.label = options.has('--clear') ? null : positional[1];
141
- }
142
137
  if (command === 'status')
143
138
  request.topicStatus = status;
144
139
  if (command === 'rebuild-index')
@@ -81,8 +81,9 @@ export class ThreadContextStorage {
81
81
  const ts = typeof m?.ts === 'number' ? m.ts : undefined;
82
82
  if (ts === undefined || ts <= afterTimestamp || ts > now)
83
83
  return false;
84
- // 只算真实对话消息
85
- return m.dir === 'in' || m.dir === 'out';
84
+ // 只算**对端发来**的消息。本端自己在这段窗口里发的汇报(dir='out')不是
85
+ // 「来源话题有新指示」,把它们算进来会让每次跨话题发送都自带一条假空洞提示。
86
+ return m.dir === 'in';
86
87
  });
87
88
  if (hits.length === 0)
88
89
  return { hasNewMessages: false, count: 0 };
@@ -87,8 +87,6 @@ async function _executeThreadOperation(request, threadService, sendSystemMsg) {
87
87
  selfAid,
88
88
  peer: request.peer,
89
89
  status: request.status,
90
- label: request.label ?? undefined,
91
- unlabeled: request.unlabeled,
92
90
  sort: request.sort,
93
91
  page: request.page,
94
92
  limit: request.limit,
@@ -130,10 +128,10 @@ async function _executeThreadOperation(request, threadService, sendSystemMsg) {
130
128
  warning = `索引异常:${result.missing} 条 session 文件缺失(数据问题),${result.stale} 条属性与文件不一致(写盘时序)`;
131
129
  }
132
130
  else if (result.missing > 0) {
133
- warning = `索引异常:${result.missing} 条 session 文件缺失,rebuild-index 后相关话题的 rename/label/status 改动将回退`;
131
+ warning = `索引异常:${result.missing} 条 session 文件缺失,rebuild-index 后相关话题的 rename/status 改动将回退`;
134
132
  }
135
133
  else if (result.stale > 0) {
136
- warning = `索引轻微不一致:${result.stale} 条话题属性(name/label/status)与 session 文件最后一行不同步,rebuild-index 可修复`;
134
+ warning = `索引轻微不一致:${result.stale} 条话题属性(name/status)与 session 文件最后一行不同步,rebuild-index 可修复`;
137
135
  }
138
136
  return { ok: true, result, indexWarning: warning };
139
137
  }
@@ -164,7 +162,6 @@ async function _executeThreadOperation(request, threadService, sendSystemMsg) {
164
162
  peer: request.peer,
165
163
  peerKind,
166
164
  name: request.name,
167
- label: request.label ?? undefined,
168
165
  topicStatus: request.topicStatus,
169
166
  });
170
167
  if (sendSystemMsg) {
@@ -208,14 +205,6 @@ async function _executeThreadOperation(request, threadService, sendSystemMsg) {
208
205
  });
209
206
  return { ok: true, result };
210
207
  }
211
- case 'label': {
212
- const { peer, threadId } = request;
213
- if (!peer || !isTopicThreadId(threadId)) {
214
- return { ok: false, code: 'MISSING_ARGS', error: '标签只适用于话题(主话题没有标签)' };
215
- }
216
- await threadService.labelThread({ selfAid, peer, threadId, label: request.label ?? null });
217
- return { ok: true };
218
- }
219
208
  case 'status': {
220
209
  const { peer, threadId } = request;
221
210
  if (!peer || !isTopicThreadId(threadId) || !request.topicStatus) {
@@ -233,8 +233,7 @@ export class ThreadService {
233
233
  channelType: parsedDir.channelType,
234
234
  peerKind: last.chatType === 'group' ? 'group' : 'private',
235
235
  name: last.name ?? threadId,
236
- label: last.label ?? null,
237
- topicStatus: last.topicStatus ?? 'pending',
236
+ topicStatus: last.topicStatus ?? 'active',
238
237
  createdAt: last.createdAt ?? 0,
239
238
  lastActiveAt: last.updatedAt ?? 0,
240
239
  ...(typeof last.metadata?.nameUpdatedAt === 'number'
@@ -262,7 +261,7 @@ export class ThreadService {
262
261
  }
263
262
  // ── P1a.1.2: 话题创建 ──
264
263
  async createThread(input) {
265
- const { selfAid, peerKind, name, label, topicStatus } = input;
264
+ const { selfAid, peerKind, name, topicStatus } = input;
266
265
  const peer = normalizeThreadPeer(input.peer) ?? input.peer;
267
266
  // Validate name
268
267
  const sanitized = sanitizeSessionTitle(name);
@@ -293,8 +292,7 @@ export class ThreadService {
293
292
  'aun', // channelType
294
293
  peerKind === 'group' ? 'group' : 'agent', // peerType
295
294
  undefined, // identity
296
- label, // label
297
- topicStatus ?? 'pending');
295
+ topicStatus ?? 'active');
298
296
  const entry = {
299
297
  threadId,
300
298
  sessionId: session.id,
@@ -303,8 +301,7 @@ export class ThreadService {
303
301
  peerKind,
304
302
  name: sanitized,
305
303
  nameUpdatedAt: now,
306
- label: label ?? null,
307
- topicStatus: topicStatus ?? 'pending',
304
+ topicStatus: topicStatus ?? 'active',
308
305
  createdAt: now,
309
306
  lastActiveAt: now,
310
307
  };
@@ -409,8 +406,7 @@ export class ThreadService {
409
406
  peerKind: input.peerKind ?? 'private',
410
407
  name: sanitized,
411
408
  nameUpdatedAt: input.nameUpdatedAt,
412
- label: null,
413
- topicStatus: 'pending',
409
+ topicStatus: 'active',
414
410
  createdAt: input.nameUpdatedAt,
415
411
  lastActiveAt: input.nameUpdatedAt,
416
412
  });
@@ -426,23 +422,6 @@ export class ThreadService {
426
422
  await this.sessionManager.renameSession(session.id, sanitized, input.nameUpdatedAt);
427
423
  return { applied: true };
428
424
  }
429
- // ── P1a.1.6: 话题标签 ──
430
- async labelThread(input) {
431
- const { selfAid, threadId, label } = input;
432
- const peer = normalizeThreadPeer(input.peer) ?? input.peer;
433
- const index = this.readThreadIndex(selfAid);
434
- const entry = index.threads.find(t => t.peer === peer && t.threadId === threadId);
435
- if (!entry)
436
- throw new ThreadServiceError(`话题不存在: ${threadId}`, 'TOPIC_NOT_FOUND');
437
- entry.label = label;
438
- entry.lastActiveAt = Date.now();
439
- this.writeThreadIndex(selfAid, index);
440
- this.appendThreadSnapshot(selfAid, entry);
441
- const session = await this.sessionManager.getThreadSession(entryChannelType(entry), entry.peer, threadId, selfAid);
442
- if (session) {
443
- await this.sessionManager.setTopicLabel(session.id, label);
444
- }
445
- }
446
425
  // ── P1a.1.6: 话题状态 ──
447
426
  async statusThread(input) {
448
427
  const { selfAid, threadId, topicStatus } = input;
@@ -557,12 +536,12 @@ export class ThreadService {
557
536
  }
558
537
  // ── list ──
559
538
  listThreads(input) {
560
- const { selfAid, status, label, unlabeled, sort, page = 1, limit: rawLimit } = input;
539
+ const { selfAid, status, sort, page = 1, limit: rawLimit } = input;
561
540
  const peer = normalizeThreadPeer(input.peer);
562
541
  const limit = Math.min(rawLimit ?? LIST_DEFAULT_LIMIT, LIST_MAX_LIMIT);
563
542
  const { index, state: indexState } = this.readThreadIndexWithState(selfAid);
564
543
  // 未套过滤条件的话题数:用于把「该对端确实没有话题」与
565
- // 「有话题但被 --status/--label 挡掉」区分开。
544
+ // 「有话题但被 --status 挡掉」区分开。
566
545
  const peerTopicCount = peer
567
546
  ? index.threads.filter(t => normalizeThreadPeer(t.peer) === peer).length
568
547
  : index.threads.length;
@@ -571,10 +550,6 @@ export class ThreadService {
571
550
  return false;
572
551
  if (status && t.topicStatus !== status)
573
552
  return false;
574
- if (unlabeled && t.label)
575
- return false;
576
- if (label && t.label !== label)
577
- return false;
578
553
  return true;
579
554
  });
580
555
  // 主话题由会话文件产生、从不进话题索引。只列话题会让「和某对端聊过什么」
@@ -613,7 +588,6 @@ export class ThreadService {
613
588
  // 读真实值而不是写死 `主会话`:否则列表里的名字和会话存档对不上,
614
589
  // 用户也没法从列表确认改名是否生效。`[主话题]` 前缀由 CLI 渲染。
615
590
  name: active?.name || '主会话',
616
- label: null,
617
591
  createdAt: lastTs,
618
592
  lastActiveAt: lastTs,
619
593
  mainSession: true,
@@ -622,9 +596,9 @@ export class ThreadService {
622
596
  msg24h: 0,
623
597
  lastMsgSnippet: '',
624
598
  };
625
- // 该对端没有任何主会话往来时不造空行;状态/标签过滤对主会话也无意义,
599
+ // 该对端没有任何主会话往来时不造空行;状态过滤对主会话无意义,
626
600
  // 只在未过滤时加入。
627
- if (lastTs > 0 && !status && !label && !unlabeled)
601
+ if (lastTs > 0 && !status)
628
602
  threads = [synthetic, ...threads];
629
603
  }
630
604
  }
@@ -717,7 +691,7 @@ export class ThreadService {
717
691
  return {
718
692
  threads, total, page, limit,
719
693
  hasMore: offset + threads.length < total,
720
- totalMsgCount, peer, selfAid, sort, status, label, unlabeled,
694
+ totalMsgCount, peer, selfAid, sort, status,
721
695
  peerKnown, peerTopicCount, hasMainChat, indexState,
722
696
  };
723
697
  }
@@ -853,8 +827,7 @@ export class ThreadService {
853
827
  : typeof last.nameUpdatedAt === 'number'
854
828
  ? { nameUpdatedAt: last.nameUpdatedAt }
855
829
  : {}),
856
- label: last.label ?? null,
857
- topicStatus: last.topicStatus ?? 'pending',
830
+ topicStatus: last.topicStatus ?? 'active',
858
831
  createdAt: last.createdAt ?? 0,
859
832
  lastActiveAt: last.updatedAt ?? 0,
860
833
  });
@@ -873,7 +846,7 @@ export class ThreadService {
873
846
  /**
874
847
  * 检查话题索引的健康状态,区分两类问题:
875
848
  * missing — _threads JSONL 文件不存在(数据问题,严重,rebuild 会丢失属性改动)
876
- * stale — 文件存在但最后一行的 name/label/topicStatus 与索引不一致(写盘时序问题,轻微)
849
+ * stale — 文件存在但最后一行的 name/topicStatus 与索引不一致(写盘时序问题,轻微)
877
850
  */
878
851
  checkIndex(selfAid) {
879
852
  const index = this.readThreadIndex(selfAid);
@@ -888,13 +861,12 @@ export class ThreadService {
888
861
  missingIds.push(entry.threadId);
889
862
  continue;
890
863
  }
891
- // 检查最后一行是否与索引一致(name / label / topicStatus)
864
+ // 检查最后一行是否与索引一致(name / topicStatus)
892
865
  try {
893
866
  const lines = readAllJsonlLines(metaPath);
894
867
  const last = lines[lines.length - 1];
895
868
  if (last && (last.name !== entry.name ||
896
- (last.label ?? null) !== (entry.label ?? null) ||
897
- (last.topicStatus ?? 'pending') !== entry.topicStatus)) {
869
+ (last.topicStatus ?? 'active') !== entry.topicStatus)) {
898
870
  staleIds.push(entry.threadId);
899
871
  }
900
872
  }
@@ -927,7 +899,6 @@ export class ThreadService {
927
899
  peerKind: session.chatType === 'group' ? 'group' : 'private',
928
900
  name: session.name ?? peer,
929
901
  nameUpdatedAt: typeof session.metadata?.nameUpdatedAt === 'number' ? session.metadata.nameUpdatedAt : undefined,
930
- label: session.label ?? null,
931
902
  createdAt: session.createdAt ?? 0,
932
903
  lastActiveAt: session.updatedAt ?? 0,
933
904
  running: session.processingState?.startsWith('processing') ?? false,
@@ -946,7 +917,6 @@ export class ThreadService {
946
917
  peerKind: entry.peerKind,
947
918
  name: entry.name,
948
919
  nameUpdatedAt: undefined,
949
- label: null,
950
920
  createdAt: entry.createdAt,
951
921
  lastActiveAt: entry.lastActiveAt,
952
922
  running: false,
@@ -1014,7 +984,7 @@ export class ThreadService {
1014
984
  }
1015
985
  /**
1016
986
  * 把话题的当前元数据追加一行到 _threads/<sessionId>.jsonl,
1017
- * 使 rebuildIndex 读最后一行时能拿到 rename/label/status 后的最新值。
987
+ * 使 rebuildIndex 读最后一行时能拿到 rename/status 后的最新值。
1018
988
  * 追加的行以最后一行(当前权威快照)为底,只覆盖话题字段,
1019
989
  * 确保 readMetaLatest 读最后一行时不报 "baseagent is empty"。
1020
990
  *
@@ -1042,7 +1012,6 @@ export class ThreadService {
1042
1012
  threadId: entry.threadId,
1043
1013
  channelIdAlias: entry.peer,
1044
1014
  name: entry.name,
1045
- label: entry.label,
1046
1015
  topicStatus: entry.topicStatus,
1047
1016
  createdAt: entry.createdAt,
1048
1017
  createdAtStr: latest.createdAtStr ?? '',
@@ -217,7 +217,7 @@ export function readOwnerDirectoryMembership(selfAid, aid, appOwned = false) {
217
217
  // App 侧一律按目录不可用处理,不因"没数据"放宽。
218
218
  if (!appOwned)
219
219
  return undefined;
220
- logDirectoryAdmissionUnavailable(selfAid, aid, 'snapshot_missing');
220
+ logDirectoryAdmissionUnavailable(selfAid, aid, 'snapshot_missing', ownerResolver.owner(selfAid));
221
221
  return { category: 'unavailable' };
222
222
  }
223
223
  // ownerAid 优先取快照信封:它自证归属,离线也能用。解析器只在没有快照时兜底。
@@ -46,6 +46,8 @@ export const OWNER_DIRECTORY_APPLY_WAIT_MS = 300;
46
46
  * 退避按时间而不是按次数,既不会造成拉取风暴,也不会永久放弃。
47
47
  */
48
48
  export const OWNER_DIRECTORY_PULL_BACKOFF_MS = [15_000, 30_000, 60_000, 120_000, 240_000, 480_000, 960_000, 1_800_000, 3_600_000];
49
+ /** A denied credential needs a grant/change event, a new runtime, or an hourly probe. */
50
+ const PERMISSION_DENIED_PROBE_MS = 3_600_000;
49
51
  /**
50
52
  * 拉取前的防抖窗口。
51
53
  *
@@ -149,6 +151,7 @@ class OwnerDirectoryCoordinator {
149
151
  pullGeneration = 0;
150
152
  /** 已经计过失败的那一轮序号;同一轮无论几个 agent 报告都只记一次。 */
151
153
  countedFailureGeneration;
154
+ deniedUntil = new Map();
152
155
  constructor(ownerAid) {
153
156
  this.ownerAid = ownerAid;
154
157
  }
@@ -169,10 +172,14 @@ class OwnerDirectoryCoordinator {
169
172
  }
170
173
  /** 距离退避窗口结束还有多久;0 表示可以立刻拉取。 */
171
174
  backoffRemainingMs(now) {
172
- if (this.failures === 0 || this.lastFailureAtMs === undefined)
173
- return 0;
174
- const window = OWNER_DIRECTORY_PULL_BACKOFF_MS[Math.min(this.failures, OWNER_DIRECTORY_PULL_BACKOFF_MS.length) - 1];
175
- return Math.max(0, this.lastFailureAtMs + window - now);
175
+ const window = this.failures === 0 || this.lastFailureAtMs === undefined ? 0
176
+ : Math.max(0, this.lastFailureAtMs
177
+ + OWNER_DIRECTORY_PULL_BACKOFF_MS[Math.min(this.failures, OWNER_DIRECTORY_PULL_BACKOFF_MS.length) - 1] - now);
178
+ if (!this.deniedUntil.size)
179
+ return window;
180
+ const candidates = [...this.caches].filter(cache => !cache.isRetired() && !cache.isRevoked());
181
+ const permissionWait = candidates.length ? Math.min(...candidates.map(cache => Math.max(0, (this.deniedUntil.get(cache) ?? 0) - now))) : 0;
182
+ return Math.max(window, permissionWait);
176
183
  }
177
184
  clearFailures() {
178
185
  this.failures = 0;
@@ -184,28 +191,24 @@ class OwnerDirectoryCoordinator {
184
191
  *
185
192
  * 判据是「实例还活着 + 它有授权」——授权凭证是 per-agent 的,协调者没有
186
193
  * 自己的身份,所以必须借一个。优先选最近活跃的,避免挑到一个正在停止中的。
187
- * 被远端拒过的实例排在后面:它多半还会被拒,但全员都被拒时仍要有人去试,
188
- * 否则名录永远不更新。被拒只影响这里,不影响任何一方能不能用名录。
194
+ * 明确被拒的凭证暂停一小时;新授权、新通知或新运行时可提前恢复候选资格。
195
+ * 被拒只影响远端拉取,不影响读取已有本地快照。
189
196
  */
190
- pickExecutor(preferred) {
197
+ pickExecutor(preferred, now) {
191
198
  // 优先用发起方自己:它一定想拿到这份数据,结果也直接回给它。
192
199
  // 只有它自身不可用(授权失效/已退役/刚被远端拒过)时才退到别人,避免出现
193
200
  // 「A 触发、却被 B 的代拉结果覆盖」这种观测不到的错配。
194
201
  // 执行者资格只看"实例还活着、没被远端拒过"——没有本地凭证可审了。
195
- const usable = (cache) => !cache.isRetired() && !cache.isRevoked();
196
- if (preferred && usable(preferred) && !preferred.pullBlocked())
202
+ const usable = (cache) => !cache.isRetired() && !cache.isRevoked()
203
+ && (this.deniedUntil.get(cache) ?? 0) <= now;
204
+ if (preferred && usable(preferred))
197
205
  return preferred;
198
206
  for (const cache of this.caches) {
199
207
  if (cache.isRetired()) {
200
208
  this.caches.delete(cache);
209
+ this.deniedUntil.delete(cache);
201
210
  continue;
202
211
  }
203
- if (usable(cache) && !cache.pullBlocked())
204
- return cache;
205
- }
206
- if (preferred && usable(preferred))
207
- return preferred;
208
- for (const cache of this.caches) {
209
212
  if (usable(cache))
210
213
  return cache;
211
214
  }
@@ -469,6 +472,7 @@ export class OwnerDirectoryCache {
469
472
  return;
470
473
  }
471
474
  this.writeRevocationState(false);
475
+ coordinatorFor(this.options.ownerAid).deniedUntil.delete(this);
472
476
  this.clearPullFailures();
473
477
  logger.info(`[OwnerDirectoryCache] Owner directory grant applied: status=${result.status} (no local credential stored)`);
474
478
  this._logAction({
@@ -558,6 +562,7 @@ export class OwnerDirectoryCache {
558
562
  ...(contentDigest ? { contentDigest } : {}),
559
563
  receivedAtMs: this.now(),
560
564
  };
565
+ coordinator.deniedUntil.delete(this);
561
566
  // 新通知意味着新的变更意图:退避归零,立刻给一次机会。
562
567
  coordinator.clearFailures();
563
568
  this.writePendingUpdate({
@@ -720,6 +725,7 @@ export class OwnerDirectoryCache {
720
725
  // 若各自 ++,一次网络故障就会把退避直接推到封顶。
721
726
  coordinator.recordFailure(this.now(), coordinator.pullGeneration);
722
727
  const failures = coordinator.failures;
728
+ const next = coordinator.backoffRemainingMs(this.now());
723
729
  this._logAction({
724
730
  action: 'error',
725
731
  trigger: trigger ?? (pending.operationId.startsWith('notification-') ? 'notification' : 'startup'),
@@ -728,9 +734,8 @@ export class OwnerDirectoryCache {
728
734
  sharedGeneration: coordinator.epoch?.generation,
729
735
  error: errorText(error),
730
736
  detail: `拉取失败(连续第 ${failures} 次,下一档退避 `
731
- + `${OWNER_DIRECTORY_PULL_BACKOFF_MS[Math.min(failures, OWNER_DIRECTORY_PULL_BACKOFF_MS.length) - 1]}ms)`,
737
+ + `${next}ms)`,
732
738
  });
733
- const next = OWNER_DIRECTORY_PULL_BACKOFF_MS[Math.min(failures, OWNER_DIRECTORY_PULL_BACKOFF_MS.length) - 1];
734
739
  const message = `[OwnerDirectoryCache] Pending pull failed (${failures} in a row, next retry in ${next}ms): ${errorText(error)}`;
735
740
  // 连续失败不是抖动:升级日志级别,让"名录一直没更新"能被发现,
736
741
  // 而不是翻两小时前的 WARN 才知道。
@@ -810,12 +815,8 @@ export class OwnerDirectoryCache {
810
815
  const outcome = coordinator.pulling
811
816
  ? await coordinator.pulling
812
817
  : await this._startCoordinatedPull(coordinator, trigger, operationId, hintDigest);
813
- // 远端明确拒绝:标记 blocked 让别的 agent 去拉,重试没有意义。逐个 scope 处理,
814
- // 因为一次拉取里可能多个 scope 都被拒;共用同一个 Promise 的调用方也各自执行这一步。
815
- // 只认远端结论,本地不再有凭证可以判"该不该被拒"。
816
- for (const scope of outcome.denied) {
817
- await this.blockScope(scope);
818
- }
818
+ // Only the executor's credential was tested. Single-flight waiters must not
819
+ // inherit its denial; one of them may be able to supply the shared snapshot.
819
820
  const complete = this._assertComplete(outcome.data, outcome.failures);
820
821
  return complete;
821
822
  }
@@ -840,11 +841,25 @@ export class OwnerDirectoryCache {
840
841
  return { data: cached, denied: [], failures: {} };
841
842
  }
842
843
  }
843
- const executor = coordinator.pickExecutor(this);
844
+ let executor = coordinator.pickExecutor(this, this.now());
844
845
  if (!executor) {
845
- throw new OwnerDirectoryCacheError('NOT_AUTHORIZED', 'no agent with a valid owner directory authorization to pull for');
846
+ throw new OwnerDirectoryCacheError('PERMISSION_DENIED', 'no owner directory executor is currently eligible to pull');
847
+ }
848
+ let result;
849
+ const attempted = new Set();
850
+ while (true) {
851
+ attempted.add(executor);
852
+ result = await executor._doFetch();
853
+ if (!result.denied.length)
854
+ break;
855
+ coordinator.deniedUntil.set(executor, this.now() + PERMISSION_DENIED_PROBE_MS);
856
+ for (const scope of result.denied)
857
+ await executor.blockScope(scope);
858
+ const alternative = coordinator.pickExecutor(undefined, this.now());
859
+ if (!alternative || attempted.has(alternative))
860
+ break;
861
+ executor = alternative;
846
862
  }
847
- const result = await executor._doFetch();
848
863
  const written = executor._commitSharedCache(result.data, trigger, operationId, startedAt);
849
864
  if (written) {
850
865
  // 执行者**自己**先同步落地:`onSnapshotApplying` 这类前置校验失败必须
@@ -1424,8 +1439,8 @@ export class OwnerDirectoryCache {
1424
1439
  if (this.canMutate())
1425
1440
  this.options.onError?.(scope, normalized);
1426
1441
  this._appendFetchFailure(scope, code, errorText(normalized));
1427
- // 远端拒绝随结果返回,由调用方作废自己的本地快照;其它错误保持 pending,
1428
- // 交给时间退避重试。拒绝信息必须在返回值里走——单飞复用者也要看得到。
1442
+ // The coordinator suspends only this executor's denied credential.
1443
+ // Existing snapshots remain usable, and other executors may still fetch.
1429
1444
  if (isPermissionDenied(normalized))
1430
1445
  denied.push(scope);
1431
1446
  }
@@ -1942,6 +1957,8 @@ export class OwnerDirectoryCache {
1942
1957
  ownerAid: this.options.ownerAid,
1943
1958
  selfAid: this.options.selfAid,
1944
1959
  snapshot,
1960
+ // 备注不走命令,注入里要写出文件的真实位置,模型才知道往哪写。
1961
+ directory: this.options.directory,
1945
1962
  remarks: this.remarksSnapshot(),
1946
1963
  policy: resolveOwnerDirectoryRenderPolicy(this.options.selfAid, snapshot),
1947
1964
  // `config.team` 每轮现读:Owner 在 App 里改完团队成员,下一次重算就生效。
@@ -1,6 +1,6 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
- import { splitAliases } from './owner-directory-remarks.js';
3
+ import { OWNER_DIRECTORY_REMARKS_DIR, splitAliases, } from './owner-directory-remarks.js';
4
4
  import { classifyEntry, entryOwnerAid, isInPaTeam, ownerRefAid, } from './owner-directory-scope.js';
5
5
  /** ECK 载入的名录文件,与名录快照同目录。 */
6
6
  export const OWNER_DIRECTORY_MARKDOWN_FILE = 'directory.md';
@@ -76,6 +76,17 @@ export function resolveMyAgentTeamAids(team, snapshot, selfAid, ownerAid) {
76
76
  const visible = total.slice(0, MY_AGENT_TEAM_LIMIT);
77
77
  return { visible, total: total.length, dropped: total.length - visible.length };
78
78
  }
79
+ /**
80
+ * 注入内容里示例备注文件的路径。
81
+ *
82
+ * 备注不走命令,模型必须知道写哪个文件才不会靠猜。知道 `directory/` 的真实位置时
83
+ * 写绝对路径;不知道(测试、或调用方没传)时回落成占位写法,不编一个假路径。
84
+ */
85
+ function remarksExamplePath(input) {
86
+ return input.directory
87
+ ? path.join(input.directory, OWNER_DIRECTORY_REMARKS_DIR, '<AID>.md')
88
+ : '<agent 目录>/directory/remarks/<AID>.md';
89
+ }
79
90
  export function renderOwnerDirectoryMarkdown(input) {
80
91
  const { selfAid, ownerAid, snapshot, remarks } = input;
81
92
  if (!snapshot)
@@ -161,6 +172,7 @@ export function renderOwnerDirectoryMarkdown(input) {
161
172
  '- `ec directory request <AID> [--note <说明>]`:给一个**还不在名录里**的人发加好友申请。',
162
173
  ' 只表示申请已提交,要等 Owner 在 App 上处理并同步名录后,才可能联系得上。',
163
174
  '- 需要名片原文时:`ec aid agentmd get <AID>`。',
175
+ `- **备注不走命令**:直接写 \`${remarksExamplePath(input)}\`,frontmatter 用 \`aid\`/\`remark\`/\`updated_at\`,正文写「什么事找他」,写完 \`ec directory refresh\`。文件名须与 \`aid\` 一致,否则整条作废。`,
164
176
  ];
165
177
  if (owner?.aid) {
166
178
  head.push('', '## Owner(1)', identityRow(owner.aid, owner.name, remarks?.get(owner.aid)));
@@ -22,6 +22,7 @@ import { isInternalEntry, ownerRefAid } from './owner-directory-scope.js';
22
22
  import { editDistance, normalizeDirectoryText, sameDirectoryName, stripTrailingParenthetical, } from './owner-directory-text.js';
23
23
  import { ownerResolver } from '../core/ownership/owner-resolver.js';
24
24
  import { snapshotOwnerAid, refreshOwnerDirectory, syncOwnerDirectoryForLookup } from './owner-directory-admission.js';
25
+ import { mutatePeerBook } from '../config/peer-book-store.js';
25
26
  import { getPeerSnapshot } from '../config/peer-book.js';
26
27
  import { resolveEntryContactable, resolveMyAgentTeam } from './owner-directory-policy.js';
27
28
  import { resolveMyAgentTeamAids } from './owner-directory-markdown.js';
@@ -43,8 +44,8 @@ export function resolveDirectoryQueryCommand(argv) {
43
44
  const [rawAction, ...rest] = argv;
44
45
  const action = rawAction;
45
46
  if (action !== 'list' && action !== 'info'
46
- && action !== 'refresh' && action !== 'blocked') {
47
- throw new DirectoryQueryError('INVALID_ACTION', 'directory requires one of: list, info, refresh, blocked');
47
+ && action !== 'refresh' && action !== 'blocked' && action !== 'block' && action !== 'unblock') {
48
+ throw new DirectoryQueryError('INVALID_ACTION', 'directory requires one of: list, info, refresh, blocked, block, unblock');
48
49
  }
49
50
  const selfAid = takeFlag(rest, '--self') ?? process.env.EVOLCORE_SELF_AID?.trim();
50
51
  if (!selfAid)
@@ -57,6 +58,12 @@ export function resolveDirectoryQueryCommand(argv) {
57
58
  const page = parsePage(takeFlag(rest, '--page'));
58
59
  const ownerAid = parseOwnerFilter(takeFlag(rest, '--owner'));
59
60
  const positional = takePositional(rest);
61
+ if (action === 'block' || action === 'unblock') {
62
+ if (positional.length !== 1 || !isValidAid(positional[0])) {
63
+ throw new DirectoryQueryError('INVALID_ARGUMENT', action + ' requires one valid target AID');
64
+ }
65
+ return { action, selfAid, target: positional[0] };
66
+ }
60
67
  if (action === 'info') {
61
68
  const target = positional.join(' ').trim();
62
69
  if (!target)
@@ -100,13 +107,32 @@ export function resolveDirectoryQueryCommand(argv) {
100
107
  * 快照优先取 channel 正在用的实例(能共享模块级单飞);拿不到时构造一个只读实例,
101
108
  * 读本地文件即可——查询不需要网络,除非关键词未命中要触发同步。
102
109
  */
103
- export async function executeDirectoryQueryCommand(command) {
110
+ export async function executeDirectoryQueryCommand(command, actorId = 'local-cli') {
104
111
  const directory = path.join(agentDir(command.selfAid), 'directory');
105
112
  if (!fs.existsSync(agentDir(command.selfAid))) {
106
113
  return { ok: false, code: 'AGENT_NOT_FOUND', error: `agent ${command.selfAid} does not exist` };
107
114
  }
115
+ if (command.action === 'block' || command.action === 'unblock') {
116
+ try {
117
+ const result = await mutatePeerBook({
118
+ selfAid: command.selfAid, actor: actorId,
119
+ mutation: { type: 'set-status', primaryId: command.target,
120
+ status: command.action === 'block' ? 'blocked' : 'active' },
121
+ });
122
+ return { ok: true, action: command.action, selfAid: command.selfAid, targetAid: command.target,
123
+ blocked: command.action === 'block', changed: result.changed };
124
+ }
125
+ catch (error) {
126
+ return { ok: false, code: error.code ?? 'BLACKLIST_WRITE_FAILED',
127
+ error: error instanceof Error ? error.message : String(error) };
128
+ }
129
+ }
108
130
  // ownerAid 取自快照信封:快照自证归属,离线也能用。解析器只在没有快照时兜底。
109
131
  const ownerAid = snapshotOwnerAid(directory, command.selfAid) ?? ownerResolver.owner(command.selfAid);
132
+ if (!ownerAid && command.action === 'blocked') {
133
+ return { ok: true, action: 'blocked', entries: [...getPeerSnapshot(command.selfAid).blockedIndex]
134
+ .sort().map(aid => ({ aid, source: 'local', contactable: false })) };
135
+ }
110
136
  if (!ownerAid) {
111
137
  return { ok: false, code: 'NOT_AUTHORIZED', error: 'directory is not available for this agent' };
112
138
  }
@@ -2,9 +2,17 @@
2
2
  * 本地备注:`$AGENT_DIR/directory/remarks/<aid>.md`。
3
3
  *
4
4
  * 备注描述的是"这个 agent 自己怎么看这个人",和 Owner 侧发布的远端条目不是
5
- * 一回事,所以存在本地、由个人助理通过 `ec directory remark` 命令维护,
6
- * 引擎只读。渲染目录时按 AID 覆盖远端的 `description`(正文)和 `remark`
7
- * (frontmatter)。
5
+ * 一回事,所以存在本地、由 Agent 自己用文件工具直接读写,引擎只读。
6
+ *
7
+ * **没有对应命令**:备注只落在写者自己的 agent 目录里,没有跨目录写入的需求,
8
+ * 包一层 CLI + daemon IPC 只是把"写一个文件"变复杂。原先的
9
+ * `ec directory remark get|set|rm` 已在 `7a2f5032` 下线,改完 `ec directory
10
+ * refresh` 即重算注入。
11
+ *
12
+ * 渲染目录时按 AID 覆盖远端的 `description`(正文)和 `remark`(frontmatter)。
13
+ *
14
+ * 文件位置:`$AGENT_DIR/directory/remarks/<aid>.md`(`$EVOLCORE_HOME/agents/<自己的 AID>/directory/remarks/`)。
15
+ * 文件名必须与 frontmatter 的 `aid` 一致,否则整条作废——防止备注挂到别人头上。
8
16
  *
9
17
  * 文件格式:
10
18
  *