evolcore 0.0.49 → 0.0.51

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 (514) hide show
  1. package/CHANGELOG.md +103 -3
  2. package/bin/ec-build.mjs +60 -0
  3. package/bin/ecmsg.js +64 -57
  4. package/dist/ability/caller/authorization.js +21 -0
  5. package/dist/ability/caller/command.js +173 -0
  6. package/dist/ability/caller/contract.js +117 -0
  7. package/dist/ability/caller/credential-files.js +132 -0
  8. package/dist/ability/caller/daemon.js +183 -0
  9. package/dist/ability/caller/schema-view.js +157 -0
  10. package/dist/ability/caller/service.js +519 -0
  11. package/dist/ability/command-contract.js +5 -0
  12. package/dist/ability/daemon.js +5 -1
  13. package/dist/ability/interop-v1.js +156 -106
  14. package/dist/ability/management.js +1 -0
  15. package/dist/agent-template/jobs.js +79 -3
  16. package/dist/agent-template/runtime.js +459 -47
  17. package/dist/agent-template/service.js +1242 -198
  18. package/dist/agent-template/share.js +103 -0
  19. package/dist/agent-template/tool-runner.js +25 -0
  20. package/dist/agent-template/types.js +10 -2
  21. package/dist/agents/claude/availability.js +94 -0
  22. package/dist/agents/claude/capability-provider.js +154 -0
  23. package/dist/agents/claude/index.js +145 -0
  24. package/dist/agents/{claude-runner.js → claude/runner.js} +78 -166
  25. package/dist/agents/claude/session-file-adapter.js +246 -0
  26. package/dist/agents/codex/app-server-client.js +90 -10
  27. package/dist/agents/codex/availability.js +164 -0
  28. package/dist/agents/codex/capability-provider.js +138 -0
  29. package/dist/agents/codex/cli.js +38 -0
  30. package/dist/agents/codex/index.js +345 -0
  31. package/dist/agents/codex/mcp-elicitation.js +135 -0
  32. package/dist/agents/{codex-runner.js → codex/runner.js} +652 -383
  33. package/dist/agents/codex/session-file-adapter.js +834 -0
  34. package/dist/agents/dsh/availability.js +28 -0
  35. package/dist/agents/dsh/capability-provider.js +56 -0
  36. package/dist/agents/dsh/desktop-locations.ps1 +66 -0
  37. package/dist/agents/dsh/desktop-probe.cjs +37 -0
  38. package/dist/agents/dsh/index.js +98 -0
  39. package/dist/agents/dsh/installation.js +400 -0
  40. package/dist/agents/dsh/resources.js +755 -0
  41. package/dist/agents/dsh/runner.js +1183 -0
  42. package/dist/agents/dsh/runtime/README.md +243 -0
  43. package/dist/agents/dsh/runtime/authorization.js +23 -0
  44. package/dist/agents/dsh/runtime/bridge.js +837 -0
  45. package/dist/agents/dsh/runtime/config.js +271 -0
  46. package/dist/agents/dsh/runtime/entry.js +229 -0
  47. package/dist/agents/dsh/runtime/session-inspector.js +340 -0
  48. package/dist/agents/dsh/runtime/tool-policy.js +49 -0
  49. package/dist/agents/dsh/session-file-adapter.js +145 -0
  50. package/dist/agents/ecagent/index.js +215 -0
  51. package/dist/agents/{ecagent-runner.js → ecagent/runner.js} +592 -106
  52. package/dist/agents/ecagent/session-file-adapter.js +134 -0
  53. package/dist/agents/gemini/index.js +96 -0
  54. package/dist/agents/{gemini-runner.js → gemini/runner.js} +18 -23
  55. package/dist/{core/session/adapters/gemini-session-file-adapter.js → agents/gemini/session-file-adapter.js} +2 -2
  56. package/dist/aun/ability-device-routing.js +11 -17
  57. package/dist/aun/aid/agentmd.js +27 -1
  58. package/dist/aun/aid/control-aid.js +52 -32
  59. package/dist/aun/aid/managed-operation.js +6 -4
  60. package/dist/aun/group/invite-service.js +7 -37
  61. package/dist/aun/group/operations.js +6 -0
  62. package/dist/aun/menu/client.js +1 -1
  63. package/dist/aun/msg/history.js +1 -1
  64. package/dist/aun/msg/managed-operation.js +93 -21
  65. package/dist/aun/msg/mention-schema.js +1 -1
  66. package/dist/aun/msg/p2p.js +32 -4
  67. package/dist/aun/msg/upload.js +126 -3
  68. package/dist/aun/service-proxy.js +1 -1
  69. package/dist/aun/storage/index.js +242 -0
  70. package/dist/build-identity.json +1 -1
  71. package/dist/channels/aun.js +698 -213
  72. package/dist/channels/daemon.js +3 -2
  73. package/dist/channels/dingtalk.js +1 -1
  74. package/dist/channels/feishu.js +9 -9
  75. package/dist/channels/qqbot.js +1 -1
  76. package/dist/channels/wechat.js +2 -2
  77. package/dist/channels/wecom.js +1 -1
  78. package/dist/claude-gateway/agent-registration.js +389 -0
  79. package/dist/claude-gateway/binding.js +96 -0
  80. package/dist/claude-gateway/inbox.js +138 -0
  81. package/dist/claude-gateway/index.js +125 -0
  82. package/dist/claude-gateway/listing.js +330 -0
  83. package/dist/claude-gateway/router.js +328 -0
  84. package/dist/claude-gateway/sessions.js +128 -0
  85. package/dist/claude-gateway/terminal.js +250 -0
  86. package/dist/claude-gateway/transcript.js +272 -0
  87. package/dist/claude-gateway/types.js +14 -0
  88. package/dist/cli/ability-command.js +45 -0
  89. package/dist/cli/ability-output.js +182 -0
  90. package/dist/cli/agent-command.js +21 -2
  91. package/dist/cli/agent-create.js +197 -56
  92. package/dist/cli/agent-template.js +400 -27
  93. package/dist/cli/agent.js +105 -11
  94. package/dist/cli/aun-commands.js +237 -123
  95. package/dist/cli/bench.js +5 -2
  96. package/dist/cli/config.js +22 -6
  97. package/dist/cli/daemon-commands.js +283 -109
  98. package/dist/cli/data-command.js +1 -1
  99. package/dist/cli/debug-mode.js +9 -0
  100. package/dist/cli/directory.js +1 -2
  101. package/dist/cli/ecmsg-gateway.js +64 -26
  102. package/dist/cli/fs-command.js +67 -39
  103. package/dist/cli/index.js +45 -12
  104. package/dist/cli/init.js +161 -90
  105. package/dist/cli/managed-command-guard.js +3 -0
  106. package/dist/cli/menu-client.js +32 -7
  107. package/dist/cli/model.js +1 -1
  108. package/dist/cli/pay-command.js +30 -0
  109. package/dist/cli/provider-command.js +6 -2
  110. package/dist/cli/restart-monitor.js +4 -4
  111. package/dist/cli/services-command.js +35 -10
  112. package/dist/cli/skill-command.js +4 -4
  113. package/dist/cli/task-context.js +24 -14
  114. package/dist/cli/team-workspace-command.js +50 -52
  115. package/dist/cli/thread-command.js +81 -14
  116. package/dist/cli/trigger-command.js +47 -12
  117. package/dist/cli/watch-logs.js +2 -1
  118. package/dist/config/access-policy.js +16 -3
  119. package/dist/config/boot-log.js +3 -0
  120. package/dist/config/builtin-role-templates.js +1 -1
  121. package/dist/config/config-field-policy.js +26 -13
  122. package/dist/config/config-manager.js +113 -52
  123. package/dist/config/config-operation-service.js +22 -1
  124. package/dist/config/gateway-config.js +29 -44
  125. package/dist/config/invoke-ipc-service.js +1 -1
  126. package/dist/config/owner-config.js +5 -19
  127. package/dist/config/peer-book-store.js +2 -3
  128. package/dist/config/peer-book.js +2 -2
  129. package/dist/config/peer-role-resolver.js +3 -9
  130. package/dist/config/provider-identity-migration.js +24 -105
  131. package/dist/config/provider-ipc-service.js +13 -3
  132. package/dist/config/provider-local-sync.js +4 -1
  133. package/dist/config/provider-menu-request.js +21 -3
  134. package/dist/config/provider-templates.js +1 -1
  135. package/dist/config/providers-config.js +138 -31
  136. package/dist/config/providers-import.js +3 -3
  137. package/dist/config/providers-management.js +109 -118
  138. package/dist/config/resolved-config-op.js +1 -42
  139. package/dist/config/schema-migration.js +254 -15
  140. package/dist/config/schema-registry.js +53 -8
  141. package/dist/config-store.js +1343 -63
  142. package/dist/core/{agent-application-service.js → agent/agent-application-service.js} +228 -9
  143. package/dist/core/{agent-create-status.js → agent/agent-create-status.js} +112 -4
  144. package/dist/core/{agent-creation-claim.js → agent/agent-creation-claim.js} +3 -3
  145. package/dist/core/{agent-ipc-registration.js → agent/agent-ipc-registration.js} +119 -25
  146. package/dist/core/{agent-reload-coordinator.js → agent/agent-reload-coordinator.js} +65 -0
  147. package/dist/core/{agent-runtime.js → agent/agent-runtime.js} +249 -79
  148. package/dist/core/{evolagent-registry.js → agent/evolagent-registry.js} +23 -18
  149. package/dist/core/{evolagent.js → agent/evolagent.js} +11 -11
  150. package/dist/core/auth/agent-delegation.js +15 -8
  151. package/dist/core/auth/delegation-authorization.js +28 -0
  152. package/dist/core/auth/operation-authorizer.js +20 -2
  153. package/dist/core/auth/operation-catalog.js +80 -8
  154. package/dist/core/baseagent/baseagent-availability.js +197 -0
  155. package/dist/core/baseagent/baseagent-capability-adapter.js +288 -0
  156. package/dist/core/baseagent/baseagent-config-shared.js +56 -0
  157. package/dist/core/baseagent/baseagent-identity.js +68 -0
  158. package/dist/core/{baseagent-loader.js → baseagent/baseagent-loader.js} +89 -6
  159. package/dist/core/baseagent/baseagent-model-defaults.js +26 -0
  160. package/dist/core/baseagent/baseagent-plugin-descriptor.js +357 -0
  161. package/dist/core/baseagent/baseagent-plugin-loader.js +367 -0
  162. package/dist/core/baseagent/baseagent.js +157 -0
  163. package/dist/{agents → core/baseagent}/runner-types.js +36 -4
  164. package/dist/core/capability/capability-manager.js +91 -33
  165. package/dist/core/capability/providers/claude-capability-provider.js +2 -154
  166. package/dist/core/capability/providers/codex-capability-provider.js +2 -136
  167. package/dist/core/{channel-loader.js → channel/channel-loader.js} +226 -38
  168. package/dist/core/{channel-runtime.js → channel/channel-runtime.js} +21 -19
  169. package/dist/core/command/agent-control.js +80 -17
  170. package/dist/core/command/agent-template-menu.js +23 -10
  171. package/dist/core/command/agentmd-menu-request.js +19 -8
  172. package/dist/core/command/agentmd-menu.js +14 -5
  173. package/dist/core/command/cli-intent-parser.js +15 -0
  174. package/dist/core/command/command-handler.js +127 -57
  175. package/dist/core/command/context-policy-menu.js +122 -0
  176. package/dist/core/command/data-root-resolver.js +157 -20
  177. package/dist/core/command/memory-slash.js +6 -6
  178. package/dist/core/command/menu-catalog.js +95 -19
  179. package/dist/core/command/menu-file-path.js +70 -0
  180. package/dist/core/command/menu-handler.js +392 -93
  181. package/dist/core/command/menu-protocol.js +47 -8
  182. package/dist/core/command/menu-query-batch.js +9 -5
  183. package/dist/core/command/private-mention-menu.js +71 -0
  184. package/dist/core/command/provider-menu.js +7 -11
  185. package/dist/core/command/role-menu.js +1 -1
  186. package/dist/core/command/skill-slash.js +17 -5
  187. package/dist/core/command/slash-gate.js +2 -4
  188. package/dist/core/command/slash-handler.js +143 -121
  189. package/dist/core/command/team-workspace-bootstrap.js +2 -1
  190. package/dist/core/command/team-workspace-team.js +3 -3
  191. package/dist/core/command/topic-slash.js +16 -10
  192. package/dist/core/{daemon-bootstrap.js → daemon/daemon-bootstrap.js} +14 -18
  193. package/dist/core/{daemon-control.js → daemon/daemon-control.js} +48 -21
  194. package/dist/core/{daemon-lifecycle.js → daemon/daemon-lifecycle.js} +28 -20
  195. package/dist/core/{host-snapshot.js → daemon/host-snapshot.js} +10 -5
  196. package/dist/core/{ipc-registration.js → daemon/ipc-registration.js} +101 -37
  197. package/dist/core/{lifecycle-notice.js → daemon/lifecycle-notice.js} +4 -5
  198. package/dist/core/file-integrity/store.js +1 -1
  199. package/dist/core/handoff/ipc-registration.js +3 -3
  200. package/dist/core/handoff/runtime.js +2 -2
  201. package/dist/{agents → core/inference}/request-identity.js +2 -2
  202. package/dist/core/inference/text-inference.js +4 -4
  203. package/dist/core/{bootstrap-messages.js → initialization/bootstrap-messages.js} +10 -10
  204. package/dist/core/{bootstrap-service.js → initialization/bootstrap-service.js} +24 -23
  205. package/dist/core/initialization/service.js +57 -9
  206. package/dist/core/invoke/executors/media.js +1 -1
  207. package/dist/core/invoke/executors/text.js +1 -1
  208. package/dist/core/memory/consolidation-context.js +3 -2
  209. package/dist/core/memory/consolidation-trigger.js +9 -3
  210. package/dist/core/memory/consolidation.js +39 -68
  211. package/dist/core/memory/memory-admin.js +6 -6
  212. package/dist/core/memory/memory-writer.js +1 -1
  213. package/dist/core/memory/relation-idle-monitor.js +1 -1
  214. package/dist/core/message/aun-ipc-sender.js +204 -88
  215. package/dist/core/message/aun-request-registry.js +44 -5
  216. package/dist/core/message/auto-mention-gate.js +1 -1
  217. package/dist/core/message/contact-admission.js +1 -1
  218. package/dist/core/message/im-renderer.js +19 -0
  219. package/dist/core/{interaction-router.js → message/interaction-router.js} +131 -1
  220. package/dist/core/message/items-formatter.js +5 -5
  221. package/dist/core/message/message-admission.js +1 -1
  222. package/dist/core/message/message-bridge.js +239 -59
  223. package/dist/core/message/message-log.js +8 -0
  224. package/dist/core/message/message-queue.js +88 -7
  225. package/dist/core/message/message-utils.js +1 -1
  226. package/dist/core/message/peer-mode.js +16 -5
  227. package/dist/core/message/response-engine.js +351 -152
  228. package/dist/core/message/send-options.js +44 -7
  229. package/dist/core/message/send-routing.js +55 -115
  230. package/dist/core/message/stream-idle-monitor.js +1 -1
  231. package/dist/core/{data-migration.js → migration/data-migration.js} +29 -1
  232. package/dist/core/model/catalog-service.js +29 -8
  233. package/dist/core/model/model-capabilities.js +88 -0
  234. package/dist/core/model/model-catalog.js +18 -7
  235. package/dist/core/model/model-diagnostics.js +4 -4
  236. package/dist/core/ownership/owner-resolver.js +107 -101
  237. package/dist/core/{pack-auth.js → pack/pack-auth.js} +34 -3
  238. package/dist/core/{pack-install.js → pack/pack-install.js} +95 -17
  239. package/dist/core/permission/approval-gateway.js +9 -18
  240. package/dist/core/permission/ec-command-parser.js +242 -82
  241. package/dist/core/permission/managed-file.js +234 -0
  242. package/dist/core/permission/protected-paths.js +120 -9
  243. package/dist/core/permission/sandbox-runtime.js +267 -3
  244. package/dist/core/permission/services-path-acl.js +9 -2
  245. package/dist/core/permission/session-path-grants.js +1 -1
  246. package/dist/core/permission/shell-environment.js +15 -1
  247. package/dist/core/permission/tool-policy.js +21 -9
  248. package/dist/core/plugin/plugin-lifecycle.js +442 -0
  249. package/dist/core/session/adapters/claude-session-file-adapter.js +2 -242
  250. package/dist/core/session/adapters/codex-session-file-adapter.js +2 -562
  251. package/dist/core/session/adapters/ecagent-session-file-adapter.js +2 -134
  252. package/dist/core/{background-session → session/background}/session-cleanup.js +2 -2
  253. package/dist/core/{background-session → session/background}/types.js +1 -1
  254. package/dist/core/session/session-file-health.js +2 -272
  255. package/dist/core/session/session-idle-monitor.js +1 -1
  256. package/dist/core/session/session-manager.js +76 -12
  257. package/dist/core/session/session-mapper.js +16 -0
  258. package/dist/core/session/session-terminal.js +185 -0
  259. package/dist/core/session/session-title.js +8 -11
  260. package/dist/core/{system-session → session/system}/memory.js +43 -9
  261. package/dist/core/{system-session → session/system}/registry.js +1 -1
  262. package/dist/core/{system-session → session/system}/types.js +1 -1
  263. package/dist/core/skill/index-generator.js +3 -3
  264. package/dist/core/skill/switch-resolver.js +3 -0
  265. package/dist/core/task/task-activity-store.js +112 -0
  266. package/dist/core/task/task-recovery-service.js +2 -2
  267. package/dist/core/thread/command-parser.js +4 -1
  268. package/dist/core/thread/ipc-operation.js +6 -4
  269. package/dist/core/thread/thread-operation.js +27 -11
  270. package/dist/core/thread/thread-route.js +5 -3
  271. package/dist/core/thread/thread-service.js +307 -58
  272. package/dist/core/thread/topic-id.js +52 -2
  273. package/dist/core/thread/types.js +15 -1
  274. package/dist/directory/{owner-directory-admission.js → admission.js} +3 -3
  275. package/dist/directory/{owner-directory-cache.js → cache.js} +90 -8
  276. package/dist/directory/{owner-directory-markdown.js → markdown.js} +2 -2
  277. package/dist/directory/{owner-directory-query-operation.js → query-operation.js} +83 -9
  278. package/dist/directory/{owner-directory-search.js → search.js} +50 -2
  279. package/dist/directory/{owner-directory-store.js → store.js} +2 -2
  280. package/dist/eck/kit-renderer.js +3 -2
  281. package/dist/eck/manifest-engine.js +64 -2
  282. package/dist/eck/message-renderer.js +35 -0
  283. package/dist/ecweb/basic-settings-service.js +12 -10
  284. package/dist/{contracts → ecweb/contracts}/ecweb-service-protocol.js +2 -1
  285. package/dist/ecweb/dsh-native-service.js +413 -0
  286. package/dist/ecweb/providers-service.js +5 -3
  287. package/dist/ecweb/runtime/lifecycle.js +1 -1
  288. package/dist/ecweb/runtime/supervisor.js +1 -1
  289. package/dist/event-center/center-config.js +2 -2
  290. package/dist/event-center/dispatcher.js +1 -1
  291. package/dist/event-center/ipc-operation.js +12 -3
  292. package/dist/event-center/pack-loader.js +2 -2
  293. package/dist/event-center/registry.js +6 -6
  294. package/dist/event-center/runtime.js +2 -2
  295. package/dist/index.js +181 -77
  296. package/dist/ipc.js +161 -12
  297. package/dist/outputs/authorization.js +27 -0
  298. package/dist/outputs/events.js +10 -1
  299. package/dist/outputs/panel-cards.js +960 -0
  300. package/dist/paths.js +60 -1
  301. package/dist/pay/command.js +38 -0
  302. package/dist/pay/protocol.js +136 -0
  303. package/dist/pay/runtime.js +196 -0
  304. package/dist/pay/service.js +384 -0
  305. package/dist/pay/store.js +81 -0
  306. package/dist/response-system/engines/v1/proactive-flow.js +30 -3
  307. package/dist/services/dispatcher.js +25 -7
  308. package/dist/services/host/main.js +397 -0
  309. package/dist/services/host/protocol.js +125 -0
  310. package/dist/services/host/resident.js +347 -0
  311. package/dist/services/host-client.js +398 -0
  312. package/dist/services/host-deploy.js +180 -0
  313. package/dist/services/host-launch.js +117 -0
  314. package/dist/services/host-recycle.js +208 -0
  315. package/dist/services/host-runtime.js +841 -0
  316. package/dist/services/idempotency.js +44 -86
  317. package/dist/services/index-generator.js +4 -3
  318. package/dist/services/index.js +258 -36
  319. package/dist/services/ipc-operation.js +503 -78
  320. package/dist/services/pack-manager.js +2 -2
  321. package/dist/services/router.js +43 -3
  322. package/dist/services/script-runner.js +541 -100
  323. package/dist/services/service-payload.js +28 -1
  324. package/dist/services/validation.js +136 -5
  325. package/dist/stats/context-usage.js +110 -0
  326. package/dist/stats/model-resolver.js +103 -17
  327. package/dist/stats/query.js +5 -0
  328. package/dist/trigger/application-service.js +9 -6
  329. package/dist/trigger/authorization.js +36 -33
  330. package/dist/trigger/ipc-service.js +4 -4
  331. package/dist/trigger/local-files.js +8 -166
  332. package/dist/trigger/manager.js +2 -2
  333. package/dist/trigger/parser.js +48 -0
  334. package/dist/trigger/scheduler.js +35 -13
  335. package/dist/trigger/script-executor.js +21 -0
  336. package/dist/trigger/script-sandbox.js +77 -232
  337. package/dist/trigger/system-definitions.js +25 -0
  338. package/dist/trigger/validation.js +1 -1
  339. package/dist/utils/aid-bind.js +3 -0
  340. package/dist/utils/atomic-write.js +88 -1
  341. package/dist/utils/cross-platform.js +4 -42
  342. package/dist/utils/error-dict.json +22 -1
  343. package/dist/utils/error-utils.js +193 -6
  344. package/dist/utils/evolcore-version.js +2 -2
  345. package/dist/utils/host-info.js +74 -1
  346. package/dist/utils/logger.js +5 -3
  347. package/dist/utils/media-cache.js +284 -42
  348. package/dist/utils/restart-safety.js +14 -1
  349. package/dist/utils/startup-trace.js +20 -4
  350. package/dist/utils/system-memory.js +113 -25
  351. package/dist/utils/systemd-lifecycle.js +154 -0
  352. package/dist/utils/welcome.js +64 -20
  353. package/dist/utils/windows-shell-trust.js +7 -3
  354. package/ecagent/README.md +35 -0
  355. package/ecagent/dist/agent-loop.js +80 -30
  356. package/ecagent/dist/harness/env/nodejs.d.ts +16 -0
  357. package/ecagent/dist/harness/env/nodejs.js +49 -20
  358. package/ecagent/dist/harness/messages.js +3 -2
  359. package/ecagent/dist/harness/types.d.ts +1 -0
  360. package/ecagent/dist/runtime/types.d.ts +2 -0
  361. package/ecagent/dist/runtime/utils/validation.d.ts +7 -1
  362. package/ecagent/dist/runtime/utils/validation.js +42 -0
  363. package/ecagent/dist/types.d.ts +2 -0
  364. package/kits/docs/INDEX.md +3 -2
  365. package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +1 -0
  366. package/kits/docs/channels/aun.md +1 -1
  367. package/kits/docs/channels/feishu.md +1 -1
  368. package/kits/docs/evolcore/INDEX.md +13 -9
  369. package/kits/docs/evolcore/agent-create.md +2 -0
  370. package/kits/docs/evolcore/agent.md +133 -11
  371. package/kits/docs/evolcore/aid.md +39 -6
  372. package/kits/docs/evolcore/config.md +95 -1
  373. package/kits/docs/evolcore/ctl.md +2 -1
  374. package/kits/docs/evolcore/ec-capabilities.md +7 -10
  375. package/kits/docs/evolcore/ecweb-lifecycle.md +5 -1
  376. package/kits/docs/evolcore/event.md +1 -1
  377. package/kits/docs/evolcore/fs.md +49 -3
  378. package/kits/docs/evolcore/group.md +5 -4
  379. package/kits/docs/evolcore/memory-consolidation.md +1 -1
  380. package/kits/docs/evolcore/memory-tags.md +2 -0
  381. package/kits/docs/evolcore/menu-client.md +3 -3
  382. package/kits/docs/evolcore/menu-protocol.md +31 -2
  383. package/kits/docs/evolcore/model.md +12 -1
  384. package/kits/docs/evolcore/msg.md +96 -36
  385. package/kits/docs/evolcore/pay.md +22 -0
  386. package/kits/docs/evolcore/plugin.md +74 -0
  387. package/kits/docs/evolcore/provider.md +29 -2
  388. package/kits/docs/evolcore/rpc.md +2 -2
  389. package/kits/docs/evolcore/services.md +46 -18
  390. package/kits/docs/evolcore/skill.md +17 -1
  391. package/kits/docs/evolcore/stats.md +5 -0
  392. package/kits/docs/evolcore/storage.md +22 -0
  393. package/kits/docs/evolcore/thread-chain.md +20 -9
  394. package/kits/docs/evolcore/tool-authorization.md +14 -0
  395. package/kits/docs/evolcore/trigger.md +89 -13
  396. package/kits/docs/identity/AID_PROFILE_SPEC.md +1 -1
  397. package/kits/docs/venues/feishu-group.md +3 -2
  398. package/kits/docs/venues/feishu-private.md +3 -2
  399. package/kits/rules/01-overview.md +11 -32
  400. package/kits/rules/02-navigation.md +20 -6
  401. package/kits/rules/06-channel.md +20 -4
  402. package/kits/schemas/_meta.json +42 -5
  403. package/kits/schemas/agent-config.schema.21.json +974 -0
  404. package/kits/schemas/agent-config.schema.22.json +977 -0
  405. package/kits/schemas/agent-config.schema.23.json +974 -0
  406. package/kits/schemas/agent-config.schema.24.json +986 -0
  407. package/kits/schemas/agent-config.schema.25.json +986 -0
  408. package/kits/schemas/daemon.schema.10.json +373 -0
  409. package/kits/schemas/daemon.schema.11.json +487 -0
  410. package/kits/schemas/daemon.schema.12.json +505 -0
  411. package/kits/schemas/daemon.schema.9.json +12 -0
  412. package/kits/schemas/defaults.schema.7.json +472 -0
  413. package/kits/schemas/defaults.schema.8.json +484 -0
  414. package/kits/schemas/providers.schema.1.json +1 -1
  415. package/kits/schemas/providers.schema.2.json +1 -1
  416. package/kits/schemas/providers.schema.3.json +26 -4
  417. package/kits/schemas/relation-config.schema.13.json +289 -0
  418. package/kits/skills/.switches.json +17 -1
  419. package/kits/skills/ability/SKILL.md +395 -33
  420. package/kits/skills/ability/STRUCTURE.md +338 -0
  421. package/kits/skills/ability/references/cli.md +208 -0
  422. package/kits/skills/ability/references/development.md +107 -37
  423. package/kits/skills/ability/references/management.md +106 -46
  424. package/kits/skills/ability/references/runtime-protocol.md +65 -63
  425. package/kits/skills/agent-output-cards/SKILL.md +80 -37
  426. package/kits/skills/agent-output-cards/examples/html-surface.json +11 -0
  427. package/kits/skills/agent-output-cards/examples/meeting-followups.json +16 -0
  428. package/kits/skills/agent-output-cards/examples/meeting-latest.json +24 -0
  429. package/kits/skills/agent-output-cards/examples/project-metrics.json +16 -0
  430. package/kits/skills/agent-output-cards/examples/quick-links.json +18 -0
  431. package/kits/skills/agent-output-cards/examples/surface.html +8 -0
  432. package/kits/skills/agent-template-project/SKILL.md +51 -0
  433. package/kits/skills/agent-template-project/references/01-collect-and-pack.md +174 -0
  434. package/kits/skills/agent-template-project/references/02-upload-and-share.md +109 -0
  435. package/kits/skills/agent-template-project/references/03-download-and-install.md +189 -0
  436. package/kits/skills/agent-template-project/references/04-upgrade-and-recovery.md +74 -0
  437. package/kits/skills/agent-template-project/references/05-publish-to-platform.md +62 -0
  438. package/kits/skills/ec-group/SKILL.md +8 -6
  439. package/kits/skills/ec-group/TASK.md +186 -0
  440. package/kits/skills/ec-group/WORKLOG.md +180 -0
  441. package/kits/skills/ec-group-collaboration/SKILL.md +5 -5
  442. package/kits/skills/ec-identity/SKILL.md +9 -6
  443. package/kits/skills/ec-pay/SKILL.md +223 -0
  444. package/kits/skills/ec-provider/SKILL.md +6 -6
  445. package/kits/skills/{ec-service-proxy → ec-proxy}/SKILL.md +8 -5
  446. package/kits/skills/ec-service-call/SKILL.md +138 -0
  447. package/kits/skills/ec-service-pack/SKILL.md +277 -0
  448. package/kits/skills/ec-skill/SKILL.md +25 -9
  449. package/kits/skills/ec-skill/scripts/cli.mjs +7 -7
  450. package/kits/skills/ec-skill/scripts/skill.mjs +55 -41
  451. package/kits/skills/ec-skill/scripts/template/SKILL.md.tmpl +9 -0
  452. package/kits/skills/ec-trigger/SKILL.md +3 -3
  453. package/kits/skills/personal-assistant/SKILL.md +22 -22
  454. package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +1 -1
  455. package/kits/skills/scrapling-article-fetch/SKILL.md +5 -5
  456. package/kits/skills/thread-ops/SKILL.md +19 -9
  457. package/kits/skills/wechat-article-media-download/SKILL.md +2 -2
  458. package/kits/skills/wechat-article-reader/SKILL.md +2 -2
  459. package/kits/templates/memory-consolidation/notes.md +2 -2
  460. package/kits/templates/memory-consolidation/workflow.md +46 -0
  461. package/kits/templates/system-fragments/channel.md +13 -4
  462. package/kits/templates/system-fragments/commands.md +5 -4
  463. package/kits/templates/system-fragments/personal-assistant.md +2 -2
  464. package/kits/templates/system-fragments/reply.md +15 -9
  465. package/kits/templates/system-fragments/session.md +2 -2
  466. package/kits/templates/system-fragments/thread.md +30 -127
  467. package/kits/templates/system-fragments/venue.md +16 -0
  468. package/package.json +7 -7
  469. package/scripts/agent-template/index.mjs +7 -1
  470. package/scripts/agent-template/inspect.mjs +99 -39
  471. package/scripts/agent-template/overlay.mjs +126 -2
  472. package/scripts/agent-template/shared/common.mjs +49 -5
  473. package/scripts/agent-template/shared/plan.mjs +4 -2
  474. package/scripts/agent-template/shared/service-packs.mjs +104 -0
  475. package/scripts/agent-template/shared/team-schema.json +468 -39
  476. package/scripts/agent-template/shared/template-contract.mjs +93 -51
  477. package/scripts/agent-template/shared/template-package.mjs +225 -44
  478. package/scripts/agent-template/shared/template-runtime.mjs +137 -15
  479. package/scripts/agent-template/shared/template.mjs +31 -8
  480. package/scripts/agent-template/team-pack.mjs +528 -56
  481. package/scripts/agent-template/team-preview.mjs +102 -9
  482. package/scripts/aid-batch/identity-batch.mjs +1 -1
  483. package/dist/agents/baseagent-availability.js +0 -152
  484. package/dist/agents/baseagent.js +0 -750
  485. package/dist/agents/codex/catalog.js +0 -80
  486. package/dist/agents/ecagent-plugin-lazy.js +0 -41
  487. package/dist/agents/tool-time-context.js +0 -55
  488. package/dist/core/legacy-rename.js +0 -41
  489. package/dist/core/plugin-lifecycle.js +0 -137
  490. package/dist/core/rate-window.js +0 -53
  491. package/dist/core/runner-reload-transaction.js +0 -60
  492. package/dist/core/runtime-lock.js +0 -90
  493. package/dist/core/soul.js +0 -66
  494. package/dist/core/system-session/grants.js +0 -40
  495. package/dist/directory/owner-directory-agentmd-sync.js +0 -89
  496. package/dist/directory/owner-directory-request-operation.js +0 -79
  497. package/dist/directory/owner-directory-text.js +0 -60
  498. package/kits/docs/aun/ABILITY_CALLING.md +0 -280
  499. package/kits/docs/evolcore/ability.md +0 -185
  500. package/kits/skills/ability/references/calling.md +0 -56
  501. package/kits/skills/ability/references/contract-checklist.md +0 -37
  502. package/kits/skills/ability/references/recovery.md +0 -27
  503. /package/dist/{core/capability/providers/gemini-capability-provider.js → agents/gemini/capability-provider.js} +0 -0
  504. /package/dist/core/{system-channels.js → channel/system-channels.js} +0 -0
  505. /package/dist/core/{daemon-file-cache.js → daemon/daemon-file-cache.js} +0 -0
  506. /package/dist/core/{event-bus.js → event/event-bus.js} +0 -0
  507. /package/dist/core/{event-catalog.js → event/event-catalog.js} +0 -0
  508. /package/dist/core/{pack-ledger.js → pack/pack-ledger.js} +0 -0
  509. /package/dist/directory/{owner-directory-identity.js → identity.js} +0 -0
  510. /package/dist/directory/{owner-directory-policy.js → policy.js} +0 -0
  511. /package/dist/directory/{owner-directory-remarks.js → remarks.js} +0 -0
  512. /package/dist/directory/{owner-directory-scope.js → scope.js} +0 -0
  513. /package/dist/{contracts → ecweb/contracts}/ecweb-instance.js +0 -0
  514. /package/kits/templates/{bootstrap-welcome.md → bootstrap-intro.md} +0 -0
package/CHANGELOG.md CHANGED
@@ -3,7 +3,79 @@
3
3
  本文件记录 EvolCore 的重要变更。EvolClaw 版本线的历史记录已归档至
4
4
  [`docs/_archive/CHANGELOG-evolclaw.md`](docs/_archive/CHANGELOG-evolclaw.md)。
5
5
 
6
- ## Unreleased
6
+ ## 0.0.51 (2026-11-22)
7
+
8
+ ### 基座与上下文
9
+
10
+ - 基座统一由 daemon 插件声明管理,完善安装探测、延迟加载、配置迁移和能力诊断;按必需能力校验接入条件,并按运行环境、模型与验证证据开放选配能力。
11
+ - 新增 DeepSeek Harness(DSH)接入,支持 CLI 与桌面安装发现、原生 Home/Profile 授权、会话绑定与接续、图片输入、推理参数和原生技能;支持完整会话及消息锚点分叉,校验来源与目标绑定并处理失败回滚。
12
+ - 支持按 Agent 配置 Claude、Codex、DSH 的上下文压缩阈值,展示容量来源、有效阈值及历史运行信息;DSH 根据原生上下文压力在输入前触发压缩。
13
+ - 完善 Codex 会话进程隔离、启动超时回收、中断确认、MCP 表单及空表单确认;补齐当前 Agent 附件目录的读取权限。
14
+ - ecagent 支持项目规则、原生技能和消息锚点分叉,完善中断后的工具结果补全;收紧工具授权、Shell 环境和 Linux/Windows 文件隔离,限制只读工具并发与输出长度,禁止执行被截断的工具调用。
15
+ - 移除 /clear;使用 /new 创建新会话并保留旧会话历史。完善会话原生终端入口、运行状态清理及历史读取诊断。
16
+
17
+ ### 消息与成果
18
+
19
+ - ecmsg send 根据话题与模式确定接收方,支持当前话题发送、跨话题委托和跨话题自派;废弃 --to,托管发送禁止 --from,完善参数错误提示和返回结果展示。
20
+ - 修正主话题消息归属、远端能力发现缓存和 IPC 流式中文解码;被打断回合补投已生成正文,完善话题摘要更新时机与重复写入控制。
21
+ - 新增 Owner 面板卡片协议,支持结构化内容、HTML 卡片、资源校验、增量及加密详情查询;成果源文件使用项目 .output 分区,卡片入口由 Owner 管理。
22
+ - 完善远端能力调用的设备路由、参数契约和结果筛选;修复下载直链有效期的秒与毫秒转换及不过期展示。
23
+
24
+ ### 模板与配置
25
+
26
+ - Agent 模板支持按模块采集、编辑副本和组合封包,提供本地导入、命令行预览、定向分享及模板仓库发行查询、发布和下载;完善凭据检查、进度反馈和中断恢复。
27
+ - 模板安装与升级复用目标主机 Provider 绑定,处理平台和模型不匹配,保留显式选择及未就绪状态;部署后补齐新 Agent 初始化和欢迎消息恢复。
28
+ - 首次设定引导与激活欢迎文案分离,欢迎文案根据名片生成;bootstrapWelcome 更名为 enableWelcome,兼容读取旧配置。
29
+ - Provider 标识与连接地址解耦,完善服务独立配置、导入冲突和修订校验;未命名本地 IP 连接采用基座名称,同名时明确报冲突,保留用户指定名称。
30
+ - 旧 daemon/defaults 插件声明迁移先清理废弃 AUN gatewayUrl,再校验和保存,避免合法升级被旧字段阻断。
31
+
32
+ ### 服务与运行
33
+
34
+ - 服务包支持 pack update 和本地调用,完善安装及加载错误、调用参数、沙箱快照与帮助提示;更新时保留运行日志。
35
+ - 完善受管文件、运行锁、Windows 临时目录及工具命令校验;帮助查询和已完成迁移的托管命令避免重复执行启动迁移。
36
+ - 按职责整理内部模块并合并局部辅助逻辑,保留插件加载、独立进程与安全策略边界。
37
+
38
+ ### 兼容要求
39
+
40
+ - 需要 Node.js >=22.16.0,依赖 @agentunion/fastaun ^0.5.42,配套 ec-web@0.0.51。
41
+ - 可选 DSH 接入要求 @deepseek-ai/dsh 0.2.2-rc.5 和 Node.js >=24.9,当前声明支持 Linux、Windows;须先授权原生资源及会话绑定。
42
+ - Gemini 仍存在必需能力缺口,严格模式拒绝接入;强制加载不会补足缺失能力。
43
+ - Invoke 尚未完成,不作为本版可用功能验收,相关测试继续排除。
44
+
45
+ ## 0.0.50 (2026-11-17)
46
+
47
+ ### 能力调用与交互
48
+
49
+ - 新增 ec ability remote list/discover/info/devices/call/result,支持发现主体能力、筛选设备、读取契约、校验参数和加密调用;提供固定计划预览、操作去重及迟到结果查询,区分投递回执与业务完成。
50
+ - 远端能力使用协议专用授权,复用托管委托、共享发送器和请求索引;默认精简分页,支持搜索及按需读取契约和用法,完善参数错误诊断。
51
+ - 新增订单扫码付款卡片及 ec pay,支持微信、支付宝渠道选择、二维码刷新、订单核验和付款后继续任务;新增 WidgetCard HTML 表单交互及关联回复。
52
+ - 新增 Owner 可管理的私聊提及模式,默认关闭;开启后未提及消息仅保留历史,不创建模型回合,与群聊提及策略独立。
53
+
54
+ ### 基座与会话
55
+
56
+ - 新增随包基座插件发现、描述符校验、全局启用开关及运行组件注册回滚;初始化、模型目录、供应商诊断和模板采集使用已发现的基座,Gemini 迁入目录插件结构。
57
+ - 新增本机 Claude Code 会话网关,支持按话题绑定原生会话、投递消息和跟读输出;网关须显式启用。
58
+ - 支持单个及多选 Agent 项目地址迁移,展示分步进度,处理文件冲突、原生会话资源复用、失败回滚及中断恢复。
59
+
60
+ ### 模板与服务
61
+
62
+ - 团队模板支持可选成员、外部联系人声明及安装状态恢复,完善模板标识、内容打包和显式访问配置保留。
63
+ - 单 Agent 模板支持可信来源绑定、更新检查、固定版本预览及 Owner 手动确认执行;失败时回滚并恢复原作业,auto 声明暂不触发自动更新。
64
+ - 服务包新增常驻脚本宿主,完善调用关联、超时、空闲回收、重启退避及降级执行;代理管理、服务调用和建包分别使用对应技能。
65
+
66
+ ### 身份、安全与运行
67
+
68
+ - Owner 仅由 Ownership 2.1 协议共识授予,移除 daemon 与 Agent 配置中的 Owner 授权回退,保留协议来源的只读查询,并迁移旧配置字段。
69
+ - 附件统一归档至 Agent 目录,历史引用使用可迁移别名;修复新旧附件索引按文件名和附件 ID 解析的问题。
70
+ - 修复 Windows 文件校验及普通 Shell 命令误拦截,补齐设备标识签名伴随文件保护,修正 Claude 百万上下文识别,完善 systemd 重启接管和就绪确认。
71
+ - 精简 ECK 注入并收拢 Ability、付款和服务技能文档;完善消息发送参数、来源信息及失败诊断。
72
+
73
+ ### 兼容要求
74
+
75
+ - 需要 Node.js >=22.16.0,固定依赖 @agentunion/fastaun 0.5.38,配套 ec-web@0.0.50。
76
+ - EventService Bus 需要服务端支持会话绑定注册确认;Owner 配置字段不再授予权限。
77
+ - Gemini 插件当前仅声明 Linux 环境,保留 readonly/auto 的现有限制;Windows、macOS 暂不启用该插件,原生 CLI 和 Provider 仍须单独配置。
78
+ - Invoke 尚未完成,不作为本版可用功能验收,相关测试继续跳过。
7
79
 
8
80
  ## 0.0.49 (2026-11-15)
9
81
 
@@ -35,9 +107,37 @@
35
107
 
36
108
  ### 兼容要求
37
109
 
38
- - 需要 Node.js >=22.16.0,依赖 @agentunion/fastaun 0.5.36,配套 ec-web@0.0.49。
110
+ - 需要 Node.js >=22.16.0,依赖 @agentunion/fastaun 0.5.37,配套 ec-web@0.0.49。
39
111
  - 远程终端仅提供非交互单命令执行,不保留跨命令的目录或环境变量状态。
40
112
  - Invoke 尚未完成,本版不将其列为可用功能;相关测试继续跳过。
113
+ ### 远端 Ability 工具
114
+
115
+ - 提示词与 ability skill 明确直接读取精简 JSON,优先用内置搜索/分页,不接 Python/Node/jq 管道;切换能力时重新核对当前参数 Schema,禁止照搬 action。参数 enum/const 报错展示字段及允许值,PARAMS_INVALID 明确 validation、sent=false 和修正参数指引。
116
+ - 远端 Ability 使用协议专用授权,不继承本机插件权限或普通聊天联系人准入准出,不设 Owner/admin/DaemonOwner 门槛;复用 daemon 共享发送器,保留任务/原命令绑定、readonly、契约、加密和 Provider 授权。回包在聊天准入前按原请求核验,未匹配回包不进模型;新增真实策略与传输回归。
117
+ - list/discover 默认精简分页(20项,最多100项),新增搜索与 --full;info 聚焦所选契约、用法及设备。统一位置 path 并兼容 --path,参数错误附正确用法;有效快照及指南复用。同步调整 skill、提示词和文档为按需 info → call,减少重复发现与资料读取。
118
+ - 修复远端发现被 `index.v1` 硬限制的问题:运行时从 well-known 按稳定目录字段读取,保留版本及兼容声明,沿 skill_ref/detail_ref 继续解析;支持 release 内嵌 definition/usage 及发布摘要校验,新增 list --usage,避免固化 Provider 能力和文件布局。
119
+ - 新增 `ec ability remote list/discover/info/devices/call/result`,从主体 AID 发现能力、读取契约、筛选设备,自动校验参数并加密定向调用;原宿主插件管理命令保持兼容。
120
+ - 支持 `call --dry-run` 固定计划、持久操作去重和迟到结果查询;区分投递 ACK、业务状态与结果验证,超时和崩溃恢复不自动重发。
121
+ - 远端工具复用托管会话的委托鉴权、共享 sender 和请求索引;同步更新 Ability 文档、skill 与 ECK 提示词。首次加载新 daemon 代码需要宿主重启。
122
+
123
+ ### 消息与提及
124
+
125
+ - 私聊提及模式新增专用 Menu 查询、选项与 Owner 修改接口 `private-mention-mode`,接入 `queries` 与 Catalog `privateMentionMode.agent` 的 `values` 批量获取;更新使用 revision 校验,无需 CLI。
126
+ - 新增私聊提及模式:Agent 级配置项 `privateMentionMode`(`disabled` / `mention-only`,默认 `disabled`,仅 Owner 可改),
127
+ 开启后未被 `@` 的私聊消息只记入本地历史、不创建模型回合;与群聊 `mentionMode` 完全独立,群聊行为不变。
128
+ - 私聊入站补齐 `isMentioned` 标记与本地过滤记录字段 `privateAttention`,过滤记录可用 `ec msg history` 读取。
129
+
130
+ ### 依赖与 SDK
131
+
132
+ - SDK 升级并固定为 @agentunion/fastaun 0.5.37,跟进派生密钥缓存、重连削峰、Ownership 共识缓存、
133
+ 消息交付与 ACK 及 UDP 待机改进。
134
+ - 该版本将 EventService Bus 注册改为连接会话绑定:注册结果必须返回匹配的 `registration_id` 与
135
+ `session_bound: true`,否则按 `SERVICE_UNAVAILABLE` 失败;服务端需同步支持会话绑定注册。
136
+ - SDK 继续升级并固定为 @agentunion/fastaun 0.5.38,跟进设备标识 v2、共享 worker 池、证书验签与
137
+ 网关发现缓存、日志分流及多 Client 恢复错峰。
138
+ - `connect()` 改为返回 `Promise<ConnectResult>`;本仓库所有调用点均丢弃返回值,无需改动。
139
+ - 审计表的 workflow 字节本版有变化:仅 `yaml` 由静态导入改为在解析路径内 `createRequire` 懒加载,
140
+ read/verify/execute 边界不变,已按新摘要补登 `0.5.38` 条目。
41
141
 
42
142
  ## 0.0.48 (2026-11-14)
43
143
 
@@ -406,7 +506,7 @@
406
506
 
407
507
  ### 身份、联系人与配置
408
508
 
409
- - Agent 显示名跟随签名名片变化刷新,移除一次性自我介绍注入;新增 bootstrapWelcome 开关,可跳过首次欢迎消息。
509
+ - Agent 显示名跟随签名名片变化刷新,移除一次性自我介绍注入;新增 bootstrapWelcome(现为 `enableWelcome`)开关,可跳过首次欢迎消息。
410
510
  - 名录查询统一为 list/info,移除 find/show 别名;修复名录拉取,区分指定联系人名单与全部联系人授权,防止开放策略扩大准入范围。
411
511
  - 将同 Owner 默认角色资格扩展至验签及归属核验通过的内部 Agent,敏感操作前重新核验;拒绝将 Agent 自身声明为其 Owner。
412
512
  - Agent、Relation、Role Schema 分别收敛为 v19、v12、v2;兼容的 Agent v20 与 Relation v13 配置启动时备份迁移,自定义 Role v3 需人工调整至 v2;统一 paactive 配置写入并核验私聊关系。
package/bin/ec-build.mjs CHANGED
@@ -38,6 +38,66 @@ export async function build() {
38
38
  process.exitCode = results.some(result => result.status === 'rejected' || result.value !== 0) ? 1 : 0;
39
39
  }
40
40
 
41
+ /** Remove generated DSH adapter and runtime modules so renamed files cannot ship. */
42
+ export async function cleanDshRuntimeOutput() {
43
+ const dist = path.resolve(root, 'dist');
44
+ const target = path.resolve(dist, 'agents', 'dsh');
45
+ if (!target.startsWith(dist + path.sep)) throw new Error('Invalid DSH build output path');
46
+ await fs.promises.rm(target, { recursive: true, force: true });
47
+ }
48
+
49
+ /** tsc leaves old output behind when modules are moved or renamed. */
50
+ export async function cleanMovedCoreModules() {
51
+ for (const name of ['agents', 'core', 'directory']) {
52
+ const source = path.join(root, 'src', name);
53
+ const output = path.join(root, 'dist', name);
54
+ const sources = new Set(await fs.promises.readdir(source));
55
+ for (const entry of await fs.promises.readdir(output, { withFileTypes: true })) {
56
+ if (entry.isFile() && entry.name.endsWith('.js') && !sources.has(entry.name.slice(0, -3) + '.ts')) {
57
+ await fs.promises.unlink(path.join(output, entry.name));
58
+ }
59
+ }
60
+ }
61
+ for (const relative of [
62
+ 'core/system-session', 'core/background-session', 'contracts',
63
+ 'cli/fs-expiry.js', 'ecweb/dsh-session-view.js', 'stats/codex-context-window.js',
64
+ 'outputs/panel-card-trigger-authorization.js', 'core/session/system/grants.js', 'directory/text.js',
65
+ 'aun/aid/agentmd-fields.js', 'core/agent/runner-reload-transaction.js', 'core/agent/soul.js',
66
+ 'core/baseagent/baseagent-plugin-lazy.js', 'core/migration/legacy-rename.js',
67
+ 'core/model/agent-context-policy.js', 'core/ownership/agent-creation-approval.js',
68
+ 'core/permission/runtime-lock.js', 'directory/agentmd-sync.js', 'directory/request-operation.js',
69
+ 'eck/tool-time-context.js', 'utils/rate-window.js',
70
+ ]) {
71
+ const staleOutput = path.resolve(root, 'dist', relative);
72
+ if (!staleOutput.startsWith(path.resolve(root, 'dist') + path.sep)) {
73
+ throw new Error(`Invalid stale build output path: ${relative}`);
74
+ }
75
+ await fs.promises.rm(staleOutput, { recursive: true, force: true });
76
+ }
77
+
78
+ // Remove outputs left by agent modules whose names changed inside their directories.
79
+ const renamedAgentModules = {
80
+ claude: ['claude-capability-provider.js', 'claude-runner.js', 'claude-session-file-adapter.js'],
81
+ codex: ['codex-capability-provider.js', 'codex-runner.js', 'codex-session-file-adapter.js'],
82
+ ecagent: ['ecagent-runner.js', 'ecagent-session-file-adapter.js'],
83
+ gemini: ['gemini-capability-provider.js', 'gemini-runner.js', 'gemini-session-file-adapter.js'],
84
+ };
85
+ const agentsOutput = path.join(root, 'dist', 'agents');
86
+ for (const [agent, files] of Object.entries(renamedAgentModules)) {
87
+ for (const file of files) await fs.promises.rm(path.join(agentsOutput, agent, file), { force: true });
88
+ }
89
+ }
90
+
91
+ /** Non-TypeScript assets for DSH installation discovery and runtime documentation. */
92
+ export async function copyDshAssets(distDir = path.join(root, 'dist')) {
93
+ const source = path.join(root, 'src', 'agents', 'dsh');
94
+ const target = path.join(distDir, 'agents', 'dsh');
95
+ await fs.promises.mkdir(path.join(target, 'runtime'), { recursive: true });
96
+ for (const name of ['desktop-locations.ps1', 'runtime/README.md']) {
97
+ await fs.promises.copyFile(path.join(source, name), path.join(target, name));
98
+ }
99
+ }
100
+
41
101
  // The marker and embedded values must not contribute to their own content hash.
42
102
  const excluded = new Set(['build-identity.json', 'build-identity.json.tmp']);
43
103
  const identityBlock = /^\/\/ @evolcore-build-identity:start\r?\n[\s\S]*?^\/\/ @evolcore-build-identity:end[ \t]*(?=\r?$)/m;
package/bin/ecmsg.js CHANGED
@@ -41,44 +41,53 @@ const MAIN_CLI_BIN = 'ec';
41
41
 
42
42
  const HELP = `用法: ecmsg send '<正文>' [选项]
43
43
  ecmsg send '<正文>' --thread <话题id>
44
- ecmsg send '<正文>' --to <对端ID>
44
+ ecmsg send '<正文>' --thread <话题id> --selfmode
45
45
 
46
- 发送目标(三选一,优先级从高到低):
47
- (省略) 回复当前会话的对端/群
48
- --thread <话题id> 发到指定话题;只接受 thread-… 或 main:<aidA>:<aidB>
49
- --to <对端ID> 发到指定对端(群 AID 或对方 AID,按本地关系判定类型)
50
- --from <本端AID> 托管会话可省略(恒等于会话本端);非托管必填
51
- --to <本端AID> 跨话题自派(self-dispatch):必须配合 --thread,换话题给自己派活
46
+ 发送目标只有三种(接收方由话题和模式推出,不接受 --to):
47
+ (省略 --thread) 当前话题消息:发给当前会话的对端/群
48
+ --thread <话题id> 跨话题委托:发给该话题的对端
49
+ --thread <话题id> --selfmode 跨话题自派:发给本端自己,落在该话题的会话
50
+ --from <本端AID> 宿主终端(非托管)必填;托管会话禁止使用
52
51
 
53
- 复查:
54
- 跨话题(对端或话题与会话不同)自动创建复查 Trigger,默认 20m;
55
- --check-every <时长> 自定义复查周期(5m/30m/2h/1d)
56
- 同话题永不创建复查;此时传 --check-every 只在回执里说明,不报错。
52
+ 话题 id:
53
+ thread-… 独立话题,必须已存在于本端索引
54
+ main:<aidA>:<aidB> 主话题(两种顺序等价);首次联系可直接使用
55
+
56
+ 注意:
57
+ · --thread 不能是当前话题 id;当前话题消息省略 --thread。
58
+ · 话题的本端必须是当前会话本端。
59
+ · 位置参数只写正文;写在前面的 AID 会被当成正文。
60
+
61
+ 复查(仅跨话题委托):
62
+ 跨话题委托默认自动建复查 20m;--check-every <时长|none> 自定义或关闭。
63
+ 自派不建复查,不能与 --check-every 同用。
57
64
 
58
65
  加密:
59
- --encrypt yes|no|auto 默认 auto:被对端消息触发时跟随该消息,否则明文
60
- 只有目标对端在 AUN 网络上才能加密;非 AUN 目标用 yes 会被拒绝。
66
+ --encrypt yes|no|auto 默认 auto;只有目标对端在 AUN 上才能 yes
61
67
 
62
68
  正文来源:
63
- '<正文>' 位置参数
64
- --text-from-file <path> 从文件读取
65
- --file <path> 附件(可配 --as image|video|voice|file、--text 说明)
66
- --link <url> [--title T] 链接卡片
67
- --payload '<json>' 自定义 payload
69
+ '<正文>' 位置参数
70
+ --text-from-file <path> 从文件读取
71
+ --file <path> 附件(可配 --as image|video|voice|file|widget_card、--text 说明)
72
+ --as widget_card 上传 HTML 表单并发送 WidgetCard(--title 标题)
73
+ --link <url> [--title T] 链接卡片
74
+ --payload '<json>' 自定义 payload
75
+ --payload-file <path> 从 UTF-8 文件读 payload(仅私聊;文件上限 1 MiB)
68
76
 
69
77
  @提及(仅群聊;私聊带 --mention 会被拒绝):
70
- --mention '<aid1>,<aid2>' @指定成员,逗号分隔
71
- --mention-all @所有人
78
+ --mention '<aid1>,<aid2>' @指定成员,逗号分隔
79
+ --mention-all @所有人
72
80
 
73
81
  其它:
74
- --format json 输出 JSON 回执
75
- --help 显示本帮助
82
+ --format json 输出 JSON 回执
83
+ --help 显示本帮助
76
84
 
77
85
  示例:
78
86
  ecmsg send '收到,稍后回你'
79
- ecmsg send '问题已记录' --thread thread-1793851439746-7477-6351
80
- ecmsg send '进度如何' --to wang.agentid.pub --check-every 10m
81
- ecmsg send '报告在这里' --file ./report.md --as file
87
+ ecmsg send '进度如何' --thread thread-1793851439746-7477-6351
88
+ ecmsg send '接手这个子任务' --thread thread-1793851439746-7477-6351 --selfmode
89
+ ecmsg send '你好' --thread main:bob.agentid.cn:alice.agentid.cn
90
+ ecmsg send --file ./report.md --as file --text '报告在这里'
82
91
  `;
83
92
 
84
93
  // ── 委托哈希(与 agent-delegation.ts 逐字节一致,改动时两处必须同步) ──
@@ -287,7 +296,7 @@ async function main() {
287
296
 
288
297
  jsonOutput = wantsJsonOutput(argv.slice(1));
289
298
  const parsed = gateway.parseGatewayArgs(argv.slice(1));
290
- if (!parsed.ok) fail(parsed.error, 'INVALID_ARGUMENT');
299
+ if (!parsed.ok) fail(parsed.error, parsed.code ?? 'INVALID_ARGUMENT');
291
300
  const { route: routeOpts, passthrough, text } = parsed;
292
301
  if (routeOpts.help) { process.stdout.write(HELP); return; }
293
302
  jsonOutput = jsonOutput || routeOpts.format === 'json';
@@ -301,11 +310,15 @@ async function main() {
301
310
  if (nonManaged && !delegationToken) {
302
311
  if (!routeOpts.from || !String(routeOpts.from).trim()) {
303
312
  fail('非托管使用需要 --from <本端AID> 指定发送方', 'FROM_REQUIRED',
304
- { hint: 'ecmsg send \'<正文>\' --from <本端AID> --thread <话题id> --to <对端或本端AID>' });
313
+ { hint: "ecmsg send '<正文>' --from <本端AID> --thread <话题id> --selfmode(宿主终端只支持跨话题自派)" });
305
314
  }
306
315
  if (!routeOpts.thread || !String(routeOpts.thread).trim()) {
307
316
  fail('非托管使用需要 --thread <话题id> 定位会话', 'THREAD_REQUIRED',
308
- { hint: "ecmsg send '<正文>' --from <本端AID> --thread <话题id> --to <对端或本端AID>" });
317
+ { hint: "ecmsg send '<正文>' --from <本端AID> --thread <话题id> --selfmode(宿主终端只支持跨话题自派)" });
318
+ }
319
+ if (!routeOpts.selfMode) {
320
+ fail('宿主终端只支持跨话题自派:请加 --selfmode', 'SELFMODE_REQUIRED',
321
+ { hint: "ecmsg send '<正文>' --from <本端AID> --thread <话题id> --selfmode" });
309
322
  }
310
323
  if (passthrough.length > 0) {
311
324
  fail(`非托管发送目前只支持纯文本,不支持的选项:${passthrough.join(' ')}`, 'UNSUPPORTED_OPTION');
@@ -363,36 +376,14 @@ async function main() {
363
376
  return;
364
377
  }
365
378
 
366
- // 话题索引:--thread 是独立话题、或 --to 需要判断"是不是首次联系"时才真读盘,
367
- // 其余情况零 IO。
379
+ // 话题索引:--thread 是独立话题时才真读盘,其余情况零 IO。
368
380
  const deps = {};
369
381
 
370
382
  // 本端 AID:托管取运行时,非托管取 `--from`。
371
383
  const selfAid = nonManaged ? String(routeOpts.from).trim().replace(/^@/, '') : runtime.selfAid;
372
384
 
373
- // 群 AID 归一:`g-18127` 这类裸 base 必须在判定目标之前展开成完整 AID,
374
- // 否则既判不出它是群,也拼不出主话题。展开逻辑见 `ecmsg-gateway.ts` 的
375
- // `expandGroupBase`(纯函数,有单测)。
376
- let groupIdentity;
377
- const resolveGroupId = async id => {
378
- groupIdentity ??= await loadDist('aun/group/identity.js');
379
- return gateway.expandGroupBase(selfAid, id, groupIdentity?.normalizeGroupAid);
380
- };
381
-
382
- // --to 的目标类型:下游按它选 msg send / group send,必须解析而不是沿用
383
- // 当前会话的类型——否则"在私聊会话里给群发"会走成私聊,"在群会话里给个人发"
384
- // 会走成群消息。
385
- //
386
- // 群 AID 的 base 简写(`g-18127`)必须先展开成完整 AID,再做类型判定与路由:
387
- // 否则它既不像群也拼不出主话题,`--to g-18127` 会直接 TOPIC_REQUIRED。
388
- if (routeOpts.to !== undefined && String(routeOpts.to).trim()) {
389
- // 归一后写回 routeOpts:下游 argv 与回执都必须用展开后的完整 AID。
390
- routeOpts.to = await resolveGroupId(String(routeOpts.to).trim());
391
- const peerKind = await resolveTargetPeerKind(runtime, routeOpts.to, selfAid);
392
- deps.resolveTarget = id => ({ channelType: runtime?.channel ?? 'aun', peerKind, id });
393
- }
394
385
  // `--thread main:<a>:<b>` 的对端类型:主话题 id 里只有两个 AID,群的主话题同样写成
395
- // main:<self>:<群AID>。类型按关系证据解析(与 --to 同一套),再同步注入给纯函数;
386
+ // main:<self>:<群AID>。类型按关系证据解析,再同步注入给纯函数;
396
387
  // 否则网关会把群主话题当私聊,下游走 msg scope 被判 TOPIC_NOT_FOUND。
397
388
  if (typeof routeOpts.thread === 'string' && routeOpts.thread.trim()) {
398
389
  const topicIds = await loadDist('core/thread/topic-id.js');
@@ -405,8 +396,7 @@ async function main() {
405
396
  deps.resolvePeerKind = () => mainPeerKind;
406
397
  }
407
398
  }
408
- const needsThreadModule = gateway.needsThreadIndexLookup(routeOpts.thread)
409
- || routeOpts.to !== undefined;
399
+ const needsThreadModule = gateway.needsThreadIndexLookup(routeOpts.thread);
410
400
  // 话题条目:非托管下它就是「当前会话」的全部来源(对端 / chatType / channelType)。
411
401
  let threadEntry;
412
402
  if (needsThreadModule) {
@@ -471,13 +461,16 @@ async function main() {
471
461
 
472
462
  // 非托管:没有会话上下文,本端来自 --from,对端/类型来自话题索引条目。
473
463
  // chatType 按条目判(群话题 = group),peerId 用条目里的对端。
464
+ //
465
+ // threadId 恒为 undefined:宿主没有「当前会话」,`--thread` 是投递目标而不是
466
+ // 来源话题。若把它同时当成当前话题,自派会必然被判成 TOPIC_IS_CURRENT。
474
467
  const sessionContext = nonManaged
475
468
  ? {
476
469
  selfAid,
477
470
  channelType: threadEntry?.channelType ?? 'aun',
478
471
  chatType: threadEntry?.peerKind === 'group' ? 'group' : 'private',
479
472
  peerId: threadEntry?.peer ?? '',
480
- threadId: routing.isThreadTopicId(routeOpts.thread) ? routeOpts.thread : undefined,
473
+ threadId: undefined,
481
474
  }
482
475
  : {
483
476
  selfAid: runtime.selfAid,
@@ -490,11 +483,10 @@ async function main() {
490
483
  const outcome = routing.resolveSendRoute(
491
484
  {
492
485
  thread: routeOpts.thread,
493
- to: routeOpts.to,
486
+ selfMode: routeOpts.selfMode === true,
494
487
  from: routeOpts.from,
495
488
  checkEvery: routeOpts.checkEvery,
496
489
  encrypt: routeOpts.encrypt,
497
- noEncrypt: routeOpts.noEncrypt === true,
498
490
  // auto 的判据:本轮是否带着入站消息的加密态。有该状态说明是回复对端消息,
499
491
  // 沿用它的加密方式;没有(如 trigger 唤醒发起)则明文。
500
492
  inboundTriggered: runtime?.inboundEncrypted !== undefined,
@@ -596,6 +588,14 @@ function renderReceipt(route, result, routing, gateway) {
596
588
  // 它随消息类型在 sent/delivered/accepted 之间变化,不适合当判据。
597
589
  status: 'accepted',
598
590
  ...(result.status !== undefined ? { aun_status: result.status } : {}),
591
+ // `--return required`:daemon 已登记请求并等到了对端应答。漏掉这几个字段,
592
+ // 调用方只看到「已发送」,对端的结果在注册表里落盘了却永远拿不到。
593
+ ...(result.request_id ? {
594
+ request_id: result.request_id,
595
+ request_state: result.request_state,
596
+ ...(result.response !== undefined ? { response: result.response } : {}),
597
+ ...(result.responses !== undefined ? { responses: result.responses } : {}),
598
+ } : {}),
599
599
  ...(selfAddressed || result.self_session_id !== undefined || result.self_delivery_error !== undefined ? {
600
600
  self_session_id: result.self_session_id,
601
601
  self_delivery_error: result.self_delivery_error,
@@ -609,6 +609,9 @@ function renderReceipt(route, result, routing, gateway) {
609
609
  `✓ 已发送 ${routeLine} message_id=${result.message_id ?? '-'}`
610
610
  + ` request_id=${result.request_id} state=${result.request_state ?? '-'}\n`,
611
611
  );
612
+ // 应答正文是这次调用的结果,不打印等于白等。
613
+ if (result.response !== undefined) process.stdout.write(`${JSON.stringify(result.response, null, 2)}\n`);
614
+ else if (result.responses !== undefined) process.stdout.write(`${JSON.stringify(result.responses, null, 2)}\n`);
612
615
  return;
613
616
  }
614
617
 
@@ -636,6 +639,10 @@ function renderReceipt(route, result, routing, gateway) {
636
639
 
637
640
  if (route.firstContact) {
638
641
  process.stdout.write('· 首次联系:目标会话随本条建立,本次不建复查\n');
642
+ } else if (route.crossTopic && route.checkEveryMs === undefined) {
643
+ // `--check-every none`:显式不建复查。checkEveryMs 为 undefined 时不再走默认周期,
644
+ // 回执照旧输出「已建复查」会误导(trigger_id 也是空的)。
645
+ process.stdout.write('· 跨话题,按 --check-every none 未建复查\n');
639
646
  } else if (route.crossTopic) {
640
647
  const duration = gateway.formatDuration(route.checkEveryMs);
641
648
  const label = route.checkEveryDefaulted ? `默认 ${duration}` : duration;
@@ -0,0 +1,21 @@
1
+ /** Protocol execution identity, independent of local plugin and contact roles. */
2
+ export function createRemoteAbilityAuthorizer(deps) {
3
+ return async (params, operation) => {
4
+ const validation = params.delegationGrant ? { ok: true, grant: params.delegationGrant }
5
+ : deps.agentDelegationRegistry.validate(params.delegationToken, params.sessionId, params.delegationCommandHash);
6
+ if (!validation.ok)
7
+ return { ok: false, code: validation.code, error: validation.reason };
8
+ const grant = validation.grant;
9
+ const session = await deps.sessionManager.getSessionById(params.sessionId);
10
+ if (grant.sessionId !== params.sessionId || !session || session.selfAID !== grant.selfAid
11
+ || !deps.agentDelegationRegistry.isCurrentTaskGrant(grant)) {
12
+ return { ok: false, code: 'INVALID_DELEGATION', error: 'Remote Ability requires the current task and Caller identity' };
13
+ }
14
+ if (grant.channelType !== 'aun')
15
+ return { ok: false, code: 'AUN_SESSION_REQUIRED', error: 'Remote Ability requires an AUN managed session' };
16
+ if (operation === 'ability.remote.call' && grant.permissionMode === 'readonly') {
17
+ return { ok: false, code: 'NOT_ALLOWED', error: 'Readonly tasks may inspect or preview; business calls require a writable task' };
18
+ }
19
+ return { ok: true, grant };
20
+ };
21
+ }
@@ -0,0 +1,173 @@
1
+ export const REMOTE_CLI_VERSION = 'evolcore.ability-remote-cli/v1';
2
+ export const REMOTE_MIN_OUTPUT_BYTES = 256;
3
+ export const REMOTE_DEFAULT_INSPECTION_BYTES = 8192;
4
+ export const REMOTE_COMMANDS = {
5
+ list: { description: '读取完整能力目录,按需附指南或设备', positional: 1, options: ['path', 'search', 'full', 'refresh', 'usage', 'discovery', 'devices'] },
6
+ discover: { description: '按需在线发现并收集设备能力', positional: 1, options: ['path', 'window', 'full', 'device-id', 'credential-file'] },
7
+ info: { description: '读取或提取所选能力的契约字段', positional: 2, options: ['discovery', 'definition-id', 'usage', 'refresh', 'full', 'action', 'schema', 'select', 'jq'] },
8
+ devices: { description: '从发现快照筛选匹配能力的设备', positional: 1, options: ['path', 'discovery'] },
9
+ call: { description: '校验、预览或加密定向调用远端能力', positional: 2, options: ['discovery', 'definition-id', 'device-id', 'credential-file', 'params', 'params-file', 'timeout', 'ttl', 'operation-id', 'dry-run', 'plan'] },
10
+ result: { description: '查询并校验原请求结果,不重新发送', positional: 1, options: ['wait'] },
11
+ };
12
+ export function remoteUsage(action) {
13
+ const signature = action === 'result' ? '<request-id> [--wait 30s]'
14
+ : action === 'call' ? '<ProviderAID> <path> [--params \'<JSON对象>\'] [选项] | ec ability remote call --plan <plan-id>'
15
+ : action === 'info' ? '<ProviderAID> <path> [--action <action>] [--schema params|result|both] [--select <jsonpath> | --jq <expr>] [选项]'
16
+ : action === 'devices' ? '<ProviderAID> <path> --discovery <id>'
17
+ : '<ProviderAID> [path] [选项]';
18
+ return `ec ability remote ${action} ${signature}`;
19
+ }
20
+ export class RemoteError extends Error {
21
+ code;
22
+ data;
23
+ constructor(code, message, data) {
24
+ super(message);
25
+ this.code = code;
26
+ this.data = data;
27
+ }
28
+ }
29
+ export function remoteAssert(value, code, message, data) {
30
+ if (!value)
31
+ throw new RemoteError(code, message, data);
32
+ }
33
+ export function durationSeconds(value, maximum = 3600) {
34
+ const match = /^(\d+)(s|m)?$/.exec(value);
35
+ const seconds = match ? Number(match[1]) * (match[2] === 'm' ? 60 : 1) : NaN;
36
+ remoteAssert(Number.isSafeInteger(seconds) && seconds >= 1 && seconds <= maximum, 'ARGUMENT_INVALID', `Duration must be an integer from 1 to ${maximum} seconds`);
37
+ return seconds;
38
+ }
39
+ export function assertAbilityPath(value) {
40
+ remoteAssert(value.length <= 256 && /^[a-z][a-z0-9_-]*(\/[a-z][a-z0-9_-]*)+$/.test(value), 'ARGUMENT_INVALID', 'An exact Ability path is required');
41
+ }
42
+ export function parseRemoteCommand(argv) {
43
+ try {
44
+ return parseRemoteArguments(argv);
45
+ }
46
+ catch (error) {
47
+ if (!(error instanceof RemoteError) || error.code !== 'ARGUMENT_INVALID')
48
+ throw error;
49
+ const action = argv[2];
50
+ const usage = Object.hasOwn(REMOTE_COMMANDS, action) ? remoteUsage(action) : 'ec ability remote --help';
51
+ throw new RemoteError(error.code, error.message.includes('Usage:') ? error.message : `${error.message}. Usage: ${usage}`, { ...error.data, usage });
52
+ }
53
+ }
54
+ function parseRemoteArguments(argv) {
55
+ remoteAssert(argv[0] === 'ability' && argv[1] === 'remote', 'ARGUMENT_INVALID', 'Expected ability remote command');
56
+ const action = argv[2];
57
+ remoteAssert(Object.hasOwn(REMOTE_COMMANDS, action), 'ACTION_UNSUPPORTED', 'Unknown remote Ability command');
58
+ const descriptor = REMOTE_COMMANDS[action];
59
+ const options = Object.create(null);
60
+ const positional = [];
61
+ for (let i = 3; i < argv.length; i++) {
62
+ const arg = argv[i];
63
+ remoteAssert(typeof arg === 'string' && !arg.includes('\0'), 'ARGUMENT_INVALID', 'Invalid argument');
64
+ if (!arg.startsWith('-')) {
65
+ positional.push(arg);
66
+ continue;
67
+ }
68
+ const key = arg.slice(2);
69
+ remoteAssert(arg.startsWith('--') && (['format', 'max-bytes'].includes(key) || descriptor.options.includes(key)) && !Object.hasOwn(options, key), 'ARGUMENT_INVALID', `Unknown or duplicate option: ${arg}`);
70
+ if (['refresh', 'usage', 'dry-run', 'full', 'devices'].includes(key))
71
+ options[key] = 'true';
72
+ else {
73
+ remoteAssert(!!argv[i + 1] && !argv[i + 1].startsWith('--'), 'ARGUMENT_INVALID', `Missing value: ${arg}`);
74
+ options[key] = argv[++i];
75
+ }
76
+ }
77
+ remoteAssert(!options.format || options.format === 'json', 'ARGUMENT_INVALID', 'Only --format json is supported');
78
+ if (options['max-bytes'])
79
+ remoteAssert(/^\d+$/.test(options['max-bytes']) && Number.isSafeInteger(Number(options['max-bytes']))
80
+ && Number(options['max-bytes']) >= REMOTE_MIN_OUTPUT_BYTES, 'ARGUMENT_INVALID', `--max-bytes must be an integer of at least ${REMOTE_MIN_OUTPUT_BYTES}`);
81
+ remoteAssert(!(options.select && options.jq), 'ARGUMENT_INVALID', '--select and --jq are mutually exclusive');
82
+ if (options.schema)
83
+ remoteAssert(['params', 'result', 'both'].includes(options.schema), 'ARGUMENT_INVALID', '--schema must be params, result or both');
84
+ if (action === 'call' && options.plan) {
85
+ remoteAssert(positional.length === 0 && Object.keys(options).every(key => ['plan', 'format', 'max-bytes', 'credential-file'].includes(key)), 'ARGUMENT_INVALID', '--plan cannot be combined with call parameters');
86
+ return { action, options };
87
+ }
88
+ const optionalPath = ['list', 'discover', 'devices'].includes(action);
89
+ remoteAssert(positional.length === descriptor.positional || optionalPath && positional.length === 2, 'ARGUMENT_INVALID', `Invalid arguments. Usage: ${remoteUsage(action)}`, { usage: remoteUsage(action) });
90
+ remoteAssert(!(positional[1] && options.path), 'ARGUMENT_INVALID', 'Specify path once, as a positional argument or --path', { usage: remoteUsage(action) });
91
+ if (action === 'result') {
92
+ remoteAssert(/^[A-Za-z0-9_.:-]{1,256}$/.test(positional[0]), 'ARGUMENT_INVALID', 'Invalid request ID');
93
+ if (options.wait)
94
+ durationSeconds(options.wait, 60);
95
+ return { action, requestId: positional[0], options };
96
+ }
97
+ const labels = positional[0].split('.');
98
+ remoteAssert(positional[0].length <= 512 && labels.length >= 3 && labels.every(label => /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(label)), 'ARGUMENT_INVALID', 'Use an exact lowercase Provider AID');
99
+ const abilityPath = positional[1] ?? options.path;
100
+ if (abilityPath)
101
+ assertAbilityPath(abilityPath);
102
+ if (options['definition-id'])
103
+ remoteAssert(/^[a-z0-9][a-z0-9_-]{0,63}$/.test(options['definition-id']), 'ARGUMENT_INVALID', 'Invalid definition ID');
104
+ if (options['device-id'])
105
+ remoteAssert(options['device-id'].length <= 256 && !/[\s\x00-\x1f\x7f]/.test(options['device-id']), 'ARGUMENT_INVALID', 'Invalid device ID');
106
+ if (options['operation-id'])
107
+ remoteAssert(/^[A-Za-z0-9_.:-]{1,256}$/.test(options['operation-id']), 'ARGUMENT_INVALID', 'Invalid operation ID');
108
+ if (options.window)
109
+ durationSeconds(options.window, 30);
110
+ if (options.search)
111
+ remoteAssert(options.search.length <= 256, 'ARGUMENT_INVALID', '--search must be at most 256 characters');
112
+ remoteAssert(!(options.refresh && options.discovery), 'ARGUMENT_INVALID', '--refresh cannot be combined with a fixed --discovery snapshot');
113
+ for (const key of ['timeout', 'ttl'])
114
+ if (options[key])
115
+ durationSeconds(options[key]);
116
+ remoteAssert(!(options.params && options['params-file']), 'ARGUMENT_INVALID', '--params and --params-file are mutually exclusive');
117
+ if (action === 'devices')
118
+ remoteAssert(options.discovery && abilityPath, 'ARGUMENT_INVALID', `Usage: ${remoteUsage(action)} (--path is also supported)`, { usage: remoteUsage(action) });
119
+ if (action === 'call')
120
+ remoteAssert(abilityPath !== 'protocol/discover', 'ARGUMENT_INVALID', 'Use remote discover for protocol/discover');
121
+ return { action, provider: positional[0], path: abilityPath, options };
122
+ }
123
+ export function remoteOperation(command) {
124
+ return `ability.remote.${command.action === 'call' && command.options['dry-run'] ? 'preview' : command.action}`;
125
+ }
126
+ export function remoteCommandSchema(action) {
127
+ remoteAssert(Object.hasOwn(REMOTE_COMMANDS, action), 'ACTION_UNSUPPORTED', 'Unknown remote Ability command');
128
+ const descriptor = REMOTE_COMMANDS[action];
129
+ const string = { type: 'string', minLength: 1 };
130
+ const path = { type: 'string', maxLength: 256, pattern: '^[a-z][a-z0-9_-]*(/[a-z][a-z0-9_-]*)+$' };
131
+ const fields = {
132
+ path, refresh: { type: 'boolean' }, usage: { type: 'boolean' }, full: { type: 'boolean' }, 'dry-run': { type: 'boolean' },
133
+ devices: { type: 'boolean' }, action: string, schema: { enum: ['params', 'result', 'both'] }, select: string, jq: string,
134
+ search: { type: 'string', minLength: 1, maxLength: 256 }, 'credential-file': string,
135
+ discovery: string, 'definition-id': { type: 'string', pattern: '^[a-z0-9][a-z0-9_-]{0,63}$' },
136
+ 'device-id': { type: 'string', minLength: 1, maxLength: 256, pattern: '^[^\\s\\u0000-\\u001f\\u007f]+$' },
137
+ params: { type: 'object', description: 'Decoded --params JSON; exact business Schema comes from remote info.' },
138
+ 'params-file': string, 'operation-id': { type: 'string', pattern: '^[A-Za-z0-9_.:-]{1,256}$' },
139
+ window: { type: 'string', pattern: '^(?:[1-9]|[12][0-9]|30)s?$' },
140
+ wait: { type: 'string', pattern: '^(?:(?:[1-9]|[1-5][0-9]|60)s?|1m)$' },
141
+ timeout: { type: 'string', pattern: '^\\d+[sm]?$', description: '1–3600 integer seconds after unit conversion; default 60s.' },
142
+ ttl: { type: 'string', pattern: '^\\d+[sm]?$', description: '1–3600 integer seconds after unit conversion; defaults to timeout.' },
143
+ };
144
+ const properties = Object.fromEntries(descriptor.options.filter(key => key !== 'plan').map(key => [key, fields[key]]));
145
+ properties.format = { const: 'json' };
146
+ properties['max-bytes'] = { type: 'integer', minimum: REMOTE_MIN_OUTPUT_BYTES, maximum: Number.MAX_SAFE_INTEGER };
147
+ const required = [];
148
+ if (action === 'result') {
149
+ properties.requestId = { ...string, pattern: '^[A-Za-z0-9_.:-]{1,256}$' };
150
+ required.push('requestId');
151
+ }
152
+ else {
153
+ properties.provider = { type: 'string', maxLength: 512, pattern: '^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?){2,}$' };
154
+ required.push('provider');
155
+ if (descriptor.positional === 2) {
156
+ properties.path = path;
157
+ required.push('path');
158
+ }
159
+ if (action === 'devices')
160
+ required.push('path', 'discovery');
161
+ }
162
+ const normal = { type: 'object', additionalProperties: false, properties, required,
163
+ ...(action === 'info' ? { not: { required: ['select', 'jq'] } } : {}),
164
+ ...(['call', 'discover'].includes(action) ? { allOf: [
165
+ ...(action === 'call' ? [{ not: { required: ['params', 'params-file'] } }] : []),
166
+ ] } : {}) };
167
+ const input = action === 'call' ? { oneOf: [normal, { type: 'object', additionalProperties: false,
168
+ properties: { plan: string, format: { const: 'json' }, 'max-bytes': properties['max-bytes'], 'credential-file': fields['credential-file'] }, required: ['plan'] }] } : normal;
169
+ return { schemaVersion: REMOTE_CLI_VERSION, operation: `remote.${action}`, command: REMOTE_COMMANDS[action],
170
+ input: { $schema: 'http://json-schema.org/draft-07/schema#', description: 'Semantic CLI arguments, not an IPC body or --file input. Boolean options represent flags; params is decoded JSON. Duration limits and device/contract constraints are also checked at execution.', ...input },
171
+ params: { type: 'object', description: 'Business params; the exact Schema is returned by remote info. --params and --params-file are mutually exclusive.' },
172
+ durations: { window: { default: 5, minimum: 1, maximum: 30 }, timeout: { default: 60, minimum: 1, maximum: 3600 }, wait: { minimum: 1, maximum: 60 } } };
173
+ }