evolcore 0.0.43-test.6 → 0.0.43-test.8

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 (249) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/bin/ecmsg.js +188 -58
  3. package/dist/agent-template/jobs.js +62 -0
  4. package/dist/agent-template/runtime.js +214 -0
  5. package/dist/agent-template/service.js +465 -0
  6. package/dist/agent-template/tool-runner.js +45 -0
  7. package/dist/agent-template/types.js +5 -0
  8. package/dist/agents/baseagent-availability.js +1 -1
  9. package/dist/agents/claude-runner.js +1 -1
  10. package/dist/agents/codex/app-server-client.js +22 -0
  11. package/dist/agents/codex-runner.js +69 -2
  12. package/dist/aun/aid/agentmd.js +56 -1
  13. package/dist/aun/aid/client.js +3 -1
  14. package/dist/aun/menu/client.js +3 -2
  15. package/dist/aun/msg/p2p.js +6 -1
  16. package/dist/channels/aun.js +277 -49
  17. package/dist/cli/agent-command.js +5 -0
  18. package/dist/cli/agent-create.js +7 -3
  19. package/dist/cli/agent-template.js +124 -0
  20. package/dist/cli/aun-commands.js +2 -2
  21. package/dist/cli/ctl-command.js +2 -1
  22. package/dist/cli/daemon-commands.js +11 -66
  23. package/dist/cli/daemon-lifecycle-client.js +61 -0
  24. package/dist/cli/ecmsg-gateway.js +35 -2
  25. package/dist/cli/events-command.js +109 -0
  26. package/dist/cli/index.js +60 -14
  27. package/dist/cli/invoke-command.js +182 -0
  28. package/dist/cli/managed-command-guard.js +6 -1
  29. package/dist/cli/net-check.js +1 -1
  30. package/dist/cli/restart-monitor.js +160 -83
  31. package/dist/cli/services-command.js +137 -0
  32. package/dist/cli/team-workspace-command.js +134 -0
  33. package/dist/cli/thread-command.js +103 -13
  34. package/dist/cli/watch-msg.js +1 -1
  35. package/dist/config/boot-log.js +8 -8
  36. package/dist/config/config-field-policy.js +2 -2
  37. package/dist/config/config-manager.js +0 -7
  38. package/dist/config/invoke-ipc-service.js +118 -0
  39. package/dist/config/schema-migration.js +45 -15
  40. package/dist/config-store.js +2 -1
  41. package/dist/core/agent-ipc-registration.js +25 -4
  42. package/dist/core/agent-reload-coordinator.js +6 -4
  43. package/dist/core/agent-runtime.js +106 -10
  44. package/dist/core/auth/delegation-authorization.js +66 -0
  45. package/dist/core/auth/operation-authorizer.js +2 -0
  46. package/dist/core/auth/operation-catalog.js +29 -0
  47. package/dist/core/baseagent-loader.js +60 -130
  48. package/dist/core/channel-loader.js +10 -1
  49. package/dist/core/channel-runtime.js +20 -12
  50. package/dist/core/command/agent-control.js +12 -2
  51. package/dist/core/command/agent-storage-menu.js +1 -1
  52. package/dist/core/command/agent-template-menu.js +147 -0
  53. package/dist/core/command/chatmode-config.js +2 -36
  54. package/dist/core/command/command-handler.js +80 -17
  55. package/dist/core/command/data-root-resolver.js +32 -23
  56. package/dist/core/command/eventcenter-menu.js +468 -0
  57. package/dist/core/command/menu-catalog.js +15 -0
  58. package/dist/core/command/menu-handler.js +216 -90
  59. package/dist/core/command/menu-protocol.js +71 -13
  60. package/dist/core/command/menu-query-batch.js +194 -0
  61. package/dist/core/command/slash-gate.js +1 -1
  62. package/dist/core/command/slash-handler.js +34 -42
  63. package/dist/core/command/team-workspace-bootstrap.js +350 -0
  64. package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
  65. package/dist/core/command/team-workspace-initializer.js +2 -0
  66. package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
  67. package/dist/core/command/team-workspace-job-store.js +88 -0
  68. package/dist/core/command/team-workspace-management-service.js +2 -0
  69. package/dist/core/command/team-workspace-management-store.js +96 -0
  70. package/dist/core/command/team-workspace-management.js +265 -0
  71. package/dist/core/command/team-workspace-members-menu.js +88 -0
  72. package/dist/core/command/team-workspace-store.js +612 -0
  73. package/dist/core/command/team-workspace-team.js +193 -0
  74. package/dist/core/daemon-control.js +22 -5
  75. package/dist/core/daemon-lifecycle.js +323 -191
  76. package/dist/core/handoff/runtime.js +45 -13
  77. package/dist/core/invoke/executors/index.js +13 -0
  78. package/dist/core/invoke/executors/media.js +283 -0
  79. package/dist/core/invoke/executors/text.js +198 -0
  80. package/dist/core/invoke/invoke-service.js +157 -0
  81. package/dist/core/invoke/style-router.js +48 -0
  82. package/dist/core/invoke/types.js +19 -0
  83. package/dist/core/ipc-registration.js +50 -7
  84. package/dist/core/legacy-rename.js +41 -0
  85. package/dist/core/memory/consolidation.js +7 -5
  86. package/dist/core/message/aun-ipc-sender.js +252 -17
  87. package/dist/core/message/im-renderer.js +116 -85
  88. package/dist/core/message/message-bridge.js +4 -0
  89. package/dist/core/message/message-queue.js +66 -15
  90. package/dist/core/message/message-utils.js +10 -2
  91. package/dist/core/message/peer-mode.js +7 -34
  92. package/dist/core/message/pending-hints.js +29 -5
  93. package/dist/core/message/response-engine.js +194 -61
  94. package/dist/core/message/send-options.js +7 -4
  95. package/dist/core/message/send-routing.js +50 -5
  96. package/dist/core/ownership/owner-resolver.js +7 -0
  97. package/dist/core/pack-auth.js +94 -0
  98. package/dist/core/pack-install.js +194 -0
  99. package/dist/core/permission/ec-command-parser.js +51 -17
  100. package/dist/core/permission/protected-paths.js +12 -2
  101. package/dist/core/permission/shell-environment.js +9 -0
  102. package/dist/core/rate-window.js +48 -0
  103. package/dist/core/relation/peer-identity.js +28 -0
  104. package/dist/core/session/session-file-health.js +243 -0
  105. package/dist/core/session/session-fs-store.js +67 -28
  106. package/dist/core/session/session-idle-monitor.js +59 -19
  107. package/dist/core/session/session-manager.js +13 -4
  108. package/dist/core/task/task-recovery-service.js +13 -2
  109. package/dist/core/thread/command-parser.js +9 -2
  110. package/dist/core/thread/thread-operation.js +21 -2
  111. package/dist/core/thread/thread-route.js +13 -2
  112. package/dist/core/thread/thread-service.js +52 -3
  113. package/dist/directory/owner-directory-admission.js +40 -53
  114. package/dist/directory/owner-directory-cache.js +89 -113
  115. package/dist/directory/owner-directory-query-operation.js +8 -10
  116. package/dist/eck/kit-renderer.js +7 -5
  117. package/dist/eck/message-renderer.js +2 -0
  118. package/dist/ecweb/basic-settings-service.js +1 -1
  119. package/dist/ecweb/message-context-service.js +0 -4
  120. package/dist/ecweb/runtime/lifecycle.js +6 -2
  121. package/dist/ecweb/runtime/supervisor.js +19 -4
  122. package/dist/event-center/admission-materializer.js +124 -0
  123. package/dist/event-center/bus-gate.js +154 -0
  124. package/dist/event-center/bus-host.js +307 -0
  125. package/dist/event-center/bus-resolver.js +120 -0
  126. package/dist/event-center/center-config.js +127 -0
  127. package/dist/event-center/daemon.js +44 -0
  128. package/dist/event-center/directory-source.js +55 -0
  129. package/dist/event-center/dispatcher.js +157 -0
  130. package/dist/event-center/event-log.js +110 -0
  131. package/dist/event-center/index-generator.js +73 -0
  132. package/dist/event-center/ipc-operation.js +423 -0
  133. package/dist/event-center/ledger.js +52 -0
  134. package/dist/event-center/pack-loader.js +207 -0
  135. package/dist/event-center/pack-manager.js +85 -0
  136. package/dist/event-center/registry.js +463 -0
  137. package/dist/event-center/runtime.js +837 -0
  138. package/dist/event-center/script-runner.js +356 -0
  139. package/dist/event-center/types.js +51 -0
  140. package/dist/event-center/validation.js +435 -0
  141. package/dist/index.js +424 -135
  142. package/dist/ipc.js +106 -12
  143. package/dist/paths.js +20 -0
  144. package/dist/product.js +14 -0
  145. package/dist/proxy/manager.js +5 -1
  146. package/dist/proxy/service-supervisor.js +13 -4
  147. package/dist/response-system/engines/v1/index.js +0 -1
  148. package/dist/response-system/engines/v1/proactive-flow.js +4 -2
  149. package/dist/response-system/modes/single-session/index.js +1 -1
  150. package/dist/services/dispatcher.js +100 -0
  151. package/dist/services/idempotency.js +90 -0
  152. package/dist/services/identity.js +52 -0
  153. package/dist/services/index-generator.js +70 -0
  154. package/dist/services/index.js +449 -0
  155. package/dist/services/ipc-operation.js +550 -0
  156. package/dist/services/ledger.js +52 -0
  157. package/dist/services/message-log.js +112 -0
  158. package/dist/services/pack-manager.js +215 -0
  159. package/dist/services/reply.js +55 -0
  160. package/dist/services/router.js +98 -0
  161. package/dist/services/script-runner.js +422 -0
  162. package/dist/services/service-payload.js +70 -0
  163. package/dist/services/types.js +18 -0
  164. package/dist/services/validation.js +297 -0
  165. package/dist/trigger/application-service.js +18 -0
  166. package/dist/trigger/event-source.js +1 -1
  167. package/dist/trigger/ipc-service.js +3 -1
  168. package/dist/trigger/scheduler.js +38 -0
  169. package/dist/trigger/script-sandbox.js +170 -24
  170. package/dist/utils/cross-platform.js +24 -10
  171. package/dist/utils/evolcore-version.js +69 -27
  172. package/dist/utils/instance-registry.js +19 -13
  173. package/dist/utils/npm-ops.js +2 -1
  174. package/dist/utils/package-version-info.js +6 -3
  175. package/dist/utils/process-introspect.js +45 -9
  176. package/dist/utils/startup-trace.js +74 -37
  177. package/dist/utils/windows-shell-trust.js +80 -6
  178. package/kits/docs/INDEX.md +2 -2
  179. package/kits/docs/aun/ABILITY_CALLING.md +9 -15
  180. package/kits/docs/context-assembly.md +1 -1
  181. package/kits/docs/evolcore/INDEX.md +3 -1
  182. package/kits/docs/evolcore/ability.md +4 -0
  183. package/kits/docs/evolcore/agent.md +22 -1
  184. package/kits/docs/evolcore/aid.md +1 -1
  185. package/kits/docs/evolcore/event-center.md +227 -0
  186. package/kits/docs/evolcore/file-navigation.md +10 -264
  187. package/kits/docs/evolcore/fs.md +5 -3
  188. package/kits/docs/evolcore/group.md +1 -1
  189. package/kits/docs/evolcore/memory-architecture.md +2 -0
  190. package/kits/docs/evolcore/menu-protocol.md +28 -1
  191. package/kits/docs/evolcore/msg.md +21 -9
  192. package/kits/docs/evolcore/provider.md +3 -1
  193. package/kits/docs/evolcore/response.md +5 -5
  194. package/kits/docs/evolcore/services.md +294 -0
  195. package/kits/docs/evolcore/task.md +2 -0
  196. package/kits/docs/evolcore/team-workspace.md +41 -0
  197. package/kits/docs/evolcore/thread-chain.md +15 -3
  198. package/kits/eck_manifest.json +26 -0
  199. package/kits/rules/02-navigation.md +10 -1
  200. package/kits/rules/06-channel.md +1 -0
  201. package/kits/schemas/_meta.json +17 -6
  202. package/kits/schemas/agent-config.schema.19.json +5 -7
  203. package/kits/schemas/agent-config.schema.20.json +936 -0
  204. package/kits/schemas/relation-config.schema.12.json +2 -3
  205. package/kits/schemas/role-config.schema.2.json +4 -4
  206. package/kits/skills/.switches.json +1 -5
  207. package/kits/skills/ability/SKILL.md +56 -0
  208. package/kits/skills/ability/references/calling.md +56 -0
  209. package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
  210. package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
  211. package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
  212. package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
  213. package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
  214. package/kits/skills/ec-agent-create/SKILL.md +0 -1
  215. package/kits/skills/ec-group/SKILL.md +5 -8
  216. package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
  217. package/kits/skills/ec-service-proxy/SKILL.md +34 -5
  218. package/kits/skills/ec-trigger/SKILL.md +4 -4
  219. package/kits/skills/personal-assistant/SKILL.md +6 -6
  220. package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
  221. package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
  222. package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
  223. package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
  224. package/kits/skills/thread-ops/SKILL.md +10 -10
  225. package/kits/templates/message-fragments/item.md +1 -1
  226. package/kits/templates/system-fragments/channel.md +3 -3
  227. package/kits/templates/system-fragments/commands.md +5 -3
  228. package/kits/templates/system-fragments/reply.md +1 -5
  229. package/kits/templates/system-fragments/thread.md +13 -10
  230. package/package.json +5 -6
  231. package/scripts/agent-template/index.mjs +40 -0
  232. package/scripts/agent-template/inspect.mjs +240 -0
  233. package/scripts/agent-template/overlay.mjs +71 -0
  234. package/scripts/agent-template/pack.mjs +169 -0
  235. package/scripts/agent-template/shared/common.mjs +235 -0
  236. package/scripts/agent-template/shared/evolcore.mjs +75 -0
  237. package/scripts/agent-template/shared/plan.mjs +129 -0
  238. package/scripts/agent-template/shared/team-schema.json +70 -0
  239. package/scripts/agent-template/shared/template-contract.mjs +154 -0
  240. package/scripts/agent-template/shared/template-package.mjs +265 -0
  241. package/scripts/agent-template/shared/template-runtime.mjs +80 -0
  242. package/scripts/agent-template/shared/template.mjs +142 -0
  243. package/dist/cli/pa-workspace-command.js +0 -225
  244. package/dist/core/command/pa-workspace-store.js +0 -468
  245. package/dist/core/relation/pa-team.js +0 -132
  246. package/kits/docs/evolcore/pa-workspace.md +0 -51
  247. package/kits/skills/aid-ability/SKILL.md +0 -244
  248. package/kits/skills/ec-ability/SKILL.md +0 -67
  249. package/kits/skills/ec-ability/references/workflows.md +0 -15
package/dist/cli/index.js CHANGED
@@ -12,7 +12,6 @@ import * as platform from '../utils/cross-platform.js';
12
12
  // 实测这些模块各自 350-590ms(aun-commands/agent-command/init 最重),
13
13
  // 静态导入会让 `ec start` 的 CLI bootstrap 多花约 300ms 而毫无收益。
14
14
  // 本文件其余分支(task/trigger/proxy/thread/...)本来就是这个写法。
15
- import { cmdStart, cmdStop, cmdRestart, cmdStatus, cmdLogs, cmdWatchCommand, cmdMv, cmdDiagnose } from './daemon-commands.js';
16
15
  import { logCliCommand } from './command-log.js';
17
16
  import { isInitCancelledError, printInitCancelHint } from './init-cancel.js';
18
17
  import { assertManagedTopLevelCommandAllowed, ManagedCommandNotAllowedError } from './managed-command-guard.js';
@@ -38,11 +37,13 @@ Agent 与会话:
38
37
  session 按 ec 会话 id 查询本地 session 存档(含 agentSessionId)
39
38
  getmeta 按会话 id / threadId / agentSessionId 查询会话元数据
40
39
  thread 话题链:对端话题的列表、历史、摘要与索引维护
40
+ events 事件中心:事件包状态、台账、白名单与发布
41
+ services 服务路由:服务包状态、台账、诊断与对端调用
41
42
  memory 记忆:写 note、整理正式记忆、触发整理会话
42
43
  task 恢复暂停或异常中断的会话任务
43
44
  trigger 管理定时与事件触发器
44
45
  proxy 查询和管理 daemon 服务代理
45
- pa-workspace 绑定 PA 工作区并维护入口导航
46
+ team 管理 Team Workspace、导航和成员
46
47
  model 查看或设置模型与推理强度
47
48
  response 查看或设置响应模式
48
49
 
@@ -69,6 +70,7 @@ AUN:
69
70
  配置与诊断:
70
71
  config 读取、修改和检查分层配置
71
72
  provider 管理 daemon 级 Provider 注册表与 JSON 导入
73
+ invoke 统一模型调用:按 provider 的 style 路由到内置执行器
72
74
  ability 按 AID 管理能力插件、运行、发布和作业
73
75
  stats Token 用量与费用统计
74
76
  skill EC 技能管理:加载、安装、启停与索引刷新
@@ -92,6 +94,27 @@ AUN:
92
94
  MESSAGE_LOG 消息日志(默认: true)
93
95
  EVENT_LOG 事件日志(默认: true)
94
96
  CHANNEL_LOGS 渠道边界审计日志(默认: false;也可用 daemon.json.debug.channelLogs)`;
97
+ /**
98
+ * 顶层命令全集,必须与下方 switch 的 case(以及版本别名分支)同步。
99
+ *
100
+ * 用于在托管任务里区分「命令不存在」和「命令存在但被策略拒绝」:
101
+ * 白名单守卫只认识自己那份 allowlist,未知命令会先被它拦下并报成
102
+ * NOT_ALLOWED,看起来像权限问题,实际只是打错了命令名。
103
+ */
104
+ export const KNOWN_TOP_LEVEL_COMMANDS = new Set([
105
+ 'init', 'start', 'stop', 'restart', 'restart-monitor',
106
+ 'upgrade', 'update', 'status', 'logs', 'watch',
107
+ 'mode', 'mv', 'diagnose', 'data', 'net', 'integrity',
108
+ 'ctl', 'memory', 'queue', 'task', 'trigger', 'proxy', 'team',
109
+ 'agent', 'aid', 'rpc', 'diag', 'menu-client',
110
+ 'storage', 'fs', 'msg', 'thread', 'events', 'services',
111
+ 'session', 'getmeta', 'group', 'model', 'skill', 'response',
112
+ 'config', 'peer', 'directory', 'role', 'stats',
113
+ 'provider', 'invoke', 'ability',
114
+ // 版本三个别名在 switch 之前统一处理(含只在早期分支出现的 -V)。
115
+ 'version', '-v', '-V', '--version',
116
+ 'bench', 'link-rules',
117
+ ]);
95
118
  function printLifecycleHelp(command) {
96
119
  const help = {
97
120
  start: `用法: ec start [--foreground] [--diagnose|-d] [--debug] [--as-mode dev|install]\n\n --foreground 前台运行,适合 systemd 或容器直接管理\n --diagnose, -d 以诊断模式启动 daemon\n --debug 调试模式:注册调试 IPC,可在宿主终端以任意 session 身份发命令\n --as-mode 覆盖运行模式判定(仅本次启动生效,不写配置):\n install = 按安装模式(校验随包文件完整性,篡改自动恢复)\n dev = 按开发模式(不校验随包文件)`,
@@ -168,6 +191,14 @@ export async function main(args) {
168
191
  await resolveDebugContext(args);
169
192
  // 注入完成后剥除 --as-session <sessionId> 两个参数,避免子命令把它们当作未知参数
170
193
  const strippedArgs = stripAsSessionArgs(args);
194
+ // 未知命令先于托管策略判定:白名单守卫不掌握命令全集,先跑会把
195
+ // `ec self` 这类不存在的命令报成 NOT_ALLOWED,误导成权限问题。
196
+ if (!isHelpFlag(cmd) && !KNOWN_TOP_LEVEL_COMMANDS.has(cmd)) {
197
+ console.error(`未知命令: ${cmd}`);
198
+ console.log(MAIN_HELP);
199
+ process.exitCode = 1;
200
+ return;
201
+ }
171
202
  try {
172
203
  await assertManagedTopLevelCommandAllowed(cmd, strippedArgs);
173
204
  }
@@ -321,7 +352,7 @@ export async function main(args) {
321
352
  process.exitCode = 1;
322
353
  break;
323
354
  }
324
- await cmdStart({
355
+ await (await import('./daemon-commands.js')).cmdStart({
325
356
  diagnose: strippedArgs.includes('--diagnose') || strippedArgs.includes('-d'),
326
357
  foreground: strippedArgs.includes('--foreground'),
327
358
  debug: strippedArgs.includes('--debug'),
@@ -338,7 +369,7 @@ export async function main(args) {
338
369
  process.exitCode = 1;
339
370
  break;
340
371
  }
341
- await cmdStop();
372
+ await (await import('./daemon-commands.js')).cmdStop();
342
373
  break;
343
374
  case 'restart':
344
375
  if (wantsHelp(strippedArgs.slice(1))) {
@@ -349,7 +380,7 @@ export async function main(args) {
349
380
  process.exitCode = 1;
350
381
  break;
351
382
  }
352
- await cmdRestart({ clear: strippedArgs.includes('--clear'), diagnose: strippedArgs.includes('--diagnose') || strippedArgs.includes('-d') });
383
+ await (await import('./daemon-commands.js')).cmdRestart({ clear: strippedArgs.includes('--clear'), diagnose: strippedArgs.includes('--diagnose') || strippedArgs.includes('-d') });
353
384
  break;
354
385
  case 'upgrade':
355
386
  case 'update': {
@@ -400,10 +431,10 @@ export async function main(args) {
400
431
  process.exitCode = 1;
401
432
  break;
402
433
  }
403
- await cmdStatus({ format });
434
+ await (await import('./daemon-commands.js')).cmdStatus({ format });
404
435
  }
405
436
  else {
406
- await cmdStatus({ format });
437
+ await (await import('./daemon-commands.js')).cmdStatus({ format });
407
438
  }
408
439
  }
409
440
  break;
@@ -412,14 +443,14 @@ export async function main(args) {
412
443
  printLifecycleHelp('logs');
413
444
  break;
414
445
  }
415
- await cmdLogs(strippedArgs.slice(1));
446
+ await (await import('./daemon-commands.js')).cmdLogs(strippedArgs.slice(1));
416
447
  break;
417
448
  case 'watch':
418
449
  if (wantsHelp(strippedArgs.slice(1))) {
419
450
  printLifecycleHelp('watch');
420
451
  break;
421
452
  }
422
- await cmdWatchCommand(strippedArgs.slice(1));
453
+ await (await import('./daemon-commands.js')).cmdWatchCommand(strippedArgs.slice(1));
423
454
  break;
424
455
  case 'restart-monitor':
425
456
  if (wantsHelp(strippedArgs.slice(1))) {
@@ -448,14 +479,14 @@ export async function main(args) {
448
479
  printLifecycleHelp('mv');
449
480
  break;
450
481
  }
451
- await cmdMv(strippedArgs[1], strippedArgs[2]);
482
+ await (await import('./daemon-commands.js')).cmdMv(strippedArgs[1], strippedArgs[2]);
452
483
  break;
453
484
  case 'diagnose':
454
485
  if (wantsHelp(strippedArgs.slice(1))) {
455
486
  printLifecycleHelp('diagnose');
456
487
  break;
457
488
  }
458
- await cmdDiagnose(strippedArgs.slice(1));
489
+ await (await import('./daemon-commands.js')).cmdDiagnose(strippedArgs.slice(1));
459
490
  break;
460
491
  case 'data': {
461
492
  const { cmdData } = await import('./data-command.js');
@@ -580,6 +611,16 @@ export async function main(args) {
580
611
  await runThreadCommand(strippedArgs.slice(1));
581
612
  break;
582
613
  }
614
+ case 'events': {
615
+ const { runEventsCommand } = await import('./events-command.js');
616
+ await runEventsCommand(strippedArgs.slice(1));
617
+ break;
618
+ }
619
+ case 'services': {
620
+ const { runServicesCommand } = await import('./services-command.js');
621
+ await runServicesCommand(strippedArgs.slice(1));
622
+ break;
623
+ }
583
624
  case 'session': {
584
625
  const { runSessionCommand } = await import('./session-command.js');
585
626
  await runSessionCommand(strippedArgs.slice(1));
@@ -606,9 +647,9 @@ export async function main(args) {
606
647
  await cmdSkill(strippedArgs.slice(1));
607
648
  break;
608
649
  }
609
- case 'pa-workspace': {
610
- const { cmdPaWorkspace } = await import('./pa-workspace-command.js');
611
- await cmdPaWorkspace(strippedArgs.slice(1));
650
+ case 'team': {
651
+ const { cmdTeamWorkspace } = await import('./team-workspace-command.js');
652
+ await cmdTeamWorkspace(strippedArgs.slice(1));
612
653
  break;
613
654
  }
614
655
  case 'response': {
@@ -621,6 +662,11 @@ export async function main(args) {
621
662
  await cmdProvider(strippedArgs.slice(1));
622
663
  break;
623
664
  }
665
+ case 'invoke': {
666
+ const { cmdInvoke } = await import('./invoke-command.js');
667
+ await cmdInvoke(strippedArgs.slice(1));
668
+ break;
669
+ }
624
670
  case 'ability': {
625
671
  const { cmdAbility } = await import('./ability-command.js');
626
672
  await cmdAbility(strippedArgs.slice(1));
@@ -0,0 +1,182 @@
1
+ /**
2
+ * `ec invoke` —— 统一模型调用入口。
3
+ *
4
+ * 设计见 `docs/model-intent/invoke-design.md`。
5
+ *
6
+ * 它不经过任何 baseagent:直接读 `providers.json` 的端点打过去。
7
+ * 所以在 Claude Code 会话里可以调 Codex 端点,也可以调生图/生视频端点——
8
+ * 只要端点在 providers.json 里登记过。
9
+ */
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ import { resolvePaths } from '../paths.js';
13
+ import { readDelegationCredential, hashCurrentDelegatedCommand } from '../core/auth/agent-delegation.js';
14
+ import { daemonUnavailableMessage, queryDaemon, wantsHelp } from './help.js';
15
+ import { parseInvokeArgv } from '../config/invoke-ipc-service.js';
16
+ const HELP = `用法: ec invoke --provider <id> --service <type> (--input <json>|--input-file <path>) [选项]
17
+
18
+ 统一模型调用入口:按 providers.json 的 style 路由到内置执行器。
19
+
20
+ 必填:
21
+ --provider <id> Provider ID(支持别名)
22
+ --service <type> providers.json 的 service 类型,如 text / image / decision
23
+ --input <json> | --input-file <path> 端点特定入参(JSON)
24
+
25
+ 可选:
26
+ --model <id> 缺省取该 service 下第一个已启用模型
27
+ --out <path> 产物落盘路径(图片/音频/视频)
28
+ --timeout <duration> 单次尝试超时,缺省 60s;支持 30s / 2m / 60000
29
+ --retries <n> 传输层重试次数,缺省 3,上限 10;0 = 只打一次
30
+ 仅 5xx/超时/连接失败重试,4xx 不重试
31
+ --dry-run 只解析与路由,不触网
32
+ --format json|text 缺省 json
33
+
34
+ 示例:
35
+ ec invoke --provider provider-1 --service text --model sonnet \\
36
+ --input '{"input":"你好"}'
37
+ ec invoke --provider provider-2 --service image --model dall-e-3 \\
38
+ --input '{"prompt":"一只猫"}' --out ./cat.png
39
+
40
+ 路由表(内置):
41
+ claude / anthropic → /v1/messages
42
+ codex / openai-responses→ /v1/responses
43
+ openai-compatible → /v1/chat/completions
44
+ gemini → /v1beta/models/{model}:generateContent
45
+ systemone → POST {baseUrl}
46
+ openai-images → /v1/images/generations (service: image)
47
+ openai-audio → /v1/audio/speech (service: speech)
48
+ openai-audio → /v1/audio/transcriptions (service: transcribe)
49
+ openai-embeddings → /v1/embeddings (service: embedding)
50
+
51
+ 本命令不修改 providers.json;产物路径由调用方指定。`;
52
+ function parseDuration(raw) {
53
+ const match = /^(\d+)\s*(ms|s|m|h)?$/u.exec(raw.trim());
54
+ if (!match)
55
+ throw Object.assign(new Error(`--timeout 格式无效: ${raw}`), { code: 'INVALID_ARGUMENT' });
56
+ const value = Number(match[1]);
57
+ const unit = match[2] ?? 'ms';
58
+ const factor = unit === 'h' ? 3_600_000 : unit === 'm' ? 60_000 : unit === 's' ? 1_000 : 1;
59
+ return value * factor;
60
+ }
61
+ /** 把 `--timeout <duration>` 统一改写为 `--timeout-ms <n>`。 */
62
+ function normalizeTimeoutArgs(args) {
63
+ const out = [];
64
+ for (let index = 0; index < args.length; index++) {
65
+ const token = args[index];
66
+ if (token === '--timeout') {
67
+ const value = args[index + 1];
68
+ if (value === undefined)
69
+ throw Object.assign(new Error('--timeout requires a value'), { code: 'INVALID_ARGUMENT' });
70
+ out.push('--timeout-ms', String(parseDuration(value)));
71
+ index++;
72
+ continue;
73
+ }
74
+ if (token.startsWith('--timeout=')) {
75
+ out.push('--timeout-ms', String(parseDuration(token.slice('--timeout='.length))));
76
+ continue;
77
+ }
78
+ out.push(token);
79
+ }
80
+ return out;
81
+ }
82
+ function isSuccess(response) {
83
+ // 只有明确的 ok:true 才算成功;daemon 旧版本或异常响应只带 error 时按失败处理。
84
+ return response.ok === true;
85
+ }
86
+ function renderText(response) {
87
+ if (!isSuccess(response)) {
88
+ const code = response.code ?? 'INVOKE_FAILED';
89
+ const message = response.error ?? 'invoke failed';
90
+ return `❌ ${message} (${code})` + (response.data?.hint ? `\n 提示: ${response.data.hint}` : '');
91
+ }
92
+ const lines = [
93
+ `✓ 调用成功`,
94
+ ` provider: ${response.provider}`,
95
+ ` service : ${response.service}`,
96
+ ` model : ${response.model}`,
97
+ ` style : ${response.style}`,
98
+ ` executor: ${response.executor}`,
99
+ ` latency : ${response.result?.latencyMs ?? 0}ms`,
100
+ ];
101
+ if (response.result?.artifacts?.length) {
102
+ lines.push(' 产物:');
103
+ for (const artifact of response.result.artifacts) {
104
+ lines.push(` ${artifact.kind}${artifact.path ? ` ${artifact.path}` : ''}${artifact.url ? ` ${artifact.url}` : ''}`);
105
+ }
106
+ }
107
+ return lines.join('\n');
108
+ }
109
+ export async function cmdInvoke(args) {
110
+ if (!args.length || wantsHelp(args)) {
111
+ console.log(HELP);
112
+ return;
113
+ }
114
+ const json = args.some((value, index) => value === '--format=json' || (value === '--format' && args[index + 1] === 'json'));
115
+ const emit = (payload) => {
116
+ if (json)
117
+ console.log(JSON.stringify(payload, null, 2));
118
+ else if (!isSuccess(payload))
119
+ console.error(renderText(payload));
120
+ else
121
+ console.log(renderText(payload));
122
+ };
123
+ let parsed;
124
+ try {
125
+ // 本地把 `--timeout <duration>` 换算成毫秒,再交给统一的 argv 解析。
126
+ const normalized = normalizeTimeoutArgs(args);
127
+ parsed = parseInvokeArgv(['invoke', ...normalized]);
128
+ }
129
+ catch (error) {
130
+ emit({ ok: false, code: error.code ?? 'INVALID_ARGUMENT', error: error.message });
131
+ process.exitCode = 1;
132
+ return;
133
+ }
134
+ // 本地解析出的 input:路径相对 cwd 解析(daemon 无法知道调用方 cwd)。
135
+ const inputText = parsed.inputFile
136
+ ? fs.readFileSync(path.resolve(parsed.inputFile), 'utf8')
137
+ : parsed.input;
138
+ if (Buffer.byteLength(inputText, 'utf8') > 1024 * 1024) {
139
+ emit({ ok: false, code: 'INVALID_ARGUMENT', error: 'invoke input must be under 1 MiB' });
140
+ process.exitCode = 1;
141
+ return;
142
+ }
143
+ const timeoutMs = parsed.timeoutMs;
144
+ const retries = parsed.retries === undefined ? undefined : Number(parsed.retries);
145
+ const sessionId = process.env.EVOLCORE_SESSION_ID;
146
+ const delegationToken = readDelegationCredential();
147
+ // 托管与非托管都走 daemon:密钥解析($VAR)与 providers.json 的合理归属都在 daemon。
148
+ const argv = [
149
+ 'invoke',
150
+ '--provider', parsed.providerId,
151
+ '--service', parsed.serviceType,
152
+ ...(parsed.model ? ['--model', parsed.model] : []),
153
+ ...(parsed.out ? ['--out', path.resolve(parsed.out)] : []),
154
+ ...(timeoutMs !== undefined ? ['--timeout-ms', String(timeoutMs)] : []),
155
+ ...(retries !== undefined ? ['--retries', String(retries)] : []),
156
+ ...(parsed.dryRun ? ['--dry-run'] : []),
157
+ ];
158
+ try {
159
+ let controlToken;
160
+ if (!sessionId && !delegationToken) {
161
+ try {
162
+ controlToken = fs.readFileSync(resolvePaths().controlToken, 'utf8').trim();
163
+ }
164
+ catch { }
165
+ }
166
+ const { response, transportError } = await queryDaemon(resolvePaths().socket, {
167
+ type: 'invoke.op', argv, input: inputText,
168
+ ...(sessionId || delegationToken
169
+ ? { sessionId, delegationToken, delegationCommandHash: hashCurrentDelegatedCommand() }
170
+ : { controlToken }),
171
+ }, (timeoutMs ?? 60_000) + 30_000);
172
+ if (!response)
173
+ throw Object.assign(new Error(daemonUnavailableMessage(transportError, '无法连接 EvolCore daemon')), { code: 'DAEMON_UNAVAILABLE' });
174
+ emit(response);
175
+ if (!isSuccess(response))
176
+ process.exitCode = 1;
177
+ }
178
+ catch (error) {
179
+ emit({ ok: false, code: error.code ?? 'INVOKE_FAILED', error: error.message });
180
+ process.exitCode = 1;
181
+ }
182
+ }
@@ -20,9 +20,11 @@ const MANAGED_TASK_COMMANDS = new Set([
20
20
  'memory',
21
21
  'model',
22
22
  'msg',
23
- 'pa-workspace',
23
+ 'team',
24
24
  'proxy',
25
25
  'provider',
26
+ // `invoke` 调用已登记的端点,不改配置;具体授权由 invoke.op 的委托校验完成。
27
+ 'invoke',
26
28
  'ability',
27
29
  'queue',
28
30
  'response',
@@ -39,6 +41,9 @@ const MANAGED_TASK_COMMANDS = new Set([
39
41
  // ec-skill 技能的 SKILL.md 明确指导 agent 调用它。脚本只读写
40
42
  // `thread` 提供话题链操作,通过 thread.op IPC 鉴权
41
43
  'thread',
44
+ // `events` 事件中心运维(白名单自动维护脚本用它加白名单),通过 events.op IPC
45
+ // 且要求本地 control token,daemon 侧鉴权。
46
+ 'events',
42
47
  // $EVOLCORE_HOME/skills/ 与 kits/skills/ 下的技能文件,不触碰进程生命周期。
43
48
  // 本白名单只负责让它进到脚本;具体某一级的读写权限由 skill.mjs 的
44
49
  // assertPermission() 按会话上下文判定(群聊一律拒,Agent 级要 owner,
@@ -39,7 +39,7 @@ const i18n = {
39
39
  sessionReady: isZh ? '会话就绪' : 'session ready',
40
40
  pingOk: isZh ? '响应正常' : 'response ok',
41
41
  pingFailed: isZh ? '失败' : 'failed',
42
- msgOk: isZh ? '自发自收成功' : 'self-send ok',
42
+ msgOk: isZh ? '自派自收成功' : 'self-send ok',
43
43
  msgFailed: isZh ? '消息发送失败' : 'message send failed',
44
44
  noGateway: isZh ? '响应中无网关地址' : 'no gateway in response',
45
45
  fetchGwFailed: isZh ? '获取网关失败' : 'fetch gateway failed',