evolcore 0.0.50 → 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 (448) hide show
  1. package/CHANGELOG.md +39 -2
  2. package/bin/ec-build.mjs +60 -0
  3. package/bin/ecmsg.js +65 -63
  4. package/dist/ability/caller/command.js +24 -15
  5. package/dist/ability/caller/contract.js +24 -9
  6. package/dist/ability/caller/credential-files.js +132 -0
  7. package/dist/ability/caller/daemon.js +32 -7
  8. package/dist/ability/caller/schema-view.js +157 -0
  9. package/dist/ability/caller/service.js +202 -63
  10. package/dist/ability/interop-v1.js +156 -113
  11. package/dist/agent-template/jobs.js +14 -110
  12. package/dist/agent-template/runtime.js +331 -193
  13. package/dist/agent-template/service.js +1029 -1104
  14. package/dist/agent-template/share.js +103 -0
  15. package/dist/agent-template/tool-runner.js +25 -0
  16. package/dist/agent-template/types.js +10 -3
  17. package/dist/agents/claude/availability.js +94 -0
  18. package/dist/agents/claude/capability-provider.js +154 -0
  19. package/dist/agents/claude/index.js +145 -0
  20. package/dist/agents/{claude-runner.js → claude/runner.js} +74 -158
  21. package/dist/agents/claude/session-file-adapter.js +246 -0
  22. package/dist/agents/codex/app-server-client.js +90 -10
  23. package/dist/agents/codex/availability.js +164 -0
  24. package/dist/agents/codex/capability-provider.js +138 -0
  25. package/dist/agents/codex/cli.js +38 -0
  26. package/dist/agents/codex/index.js +345 -0
  27. package/dist/agents/codex/mcp-elicitation.js +135 -0
  28. package/dist/agents/{codex-runner.js → codex/runner.js} +648 -382
  29. package/dist/agents/codex/session-file-adapter.js +834 -0
  30. package/dist/agents/dsh/availability.js +28 -0
  31. package/dist/agents/dsh/capability-provider.js +56 -0
  32. package/dist/agents/dsh/desktop-locations.ps1 +66 -0
  33. package/dist/agents/dsh/desktop-probe.cjs +37 -0
  34. package/dist/agents/dsh/index.js +98 -0
  35. package/dist/agents/dsh/installation.js +400 -0
  36. package/dist/agents/dsh/resources.js +755 -0
  37. package/dist/agents/dsh/runner.js +1183 -0
  38. package/dist/agents/dsh/runtime/README.md +243 -0
  39. package/dist/agents/dsh/runtime/authorization.js +23 -0
  40. package/dist/agents/dsh/runtime/bridge.js +837 -0
  41. package/dist/agents/dsh/runtime/config.js +271 -0
  42. package/dist/agents/dsh/runtime/entry.js +229 -0
  43. package/dist/agents/dsh/runtime/session-inspector.js +340 -0
  44. package/dist/agents/dsh/runtime/tool-policy.js +49 -0
  45. package/dist/agents/dsh/session-file-adapter.js +145 -0
  46. package/dist/agents/ecagent/index.js +215 -0
  47. package/dist/agents/{ecagent-runner.js → ecagent/runner.js} +592 -106
  48. package/dist/agents/ecagent/session-file-adapter.js +134 -0
  49. package/dist/agents/gemini/index.js +55 -10
  50. package/dist/agents/gemini/{gemini-runner.js → runner.js} +4 -9
  51. package/dist/aun/ability-device-routing.js +11 -17
  52. package/dist/aun/aid/agentmd.js +27 -1
  53. package/dist/aun/aid/managed-operation.js +6 -4
  54. package/dist/aun/group/invite-service.js +1 -1
  55. package/dist/aun/menu/client.js +1 -1
  56. package/dist/aun/msg/history.js +1 -1
  57. package/dist/aun/msg/managed-operation.js +93 -21
  58. package/dist/aun/msg/p2p.js +6 -6
  59. package/dist/aun/service-proxy.js +1 -1
  60. package/dist/aun/storage/index.js +242 -0
  61. package/dist/build-identity.json +1 -1
  62. package/dist/channels/aun.js +180 -43
  63. package/dist/channels/daemon.js +3 -2
  64. package/dist/channels/dingtalk.js +1 -1
  65. package/dist/channels/feishu.js +9 -9
  66. package/dist/channels/qqbot.js +1 -1
  67. package/dist/channels/wechat.js +2 -2
  68. package/dist/channels/wecom.js +1 -1
  69. package/dist/{agents/claude-gateway → claude-gateway}/agent-registration.js +13 -13
  70. package/dist/{agents/claude-gateway → claude-gateway}/binding.js +3 -3
  71. package/dist/{agents/claude-gateway → claude-gateway}/inbox.js +1 -1
  72. package/dist/{agents/claude-gateway → claude-gateway}/index.js +2 -2
  73. package/dist/{agents/claude-gateway → claude-gateway}/listing.js +3 -3
  74. package/dist/{agents/claude-gateway → claude-gateway}/router.js +4 -4
  75. package/dist/{agents/claude-gateway → claude-gateway}/sessions.js +2 -2
  76. package/dist/{agents/claude-gateway → claude-gateway}/terminal.js +1 -1
  77. package/dist/{agents/claude-gateway → claude-gateway}/transcript.js +1 -1
  78. package/dist/cli/ability-command.js +8 -5
  79. package/dist/cli/ability-output.js +182 -0
  80. package/dist/cli/agent-command.js +1 -1
  81. package/dist/cli/agent-create.js +123 -42
  82. package/dist/cli/agent-template.js +400 -29
  83. package/dist/cli/agent.js +14 -11
  84. package/dist/cli/aun-commands.js +167 -111
  85. package/dist/cli/daemon-commands.js +38 -8
  86. package/dist/cli/data-command.js +1 -1
  87. package/dist/cli/debug-mode.js +9 -0
  88. package/dist/cli/directory.js +1 -2
  89. package/dist/cli/ecmsg-gateway.js +55 -19
  90. package/dist/cli/fs-command.js +67 -39
  91. package/dist/cli/index.js +25 -11
  92. package/dist/cli/init.js +124 -29
  93. package/dist/cli/managed-command-guard.js +2 -0
  94. package/dist/cli/model.js +1 -1
  95. package/dist/cli/restart-monitor.js +2 -2
  96. package/dist/cli/services-command.js +24 -1
  97. package/dist/cli/skill-command.js +4 -4
  98. package/dist/cli/task-context.js +24 -14
  99. package/dist/cli/team-workspace-command.js +50 -52
  100. package/dist/cli/thread-command.js +3 -2
  101. package/dist/cli/trigger-command.js +47 -12
  102. package/dist/cli/watch-logs.js +2 -1
  103. package/dist/config/boot-log.js +3 -0
  104. package/dist/config/builtin-role-templates.js +1 -1
  105. package/dist/config/config-field-policy.js +10 -6
  106. package/dist/config/config-manager.js +33 -12
  107. package/dist/config/gateway-config.js +21 -37
  108. package/dist/config/invoke-ipc-service.js +1 -1
  109. package/dist/config/owner-config.js +5 -3
  110. package/dist/config/peer-book-store.js +2 -3
  111. package/dist/config/peer-book.js +2 -2
  112. package/dist/config/peer-role-resolver.js +2 -2
  113. package/dist/config/provider-identity-migration.js +24 -105
  114. package/dist/config/provider-ipc-service.js +13 -3
  115. package/dist/config/provider-local-sync.js +4 -1
  116. package/dist/config/provider-menu-request.js +21 -3
  117. package/dist/config/provider-templates.js +1 -1
  118. package/dist/config/providers-config.js +39 -15
  119. package/dist/config/providers-import.js +3 -3
  120. package/dist/config/providers-management.js +74 -99
  121. package/dist/config/schema-migration.js +177 -11
  122. package/dist/config/schema-registry.js +1 -1
  123. package/dist/config-store.js +38 -50
  124. package/dist/core/{agent-application-service.js → agent/agent-application-service.js} +9 -9
  125. package/dist/core/{agent-create-status.js → agent/agent-create-status.js} +112 -4
  126. package/dist/core/{agent-creation-claim.js → agent/agent-creation-claim.js} +3 -3
  127. package/dist/core/{agent-ipc-registration.js → agent/agent-ipc-registration.js} +102 -25
  128. package/dist/core/{agent-reload-coordinator.js → agent/agent-reload-coordinator.js} +61 -1
  129. package/dist/core/{agent-runtime.js → agent/agent-runtime.js} +53 -27
  130. package/dist/core/{evolagent-registry.js → agent/evolagent-registry.js} +12 -12
  131. package/dist/core/{evolagent.js → agent/evolagent.js} +11 -11
  132. package/dist/core/auth/agent-delegation.js +1 -8
  133. package/dist/core/auth/delegation-authorization.js +28 -0
  134. package/dist/core/auth/operation-authorizer.js +7 -4
  135. package/dist/core/auth/operation-catalog.js +34 -5
  136. package/dist/core/baseagent/baseagent-availability.js +197 -0
  137. package/dist/core/baseagent/baseagent-capability-adapter.js +288 -0
  138. package/dist/core/baseagent/baseagent-config-shared.js +56 -0
  139. package/dist/core/baseagent/baseagent-identity.js +68 -0
  140. package/dist/core/{baseagent-loader.js → baseagent/baseagent-loader.js} +62 -6
  141. package/dist/core/baseagent/baseagent-model-defaults.js +26 -0
  142. package/dist/{agents → core/baseagent}/baseagent-plugin-descriptor.js +107 -24
  143. package/dist/core/baseagent/baseagent-plugin-loader.js +367 -0
  144. package/dist/core/baseagent/baseagent.js +157 -0
  145. package/dist/{agents → core/baseagent}/runner-types.js +36 -4
  146. package/dist/core/capability/capability-manager.js +79 -30
  147. package/dist/core/capability/providers/claude-capability-provider.js +2 -154
  148. package/dist/core/capability/providers/codex-capability-provider.js +2 -136
  149. package/dist/core/{channel-loader.js → channel/channel-loader.js} +226 -38
  150. package/dist/core/{channel-runtime.js → channel/channel-runtime.js} +18 -18
  151. package/dist/core/command/agent-control.js +60 -15
  152. package/dist/core/command/agent-template-menu.js +21 -9
  153. package/dist/core/command/agentmd-menu-request.js +19 -8
  154. package/dist/core/command/agentmd-menu.js +14 -5
  155. package/dist/core/command/command-handler.js +127 -57
  156. package/dist/core/command/context-policy-menu.js +122 -0
  157. package/dist/core/command/data-root-resolver.js +157 -20
  158. package/dist/core/command/memory-slash.js +6 -6
  159. package/dist/core/command/menu-catalog.js +80 -20
  160. package/dist/core/command/menu-handler.js +305 -25
  161. package/dist/core/command/menu-protocol.js +42 -8
  162. package/dist/core/command/menu-query-batch.js +9 -5
  163. package/dist/core/command/provider-menu.js +7 -11
  164. package/dist/core/command/role-menu.js +1 -1
  165. package/dist/core/command/skill-slash.js +17 -5
  166. package/dist/core/command/slash-gate.js +2 -4
  167. package/dist/core/command/slash-handler.js +127 -96
  168. package/dist/core/command/team-workspace-team.js +3 -3
  169. package/dist/core/command/topic-slash.js +10 -10
  170. package/dist/core/{daemon-bootstrap.js → daemon/daemon-bootstrap.js} +14 -14
  171. package/dist/core/{daemon-control.js → daemon/daemon-control.js} +46 -20
  172. package/dist/core/{daemon-lifecycle.js → daemon/daemon-lifecycle.js} +15 -15
  173. package/dist/core/{host-snapshot.js → daemon/host-snapshot.js} +3 -3
  174. package/dist/core/{ipc-registration.js → daemon/ipc-registration.js} +98 -38
  175. package/dist/core/{lifecycle-notice.js → daemon/lifecycle-notice.js} +4 -5
  176. package/dist/core/file-integrity/store.js +1 -1
  177. package/dist/core/handoff/ipc-registration.js +3 -3
  178. package/dist/core/handoff/runtime.js +1 -1
  179. package/dist/{agents → core/inference}/request-identity.js +2 -2
  180. package/dist/core/inference/text-inference.js +4 -4
  181. package/dist/core/{bootstrap-messages.js → initialization/bootstrap-messages.js} +10 -10
  182. package/dist/core/{bootstrap-service.js → initialization/bootstrap-service.js} +24 -23
  183. package/dist/core/initialization/service.js +54 -9
  184. package/dist/core/invoke/executors/media.js +1 -1
  185. package/dist/core/invoke/executors/text.js +1 -1
  186. package/dist/core/memory/consolidation-context.js +1 -1
  187. package/dist/core/memory/consolidation-trigger.js +9 -3
  188. package/dist/core/memory/consolidation.js +4 -4
  189. package/dist/core/memory/memory-admin.js +6 -6
  190. package/dist/core/memory/memory-writer.js +1 -1
  191. package/dist/core/memory/relation-idle-monitor.js +1 -1
  192. package/dist/core/message/aun-ipc-sender.js +114 -75
  193. package/dist/core/message/aun-request-registry.js +13 -5
  194. package/dist/core/message/auto-mention-gate.js +1 -1
  195. package/dist/core/message/contact-admission.js +1 -1
  196. package/dist/core/message/im-renderer.js +19 -0
  197. package/dist/core/{interaction-router.js → message/interaction-router.js} +4 -4
  198. package/dist/core/message/items-formatter.js +5 -5
  199. package/dist/core/message/message-admission.js +1 -1
  200. package/dist/core/message/message-bridge.js +135 -54
  201. package/dist/core/message/message-queue.js +83 -4
  202. package/dist/core/message/message-utils.js +1 -1
  203. package/dist/core/message/peer-mode.js +1 -1
  204. package/dist/core/message/response-engine.js +347 -163
  205. package/dist/core/message/send-options.js +9 -6
  206. package/dist/core/message/send-routing.js +45 -109
  207. package/dist/core/message/stream-idle-monitor.js +1 -1
  208. package/dist/core/{data-migration.js → migration/data-migration.js} +29 -1
  209. package/dist/core/model/catalog-service.js +29 -8
  210. package/dist/core/model/model-capabilities.js +88 -0
  211. package/dist/core/model/model-catalog.js +14 -3
  212. package/dist/core/model/model-diagnostics.js +4 -4
  213. package/dist/core/ownership/owner-resolver.js +95 -15
  214. package/dist/core/{pack-auth.js → pack/pack-auth.js} +30 -3
  215. package/dist/core/{pack-install.js → pack/pack-install.js} +95 -17
  216. package/dist/core/permission/approval-gateway.js +9 -18
  217. package/dist/core/permission/ec-command-parser.js +70 -34
  218. package/dist/core/permission/managed-file.js +234 -0
  219. package/dist/core/permission/protected-paths.js +56 -0
  220. package/dist/core/permission/sandbox-runtime.js +267 -3
  221. package/dist/core/permission/session-path-grants.js +1 -1
  222. package/dist/core/permission/shell-environment.js +15 -1
  223. package/dist/core/plugin/plugin-lifecycle.js +442 -0
  224. package/dist/core/session/adapters/claude-session-file-adapter.js +2 -246
  225. package/dist/core/session/adapters/codex-session-file-adapter.js +2 -566
  226. package/dist/core/session/adapters/ecagent-session-file-adapter.js +2 -134
  227. package/dist/core/{background-session → session/background}/session-cleanup.js +2 -2
  228. package/dist/core/{background-session → session/background}/types.js +1 -1
  229. package/dist/core/session/session-file-health.js +2 -272
  230. package/dist/core/session/session-idle-monitor.js +1 -1
  231. package/dist/core/session/session-manager.js +29 -2
  232. package/dist/core/session/session-terminal.js +185 -0
  233. package/dist/core/session/session-title.js +8 -11
  234. package/dist/core/{system-session → session/system}/memory.js +43 -9
  235. package/dist/core/{system-session → session/system}/registry.js +1 -1
  236. package/dist/core/{system-session → session/system}/types.js +1 -1
  237. package/dist/core/skill/index-generator.js +1 -0
  238. package/dist/core/task/task-activity-store.js +112 -0
  239. package/dist/core/task/task-recovery-service.js +2 -2
  240. package/dist/core/thread/ipc-operation.js +2 -2
  241. package/dist/core/thread/thread-operation.js +2 -1
  242. package/dist/core/thread/thread-route.js +5 -3
  243. package/dist/core/thread/thread-service.js +14 -4
  244. package/dist/directory/{owner-directory-admission.js → admission.js} +3 -3
  245. package/dist/directory/{owner-directory-cache.js → cache.js} +90 -8
  246. package/dist/directory/{owner-directory-markdown.js → markdown.js} +2 -2
  247. package/dist/directory/{owner-directory-query-operation.js → query-operation.js} +83 -9
  248. package/dist/directory/{owner-directory-search.js → search.js} +50 -2
  249. package/dist/directory/{owner-directory-store.js → store.js} +2 -2
  250. package/dist/eck/kit-renderer.js +1 -1
  251. package/dist/eck/manifest-engine.js +64 -2
  252. package/dist/eck/message-renderer.js +35 -0
  253. package/dist/ecweb/basic-settings-service.js +9 -3
  254. package/dist/{contracts → ecweb/contracts}/ecweb-service-protocol.js +2 -1
  255. package/dist/ecweb/dsh-native-service.js +413 -0
  256. package/dist/ecweb/providers-service.js +1 -1
  257. package/dist/ecweb/runtime/lifecycle.js +1 -1
  258. package/dist/ecweb/runtime/supervisor.js +1 -1
  259. package/dist/event-center/center-config.js +2 -2
  260. package/dist/event-center/dispatcher.js +1 -1
  261. package/dist/event-center/ipc-operation.js +12 -3
  262. package/dist/event-center/pack-loader.js +2 -2
  263. package/dist/event-center/registry.js +6 -6
  264. package/dist/event-center/runtime.js +2 -2
  265. package/dist/index.js +71 -42
  266. package/dist/ipc.js +103 -10
  267. package/dist/outputs/authorization.js +27 -0
  268. package/dist/outputs/events.js +10 -1
  269. package/dist/outputs/panel-cards.js +960 -0
  270. package/dist/paths.js +12 -0
  271. package/dist/pay/command.js +1 -1
  272. package/dist/pay/runtime.js +18 -10
  273. package/dist/response-system/engines/v1/proactive-flow.js +1 -1
  274. package/dist/services/dispatcher.js +2 -2
  275. package/dist/services/host/main.js +10 -1
  276. package/dist/services/host/protocol.js +9 -2
  277. package/dist/services/host/resident.js +37 -0
  278. package/dist/services/host-client.js +12 -0
  279. package/dist/services/host-recycle.js +8 -3
  280. package/dist/services/host-runtime.js +54 -15
  281. package/dist/services/index.js +83 -19
  282. package/dist/services/ipc-operation.js +303 -38
  283. package/dist/services/pack-manager.js +2 -2
  284. package/dist/services/router.js +43 -3
  285. package/dist/services/script-runner.js +34 -25
  286. package/dist/services/service-payload.js +28 -1
  287. package/dist/services/validation.js +28 -2
  288. package/dist/stats/context-usage.js +110 -0
  289. package/dist/stats/model-resolver.js +103 -17
  290. package/dist/stats/query.js +5 -0
  291. package/dist/trigger/application-service.js +3 -2
  292. package/dist/trigger/authorization.js +36 -33
  293. package/dist/trigger/ipc-service.js +4 -4
  294. package/dist/trigger/local-files.js +8 -176
  295. package/dist/trigger/manager.js +2 -2
  296. package/dist/trigger/parser.js +48 -0
  297. package/dist/trigger/scheduler.js +14 -2
  298. package/dist/trigger/script-executor.js +21 -0
  299. package/dist/trigger/script-sandbox.js +57 -243
  300. package/dist/trigger/system-definitions.js +25 -0
  301. package/dist/trigger/validation.js +1 -1
  302. package/dist/utils/atomic-write.js +88 -1
  303. package/dist/utils/cross-platform.js +4 -42
  304. package/dist/utils/error-dict.json +22 -1
  305. package/dist/utils/error-utils.js +193 -6
  306. package/dist/utils/evolcore-version.js +2 -2
  307. package/dist/utils/host-info.js +1 -1
  308. package/dist/utils/logger.js +3 -1
  309. package/dist/utils/media-cache.js +99 -4
  310. package/dist/utils/startup-trace.js +20 -4
  311. package/dist/utils/welcome.js +64 -20
  312. package/ecagent/README.md +35 -0
  313. package/ecagent/dist/agent-loop.js +80 -30
  314. package/ecagent/dist/harness/env/nodejs.d.ts +16 -0
  315. package/ecagent/dist/harness/env/nodejs.js +49 -20
  316. package/ecagent/dist/harness/messages.js +3 -2
  317. package/ecagent/dist/harness/types.d.ts +1 -0
  318. package/ecagent/dist/runtime/types.d.ts +2 -0
  319. package/ecagent/dist/runtime/utils/validation.d.ts +7 -1
  320. package/ecagent/dist/runtime/utils/validation.js +42 -0
  321. package/ecagent/dist/types.d.ts +2 -0
  322. package/kits/docs/INDEX.md +1 -1
  323. package/kits/docs/channels/feishu.md +1 -1
  324. package/kits/docs/evolcore/INDEX.md +10 -7
  325. package/kits/docs/evolcore/agent-create.md +2 -0
  326. package/kits/docs/evolcore/agent.md +100 -13
  327. package/kits/docs/evolcore/aid.md +19 -3
  328. package/kits/docs/evolcore/config.md +94 -0
  329. package/kits/docs/evolcore/ctl.md +2 -1
  330. package/kits/docs/evolcore/ec-capabilities.md +7 -10
  331. package/kits/docs/evolcore/ecweb-lifecycle.md +5 -1
  332. package/kits/docs/evolcore/event.md +1 -1
  333. package/kits/docs/evolcore/fs.md +49 -3
  334. package/kits/docs/evolcore/group.md +3 -3
  335. package/kits/docs/evolcore/memory-consolidation.md +1 -1
  336. package/kits/docs/evolcore/menu-protocol.md +24 -2
  337. package/kits/docs/evolcore/model.md +9 -1
  338. package/kits/docs/evolcore/msg.md +30 -28
  339. package/kits/docs/evolcore/pay.md +8 -20
  340. package/kits/docs/evolcore/plugin.md +74 -0
  341. package/kits/docs/evolcore/provider.md +8 -2
  342. package/kits/docs/evolcore/rpc.md +2 -2
  343. package/kits/docs/evolcore/skill.md +17 -1
  344. package/kits/docs/evolcore/stats.md +5 -0
  345. package/kits/docs/evolcore/storage.md +22 -0
  346. package/kits/docs/evolcore/thread-chain.md +19 -10
  347. package/kits/docs/evolcore/tool-authorization.md +4 -0
  348. package/kits/docs/evolcore/trigger.md +89 -13
  349. package/kits/docs/identity/AID_PROFILE_SPEC.md +1 -1
  350. package/kits/docs/venues/feishu-group.md +3 -2
  351. package/kits/docs/venues/feishu-private.md +3 -2
  352. package/kits/rules/02-navigation.md +20 -13
  353. package/kits/rules/06-channel.md +18 -2
  354. package/kits/schemas/_meta.json +8 -4
  355. package/kits/schemas/agent-config.schema.23.json +19 -3
  356. package/kits/schemas/agent-config.schema.24.json +986 -0
  357. package/kits/schemas/agent-config.schema.25.json +986 -0
  358. package/kits/schemas/daemon.schema.11.json +487 -0
  359. package/kits/schemas/daemon.schema.12.json +505 -0
  360. package/kits/schemas/defaults.schema.8.json +484 -0
  361. package/kits/schemas/providers.schema.1.json +1 -1
  362. package/kits/schemas/providers.schema.2.json +1 -1
  363. package/kits/schemas/providers.schema.3.json +8 -2
  364. package/kits/skills/.switches.json +4 -0
  365. package/kits/skills/ability/SKILL.md +194 -27
  366. package/kits/skills/ability/STRUCTURE.md +5 -0
  367. package/kits/skills/agent-output-cards/SKILL.md +90 -54
  368. package/kits/skills/agent-output-cards/examples/html-surface.json +11 -0
  369. package/kits/skills/agent-output-cards/examples/meeting-followups.json +16 -0
  370. package/kits/skills/agent-output-cards/examples/meeting-latest.json +24 -0
  371. package/kits/skills/agent-output-cards/examples/project-metrics.json +16 -0
  372. package/kits/skills/agent-output-cards/examples/quick-links.json +18 -0
  373. package/kits/skills/agent-output-cards/examples/surface.html +8 -0
  374. package/kits/skills/agent-template-project/SKILL.md +51 -0
  375. package/kits/skills/agent-template-project/references/01-collect-and-pack.md +174 -0
  376. package/kits/skills/agent-template-project/references/02-upload-and-share.md +109 -0
  377. package/kits/skills/agent-template-project/references/03-download-and-install.md +189 -0
  378. package/kits/skills/agent-template-project/references/04-upgrade-and-recovery.md +74 -0
  379. package/kits/skills/agent-template-project/references/05-publish-to-platform.md +62 -0
  380. package/kits/skills/ec-group/SKILL.md +3 -3
  381. package/kits/skills/ec-group-collaboration/SKILL.md +4 -4
  382. package/kits/skills/ec-identity/SKILL.md +9 -6
  383. package/kits/skills/ec-pay/SKILL.md +163 -41
  384. package/kits/skills/ec-provider/SKILL.md +5 -5
  385. package/kits/skills/ec-service-call/SKILL.md +3 -0
  386. package/kits/skills/ec-skill/SKILL.md +25 -9
  387. package/kits/skills/ec-skill/scripts/cli.mjs +7 -7
  388. package/kits/skills/ec-skill/scripts/skill.mjs +55 -41
  389. package/kits/skills/ec-skill/scripts/template/SKILL.md.tmpl +9 -0
  390. package/kits/skills/ec-trigger/SKILL.md +2 -2
  391. package/kits/skills/personal-assistant/SKILL.md +22 -22
  392. package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +1 -1
  393. package/kits/skills/scrapling-article-fetch/SKILL.md +5 -5
  394. package/kits/skills/thread-ops/SKILL.md +19 -9
  395. package/kits/skills/wechat-article-media-download/SKILL.md +2 -2
  396. package/kits/skills/wechat-article-reader/SKILL.md +2 -2
  397. package/kits/templates/system-fragments/commands.md +1 -1
  398. package/kits/templates/system-fragments/personal-assistant.md +2 -2
  399. package/kits/templates/system-fragments/reply.md +14 -9
  400. package/kits/templates/system-fragments/session.md +1 -1
  401. package/kits/templates/system-fragments/thread.md +10 -5
  402. package/package.json +6 -5
  403. package/scripts/agent-template/index.mjs +7 -1
  404. package/scripts/agent-template/inspect.mjs +81 -35
  405. package/scripts/agent-template/overlay.mjs +110 -4
  406. package/scripts/agent-template/shared/common.mjs +36 -4
  407. package/scripts/agent-template/shared/plan.mjs +4 -2
  408. package/scripts/agent-template/shared/service-packs.mjs +104 -0
  409. package/scripts/agent-template/shared/team-schema.json +467 -54
  410. package/scripts/agent-template/shared/template-contract.mjs +70 -68
  411. package/scripts/agent-template/shared/template-package.mjs +153 -36
  412. package/scripts/agent-template/shared/template-runtime.mjs +76 -64
  413. package/scripts/agent-template/shared/template.mjs +11 -46
  414. package/scripts/agent-template/team-pack.mjs +451 -35
  415. package/scripts/agent-template/team-preview.mjs +75 -226
  416. package/scripts/aid-batch/identity-batch.mjs +1 -1
  417. package/dist/agents/baseagent-availability.js +0 -176
  418. package/dist/agents/baseagent-capability-adapter.js +0 -102
  419. package/dist/agents/baseagent-plugin-loader.js +0 -145
  420. package/dist/agents/baseagent.js +0 -816
  421. package/dist/agents/codex/catalog.js +0 -80
  422. package/dist/agents/ecagent-plugin-lazy.js +0 -41
  423. package/dist/agents/tool-time-context.js +0 -55
  424. package/dist/core/legacy-rename.js +0 -41
  425. package/dist/core/plugin-lifecycle.js +0 -137
  426. package/dist/core/rate-window.js +0 -53
  427. package/dist/core/runner-reload-transaction.js +0 -60
  428. package/dist/core/runtime-lock.js +0 -90
  429. package/dist/core/soul.js +0 -66
  430. package/dist/core/system-session/grants.js +0 -40
  431. package/dist/directory/owner-directory-agentmd-sync.js +0 -89
  432. package/dist/directory/owner-directory-request-operation.js +0 -79
  433. package/dist/directory/owner-directory-text.js +0 -60
  434. package/kits/skills/ec-pay/references/pay-cli.md +0 -110
  435. /package/dist/agents/gemini/{gemini-capability-provider.js → capability-provider.js} +0 -0
  436. /package/dist/agents/gemini/{gemini-session-file-adapter.js → session-file-adapter.js} +0 -0
  437. /package/dist/{agents/claude-gateway → claude-gateway}/types.js +0 -0
  438. /package/dist/core/{system-channels.js → channel/system-channels.js} +0 -0
  439. /package/dist/core/{daemon-file-cache.js → daemon/daemon-file-cache.js} +0 -0
  440. /package/dist/core/{event-bus.js → event/event-bus.js} +0 -0
  441. /package/dist/core/{event-catalog.js → event/event-catalog.js} +0 -0
  442. /package/dist/core/{pack-ledger.js → pack/pack-ledger.js} +0 -0
  443. /package/dist/directory/{owner-directory-identity.js → identity.js} +0 -0
  444. /package/dist/directory/{owner-directory-policy.js → policy.js} +0 -0
  445. /package/dist/directory/{owner-directory-remarks.js → remarks.js} +0 -0
  446. /package/dist/directory/{owner-directory-scope.js → scope.js} +0 -0
  447. /package/dist/{contracts → ecweb/contracts}/ecweb-instance.js +0 -0
  448. /package/kits/templates/{bootstrap-welcome.md → bootstrap-intro.md} +0 -0
@@ -2,34 +2,33 @@ import path from 'node:path';
2
2
  import { resolveAunSendDevice } from '../../aun/ability-device-routing.js';
3
3
  import crypto from 'crypto';
4
4
  import { authorizeDelegatedAunMsgSend, delegationFailureDetailCode, hasTrustedFullAccessDelegation, hashDelegatedCommandArgv, } from '../auth/agent-delegation.js';
5
- import { formatChannelKey, tryParseChannelKey } from '../channel-loader.js';
5
+ import { formatChannelKey, tryParseChannelKey } from '../channel/channel-loader.js';
6
6
  import { AUN_HANDOFF_MARKER_FIELD } from '../../channels/aun.js';
7
7
  import { classifyAunPayloadForLog } from './message-log.js';
8
8
  import { isValidAunDeliveryForChannel } from './outbound.js';
9
9
  import { isHClassPath } from '../permission/protected-paths.js';
10
10
  import { normalizeAunMentionEntries, withAunAttention } from '../../aun/msg/mention-schema.js';
11
11
  import { resolveManagedSendArgv } from '../../cli/aun-commands.js';
12
- import { readTriggerLocalFile, resolveAttachmentLocalPath } from '../../trigger/local-files.js';
12
+ import { readMessageLocalFile, resolveAttachmentLocalPath } from '../permission/managed-file.js';
13
13
  import { TriggerDefinitionManager } from '../../trigger/manager.js';
14
- import { normalizeGroupAid, sameGroupAid } from '../../aun/group/identity.js';
14
+ import { sameGroupAid } from '../../aun/group/identity.js';
15
15
  import { resolveThreadRouteTarget } from '../thread/thread-route.js';
16
16
  import { isMainSessionThreadId, isTopicThreadId, parseMainTopicId, safeFormatMainTopicId, sessionLocalTopicId, } from '../thread/topic-id.js';
17
17
  import { ThreadService } from '../thread/thread-service.js';
18
18
  import { diagLog } from '../../utils/msg-diag.js';
19
19
  import { buildEnvelope, DEFAULT_NOOP_SENTINEL } from './message-utils.js';
20
20
  import { sessionTopicThreadId } from '../thread/topic-id.js';
21
- import { getAunRequestRegistry, requestDiagnostics, requestTtlSeconds } from './aun-request-registry.js';
21
+ import { getAunRequestRegistry, redactAbilityCredentials, requestDiagnostics, requestTtlSeconds } from './aun-request-registry.js';
22
22
  import { canonicalizeEvolcoreCommandArgv, parseJsonObjectArgument } from '../permission/ec-command-parser.js';
23
- import { formatPeerKey, parsePeerKey, readAunPeerKind, resolveAunPeerKind } from '../relation/peer-identity.js';
23
+ import { PeerIdentityCache, formatPeerKey, parsePeerKey, readAunPeerKind, resolveAunPeerKind } from '../relation/peer-identity.js';
24
24
  import { logger } from '../../utils/logger.js';
25
25
  import { MESSAGE_CLI_BIN, MAIN_CLI_BIN } from '../../product.js';
26
26
  import { parseRemoteCommand } from '../../ability/caller/command.js';
27
- import { buildDownstreamArgv, expandGroupBase, parseGatewayArgs } from '../../cli/ecmsg-gateway.js';
27
+ import { buildDownstreamArgv, parseGatewayArgs } from '../../cli/ecmsg-gateway.js';
28
28
  import { resolveSendRoute } from './send-routing.js';
29
29
  import { agentDir } from '../../paths.js';
30
30
  import { chatDirPath, readAllJsonlLines } from '../session/session-fs-store.js';
31
- import { prepareContactThreadDelegation, finishContactThreadDelegation, findContactThreadReturn } from './contact-thread-approval.js';
32
- import { currentContactBinding } from './contact-admission.js';
31
+ import { prepareContactThreadDelegation, finishContactThreadDelegation } from './contact-thread-approval.js';
33
32
  const TASK_ID_MESSAGE_PAYLOAD_TYPES = new Set(['text', 'link', 'image', 'video', 'voice', 'file']);
34
33
  const TOPIC_SOURCE_MESSAGE_TYPES = new Set(['text', 'link', 'image', 'video', 'voice', 'file', 'action_card', 'widget_card']);
35
34
  /** Stamp the actual runtime source before handoff/outbox persistence, including retries. */
@@ -228,11 +227,21 @@ async function applyManagedCrossThreadSendEffects(input) {
228
227
  : ThreadService.findMainSessionEntry(input.selfAid, input.targetChannelId);
229
228
  const originThreadName = originEntry?.name || (originThreadId || originPeer);
230
229
  const originPeerName = originEntry?.peerName || originPeer;
231
- // 来源话题对端的主体类型:运行时上下文是唯一来源;伪对端不写。
230
+ // 来源话题对端的主体类型:以身份缓存(agent.md 快照)为准,按来源对端 AID 查。
231
+ // 复查唤醒建出的话题会话 peerType 兜底成 'system'(feedback.ts),但 peerId 是真实对端,
232
+ // 只按 trigger:/bg: 前缀过滤会把 'system' 写进信封;运行时取值仅作兜底,且排除 'system'。
232
233
  const originPeerType = (() => {
234
+ try {
235
+ const cached = PeerIdentityCache.get('aun', originPeer, agentDir(input.selfAid));
236
+ if (cached && cached.source !== 'unknown' && cached.type)
237
+ return cached.type;
238
+ }
239
+ catch {
240
+ // 缓存不可读时退回运行时取值
241
+ }
233
242
  const type = String(input.runtime?.peerType ?? '').trim();
234
243
  const peerId = String(input.runtime?.peerId ?? '');
235
- if (!type || peerId.startsWith('trigger:') || peerId.startsWith('bg:'))
244
+ if (!type || type === 'system' || peerId.startsWith('trigger:') || peerId.startsWith('bg:'))
236
245
  return undefined;
237
246
  return type;
238
247
  })();
@@ -480,8 +489,15 @@ async function deliverSelfAddressed(input) {
480
489
  logger.warn('[AUN] self-dispatch role unresolved; falling back to visitor');
481
490
  enqueueRole = 'visitor';
482
491
  }
492
+ // 历史话题可能建立时没有绑定项目,projectPath 为空;直接用空值入队会被
493
+ // MessageQueue 拒绝,消息已发出却没进本机队列。按来源任务或 agent 配置兜底。
494
+ const projectPath = String(session.projectPath ?? '').trim()
495
+ || String(input.fallbackProjectPath ?? '').trim();
496
+ if (!projectPath) {
497
+ return { deliveryError: `enqueue failed: session ${session.id} has no project path` };
498
+ }
483
499
  try {
484
- await input.messageQueue.enqueue(session.id, message, session.projectPath, {
500
+ await input.messageQueue.enqueue(session.id, message, projectPath, {
485
501
  interruptible: false,
486
502
  agentName: params.aid,
487
503
  ...(enqueueRole ? { role: enqueueRole } : {}),
@@ -547,18 +563,6 @@ async function resolveGatewaySend(argv, grant, runtime, session) {
547
563
  || (currentChatType !== 'private' && currentChatType !== 'group')) {
548
564
  throw Object.assign(new Error('Current AUN conversation route is unavailable'), { code: 'AUN_OUTBOUND_ROUTE_REQUIRED' });
549
565
  }
550
- // An unqualified report to Owner continues its unique originating delegation.
551
- // Explicit --thread always wins; unrelated conversations keep normal routing.
552
- let returningToOrigin = false;
553
- if (options.thread === undefined && options.to
554
- && normalizeAid(options.to) === currentContactBinding(grant.selfAid)?.owner_aid) {
555
- const origin = findContactThreadReturn({ selfAid: grant.selfAid, grant, runtime });
556
- if (origin) {
557
- options.thread = origin.originThreadId;
558
- options.checkEvery ??= 'none';
559
- returningToOrigin = true;
560
- }
561
- }
562
566
  const resolveKind = async (target) => {
563
567
  if (normalizeAid(target) === normalizeAid(currentPeer))
564
568
  return currentChatType;
@@ -576,10 +580,6 @@ async function resolveGatewaySend(argv, grant, runtime, session) {
576
580
  }
577
581
  };
578
582
  const kinds = new Map();
579
- if (options.to) {
580
- options.to = expandGroupBase(grant.selfAid, options.to, normalizeGroupAid);
581
- kinds.set(options.to, await resolveKind(options.to));
582
- }
583
583
  const mainPeer = options.thread ? parseMainTopicId(options.thread) : undefined;
584
584
  if (mainPeer) {
585
585
  const peer = mainPeer.aidA === grant.selfAid ? mainPeer.aidB : mainPeer.aidA;
@@ -591,7 +591,6 @@ async function resolveGatewaySend(argv, grant, runtime, session) {
591
591
  return entry ? { threadId: entry.threadId, selfAid: grant.selfAid,
592
592
  peer: { channelType: entry.channelType ?? 'aun', peerKind: entry.peerKind, id: entry.peer } } : undefined;
593
593
  },
594
- resolveTarget: id => ({ channelType: 'aun', peerKind: kinds.get(id) ?? 'private', id }),
595
594
  resolvePeerKind: id => kinds.get(id),
596
595
  mainSessionExists: peer => !!ThreadService.findMainSessionEntry(grant.selfAid, peer.id),
597
596
  resolveLastTopicEncrypt: threadId => {
@@ -604,6 +603,7 @@ async function resolveGatewaySend(argv, grant, runtime, session) {
604
603
  },
605
604
  };
606
605
  const route = resolveSendRoute({ ...options,
606
+ selfMode: options.selfMode === true,
607
607
  encrypt: options.encrypt,
608
608
  inboundTriggered: runtime.inboundEncrypted !== undefined,
609
609
  inboundEncrypted: runtime.inboundEncrypted === true, }, {
@@ -612,11 +612,9 @@ async function resolveGatewaySend(argv, grant, runtime, session) {
612
612
  }, deps);
613
613
  if (!route.ok)
614
614
  throw Object.assign(new Error(route.message), { code: route.code });
615
- if (returningToOrigin)
616
- route.source.thread = 'derived';
617
615
  return { route, argv: buildDownstreamArgv(route, text, passthrough) };
618
616
  }
619
- export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegationRegistry, responseEngine, handoffRuntime, sessionManager, messageQueue, createCrossThreadReviewTrigger, }) {
617
+ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegationRegistry, responseEngine, handoffRuntime, sessionManager, messageQueue, resolveAgentProjectPath, createCrossThreadReviewTrigger, }) {
620
618
  const getRequest = async (params, abilityGrant) => {
621
619
  if (!params.sessionId || !params.delegationToken) {
622
620
  return { ok: false, code: 'DELEGATION_REQUIRED', error: 'Request queries require an active delegated session' };
@@ -656,7 +654,7 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
656
654
  });
657
655
  if (!permitted.ok)
658
656
  return { ok: false, code: permitted.code, error: permitted.reason };
659
- return request ? { ok: true, request: request }
657
+ return request ? { ok: true, request: (request.responseCorrelation ? redactAbilityCredentials(request) : request) }
660
658
  : { ok: false, code: 'REQUEST_NOT_FOUND', error: `request not found: ${params.requestId}` };
661
659
  };
662
660
  ipcServer.setAunRequestGetExecutor(params => getRequest(params));
@@ -721,10 +719,14 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
721
719
  catch (error) {
722
720
  return { ok: false, code: error.code ?? 'INVALID_ARGUMENT', error: error instanceof Error ? error.message : String(error) };
723
721
  }
722
+ const isSystemEvent = params.trustedSystemEvent === true
723
+ && params.payload?.type === 'event' && params.payload.event === 'topic.renamed';
724
+ // 改名事件只同步元数据,不读取或重建托管任务上下文。
724
725
  // 活跃任务走内存上下文;调试会话(--as-session)和已结束的会话没有内存记录,
725
726
  // 这时从会话本身重建,否则跨话题复查会静默不创建(getTaskRuntimeContext 返回 null)。
726
- let runtime = params.originSessionId ? responseEngine.getTaskRuntimeContext(params.originSessionId) : undefined;
727
- if (!runtime && params.originSessionId && sessionManager) {
727
+ let runtime = !isSystemEvent && params.originSessionId
728
+ ? responseEngine.getTaskRuntimeContext(params.originSessionId) : undefined;
729
+ if (!isSystemEvent && !runtime && params.originSessionId && sessionManager) {
728
730
  try {
729
731
  const session = await sessionManager.getSessionById(params.originSessionId);
730
732
  if (session) {
@@ -757,11 +759,18 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
757
759
  }
758
760
  // 话题引用解析:`threadRef` 是调用方写的原值(可能是主话题 id),
759
761
  // `threadRoute` 非空即"这是跨话题发送"——与话题 id 是否为空无关。
762
+ // `--selfmode` 是结构化标记:收件人必须是本端。网关已经保证,这里兜住
763
+ // 手工构造的 IPC 请求,避免把一条「委托」误当成「自派」。
764
+ if (params.selfMode === true && !selfAddressed) {
765
+ return { ok: false, code: 'INVALID_ARGUMENT', error: '--selfmode requires the local AID as recipient' };
766
+ }
760
767
  const threadRef = params.thread;
761
768
  const threadRoute = threadRef
762
769
  ? resolveThreadRouteTarget(params.aid, threadRef, params.scope, params.to, { allowSelfTarget: selfAddressed })
763
770
  : undefined;
764
- if (threadRef && !threadRoute) {
771
+ // 首次联系:主话题的会话还不存在,投递侧(handoff)会随本条消息建立。
772
+ // 除此之外,带 --thread 却解析不到话题都是错误。
773
+ if (threadRef && !threadRoute && gatewayRoute?.firstContact !== true) {
765
774
  return { ok: false, code: 'TOPIC_NOT_FOUND', error: `话题不存在或不属于目标对端: ${threadRef}` };
766
775
  }
767
776
  // Topic lookup also restores the current topic; cross-topic side effects
@@ -775,12 +784,62 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
775
784
  ? threadRef
776
785
  : (safeFormatMainTopicId(params.aid, threadRoute.peer) ?? threadRef))
777
786
  : gatewayRoute?.threadId;
778
- const isSystemEvent = params.trustedSystemEvent === true
779
- && params.payload?.type === 'event' && params.payload.event === 'topic.renamed';
787
+ const inst = channelInstances.find((candidate) => {
788
+ if (candidate.channelType !== 'aun')
789
+ return false;
790
+ const ch = candidate.channel;
791
+ try {
792
+ const aidState = typeof ch?.getAidState === 'function' ? ch.getAidState() : null;
793
+ if (aidState?.aid === params.aid)
794
+ return true;
795
+ if (typeof ch?.getAid === 'function' && ch.getAid() === params.aid)
796
+ return true;
797
+ }
798
+ catch { /* ignore */ }
799
+ return false;
800
+ });
801
+ const ch = inst?.channel;
802
+ // `auto` 沿用业务消息的入站加密状态;无任务上下文的系统事件按主动发送处理。
803
+ const encrypt = typeof params.encrypt === 'boolean'
804
+ ? params.encrypt
805
+ : params.encrypt === 'auto'
806
+ ? runtime?.inboundEncrypted === true
807
+ : (typeof ch?.getDefaultEncrypt === 'function' ? ch.getDefaultEncrypt() : false);
808
+ if (isSystemEvent) {
809
+ const payload = params.payload;
810
+ const data = payload.data && typeof payload.data === 'object' && !Array.isArray(payload.data)
811
+ ? payload.data : undefined;
812
+ if (!threadRoute || (threadRoute.channelType ?? 'aun') !== 'aun' || selfAddressed
813
+ || !(isTopicThreadId(threadRef) || typeof threadRef === 'string' && parseMainTopicId(threadRef))
814
+ || payload.thread_id !== threadRef || data?.schema_version !== 1
815
+ || typeof data.name !== 'string' || !data.name.trim()
816
+ || typeof data.name_updated_at !== 'number' || !Number.isFinite(data.name_updated_at)
817
+ || payload.occurred_at !== data.name_updated_at
818
+ || params.argv !== undefined || params.file || params.deviceId || params.returnPolicy === 'required') {
819
+ return { ok: false, code: 'INVALID_SYSTEM_EVENT', error: 'Invalid topic.renamed event or target', sent: false };
820
+ }
821
+ if (!ch) {
822
+ return { ok: false, code: 'AUN_CHANNEL_NOT_FOUND', error: `AUN channel not found for ${params.aid}` };
823
+ }
824
+ if (params.scope === 'group' ? typeof ch.sendDaemonGroupMsg !== 'function' : typeof ch.sendDaemonMsg !== 'function') {
825
+ return { ok: false, code: params.scope === 'group' ? 'AUN_GROUP_UNSUPPORTED' : 'AUN_MSG_UNSUPPORTED',
826
+ error: `AUN channel does not support daemon ${params.scope === 'group' ? 'group' : 'private'} sends` };
827
+ }
828
+ // 此标记仅由进程内 ThreadSystemMsgSender 注入,公共 IPC 不接收。
829
+ // 发送后直接返回渠道回执,不进入 handoff、inbox 或复查业务。
830
+ const diagnostic = { aid: params.aid, from: params.aid, to: params.to,
831
+ text: classifyAunPayloadForLog(payload).content };
832
+ diagLog('aun_out', diagnostic);
833
+ const sent = params.scope === 'group'
834
+ ? await ch.sendDaemonGroupMsg({ groupId: params.to, payload, encrypt })
835
+ : await ch.sendDaemonMsg({ to: params.to, payload, encrypt });
836
+ if (sent.ok && sent.message_id)
837
+ diagLog('send_ok', { ...diagnostic, msgId: sent.message_id });
838
+ return sent;
839
+ }
780
840
  // 非托管跨话题自派:调用方没有委托凭证,用本机 controlToken 证明「本机控制面调用」。
781
841
  // 只有「跨话题自派 + 会话级 msg 发送」走这条,其余(含一切发给对端的发送)仍必须走委托链。
782
- const localSelfSend = !isSystemEvent
783
- && params.localControl === true
842
+ const localSelfSend = params.localControl === true
784
843
  && selfAddressed
785
844
  && params.scope === 'msg'
786
845
  && !params.originSessionId;
@@ -815,7 +874,6 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
815
874
  scope: params.scope,
816
875
  action: params.file ? 'file' : 'send',
817
876
  threadRouted: authorizationTargetRouted,
818
- isSystemEvent,
819
877
  });
820
878
  if (!delegation.ok) {
821
879
  return {
@@ -827,7 +885,7 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
827
885
  ...(delegation.sent === false ? { sent: false } : {}),
828
886
  };
829
887
  }
830
- const fullAccess = !!delegation.grant && hasTrustedFullAccessDelegation(delegation.grant);
888
+ const fullAccess = hasTrustedFullAccessDelegation(delegation.grant);
831
889
  try {
832
890
  const fileScope = runtime?.projectPath && delegation.grant
833
891
  ? { selfAid: delegation.grant.selfAid, projectPath: runtime.projectPath,
@@ -837,13 +895,13 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
837
895
  if ((textFile || payloadFile || params.file) && !fileScope)
838
896
  throw new Error('Current task project context is unavailable');
839
897
  if (textFile) {
840
- const text = new TextDecoder('utf-8', { fatal: true }).decode(readTriggerLocalFile(textFile, fileScope));
898
+ const text = new TextDecoder('utf-8', { fatal: true }).decode(readMessageLocalFile(textFile, fileScope));
841
899
  if (!text || text.includes('\0'))
842
900
  throw new Error('Message file must contain nonempty UTF-8 text');
843
901
  params.payload = { type: 'text', text };
844
902
  }
845
903
  if (payloadFile) {
846
- const raw = new TextDecoder('utf-8', { fatal: true }).decode(readTriggerLocalFile(payloadFile, fileScope));
904
+ const raw = new TextDecoder('utf-8', { fatal: true }).decode(readMessageLocalFile(payloadFile, fileScope));
847
905
  params.payload = parseJsonObjectArgument(raw, '--payload-file');
848
906
  }
849
907
  if (params.file) {
@@ -862,8 +920,12 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
862
920
  : safeFormatMainTopicId(params.aid, gatewayRoute.peer.id);
863
921
  const payloadThread = params.payload?.thread_id;
864
922
  const expectedThread = isTopicThreadId(gatewayRoute.threadId) ? gatewayRoute.threadId : undefined;
923
+ // 自派一律是发给本端的 msg;委托按话题对端类型选 scope。
924
+ const expectedScope = gatewayRoute.recipient === 'self'
925
+ ? 'msg'
926
+ : (gatewayRoute.peer.peerKind === 'group' ? 'group' : 'msg');
865
927
  if (params.aid !== gatewayRoute.self || params.to !== gatewayRoute.recipientId
866
- || params.scope !== (gatewayRoute.peer.peerKind === 'group' ? 'group' : 'msg')
928
+ || params.scope !== expectedScope
867
929
  || topicId !== gatewayRoute.threadId
868
930
  || (payloadThread !== undefined && payloadThread !== expectedThread)) {
869
931
  throw Object.assign(new Error('Message recipient or topic conflicts with the resolved send route'), {
@@ -879,34 +941,9 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
879
941
  error: error instanceof Error ? error.message : String(error),
880
942
  };
881
943
  }
882
- const inst = channelInstances.find((candidate) => {
883
- if (candidate.channelType !== 'aun')
884
- return false;
885
- const ch = candidate.channel;
886
- try {
887
- const aidState = typeof ch?.getAidState === 'function' ? ch.getAidState() : null;
888
- if (aidState?.aid === params.aid)
889
- return true;
890
- if (typeof ch?.getAid === 'function' && ch.getAid() === params.aid)
891
- return true;
892
- }
893
- catch { /* ignore */ }
894
- return false;
895
- });
896
- const ch = inst?.channel;
897
944
  if (!ch) {
898
945
  return { ok: false, error: `AUN channel not found for ${params.aid}`, code: 'AUN_CHANNEL_NOT_FOUND' };
899
946
  }
900
- // The IPC command already carries the caller-selected transport scope.
901
- // Never reclassify the target by parsing its AID string: a private AID may
902
- // look group-like and a group identifier may use a future format.
903
- // `auto` 不能在本层塌成渠道默认值:它要求「被对端消息触发时沿用该消息的
904
- // 加密状态,否则明文」。入站态只有处理这条消息的一侧知道,从这里取。
905
- const encrypt = typeof params.encrypt === 'boolean'
906
- ? params.encrypt
907
- : params.encrypt === 'auto'
908
- ? runtime?.inboundEncrypted === true
909
- : (typeof ch.getDefaultEncrypt === 'function' ? ch.getDefaultEncrypt() : false);
910
947
  let payload = params.payload;
911
948
  // 文件发送成功构造 payload 后,在这里留下归档路径文案,供后面写历史时使用。
912
949
  let archivedFileLog = null;
@@ -950,9 +987,9 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
950
987
  && typeof payload.type === 'string' && TASK_ID_MESSAGE_PAYLOAD_TYPES.has(payload.type)) {
951
988
  payload = { ...payload, task_id: runtime.taskId };
952
989
  }
953
- // 托管 argv 通道(runManagedSend)先前不带 log 元数据:群聊 sendDaemonGroupMsg
954
- // 自身会写日志,私聊 sendDaemonMsg 只在 args.log 存在时才写,于是同一份
955
- // `ec msg send` 在私聊下不落 messages.jsonl,话题历史里查不到已发出的消息。
990
+ // 托管 argv 通道(ecmsg 经 daemon 发送)不带 log 元数据:群聊 sendDaemonGroupMsg
991
+ // 自身会写日志,私聊 sendDaemonMsg 只在 args.log 存在时才写,于是私聊的
992
+ // 托管发送不落 messages.jsonl,话题历史里查不到已发出的消息。
956
993
  // 这里在 payload 定型后按同一套规则补出日志元数据,让两条路径记账一致。
957
994
  if (params.argv !== undefined && params.log === undefined) {
958
995
  const classified = classifyAunPayloadForLog(payload);
@@ -1197,7 +1234,7 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
1197
1234
  }
1198
1235
  }
1199
1236
  const debug = await resolveOutboundDebug(sessionId => responseEngine.getOutboundDebug(sessionId), params.originSessionId);
1200
- // 主动发送路径(ecmsg send / ec msg send / ec group send)不经过
1237
+ // 主动发送路径(ecmsg send)不经过
1201
1238
  // deliverTextEntry,出站诊断需要在这里单独打点,否则 diag 里查不到 agent 手发的消息。
1202
1239
  const diagText = params.log?.content ?? classifyAunPayloadForLog(payload).content;
1203
1240
  const diagCommon = {
@@ -1309,6 +1346,7 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
1309
1346
  encrypted: encrypt,
1310
1347
  originThreadId: runtime?.threadId,
1311
1348
  originPeer: runtime?.peerId,
1349
+ fallbackProjectPath: runtime?.projectPath || resolveAgentProjectPath?.(params.aid),
1312
1350
  });
1313
1351
  if (delivered.deliveryError)
1314
1352
  sent.self_delivery_error = delivered.deliveryError;
@@ -1344,8 +1382,9 @@ export function registerAunIpcSender({ ipcServer, channelInstances, agentDelegat
1344
1382
  ipcServer.setAbilityRequestSender?.(async (params, originGrant) => {
1345
1383
  try {
1346
1384
  // This is a daemon-only API, not a public IPC flag or a payload-type
1347
- // exemption. Retain and verify the approved remote command itself.
1348
- if (hashDelegatedCommandArgv([MAIN_CLI_BIN, ...params.argv]) !== params.delegationCommandHash) {
1385
+ // exemption. Retain the approved execution spec as well as argv, so
1386
+ // bounded-output/cd-prefixed approvals use the same v2 hash as IPC.
1387
+ if (hashDelegatedCommandArgv([MAIN_CLI_BIN, ...params.argv], params.executionSpec) !== params.delegationCommandHash) {
1349
1388
  return { ok: false, code: 'INVALID_DELEGATION', error: 'Ability command hash mismatch', sent: false };
1350
1389
  }
1351
1390
  const command = parseRemoteCommand(params.argv);
@@ -4,8 +4,16 @@ import crypto from 'crypto';
4
4
  import { StringDecoder } from 'node:string_decoder';
5
5
  import { resolvePaths } from '../../paths.js';
6
6
  import { appendJsonlDurable } from '../session/session-fs-store.js';
7
- import { isAidWideAbilityQuery } from '../../aun/ability-device-routing.js';
7
+ import { isAbilityDiscoveryQuery } from '../../aun/ability-device-routing.js';
8
8
  import { validateAbilityResult } from '../../ability/interop-v1.js';
9
+ /** Remove standard Ability credential fields from durable request history. */
10
+ export function redactAbilityCredentials(value) {
11
+ if (Array.isArray(value))
12
+ return value.map(redactAbilityCredentials);
13
+ if (!value || typeof value !== 'object')
14
+ return value;
15
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, key === 'credential' ? '[redacted]' : redactAbilityCredentials(item)]));
16
+ }
9
17
  export function requestDiagnostics(record) {
10
18
  const ignoredReason = record.lastIgnoredResponse?.reason;
11
19
  const unresolved = record.state !== 'completed' && record.state !== 'failed';
@@ -128,7 +136,7 @@ export class AunRequestRegistry {
128
136
  persist(record) {
129
137
  const file = requestFile(record.selfAid);
130
138
  fs.mkdirSync(path.dirname(file), { recursive: true });
131
- appendJsonlDurable(file, { event: 'upsert', record });
139
+ appendJsonlDurable(file, { event: 'upsert', record: record.responseCorrelation ? redactAbilityCredentials(record) : record });
132
140
  this.records.set(this.key(record.selfAid, record.requestId), record);
133
141
  for (const alias of record.correlationKeys)
134
142
  this.records.set(this.key(record.selfAid, alias), record);
@@ -152,7 +160,7 @@ export class AunRequestRegistry {
152
160
  const fd = fs.openSync(staged, 'wx', 0o600);
153
161
  try {
154
162
  for (const record of this.recordsFor(selfAid))
155
- fs.writeSync(fd, JSON.stringify({ event: 'upsert', record }) + '\n');
163
+ fs.writeSync(fd, JSON.stringify({ event: 'upsert', record: record.responseCorrelation ? redactAbilityCredentials(record) : record }) + '\n');
156
164
  fs.fsyncSync(fd);
157
165
  }
158
166
  finally {
@@ -220,7 +228,7 @@ export class AunRequestRegistry {
220
228
  updatedAt: now,
221
229
  deadlineAt: now + collectionMs,
222
230
  ...(abilityCorrelation ? { responseCorrelation: abilityCorrelation } : {}),
223
- ...(!params.targetDeviceId && isAidWideAbilityQuery(params.payload) ? {
231
+ ...(!params.targetDeviceId && isAbilityDiscoveryQuery(params.payload) ? {
224
232
  responseMode: 'all_devices',
225
233
  responses: [],
226
234
  } : {}),
@@ -303,7 +311,7 @@ export class AunRequestRegistry {
303
311
  if (expected) {
304
312
  // Match EvolApp's caller: encrypted private transport is required.
305
313
  // Generic requests keep their existing transport semantics.
306
- if (params.encrypted !== true || params.transport !== 'p2p')
314
+ if (params.encrypted !== true || params.transport !== 'p2p' || !stringValue(params.fromDeviceId))
307
315
  continue;
308
316
  try {
309
317
  // EvolApp replay ACKs can omit ability_path; terminal results must
@@ -1,7 +1,7 @@
1
1
  import path from 'path';
2
2
  import { readGroupHistoryContext } from '../../aun/group/history.js';
3
3
  import { getPackageRoot } from '../../paths.js';
4
- import { createErrorCapturingReader, fileCache } from '../daemon-file-cache.js';
4
+ import { createErrorCapturingReader, fileCache } from '../daemon/daemon-file-cache.js';
5
5
  import { logger } from '../../utils/logger.js';
6
6
  const MAX_HISTORY_MESSAGES = 20;
7
7
  const MAX_HISTORY_MESSAGE_CHARS = 800;
@@ -7,7 +7,7 @@ import { atomicWriteJson } from '../../utils/atomic-write.js';
7
7
  import { isValidAid } from '../../aun/aid/validation.js';
8
8
  import { readAccessPolicy } from '../../config/access-policy.js';
9
9
  import { resolvePeerView } from '../../config/peer-book.js';
10
- import { readOwnerDirectoryMembership } from '../../directory/owner-directory-admission.js';
10
+ import { readOwnerDirectoryMembership } from '../../directory/admission.js';
11
11
  import { ownerResolver } from '../ownership/owner-resolver.js';
12
12
  import { isProcessRunning } from '../../utils/cross-platform.js';
13
13
  export const CONTACT_EVENT_TTL_MS = 3 * 24 * 60 * 60 * 1000;
@@ -301,6 +301,25 @@ export class IMRenderer {
301
301
  getFinalText() {
302
302
  return this.allText;
303
303
  }
304
+ /**
305
+ * 取走尚未发出的正文并清空,供被抢占回合的收尾补投使用。
306
+ *
307
+ * 只交出正文:模型输出过就已经进入上下文,丢掉的只能是投递,不是内容本身。
308
+ * 已发出的部分不再重复(sentContent 为真时 allText 里仍含已发段落,故用待发 buffer)。
309
+ */
310
+ drainUnsentText() {
311
+ // proactive 下正文不走 textBuffer:终稿被扣在 pendingProactiveFinal 里等提交,
312
+ // 打断时同样会连同整轮一起丢掉,这里一并取走。
313
+ const deferred = [
314
+ ...this.deferredProactiveText.map(item => item.text),
315
+ ...(this.pendingProactiveFinal ? [this.pendingProactiveFinal.item.text] : []),
316
+ ].join('\n');
317
+ const interactive = this.textBuffer.trim().length > 0
318
+ ? this.textBuffer
319
+ : this.itemsQueue.filter(it => it.kind === 'text').map(it => it.text).join('');
320
+ this.discardPending();
321
+ return interactive.trim().length > 0 ? interactive : deferred;
322
+ }
304
323
  /** 丢弃当前 attempt 的未发送内容;用于命中可重试错误后避免把瞬时错误文本发给用户。 */
305
324
  discardPending() {
306
325
  if (this.timer) {
@@ -1,9 +1,9 @@
1
- import { logger } from '../utils/logger.js';
1
+ import { logger } from '../../utils/logger.js';
2
2
  import crypto from 'node:crypto';
3
3
  import path from 'node:path';
4
- import { agentDataDir } from '../paths.js';
5
- import { atomicRead, atomicWriteJson, withFileLock } from '../utils/atomic-write.js';
6
- import { MAX_WIDGET_VALUES_BYTES } from '../aun/msg/upload.js';
4
+ import { agentDataDir } from '../../paths.js';
5
+ import { atomicRead, atomicWriteJson, withFileLock } from '../../utils/atomic-write.js';
6
+ import { MAX_WIDGET_VALUES_BYTES } from '../../aun/msg/upload.js';
7
7
  function widgetCardFile(selfAid, messageId) {
8
8
  const key = crypto.createHash('sha256').update(messageId).digest('hex');
9
9
  return path.join(agentDataDir(selfAid), 'aun', 'widget-cards', `${key}.json`);
@@ -23,23 +23,23 @@ function formatItem(item) {
23
23
  case 'tool_call': {
24
24
  const desc = item.text || summarizeArgs(item.arguments);
25
25
  if (!desc)
26
- return `🔧 ${item.name}`;
26
+ return item.name;
27
27
  // 多行 desc(如 Edit diff):第一行跟工具名同行,代码块从新行开始
28
28
  if (desc.includes('\n')) {
29
29
  const nlIdx = desc.indexOf('\n');
30
- return `🔧 ${item.name} ${desc.slice(0, nlIdx)}\n${desc.slice(nlIdx + 1)}`;
30
+ return `${item.name} ${desc.slice(0, nlIdx)}\n${desc.slice(nlIdx + 1)}`;
31
31
  }
32
- return `🔧 ${item.name}: ${desc}`;
32
+ return `${item.name}: ${desc}`;
33
33
  }
34
34
  case 'tool_result': {
35
35
  if (!item.ok) {
36
36
  const errMsg = item.error || (typeof item.result === 'string' ? item.result : '执行失败');
37
37
  return `⚠️ ${item.name}: ${capChars(errMsg, 200)}`;
38
38
  }
39
- return item.text ? `✓ ${item.name}: ${item.text}` : `✓ ${item.name}`;
39
+ return item.text ? `${item.name}: ${item.text}` : item.name;
40
40
  }
41
41
  case 'progress':
42
- return `⏳ ${item.text}`;
42
+ return item.text;
43
43
  case 'notice':
44
44
  return item.severity === 'warn' ? `⚠️ ${item.text}` : item.text;
45
45
  case 'summary':
@@ -1,7 +1,7 @@
1
1
  import { readAccessPolicy, } from '../../config/access-policy.js';
2
2
  import { resolvePeerView, resolvePrincipal, } from '../../config/peer-book.js';
3
3
  import { isValidAid } from '../../aun/aid/validation.js';
4
- import { readOwnerDirectoryMembership } from '../../directory/owner-directory-admission.js';
4
+ import { readOwnerDirectoryMembership } from '../../directory/admission.js';
5
5
  import { evaluateAppContactAdmission } from './contact-admission.js';
6
6
  /** @deprecated Ordinary outbound messages have no contact admission gate. */
7
7
  export async function evaluateOutboundContactAdmission(input) {