evolcore 0.0.43-test.5 → 0.0.43-test.7

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 (259) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/bin/ecmsg.js +281 -81
  3. package/dist/agents/baseagent-availability.js +20 -5
  4. package/dist/agents/baseagent.js +2 -2
  5. package/dist/agents/claude-runner.js +19 -4
  6. package/dist/agents/codex/app-server-client.js +36 -3
  7. package/dist/agents/codex-runner.js +75 -8
  8. package/dist/aun/group/invite-service.js +3 -2
  9. package/dist/aun/msg/p2p.js +6 -1
  10. package/dist/aun/service-proxy.js +18 -6
  11. package/dist/channels/aun.js +306 -30
  12. package/dist/cli/agent-create.js +18 -8
  13. package/dist/cli/aun-commands.js +9 -1
  14. package/dist/cli/daemon-commands.js +34 -65
  15. package/dist/cli/daemon-lifecycle-client.js +61 -0
  16. package/dist/cli/ecmsg-gateway.js +38 -3
  17. package/dist/cli/events-command.js +73 -0
  18. package/dist/cli/index.js +31 -14
  19. package/dist/cli/init.js +75 -0
  20. package/dist/cli/invoke-command.js +182 -0
  21. package/dist/cli/managed-command-guard.js +6 -1
  22. package/dist/cli/provider-command.js +1 -1
  23. package/dist/cli/restart-monitor.js +67 -50
  24. package/dist/cli/services-command.js +111 -0
  25. package/dist/cli/task-context.js +38 -1
  26. package/dist/cli/team-workspace-command.js +134 -0
  27. package/dist/cli/thread-command.js +6 -2
  28. package/dist/cli/watch-logs.js +6 -4
  29. package/dist/cli/watch-msg.js +1 -1
  30. package/dist/config/boot-log.js +6 -4
  31. package/dist/config/builtin-roles.js +2 -2
  32. package/dist/config/config-field-policy.js +2 -2
  33. package/dist/config/config-manager.js +1 -8
  34. package/dist/config/invoke-ipc-service.js +118 -0
  35. package/dist/config/peer-role-resolver.js +1 -1
  36. package/dist/config/provider-identity-migration.js +92 -17
  37. package/dist/config/provider-local-sync.js +2 -0
  38. package/dist/config/providers-config.js +13 -0
  39. package/dist/config/providers-management.js +100 -10
  40. package/dist/config/role-service.js +8 -8
  41. package/dist/config/role-store.js +22 -22
  42. package/dist/config/schema-migration.js +86 -88
  43. package/dist/config/snapshot.js +70 -41
  44. package/dist/config-store.js +2 -1
  45. package/dist/core/agent-reload-coordinator.js +6 -4
  46. package/dist/core/agent-runtime.js +146 -15
  47. package/dist/core/auth/delegation-authorization.js +66 -0
  48. package/dist/core/auth/operation-catalog.js +20 -0
  49. package/dist/core/baseagent-loader.js +75 -42
  50. package/dist/core/channel-loader.js +45 -13
  51. package/dist/core/channel-runtime.js +116 -45
  52. package/dist/core/command/agent-control.js +1 -1
  53. package/dist/core/command/agent-storage-menu.js +1 -1
  54. package/dist/core/command/chatmode-config.js +2 -36
  55. package/dist/core/command/command-handler.js +58 -16
  56. package/dist/core/command/data-root-resolver.js +32 -23
  57. package/dist/core/command/eventcenter-menu.js +338 -0
  58. package/dist/core/command/menu-catalog.js +8 -0
  59. package/dist/core/command/menu-handler.js +206 -87
  60. package/dist/core/command/menu-protocol.js +142 -22
  61. package/dist/core/command/menu-query-batch.js +194 -0
  62. package/dist/core/command/role-menu.js +27 -15
  63. package/dist/core/command/slash-gate.js +1 -1
  64. package/dist/core/command/slash-handler.js +34 -42
  65. package/dist/core/command/team-workspace-bootstrap.js +350 -0
  66. package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
  67. package/dist/core/command/team-workspace-initializer.js +2 -0
  68. package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
  69. package/dist/core/command/team-workspace-job-store.js +88 -0
  70. package/dist/core/command/team-workspace-management-service.js +2 -0
  71. package/dist/core/command/team-workspace-management-store.js +96 -0
  72. package/dist/core/command/team-workspace-management.js +265 -0
  73. package/dist/core/command/team-workspace-members-menu.js +88 -0
  74. package/dist/core/command/team-workspace-store.js +612 -0
  75. package/dist/core/command/team-workspace-team.js +193 -0
  76. package/dist/core/daemon-control.js +45 -15
  77. package/dist/core/daemon-lifecycle.js +478 -75
  78. package/dist/core/handoff/dispatcher.js +9 -3
  79. package/dist/core/handoff/runtime.js +130 -42
  80. package/dist/core/handoff/store.js +190 -2
  81. package/dist/core/handoff/types.js +5 -0
  82. package/dist/core/initialization/service.js +4 -4
  83. package/dist/core/invoke/executors/index.js +13 -0
  84. package/dist/core/invoke/executors/media.js +283 -0
  85. package/dist/core/invoke/executors/text.js +198 -0
  86. package/dist/core/invoke/invoke-service.js +157 -0
  87. package/dist/core/invoke/style-router.js +48 -0
  88. package/dist/core/invoke/types.js +19 -0
  89. package/dist/core/ipc-registration.js +51 -11
  90. package/dist/core/lifecycle-notice.js +10 -4
  91. package/dist/core/memory/consolidation.js +7 -5
  92. package/dist/core/message/aun-ipc-sender.js +149 -19
  93. package/dist/core/message/im-renderer.js +28 -84
  94. package/dist/core/message/message-bridge.js +57 -4
  95. package/dist/core/message/message-queue.js +46 -4
  96. package/dist/core/message/message-utils.js +10 -2
  97. package/dist/core/message/peer-mode.js +7 -34
  98. package/dist/core/message/pending-hints.js +4 -10
  99. package/dist/core/message/response-engine.js +163 -52
  100. package/dist/core/message/send-options.js +7 -4
  101. package/dist/core/message/send-routing.js +55 -7
  102. package/dist/core/ownership/owner-resolver.js +8 -0
  103. package/dist/core/permission/ec-command-parser.js +14 -3
  104. package/dist/core/permission/protected-paths.js +12 -2
  105. package/dist/core/permission/shell-environment.js +9 -0
  106. package/dist/core/session/adapters/claude-session-file-adapter.js +24 -0
  107. package/dist/core/session/adapters/codex-session-file-adapter.js +80 -0
  108. package/dist/core/session/adapters/ecagent-session-file-adapter.js +22 -0
  109. package/dist/core/session/adapters/gemini-session-file-adapter.js +39 -0
  110. package/dist/core/session/session-file-health.js +243 -0
  111. package/dist/core/session/session-fs-store.js +163 -3
  112. package/dist/core/session/session-idle-monitor.js +9 -1
  113. package/dist/core/session/session-manager.js +36 -2
  114. package/dist/core/task/task-recovery-service.js +13 -2
  115. package/dist/core/thread/command-parser.js +9 -2
  116. package/dist/core/thread/thread-operation.js +21 -2
  117. package/dist/core/thread/thread-route.js +13 -2
  118. package/dist/directory/owner-directory-admission.js +42 -30
  119. package/dist/directory/owner-directory-cache.js +143 -126
  120. package/dist/directory/owner-directory-query-operation.js +9 -8
  121. package/dist/eck/kit-renderer.js +7 -5
  122. package/dist/ecweb/basic-settings-service.js +1 -1
  123. package/dist/ecweb/message-context-service.js +0 -4
  124. package/dist/ecweb/runtime/lifecycle.js +14 -8
  125. package/dist/ecweb/runtime/supervisor.js +62 -30
  126. package/dist/event-center/admission-materializer.js +114 -0
  127. package/dist/event-center/bus-gate.js +136 -0
  128. package/dist/event-center/bus-host.js +290 -0
  129. package/dist/event-center/bus-resolver.js +120 -0
  130. package/dist/event-center/center-config.js +100 -0
  131. package/dist/event-center/client-factory.js +50 -0
  132. package/dist/event-center/daemon.js +45 -0
  133. package/dist/event-center/directory-source.js +53 -0
  134. package/dist/event-center/dispatcher.js +157 -0
  135. package/dist/event-center/event-log.js +110 -0
  136. package/dist/event-center/index-generator.js +63 -0
  137. package/dist/event-center/ipc-operation.js +308 -0
  138. package/dist/event-center/ledger.js +52 -0
  139. package/dist/event-center/pack-loader.js +202 -0
  140. package/dist/event-center/pack-manager.js +85 -0
  141. package/dist/event-center/registry.js +238 -0
  142. package/dist/event-center/runtime.js +641 -0
  143. package/dist/event-center/script-runner.js +356 -0
  144. package/dist/event-center/types.js +35 -0
  145. package/dist/event-center/validation.js +413 -0
  146. package/dist/index.js +751 -268
  147. package/dist/ipc.js +66 -12
  148. package/dist/paths.js +20 -0
  149. package/dist/product.js +14 -0
  150. package/dist/proxy/manager.js +43 -18
  151. package/dist/proxy/service-supervisor.js +78 -35
  152. package/dist/response-system/engines/v1/index.js +0 -1
  153. package/dist/response-system/modes/single-session/index.js +1 -1
  154. package/dist/services/dispatcher.js +100 -0
  155. package/dist/services/idempotency.js +90 -0
  156. package/dist/services/identity.js +52 -0
  157. package/dist/services/index-generator.js +70 -0
  158. package/dist/services/index.js +449 -0
  159. package/dist/services/ipc-operation.js +458 -0
  160. package/dist/services/ledger.js +52 -0
  161. package/dist/services/message-log.js +112 -0
  162. package/dist/services/pack-manager.js +204 -0
  163. package/dist/services/reply.js +55 -0
  164. package/dist/services/router.js +95 -0
  165. package/dist/services/script-runner.js +422 -0
  166. package/dist/services/service-payload.js +70 -0
  167. package/dist/services/types.js +18 -0
  168. package/dist/services/validation.js +297 -0
  169. package/dist/trigger/application-service.js +21 -1
  170. package/dist/trigger/audit.js +19 -4
  171. package/dist/trigger/authorization.js +14 -5
  172. package/dist/trigger/event-source.js +1 -1
  173. package/dist/trigger/history.js +176 -7
  174. package/dist/trigger/ipc-service.js +3 -1
  175. package/dist/trigger/manager.js +1 -3
  176. package/dist/trigger/scheduler.js +78 -5
  177. package/dist/trigger/script-sandbox.js +118 -22
  178. package/dist/utils/cross-platform.js +175 -13
  179. package/dist/utils/evolcore-version.js +69 -27
  180. package/dist/utils/host-info.js +11 -8
  181. package/dist/utils/instance-registry.js +19 -13
  182. package/dist/utils/npm-ops.js +48 -0
  183. package/dist/utils/process-introspect.js +109 -10
  184. package/dist/utils/startup-trace.js +222 -44
  185. package/dist/utils/windows-shell-trust.js +80 -6
  186. package/kits/docs/INDEX.md +2 -2
  187. package/kits/docs/aun/ABILITY_CALLING.md +10 -17
  188. package/kits/docs/context-assembly.md +1 -1
  189. package/kits/docs/evolcore/INDEX.md +5 -2
  190. package/kits/docs/evolcore/ability.md +4 -0
  191. package/kits/docs/evolcore/aid.md +1 -1
  192. package/kits/docs/evolcore/ctl.md +2 -1
  193. package/kits/docs/evolcore/event-center.md +207 -0
  194. package/kits/docs/evolcore/file-navigation.md +10 -264
  195. package/kits/docs/evolcore/fs.md +3 -2
  196. package/kits/docs/evolcore/group.md +2 -2
  197. package/kits/docs/evolcore/memory-architecture.md +2 -0
  198. package/kits/docs/evolcore/menu-exec-schema-commands.md +1 -1
  199. package/kits/docs/evolcore/menu-protocol.md +21 -0
  200. package/kits/docs/evolcore/msg.md +27 -8
  201. package/kits/docs/evolcore/provider.md +23 -3
  202. package/kits/docs/evolcore/response.md +5 -5
  203. package/kits/docs/evolcore/services.md +277 -0
  204. package/kits/docs/evolcore/task.md +2 -0
  205. package/kits/docs/evolcore/team-workspace.md +41 -0
  206. package/kits/eck_manifest.json +45 -7
  207. package/kits/eck_message_manifest.json +3 -3
  208. package/kits/rules/02-navigation.md +10 -1
  209. package/kits/rules/06-channel.md +5 -6
  210. package/kits/schemas/_meta.json +17 -6
  211. package/kits/schemas/agent-config.schema.19.json +5 -7
  212. package/kits/schemas/agent-config.schema.20.json +936 -0
  213. package/kits/schemas/daemon.schema.1.json +5 -0
  214. package/kits/schemas/daemon.schema.2.json +5 -0
  215. package/kits/schemas/daemon.schema.3.json +2 -1
  216. package/kits/schemas/daemon.schema.4.json +2 -1
  217. package/kits/schemas/daemon.schema.5.json +2 -1
  218. package/kits/schemas/daemon.schema.6.json +1 -1
  219. package/kits/schemas/daemon.schema.7.json +1 -1
  220. package/kits/schemas/daemon.schema.8.json +2 -1
  221. package/kits/schemas/daemon.schema.9.json +2 -1
  222. package/kits/schemas/relation-config.schema.12.json +2 -3
  223. package/kits/schemas/role-config.schema.2.json +4 -4
  224. package/kits/schemas/role-registry.schema.1.json +2 -2
  225. package/kits/schemas/single-session.schema.1.json +1 -1
  226. package/kits/schemas/single-session.schema.2.json +1 -1
  227. package/kits/schemas/single-session.schema.3.json +1 -1
  228. package/kits/skills/.switches.json +1 -5
  229. package/kits/skills/ability/SKILL.md +56 -0
  230. package/kits/skills/ability/references/calling.md +56 -0
  231. package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
  232. package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
  233. package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
  234. package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
  235. package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
  236. package/kits/skills/ec-agent-create/SKILL.md +0 -1
  237. package/kits/skills/ec-group/SKILL.md +8 -5
  238. package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
  239. package/kits/skills/ec-service-proxy/SKILL.md +34 -5
  240. package/kits/skills/ec-trigger/SKILL.md +4 -4
  241. package/kits/skills/personal-assistant/SKILL.md +6 -6
  242. package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
  243. package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
  244. package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
  245. package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
  246. package/kits/skills/thread-ops/SKILL.md +10 -10
  247. package/kits/templates/system-fragments/channel.md +3 -3
  248. package/kits/templates/system-fragments/commands.md +9 -7
  249. package/kits/templates/system-fragments/reply.md +2 -6
  250. package/kits/templates/system-fragments/session.md +1 -1
  251. package/kits/templates/system-fragments/thread.md +11 -9
  252. package/package.json +5 -6
  253. package/dist/cli/pa-workspace-command.js +0 -225
  254. package/dist/core/command/pa-workspace-store.js +0 -468
  255. package/dist/core/relation/pa-team.js +0 -132
  256. package/kits/docs/evolcore/pa-workspace.md +0 -51
  257. package/kits/skills/aid-ability/SKILL.md +0 -244
  258. package/kits/skills/ec-ability/SKILL.md +0 -67
  259. package/kits/skills/ec-ability/references/workflows.md +0 -15
@@ -26,6 +26,7 @@ import { creationOwnershipBinding } from '../core/ownership/owner-resolver.js';
26
26
  import { getCatalog, getProviderCatalog, resolveCatalogModel, catalogEfforts, assertCatalogSelectable } from '../core/model/model-catalog.js';
27
27
  import { resolveProviderId, resolveProviderServiceForBaseagent } from '../config/providers.js';
28
28
  import { claimAgentCreation, claimAgentCreationAsync, readAgentCreationClaim, updateAgentCreationClaim } from '../core/agent-creation-claim.js';
29
+ import { initializationRuntimePlan } from '../config/providers-config.js';
29
30
  /** Select the creation lifecycle independently of --non-interactive. */
30
31
  export function resolveAgentCreateMode(args) {
31
32
  if (args.includes('--initialize') && args.includes('--bootstrap')) {
@@ -970,6 +971,12 @@ export function readInitialization(aid) {
970
971
  if (fingerprint !== record.fingerprint)
971
972
  throw new InitializationStateError('fingerprint_mismatch');
972
973
  }
974
+ try {
975
+ initializationRuntimePlan(record);
976
+ }
977
+ catch {
978
+ throw new InitializationStateError('invalid_record');
979
+ }
973
980
  return record;
974
981
  }
975
982
  export function saveInitialization(record) {
@@ -1126,8 +1133,8 @@ export function validateInitializationPlan(plan) {
1126
1133
  if (plan.chatmode !== undefined) {
1127
1134
  if (!plan.chatmode || typeof plan.chatmode !== 'object' || Array.isArray(plan.chatmode)
1128
1135
  || Object.entries(plan.chatmode).some(([scope, value]) => !['private', 'group', 'nothuman'].includes(scope)
1129
- || !(scope === 'group' ? ['proactive'] : ['interactive', 'proactive', ...(scope === 'private' ? ['paactive'] : [])]).includes(value))) {
1130
- failure('INVALID_ARGS', 'chatmode.group must be proactive; paactive is private AUN only');
1136
+ || !(scope === 'group' ? ['proactive'] : ['interactive', 'proactive']).includes(value))) {
1137
+ failure('INVALID_ARGS', 'chatmode.group must be proactive; private/nothuman must be interactive or proactive');
1131
1138
  }
1132
1139
  }
1133
1140
  if (plan.avatarFile !== undefined && plan.avatarUrl !== undefined)
@@ -1251,13 +1258,15 @@ export class AgentInitializationService {
1251
1258
  usable: complete && this.deps.usable(aid), initialization: summary,
1252
1259
  };
1253
1260
  }
1254
- start(plan, actor, dryRun = false) {
1261
+ start(plan, actor, dryRun = false, providerMigration) {
1255
1262
  if (this.deps.authorize && !this.deps.authorize(actor))
1256
1263
  failure('NOT_ALLOWED');
1257
- validateInitializationPlan(plan);
1258
1264
  plan = JSON.parse(JSON.stringify(plan));
1259
- const fingerprint = initializationFingerprint(plan);
1265
+ assertAgentAidAvailable(plan.aid);
1260
1266
  const existing = readInitialization(plan.aid);
1267
+ if (!existing)
1268
+ validateInitializationPlan(initializationRuntimePlan({ plan, providerMigration }));
1269
+ const fingerprint = initializationFingerprint(plan);
1261
1270
  if (existing) {
1262
1271
  if (recordMode(existing) !== 'supplied' || existing.actor !== actor || existing.fingerprint !== fingerprint)
1263
1272
  failure('INITIALIZE_PLAN_CONFLICT');
@@ -1276,6 +1285,7 @@ export class AgentInitializationService {
1276
1285
  }
1277
1286
  const r = {
1278
1287
  version: 1, operationId: `init-${randomBytes(12).toString('hex')}`, actor, plan, fingerprint,
1288
+ ...(providerMigration ? { providerMigration } : {}),
1279
1289
  status: 'in_progress', phase: 'planned', startedAt: Date.now(), updatedAt: Date.now(),
1280
1290
  };
1281
1291
  const claim = claimAgentCreation({
@@ -1434,7 +1444,7 @@ export class AgentInitializationService {
1434
1444
  if (r.status === 'cancelled')
1435
1445
  failure('INITIALIZE_CANCELLED');
1436
1446
  if (r.status !== 'complete' && !this.running.has(aid)) {
1437
- validateInitializationPlan(r.plan);
1447
+ validateInitializationPlan(initializationRuntimePlan(r));
1438
1448
  r.status = 'in_progress';
1439
1449
  if (r.bindAttempt?.state === 'unknown') {
1440
1450
  // A prior local diagnostic (for example TARGET_CHANGED after a
@@ -1596,7 +1606,7 @@ export class AgentInitializationService {
1596
1606
  // they do on initial creation. Only explicit plan overrides are frozen.
1597
1607
  if (config && r.plan.provider !== undefined
1598
1608
  && (typeof baseagentConfig?.provider !== 'string'
1599
- || resolveProviderId(baseagentConfig.provider) !== resolveProviderId(r.plan.provider)))
1609
+ || resolveProviderId(baseagentConfig.provider) !== resolveProviderId(initializationRuntimePlan(r).provider)))
1600
1610
  failure('INITIALIZE_TARGET_CHANGED');
1601
1611
  if (config && r.plan.chatmode !== undefined
1602
1612
  && ['private', 'group', 'nothuman'].some(scope => config.chatmode?.[scope] !== r.plan.chatmode?.[scope])) {
@@ -1749,7 +1759,7 @@ export class AgentInitializationService {
1749
1759
  return true;
1750
1760
  }
1751
1761
  async run(r) {
1752
- const p = r.plan;
1762
+ const p = initializationRuntimePlan(r);
1753
1763
  // Resume from the durable checkpoint. In particular, never call aidCreate
1754
1764
  // again after the bind/activation stages have created the local config.
1755
1765
  if (!r.configSaved) {
@@ -1770,9 +1770,10 @@ Commands:
1770
1770
  online <from> <target-aid> [<target-aid>...] 查询在线状态
1771
1771
  history <from> [<target-aid>|selector] [筛选选项] 查询本地消息历史
1772
1772
 
1773
- 托管会话简化语法(EVOLCORE_SESSION_ID 已设时):
1773
+ 托管会话简化语法(EVOLCORE_SESSION_ID 已设时;正式回复请用 ecmsg send):
1774
1774
  send <text> --thread <id> from/to 从运行时上下文与话题索引自动推断
1775
1775
  send <text> 发送到当前会话对端
1776
+ ecmsg send '<text>' [--thread <id>|--to <对端ID>] 统一入口,跨话题自动建复查
1776
1777
 
1777
1778
  Options:
1778
1779
  --text-from-file <path> 从文件读取文本(UTF-8),用于超长消息或避免 Shell 转义
@@ -2584,6 +2585,7 @@ visitor 不开放历史;群权限仍由托管会话校验。`);
2584
2585
  send <from> <group-id> <text> 发送群文本
2585
2586
  send <from> <group-id> --file <path> [--as <type>] 发送群文件
2586
2587
  send <from> <group-id> --payload <json> 发送自定义 payload
2588
+ (托管会话发消息统一用 ecmsg send '<text>' --to <群ID>,见 ecmsg --help)
2587
2589
  pull <from> <group-id> [--after-seq N] [--limit N] --app <name> 拉取群消息(必须使用独立 slot)
2588
2590
  ack <from> <group-id> <seq> [--app <name>] 确认已读
2589
2591
  history <from> <group-id> [options] 查询本地群消息历史(只读)
@@ -3643,6 +3645,12 @@ export function resolveManagedSendArgv(argv, routing) {
3643
3645
  text.push(...argv.slice(index + 1));
3644
3646
  break;
3645
3647
  }
3648
+ // `--to` / `--from` 是网关选项,托管发送用位置参数表达 from/to。它们不在
3649
+ // 取值表里,落到下面就会进 text —— 正文会变成「--to x.agentid.cn 你好」,
3650
+ // 消息照常送达,于是没人发现发错了。这里明确拒绝,让调用方改写法。
3651
+ if (flag === '--to' || flag === '--from') {
3652
+ throw new Error(`${flag} is not supported by managed send; use positional from/to, or \`ecmsg send --to <aid>\``);
3653
+ }
3646
3654
  if (flag === '--app' || flag === '--aun-path')
3647
3655
  throw new Error(`${flag} is not allowed for managed sends`);
3648
3656
  if (booleanFlags.has(flag))
@@ -32,7 +32,8 @@ import { logLevelRank } from '../utils/logger.js';
32
32
  import { inspectDataMigrationRequirement } from '../core/data-migration.js';
33
33
  import { readHostInfo, readVersionInfo } from '../utils/host-info.js';
34
34
  import { queryStatusActivity, queryStatusActivityByAgent } from '../stats/query.js';
35
- import { listCodexAppServerProcesses, unregisterCodexAppServerProcess } from '../agents/codex/app-server-registry.js';
35
+ import { DAEMON_PROBE_TIMEOUT_MS, DAEMON_SHUTDOWN_TIMEOUT_MS, probeDaemon, requestDaemonShutdown } from './daemon-lifecycle-client.js';
36
+ export { DAEMON_SHUTDOWN_TIMEOUT_MS, requestDaemonShutdown, stopCodexAppServerOrphans } from './daemon-lifecycle-client.js';
36
37
  import { DEFAULT_ECWEB_PORT, ecwebService, serviceRuntimeMode, setEcwebEnabled } from '../config/daemon-services.js';
37
38
  import { checkCodexProjectPath, inspectCodexManagedHook, ensureCodexManagedHook, runCodexHookLaunchDiagnostic, } from '../agents/codex/diagnostics.js';
38
39
  import { formatClaudeSandboxDependencies, formatCodexSandboxAvailability, inspectClaudeSandboxDependencies, inspectCodexSandboxAvailability, probeClaudeSandboxDependencies, probeCodexSandboxAvailability, } from '../core/permission/sandbox-runtime.js';
@@ -135,37 +136,6 @@ function printNoSelfAgentHints(options) {
135
136
  console.log(` - ${skippedAgent.dirName}: ${skippedAgent.reason}`);
136
137
  }
137
138
  }
138
- // Windows named-pipe connection setup can take a couple of seconds on a busy
139
- // host (especially on the first request after the daemon starts). A one-second
140
- // probe causes `ec stop` to skip the IPC shutdown path and fall back to
141
- // taskkill, even though the daemon is healthy and able to shut down gracefully.
142
- const DAEMON_PROBE_TIMEOUT_MS = platform.isWindows ? 5_000 : 1_000;
143
- export const DAEMON_SHUTDOWN_TIMEOUT_MS = platform.isWindows ? 10_000 : 3_000;
144
- async function probeDaemon(socketPath, timeoutMs = DAEMON_PROBE_TIMEOUT_MS, throwOnError = false) {
145
- const response = await ipcQuery(socketPath, { type: 'ping' }, timeoutMs, { throwOnError });
146
- if (response?.pong !== true || !Number.isInteger(response.pid) || response.pid <= 0)
147
- return null;
148
- return response;
149
- }
150
- /** Ask the daemon to run its own graceful shutdown lifecycle. */
151
- export async function requestDaemonShutdown(socketPath, timeoutMs = DAEMON_SHUTDOWN_TIMEOUT_MS, reason = 'cli', expectedPids, traceId) {
152
- const daemon = await probeDaemon(socketPath, Math.min(timeoutMs, DAEMON_PROBE_TIMEOUT_MS));
153
- if (!daemon || (expectedPids && !expectedPids.has(daemon.pid)))
154
- return null;
155
- const response = await ipcQuery(socketPath, {
156
- type: 'shutdown',
157
- reason,
158
- expectedPid: daemon.pid,
159
- // 让 daemon 侧退出阶段落进同一条停止甘特图(时间轴按同一次停止对齐)。
160
- ...(traceId ? { traceId } : {}),
161
- }, timeoutMs);
162
- if (response?.ok !== true || response.accepted !== true
163
- || !Number.isInteger(response.pid) || response.pid <= 0
164
- || response.pid !== daemon.pid) {
165
- return null;
166
- }
167
- return response.pid;
168
- }
169
139
  function hasVisibleDaemonPid(status, ping) {
170
140
  return status.mains.some(entry => entry.alive && entry.record.pid === ping.pid);
171
141
  }
@@ -1511,6 +1481,29 @@ function renderStatusOverview(snapshot) {
1511
1481
  ['Memory', `${Number.isFinite(totalMemory) ? `${formatBytes(totalMemory)} 主机总量` : '主机信息不可用'}${processMemory}`],
1512
1482
  ];
1513
1483
  renderStatusFields(overviewFields);
1484
+ const startup = snapshot.daemon.startup;
1485
+ if (startup) {
1486
+ const phases = { classifying: '识别待恢复任务(控制面可用)', recovering: '优先恢复进行中任务', loading: '完成启动准入', ready: '正常 Ready', failed: '启动未就绪(关键模块失败)' };
1487
+ const states = { waiting: '等待前置阶段', starting: '启动中', recovering: '恢复运行中任务', ready: '已就绪', failed: '失败', disabled: '已禁用', deferred: '按需加载(未加载)' };
1488
+ const agents = startup.agents;
1489
+ renderStatusFields([
1490
+ ['启动进度', phases[startup.phase]],
1491
+ ['已加载', `Runner ${agents.filter(agent => agent.runner === 'ready').length}/${agents.length}`
1492
+ + `(按需 ${agents.filter(agent => agent.runner === 'deferred').length})`
1493
+ + ` · AUN ${agents.filter(agent => agent.aun).length}/${agents.length}`
1494
+ + ` · 恢复登记 ${agents.filter(agent => agent.recovery).length}/${agents.length}`
1495
+ + ` · Trigger ${startup.triggers.loaded}/${startup.triggers.total}`],
1496
+ ['ECWeb 启动', states[startup.ecweb]],
1497
+ ...(startup.priorityRelease === 'timeout' || startup.optionalRelease === 'timeout'
1498
+ ? [['启动放行', '已按等待预算放行后续模块;正常 Ready 仍按实际条件判断']] : []),
1499
+ ]);
1500
+ if (startup.phase !== 'ready') {
1501
+ renderStatusTable(['Agent', '启动组', 'Runner', 'AUN', '恢复登记', 'Trigger'], agents.map(agent => [
1502
+ agent.aid, startup.phase === 'classifying' ? '待判断' : agent.priority ? '优先恢复' : '空闲', states[agent.runner], agent.aun ? '已连接' : '等待连接',
1503
+ agent.recovery ? '完成' : '等待恢复', states[agent.trigger],
1504
+ ]));
1505
+ }
1506
+ }
1514
1507
  const baseagents = snapshot.baseagents?.items;
1515
1508
  const activity = snapshot.activity;
1516
1509
  if (activity) {
@@ -1781,6 +1774,7 @@ async function collectStatusSnapshot() {
1781
1774
  build: statusResponse?.build
1782
1775
  ? { runtimeMode: statusResponse.build.runtimeMode, version: statusResponse.build.version ?? null } : null,
1783
1776
  queue: statusResponse?.queue ?? { pending: null, processing: null },
1777
+ startup: statusResponse?.startup,
1784
1778
  restartMonitorPids: restartMonitors.map(item => item.record.pid),
1785
1779
  },
1786
1780
  baseagents: statusResponse?.baseagents ?? { source: 'unavailable', items: [] },
@@ -1816,7 +1810,7 @@ async function collectStatusSnapshot() {
1816
1810
  ? { source: 'runtime+history', ...statusResponse.triggers }
1817
1811
  : { source: 'unavailable', enabled: null, today: { calls: null, failures: null } },
1818
1812
  proxy: statusResponse?.serviceProxy ?? { source: 'unavailable', items: [] },
1819
- ecweb, diagnostics,
1813
+ ecweb: { ...ecweb, startupState: statusResponse?.startup?.ecweb }, diagnostics,
1820
1814
  };
1821
1815
  }
1822
1816
  function renderStatusHeader(snapshot) {
@@ -2915,7 +2909,7 @@ async function cmdWatchAid() {
2915
2909
  // 标记生成:[明文/密文|自主/响应](紫色=工具渲染标记)
2916
2910
  const mkTags = (encrypt, chatmode) => {
2917
2911
  const enc = encrypt ? '密文' : '明文';
2918
- const mode = chatmode === 'paactive' ? 'PA' : chatmode === 'proactive' ? '自主' : '响应';
2912
+ const mode = chatmode === 'proactive' ? '自主' : '响应';
2919
2913
  return `${MAGENTA}[${enc}|${mode}]${RST}`;
2920
2914
  };
2921
2915
  let msgPreview = '';
@@ -3315,6 +3309,12 @@ function renderEcwebStatus(status) {
3315
3309
  console.log(` 命令行输入 ${MAIN_CLI_BIN} watch web/${WEB_CLI_BIN} 获取配对码`);
3316
3310
  }
3317
3311
  }
3312
+ else if (status.startupState === 'waiting') {
3313
+ console.log('🔭 ECWeb: 等待优先恢复组放行,将与空闲 Agent 一起启动');
3314
+ }
3315
+ else if (status.startupState === 'starting' && status.status !== 'process-not-ready') {
3316
+ console.log('🔭 ECWeb: 正在启动,等待健康检查');
3317
+ }
3318
3318
  else if (status.status === 'process-not-ready') {
3319
3319
  if (status.reason === 'daemon-not-ready') {
3320
3320
  const detail = status.readinessError ? `:${status.readinessError}` : '';
@@ -3364,37 +3364,6 @@ async function stopStartedEcweb(pid, expectedStartedAt) {
3364
3364
  return false;
3365
3365
  return platform.waitForProcessExit(pid, 5_000);
3366
3366
  }
3367
- /** 清理 EvolCore 登记的 codex app-server 孤儿进程,返回清理的进程数。 */
3368
- export function stopCodexAppServerOrphans() {
3369
- const entries = listCodexAppServerProcesses();
3370
- if (entries.length === 0)
3371
- return 0;
3372
- const codexProcs = new Set(platform.findProcesses('codex app-server'));
3373
- let killed = 0;
3374
- for (const entry of entries) {
3375
- const { pid, startedAt } = entry.record;
3376
- if (!platform.isProcessRunning(pid)) {
3377
- unregisterCodexAppServerProcess(entry.filePath);
3378
- continue;
3379
- }
3380
- // PID 复用时丢弃登记,不发送信号;命令行探测失败则保留登记,等待下次重试。
3381
- const actualStartedAt = getProcessStartTime(pid);
3382
- if (!startTimeMatches(startedAt, actualStartedAt)) {
3383
- unregisterCodexAppServerProcess(entry.filePath);
3384
- continue;
3385
- }
3386
- if (!codexProcs.has(pid))
3387
- continue;
3388
- try {
3389
- if (platform.killProcess(pid, true)) {
3390
- killed++;
3391
- unregisterCodexAppServerProcess(entry.filePath);
3392
- }
3393
- }
3394
- catch { }
3395
- }
3396
- return killed;
3397
- }
3398
3367
  /** Stop managed ECWeb, including verified listeners without instance records. */
3399
3368
  async function stopManagedEcweb(p) {
3400
3369
  try {
@@ -0,0 +1,61 @@
1
+ import { ipcQuery } from '../ipc.js';
2
+ import * as platform from '../utils/cross-platform.js';
3
+ import { getProcessStartTime, startTimeMatches } from '../utils/process-introspect.js';
4
+ import { listCodexAppServerProcesses, unregisterCodexAppServerProcess } from '../agents/codex/app-server-registry.js';
5
+ // A busy Windows named pipe may need several seconds to accept a connection.
6
+ export const DAEMON_PROBE_TIMEOUT_MS = platform.isWindows ? 5_000 : 1_000;
7
+ export const DAEMON_SHUTDOWN_TIMEOUT_MS = platform.isWindows ? 10_000 : 3_000;
8
+ export async function probeDaemon(socketPath, timeoutMs = DAEMON_PROBE_TIMEOUT_MS, throwOnError = false) {
9
+ const response = await ipcQuery(socketPath, { type: 'ping' }, timeoutMs, { throwOnError });
10
+ if (response?.pong !== true || !Number.isInteger(response.pid) || response.pid <= 0)
11
+ return null;
12
+ return response;
13
+ }
14
+ /** Ask the verified daemon to run its own graceful shutdown lifecycle. */
15
+ export async function requestDaemonShutdown(socketPath, timeoutMs = DAEMON_SHUTDOWN_TIMEOUT_MS, reason = 'cli', expectedPids, traceId) {
16
+ const daemon = await probeDaemon(socketPath, Math.min(timeoutMs, DAEMON_PROBE_TIMEOUT_MS));
17
+ if (!daemon || (expectedPids && !expectedPids.has(daemon.pid)))
18
+ return null;
19
+ const response = await ipcQuery(socketPath, {
20
+ type: 'shutdown',
21
+ reason,
22
+ expectedPid: daemon.pid,
23
+ ...(traceId ? { traceId } : {}),
24
+ }, timeoutMs);
25
+ if (response?.ok !== true || response.accepted !== true
26
+ || !Number.isInteger(response.pid) || response.pid <= 0
27
+ || response.pid !== daemon.pid)
28
+ return null;
29
+ return response.pid;
30
+ }
31
+ /** Clean up only registered, identity-verified EvolCore Codex app-server children. */
32
+ export function stopCodexAppServerOrphans() {
33
+ const entries = listCodexAppServerProcesses();
34
+ if (entries.length === 0)
35
+ return 0;
36
+ const codexProcs = new Set(platform.findProcesses('codex app-server'));
37
+ let killed = 0;
38
+ for (const entry of entries) {
39
+ const { pid, startedAt } = entry.record;
40
+ if (!platform.isProcessRunning(pid)) {
41
+ unregisterCodexAppServerProcess(entry.filePath);
42
+ continue;
43
+ }
44
+ // Discard reused PIDs without signalling; retain unverified commands to retry.
45
+ const actualStartedAt = getProcessStartTime(pid);
46
+ if (!startTimeMatches(startedAt, actualStartedAt)) {
47
+ unregisterCodexAppServerProcess(entry.filePath);
48
+ continue;
49
+ }
50
+ if (!codexProcs.has(pid))
51
+ continue;
52
+ try {
53
+ if (platform.killProcess(pid, true)) {
54
+ killed++;
55
+ unregisterCodexAppServerProcess(entry.filePath);
56
+ }
57
+ }
58
+ catch { }
59
+ }
60
+ return killed;
61
+ }
@@ -83,6 +83,11 @@ export function parseGatewayArgs(args) {
83
83
  continue;
84
84
  }
85
85
  if (PASSTHROUGH_VALUE_FLAGS.has(flag)) {
86
+ // `--self` 是 `--from` 的历史别名,已从网关移除:本端只由 `--from` 表达。
87
+ // 显式拒绝而不是透传——透传会被下游当成未知选项,或更糟:被当成正文。
88
+ if (flag === '--self') {
89
+ return { ok: false, error: '--self 已不再支持;本端请用 --from <本端AID>' };
90
+ }
86
91
  const value = args[++index];
87
92
  if (value === undefined)
88
93
  return { ok: false, error: `${token} 需要一个值` };
@@ -133,13 +138,19 @@ function looksLikeAid(value) {
133
138
  }
134
139
  export function buildDownstreamArgv(route, text, passthrough) {
135
140
  const scope = route.peer.peerKind === 'group' ? 'group' : 'msg';
141
+ // 收件人:私聊自发时是本端,否则是话题对端。用 route.peer.id 会把自发消息
142
+ // 实际投给话题对端(下游按位置参数认目标,--thread 只决定落点会话)。
143
+ // 群发送恒以群 AID 为目标,自发不适用于群。
144
+ const targetId = scope === 'group' ? route.peer.id : route.recipientId;
136
145
  // 目标为原生 ID 时必须靠 --thread 推导,写成位置参数会变成正文的一部分。
137
- const targetAsPositional = looksLikeAid(route.peer.id)
146
+ const targetAsPositional = looksLikeAid(targetId)
138
147
  || (route.peer.peerKind === 'group' && !route.crossTopic);
139
148
  const argv = targetAsPositional
140
- ? [scope, 'send', route.self, route.peer.id, ...text, ...passthrough]
149
+ ? [scope, 'send', route.self, targetId, ...text, ...passthrough]
141
150
  : [scope, 'send', route.self, ...text, ...passthrough];
142
- if (route.crossTopic && route.threadId) {
151
+ // 首次联系:主话题还没被创建,带上 --thread 反而会被下游判成"话题不存在",
152
+ // 所以按普通私聊发出,会话随这条消息建立,也就不建复查。
153
+ if (route.crossTopic && route.threadId && !route.firstContact) {
143
154
  argv.push('--thread', route.threadId);
144
155
  if (route.checkEveryMs)
145
156
  argv.push('--check-every', formatDuration(route.checkEveryMs));
@@ -147,6 +158,30 @@ export function buildDownstreamArgv(route, text, passthrough) {
147
158
  argv.push(route.encryptResolved ? '--encrypt' : '--no-encrypt');
148
159
  return argv;
149
160
  }
161
+ /**
162
+ * 群 AID 的 base 简写展开(`g-18127` → `g-18127.agentid.cn`)。
163
+ *
164
+ * 网关必须在构造路由**之前**完成这一步:`--to g-18127` 若不展开,既判不出它是群
165
+ * (类型解析拿不到证据),也拼不出主话题 id,会直接 `TOPIC_REQUIRED`。
166
+ *
167
+ * 只处理裸 base:已含 issuer 的值原样返回,私聊 AID 不受影响。
168
+ * issuer 取本端 AID 的域,与 `ec group send` / 托管 group 操作的调用口径一致。
169
+ * 展开失败(非群 AID 形态)时同样原样返回,交给后续判定按私聊处理。
170
+ */
171
+ export function expandGroupBase(selfAid, value, normalizeGroupAid) {
172
+ const id = String(value ?? '').trim().replace(/^@/, '');
173
+ if (!id || id.includes('.'))
174
+ return id;
175
+ const issuer = String(selfAid ?? '').split('.').slice(1).join('.');
176
+ if (!issuer)
177
+ return id;
178
+ try {
179
+ return normalizeGroupAid?.(id, issuer) ?? id;
180
+ }
181
+ catch {
182
+ return id;
183
+ }
184
+ }
150
185
  /**
151
186
  * 校验 `--thread` 是否需要在本地索引里查表。
152
187
  *
@@ -0,0 +1,73 @@
1
+ /**
2
+ * `ec events` CLI:事件中心运维(status / ledger / tail / doctor / reload / allowlist / publish)。
3
+ * daemon-control 风格:读本地 control token,经 events.op 转发,daemon 解析执行。
4
+ */
5
+ import fs from 'node:fs';
6
+ import { ipcQuery } from '../ipc.js';
7
+ import { resolvePaths } from '../paths.js';
8
+ const HELP = `ec events — 事件中心运维
9
+
10
+ 用法:
11
+ ec events status [<包名>] [--aid <aid>] 每包状态
12
+ ec events ledger <包名> [--tail N] 台账
13
+ ec events tail <包名> [--tail N] 事件日志
14
+ ec events doctor <包名> 诊断
15
+ ec events reload [<包名>] 重载(重新扫描目录并重建订阅)
16
+ ec events allowlist add <事件> --publish <aid> [--subscribe <aid>]
17
+ ec events allowlist remove <事件> --publish <aid> [--subscribe <aid>]
18
+ ec events allowlist show [--event <事件>]
19
+ ec events publish <包名> <事件> --data '<json>' [--ttl <秒>]
20
+
21
+ 事件是 TTL 内的在线通知:不落库、不重放。详见 $KITS_DOCS/evolcore/event-center.md`;
22
+ function readControlToken() {
23
+ try {
24
+ return fs.readFileSync(resolvePaths().controlToken, 'utf8').trim() || undefined;
25
+ }
26
+ catch {
27
+ return undefined;
28
+ }
29
+ }
30
+ async function queryEvents(argv) {
31
+ const controlToken = readControlToken();
32
+ try {
33
+ const response = await ipcQuery(resolvePaths().socket, { type: 'events.op', argv, controlToken }, 20_000, { throwOnError: false });
34
+ if (!response || typeof response !== 'object')
35
+ return { transportError: 'invalid daemon response' };
36
+ return { response };
37
+ }
38
+ catch (error) {
39
+ return { transportError: error instanceof Error ? error.message : String(error) };
40
+ }
41
+ }
42
+ function printResult(result, json) {
43
+ if (json) {
44
+ console.log(JSON.stringify(result, null, 2));
45
+ return;
46
+ }
47
+ if (result && typeof result === 'object') {
48
+ console.log(JSON.stringify(result, null, 2));
49
+ return;
50
+ }
51
+ console.log(String(result));
52
+ }
53
+ export async function runEventsCommand(argv) {
54
+ const args = [...argv];
55
+ const json = args.includes('--json');
56
+ if (args.length === 0 || args[0] === 'help' || args[0] === '--help') {
57
+ console.log(HELP);
58
+ return;
59
+ }
60
+ const query = await queryEvents(args);
61
+ if ('transportError' in query) {
62
+ console.error(`daemon 不可达:${query.transportError}`);
63
+ process.exitCode = 1;
64
+ return;
65
+ }
66
+ const { response } = query;
67
+ if (!response.ok) {
68
+ console.error(`${response.code ?? 'ERROR'}: ${response.error ?? 'unknown error'}`);
69
+ process.exitCode = 1;
70
+ return;
71
+ }
72
+ printResult(response.result, json);
73
+ }
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 技能管理:加载、安装、启停与索引刷新
@@ -321,7 +323,7 @@ export async function main(args) {
321
323
  process.exitCode = 1;
322
324
  break;
323
325
  }
324
- await cmdStart({
326
+ await (await import('./daemon-commands.js')).cmdStart({
325
327
  diagnose: strippedArgs.includes('--diagnose') || strippedArgs.includes('-d'),
326
328
  foreground: strippedArgs.includes('--foreground'),
327
329
  debug: strippedArgs.includes('--debug'),
@@ -338,7 +340,7 @@ export async function main(args) {
338
340
  process.exitCode = 1;
339
341
  break;
340
342
  }
341
- await cmdStop();
343
+ await (await import('./daemon-commands.js')).cmdStop();
342
344
  break;
343
345
  case 'restart':
344
346
  if (wantsHelp(strippedArgs.slice(1))) {
@@ -349,7 +351,7 @@ export async function main(args) {
349
351
  process.exitCode = 1;
350
352
  break;
351
353
  }
352
- await cmdRestart({ clear: strippedArgs.includes('--clear'), diagnose: strippedArgs.includes('--diagnose') || strippedArgs.includes('-d') });
354
+ await (await import('./daemon-commands.js')).cmdRestart({ clear: strippedArgs.includes('--clear'), diagnose: strippedArgs.includes('--diagnose') || strippedArgs.includes('-d') });
353
355
  break;
354
356
  case 'upgrade':
355
357
  case 'update': {
@@ -400,10 +402,10 @@ export async function main(args) {
400
402
  process.exitCode = 1;
401
403
  break;
402
404
  }
403
- await cmdStatus({ format });
405
+ await (await import('./daemon-commands.js')).cmdStatus({ format });
404
406
  }
405
407
  else {
406
- await cmdStatus({ format });
408
+ await (await import('./daemon-commands.js')).cmdStatus({ format });
407
409
  }
408
410
  }
409
411
  break;
@@ -412,14 +414,14 @@ export async function main(args) {
412
414
  printLifecycleHelp('logs');
413
415
  break;
414
416
  }
415
- await cmdLogs(strippedArgs.slice(1));
417
+ await (await import('./daemon-commands.js')).cmdLogs(strippedArgs.slice(1));
416
418
  break;
417
419
  case 'watch':
418
420
  if (wantsHelp(strippedArgs.slice(1))) {
419
421
  printLifecycleHelp('watch');
420
422
  break;
421
423
  }
422
- await cmdWatchCommand(strippedArgs.slice(1));
424
+ await (await import('./daemon-commands.js')).cmdWatchCommand(strippedArgs.slice(1));
423
425
  break;
424
426
  case 'restart-monitor':
425
427
  if (wantsHelp(strippedArgs.slice(1))) {
@@ -448,14 +450,14 @@ export async function main(args) {
448
450
  printLifecycleHelp('mv');
449
451
  break;
450
452
  }
451
- await cmdMv(strippedArgs[1], strippedArgs[2]);
453
+ await (await import('./daemon-commands.js')).cmdMv(strippedArgs[1], strippedArgs[2]);
452
454
  break;
453
455
  case 'diagnose':
454
456
  if (wantsHelp(strippedArgs.slice(1))) {
455
457
  printLifecycleHelp('diagnose');
456
458
  break;
457
459
  }
458
- await cmdDiagnose(strippedArgs.slice(1));
460
+ await (await import('./daemon-commands.js')).cmdDiagnose(strippedArgs.slice(1));
459
461
  break;
460
462
  case 'data': {
461
463
  const { cmdData } = await import('./data-command.js');
@@ -580,6 +582,16 @@ export async function main(args) {
580
582
  await runThreadCommand(strippedArgs.slice(1));
581
583
  break;
582
584
  }
585
+ case 'events': {
586
+ const { runEventsCommand } = await import('./events-command.js');
587
+ await runEventsCommand(strippedArgs.slice(1));
588
+ break;
589
+ }
590
+ case 'services': {
591
+ const { runServicesCommand } = await import('./services-command.js');
592
+ await runServicesCommand(strippedArgs.slice(1));
593
+ break;
594
+ }
583
595
  case 'session': {
584
596
  const { runSessionCommand } = await import('./session-command.js');
585
597
  await runSessionCommand(strippedArgs.slice(1));
@@ -606,9 +618,9 @@ export async function main(args) {
606
618
  await cmdSkill(strippedArgs.slice(1));
607
619
  break;
608
620
  }
609
- case 'pa-workspace': {
610
- const { cmdPaWorkspace } = await import('./pa-workspace-command.js');
611
- await cmdPaWorkspace(strippedArgs.slice(1));
621
+ case 'team': {
622
+ const { cmdTeamWorkspace } = await import('./team-workspace-command.js');
623
+ await cmdTeamWorkspace(strippedArgs.slice(1));
612
624
  break;
613
625
  }
614
626
  case 'response': {
@@ -621,6 +633,11 @@ export async function main(args) {
621
633
  await cmdProvider(strippedArgs.slice(1));
622
634
  break;
623
635
  }
636
+ case 'invoke': {
637
+ const { cmdInvoke } = await import('./invoke-command.js');
638
+ await cmdInvoke(strippedArgs.slice(1));
639
+ break;
640
+ }
624
641
  case 'ability': {
625
642
  const { cmdAbility } = await import('./ability-command.js');
626
643
  await cmdAbility(strippedArgs.slice(1));