@zhin.js/agent 1.1.8 → 1.1.10

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 (673) hide show
  1. package/README.md +15 -23
  2. package/lib/activity-feedback/adapter-integration.d.ts +1 -2
  3. package/lib/activity-feedback/adapter-integration.d.ts.map +1 -1
  4. package/lib/activity-feedback/adapter-integration.js +46 -18
  5. package/lib/activity-feedback/adapter-integration.js.map +1 -1
  6. package/lib/assistant/index.d.ts +1 -1
  7. package/lib/assistant/index.d.ts.map +1 -1
  8. package/lib/assistant/index.js +1 -1
  9. package/lib/assistant/index.js.map +1 -1
  10. package/lib/assistant/job-creator.d.ts +0 -7
  11. package/lib/assistant/job-creator.d.ts.map +1 -1
  12. package/lib/assistant/job-creator.js +1 -12
  13. package/lib/assistant/job-creator.js.map +1 -1
  14. package/lib/builtin/five-agent/index.d.ts +6 -3
  15. package/lib/builtin/five-agent/index.d.ts.map +1 -1
  16. package/lib/builtin/five-agent/index.js +6 -4
  17. package/lib/builtin/five-agent/index.js.map +1 -1
  18. package/lib/builtin/five-agent/prompts.d.ts +3 -3
  19. package/lib/builtin/five-agent/prompts.d.ts.map +1 -1
  20. package/lib/builtin/five-agent/prompts.js +3 -3
  21. package/lib/builtin/five-agent/prompts.js.map +1 -1
  22. package/lib/builtin/five-agent/role-capability-policy.d.ts +9 -0
  23. package/lib/builtin/five-agent/role-capability-policy.d.ts.map +1 -0
  24. package/lib/builtin/five-agent/role-capability-policy.js +22 -0
  25. package/lib/builtin/five-agent/role-capability-policy.js.map +1 -0
  26. package/lib/builtin/five-agent/roles.d.ts +5 -0
  27. package/lib/builtin/five-agent/roles.d.ts.map +1 -0
  28. package/lib/builtin/five-agent/roles.js +12 -0
  29. package/lib/builtin/five-agent/roles.js.map +1 -0
  30. package/lib/builtin/generate-image-tool.d.ts +1 -1
  31. package/lib/builtin/generate-image-tool.d.ts.map +1 -1
  32. package/lib/builtin/generate-image-tool.js +3 -3
  33. package/lib/builtin/generate-image-tool.js.map +1 -1
  34. package/lib/builtin/orchestration-tools.d.ts.map +1 -1
  35. package/lib/builtin/orchestration-tools.js +12 -38
  36. package/lib/builtin/orchestration-tools.js.map +1 -1
  37. package/lib/builtin/spawn-task-tool.js +2 -2
  38. package/lib/builtin/spawn-task-tool.js.map +1 -1
  39. package/lib/builtins/builtin-tool-service.d.ts +28 -0
  40. package/lib/builtins/builtin-tool-service.d.ts.map +1 -0
  41. package/lib/builtins/builtin-tool-service.js +63 -0
  42. package/lib/builtins/builtin-tool-service.js.map +1 -0
  43. package/lib/config/agent-interfaces.d.ts +2 -2
  44. package/lib/config/agent-interfaces.d.ts.map +1 -1
  45. package/lib/config/fix-ai-config.d.ts.map +1 -1
  46. package/lib/config/fix-ai-config.js +1 -38
  47. package/lib/config/fix-ai-config.js.map +1 -1
  48. package/lib/config/index.d.ts +1 -1
  49. package/lib/config/index.d.ts.map +1 -1
  50. package/lib/config/index.js +1 -1
  51. package/lib/config/index.js.map +1 -1
  52. package/lib/config/resolve-five-agent-binding.d.ts +10 -0
  53. package/lib/config/resolve-five-agent-binding.d.ts.map +1 -0
  54. package/lib/config/resolve-five-agent-binding.js +31 -0
  55. package/lib/config/resolve-five-agent-binding.js.map +1 -0
  56. package/lib/config/zhin-agent-config.d.ts +4 -0
  57. package/lib/config/zhin-agent-config.d.ts.map +1 -1
  58. package/lib/config/zhin-agent-defaults.d.ts.map +1 -1
  59. package/lib/config/zhin-agent-defaults.js +2 -0
  60. package/lib/config/zhin-agent-defaults.js.map +1 -1
  61. package/lib/context/context-system.d.ts +2 -2
  62. package/lib/context/context-system.d.ts.map +1 -1
  63. package/lib/context/context-system.js +2 -3
  64. package/lib/context/context-system.js.map +1 -1
  65. package/lib/context/context-tail-limit.d.ts +0 -2
  66. package/lib/context/context-tail-limit.d.ts.map +1 -1
  67. package/lib/context/context-tail-limit.js +1 -3
  68. package/lib/context/context-tail-limit.js.map +1 -1
  69. package/lib/context/default-builders.d.ts +0 -4
  70. package/lib/context/default-builders.d.ts.map +1 -1
  71. package/lib/context/default-builders.js +0 -14
  72. package/lib/context/default-builders.js.map +1 -1
  73. package/lib/context/envelope-parts.d.ts +0 -1
  74. package/lib/context/envelope-parts.d.ts.map +1 -1
  75. package/lib/context/index.d.ts +2 -2
  76. package/lib/context/index.d.ts.map +1 -1
  77. package/lib/context/index.js +2 -2
  78. package/lib/context/index.js.map +1 -1
  79. package/lib/context/turn-envelope.d.ts +0 -1
  80. package/lib/context/turn-envelope.d.ts.map +1 -1
  81. package/lib/context/turn-envelope.js +0 -2
  82. package/lib/context/turn-envelope.js.map +1 -1
  83. package/lib/core/agent-core-run.js +1 -1
  84. package/lib/core/agent-core-run.js.map +1 -1
  85. package/lib/core/agent-loop-standalone.d.ts +2 -1
  86. package/lib/core/agent-loop-standalone.d.ts.map +1 -1
  87. package/lib/core/agent-loop-standalone.js.map +1 -1
  88. package/lib/core/turn-event-mapper.d.ts +3 -1
  89. package/lib/core/turn-event-mapper.d.ts.map +1 -1
  90. package/lib/core/turn-event-mapper.js +12 -2
  91. package/lib/core/turn-event-mapper.js.map +1 -1
  92. package/lib/event/agent-stream-bus.d.ts +0 -1
  93. package/lib/event/agent-stream-bus.d.ts.map +1 -1
  94. package/lib/event/agent-stream-bus.js.map +1 -1
  95. package/lib/event/publish-agent-stream.js +2 -2
  96. package/lib/event/publish-agent-stream.js.map +1 -1
  97. package/lib/event/turn-event.d.ts +16 -1
  98. package/lib/event/turn-event.d.ts.map +1 -1
  99. package/lib/event/turn-event.js.map +1 -1
  100. package/lib/index.d.ts +23 -21
  101. package/lib/index.d.ts.map +1 -1
  102. package/lib/index.js +13 -15
  103. package/lib/index.js.map +1 -1
  104. package/lib/init/activate-ai-database-storage.d.ts +2 -2
  105. package/lib/init/activate-ai-database-storage.d.ts.map +1 -1
  106. package/lib/init/activate-ai-database-storage.js +1 -3
  107. package/lib/init/activate-ai-database-storage.js.map +1 -1
  108. package/lib/init/define-ai-database-models.d.ts +1 -1
  109. package/lib/init/define-ai-database-models.d.ts.map +1 -1
  110. package/lib/init/define-ai-database-models.js +1 -9
  111. package/lib/init/define-ai-database-models.js.map +1 -1
  112. package/lib/init/runtime-management-commands.d.ts +2 -3
  113. package/lib/init/runtime-management-commands.d.ts.map +1 -1
  114. package/lib/init/runtime-management-commands.js +6 -6
  115. package/lib/init/runtime-management-commands.js.map +1 -1
  116. package/lib/internal/agent-host.d.ts +2 -3
  117. package/lib/internal/agent-host.d.ts.map +1 -1
  118. package/lib/internal/host-types.d.ts +0 -28
  119. package/lib/internal/host-types.d.ts.map +1 -1
  120. package/lib/memory/context-repository-store.js +1 -1
  121. package/lib/memory/context-repository-store.js.map +1 -1
  122. package/lib/memory/memory-system.d.ts +1 -2
  123. package/lib/memory/memory-system.d.ts.map +1 -1
  124. package/lib/memory/memory-system.js +1 -3
  125. package/lib/memory/memory-system.js.map +1 -1
  126. package/lib/orchestrator/bootstrap-executors.d.ts +0 -4
  127. package/lib/orchestrator/bootstrap-executors.d.ts.map +1 -1
  128. package/lib/orchestrator/bootstrap-executors.js +11 -137
  129. package/lib/orchestrator/bootstrap-executors.js.map +1 -1
  130. package/lib/orchestrator/orchestration-mappers.d.ts +1 -1
  131. package/lib/orchestrator/orchestration-mappers.d.ts.map +1 -1
  132. package/lib/orchestrator/orchestration-mappers.js +4 -49
  133. package/lib/orchestrator/orchestration-mappers.js.map +1 -1
  134. package/lib/orchestrator/orchestration-service.d.ts.map +1 -1
  135. package/lib/orchestrator/orchestration-service.js +2 -5
  136. package/lib/orchestrator/orchestration-service.js.map +1 -1
  137. package/lib/orchestrator/orchestration-source.d.ts +5 -0
  138. package/lib/orchestrator/orchestration-source.d.ts.map +1 -0
  139. package/lib/orchestrator/orchestration-source.js +22 -0
  140. package/lib/orchestrator/orchestration-source.js.map +1 -0
  141. package/lib/orchestrator/types.d.ts +9 -0
  142. package/lib/orchestrator/types.d.ts.map +1 -1
  143. package/lib/outbound/send-proactive.d.ts +3 -13
  144. package/lib/outbound/send-proactive.d.ts.map +1 -1
  145. package/lib/outbound/send-proactive.js +1 -53
  146. package/lib/outbound/send-proactive.js.map +1 -1
  147. package/lib/plugin-runtime/agent-host-port.d.ts +12 -3
  148. package/lib/plugin-runtime/agent-host-port.d.ts.map +1 -1
  149. package/lib/plugin-runtime/agent-host-port.js +1 -1
  150. package/lib/plugin-runtime/agent-host-port.js.map +1 -1
  151. package/lib/plugin-runtime/agent-runtime.d.ts +7 -4
  152. package/lib/plugin-runtime/agent-runtime.d.ts.map +1 -1
  153. package/lib/plugin-runtime/agent-runtime.js +3 -2
  154. package/lib/plugin-runtime/agent-runtime.js.map +1 -1
  155. package/lib/plugin-runtime/capability-tools.d.ts.map +1 -1
  156. package/lib/plugin-runtime/capability-tools.js +3 -0
  157. package/lib/plugin-runtime/capability-tools.js.map +1 -1
  158. package/lib/plugin-runtime/deferred-capability-plan.d.ts +1 -0
  159. package/lib/plugin-runtime/deferred-capability-plan.d.ts.map +1 -1
  160. package/lib/plugin-runtime/deferred-capability-plan.js +7 -1
  161. package/lib/plugin-runtime/deferred-capability-plan.js.map +1 -1
  162. package/lib/plugin-runtime/full-agent-turn-engine.d.ts.map +1 -1
  163. package/lib/plugin-runtime/full-agent-turn-engine.js +239 -14
  164. package/lib/plugin-runtime/full-agent-turn-engine.js.map +1 -1
  165. package/lib/plugin-runtime/host-mcp-projection.d.ts.map +1 -1
  166. package/lib/plugin-runtime/host-mcp-projection.js +17 -2
  167. package/lib/plugin-runtime/host-mcp-projection.js.map +1 -1
  168. package/lib/plugin-runtime/schedule-capability-plan.d.ts +20 -0
  169. package/lib/plugin-runtime/schedule-capability-plan.d.ts.map +1 -0
  170. package/lib/plugin-runtime/schedule-capability-plan.js +88 -0
  171. package/lib/plugin-runtime/schedule-capability-plan.js.map +1 -0
  172. package/lib/prompt/assembly.d.ts.map +1 -1
  173. package/lib/prompt/assembly.js +2 -0
  174. package/lib/prompt/assembly.js.map +1 -1
  175. package/lib/prompt/define-agent-prompt-section.d.ts +29 -0
  176. package/lib/prompt/define-agent-prompt-section.d.ts.map +1 -0
  177. package/lib/prompt/define-agent-prompt-section.js +22 -0
  178. package/lib/prompt/define-agent-prompt-section.js.map +1 -0
  179. package/lib/prompt/discover-prompt-sections.d.ts +21 -0
  180. package/lib/prompt/discover-prompt-sections.d.ts.map +1 -0
  181. package/lib/prompt/discover-prompt-sections.js +49 -0
  182. package/lib/prompt/discover-prompt-sections.js.map +1 -0
  183. package/lib/prompt/index.d.ts +10 -1
  184. package/lib/prompt/index.d.ts.map +1 -1
  185. package/lib/prompt/index.js +6 -1
  186. package/lib/prompt/index.js.map +1 -1
  187. package/lib/prompt/prompt-assembly-registry.d.ts +31 -0
  188. package/lib/prompt/prompt-assembly-registry.d.ts.map +1 -0
  189. package/lib/prompt/prompt-assembly-registry.js +56 -0
  190. package/lib/prompt/prompt-assembly-registry.js.map +1 -0
  191. package/lib/prompt/prompt-budget.d.ts +9 -0
  192. package/lib/prompt/prompt-budget.d.ts.map +1 -0
  193. package/lib/prompt/prompt-budget.js +28 -0
  194. package/lib/prompt/prompt-budget.js.map +1 -0
  195. package/lib/prompt/prompt-builder.js +1 -1
  196. package/lib/prompt/prompt-builder.js.map +1 -1
  197. package/lib/prompt/prompt-section-loader.d.ts +27 -0
  198. package/lib/prompt/prompt-section-loader.d.ts.map +1 -0
  199. package/lib/prompt/prompt-section-loader.js +75 -0
  200. package/lib/prompt/prompt-section-loader.js.map +1 -0
  201. package/lib/prompt/system-prompt.d.ts +5 -8
  202. package/lib/prompt/system-prompt.d.ts.map +1 -1
  203. package/lib/prompt/system-prompt.js +159 -78
  204. package/lib/prompt/system-prompt.js.map +1 -1
  205. package/lib/prompt/tokens.d.ts +8 -0
  206. package/lib/prompt/tokens.d.ts.map +1 -0
  207. package/lib/prompt/tokens.js +2 -0
  208. package/lib/prompt/tokens.js.map +1 -0
  209. package/lib/prompt/turn-prompt-profile.d.ts +1 -2
  210. package/lib/prompt/turn-prompt-profile.d.ts.map +1 -1
  211. package/lib/schedule-domain/audit-logger.d.ts +2 -2
  212. package/lib/schedule-domain/audit-logger.d.ts.map +1 -1
  213. package/lib/schedule-domain/execution-domain.d.ts +21 -17
  214. package/lib/schedule-domain/execution-domain.d.ts.map +1 -1
  215. package/lib/schedule-domain/execution-domain.js +41 -23
  216. package/lib/schedule-domain/execution-domain.js.map +1 -1
  217. package/lib/schedule-domain/index.d.ts +0 -1
  218. package/lib/schedule-domain/index.d.ts.map +1 -1
  219. package/lib/schedule-domain/index.js +0 -1
  220. package/lib/schedule-domain/index.js.map +1 -1
  221. package/lib/schedule-domain/prompt-assembler.d.ts +3 -4
  222. package/lib/schedule-domain/prompt-assembler.d.ts.map +1 -1
  223. package/lib/schedule-domain/prompt-assembler.js +0 -16
  224. package/lib/schedule-domain/prompt-assembler.js.map +1 -1
  225. package/lib/schedule-domain/security-harness.d.ts +10 -15
  226. package/lib/schedule-domain/security-harness.d.ts.map +1 -1
  227. package/lib/schedule-domain/security-harness.js +5 -78
  228. package/lib/schedule-domain/security-harness.js.map +1 -1
  229. package/lib/seam/index.d.ts +8 -0
  230. package/lib/seam/index.d.ts.map +1 -0
  231. package/lib/seam/index.js +4 -0
  232. package/lib/seam/index.js.map +1 -0
  233. package/lib/seam/seam-integration.d.ts +46 -0
  234. package/lib/seam/seam-integration.d.ts.map +1 -0
  235. package/lib/seam/seam-integration.js +70 -0
  236. package/lib/seam/seam-integration.js.map +1 -0
  237. package/lib/seam/seam-provider.d.ts +63 -0
  238. package/lib/seam/seam-provider.d.ts.map +1 -0
  239. package/lib/seam/seam-provider.js +66 -0
  240. package/lib/seam/seam-provider.js.map +1 -0
  241. package/lib/seam/skill-service.d.ts +49 -0
  242. package/lib/seam/skill-service.d.ts.map +1 -0
  243. package/lib/seam/skill-service.js +8 -0
  244. package/lib/seam/skill-service.js.map +1 -0
  245. package/lib/seam/tokens.d.ts +8 -0
  246. package/lib/seam/tokens.d.ts.map +1 -0
  247. package/lib/seam/tokens.js +5 -0
  248. package/lib/seam/tokens.js.map +1 -0
  249. package/lib/seam/tool-service.d.ts +58 -0
  250. package/lib/seam/tool-service.d.ts.map +1 -0
  251. package/lib/seam/tool-service.js +8 -0
  252. package/lib/seam/tool-service.js.map +1 -0
  253. package/lib/security/exec-policy.d.ts +2 -0
  254. package/lib/security/exec-policy.d.ts.map +1 -1
  255. package/lib/security/exec-policy.js +21 -0
  256. package/lib/security/exec-policy.js.map +1 -1
  257. package/lib/security/owner-approve-always-store.d.ts +8 -3
  258. package/lib/security/owner-approve-always-store.d.ts.map +1 -1
  259. package/lib/security/owner-approve-always-store.js +160 -173
  260. package/lib/security/owner-approve-always-store.js.map +1 -1
  261. package/lib/security/policy-facade.d.ts.map +1 -1
  262. package/lib/security/policy-facade.js +11 -1
  263. package/lib/security/policy-facade.js.map +1 -1
  264. package/lib/service.d.ts.map +1 -1
  265. package/lib/service.js +0 -7
  266. package/lib/service.js.map +1 -1
  267. package/lib/session/index.d.ts +3 -3
  268. package/lib/session/index.d.ts.map +1 -1
  269. package/lib/session/index.js +3 -3
  270. package/lib/session/index.js.map +1 -1
  271. package/lib/session/passive-group-session.js +1 -1
  272. package/lib/session/session-key.d.ts +4 -0
  273. package/lib/session/session-key.d.ts.map +1 -0
  274. package/lib/session/session-key.js +6 -0
  275. package/lib/session/session-key.js.map +1 -0
  276. package/lib/session/session-system.d.ts.map +1 -1
  277. package/lib/session/session-system.js +4 -4
  278. package/lib/session/session-system.js.map +1 -1
  279. package/lib/session/session-tree-commands.d.ts +2 -3
  280. package/lib/session/session-tree-commands.d.ts.map +1 -1
  281. package/lib/session/session-tree-commands.js +2 -5
  282. package/lib/session/session-tree-commands.js.map +1 -1
  283. package/lib/session/strategies.d.ts +1 -1
  284. package/lib/session/strategies.d.ts.map +1 -1
  285. package/lib/session/strategies.js +2 -2
  286. package/lib/session/strategies.js.map +1 -1
  287. package/lib/skill/skill-registry-as-service.d.ts +29 -0
  288. package/lib/skill/skill-registry-as-service.d.ts.map +1 -0
  289. package/lib/skill/skill-registry-as-service.js +53 -0
  290. package/lib/skill/skill-registry-as-service.js.map +1 -0
  291. package/lib/subagent/im-result-sink.d.ts.map +1 -1
  292. package/lib/subagent/im-result-sink.js +0 -1
  293. package/lib/subagent/im-result-sink.js.map +1 -1
  294. package/lib/subagent-goal-notify.d.ts +0 -9
  295. package/lib/subagent-goal-notify.d.ts.map +1 -1
  296. package/lib/subagent-goal-notify.js +0 -13
  297. package/lib/subagent-goal-notify.js.map +1 -1
  298. package/lib/task-executor.d.ts +14 -3
  299. package/lib/task-executor.d.ts.map +1 -1
  300. package/lib/task-executor.js +48 -61
  301. package/lib/task-executor.js.map +1 -1
  302. package/lib/tool/classic-tool-execution-authority.d.ts.map +1 -1
  303. package/lib/tool/classic-tool-execution-authority.js +4 -3
  304. package/lib/tool/classic-tool-execution-authority.js.map +1 -1
  305. package/lib/tool/prepare-turn-tools.d.ts +0 -2
  306. package/lib/tool/prepare-turn-tools.d.ts.map +1 -1
  307. package/lib/tool/prepare-turn-tools.js +1 -55
  308. package/lib/tool/prepare-turn-tools.js.map +1 -1
  309. package/lib/tool/tool-runtime.d.ts +1 -1
  310. package/lib/tool/tool-runtime.d.ts.map +1 -1
  311. package/lib/turn/auto-continue.js +1 -1
  312. package/lib/turn/auto-continue.js.map +1 -1
  313. package/lib/turn/cancel-intent.d.ts +2 -0
  314. package/lib/turn/cancel-intent.d.ts.map +1 -0
  315. package/lib/turn/cancel-intent.js +5 -0
  316. package/lib/turn/cancel-intent.js.map +1 -0
  317. package/lib/turn/index.d.ts +2 -0
  318. package/lib/turn/index.d.ts.map +1 -1
  319. package/lib/turn/index.js +2 -0
  320. package/lib/turn/index.js.map +1 -1
  321. package/lib/turn/persist-deferred-context.js +1 -1
  322. package/lib/turn/persist-deferred-context.js.map +1 -1
  323. package/lib/turn/persist-subagent-context.js +1 -1
  324. package/lib/turn/persist-subagent-context.js.map +1 -1
  325. package/lib/turn/process-stream.d.ts.map +1 -1
  326. package/lib/turn/process-stream.js +0 -2
  327. package/lib/turn/process-stream.js.map +1 -1
  328. package/lib/turn/prompt-controller.d.ts +2 -0
  329. package/lib/turn/prompt-controller.d.ts.map +1 -1
  330. package/lib/turn/prompt-controller.js +9 -0
  331. package/lib/turn/prompt-controller.js.map +1 -1
  332. package/lib/turn/trigger-cancelled-error.d.ts +10 -0
  333. package/lib/turn/trigger-cancelled-error.d.ts.map +1 -0
  334. package/lib/turn/trigger-cancelled-error.js +19 -0
  335. package/lib/turn/trigger-cancelled-error.js.map +1 -0
  336. package/lib/turn/turn-ingress.d.ts +21 -1
  337. package/lib/turn/turn-ingress.d.ts.map +1 -1
  338. package/lib/turn/turn-ingress.js +29 -0
  339. package/lib/turn/turn-ingress.js.map +1 -1
  340. package/lib/turn/turn-pipeline.d.ts +0 -5
  341. package/lib/turn/turn-pipeline.d.ts.map +1 -1
  342. package/lib/turn/turn-pipeline.js +12 -32
  343. package/lib/turn/turn-pipeline.js.map +1 -1
  344. package/lib/turn/turn-terminal.d.ts.map +1 -1
  345. package/lib/turn/turn-terminal.js +4 -0
  346. package/lib/turn/turn-terminal.js.map +1 -1
  347. package/lib/typing-indicator/adapter-integration.d.ts +1 -2
  348. package/lib/typing-indicator/adapter-integration.d.ts.map +1 -1
  349. package/lib/typing-indicator/adapter-integration.js.map +1 -1
  350. package/lib/typing-indicator/index.d.ts.map +1 -1
  351. package/lib/typing-indicator/index.js +3 -6
  352. package/lib/typing-indicator/index.js.map +1 -1
  353. package/lib/typing-indicator/integration.d.ts +2 -3
  354. package/lib/typing-indicator/integration.d.ts.map +1 -1
  355. package/lib/typing-indicator/integration.js +51 -17
  356. package/lib/typing-indicator/integration.js.map +1 -1
  357. package/lib/zhin-agent/index.d.ts +5 -8
  358. package/lib/zhin-agent/index.d.ts.map +1 -1
  359. package/lib/zhin-agent/index.js +21 -15
  360. package/lib/zhin-agent/index.js.map +1 -1
  361. package/package.json +9 -9
  362. package/lib/aop/index.d.ts +0 -11
  363. package/lib/aop/index.d.ts.map +0 -1
  364. package/lib/aop/index.js +0 -11
  365. package/lib/aop/index.js.map +0 -1
  366. package/lib/aop/pipeline/index.d.ts +0 -12
  367. package/lib/aop/pipeline/index.d.ts.map +0 -1
  368. package/lib/aop/pipeline/index.js +0 -12
  369. package/lib/aop/pipeline/index.js.map +0 -1
  370. package/lib/aop/pipeline/pipeline-flow.d.ts +0 -25
  371. package/lib/aop/pipeline/pipeline-flow.d.ts.map +0 -1
  372. package/lib/aop/pipeline/pipeline-flow.js +0 -115
  373. package/lib/aop/pipeline/pipeline-flow.js.map +0 -1
  374. package/lib/aop/pipeline/pipeline-mode.d.ts +0 -10
  375. package/lib/aop/pipeline/pipeline-mode.d.ts.map +0 -1
  376. package/lib/aop/pipeline/pipeline-mode.js +0 -16
  377. package/lib/aop/pipeline/pipeline-mode.js.map +0 -1
  378. package/lib/aop/pipeline/pipeline-service.d.ts +0 -123
  379. package/lib/aop/pipeline/pipeline-service.d.ts.map +0 -1
  380. package/lib/aop/pipeline/pipeline-service.js +0 -238
  381. package/lib/aop/pipeline/pipeline-service.js.map +0 -1
  382. package/lib/aop/pipeline/pipeline-transitions.d.ts +0 -14
  383. package/lib/aop/pipeline/pipeline-transitions.d.ts.map +0 -1
  384. package/lib/aop/pipeline/pipeline-transitions.js +0 -31
  385. package/lib/aop/pipeline/pipeline-transitions.js.map +0 -1
  386. package/lib/aop/pipeline/ports.d.ts +0 -16
  387. package/lib/aop/pipeline/ports.d.ts.map +0 -1
  388. package/lib/aop/pipeline/ports.js +0 -2
  389. package/lib/aop/pipeline/ports.js.map +0 -1
  390. package/lib/aop/pipeline/role-capability-policy.d.ts +0 -16
  391. package/lib/aop/pipeline/role-capability-policy.d.ts.map +0 -1
  392. package/lib/aop/pipeline/role-capability-policy.js +0 -29
  393. package/lib/aop/pipeline/role-capability-policy.js.map +0 -1
  394. package/lib/aop/runtime/index.d.ts +0 -9
  395. package/lib/aop/runtime/index.d.ts.map +0 -1
  396. package/lib/aop/runtime/index.js +0 -9
  397. package/lib/aop/runtime/index.js.map +0 -1
  398. package/lib/collaboration/collab-admin-gate.d.ts +0 -21
  399. package/lib/collaboration/collab-admin-gate.d.ts.map +0 -1
  400. package/lib/collaboration/collab-admin-gate.js +0 -74
  401. package/lib/collaboration/collab-admin-gate.js.map +0 -1
  402. package/lib/collaboration/collab-utils.d.ts +0 -15
  403. package/lib/collaboration/collab-utils.d.ts.map +0 -1
  404. package/lib/collaboration/collab-utils.js +0 -37
  405. package/lib/collaboration/collab-utils.js.map +0 -1
  406. package/lib/collaboration/collaboration-artifact-repository.d.ts +0 -48
  407. package/lib/collaboration/collaboration-artifact-repository.d.ts.map +0 -1
  408. package/lib/collaboration/collaboration-artifact-repository.js +0 -114
  409. package/lib/collaboration/collaboration-artifact-repository.js.map +0 -1
  410. package/lib/collaboration/collaboration-commands.d.ts +0 -38
  411. package/lib/collaboration/collaboration-commands.d.ts.map +0 -1
  412. package/lib/collaboration/collaboration-commands.js +0 -373
  413. package/lib/collaboration/collaboration-commands.js.map +0 -1
  414. package/lib/collaboration/collaboration-config.d.ts +0 -30
  415. package/lib/collaboration/collaboration-config.d.ts.map +0 -1
  416. package/lib/collaboration/collaboration-config.js +0 -170
  417. package/lib/collaboration/collaboration-config.js.map +0 -1
  418. package/lib/collaboration/collaboration-context.d.ts +0 -15
  419. package/lib/collaboration/collaboration-context.d.ts.map +0 -1
  420. package/lib/collaboration/collaboration-context.js +0 -101
  421. package/lib/collaboration/collaboration-context.js.map +0 -1
  422. package/lib/collaboration/collaboration-db-model.d.ts +0 -350
  423. package/lib/collaboration/collaboration-db-model.d.ts.map +0 -1
  424. package/lib/collaboration/collaboration-db-model.js +0 -112
  425. package/lib/collaboration/collaboration-db-model.js.map +0 -1
  426. package/lib/collaboration/collaboration-delegation.d.ts +0 -21
  427. package/lib/collaboration/collaboration-delegation.d.ts.map +0 -1
  428. package/lib/collaboration/collaboration-delegation.js +0 -221
  429. package/lib/collaboration/collaboration-delegation.js.map +0 -1
  430. package/lib/collaboration/collaboration-dispatch.d.ts +0 -32
  431. package/lib/collaboration/collaboration-dispatch.d.ts.map +0 -1
  432. package/lib/collaboration/collaboration-dispatch.js +0 -93
  433. package/lib/collaboration/collaboration-dispatch.js.map +0 -1
  434. package/lib/collaboration/collaboration-kernel-bridge.d.ts +0 -23
  435. package/lib/collaboration/collaboration-kernel-bridge.d.ts.map +0 -1
  436. package/lib/collaboration/collaboration-kernel-bridge.js +0 -105
  437. package/lib/collaboration/collaboration-kernel-bridge.js.map +0 -1
  438. package/lib/collaboration/collaboration-outbound.d.ts +0 -64
  439. package/lib/collaboration/collaboration-outbound.d.ts.map +0 -1
  440. package/lib/collaboration/collaboration-outbound.js +0 -312
  441. package/lib/collaboration/collaboration-outbound.js.map +0 -1
  442. package/lib/collaboration/collaboration-scene-repository.d.ts +0 -154
  443. package/lib/collaboration/collaboration-scene-repository.d.ts.map +0 -1
  444. package/lib/collaboration/collaboration-scene-repository.js +0 -451
  445. package/lib/collaboration/collaboration-scene-repository.js.map +0 -1
  446. package/lib/collaboration/collaboration-turn-snapshot.d.ts +0 -18
  447. package/lib/collaboration/collaboration-turn-snapshot.d.ts.map +0 -1
  448. package/lib/collaboration/collaboration-turn-snapshot.js +0 -35
  449. package/lib/collaboration/collaboration-turn-snapshot.js.map +0 -1
  450. package/lib/collaboration/delegation-state.d.ts +0 -30
  451. package/lib/collaboration/delegation-state.d.ts.map +0 -1
  452. package/lib/collaboration/delegation-state.js +0 -86
  453. package/lib/collaboration/delegation-state.js.map +0 -1
  454. package/lib/collaboration/endpoint-identity.d.ts +0 -28
  455. package/lib/collaboration/endpoint-identity.d.ts.map +0 -1
  456. package/lib/collaboration/endpoint-identity.js +0 -80
  457. package/lib/collaboration/endpoint-identity.js.map +0 -1
  458. package/lib/collaboration/group-feed.d.ts +0 -30
  459. package/lib/collaboration/group-feed.d.ts.map +0 -1
  460. package/lib/collaboration/group-feed.js +0 -150
  461. package/lib/collaboration/group-feed.js.map +0 -1
  462. package/lib/collaboration/group-message.d.ts +0 -53
  463. package/lib/collaboration/group-message.d.ts.map +0 -1
  464. package/lib/collaboration/group-message.js +0 -101
  465. package/lib/collaboration/group-message.js.map +0 -1
  466. package/lib/collaboration/im-mention-delegate.d.ts +0 -22
  467. package/lib/collaboration/im-mention-delegate.d.ts.map +0 -1
  468. package/lib/collaboration/im-mention-delegate.js +0 -15
  469. package/lib/collaboration/im-mention-delegate.js.map +0 -1
  470. package/lib/collaboration/inbound-peer-handback.d.ts +0 -18
  471. package/lib/collaboration/inbound-peer-handback.d.ts.map +0 -1
  472. package/lib/collaboration/inbound-peer-handback.js +0 -65
  473. package/lib/collaboration/inbound-peer-handback.js.map +0 -1
  474. package/lib/collaboration/inbound-spawn-task.d.ts +0 -29
  475. package/lib/collaboration/inbound-spawn-task.d.ts.map +0 -1
  476. package/lib/collaboration/inbound-spawn-task.js +0 -96
  477. package/lib/collaboration/inbound-spawn-task.js.map +0 -1
  478. package/lib/collaboration/inbound-turn-endpoint.d.ts +0 -16
  479. package/lib/collaboration/inbound-turn-endpoint.d.ts.map +0 -1
  480. package/lib/collaboration/inbound-turn-endpoint.js +0 -26
  481. package/lib/collaboration/inbound-turn-endpoint.js.map +0 -1
  482. package/lib/collaboration/inbound-turn-tools.d.ts +0 -13
  483. package/lib/collaboration/inbound-turn-tools.d.ts.map +0 -1
  484. package/lib/collaboration/inbound-turn-tools.js +0 -24
  485. package/lib/collaboration/inbound-turn-tools.js.map +0 -1
  486. package/lib/collaboration/index.d.ts +0 -21
  487. package/lib/collaboration/index.d.ts.map +0 -1
  488. package/lib/collaboration/index.js +0 -19
  489. package/lib/collaboration/index.js.map +0 -1
  490. package/lib/collaboration/init-observe-hook.d.ts +0 -56
  491. package/lib/collaboration/init-observe-hook.d.ts.map +0 -1
  492. package/lib/collaboration/init-observe-hook.js +0 -168
  493. package/lib/collaboration/init-observe-hook.js.map +0 -1
  494. package/lib/collaboration/init-wizard-service.d.ts +0 -57
  495. package/lib/collaboration/init-wizard-service.d.ts.map +0 -1
  496. package/lib/collaboration/init-wizard-service.js +0 -187
  497. package/lib/collaboration/init-wizard-service.js.map +0 -1
  498. package/lib/collaboration/outbound-resolver.d.ts +0 -37
  499. package/lib/collaboration/outbound-resolver.d.ts.map +0 -1
  500. package/lib/collaboration/outbound-resolver.js +0 -189
  501. package/lib/collaboration/outbound-resolver.js.map +0 -1
  502. package/lib/collaboration/peer-policy.d.ts +0 -29
  503. package/lib/collaboration/peer-policy.d.ts.map +0 -1
  504. package/lib/collaboration/peer-policy.js +0 -118
  505. package/lib/collaboration/peer-policy.js.map +0 -1
  506. package/lib/collaboration/resolve-agent-session-key.d.ts +0 -21
  507. package/lib/collaboration/resolve-agent-session-key.d.ts.map +0 -1
  508. package/lib/collaboration/resolve-agent-session-key.js +0 -61
  509. package/lib/collaboration/resolve-agent-session-key.js.map +0 -1
  510. package/lib/collaboration/runtime-inbound-gate.d.ts +0 -35
  511. package/lib/collaboration/runtime-inbound-gate.d.ts.map +0 -1
  512. package/lib/collaboration/runtime-inbound-gate.js +0 -105
  513. package/lib/collaboration/runtime-inbound-gate.js.map +0 -1
  514. package/lib/collaboration/scene-context.d.ts +0 -17
  515. package/lib/collaboration/scene-context.d.ts.map +0 -1
  516. package/lib/collaboration/scene-context.js +0 -22
  517. package/lib/collaboration/scene-context.js.map +0 -1
  518. package/lib/collaboration/scene-identity-service.d.ts +0 -169
  519. package/lib/collaboration/scene-identity-service.d.ts.map +0 -1
  520. package/lib/collaboration/scene-identity-service.js +0 -479
  521. package/lib/collaboration/scene-identity-service.js.map +0 -1
  522. package/lib/collaboration/scene-service.d.ts +0 -67
  523. package/lib/collaboration/scene-service.d.ts.map +0 -1
  524. package/lib/collaboration/scene-service.js +0 -157
  525. package/lib/collaboration/scene-service.js.map +0 -1
  526. package/lib/collaboration/structured-ai-outbound.d.ts +0 -25
  527. package/lib/collaboration/structured-ai-outbound.d.ts.map +0 -1
  528. package/lib/collaboration/structured-ai-outbound.js +0 -179
  529. package/lib/collaboration/structured-ai-outbound.js.map +0 -1
  530. package/lib/collaboration/turn-plan-resolver.d.ts +0 -17
  531. package/lib/collaboration/turn-plan-resolver.d.ts.map +0 -1
  532. package/lib/collaboration/turn-plan-resolver.js +0 -63
  533. package/lib/collaboration/turn-plan-resolver.js.map +0 -1
  534. package/lib/collaboration/types.d.ts +0 -147
  535. package/lib/collaboration/types.d.ts.map +0 -1
  536. package/lib/collaboration/types.js +0 -16
  537. package/lib/collaboration/types.js.map +0 -1
  538. package/lib/collaboration/wire-collaboration-storage.d.ts +0 -4
  539. package/lib/collaboration/wire-collaboration-storage.d.ts.map +0 -1
  540. package/lib/collaboration/wire-collaboration-storage.js +0 -26
  541. package/lib/collaboration/wire-collaboration-storage.js.map +0 -1
  542. package/lib/config/resolve-pipeline-binding.d.ts +0 -16
  543. package/lib/config/resolve-pipeline-binding.d.ts.map +0 -1
  544. package/lib/config/resolve-pipeline-binding.js +0 -35
  545. package/lib/config/resolve-pipeline-binding.js.map +0 -1
  546. package/lib/discovery/register-agent-surface.d.ts +0 -33
  547. package/lib/discovery/register-agent-surface.d.ts.map +0 -1
  548. package/lib/discovery/register-agent-surface.js +0 -170
  549. package/lib/discovery/register-agent-surface.js.map +0 -1
  550. package/lib/init/create-zhin-agent.d.ts +0 -3
  551. package/lib/init/create-zhin-agent.d.ts.map +0 -1
  552. package/lib/init/create-zhin-agent.js +0 -401
  553. package/lib/init/create-zhin-agent.js.map +0 -1
  554. package/lib/init/register-ai-service.d.ts +0 -7
  555. package/lib/init/register-ai-service.d.ts.map +0 -1
  556. package/lib/init/register-ai-service.js +0 -45
  557. package/lib/init/register-ai-service.js.map +0 -1
  558. package/lib/init/register-builtin-tools.d.ts +0 -3
  559. package/lib/init/register-builtin-tools.d.ts.map +0 -1
  560. package/lib/init/register-builtin-tools.js +0 -411
  561. package/lib/init/register-builtin-tools.js.map +0 -1
  562. package/lib/init/register-capability-features.d.ts +0 -2
  563. package/lib/init/register-capability-features.d.ts.map +0 -1
  564. package/lib/init/register-capability-features.js +0 -28
  565. package/lib/init/register-capability-features.js.map +0 -1
  566. package/lib/init/register-collaboration-commands.d.ts +0 -2
  567. package/lib/init/register-collaboration-commands.d.ts.map +0 -1
  568. package/lib/init/register-collaboration-commands.js +0 -110
  569. package/lib/init/register-collaboration-commands.js.map +0 -1
  570. package/lib/init/register-db-models.d.ts +0 -2
  571. package/lib/init/register-db-models.d.ts.map +0 -1
  572. package/lib/init/register-db-models.js +0 -18
  573. package/lib/init/register-db-models.js.map +0 -1
  574. package/lib/init/register-db-upgrade.d.ts +0 -7
  575. package/lib/init/register-db-upgrade.d.ts.map +0 -1
  576. package/lib/init/register-db-upgrade.js +0 -79
  577. package/lib/init/register-db-upgrade.js.map +0 -1
  578. package/lib/init/register-group-session-passive.d.ts +0 -3
  579. package/lib/init/register-group-session-passive.d.ts.map +0 -1
  580. package/lib/init/register-group-session-passive.js +0 -61
  581. package/lib/init/register-group-session-passive.js.map +0 -1
  582. package/lib/init/register-im-segment-filter.d.ts +0 -2
  583. package/lib/init/register-im-segment-filter.d.ts.map +0 -1
  584. package/lib/init/register-im-segment-filter.js +0 -23
  585. package/lib/init/register-im-segment-filter.js.map +0 -1
  586. package/lib/init/register-init-wizard-guardrail.d.ts +0 -2
  587. package/lib/init/register-init-wizard-guardrail.d.ts.map +0 -1
  588. package/lib/init/register-init-wizard-guardrail.js +0 -41
  589. package/lib/init/register-init-wizard-guardrail.js.map +0 -1
  590. package/lib/init/register-introspection-commands.d.ts +0 -3
  591. package/lib/init/register-introspection-commands.d.ts.map +0 -1
  592. package/lib/init/register-introspection-commands.js +0 -107
  593. package/lib/init/register-introspection-commands.js.map +0 -1
  594. package/lib/init/register-management-tools.d.ts +0 -10
  595. package/lib/init/register-management-tools.d.ts.map +0 -1
  596. package/lib/init/register-management-tools.js +0 -42
  597. package/lib/init/register-management-tools.js.map +0 -1
  598. package/lib/init/register-mcp-from-config.d.ts +0 -2
  599. package/lib/init/register-mcp-from-config.d.ts.map +0 -1
  600. package/lib/init/register-mcp-from-config.js +0 -87
  601. package/lib/init/register-mcp-from-config.js.map +0 -1
  602. package/lib/init/register-orchestrator.d.ts +0 -2
  603. package/lib/init/register-orchestrator.d.ts.map +0 -1
  604. package/lib/init/register-orchestrator.js +0 -15
  605. package/lib/init/register-orchestrator.js.map +0 -1
  606. package/lib/init/register-tool-service.d.ts +0 -2
  607. package/lib/init/register-tool-service.d.ts.map +0 -1
  608. package/lib/init/register-tool-service.js +0 -9
  609. package/lib/init/register-tool-service.js.map +0 -1
  610. package/lib/init/shared-refs.d.ts +0 -14
  611. package/lib/init/shared-refs.d.ts.map +0 -1
  612. package/lib/init/shared-refs.js +0 -7
  613. package/lib/init/shared-refs.js.map +0 -1
  614. package/lib/init/types.d.ts +0 -26
  615. package/lib/init/types.d.ts.map +0 -1
  616. package/lib/init/types.js +0 -7
  617. package/lib/init/types.js.map +0 -1
  618. package/lib/init.d.ts +0 -7
  619. package/lib/init.d.ts.map +0 -1
  620. package/lib/init.js +0 -11
  621. package/lib/init.js.map +0 -1
  622. package/lib/schedule-domain/tool-resolver.d.ts +0 -20
  623. package/lib/schedule-domain/tool-resolver.d.ts.map +0 -1
  624. package/lib/schedule-domain/tool-resolver.js +0 -80
  625. package/lib/schedule-domain/tool-resolver.js.map +0 -1
  626. package/lib/schedule-domain/turn-context.d.ts +0 -9
  627. package/lib/schedule-domain/turn-context.d.ts.map +0 -1
  628. package/lib/schedule-domain/turn-context.js +0 -36
  629. package/lib/schedule-domain/turn-context.js.map +0 -1
  630. package/lib/session/agent-session-host-port.d.ts +0 -23
  631. package/lib/session/agent-session-host-port.d.ts.map +0 -1
  632. package/lib/session/agent-session-host-port.js +0 -61
  633. package/lib/session/agent-session-host-port.js.map +0 -1
  634. package/lib/session/http-agent-session-store.d.ts +0 -76
  635. package/lib/session/http-agent-session-store.d.ts.map +0 -1
  636. package/lib/session/http-agent-session-store.js +0 -211
  637. package/lib/session/http-agent-session-store.js.map +0 -1
  638. package/lib/session/http-approval-adapter.d.ts +0 -11
  639. package/lib/session/http-approval-adapter.d.ts.map +0 -1
  640. package/lib/session/http-approval-adapter.js +0 -19
  641. package/lib/session/http-approval-adapter.js.map +0 -1
  642. package/lib/session/http-approval-waiter.d.ts +0 -11
  643. package/lib/session/http-approval-waiter.d.ts.map +0 -1
  644. package/lib/session/http-approval-waiter.js +0 -61
  645. package/lib/session/http-approval-waiter.js.map +0 -1
  646. package/lib/session/http-session-persistence.d.ts +0 -28
  647. package/lib/session/http-session-persistence.d.ts.map +0 -1
  648. package/lib/session/http-session-persistence.js +0 -60
  649. package/lib/session/http-session-persistence.js.map +0 -1
  650. package/lib/session/http-session-sink.d.ts +0 -11
  651. package/lib/session/http-session-sink.d.ts.map +0 -1
  652. package/lib/session/http-session-sink.js +0 -32
  653. package/lib/session/http-session-sink.js.map +0 -1
  654. package/lib/session/http-step-projector.d.ts +0 -16
  655. package/lib/session/http-step-projector.d.ts.map +0 -1
  656. package/lib/session/http-step-projector.js +0 -118
  657. package/lib/session/http-step-projector.js.map +0 -1
  658. package/lib/session/http-turn-runner.d.ts +0 -16
  659. package/lib/session/http-turn-runner.d.ts.map +0 -1
  660. package/lib/session/http-turn-runner.js +0 -57
  661. package/lib/session/http-turn-runner.js.map +0 -1
  662. package/lib/session/park-controller.d.ts +0 -24
  663. package/lib/session/park-controller.d.ts.map +0 -1
  664. package/lib/session/park-controller.js +0 -58
  665. package/lib/session/park-controller.js.map +0 -1
  666. package/lib/session/resolve-approval-port.d.ts +0 -7
  667. package/lib/session/resolve-approval-port.d.ts.map +0 -1
  668. package/lib/session/resolve-approval-port.js +0 -13
  669. package/lib/session/resolve-approval-port.js.map +0 -1
  670. package/lib/session/session-event-log.d.ts +0 -17
  671. package/lib/session/session-event-log.d.ts.map +0 -1
  672. package/lib/session/session-event-log.js +0 -56
  673. package/lib/session/session-event-log.js.map +0 -1
@@ -1,118 +0,0 @@
1
- /**
2
- * Peer inbound trigger policy — prevent bot-to-bot chat storms.
3
- */
4
- import { isAtEndpoint, readMentionSegmentTarget, segment } from '@zhin.js/core';
5
- import { resolveMemberBySender } from './endpoint-identity.js';
6
- function segmentAtUserId(seg) {
7
- return readMentionSegmentTarget(seg);
8
- }
9
- /** 按消息顺序收集 @ 到的 Cell 成员 endpointKey */
10
- export function resolveCellAtMentionedEndpointKeys(message, cell, root) {
11
- const memberIds = new Set(cell.members.map((m) => m.endpointKey));
12
- const ordered = [];
13
- const fromPeer = isInboundFromCollaborationPeer(message, cell, root);
14
- for (const seg of message.$content) {
15
- const uid = segmentAtUserId(seg);
16
- if (uid && memberIds.has(uid) && !ordered.includes(uid)) {
17
- ordered.push(uid);
18
- continue;
19
- }
20
- // Bot 纯文本里的 @endpoint 是「假 @」,不能触发 peer;仅人类入站才做文本兜底。
21
- if (!fromPeer && seg.type === 'text' && seg.data?.text) {
22
- const text = String(seg.data.text);
23
- for (const id of memberIds) {
24
- const re = new RegExp(`@${id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:\\s|$)`);
25
- if (re.test(text) && !ordered.includes(id))
26
- ordered.push(id);
27
- }
28
- }
29
- }
30
- return ordered;
31
- }
32
- /** @deprecated 使用 resolveCellAtMentionedEndpointKeys;保留首个 @ 以兼容旧调用 */
33
- export function resolveCellAtWinnerEndpointKey(message, cell) {
34
- return resolveCellAtMentionedEndpointKeys(message, cell)[0];
35
- }
36
- /** 同群多 Bot:仅被 @ 的 Cell 成员响应;未 @ 任何成员时不触发 */
37
- export function evaluateCellAtOwnership(message, cell, endpointKey, root) {
38
- if (!cell)
39
- return { shouldHandle: true };
40
- const mentioned = resolveCellAtMentionedEndpointKeys(message, cell, root);
41
- // Delegation ownership is owned by the OrchestrationKernel (ADR 0027):
42
- // active group_mention tasks, not cell.pipelineState. The inbound pipeline
43
- // resolves handback against kernel tasks directly, so this gate is purely
44
- // mention-based.
45
- if (mentioned.length === 0) {
46
- return {
47
- shouldHandle: false,
48
- mentionedEndpointKeys: mentioned,
49
- reason: 'cell_mention_required',
50
- };
51
- }
52
- // Bot 编排消息 @ 多个成员时,只认消息序第一个(防 Planner @all 引发全员响应)
53
- if (mentioned.length > 1 && isInboundFromCollaborationPeer(message, cell, root)) {
54
- const winner = mentioned[0];
55
- if (endpointKey !== winner) {
56
- return {
57
- shouldHandle: false,
58
- mentionedEndpointKeys: mentioned,
59
- reason: 'peer_multi_mention_first_only',
60
- };
61
- }
62
- return { shouldHandle: true, mentionedEndpointKeys: mentioned };
63
- }
64
- if (mentioned.includes(endpointKey)) {
65
- return { shouldHandle: true, mentionedEndpointKeys: mentioned };
66
- }
67
- return {
68
- shouldHandle: false,
69
- mentionedEndpointKeys: mentioned,
70
- reason: 'cell_not_mentioned',
71
- };
72
- }
73
- export function evaluatePeerTrigger(input) {
74
- const { message, cell, peerMode, endpointAtIds, root } = input;
75
- if (!cell) {
76
- return { isPeer: false, shouldTrigger: true };
77
- }
78
- const senderId = String(message.$sender?.id ?? '');
79
- const member = resolveMemberBySender(cell, senderId, root);
80
- if (!member) {
81
- return { isPeer: false, shouldTrigger: true };
82
- }
83
- if (peerMode === 'off') {
84
- return { isPeer: true, peerEndpointKey: member.endpointKey, shouldTrigger: true };
85
- }
86
- if (peerMode === 'mention-only') {
87
- const atSelf = isAtEndpoint(message, endpointAtIds);
88
- // 协作 Cell:peer 仅认真实 at segment,正文假 @ 不触发(与 harness 委派一致)。
89
- if (cell) {
90
- return {
91
- isPeer: true,
92
- peerEndpointKey: member.endpointKey,
93
- shouldTrigger: atSelf,
94
- reason: atSelf ? 'peer_mentioned' : 'peer_mention_required',
95
- };
96
- }
97
- const raw = segment.raw(message.$content).trim();
98
- const atInText = endpointAtIds.some((id) => raw.includes(`@${id}`));
99
- const shouldTrigger = atSelf || atInText;
100
- return {
101
- isPeer: true,
102
- peerEndpointKey: member.endpointKey,
103
- shouldTrigger,
104
- reason: shouldTrigger ? 'peer_mentioned' : 'peer_mention_required',
105
- };
106
- }
107
- return { isPeer: true, peerEndpointKey: member.endpointKey, shouldTrigger: true };
108
- }
109
- /** 入站是否来自同 Cell 的另一 Endpoint(Bot↔Bot 协作,非人类用户) */
110
- export function isInboundFromCollaborationPeer(message, cell, root) {
111
- if (!cell)
112
- return false;
113
- const senderId = String(message.$sender?.id ?? '');
114
- if (!senderId)
115
- return false;
116
- return !!resolveMemberBySender(cell, senderId, root);
117
- }
118
- //# sourceMappingURL=peer-policy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"peer-policy.js","sourceRoot":"","sources":["../../src/collaboration/peer-policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAA6B,YAAY,EAAE,wBAAwB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE3G,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAiB/D,SAAS,eAAe,CAAC,GAAqD;IAC5E,OAAO,wBAAwB,CAAC,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,kCAAkC,CAChD,OAAgB,EAChB,IAAwB,EACxB,IAAa;IAEb,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IAClE,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,8BAA8B,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAErE,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACnC,MAAM,GAAG,GAAG,eAAe,CAAC,GAAuD,CAAC,CAAC;QACrF,IAAI,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAClB,SAAS;QACX,CAAC;QACD,oDAAoD;QACpD,IAAI,CAAC,QAAQ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AAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,OAAO,CAAC,CAAC,qBAAqB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC"}
@@ -1,21 +0,0 @@
1
- /**
2
- * 协作群 Agent 会话 key:按 pipeline run 隔离,避免 reset 后旧 IM 上下文污染新 run。
3
- */
4
- import { type Message } from '@zhin.js/core';
5
- import type { CollaborationScene } from './types.js';
6
- /**
7
- * Agent turn 级 session key SSOT(IM transport + 可选 pipeline run 隔离)。
8
- * passive write / @ drain / auto-continue depth / persist 须共用此函数。
9
- */
10
- export declare function resolveAgentTurnSessionKey(message: Message, cell?: CollaborationScene): string;
11
- /** transport session + 可选 pipeline run 前缀(同 endpoint 不同 run 独立 agent_messages)。 */
12
- export declare function resolveAgentSessionKeyForTurn(message: Message, cell?: CollaborationScene): string;
13
- /** legacy pipeline run 解析(支持前缀);新编排请用 missionRunId / orchestration_status。 */
14
- export declare function resolveArtifactRunId(runRef: string | undefined, cell: CollaborationScene): {
15
- ok: true;
16
- runId: string;
17
- } | {
18
- ok: false;
19
- error: string;
20
- };
21
- //# sourceMappingURL=resolve-agent-session-key.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-agent-session-key.d.ts","sourceRoot":"","sources":["../../src/collaboration/resolve-agent-session-key.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAgBrD;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,kBAAkB,GACxB,MAAM,CAYR;AAED,mFAAmF;AACnF,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,kBAAkB,GACxB,MAAM,CAER;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,IAAI,EAAE,kBAAkB,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAc5D"}
@@ -1,61 +0,0 @@
1
- /**
2
- * 协作群 Agent 会话 key:按 pipeline run 隔离,避免 reset 后旧 IM 上下文污染新 run。
3
- */
4
- import { resolveIMSessionIdFromMessage } from '@zhin.js/core';
5
- import { resolveRunIdRef } from '../aop/pipeline/pipeline-flow.js';
6
- import { readCollaborationTurnSnapshot } from './collaboration-turn-snapshot.js';
7
- import { resolveCollaborationSceneForMessage } from './collaboration-context.js';
8
- import { findActiveDelegation } from './delegation-state.js';
9
- function pipelinePrefixedSessionKey(transport, bindRun) {
10
- return `pipeline:${bindRun.slice(0, 8)}:${transport}`;
11
- }
12
- function resolveBindRunFromCell(cell, endpointKey) {
13
- const runId = cell.pipelineState?.runId;
14
- if (!runId)
15
- return undefined;
16
- const delegation = findActiveDelegation(cell, endpointKey);
17
- return delegation?.runId ?? runId;
18
- }
19
- /**
20
- * Agent turn 级 session key SSOT(IM transport + 可选 pipeline run 隔离)。
21
- * passive write / @ drain / auto-continue depth / persist 须共用此函数。
22
- */
23
- export function resolveAgentTurnSessionKey(message, cell) {
24
- const transport = resolveIMSessionIdFromMessage(message);
25
- const snap = readCollaborationTurnSnapshot(message);
26
- if (snap?.runId) {
27
- const bindRun = snap.delegationRunId ?? snap.runId;
28
- return pipelinePrefixedSessionKey(transport, bindRun);
29
- }
30
- const resolvedCell = cell ?? resolveCollaborationSceneForMessage(message);
31
- if (!resolvedCell)
32
- return transport;
33
- const bindRun = resolveBindRunFromCell(resolvedCell, String(message.$endpoint ?? ''));
34
- if (!bindRun)
35
- return transport;
36
- return pipelinePrefixedSessionKey(transport, bindRun);
37
- }
38
- /** transport session + 可选 pipeline run 前缀(同 endpoint 不同 run 独立 agent_messages)。 */
39
- export function resolveAgentSessionKeyForTurn(message, cell) {
40
- return resolveAgentTurnSessionKey(message, cell);
41
- }
42
- /** legacy pipeline run 解析(支持前缀);新编排请用 missionRunId / orchestration_status。 */
43
- export function resolveArtifactRunId(runRef, cell) {
44
- const state = cell.pipelineState;
45
- if (!state)
46
- return { ok: false, error: 'pipeline 未初始化' };
47
- if (!runRef?.trim())
48
- return { ok: true, runId: state.runId };
49
- const resolved = resolveRunIdRef(runRef.trim(), state);
50
- if (resolved)
51
- return { ok: true, runId: resolved };
52
- if (state.runHistory?.some((h) => h.runId === runRef || h.runId.startsWith(runRef))) {
53
- const match = state.runHistory.find((h) => h.runId === runRef || h.runId.startsWith(runRef));
54
- return { ok: true, runId: match.runId };
55
- }
56
- return {
57
- ok: false,
58
- error: `runId ${runRef} 未找到;legacy pipeline 已弃用,请用 orchestration_status`,
59
- };
60
- }
61
- //# sourceMappingURL=resolve-agent-session-key.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolve-agent-session-key.js","sourceRoot":"","sources":["../../src/collaboration/resolve-agent-session-key.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,6BAA6B,EAAgB,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EAAE,mCAAmC,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,SAAS,0BAA0B,CAAC,SAAiB,EAAE,OAAe;IACpE,OAAO,YAAY,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC;AACxD,CAAC;AAED,SAAS,sBAAsB,CAAC,IAAwB,EAAE,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;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;IACzD,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAC7D,MAAM,QAAQ,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,KAAK,CAAC,CAAC;IACvD,IAAI,QAAQ;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IACnD,IAAI,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACpF,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAE,CAAC;QAC9F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;IAC1C,CAAC;IACD,OAAO;QACL,EAAE,EAAE,KAAK;QACT,KAAK,EAAE,SAAS,MAAM,kDAAkD;KACzE,CAAC;AACJ,CAAC"}
@@ -1,35 +0,0 @@
1
- /**
2
- * Plugin Runtime collaboration inbound gate (no host Plugin / ALS).
3
- * Peer/at ownership + handback + peer dispatch; local turns stay with Agent Host.
4
- */
5
- import type { Message } from '@zhin.js/core';
6
- import type { CollaborationScene, PeerTriggerMode, TurnPlan } from './types.js';
7
- import type { AgentBindingConfig } from '../config/types.js';
8
- export type RuntimeCollaborationInboundResult = {
9
- action: 'skip';
10
- reason: string;
11
- } | {
12
- action: 'done';
13
- reason: string;
14
- } | {
15
- action: 'continue';
16
- cell?: CollaborationScene;
17
- turnPlan: TurnPlan;
18
- };
19
- export interface RuntimeCollaborationInboundInput {
20
- message: Message;
21
- content: string;
22
- peerMode: PeerTriggerMode;
23
- /** Platform @ ids for this endpoint (optional; empty = text/@ segment only). */
24
- endpointAtIds?: string[];
25
- discoveredAgentNames?: Set<string>;
26
- agents?: Record<string, AgentBindingConfig>;
27
- replyAi: (payload: unknown) => Promise<unknown>;
28
- logger: {
29
- debug: (...args: unknown[]) => void;
30
- info: (...args: unknown[]) => void;
31
- warn: (...args: unknown[]) => void;
32
- };
33
- }
34
- export declare function applyRuntimeCollaborationInbound(input: RuntimeCollaborationInboundInput): Promise<RuntimeCollaborationInboundResult>;
35
- //# sourceMappingURL=runtime-inbound-gate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-inbound-gate.d.ts","sourceRoot":"","sources":["../../src/collaboration/runtime-inbound-gate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAQ7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,MAAM,iCAAiC,GACzC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE1E,MAAM,WAAW,gCAAgC;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,eAAe,CAAC;IAC1B,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,oBAAoB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC5C,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,EAAE;QACN,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;QACpC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;QACnC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;KACpC,CAAC;CACH;AAED,wBAAsB,gCAAgC,CACpD,KAAK,EAAE,gCAAgC,GACtC,OAAO,CAAC,iCAAiC,CAAC,CAsH5C"}
@@ -1,105 +0,0 @@
1
- import { formatCompact } from '@zhin.js/logger';
2
- import { findCellForInbound } from './collaboration-config.js';
3
- import { evaluateCellAtOwnership, evaluatePeerTrigger, isInboundFromCollaborationPeer } from './peer-policy.js';
4
- import { tryHandlePeerInboundHandback } from './inbound-peer-handback.js';
5
- import { buildTurnPlan } from './turn-plan-resolver.js';
6
- import { dispatchPeerTask } from './collaboration-dispatch.js';
7
- import { getCollaborationSceneService } from './scene-service.js';
8
- export async function applyRuntimeCollaborationInbound(input) {
9
- const { message, content, peerMode, endpointAtIds = [], discoveredAgentNames = new Set(), agents = {}, replyAi, logger, } = input;
10
- const endpointKey = String(message.$endpoint ?? '');
11
- const cellService = getCollaborationSceneService();
12
- const scope = message.$channel?.type || 'private';
13
- const sceneId = message.$channel?.id ?? '';
14
- let cell = (scope === 'group' || scope === 'channel') && sceneId !== ''
15
- ? findCellForInbound(cellService.listScenes(), String(message.$adapter), String(sceneId), endpointKey)
16
- : undefined;
17
- if (cell) {
18
- const fresh = await cellService.getSceneFresh(cell.id);
19
- if (fresh)
20
- cell = fresh;
21
- }
22
- const peerResult = evaluatePeerTrigger({
23
- message,
24
- cell,
25
- peerMode,
26
- endpointAtIds,
27
- });
28
- if (peerResult.isPeer && !peerResult.shouldTrigger) {
29
- logger.debug(formatCompact({
30
- op: 'skip_peer',
31
- peer: peerResult.peerEndpointKey,
32
- reason: peerResult.reason,
33
- }));
34
- return { action: 'skip', reason: peerResult.reason ?? 'peer_mention_required' };
35
- }
36
- const atOwnership = evaluateCellAtOwnership(message, cell, endpointKey);
37
- if (!atOwnership.shouldHandle) {
38
- logger.debug(formatCompact({
39
- op: 'skip_at_filter',
40
- reason: atOwnership.reason,
41
- endpoint: endpointKey,
42
- }));
43
- return { action: 'skip', reason: atOwnership.reason ?? 'cell_at_filter' };
44
- }
45
- const peerInbound = isInboundFromCollaborationPeer(message, cell);
46
- if (peerInbound && cell && peerResult.peerEndpointKey) {
47
- const handbackDone = await tryHandlePeerInboundHandback({
48
- message,
49
- cell,
50
- peerEndpointKey: peerResult.peerEndpointKey,
51
- replyAi,
52
- logger,
53
- });
54
- if (handbackDone) {
55
- return { action: 'done', reason: 'peer_handback' };
56
- }
57
- }
58
- const turnPlan = buildTurnPlan({
59
- message,
60
- contentText: content,
61
- endpointKey,
62
- endpointKeys: endpointAtIds,
63
- cells: cellService.listScenes(),
64
- agents,
65
- discoveredAgentNames,
66
- });
67
- const peerTarget = turnPlan.delegation?.delegateToPeer ?? turnPlan.delegation?.targetEndpointKey;
68
- if (peerTarget && peerTarget !== endpointKey && cell) {
69
- const delegateText = content.trim() || '请处理上述协作请求。';
70
- try {
71
- const dispatched = await dispatchPeerTask({
72
- cell,
73
- fromEndpointKey: endpointKey,
74
- toEndpointKey: peerTarget,
75
- goal: delegateText,
76
- handlerProfile: turnPlan.handlerProfile,
77
- message,
78
- });
79
- if (dispatched.task.status === 'completed'
80
- || dispatched.task.status === 'waiting_result'
81
- || dispatched.task.status === 'running') {
82
- logger.info(formatCompact({
83
- op: 'peer_dispatch',
84
- task: dispatched.taskId,
85
- from: endpointKey,
86
- to: peerTarget,
87
- }));
88
- return { action: 'done', reason: 'peer_dispatch' };
89
- }
90
- logger.warn(formatCompact({
91
- op: 'peer_dispatch_failed',
92
- task: dispatched.taskId,
93
- error: dispatched.task.error,
94
- }));
95
- }
96
- catch (err) {
97
- logger.warn(formatCompact({
98
- op: 'peer_dispatch_failed',
99
- error: err instanceof Error ? err.message : String(err),
100
- }));
101
- }
102
- }
103
- return { action: 'continue', cell, turnPlan };
104
- }
105
- //# sourceMappingURL=runtime-inbound-gate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-inbound-gate.js","sourceRoot":"","sources":["../../src/collaboration/runtime-inbound-gate.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAChH,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAyBlE,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,KAAuC;IAEvC,MAAM,EACJ,OAAO,EACP,OAAO,EACP,QAAQ,EACR,aAAa,GAAG,EAAE,EAClB,oBAAoB,GAAG,IAAI,GAAG,EAAE,EAChC,MAAM,GAAG,EAAE,EACX,OAAO,EACP,MAAM,GACP,GAAG,KAAK,CAAC;IAEV,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,4BAA4B,EAAE,CA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;gBACvC,OAAO;aACR,CAAC,CAAC;YACH,IACE,UAAU,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW;mBACnC,UAAU,CAAC,IAAI,CAAC,MAAM,KAAK,gBAAgB;mBAC3C,UAAU,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,EACvC,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;oBACxB,EAAE,EAAE,eAAe;oBACnB,IAAI,EAAE,UAAU,CAAC,MAAM;oBACvB,IAAI,EAAE,WAAW;oBACjB,EAAE,EAAE,UAAU;iBACf,CAAC,CAAC,CAAC;gBACJ,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;YACrD,CAAC;YACD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;gBACxB,EAAE,EAAE,sBAAsB;gBAC1B,IAAI,EAAE,UAAU,CAAC,MAAM;gBACvB,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK;aAC7B,CAAC,CAAC,CAAC;QACN,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;gBACxB,EAAE,EAAE,sBAAsB;gBAC1B,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;aACxD,CAAC,CAAC,CAAC;QACN,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAChD,CAAC"}
@@ -1,17 +0,0 @@
1
- /**
2
- * CellContext session key — cross-endpoint coordination projection layer.
3
- * Does not replace transport session keys (per ADR 0023 D4).
4
- */
5
- import type { IMSceneKind } from '@zhin.js/core';
6
- export declare function resolveCollaborationSceneContextKey(adapter: string, sceneId: string): string;
7
- export declare function resolveCollaborationSceneContextKeyFromMessage(message: {
8
- $adapter?: string;
9
- $channel?: {
10
- type?: IMSceneKind;
11
- id?: string;
12
- };
13
- $sender?: {
14
- id?: string;
15
- };
16
- }): string | undefined;
17
- //# sourceMappingURL=scene-context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scene-context.d.ts","sourceRoot":"","sources":["../../src/collaboration/scene-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD,wBAAgB,mCAAmC,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAK5F;AAED,wBAAgB,8CAA8C,CAAC,OAAO,EAAE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,WAAW,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,OAAO,CAAC,EAAE;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3B,GAAG,MAAM,GAAG,SAAS,CAMrB"}
@@ -1,22 +0,0 @@
1
- /**
2
- * CellContext session key — cross-endpoint coordination projection layer.
3
- * Does not replace transport session keys (per ADR 0023 D4).
4
- */
5
- import { getSceneIdentityService } from './scene-identity-service.js';
6
- export function resolveCollaborationSceneContextKey(adapter, sceneId) {
7
- const svc = getSceneIdentityService();
8
- const cell = svc.resolveLogicalScene(adapter, sceneId);
9
- if (cell)
10
- return `collab-scene:${cell.id}`;
11
- return `collab-scene:${String(adapter || 'unknown')}:${String(sceneId || 'unknown')}`;
12
- }
13
- export function resolveCollaborationSceneContextKeyFromMessage(message) {
14
- const scope = message.$channel?.type || 'private';
15
- if (scope !== 'group' && scope !== 'channel')
16
- return undefined;
17
- const sceneId = message.$channel?.id;
18
- if (!sceneId)
19
- return undefined;
20
- return resolveCollaborationSceneContextKey(String(message.$adapter || ''), sceneId);
21
- }
22
- //# sourceMappingURL=scene-context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scene-context.js","sourceRoot":"","sources":["../../src/collaboration/scene-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,UAAU,mCAAmC,CAAC,OAAe,EAAE,OAAe;IAClF,MAAM,GAAG,GAAG,uBAAuB,EAAE,CAAC;IACtC,MAAM,IAAI,GAAG,GAAG,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvD,IAAI,IAAI;QAAE,OAAO,gBAAgB,IAAI,CAAC,EAAE,EAAE,CAAC;IAC3C,OAAO,gBAAgB,MAAM,CAAC,OAAO,IAAI,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,IAAI,SAAS,CAAC,EAAE,CAAC;AACxF,CAAC;AAED,MAAM,UAAU,8CAA8C,CAAC,OAI9D;IACC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,EAAE,IAAI,IAAI,SAAS,CAAC;IAClD,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;IACrC,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,OAAO,mCAAmC,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;AACtF,CAAC"}
@@ -1,169 +0,0 @@
1
- /**
2
- * SceneIdentityService — 逻辑 Cell 解析 + scene_aliases 管理。
3
- *
4
- * 同一物理协作群 = 一个逻辑 Cell + 多 adapter 下的 scene/user 视角表。
5
- * 入站消息通过 `resolveLogicalScene(adapter, sceneId)` 得到逻辑 Cell。
6
- */
7
- import { type CollaborationScene } from './types.js';
8
- import { type GenerationStoreContext } from '@zhin.js/plugin-runtime';
9
- export interface SceneAliasRecord {
10
- logicalSceneId: string;
11
- adapter: string;
12
- sceneId: string;
13
- }
14
- export interface InitSessionRecord {
15
- id: string;
16
- logicalSceneId: string;
17
- plannerEndpointKey: string;
18
- plannerAdapter: string;
19
- plannerSceneId: string;
20
- status: string;
21
- wizardStep: string;
22
- createdAt: number;
23
- updatedAt: number;
24
- }
25
- export interface InitObservationRecord {
26
- sessionId: string;
27
- observerEndpointKey: string;
28
- observerAdapter: string;
29
- observerSceneId: string;
30
- atTargetPlatformId: string;
31
- wizardStep: string;
32
- observedAt: number;
33
- }
34
- export interface MemberChannelRecord {
35
- logicalSceneId: string;
36
- endpointKey: string;
37
- pipelineRole: string;
38
- adapter: string;
39
- sceneId: string;
40
- botId: string;
41
- }
42
- /** 协作群全景图输出格式。 */
43
- export interface GroupViewAgent {
44
- name: string;
45
- channels: Array<{
46
- adapter: string;
47
- scene_id: string;
48
- bot_id: string;
49
- }>;
50
- }
51
- export interface GroupView {
52
- group_id: string;
53
- group_name: string;
54
- agents: GroupViewAgent[];
55
- }
56
- type DbModel = {
57
- select(...fields: string[]): {
58
- where(condition: Record<string, unknown>): Promise<Record<string, unknown>[]>;
59
- };
60
- create(data: Record<string, unknown>): Promise<unknown>;
61
- update(data: Record<string, unknown>): {
62
- where(condition: Record<string, unknown>): Promise<unknown>;
63
- };
64
- delete?(): {
65
- where(condition: Record<string, unknown>): Promise<unknown>;
66
- };
67
- };
68
- export declare class SceneIdentityService {
69
- private sceneModel?;
70
- private sessionModel?;
71
- private observationModel?;
72
- private channelModel?;
73
- private sceneIndex;
74
- private memorySessions;
75
- private memoryObservations;
76
- private memoryChannels;
77
- constructor(sceneModel?: DbModel | undefined, sessionModel?: DbModel | undefined, observationModel?: DbModel | undefined, channelModel?: DbModel | undefined);
78
- private sceneKey;
79
- loadSceneIndex(): Promise<void>;
80
- /**
81
- * 解析逻辑 Cell:先 scene_aliases 表,再 fallback 到 CellService.findByScene。
82
- */
83
- resolveLogicalScene(adapter: string, sceneId: string, endpointKey?: string): CollaborationScene | undefined;
84
- registerSceneAlias(logicalSceneId: string, adapter: string, sceneId: string): Promise<void>;
85
- listAliases(logicalSceneId: string): Promise<SceneAliasRecord[]>;
86
- createInitSession(input: {
87
- id: string;
88
- logicalSceneId: string;
89
- plannerEndpointKey: string;
90
- plannerAdapter: string;
91
- plannerSceneId: string;
92
- }): Promise<InitSessionRecord>;
93
- getActiveInitSession(adapter: string, sceneId: string): Promise<InitSessionRecord | null>;
94
- getInitSession(sessionId: string): Promise<InitSessionRecord | null>;
95
- findActiveInitSessionForScene(adapter: string, sceneId: string): Promise<InitSessionRecord | null>;
96
- listActiveInitSessions(): Promise<InitSessionRecord[]>;
97
- /**
98
- * 入站 bot 查找进行中的 init 向导(stash 阶段)。
99
- * 1. planner 视角 scene 精确匹配
100
- * 2. 已有 observation 来自同一 adapter+scene(跨 bot 复用 session)
101
- * 3. 全局仅一个 wizard session(同物理群跨 adapter 冷启动)
102
- */
103
- findActiveInitSessionForInbound(adapter: string, sceneId: string): Promise<InitSessionRecord | null>;
104
- updateInitSessionStep(sessionId: string, wizardStep: string): Promise<void>;
105
- /**
106
- * CAS 推进向导步骤,避免同一 @ 消息并发处理时连跳两步。
107
- */
108
- advanceInitSessionStepIf(sessionId: string, expectedStep: string, nextStep: string): Promise<boolean>;
109
- updateInitSessionStatus(sessionId: string, status: string, logicalSceneId?: string): Promise<void>;
110
- addObservation(input: {
111
- sessionId: string;
112
- observerEndpointKey: string;
113
- observerAdapter: string;
114
- observerSceneId: string;
115
- atTargetPlatformId: string;
116
- wizardStep: string;
117
- }): Promise<void>;
118
- listObservations(sessionId: string): Promise<InitObservationRecord[]>;
119
- /**
120
- * 从 stash observations 计算 init 计划(不写 Cell / alias / channel)。
121
- */
122
- planInitFromObservations(logicalSceneId: string, observations: InitObservationRecord[], registeredEndpoints: Map<string, {
123
- adapter: string;
124
- endpointKey: string;
125
- }>, options?: {
126
- plannerEndpointKey?: string;
127
- }): {
128
- sceneAliases: SceneAliasRecord[];
129
- members: Array<{
130
- endpointKey: string;
131
- adapter: string;
132
- pipelineRole: string;
133
- }>;
134
- channels: MemberChannelRecord[];
135
- };
136
- /**
137
- * /collab inited 一次性提交:写 scene_aliases + member_channels(Cell 由上层 upsert)。
138
- */
139
- commitInitPlan(input: {
140
- logicalSceneId: string;
141
- sceneAliases: SceneAliasRecord[];
142
- channels: MemberChannelRecord[];
143
- }): Promise<void>;
144
- /** @deprecated 使用 planInitFromObservations + commitInitPlan */
145
- aggregateObservations(sessionId: string, logicalSceneId: string, registeredEndpoints: Map<string, {
146
- adapter: string;
147
- endpointKey: string;
148
- }>): Promise<{
149
- sceneAliases: SceneAliasRecord[];
150
- members: Array<{
151
- endpointKey: string;
152
- adapter: string;
153
- pipelineRole: string;
154
- }>;
155
- channels: MemberChannelRecord[];
156
- }>;
157
- saveMemberChannels(logicalSceneId: string, channels: MemberChannelRecord[]): Promise<void>;
158
- listMemberChannels(logicalSceneId: string): Promise<MemberChannelRecord[]>;
159
- /**
160
- * 构建协作群全景图 — 输出 { group_id, group_name, agents[].channels[] }。
161
- */
162
- buildGroupView(logicalSceneId: string, groupName?: string): Promise<GroupView>;
163
- }
164
- export declare function getSceneIdentityService(): SceneIdentityService;
165
- export declare function provideSceneIdentityService(context: GenerationStoreContext, svc: SceneIdentityService): void;
166
- export declare function setSceneIdentityService(svc: SceneIdentityService | null): void;
167
- export declare function createSceneIdentityService(sceneModel?: DbModel, sessionModel?: DbModel, observationModel?: DbModel, channelModel?: DbModel): SceneIdentityService;
168
- export {};
169
- //# sourceMappingURL=scene-identity-service.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scene-identity-service.d.ts","sourceRoot":"","sources":["../../src/collaboration/scene-identity-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,kBAAkB,EAAkB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAyB,KAAK,sBAAsB,EAAgB,MAAM,yBAAyB,CAAC;AAQ3G,MAAM,WAAW,gBAAgB;IA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