evolcore 0.0.41-test.0 → 0.0.41-test.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/agents/baseagent-availability.js +1 -1
  3. package/dist/agents/baseagent.js +88 -49
  4. package/dist/agents/claude-runner.js +177 -92
  5. package/dist/agents/codex-runner.js +146 -71
  6. package/dist/agents/ecagent-runner.js +1 -1
  7. package/dist/agents/gemini-runner.js +1 -1
  8. package/dist/aun/aid/agentmd.js +98 -11
  9. package/dist/aun/aid/client.js +1 -1
  10. package/dist/aun/aid/control-aid.js +26 -2
  11. package/dist/aun/aid/identity.js +91 -0
  12. package/dist/aun/aid/index.js +1 -1
  13. package/dist/aun/aid/managed-operation.js +1 -1
  14. package/dist/aun/aid/ownership-operation.js +23 -22
  15. package/dist/aun/group/fs-download.js +39 -0
  16. package/dist/aun/group/identity.js +36 -21
  17. package/dist/aun/group/operations.js +5 -0
  18. package/dist/aun/menu/client.js +27 -0
  19. package/dist/aun/msg/managed-operation.js +68 -7
  20. package/dist/aun/msg/p2p.js +8 -8
  21. package/dist/aun/service-proxy.js +53 -12
  22. package/dist/channels/aun.js +633 -32
  23. package/dist/channels/daemon.js +15 -1
  24. package/dist/cli/agent-command.js +5 -2
  25. package/dist/cli/agent-create.js +991 -233
  26. package/dist/cli/agent.js +49 -10
  27. package/dist/cli/aid-bind-command.js +48 -19
  28. package/dist/cli/aun-commands.js +48 -36
  29. package/dist/cli/daemon-commands.js +679 -697
  30. package/dist/cli/fs-command.js +64 -2
  31. package/dist/cli/index.js +72 -5
  32. package/dist/cli/init-channel.js +1 -1
  33. package/dist/cli/init.js +75 -1
  34. package/dist/cli/managed-command-guard.js +17 -1
  35. package/dist/cli/model.js +40 -40
  36. package/dist/cli/provider-command.js +57 -0
  37. package/dist/cli/proxy-command.js +92 -0
  38. package/dist/cli/restart-monitor.js +4 -2
  39. package/dist/cli/role.js +85 -0
  40. package/dist/cli/stats.js +10 -3
  41. package/dist/cli/task-context.js +19 -0
  42. package/dist/config/access-policy.js +7 -2
  43. package/dist/config/boot-log.js +39 -1
  44. package/dist/config/config-field-policy.js +17 -39
  45. package/dist/config/config-manager.js +183 -44
  46. package/dist/config/config-operation-service.js +5 -19
  47. package/dist/config/contact-book-store.js +47 -21
  48. package/dist/config/contact-book.js +18 -12
  49. package/dist/config/contact-operation-service.js +3 -4
  50. package/dist/config/contact-request-service.js +11 -0
  51. package/dist/config/daemon-services.js +11 -0
  52. package/dist/config/gateway-config.js +88 -594
  53. package/dist/config/owner-config.js +2 -2
  54. package/dist/config/peer-role-resolver.js +15 -12
  55. package/dist/config/provider-ipc-service.js +132 -0
  56. package/dist/config/provider-menu-request.js +58 -0
  57. package/dist/config/providers-config.js +12 -7
  58. package/dist/config/providers-import.js +3 -21
  59. package/dist/config/providers-management.js +78 -5
  60. package/dist/config/resolved-config-op.js +11 -1
  61. package/dist/config/role-command-service.js +166 -0
  62. package/dist/config/role-request-service.js +193 -0
  63. package/dist/config/schema-migration.js +1000 -25
  64. package/dist/config-store.js +89 -4
  65. package/dist/contracts/ecweb-instance.js +41 -0
  66. package/dist/contracts/ecweb-service-protocol.js +4 -1
  67. package/dist/core/agent-application-service.js +60 -11
  68. package/dist/core/agent-create-status.js +203 -0
  69. package/dist/core/agent-creation-claim.js +177 -0
  70. package/dist/core/agent-ipc-registration.js +39 -18
  71. package/dist/core/agent-runtime.js +194 -24
  72. package/dist/core/auth/agent-delegation.js +6 -3
  73. package/dist/core/auth/auth-gateway.js +67 -2
  74. package/dist/core/auth/authorization-audit.js +58 -11
  75. package/dist/core/auth/delegation-authorization.js +5 -2
  76. package/dist/core/auth/operation-authorizer.js +43 -6
  77. package/dist/core/auth/operation-catalog.js +45 -7
  78. package/dist/core/channel-loader.js +2 -0
  79. package/dist/core/command/agent-control.js +260 -21
  80. package/dist/core/command/agent-storage-menu.js +5 -3
  81. package/dist/core/command/cli-intent-parser.js +8 -3
  82. package/dist/core/command/command-handler.js +112 -154
  83. package/dist/core/command/connect-menu.js +11 -3
  84. package/dist/core/command/data-root-resolver.js +5 -4
  85. package/dist/core/command/memory-slash.js +16 -8
  86. package/dist/core/command/menu-catalog.js +10 -6
  87. package/dist/core/command/menu-handler.js +106 -73
  88. package/dist/core/command/menu-protocol.js +15 -1
  89. package/dist/core/command/provider-menu.js +46 -0
  90. package/dist/core/command/role-menu.js +147 -30
  91. package/dist/core/command/slash-handler.js +125 -255
  92. package/dist/core/daemon-control.js +26 -27
  93. package/dist/core/event-catalog.js +10 -0
  94. package/dist/core/evolagent-registry.js +7 -5
  95. package/dist/core/evolagent.js +10 -8
  96. package/dist/core/file-integrity/store.js +11 -0
  97. package/dist/core/handoff/ipc-registration.js +3 -0
  98. package/dist/core/inference/text-inference.js +31 -40
  99. package/dist/core/initialization/service.js +491 -0
  100. package/dist/core/ipc-registration.js +40 -24
  101. package/dist/core/memory/consolidation-context.js +51 -5
  102. package/dist/core/memory/consolidation-ops-records.js +96 -1
  103. package/dist/core/memory/consolidation-trigger.js +208 -191
  104. package/dist/core/memory/consolidation.js +333 -35
  105. package/dist/core/memory/index-manager.js +27 -5
  106. package/dist/core/memory/memory-admin.js +45 -5
  107. package/dist/core/memory/memory-writer.js +163 -18
  108. package/dist/core/memory/relation-idle-monitor.js +119 -58
  109. package/dist/core/memory/relation-sweep.js +55 -45
  110. package/dist/core/message/aun-ipc-sender.js +81 -69
  111. package/dist/core/message/im-renderer.js +25 -4
  112. package/dist/core/message/message-admission.js +89 -4
  113. package/dist/core/message/message-bridge.js +66 -21
  114. package/dist/core/message/response-engine.js +108 -35
  115. package/dist/core/model/catalog-service.js +5 -3
  116. package/dist/core/model/config-scope.js +29 -71
  117. package/dist/core/model/field-scope.js +1 -1
  118. package/dist/core/model/model-catalog.js +30 -41
  119. package/dist/core/model/model-diagnostics.js +4 -3
  120. package/dist/core/model/model-fallback.js +10 -7
  121. package/dist/core/model/model-permission.js +3 -2
  122. package/dist/core/ownership/owner-resolver.js +772 -158
  123. package/dist/core/permission/approval-gateway.js +103 -403
  124. package/dist/core/permission/ec-command-parser.js +62 -6
  125. package/dist/core/permission/index.js +1 -0
  126. package/dist/core/permission/permission-result.js +78 -0
  127. package/dist/core/permission/sandbox-runtime.js +18 -1
  128. package/dist/core/permission/tool-policy.js +21 -46
  129. package/dist/core/relation/peer-identity.js +64 -1
  130. package/dist/core/role/runtime-policy.js +72 -13
  131. package/dist/core/session/session-capsule.js +1 -1
  132. package/dist/core/session/session-idle-monitor.js +1 -1
  133. package/dist/core/session/session-manager.js +20 -0
  134. package/dist/core/session/session-renew.js +3 -3
  135. package/dist/core/skill/index-generator.js +15 -5
  136. package/dist/core/system-session/memory.js +43 -8
  137. package/dist/core/thread/thread-service.js +19 -6
  138. package/dist/directory/owner-directory-admission.js +95 -0
  139. package/dist/directory/owner-directory-authorization.js +309 -0
  140. package/dist/directory/owner-directory-cache.js +635 -0
  141. package/dist/eck/kit-renderer.js +2 -2
  142. package/dist/ecweb/basic-settings-service.js +33 -40
  143. package/dist/ecweb/init-menu.js +32 -0
  144. package/dist/ecweb/message-context-service.js +110 -0
  145. package/dist/index.js +93 -19
  146. package/dist/ipc.js +247 -29
  147. package/dist/paths.js +7 -0
  148. package/dist/proxy/command.js +122 -0
  149. package/dist/proxy/ipc-service.js +68 -0
  150. package/dist/proxy/manager.js +484 -0
  151. package/dist/proxy/service-supervisor.js +603 -0
  152. package/dist/response-system/engines/v1/proactive-flow.js +16 -6
  153. package/dist/trigger/authorization.js +27 -17
  154. package/dist/trigger/feedback.js +2 -3
  155. package/dist/trigger/ipc-service.js +105 -78
  156. package/dist/trigger/local-files.js +2 -1
  157. package/dist/trigger/manager.js +5 -3
  158. package/dist/trigger/scheduler.js +88 -6
  159. package/dist/utils/atomic-write.js +28 -0
  160. package/dist/utils/cross-platform.js +14 -0
  161. package/dist/utils/ecweb-supervisor.js +258 -83
  162. package/dist/utils/error-utils.js +26 -2
  163. package/dist/utils/logger.js +92 -6
  164. package/dist/utils/package-version-info.js +4 -2
  165. package/dist/utils/welcome.js +1 -1
  166. package/kits/docs/INDEX.md +1 -0
  167. package/kits/docs/aun/SDK.md +4 -1
  168. package/kits/docs/channels/aun.md +9 -0
  169. package/kits/docs/evolcore/INDEX.md +1 -0
  170. package/kits/docs/evolcore/agent.md +8 -1
  171. package/kits/docs/evolcore/aid.md +67 -17
  172. package/kits/docs/evolcore/config.md +28 -7
  173. package/kits/docs/evolcore/contact.md +3 -0
  174. package/kits/docs/evolcore/fs.md +11 -0
  175. package/kits/docs/evolcore/group.md +1 -1
  176. package/kits/docs/evolcore/memory-architecture.md +2 -2
  177. package/kits/docs/evolcore/memory-consolidation.md +32 -8
  178. package/kits/docs/evolcore/memory.md +1 -1
  179. package/kits/docs/evolcore/menu-protocol.md +4 -0
  180. package/kits/docs/evolcore/model.md +23 -20
  181. package/kits/docs/evolcore/msg.md +4 -7
  182. package/kits/docs/evolcore/provider.md +50 -0
  183. package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
  184. package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
  185. package/kits/rules/01-overview.md +3 -0
  186. package/kits/rules/04-relation.md +1 -1
  187. package/kits/schemas/_meta.json +37 -4
  188. package/kits/schemas/agent-config.schema.13.json +8 -3
  189. package/kits/schemas/agent-config.schema.16.json +891 -0
  190. package/kits/schemas/daemon.schema.9.json +366 -0
  191. package/kits/schemas/defaults.schema.5.json +406 -127
  192. package/kits/schemas/relation-config.schema.11.json +277 -0
  193. package/kits/schemas/role-config.schema.1.json +7 -7
  194. package/kits/skills/.switches.json +4 -0
  195. package/kits/skills/ec-agent-create/SKILL.md +3 -0
  196. package/kits/skills/ec-identity/SKILL.md +2 -2
  197. package/kits/skills/ec-service-proxy/SKILL.md +118 -0
  198. package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
  199. package/kits/skills/personal-assistant/SKILL.md +176 -0
  200. package/kits/skills/personal-assistant/references/01-workspace-spec.md +333 -0
  201. package/kits/skills/personal-assistant/references/02-bootstrap.md +205 -0
  202. package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +177 -0
  203. package/kits/skills/personal-assistant/references/04-frontend-contract.md +439 -0
  204. package/kits/skills/personal-assistant/references/05-directory-reference.md +292 -0
  205. package/kits/skills/personal-assistant/references/06-render-config.md +350 -0
  206. package/kits/skills/personal-assistant/schema/workspace.schema.json +85 -0
  207. package/kits/skills/personal-assistant/schema/workspace.v1.json +66 -0
  208. package/kits/skills/personal-assistant/scripts/archive.mjs +154 -0
  209. package/kits/skills/personal-assistant/scripts/check.mjs +114 -0
  210. package/kits/skills/personal-assistant/scripts/index-rebuild.mjs +252 -0
  211. package/kits/skills/personal-assistant/scripts/ingest.mjs +344 -0
  212. package/kits/skills/personal-assistant/scripts/init.mjs +270 -0
  213. package/kits/skills/personal-assistant/scripts/lib/apply.mjs +92 -0
  214. package/kits/skills/personal-assistant/scripts/lib/schema.mjs +96 -0
  215. package/kits/skills/personal-assistant/scripts/lib/time.mjs +28 -0
  216. package/kits/skills/personal-assistant/scripts/migrate.mjs +172 -0
  217. package/kits/skills/personal-assistant/scripts/search.mjs +172 -0
  218. package/kits/skills/personal-assistant/scripts/verify.mjs +196 -0
  219. package/kits/skills/personal-assistant/templates/INDEX.md.tpl +24 -0
  220. package/kits/skills/personal-assistant/templates/README.md.tpl +108 -0
  221. package/kits/skills/personal-assistant/triggers/ingest-daily.json +23 -0
  222. package/kits/skills/personal-assistant/triggers/memory-consolidate.json +23 -0
  223. package/kits/skills/personal-assistant/triggers/report-daily.json +23 -0
  224. package/kits/skills/personal-assistant/triggers/report-weekly.json +23 -0
  225. package/kits/skills/thread-ops/SKILL.md +5 -0
  226. package/kits/templates/memory-consolidation/forget.md +19 -6
  227. package/kits/templates/memory-consolidation/notes.md +1 -1
  228. package/kits/templates/memory-consolidation/profile.md +2 -2
  229. package/kits/templates/memory-consolidation/promote.md +20 -3
  230. package/kits/templates/roles/member.json +8 -1
  231. package/kits/templates/system-fragments/baseagent.md +2 -2
  232. package/kits/templates/system-fragments/memory.md +4 -4
  233. package/kits/templates/system-fragments/venue.md +1 -1
  234. package/package.json +7 -3
  235. package/dist/core/message/create-status.js +0 -96
@@ -6,7 +6,7 @@ import { agentmdGet, getAidStore, isValidAid, loadClient, SLOT } from '../aun/ai
6
6
  import { daemonUnavailableMessage, queryDaemon } from './help.js';
7
7
  import { resolvePaths } from '../paths.js';
8
8
  import { AGENT_DELEGATION_TOKEN_ENV, readDelegationCredential } from '../core/auth/agent-delegation.js';
9
- import { DEFAULT_FS_CAT_BYTES, MAX_FS_CAT_BYTES, FsReadBudgetError, downloadGroupFsBytes, readPersonalFsBytesWithinBudget, } from '../aun/group/fs-download.js';
9
+ import { DEFAULT_FS_CAT_BYTES, MAX_FS_CAT_BYTES, FsReadBudgetError, downloadGroupFsBytes, readPersonalFsBytesWithinBudget, readAuthoritativePersonalFsObject, } from '../aun/group/fs-download.js';
10
10
  class FsCliError extends Error {
11
11
  code;
12
12
  suggestion;
@@ -39,6 +39,7 @@ Commands:
39
39
  token issue|revoke|ls <path> 管理访问 token(personal storage)
40
40
  find <AID>:<path> [filters] 查找节点
41
41
  df <AID>: 查看容量/配额
42
+ link <AID>:<path> [--expires T] 生成下载直链(personal storage;T 如 24h/7d/0,0 为不过期)
42
43
  mount <target> --volume <id> 挂载实体卷
43
44
  mount <target> --source <src> 挂载远程子树
44
45
  approve <AID>:<path> 批准待审挂载(personal storage)
@@ -73,6 +74,7 @@ Options:
73
74
  --mtime <expr> find 修改时间过滤
74
75
  --head-bytes <n> cat 二进制头部字节数,默认 256
75
76
  --max-bytes <n> cat 读取预算,默认及最高 131072;超限终止读取
77
+ --authoritative cat 个人空间私有 ACL 完整对象;不使用 HTTP 下载票据
76
78
  --aun-path <path> 指定 AUN keystore 根
77
79
  --app <name> 指定 AUN app slot
78
80
 
@@ -126,6 +128,8 @@ export async function cmdFs(args) {
126
128
  let opts;
127
129
  try {
128
130
  opts = parseCommonOptions(args);
131
+ if (opts.authoritative && sub !== 'cat')
132
+ throw new FsCliError('INVALID_ARGUMENT', '--authoritative 只用于 cat');
129
133
  }
130
134
  catch (e) {
131
135
  outputError(e, formatJson);
@@ -186,6 +190,9 @@ export async function cmdFs(args) {
186
190
  case 'df':
187
191
  await fsDf(args.slice(1), opts);
188
192
  return;
193
+ case 'link':
194
+ await fsLink(args.slice(1), opts);
195
+ return;
189
196
  case 'mount':
190
197
  await fsMount(args.slice(1), opts);
191
198
  return;
@@ -275,6 +282,11 @@ async function runManagedFs(args, formatJson) {
275
282
  case 'remove':
276
283
  console.log(`✓ 已删除: ${result.path}`);
277
284
  return;
285
+ case 'link':
286
+ console.log(`🔗 ${String(result.url ?? '')}`);
287
+ if (result.expireAt)
288
+ console.log(`有效期至: ${new Date(Number(result.expireAt)).toISOString()}`);
289
+ return;
278
290
  case 'getfacl':
279
291
  console.log(JSON.stringify(result.result ?? {}, null, 2));
280
292
  return;
@@ -305,6 +317,7 @@ function parseCommonOptions(args) {
305
317
  contentType: getArgValue(args, '--content-type'),
306
318
  maxCatBytes,
307
319
  headBytes,
320
+ authoritative: args.includes('--authoritative'),
308
321
  };
309
322
  }
310
323
  function requireActor(opts) {
@@ -405,7 +418,15 @@ async function fsCat(args, opts) {
405
418
  const route = await resolveRoute(target.aid, store);
406
419
  let statInfo;
407
420
  let bytes;
408
- if (route.backend === 'group') {
421
+ if (opts.authoritative) {
422
+ if (route.backend !== 'personal' || opts.token) {
423
+ throw new FsCliError('INVALID_ARGUMENT', '--authoritative 仅支持按 AID 认证的个人空间对象');
424
+ }
425
+ const object = await readAuthoritativePersonalFsObject(client, target.path, target.aid, opts.maxCatBytes);
426
+ bytes = object.bytes;
427
+ statInfo = object.metadata;
428
+ }
429
+ else if (route.backend === 'group') {
409
430
  statInfo = await client.group.fs.stat(remoteRef(target));
410
431
  const size = numberFrom(statInfo, ['size', 'size_bytes', 'bytes']);
411
432
  if (size !== undefined && size > opts.maxCatBytes)
@@ -997,6 +1018,47 @@ async function fsDf(args, opts) {
997
1018
  }
998
1019
  });
999
1020
  }
1021
+ async function fsLink(args, opts) {
1022
+ const target = parseRemoteRequired(firstPositional(args), { command: 'link' });
1023
+ const expiresRaw = getArgValue(args, '--expires');
1024
+ let expiresSeconds;
1025
+ if (expiresRaw !== undefined) {
1026
+ const match = /^(\d+)([smhd])?$/i.exec(expiresRaw.trim());
1027
+ const unit = match?.[2]?.toLowerCase();
1028
+ const scale = unit === 'm' ? 60 : unit === 'h' ? 3600 : unit === 'd' ? 86400 : 1;
1029
+ const seconds = match ? Number(match[1]) * scale : Number.NaN;
1030
+ if (!match || !Number.isSafeInteger(seconds) || seconds > 7 * 24 * 3600) {
1031
+ throw new FsCliError('INVALID_ARGUMENT', '--expires 支持纯秒数或 30m / 12h / 7d,最长 7 天,0 表示不过期');
1032
+ }
1033
+ expiresSeconds = seconds;
1034
+ }
1035
+ await withClient(opts, async ({ client, store }) => {
1036
+ const route = await resolveRoute(target.aid, store);
1037
+ if (route.backend === 'group') {
1038
+ throw new FsCliError('NOT_ALLOWED', 'link 仅支持 personal storage');
1039
+ }
1040
+ const ticket = await client.call('storage.create_download_ticket', {
1041
+ owner_aid: target.aid,
1042
+ bucket: 'default',
1043
+ object_key: target.path.replace(/^\/+/, ''),
1044
+ ...(expiresSeconds !== undefined ? { expire_in_seconds: expiresSeconds } : {}),
1045
+ });
1046
+ const url = typeof ticket?.download_url === 'string' && ticket.download_url
1047
+ ? ticket.download_url
1048
+ : typeof ticket?.url === 'string' ? ticket.url : '';
1049
+ if (!url)
1050
+ throw new FsCliError('DEPENDENCY_UNAVAILABLE', 'storage 未返回下载链接');
1051
+ outputSuccess(opts, {
1052
+ command: 'link', backend: route.backend, route, path: remoteRef(target),
1053
+ url, expireAt: ticket.expire_at ?? null,
1054
+ }, () => {
1055
+ console.log(`🔗 ${url}`);
1056
+ if (expiresSeconds !== undefined) {
1057
+ console.log(expiresSeconds === 0 ? '有效期: 不过期' : `有效期: ${expiresSeconds} 秒`);
1058
+ }
1059
+ });
1060
+ });
1061
+ }
1000
1062
  async function fsMount(args, opts) {
1001
1063
  const positional = collectPositionals(args);
1002
1064
  const volumeId = getArgValue(args, '--volume');
package/dist/cli/index.js CHANGED
@@ -40,6 +40,7 @@ Agent 与会话:
40
40
  getmeta 按会话 id / threadId / agentSessionId 查询会话元数据
41
41
  task 恢复暂停或异常中断的会话任务
42
42
  trigger 管理定时与事件触发器
43
+ proxy 查询和管理 daemon 服务代理
43
44
  handoff 查询和完成跨会话回流
44
45
  model 查看或设置模型与推理强度
45
46
  response 查看或设置响应模式
@@ -58,6 +59,7 @@ AUN:
58
59
 
59
60
  配置与诊断:
60
61
  config 读取、修改和检查分层配置
62
+ provider 管理 daemon 级 Provider 注册表与 JSON 导入
61
63
  stats Token 用量与费用统计
62
64
  diagnose 检查启动环境
63
65
  version 显示组件版本
@@ -110,7 +112,7 @@ export async function main(args) {
110
112
  // 注入完成后剥除 --as-session <sessionId> 两个参数,避免子命令把它们当作未知参数
111
113
  const strippedArgs = stripAsSessionArgs(args);
112
114
  try {
113
- assertManagedTopLevelCommandAllowed(cmd, strippedArgs);
115
+ await assertManagedTopLevelCommandAllowed(cmd, strippedArgs);
114
116
  }
115
117
  catch (error) {
116
118
  if (!(error instanceof ManagedCommandNotAllowedError))
@@ -142,6 +144,10 @@ export async function main(args) {
142
144
  --baseagent <claude|codex|gemini|ecagent> 默认: PATH 中第一个可用项;ecagent 需显式选择
143
145
  --force 已存在 defaults.json 时覆盖
144
146
 
147
+ 通过 EC Web 完成首次初始化:
148
+ ec init --web 启动初始化所需服务并输出 EC Web 入口地址
149
+ 默认 ec init 行为保持不变
150
+
145
151
  云部署非交互式初始化(结构化 JSON 输出):
146
152
  ec init --non-interactive --owner <aid> [--format json] [选项]
147
153
  --owner <aid> 必填。控制 AID 创建后的 Owner 邀约目标,不等待审批
@@ -194,6 +200,19 @@ export async function main(args) {
194
200
  process.exit(1);
195
201
  }
196
202
  else {
203
+ if (strippedArgs.includes("--web")) {
204
+ if (strippedArgs.length !== 2) {
205
+ console.error("❌ ec init --web 不能与其他初始化参数组合使用");
206
+ process.exitCode = 1;
207
+ break;
208
+ }
209
+ const { suppressSdkLogs } = await import("../aun/aid/index.js");
210
+ suppressSdkLogs();
211
+ const initialized = await cmdInit({ web: true });
212
+ if (!initialized && process.exitCode == null)
213
+ process.exitCode = 1;
214
+ break;
215
+ }
197
216
  const { suppressSdkLogs } = await import('../aun/aid/index.js');
198
217
  suppressSdkLogs();
199
218
  const nonInteractive = strippedArgs.includes('--non-interactive');
@@ -280,11 +299,27 @@ export async function main(args) {
280
299
  if (process.env.EVOLCORE_SESSION_ID) {
281
300
  const sessionId = process.env.EVOLCORE_SESSION_ID;
282
301
  const delegationToken = readDelegationCredential();
283
- const result = await ipcQuery(resolvePaths().socket, {
284
- type: 'status.auth', sessionId, delegationToken, argv: ['status', ...statusArgs],
285
- });
302
+ let result;
303
+ try {
304
+ // Status includes a process-scope authorization round trip. Give a
305
+ // busy daemon enough time to answer and preserve transport failures
306
+ // instead of turning them into a misleading permission denial.
307
+ result = await ipcQuery(resolvePaths().socket, {
308
+ type: 'status.auth', sessionId, delegationToken, argv: ['status', ...statusArgs],
309
+ }, 10_000, { throwOnError: true });
310
+ }
311
+ catch (error) {
312
+ console.error(`❌ status 查询失败:${error instanceof Error ? error.message : String(error)}`);
313
+ process.exitCode = 1;
314
+ break;
315
+ }
316
+ if (result === null) {
317
+ console.error('❌ status 查询失败:daemon 未返回授权结果');
318
+ process.exitCode = 1;
319
+ break;
320
+ }
286
321
  if (!result?.ok) {
287
- console.error(`❌ ${result?.error || 'status is not allowed in this task'}`);
322
+ console.error(`❌ ${result?.error || 'status 权限校验失败'}`);
288
323
  process.exitCode = 1;
289
324
  break;
290
325
  }
@@ -380,6 +415,28 @@ export async function main(args) {
380
415
  await cmdTrigger(strippedArgs.slice(1));
381
416
  }
382
417
  break;
418
+ case 'proxy': {
419
+ const { cmdProxy } = await import('./proxy-command.js');
420
+ try {
421
+ await cmdProxy(strippedArgs.slice(1));
422
+ }
423
+ catch (error) {
424
+ const result = {
425
+ ok: false,
426
+ code: typeof error?.code === 'string' ? error.code : 'PROXY_FAILED',
427
+ error: error?.message ?? String(error),
428
+ };
429
+ const formatIndex = strippedArgs.indexOf('--format');
430
+ if ((formatIndex >= 0 && strippedArgs[formatIndex + 1] === 'json') || strippedArgs.includes('--json')) {
431
+ console.log(JSON.stringify(result));
432
+ }
433
+ else {
434
+ console.error(result.error + ' (' + result.code + ')');
435
+ }
436
+ process.exitCode = 1;
437
+ }
438
+ break;
439
+ }
383
440
  case 'agent': {
384
441
  const { suppressSdkLogs } = await import('../aun/aid/index.js');
385
442
  suppressSdkLogs();
@@ -482,6 +539,11 @@ export async function main(args) {
482
539
  await cmdResponse(strippedArgs.slice(1));
483
540
  break;
484
541
  }
542
+ case 'provider': {
543
+ const { cmdProvider } = await import('./provider-command.js');
544
+ await cmdProvider(strippedArgs.slice(1));
545
+ break;
546
+ }
485
547
  case 'config': {
486
548
  const { cmdConfig } = await import('./config.js');
487
549
  await cmdConfig(strippedArgs.slice(1));
@@ -492,6 +554,11 @@ export async function main(args) {
492
554
  await cmdContact(strippedArgs.slice(1));
493
555
  break;
494
556
  }
557
+ case 'role': {
558
+ const { cmdRole } = await import('./role.js');
559
+ await cmdRole(strippedArgs.slice(1));
560
+ break;
561
+ }
495
562
  case 'stats': {
496
563
  const { handleStats } = await import('./stats.js');
497
564
  await handleStats(strippedArgs.slice(1));
@@ -696,7 +696,7 @@ export async function cmdInitWechat() {
696
696
  // ==================== AUN ====================
697
697
  export async function cmdInitAun() {
698
698
  console.log('AUN 协议 Owner 统一使用 ec aid bind <ownerAid> [--subject <subjectAid>]');
699
- console.log(`状态查询: ${MAIN_CLI_BIN} aid bind status [--subject <subjectAid>];邀约审批: ${MAIN_CLI_BIN} aid bind accept|reject <operationId>。`);
699
+ console.log(`状态查询: ${MAIN_CLI_BIN} aid bind status [--refresh] [--subject <subjectAid>];转让: ${MAIN_CLI_BIN} aid transfer <subAid> <newOwnerAid> --subject <currentOwnerAid>;邀约审批: ${MAIN_CLI_BIN} aid bind accept|reject <operationId>。`);
700
700
  }
701
701
  async function pickAunOwnerBindTarget(rl, daemonAid) {
702
702
  const { agents } = loadAllAgents();
package/dist/cli/init.js CHANGED
@@ -6,7 +6,7 @@ import { resolvePaths, ensureDataDirs } from '../paths.js';
6
6
  import { commandExists } from '../utils/cross-platform.js';
7
7
  import { scanInstances } from '../utils/instance-registry.js';
8
8
  import { saveDefaultsSafe, loadAllAgents, loadDaemonConfig, saveDaemonConfig } from '../config-store.js';
9
- import { ecwebService, setEcwebEnabled } from '../config/daemon-services.js';
9
+ import { DEFAULT_ECWEB_PORT, ecwebService, setEcwebEnabled } from '../config/daemon-services.js';
10
10
  import { ensureControlAgentMd, generateControlAid, resolveControlAidDomain, submitControlAidRegistration, } from '../aun/aid/control-aid.js';
11
11
  import { isValidAid } from '../aun/aid/validation.js';
12
12
  import { getCodexAppServerAvailability } from '../agents/codex-runner.js';
@@ -161,8 +161,82 @@ export async function ensureEcwebInstalledForInit(options = {}) {
161
161
  return { ok: false, error };
162
162
  }
163
163
  }
164
+ export async function cmdInitWeb(dependencies = {}) {
165
+ const p = resolvePaths();
166
+ ensureDataDirs();
167
+ const daemonRunning = dependencies.isDaemonRunning?.()
168
+ ?? scanInstances().mains.some(instance => instance.alive);
169
+ if (daemonRunning && !(dependencies.loadConfig ?? loadDaemonConfig)().aid) {
170
+ console.error("❌ EvolCore 正在运行但未配置控制 AID;请先停止服务后重试。");
171
+ return false;
172
+ }
173
+ const install = await (dependencies.ensureEcwebInstalled ?? ensureEcwebInstalledForInit)();
174
+ if (!install.ok)
175
+ return false;
176
+ let config = (dependencies.loadConfig ?? loadDaemonConfig)();
177
+ if (!config.aid) {
178
+ try {
179
+ const aidDomain = resolveControlAidDomain(config.aun?.defaultAidDomain);
180
+ const { aid } = await (dependencies.generateAid ?? generateControlAid)(aidDomain);
181
+ config = { ...config, $schema_version: config.$schema_version ?? 1, aid };
182
+ (dependencies.saveConfig ?? saveDaemonConfig)(config);
183
+ console.log(`✓ 已生成主机控制 AID: ${aid}`);
184
+ }
185
+ catch (error) {
186
+ console.error(`❌ 主机控制 AID 准备失败: ${installErrorMessage(error)}`);
187
+ return false;
188
+ }
189
+ }
190
+ const controlAid = config.aid;
191
+ if (!controlAid) {
192
+ console.error("❌ 主机控制 AID 未配置。");
193
+ return false;
194
+ }
195
+ try {
196
+ await (dependencies.ensureAgentMd ?? ensureControlAgentMd)(controlAid);
197
+ }
198
+ catch (error) {
199
+ console.warn(`⚠️ 主机控制 AID 名片暂未发布,将由 daemon 后续重试: ${installErrorMessage(error)}`);
200
+ }
201
+ if (ecwebService(config.services)?.enabled !== true) {
202
+ config = { ...config, services: setEcwebEnabled(config.services, true) };
203
+ try {
204
+ (dependencies.saveConfig ?? saveDaemonConfig)(config);
205
+ }
206
+ catch (error) {
207
+ console.error(`❌ 启用 ECWeb 失败: ${installErrorMessage(error)}`);
208
+ return false;
209
+ }
210
+ }
211
+ try {
212
+ if (!daemonRunning && dependencies.startDaemon) {
213
+ await dependencies.startDaemon();
214
+ }
215
+ else if (!daemonRunning) {
216
+ const { cmdStart } = await import("./daemon-commands.js");
217
+ await cmdStart({ bindBootstrap: true, webInit: true });
218
+ }
219
+ const started = dependencies.startEcweb
220
+ ? await dependencies.startEcweb()
221
+ : await (await import("./daemon-commands.js")).startEcwebIfEnabled(p);
222
+ if (!started) {
223
+ console.error("❌ ECWeb 未能启动;可稍后运行 ec watch web 重试。");
224
+ return false;
225
+ }
226
+ }
227
+ catch (error) {
228
+ console.error(`❌ 启动 ECweb 初始化环境失败: ${installErrorMessage(error)}`);
229
+ return false;
230
+ }
231
+ const currentConfig = (dependencies.loadConfig ?? loadDaemonConfig)();
232
+ const port = ecwebService(currentConfig.services)?.port ?? DEFAULT_ECWEB_PORT;
233
+ console.log(`\nECweb 初始化: http://localhost:${port}/init`);
234
+ return true;
235
+ }
164
236
  // ==================== Main ====================
165
237
  export async function cmdInit(options) {
238
+ if (options?.web)
239
+ return cmdInitWeb();
166
240
  // 云部署非交互式路径:当带 --owner 或 --format json 时走结构化分支,与交互式 tail 完全隔离。
167
241
  // 预留方案 B:当 daemon 支持 Control Plane 无 agent 启动时,可在此分支跳过 agent new 预创建。
168
242
  if (options?.nonInteractive && (options.owner || options.format === 'json' || options.projectpath || options.ecweb)) {
@@ -1,4 +1,5 @@
1
1
  import { isHelpFlag, wantsHelp } from './help.js';
2
+ import { isTrustedFullAccessRuntimeContext, readVerifiedTaskRuntimeContext } from './task-context.js';
2
3
  const MANAGED_TASK_COMMANDS = new Set([
3
4
  'aid',
4
5
  'agent',
@@ -16,8 +17,13 @@ const MANAGED_TASK_COMMANDS = new Set([
16
17
  'memory',
17
18
  'model',
18
19
  'msg',
20
+ 'proxy',
21
+ 'provider',
19
22
  'queue',
20
23
  'response',
24
+ // `role` 提交/审批关系角色提升申请,通过 role.op IPC 鉴权;
25
+ // 申请本身不改变权限,审批只接受本 Agent 的 owner。
26
+ 'role',
21
27
  // `session` 按 ec 会话 id 只读查询本地 session 存档(meta 文件尾行的
22
28
  // agentSessionId 等),不触碰 daemon 与进程生命周期。
23
29
  'session',
@@ -45,6 +51,7 @@ const MANAGED_TASK_COMMANDS = new Set([
45
51
  '-V',
46
52
  '--version',
47
53
  ]);
54
+ const SELF_PROTECTED_LIFECYCLE_COMMANDS = new Set(['start', 'stop', 'restart', 'restart-monitor']);
48
55
  export class ManagedCommandNotAllowedError extends Error {
49
56
  command;
50
57
  code = 'NOT_ALLOWED';
@@ -58,9 +65,18 @@ export class ManagedCommandNotAllowedError extends Error {
58
65
  * Local maintenance commands do not have daemon authorization entrypoints.
59
66
  * Keep them outside managed tasks so they cannot read or mutate host state.
60
67
  */
61
- export function assertManagedTopLevelCommandAllowed(command, args, env = process.env) {
68
+ export async function assertManagedTopLevelCommandAllowed(command, args, env = process.env) {
62
69
  if (!env.EVOLCORE_SESSION_ID || isHelpFlag(command) || wantsHelp(args.slice(1)))
63
70
  return;
71
+ // A trusted fullaccess task may enter any implemented CLI command. The
72
+ // command's own daemon/operation handler still performs its normal checks.
73
+ const verified = await readVerifiedTaskRuntimeContext(env);
74
+ if (isTrustedFullAccessRuntimeContext(verified)) {
75
+ if (SELF_PROTECTED_LIFECYCLE_COMMANDS.has(command)) {
76
+ throw new ManagedCommandNotAllowedError(command);
77
+ }
78
+ return;
79
+ }
64
80
  if (!MANAGED_TASK_COMMANDS.has(command))
65
81
  throw new ManagedCommandNotAllowedError(command);
66
82
  }
package/dist/cli/model.js CHANGED
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * `ec model` —— 面向 agent 的模型管理命令集。
3
3
  *
4
- * 可写作用域由参数决定:
5
- * --self → agent config.json
6
- * --self --peer → 关系 relations/<peerKey>/config.json
4
+ * 模型参数只在 Agent 级配置:
5
+ * --self → agents/<aid>/config.json 的 baseagents.<ba>.{model,effort}
6
+ * --peer 保留只读:可用于查看按关系角色约束生效的模型(model current/list/check)。
7
7
  * 角色模型策略由角色策略编辑器管理;--role 仅用于过滤和预览有效模型。
8
8
  *
9
- * 改某作用域后,对应范围所有会话的下一条消息即时生效(运行时按 关系>角色>agent>defaults 解析)。
9
+ * 改 Agent 级后,该 Agent 所有会话的下一条消息即时生效(运行时不缓存,每条消息解析)。
10
10
  * 与对话内 slash(/model /effort /baseagent)互不影响。
11
11
  * 设计见 docs/model-command-design.md。
12
12
  */
13
13
  import { isHelpFlag, wantsHelp, getArgValue } from './help.js';
14
- import { ModelScopeError, normalizePeer, determineScope, activeBaseagent, writeScope, clearScope, } from '../core/model/config-scope.js';
14
+ import { ModelScopeError, normalizePeer, determineScope, activeBaseagent, writeAgentModelConfig, clearAgentModelConfig, } from '../core/model/config-scope.js';
15
15
  import { resolveEffectiveFieldWithSource } from '../config/config-manager.js';
16
16
  import { getCatalog, getModelInfo, catalogEfforts, resolveCatalogModel, assertCatalogSelectable } from '../core/model/model-catalog.js';
17
17
  import { constrainResolvedModelForRole, filterModelsForRole, validateModelSelectionForRole, } from '../core/model/model-permission.js';
@@ -119,14 +119,16 @@ function explicitOrDerivedRole(args, sel) {
119
119
  }
120
120
  }
121
121
  function determineWriteScope(sel, formatJson) {
122
+ if (!sel.self)
123
+ fail(formatJson, 'AGENT_REQUIRED', '模型参数只在 Agent 级配置,请指定 --self <aid>');
124
+ if (sel.peerKey)
125
+ fail(formatJson, 'MODEL_AGENT_ONLY', '模型参数不支持 --peer:写入只在 Agent 级,不在关系级');
122
126
  const scope = determineScope(sel);
123
- if (scope === 'global') {
127
+ if (scope === 'global')
124
128
  fail(formatJson, 'NO_GLOBAL_SCOPE', '全局 model 作用域已退役;请用 --self 选择 agent');
125
- }
126
- if (scope === 'role') {
129
+ if (scope === 'role')
127
130
  fail(formatJson, 'ROLE_POLICY_MANAGED', '角色策略只能通过角色策略编辑器修改');
128
- }
129
- return scope;
131
+ return 'agent';
130
132
  }
131
133
  function selectorWithRole(sel, role) {
132
134
  return role ? { ...sel, role } : sel;
@@ -158,7 +160,8 @@ function resolveModelConfig(sel, baseagent) {
158
160
  const effectiveModel = modelDecision.model;
159
161
  const modelSource = modelDecision.constrained ? 'role' : modelScopeFromSource(model.source);
160
162
  const source = effectiveModel !== undefined ? modelSource : modelScopeFromSource(effort.source);
161
- const scopes = ['relation', 'role', 'agent', 'global'];
163
+ // 模型只在 Agent 级配置,角色策略只做约束。
164
+ const scopes = ['role', 'agent'];
162
165
  return {
163
166
  model: effectiveModel,
164
167
  effort: effort.value,
@@ -173,27 +176,28 @@ function resolveModelConfig(sel, baseagent) {
173
176
  const HELP = `用法: ec model <command> [options]
174
177
 
175
178
  Commands:
176
- list 列出可用模型,标注各作用域命中
177
- current 显示按优先级解析后实际生效的模型 + 来源
179
+ list 列出可用模型,标注当前 Agent 级模型
180
+ current 显示 Agent 级模型(经角色约束)+ 来源
178
181
  info <model-id> 查看单个模型详情(厂商/上下文/价格/模态/effort/状态)
179
- use <model-id> 设置模型(作用域由 --self/--peer 决定)
180
- reset 清除指定作用域的设置,回落上一级
181
- effort <level> 设置推理强度(low|medium|high|xhigh|max|auto)
182
+ use <model-id> 设置 Agent 级模型(需 --self)
183
+ reset 清除 Agent 级模型与推理强度;清除后该 Agent 无模型可用
184
+ effort <level> 设置 Agent 级推理强度(low|medium|high|xhigh|max|auto)
182
185
  check 诊断网关连通性与模型可用性(分阶段输出进度)
183
186
 
184
- 作用域(越具体越优先:关系 > 角色 > agent > defaults):
185
- (无参数) 本机 CLI 只读 catalog/defaults,不允许写入
186
- --self <aid> agent级 → config.json
187
- --self <aid> --role <role> 角色策略预览(只读)
188
- --self <aid> --peer <X> 关系级 → relations/<peerKey>/config.json
187
+ 模型参数只在 Agent 级配置(agents/<aid>/config.json 的 baseagents.<ba>.{model,effort})。
188
+ 关系级与 defaults 都不承载模型;Agent 级未设置模型即无模型可用。
189
+ (无参数) 本机 CLI 只读 catalog,不允许写入
190
+ --self <aid> Agent 级(读写)
191
+ --self <aid> --role <role> 按角色策略预览有效模型(只读)
192
+ --self <aid> --peer <X> 按该对端的关系角色预览有效模型(只读,不可写)
189
193
 
190
- 修改 agent/关系作用域后,对应范围所有会话的下一条消息即时生效。
194
+ 修改 Agent 级后,该 Agent 所有会话的下一条消息即时生效。
191
195
  角色策略请通过角色策略编辑器修改。
192
- 托管会话内省略 --self/--peer/--role 时,命令作用于当前会话。
196
+ 托管会话内省略 --self/--peer/--role 时,命令作用于当前会话;写操作仅当前 Agent 的 owner/admin 可用。
193
197
 
194
198
  Options:
195
199
  --self <aid> 本端 AID
196
- --peer <X> 对端:channelType#channelId 或裸 aid(裸 aid 视为 aun#<aid>)
200
+ --peer <X> 对端:channelType#channelId 或裸 aid(裸 aid 视为 aun#<aid>),只读
197
201
  --role <role> 按角色过滤列表或预览有效模型(只读)
198
202
  --effort <level> (use 专用)同时设置推理强度
199
203
  --format json 输出 JSON
@@ -204,9 +208,8 @@ Options:
204
208
  ec model current --self bot.agentid.pub --peer aun#alice.agentid.pub
205
209
  ec model info deepseek-v4-pro
206
210
  ec model use opus --self bot.agentid.pub
207
- ec model use deepseek-v4-pro --self bot.agentid.pub --peer alice.agentid.pub
208
211
  ec model effort high --self bot.agentid.pub
209
- ec model reset --self bot.agentid.pub --peer alice.agentid.pub
212
+ ec model reset --self bot.agentid.pub
210
213
  ec model check --self bot.agentid.pub`;
211
214
  async function dispatch(sub, args, formatJson) {
212
215
  switch (sub) {
@@ -251,7 +254,7 @@ async function cmdList(args, formatJson) {
251
254
  models,
252
255
  }, () => {
253
256
  const lines = [];
254
- lines.push(`当前生效: ${resolved.model ?? '(未设置,回落 SDK 默认)'}` +
257
+ lines.push(`当前生效: ${resolved.model ?? '(未配置,Agent 级未设置模型,无模型可用)'}` +
255
258
  (resolved.source ? ` (来源: ${SCOPE_LABEL[resolved.source]})` : ''));
256
259
  lines.push('');
257
260
  if (resolved.model && !cat.models.some(m => m.id === resolved.model))
@@ -286,7 +289,7 @@ async function cmdCurrent(args, formatJson) {
286
289
  chain: resolved.chain.map((c) => ({ scope: c.scope, model: c.model ?? null, hit: c.hit })),
287
290
  }, () => {
288
291
  const lines = [];
289
- lines.push(`当前生效模型: ${resolved.model ?? '(未设置,回落 SDK 默认)'}`);
292
+ lines.push(`当前生效模型: ${resolved.model ?? '(未配置,Agent 级未设置模型,无模型可用)'}`);
290
293
  lines.push(`推理强度: ${resolved.effort ?? 'auto'}`);
291
294
  lines.push(`来源: ${resolved.source ? SCOPE_LABEL[resolved.source] : '无'}`);
292
295
  const chain = resolved.chain.map((c) => `${SCOPE_LABEL[c.scope]}${c.hit ? ' ✓' : ''}${c.model ? `(${c.model})` : ''}`).join(' > ');
@@ -328,17 +331,15 @@ function describeWrite(scope, sel, model, effort, formatJson) {
328
331
  ok: true,
329
332
  scope,
330
333
  self: sel.self ?? null,
331
- peerKey: sel.peerKey ?? null,
332
334
  model: model ?? undefined,
333
335
  effort: effort ?? undefined,
334
336
  }, () => {
335
- const lines = ['✓ 已设置', ` 作用域: ${SCOPE_LABEL[scope]}` +
336
- (sel.peerKey ? ` (${sel.peerKey})` : '') + (sel.self ? ` [self=${sel.self}]` : '')];
337
+ const lines = ['✓ 已设置', ` 作用域: ${SCOPE_LABEL[scope]} [self=${sel.self ?? '?'}]`];
337
338
  if (model !== null)
338
339
  lines.push(` 模型: ${model}`);
339
340
  if (effort !== null)
340
341
  lines.push(` 推理强度: ${effort}`);
341
- lines.push(' 生效: 该范围所有会话的下一条消息起生效。');
342
+ lines.push(' 生效: 该 Agent 所有会话的下一条消息起生效。');
342
343
  return lines.join('\n');
343
344
  });
344
345
  }
@@ -378,14 +379,14 @@ async function cmdUse(args, formatJson) {
378
379
  }
379
380
  const effortVal = effort === 'auto' ? null : (effort ?? undefined);
380
381
  try {
381
- writeScope(scope, sel, ba, { model: modelId, effort: effortVal });
382
+ writeAgentModelConfig(sel.self, ba, { model: modelId, effort: effortVal });
382
383
  }
383
384
  catch (e) {
384
385
  if (e instanceof ModelScopeError)
385
386
  fail(formatJson, e.code, e.message);
386
387
  throw e;
387
388
  }
388
- describeWrite(scope, sel, modelId, effort ?? null, formatJson);
389
+ describeWrite('agent', sel, modelId, effort ?? null, formatJson);
389
390
  }
390
391
  async function cmdEffort(args, formatJson) {
391
392
  if (wantsHelp(args)) {
@@ -410,14 +411,14 @@ async function cmdEffort(args, formatJson) {
410
411
  fail(formatJson, 'INVALID_EFFORT', `当前模型目录未声明支持推理强度: ${val}`);
411
412
  }
412
413
  try {
413
- writeScope(scope, sel, ba, { effort: val });
414
+ writeAgentModelConfig(sel.self, ba, { effort: val });
414
415
  }
415
416
  catch (e) {
416
417
  if (e instanceof ModelScopeError)
417
418
  fail(formatJson, e.code, e.message);
418
419
  throw e;
419
420
  }
420
- describeWrite(scope, sel, null, level, formatJson);
421
+ describeWrite('agent', sel, null, level, formatJson);
421
422
  }
422
423
  async function cmdReset(args, formatJson) {
423
424
  if (wantsHelp(args)) {
@@ -428,7 +429,7 @@ async function cmdReset(args, formatJson) {
428
429
  const scope = determineWriteScope(sel, formatJson);
429
430
  const ba = activeBaseagent(sel.self);
430
431
  try {
431
- clearScope(scope, sel, ba);
432
+ clearAgentModelConfig(sel.self, ba);
432
433
  }
433
434
  catch (e) {
434
435
  if (e instanceof ModelScopeError)
@@ -436,9 +437,9 @@ async function cmdReset(args, formatJson) {
436
437
  throw e;
437
438
  }
438
439
  emit(formatJson, {
439
- ok: true, scope, self: sel.self ?? null, peerKey: sel.peerKey ?? null,
440
+ ok: true, scope: 'agent', self: sel.self ?? null, peerKey: sel.peerKey ?? null,
440
441
  }, () => {
441
- return `✓ 已清除 ${SCOPE_LABEL[scope]} 设置,回落上一级(该范围所有会话下条消息生效)`;
442
+ return `✓ 已清除 Agent 级模型设置(该 Agent 所有会话下条消息生效,无模型可用直到重新设置)`;
442
443
  });
443
444
  }
444
445
  async function cmdCheck(args, formatJson) {
@@ -452,7 +453,6 @@ async function cmdCheck(args, formatJson) {
452
453
  const steps = [];
453
454
  const result = await runModelCheck({
454
455
  self: sel.self,
455
- peerKey: sel.peerKey,
456
456
  role,
457
457
  baseagent: ba,
458
458
  onStep: step => steps.push(step),