aec-agent 1.0.1 → 1.0.4

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 (557) hide show
  1. package/dist/agent-core.d.ts +123 -3
  2. package/dist/agent-core.d.ts.map +1 -1
  3. package/dist/agent-core.js +219 -23
  4. package/dist/agent-core.js.map +1 -1
  5. package/dist/components/artifact-hub/artifact-hub.d.ts +11 -1
  6. package/dist/components/artifact-hub/artifact-hub.d.ts.map +1 -1
  7. package/dist/components/artifact-hub/artifact-hub.js +21 -1
  8. package/dist/components/artifact-hub/artifact-hub.js.map +1 -1
  9. package/dist/components/channel-platform-hub/adapter-kit.d.ts +51 -0
  10. package/dist/components/channel-platform-hub/adapter-kit.d.ts.map +1 -0
  11. package/dist/components/channel-platform-hub/adapter-kit.js +153 -0
  12. package/dist/components/channel-platform-hub/adapter-kit.js.map +1 -0
  13. package/dist/components/channel-platform-hub/channel-platform-hub.d.ts +34 -0
  14. package/dist/components/channel-platform-hub/channel-platform-hub.d.ts.map +1 -0
  15. package/dist/components/channel-platform-hub/channel-platform-hub.js +52 -0
  16. package/dist/components/channel-platform-hub/channel-platform-hub.js.map +1 -0
  17. package/dist/components/channel-platform-hub/discord/discord-adapter.d.ts +57 -0
  18. package/dist/components/channel-platform-hub/discord/discord-adapter.d.ts.map +1 -0
  19. package/dist/components/channel-platform-hub/discord/discord-adapter.js +412 -0
  20. package/dist/components/channel-platform-hub/discord/discord-adapter.js.map +1 -0
  21. package/dist/components/channel-platform-hub/slack/slack-adapter.d.ts +56 -0
  22. package/dist/components/channel-platform-hub/slack/slack-adapter.d.ts.map +1 -0
  23. package/dist/components/channel-platform-hub/slack/slack-adapter.js +349 -0
  24. package/dist/components/channel-platform-hub/slack/slack-adapter.js.map +1 -0
  25. package/dist/components/channel-platform-hub/slack/slack-mrkdwn.d.ts +3 -0
  26. package/dist/components/channel-platform-hub/slack/slack-mrkdwn.d.ts.map +1 -0
  27. package/dist/components/channel-platform-hub/slack/slack-mrkdwn.js +70 -0
  28. package/dist/components/channel-platform-hub/slack/slack-mrkdwn.js.map +1 -0
  29. package/dist/components/channel-platform-hub/teams/teams-adapter.d.ts +51 -0
  30. package/dist/components/channel-platform-hub/teams/teams-adapter.d.ts.map +1 -0
  31. package/dist/components/channel-platform-hub/teams/teams-adapter.js +333 -0
  32. package/dist/components/channel-platform-hub/teams/teams-adapter.js.map +1 -0
  33. package/dist/components/channel-platform-hub/telegram/telegram-adapter.d.ts +46 -0
  34. package/dist/components/channel-platform-hub/telegram/telegram-adapter.d.ts.map +1 -0
  35. package/dist/components/channel-platform-hub/telegram/telegram-adapter.js +304 -0
  36. package/dist/components/channel-platform-hub/telegram/telegram-adapter.js.map +1 -0
  37. package/dist/components/channel-platform-hub/telegram/telegram-markdown.d.ts +3 -0
  38. package/dist/components/channel-platform-hub/telegram/telegram-markdown.d.ts.map +1 -0
  39. package/dist/components/channel-platform-hub/telegram/telegram-markdown.js +87 -0
  40. package/dist/components/channel-platform-hub/telegram/telegram-markdown.js.map +1 -0
  41. package/dist/components/channel-platform-hub/types.d.ts +290 -0
  42. package/dist/components/channel-platform-hub/types.d.ts.map +1 -0
  43. package/dist/components/channel-platform-hub/types.js +23 -0
  44. package/dist/components/channel-platform-hub/types.js.map +1 -0
  45. package/dist/components/event-handler/event-dispatcher.d.ts +28 -3
  46. package/dist/components/event-handler/event-dispatcher.d.ts.map +1 -1
  47. package/dist/components/event-handler/event-dispatcher.js +77 -13
  48. package/dist/components/event-handler/event-dispatcher.js.map +1 -1
  49. package/dist/components/event-handler/events.d.ts +316 -15
  50. package/dist/components/event-handler/events.d.ts.map +1 -1
  51. package/dist/components/event-handler/events.js +94 -2
  52. package/dist/components/event-handler/events.js.map +1 -1
  53. package/dist/components/event-handler/types.d.ts +26 -0
  54. package/dist/components/event-handler/types.d.ts.map +1 -1
  55. package/dist/components/group-hub/group-hub.d.ts +117 -0
  56. package/dist/components/group-hub/group-hub.d.ts.map +1 -0
  57. package/dist/components/group-hub/group-hub.js +334 -0
  58. package/dist/components/group-hub/group-hub.js.map +1 -0
  59. package/dist/components/group-hub/group-turns.d.ts +109 -0
  60. package/dist/components/group-hub/group-turns.d.ts.map +1 -0
  61. package/dist/components/group-hub/group-turns.js +834 -0
  62. package/dist/components/group-hub/group-turns.js.map +1 -0
  63. package/dist/components/group-hub/member-prompt.d.ts +28 -0
  64. package/dist/components/group-hub/member-prompt.d.ts.map +1 -0
  65. package/dist/components/group-hub/member-prompt.js +111 -0
  66. package/dist/components/group-hub/member-prompt.js.map +1 -0
  67. package/dist/components/group-hub/recipients.d.ts +10 -0
  68. package/dist/components/group-hub/recipients.d.ts.map +1 -0
  69. package/dist/components/group-hub/recipients.js +83 -0
  70. package/dist/components/group-hub/recipients.js.map +1 -0
  71. package/dist/components/group-hub/thread.d.ts +57 -0
  72. package/dist/components/group-hub/thread.d.ts.map +1 -0
  73. package/dist/components/group-hub/thread.js +126 -0
  74. package/dist/components/group-hub/thread.js.map +1 -0
  75. package/dist/components/group-hub/types.d.ts +277 -0
  76. package/dist/components/group-hub/types.d.ts.map +1 -0
  77. package/dist/components/group-hub/types.js +51 -0
  78. package/dist/components/group-hub/types.js.map +1 -0
  79. package/dist/components/llm-provider-hub/providers/anthropic-provider.d.ts.map +1 -1
  80. package/dist/components/llm-provider-hub/providers/anthropic-provider.js +22 -2
  81. package/dist/components/llm-provider-hub/providers/anthropic-provider.js.map +1 -1
  82. package/dist/components/llm-provider-hub/providers/bedrock-provider.d.ts.map +1 -1
  83. package/dist/components/llm-provider-hub/providers/bedrock-provider.js +15 -3
  84. package/dist/components/llm-provider-hub/providers/bedrock-provider.js.map +1 -1
  85. package/dist/components/llm-provider-hub/providers/model-info-mappers.d.ts.map +1 -1
  86. package/dist/components/llm-provider-hub/providers/model-info-mappers.js +27 -0
  87. package/dist/components/llm-provider-hub/providers/model-info-mappers.js.map +1 -1
  88. package/dist/components/llm-provider-hub/providers/openai-compatible-provider.d.ts.map +1 -1
  89. package/dist/components/llm-provider-hub/providers/openai-compatible-provider.js +10 -3
  90. package/dist/components/llm-provider-hub/providers/openai-compatible-provider.js.map +1 -1
  91. package/dist/components/llm-provider-hub/providers/openai-subscription-provider.d.ts +1 -0
  92. package/dist/components/llm-provider-hub/providers/openai-subscription-provider.d.ts.map +1 -1
  93. package/dist/components/llm-provider-hub/providers/openai-subscription-provider.js +35 -3
  94. package/dist/components/llm-provider-hub/providers/openai-subscription-provider.js.map +1 -1
  95. package/dist/components/llm-provider-hub/types.d.ts +20 -0
  96. package/dist/components/llm-provider-hub/types.d.ts.map +1 -1
  97. package/dist/components/llm-provider-hub/types.js +5 -0
  98. package/dist/components/llm-provider-hub/types.js.map +1 -1
  99. package/dist/components/multi-agent-orchestration/agent/agent-loop/agent-loop.d.ts +87 -8
  100. package/dist/components/multi-agent-orchestration/agent/agent-loop/agent-loop.d.ts.map +1 -1
  101. package/dist/components/multi-agent-orchestration/agent/agent-loop/agent-loop.js +465 -62
  102. package/dist/components/multi-agent-orchestration/agent/agent-loop/agent-loop.js.map +1 -1
  103. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/compactor.d.ts +14 -1
  104. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/compactor.d.ts.map +1 -1
  105. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/compactor.js +25 -1
  106. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/compactor.js.map +1 -1
  107. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/counter.d.ts +14 -1
  108. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/counter.d.ts.map +1 -1
  109. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/counter.js +14 -22
  110. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/counter.js.map +1 -1
  111. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/harness-executor.d.ts +41 -3
  112. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/harness-executor.d.ts.map +1 -1
  113. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/harness-executor.js +152 -44
  114. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/harness-executor.js.map +1 -1
  115. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/run-trace.d.ts +15 -0
  116. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/run-trace.d.ts.map +1 -1
  117. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/run-trace.js +35 -1
  118. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/run-trace.js.map +1 -1
  119. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/summarizer.d.ts +10 -1
  120. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/summarizer.d.ts.map +1 -1
  121. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/summarizer.js +39 -6
  122. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/summarizer.js.map +1 -1
  123. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/summarizer.types.d.ts +2 -1
  124. package/dist/components/multi-agent-orchestration/agent/agent-loop/components/summarizer.types.d.ts.map +1 -1
  125. package/dist/components/multi-agent-orchestration/agent/agent-loop/functions/context-usage.d.ts +47 -0
  126. package/dist/components/multi-agent-orchestration/agent/agent-loop/functions/context-usage.d.ts.map +1 -0
  127. package/dist/components/multi-agent-orchestration/agent/agent-loop/functions/context-usage.js +61 -0
  128. package/dist/components/multi-agent-orchestration/agent/agent-loop/functions/context-usage.js.map +1 -0
  129. package/dist/components/multi-agent-orchestration/agent/agent-loop/functions/memory-recall.d.ts +1 -1
  130. package/dist/components/multi-agent-orchestration/agent/agent-loop/functions/memory-recall.d.ts.map +1 -1
  131. package/dist/components/multi-agent-orchestration/agent/agent-loop/functions/memory-recall.js +1 -1
  132. package/dist/components/multi-agent-orchestration/agent/agent-loop/functions/memory-recall.js.map +1 -1
  133. package/dist/components/multi-agent-orchestration/agent/agent-loop/types.d.ts +131 -8
  134. package/dist/components/multi-agent-orchestration/agent/agent-loop/types.d.ts.map +1 -1
  135. package/dist/components/multi-agent-orchestration/agent/agent-loop/types.js +17 -1
  136. package/dist/components/multi-agent-orchestration/agent/agent-loop/types.js.map +1 -1
  137. package/dist/components/multi-agent-orchestration/agent/agent.d.ts +101 -15
  138. package/dist/components/multi-agent-orchestration/agent/agent.d.ts.map +1 -1
  139. package/dist/components/multi-agent-orchestration/agent/agent.js +415 -44
  140. package/dist/components/multi-agent-orchestration/agent/agent.js.map +1 -1
  141. package/dist/components/multi-agent-orchestration/agent/channel-manager/channel-manager.d.ts +245 -1
  142. package/dist/components/multi-agent-orchestration/agent/channel-manager/channel-manager.d.ts.map +1 -1
  143. package/dist/components/multi-agent-orchestration/agent/channel-manager/channel-manager.js +1583 -0
  144. package/dist/components/multi-agent-orchestration/agent/channel-manager/channel-manager.js.map +1 -1
  145. package/dist/components/multi-agent-orchestration/agent/channel-manager/channel-prompts.d.ts +76 -0
  146. package/dist/components/multi-agent-orchestration/agent/channel-manager/channel-prompts.d.ts.map +1 -0
  147. package/dist/components/multi-agent-orchestration/agent/channel-manager/channel-prompts.js +236 -0
  148. package/dist/components/multi-agent-orchestration/agent/channel-manager/channel-prompts.js.map +1 -0
  149. package/dist/components/multi-agent-orchestration/agent/channel-manager/text.d.ts +15 -0
  150. package/dist/components/multi-agent-orchestration/agent/channel-manager/text.d.ts.map +1 -0
  151. package/dist/components/multi-agent-orchestration/agent/channel-manager/text.js +80 -0
  152. package/dist/components/multi-agent-orchestration/agent/channel-manager/text.js.map +1 -0
  153. package/dist/components/multi-agent-orchestration/agent/channel-manager/turn-stream.d.ts +13 -0
  154. package/dist/components/multi-agent-orchestration/agent/channel-manager/turn-stream.d.ts.map +1 -0
  155. package/dist/components/multi-agent-orchestration/agent/channel-manager/turn-stream.js +41 -0
  156. package/dist/components/multi-agent-orchestration/agent/channel-manager/turn-stream.js.map +1 -0
  157. package/dist/components/multi-agent-orchestration/agent/channel-manager/turn-view.d.ts +69 -0
  158. package/dist/components/multi-agent-orchestration/agent/channel-manager/turn-view.d.ts.map +1 -0
  159. package/dist/components/multi-agent-orchestration/agent/channel-manager/turn-view.js +210 -0
  160. package/dist/components/multi-agent-orchestration/agent/channel-manager/turn-view.js.map +1 -0
  161. package/dist/components/multi-agent-orchestration/agent/channel-manager/types.d.ts +76 -0
  162. package/dist/components/multi-agent-orchestration/agent/channel-manager/types.d.ts.map +1 -0
  163. package/dist/components/multi-agent-orchestration/agent/channel-manager/types.js +7 -0
  164. package/dist/components/multi-agent-orchestration/agent/channel-manager/types.js.map +1 -0
  165. package/dist/components/multi-agent-orchestration/agent/command-manager/built-in-commands.d.ts +37 -0
  166. package/dist/components/multi-agent-orchestration/agent/command-manager/built-in-commands.d.ts.map +1 -0
  167. package/dist/components/multi-agent-orchestration/agent/command-manager/built-in-commands.js +544 -0
  168. package/dist/components/multi-agent-orchestration/agent/command-manager/built-in-commands.js.map +1 -0
  169. package/dist/components/multi-agent-orchestration/agent/command-manager/command-manager.d.ts +75 -0
  170. package/dist/components/multi-agent-orchestration/agent/command-manager/command-manager.d.ts.map +1 -0
  171. package/dist/components/multi-agent-orchestration/agent/command-manager/command-manager.js +299 -0
  172. package/dist/components/multi-agent-orchestration/agent/command-manager/command-manager.js.map +1 -0
  173. package/dist/components/multi-agent-orchestration/agent/command-manager/parse.d.ts +17 -0
  174. package/dist/components/multi-agent-orchestration/agent/command-manager/parse.d.ts.map +1 -0
  175. package/dist/components/multi-agent-orchestration/agent/command-manager/parse.js +19 -0
  176. package/dist/components/multi-agent-orchestration/agent/command-manager/parse.js.map +1 -0
  177. package/dist/components/multi-agent-orchestration/agent/command-manager/types.d.ts +197 -0
  178. package/dist/components/multi-agent-orchestration/agent/command-manager/types.d.ts.map +1 -0
  179. package/dist/components/multi-agent-orchestration/agent/command-manager/types.js +3 -0
  180. package/dist/components/multi-agent-orchestration/agent/command-manager/types.js.map +1 -0
  181. package/dist/components/multi-agent-orchestration/agent/context-manager/context-manager.d.ts +37 -1
  182. package/dist/components/multi-agent-orchestration/agent/context-manager/context-manager.d.ts.map +1 -1
  183. package/dist/components/multi-agent-orchestration/agent/context-manager/context-manager.js +54 -2
  184. package/dist/components/multi-agent-orchestration/agent/context-manager/context-manager.js.map +1 -1
  185. package/dist/components/multi-agent-orchestration/agent/conversation-manager/conversation-manager.d.ts +118 -14
  186. package/dist/components/multi-agent-orchestration/agent/conversation-manager/conversation-manager.d.ts.map +1 -1
  187. package/dist/components/multi-agent-orchestration/agent/conversation-manager/conversation-manager.js +239 -50
  188. package/dist/components/multi-agent-orchestration/agent/conversation-manager/conversation-manager.js.map +1 -1
  189. package/dist/components/multi-agent-orchestration/agent/conversation-manager/conversation.d.ts +34 -0
  190. package/dist/components/multi-agent-orchestration/agent/conversation-manager/conversation.d.ts.map +1 -0
  191. package/dist/components/multi-agent-orchestration/agent/conversation-manager/conversation.js +74 -0
  192. package/dist/components/multi-agent-orchestration/agent/conversation-manager/conversation.js.map +1 -0
  193. package/dist/components/multi-agent-orchestration/agent/conversation-manager/turn-gate.d.ts +49 -0
  194. package/dist/components/multi-agent-orchestration/agent/conversation-manager/turn-gate.d.ts.map +1 -0
  195. package/dist/components/multi-agent-orchestration/agent/conversation-manager/turn-gate.js +171 -0
  196. package/dist/components/multi-agent-orchestration/agent/conversation-manager/turn-gate.js.map +1 -0
  197. package/dist/components/multi-agent-orchestration/agent/job-manager/clock.d.ts +43 -0
  198. package/dist/components/multi-agent-orchestration/agent/job-manager/clock.d.ts.map +1 -0
  199. package/dist/components/multi-agent-orchestration/agent/job-manager/clock.js +116 -0
  200. package/dist/components/multi-agent-orchestration/agent/job-manager/clock.js.map +1 -0
  201. package/dist/components/multi-agent-orchestration/agent/job-manager/internal-events.d.ts +17 -0
  202. package/dist/components/multi-agent-orchestration/agent/job-manager/internal-events.d.ts.map +1 -0
  203. package/dist/components/multi-agent-orchestration/agent/job-manager/internal-events.js +93 -0
  204. package/dist/components/multi-agent-orchestration/agent/job-manager/internal-events.js.map +1 -0
  205. package/dist/components/multi-agent-orchestration/agent/job-manager/job-manager.d.ts +208 -0
  206. package/dist/components/multi-agent-orchestration/agent/job-manager/job-manager.d.ts.map +1 -0
  207. package/dist/components/multi-agent-orchestration/agent/job-manager/job-manager.js +1207 -0
  208. package/dist/components/multi-agent-orchestration/agent/job-manager/job-manager.js.map +1 -0
  209. package/dist/components/multi-agent-orchestration/agent/job-manager/rules.d.ts +129 -0
  210. package/dist/components/multi-agent-orchestration/agent/job-manager/rules.d.ts.map +1 -0
  211. package/dist/components/multi-agent-orchestration/agent/job-manager/rules.js +598 -0
  212. package/dist/components/multi-agent-orchestration/agent/job-manager/rules.js.map +1 -0
  213. package/dist/components/multi-agent-orchestration/agent/job-manager/schedule.d.ts +15 -0
  214. package/dist/components/multi-agent-orchestration/agent/job-manager/schedule.d.ts.map +1 -0
  215. package/dist/components/multi-agent-orchestration/agent/job-manager/schedule.js +113 -0
  216. package/dist/components/multi-agent-orchestration/agent/job-manager/schedule.js.map +1 -0
  217. package/dist/components/multi-agent-orchestration/agent/job-manager/timers.d.ts +8 -0
  218. package/dist/components/multi-agent-orchestration/agent/job-manager/timers.d.ts.map +1 -0
  219. package/dist/components/multi-agent-orchestration/agent/job-manager/timers.js +33 -0
  220. package/dist/components/multi-agent-orchestration/agent/job-manager/timers.js.map +1 -0
  221. package/dist/components/multi-agent-orchestration/agent/job-manager/types.d.ts +495 -0
  222. package/dist/components/multi-agent-orchestration/agent/job-manager/types.d.ts.map +1 -0
  223. package/dist/components/multi-agent-orchestration/agent/job-manager/types.js +50 -0
  224. package/dist/components/multi-agent-orchestration/agent/job-manager/types.js.map +1 -0
  225. package/dist/components/multi-agent-orchestration/agent/job-manager/webhook.d.ts +37 -0
  226. package/dist/components/multi-agent-orchestration/agent/job-manager/webhook.d.ts.map +1 -0
  227. package/dist/components/multi-agent-orchestration/agent/job-manager/webhook.js +157 -0
  228. package/dist/components/multi-agent-orchestration/agent/job-manager/webhook.js.map +1 -0
  229. package/dist/components/multi-agent-orchestration/agent/memory-system/components/dreaming.d.ts.map +1 -1
  230. package/dist/components/multi-agent-orchestration/agent/memory-system/components/dreaming.js +17 -3
  231. package/dist/components/multi-agent-orchestration/agent/memory-system/components/dreaming.js.map +1 -1
  232. package/dist/components/multi-agent-orchestration/agent/memory-system/components/memory.d.ts +7 -0
  233. package/dist/components/multi-agent-orchestration/agent/memory-system/components/memory.d.ts.map +1 -1
  234. package/dist/components/multi-agent-orchestration/agent/memory-system/components/memory.js +189 -30
  235. package/dist/components/multi-agent-orchestration/agent/memory-system/components/memory.js.map +1 -1
  236. package/dist/components/multi-agent-orchestration/agent/memory-system/memory-system.d.ts +17 -0
  237. package/dist/components/multi-agent-orchestration/agent/memory-system/memory-system.d.ts.map +1 -1
  238. package/dist/components/multi-agent-orchestration/agent/memory-system/memory-system.js +51 -0
  239. package/dist/components/multi-agent-orchestration/agent/memory-system/memory-system.js.map +1 -1
  240. package/dist/components/multi-agent-orchestration/agent/model-manager/model-manager.d.ts +5 -0
  241. package/dist/components/multi-agent-orchestration/agent/model-manager/model-manager.d.ts.map +1 -1
  242. package/dist/components/multi-agent-orchestration/agent/model-manager/model-manager.js +16 -0
  243. package/dist/components/multi-agent-orchestration/agent/model-manager/model-manager.js.map +1 -1
  244. package/dist/components/multi-agent-orchestration/agent/secret-manager/secret-manager.d.ts +41 -0
  245. package/dist/components/multi-agent-orchestration/agent/secret-manager/secret-manager.d.ts.map +1 -0
  246. package/dist/components/multi-agent-orchestration/agent/secret-manager/secret-manager.js +98 -0
  247. package/dist/components/multi-agent-orchestration/agent/secret-manager/secret-manager.js.map +1 -0
  248. package/dist/components/multi-agent-orchestration/agent/secret-manager/types.d.ts +37 -0
  249. package/dist/components/multi-agent-orchestration/agent/secret-manager/types.d.ts.map +1 -0
  250. package/dist/components/multi-agent-orchestration/agent/secret-manager/types.js.map +1 -0
  251. package/dist/components/multi-agent-orchestration/agent/skill-manager/skill-manager.d.ts.map +1 -1
  252. package/dist/components/multi-agent-orchestration/agent/skill-manager/skill-manager.js +1 -0
  253. package/dist/components/multi-agent-orchestration/agent/skill-manager/skill-manager.js.map +1 -1
  254. package/dist/components/multi-agent-orchestration/agent/subagent-manager/brief.d.ts +21 -0
  255. package/dist/components/multi-agent-orchestration/agent/subagent-manager/brief.d.ts.map +1 -0
  256. package/dist/components/multi-agent-orchestration/agent/subagent-manager/brief.js +113 -0
  257. package/dist/components/multi-agent-orchestration/agent/subagent-manager/brief.js.map +1 -0
  258. package/dist/components/multi-agent-orchestration/agent/subagent-manager/child-loop.d.ts +52 -0
  259. package/dist/components/multi-agent-orchestration/agent/subagent-manager/child-loop.d.ts.map +1 -0
  260. package/dist/components/multi-agent-orchestration/agent/subagent-manager/child-loop.js +63 -0
  261. package/dist/components/multi-agent-orchestration/agent/subagent-manager/child-loop.js.map +1 -0
  262. package/dist/components/multi-agent-orchestration/agent/subagent-manager/semaphore.d.ts +18 -0
  263. package/dist/components/multi-agent-orchestration/agent/subagent-manager/semaphore.d.ts.map +1 -0
  264. package/dist/components/multi-agent-orchestration/agent/subagent-manager/semaphore.js +56 -0
  265. package/dist/components/multi-agent-orchestration/agent/subagent-manager/semaphore.js.map +1 -0
  266. package/dist/components/multi-agent-orchestration/agent/subagent-manager/subagent-manager.d.ts +128 -0
  267. package/dist/components/multi-agent-orchestration/agent/subagent-manager/subagent-manager.d.ts.map +1 -0
  268. package/dist/components/multi-agent-orchestration/agent/subagent-manager/subagent-manager.js +661 -0
  269. package/dist/components/multi-agent-orchestration/agent/subagent-manager/subagent-manager.js.map +1 -0
  270. package/dist/components/multi-agent-orchestration/agent/subagent-manager/types.d.ts +307 -0
  271. package/dist/components/multi-agent-orchestration/agent/subagent-manager/types.d.ts.map +1 -0
  272. package/dist/components/multi-agent-orchestration/agent/subagent-manager/types.js +60 -0
  273. package/dist/components/multi-agent-orchestration/agent/subagent-manager/types.js.map +1 -0
  274. package/dist/components/multi-agent-orchestration/agent/tool-manager/tool-manager.d.ts +14 -3
  275. package/dist/components/multi-agent-orchestration/agent/tool-manager/tool-manager.d.ts.map +1 -1
  276. package/dist/components/multi-agent-orchestration/agent/tool-manager/tool-manager.js +18 -5
  277. package/dist/components/multi-agent-orchestration/agent/tool-manager/tool-manager.js.map +1 -1
  278. package/dist/components/multi-agent-orchestration/agent/types.d.ts +84 -1
  279. package/dist/components/multi-agent-orchestration/agent/types.d.ts.map +1 -1
  280. package/dist/components/multi-agent-orchestration/multi-agent-orchestration.d.ts +11 -4
  281. package/dist/components/multi-agent-orchestration/multi-agent-orchestration.d.ts.map +1 -1
  282. package/dist/components/multi-agent-orchestration/multi-agent-orchestration.js +72 -4
  283. package/dist/components/multi-agent-orchestration/multi-agent-orchestration.js.map +1 -1
  284. package/dist/components/persistence-hub/default-stores/memory-channel-store.d.ts +11 -0
  285. package/dist/components/persistence-hub/default-stores/memory-channel-store.d.ts.map +1 -0
  286. package/dist/components/persistence-hub/default-stores/memory-channel-store.js +33 -0
  287. package/dist/components/persistence-hub/default-stores/memory-channel-store.js.map +1 -0
  288. package/dist/components/persistence-hub/default-stores/memory-group-store.d.ts +21 -0
  289. package/dist/components/persistence-hub/default-stores/memory-group-store.d.ts.map +1 -0
  290. package/dist/components/persistence-hub/default-stores/memory-group-store.js +62 -0
  291. package/dist/components/persistence-hub/default-stores/memory-group-store.js.map +1 -0
  292. package/dist/components/persistence-hub/default-stores/memory-job-store.d.ts +31 -0
  293. package/dist/components/persistence-hub/default-stores/memory-job-store.d.ts.map +1 -0
  294. package/dist/components/persistence-hub/default-stores/memory-job-store.js +234 -0
  295. package/dist/components/persistence-hub/default-stores/memory-job-store.js.map +1 -0
  296. package/dist/components/persistence-hub/default-stores/memory-secret-store.d.ts +12 -0
  297. package/dist/components/persistence-hub/default-stores/memory-secret-store.d.ts.map +1 -0
  298. package/dist/components/persistence-hub/default-stores/memory-secret-store.js +38 -0
  299. package/dist/components/persistence-hub/default-stores/memory-secret-store.js.map +1 -0
  300. package/dist/components/persistence-hub/default-stores/memory-session-store.d.ts.map +1 -1
  301. package/dist/components/persistence-hub/default-stores/memory-session-store.js +7 -0
  302. package/dist/components/persistence-hub/default-stores/memory-session-store.js.map +1 -1
  303. package/dist/components/persistence-hub/default-stores/memory-subagent-run-store.d.ts +10 -0
  304. package/dist/components/persistence-hub/default-stores/memory-subagent-run-store.d.ts.map +1 -0
  305. package/dist/components/persistence-hub/default-stores/memory-subagent-run-store.js +30 -0
  306. package/dist/components/persistence-hub/default-stores/memory-subagent-run-store.js.map +1 -0
  307. package/dist/components/persistence-hub/default-stores/memory-subagent-type-store.d.ts +9 -0
  308. package/dist/components/persistence-hub/default-stores/memory-subagent-type-store.d.ts.map +1 -0
  309. package/dist/components/persistence-hub/default-stores/memory-subagent-type-store.js +17 -0
  310. package/dist/components/persistence-hub/default-stores/memory-subagent-type-store.js.map +1 -0
  311. package/dist/components/persistence-hub/persistence-hub.d.ts +41 -0
  312. package/dist/components/persistence-hub/persistence-hub.d.ts.map +1 -1
  313. package/dist/components/persistence-hub/persistence-hub.js +41 -0
  314. package/dist/components/persistence-hub/persistence-hub.js.map +1 -1
  315. package/dist/components/persistence-hub/types/channel-store.d.ts +12 -0
  316. package/dist/components/persistence-hub/types/channel-store.d.ts.map +1 -0
  317. package/dist/components/persistence-hub/types/channel-store.js +2 -0
  318. package/dist/components/persistence-hub/types/channel-store.js.map +1 -0
  319. package/dist/components/persistence-hub/types/group-store.d.ts +27 -0
  320. package/dist/components/persistence-hub/types/group-store.d.ts.map +1 -0
  321. package/dist/components/persistence-hub/types/group-store.js +2 -0
  322. package/dist/components/persistence-hub/types/group-store.js.map +1 -0
  323. package/dist/components/persistence-hub/types/job-store.d.ts +112 -0
  324. package/dist/components/persistence-hub/types/job-store.d.ts.map +1 -0
  325. package/dist/components/persistence-hub/types/job-store.js +2 -0
  326. package/dist/components/persistence-hub/types/job-store.js.map +1 -0
  327. package/dist/components/persistence-hub/types/secret-store.d.ts +18 -0
  328. package/dist/components/persistence-hub/types/secret-store.d.ts.map +1 -0
  329. package/dist/components/persistence-hub/types/secret-store.js +2 -0
  330. package/dist/components/persistence-hub/types/secret-store.js.map +1 -0
  331. package/dist/components/persistence-hub/types/session-store.d.ts +5 -0
  332. package/dist/components/persistence-hub/types/session-store.d.ts.map +1 -1
  333. package/dist/components/persistence-hub/types/subagent-run-store.d.ts +11 -0
  334. package/dist/components/persistence-hub/types/subagent-run-store.d.ts.map +1 -0
  335. package/dist/components/persistence-hub/types/subagent-run-store.js +2 -0
  336. package/dist/components/persistence-hub/types/subagent-run-store.js.map +1 -0
  337. package/dist/components/persistence-hub/types/subagent-type-store.d.ts +9 -0
  338. package/dist/components/persistence-hub/types/subagent-type-store.d.ts.map +1 -0
  339. package/dist/components/persistence-hub/types/subagent-type-store.js +2 -0
  340. package/dist/components/persistence-hub/types/subagent-type-store.js.map +1 -0
  341. package/dist/components/sandbox-hub/docker/docker-sandbox.d.ts +4 -1
  342. package/dist/components/sandbox-hub/docker/docker-sandbox.d.ts.map +1 -1
  343. package/dist/components/sandbox-hub/docker/docker-sandbox.js +398 -1
  344. package/dist/components/sandbox-hub/docker/docker-sandbox.js.map +1 -1
  345. package/dist/components/sandbox-hub/docker/sandbox-helper.d.ts.map +1 -1
  346. package/dist/components/sandbox-hub/docker/sandbox-helper.js +386 -5
  347. package/dist/components/sandbox-hub/docker/sandbox-helper.js.map +1 -1
  348. package/dist/components/sandbox-hub/host/host-sandbox.d.ts +16 -0
  349. package/dist/components/sandbox-hub/host/host-sandbox.d.ts.map +1 -1
  350. package/dist/components/sandbox-hub/host/host-sandbox.js +283 -2
  351. package/dist/components/sandbox-hub/host/host-sandbox.js.map +1 -1
  352. package/dist/components/sandbox-hub/sandbox-hub.d.ts +9 -0
  353. package/dist/components/sandbox-hub/sandbox-hub.d.ts.map +1 -1
  354. package/dist/components/sandbox-hub/sandbox-hub.js +18 -0
  355. package/dist/components/sandbox-hub/sandbox-hub.js.map +1 -1
  356. package/dist/components/sandbox-hub/traced-sandbox.d.ts.map +1 -1
  357. package/dist/components/sandbox-hub/traced-sandbox.js +32 -0
  358. package/dist/components/sandbox-hub/traced-sandbox.js.map +1 -1
  359. package/dist/components/sandbox-hub/types/sandbox.d.ts +106 -1
  360. package/dist/components/sandbox-hub/types/sandbox.d.ts.map +1 -1
  361. package/dist/components/sandbox-hub/types/sandbox.js +0 -13
  362. package/dist/components/sandbox-hub/types/sandbox.js.map +1 -1
  363. package/dist/components/secret-hub/envelope.d.ts +48 -0
  364. package/dist/components/secret-hub/envelope.d.ts.map +1 -0
  365. package/dist/components/secret-hub/envelope.js +157 -0
  366. package/dist/components/secret-hub/envelope.js.map +1 -0
  367. package/dist/components/secret-hub/rules.d.ts +33 -0
  368. package/dist/components/secret-hub/rules.d.ts.map +1 -0
  369. package/dist/components/secret-hub/rules.js +142 -0
  370. package/dist/components/secret-hub/rules.js.map +1 -0
  371. package/dist/components/secret-hub/secret-hub-provider.d.ts +61 -0
  372. package/dist/components/secret-hub/secret-hub-provider.d.ts.map +1 -0
  373. package/dist/components/secret-hub/secret-hub-provider.js +73 -0
  374. package/dist/components/secret-hub/secret-hub-provider.js.map +1 -0
  375. package/dist/components/secret-hub/secret-hub.d.ts +102 -0
  376. package/dist/components/secret-hub/secret-hub.d.ts.map +1 -0
  377. package/dist/components/secret-hub/secret-hub.js +267 -0
  378. package/dist/components/secret-hub/secret-hub.js.map +1 -0
  379. package/dist/components/secret-hub/types.d.ts +77 -0
  380. package/dist/components/secret-hub/types.d.ts.map +1 -0
  381. package/dist/components/secret-hub/types.js +23 -0
  382. package/dist/components/secret-hub/types.js.map +1 -0
  383. package/dist/components/skill-hub/built-in-skills/essential-skills.d.ts +1 -1
  384. package/dist/components/skill-hub/built-in-skills/essential-skills.d.ts.map +1 -1
  385. package/dist/components/skill-hub/built-in-skills/essential-skills.js +7 -2
  386. package/dist/components/skill-hub/built-in-skills/essential-skills.js.map +1 -1
  387. package/dist/components/skill-hub/built-in-skills/watch-and-notify.d.ts +3 -0
  388. package/dist/components/skill-hub/built-in-skills/watch-and-notify.d.ts.map +1 -0
  389. package/dist/components/skill-hub/built-in-skills/watch-and-notify.js +94 -0
  390. package/dist/components/skill-hub/built-in-skills/watch-and-notify.js.map +1 -0
  391. package/dist/components/skill-hub/skill-hub.d.ts +9 -1
  392. package/dist/components/skill-hub/skill-hub.d.ts.map +1 -1
  393. package/dist/components/skill-hub/skill-hub.js +11 -1
  394. package/dist/components/skill-hub/skill-hub.js.map +1 -1
  395. package/dist/components/subagent-hub/built-in-types.d.ts +3 -0
  396. package/dist/components/subagent-hub/built-in-types.d.ts.map +1 -0
  397. package/dist/components/subagent-hub/built-in-types.js +24 -0
  398. package/dist/components/subagent-hub/built-in-types.js.map +1 -0
  399. package/dist/components/subagent-hub/subagent-hub.d.ts +41 -0
  400. package/dist/components/subagent-hub/subagent-hub.d.ts.map +1 -0
  401. package/dist/components/subagent-hub/subagent-hub.js +158 -0
  402. package/dist/components/subagent-hub/subagent-hub.js.map +1 -0
  403. package/dist/components/subagent-hub/types.d.ts +40 -0
  404. package/dist/components/subagent-hub/types.d.ts.map +1 -0
  405. package/dist/components/subagent-hub/types.js +8 -0
  406. package/dist/components/subagent-hub/types.js.map +1 -0
  407. package/dist/components/tool-hub/built-in-tools/artifacts/artifact-helpers.d.ts +4 -1
  408. package/dist/components/tool-hub/built-in-tools/artifacts/artifact-helpers.d.ts.map +1 -1
  409. package/dist/components/tool-hub/built-in-tools/artifacts/artifact-helpers.js +4 -0
  410. package/dist/components/tool-hub/built-in-tools/artifacts/artifact-helpers.js.map +1 -1
  411. package/dist/components/tool-hub/built-in-tools/artifacts/save-artifact-tool.d.ts.map +1 -1
  412. package/dist/components/tool-hub/built-in-tools/artifacts/save-artifact-tool.js +4 -1
  413. package/dist/components/tool-hub/built-in-tools/artifacts/save-artifact-tool.js.map +1 -1
  414. package/dist/components/tool-hub/built-in-tools/artifacts/update-artifact-tool.d.ts.map +1 -1
  415. package/dist/components/tool-hub/built-in-tools/artifacts/update-artifact-tool.js +4 -1
  416. package/dist/components/tool-hub/built-in-tools/artifacts/update-artifact-tool.js.map +1 -1
  417. package/dist/components/tool-hub/built-in-tools/jobs/create-job-tools.d.ts +10 -0
  418. package/dist/components/tool-hub/built-in-tools/jobs/create-job-tools.d.ts.map +1 -0
  419. package/dist/components/tool-hub/built-in-tools/jobs/create-job-tools.js +13 -0
  420. package/dist/components/tool-hub/built-in-tools/jobs/create-job-tools.js.map +1 -0
  421. package/dist/components/tool-hub/built-in-tools/jobs/job-tool-helpers.d.ts +60 -0
  422. package/dist/components/tool-hub/built-in-tools/jobs/job-tool-helpers.d.ts.map +1 -0
  423. package/dist/components/tool-hub/built-in-tools/jobs/job-tool-helpers.js +240 -0
  424. package/dist/components/tool-hub/built-in-tools/jobs/job-tool-helpers.js.map +1 -0
  425. package/dist/components/tool-hub/built-in-tools/jobs/list-jobs-tool.d.ts +14 -0
  426. package/dist/components/tool-hub/built-in-tools/jobs/list-jobs-tool.d.ts.map +1 -0
  427. package/dist/components/tool-hub/built-in-tools/jobs/list-jobs-tool.js +36 -0
  428. package/dist/components/tool-hub/built-in-tools/jobs/list-jobs-tool.js.map +1 -0
  429. package/dist/components/tool-hub/built-in-tools/jobs/manage-job-tool.d.ts +32 -0
  430. package/dist/components/tool-hub/built-in-tools/jobs/manage-job-tool.d.ts.map +1 -0
  431. package/dist/components/tool-hub/built-in-tools/jobs/manage-job-tool.js +458 -0
  432. package/dist/components/tool-hub/built-in-tools/jobs/manage-job-tool.js.map +1 -0
  433. package/dist/components/tool-hub/built-in-tools/preview/create-preview-tools.d.ts +9 -0
  434. package/dist/components/tool-hub/built-in-tools/preview/create-preview-tools.d.ts.map +1 -0
  435. package/dist/components/tool-hub/built-in-tools/preview/create-preview-tools.js +20 -0
  436. package/dist/components/tool-hub/built-in-tools/preview/create-preview-tools.js.map +1 -0
  437. package/dist/components/tool-hub/built-in-tools/preview/list-apps-tool.d.ts +12 -0
  438. package/dist/components/tool-hub/built-in-tools/preview/list-apps-tool.d.ts.map +1 -0
  439. package/dist/components/tool-hub/built-in-tools/preview/list-apps-tool.js +57 -0
  440. package/dist/components/tool-hub/built-in-tools/preview/list-apps-tool.js.map +1 -0
  441. package/dist/components/tool-hub/built-in-tools/preview/open-in-app-tool.d.ts +15 -0
  442. package/dist/components/tool-hub/built-in-tools/preview/open-in-app-tool.d.ts.map +1 -0
  443. package/dist/components/tool-hub/built-in-tools/preview/open-in-app-tool.js +80 -0
  444. package/dist/components/tool-hub/built-in-tools/preview/open-in-app-tool.js.map +1 -0
  445. package/dist/components/tool-hub/built-in-tools/preview/preview-helpers.d.ts +53 -0
  446. package/dist/components/tool-hub/built-in-tools/preview/preview-helpers.d.ts.map +1 -0
  447. package/dist/components/tool-hub/built-in-tools/preview/preview-helpers.js +100 -0
  448. package/dist/components/tool-hub/built-in-tools/preview/preview-helpers.js.map +1 -0
  449. package/dist/components/tool-hub/built-in-tools/preview/preview-tool.d.ts +14 -0
  450. package/dist/components/tool-hub/built-in-tools/preview/preview-tool.d.ts.map +1 -0
  451. package/dist/components/tool-hub/built-in-tools/preview/preview-tool.js +63 -0
  452. package/dist/components/tool-hub/built-in-tools/preview/preview-tool.js.map +1 -0
  453. package/dist/components/tool-hub/built-in-tools/preview/service-tools.d.ts +33 -0
  454. package/dist/components/tool-hub/built-in-tools/preview/service-tools.d.ts.map +1 -0
  455. package/dist/components/tool-hub/built-in-tools/preview/service-tools.js +180 -0
  456. package/dist/components/tool-hub/built-in-tools/preview/service-tools.js.map +1 -0
  457. package/dist/components/tool-hub/built-in-tools/secrets/create-secret-tools.d.ts +6 -0
  458. package/dist/components/tool-hub/built-in-tools/secrets/create-secret-tools.d.ts.map +1 -0
  459. package/dist/components/tool-hub/built-in-tools/secrets/create-secret-tools.js +9 -0
  460. package/dist/components/tool-hub/built-in-tools/secrets/create-secret-tools.js.map +1 -0
  461. package/dist/components/tool-hub/built-in-tools/secrets/list-secrets-tool.d.ts +12 -0
  462. package/dist/components/tool-hub/built-in-tools/secrets/list-secrets-tool.d.ts.map +1 -0
  463. package/dist/components/tool-hub/built-in-tools/secrets/list-secrets-tool.js +30 -0
  464. package/dist/components/tool-hub/built-in-tools/secrets/list-secrets-tool.js.map +1 -0
  465. package/dist/components/tool-hub/built-in-tools/secrets/manage-secret-tool.d.ts +22 -0
  466. package/dist/components/tool-hub/built-in-tools/secrets/manage-secret-tool.d.ts.map +1 -0
  467. package/dist/components/tool-hub/built-in-tools/secrets/manage-secret-tool.js +113 -0
  468. package/dist/components/tool-hub/built-in-tools/secrets/manage-secret-tool.js.map +1 -0
  469. package/dist/components/tool-hub/built-in-tools/secrets/secret-tool-helpers.d.ts +9 -0
  470. package/dist/components/tool-hub/built-in-tools/secrets/secret-tool-helpers.d.ts.map +1 -0
  471. package/dist/components/tool-hub/built-in-tools/secrets/secret-tool-helpers.js +29 -0
  472. package/dist/components/tool-hub/built-in-tools/secrets/secret-tool-helpers.js.map +1 -0
  473. package/dist/components/tool-hub/built-in-tools/subagents/spawn-subagent-tool.d.ts +27 -0
  474. package/dist/components/tool-hub/built-in-tools/subagents/spawn-subagent-tool.d.ts.map +1 -0
  475. package/dist/components/tool-hub/built-in-tools/subagents/spawn-subagent-tool.js +112 -0
  476. package/dist/components/tool-hub/built-in-tools/subagents/spawn-subagent-tool.js.map +1 -0
  477. package/dist/components/tool-hub/built-in-tools/web/http-request-tool.d.ts +43 -0
  478. package/dist/components/tool-hub/built-in-tools/web/http-request-tool.d.ts.map +1 -0
  479. package/dist/components/tool-hub/built-in-tools/web/http-request-tool.js +234 -0
  480. package/dist/components/tool-hub/built-in-tools/web/http-request-tool.js.map +1 -0
  481. package/dist/components/tool-hub/built-in-tools/web/web-extract-tool.d.ts.map +1 -1
  482. package/dist/components/tool-hub/built-in-tools/web/web-extract-tool.js +2 -0
  483. package/dist/components/tool-hub/built-in-tools/web/web-extract-tool.js.map +1 -1
  484. package/dist/components/tool-hub/built-in-tools/web/web-search-tool.d.ts.map +1 -1
  485. package/dist/components/tool-hub/built-in-tools/web/web-search-tool.js +2 -0
  486. package/dist/components/tool-hub/built-in-tools/web/web-search-tool.js.map +1 -1
  487. package/dist/components/tool-hub/built-in-tools/workspace/run-code-tool.d.ts.map +1 -1
  488. package/dist/components/tool-hub/built-in-tools/workspace/run-code-tool.js +9 -1
  489. package/dist/components/tool-hub/built-in-tools/workspace/run-code-tool.js.map +1 -1
  490. package/dist/components/tool-hub/built-in-tools/workspace/terminal-tool.d.ts.map +1 -1
  491. package/dist/components/tool-hub/built-in-tools/workspace/terminal-tool.js +9 -2
  492. package/dist/components/tool-hub/built-in-tools/workspace/terminal-tool.js.map +1 -1
  493. package/dist/components/tool-hub/built-in-tools/workspace/workspace-helpers.d.ts +17 -0
  494. package/dist/components/tool-hub/built-in-tools/workspace/workspace-helpers.d.ts.map +1 -1
  495. package/dist/components/tool-hub/built-in-tools/workspace/workspace-helpers.js +29 -0
  496. package/dist/components/tool-hub/built-in-tools/workspace/workspace-helpers.js.map +1 -1
  497. package/dist/components/tool-hub/tool-links.d.ts +9 -0
  498. package/dist/components/tool-hub/tool-links.d.ts.map +1 -0
  499. package/dist/components/tool-hub/tool-links.js +11 -0
  500. package/dist/components/tool-hub/tool-links.js.map +1 -0
  501. package/dist/components/tool-hub/types.d.ts +101 -1
  502. package/dist/components/tool-hub/types.d.ts.map +1 -1
  503. package/dist/index.d.ts +109 -8
  504. package/dist/index.d.ts.map +1 -1
  505. package/dist/index.js +68 -0
  506. package/dist/index.js.map +1 -1
  507. package/dist/kernel/errors/channel-error.d.ts +24 -0
  508. package/dist/kernel/errors/channel-error.d.ts.map +1 -0
  509. package/dist/kernel/errors/channel-error.js +15 -0
  510. package/dist/kernel/errors/channel-error.js.map +1 -0
  511. package/dist/kernel/errors/command-error.d.ts +12 -0
  512. package/dist/kernel/errors/command-error.d.ts.map +1 -0
  513. package/dist/kernel/errors/command-error.js +11 -0
  514. package/dist/kernel/errors/command-error.js.map +1 -0
  515. package/dist/kernel/errors/group-error.d.ts +15 -0
  516. package/dist/kernel/errors/group-error.d.ts.map +1 -0
  517. package/dist/kernel/errors/group-error.js +10 -0
  518. package/dist/kernel/errors/group-error.js.map +1 -0
  519. package/dist/kernel/errors/job-error.d.ts +23 -0
  520. package/dist/kernel/errors/job-error.d.ts.map +1 -0
  521. package/dist/kernel/errors/job-error.js +15 -0
  522. package/dist/kernel/errors/job-error.js.map +1 -0
  523. package/dist/kernel/errors/secret-error.d.ts +19 -0
  524. package/dist/kernel/errors/secret-error.d.ts.map +1 -0
  525. package/dist/kernel/errors/secret-error.js +10 -0
  526. package/dist/kernel/errors/secret-error.js.map +1 -0
  527. package/dist/kernel/errors/session-error.d.ts +5 -1
  528. package/dist/kernel/errors/session-error.d.ts.map +1 -1
  529. package/dist/kernel/errors/session-error.js.map +1 -1
  530. package/dist/kernel/errors/subagent-error.d.ts +19 -0
  531. package/dist/kernel/errors/subagent-error.d.ts.map +1 -0
  532. package/dist/kernel/errors/subagent-error.js +10 -0
  533. package/dist/kernel/errors/subagent-error.js.map +1 -0
  534. package/dist/kernel/interfaces/kernel.d.ts +15 -0
  535. package/dist/kernel/interfaces/kernel.d.ts.map +1 -1
  536. package/dist/kernel/types.d.ts +80 -1
  537. package/dist/kernel/types.d.ts.map +1 -1
  538. package/dist/testing/fake-channel.d.ts +60 -0
  539. package/dist/testing/fake-channel.d.ts.map +1 -0
  540. package/dist/testing/fake-channel.js +135 -0
  541. package/dist/testing/fake-channel.js.map +1 -0
  542. package/dist/testing/in-memory-sandbox.d.ts +4 -1
  543. package/dist/testing/in-memory-sandbox.d.ts.map +1 -1
  544. package/dist/testing/in-memory-sandbox.js +63 -3
  545. package/dist/testing/in-memory-sandbox.js.map +1 -1
  546. package/dist/testing/mock-session-store.d.ts.map +1 -1
  547. package/dist/testing/mock-session-store.js +7 -0
  548. package/dist/testing/mock-session-store.js.map +1 -1
  549. package/package.json +2 -1
  550. package/dist/components/multi-agent-orchestration/agent/scheduled-job-manager/scheduled-job-manager.d.ts +0 -38
  551. package/dist/components/multi-agent-orchestration/agent/scheduled-job-manager/scheduled-job-manager.d.ts.map +0 -1
  552. package/dist/components/multi-agent-orchestration/agent/scheduled-job-manager/scheduled-job-manager.js +0 -155
  553. package/dist/components/multi-agent-orchestration/agent/scheduled-job-manager/scheduled-job-manager.js.map +0 -1
  554. package/dist/components/multi-agent-orchestration/agent/scheduled-job-manager/types.d.ts +0 -27
  555. package/dist/components/multi-agent-orchestration/agent/scheduled-job-manager/types.d.ts.map +0 -1
  556. package/dist/components/multi-agent-orchestration/agent/scheduled-job-manager/types.js.map +0 -1
  557. /package/dist/components/multi-agent-orchestration/agent/{scheduled-job-manager → secret-manager}/types.js +0 -0
@@ -1,6 +1,1589 @@
1
+ import { randomInt, randomUUID } from "node:crypto";
2
+ import { ChannelError } from "../../../../kernel/errors/channel-error.js";
3
+ import { SDKEventType } from "../../../event-handler/events.js";
4
+ import { ChannelPrompts } from "./channel-prompts.js";
5
+ import { parseCommand, splitMarkdown, splitMessage } from "./text.js";
6
+ import { TurnView } from "./turn-view.js";
7
+ import { helpLine } from "../command-manager/built-in-commands.js";
8
+ /** Most channels one agent may have. */
9
+ export const MAX_CHANNELS_PER_AGENT = 10;
10
+ export const MAX_CHANNEL_NAME_LENGTH = 80;
11
+ /** How long a pairing code stays valid. */
12
+ export const PAIRING_TTL_MS = 60 * 60 * 1000;
13
+ /** Most senders waiting for approval per channel; more are asked to try later. */
14
+ export const MAX_PENDING_PAIRINGS = 3;
15
+ /** "typing…" lasts about 5 seconds on most platforms, so it is renewed this often during a turn. */
16
+ const TYPING_INTERVAL_MS = 4_000;
17
+ /** Inbound message ids remembered to drop duplicates. */
18
+ const MAX_SEEN_MESSAGES = 5_000;
19
+ /** No 0/O or 1/I, so a code read aloud or retyped is not misread. */
20
+ const PAIRING_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
21
+ const PAIRING_CODE_LENGTH = 8;
22
+ const DEFAULT_ACCESS = {
23
+ dmPolicy: "pairing",
24
+ allowFrom: [],
25
+ groupPolicy: "disabled",
26
+ groups: [],
27
+ requireMention: true,
28
+ };
29
+ const DEFAULT_SETTINGS = {
30
+ streaming: true,
31
+ toolProgress: true,
32
+ };
33
+ /** Most models /model lists. */
34
+ const MAX_LISTED_MODELS = 30;
35
+ /** Commands answered at once, even while a turn of the chat is running. */
36
+ // A-135: /yolo too, so YOLO mode can be switched off while a reply is running.
37
+ // A-136: /permissions likewise, and the read-only /help, /context and /usage.
38
+ const IMMEDIATE_COMMANDS = ["stop", "status", "whoami", "approve", "deny", "yolo", "permissions", "help", "context", "usage"];
39
+ /**
40
+ * The commands shown in /help and published to the platform (adapter.setCommands),
41
+ * so the chat can suggest them. /start and /reset are answered too, as aliases.
42
+ */
43
+ const CHANNEL_COMMANDS = [
44
+ { name: "new", description: "Start a new conversation" },
45
+ { name: "stop", description: "Stop the reply in progress" },
46
+ { name: "status", description: "Show this conversation" },
47
+ { name: "model", description: "Show or switch this conversation's model" },
48
+ { name: "approve", description: "Approve a pending tool call" },
49
+ { name: "deny", description: "Deny a pending tool call" },
50
+ { name: "yolo", description: "Run tools without asking (on/off)" },
51
+ { name: "whoami", description: "Show your id" },
52
+ { name: "sethome", description: "Send job results to this chat" },
53
+ { name: "help", description: "Show the commands" },
54
+ ];
55
+ /**
56
+ * A-136: the commands the chat answers itself; every other one the agent has (its
57
+ * CommandManager: /compact, /resume, /permissions...) runs through agent.commands.
58
+ * /clear is the chat's /new (a chat's session is named after the chat).
59
+ */
60
+ const CHAT_COMMANDS = new Set(["new", "reset", "clear", "start", "help", "stop", "approve", "deny", "whoami", "sethome"]);
61
+ /** Platforms accept command names of lower-case letters, digits and "_" (Telegram: 1-32). */
62
+ const PUBLISHABLE_NAME = /^[a-z0-9_]{1,32}$/;
63
+ /** Most commands a platform takes (Telegram: 100). */
64
+ const MAX_PUBLISHED_COMMANDS = 100;
1
65
  /**
2
66
  * communication gateway: slack, teams, telegram, ...
67
+ *
68
+ * One agent's chat-app channels (A-100), like the OpenClaw / Hermes Agent
69
+ * gateways: it connects each enabled channel through its platform's adapter
70
+ * and turns inbound messages into agent turns.
71
+ *
72
+ * - Access: direct messages only (groups come later). dmPolicy "pairing"
73
+ * gives an unknown sender a one-time code for the owner to approve.
74
+ * -> Phase 2: group chats too, by groupPolicy ("disabled" by default), and
75
+ * only when the bot is mentioned or replied to (requireMention).
76
+ * - Sessions: one per chat, found again through the session's metadata
77
+ * ({ source: "channel", channelId, chatKey }) after a restart. /new starts
78
+ * a fresh one; the old one stays in the history.
79
+ * - Turns of one chat run one after another; different chats run in parallel
80
+ * (the agent's TurnGate and maxConcurrentTurns still apply).
81
+ * - Commands: /start, /help, /new, /reset, /stop, /status, /whoami. Any other
82
+ * "/..." text goes to the agent.
83
+ * -> A-135: /yolo on|off switches the conversation's approval mode (owners only).
84
+ * - Replies are plain text, split to the platform's message length.
85
+ * -> Phase 2: Markdown rendered by the adapter when it can, streamed by
86
+ * editing one message, with a tool-progress message (TurnView).
87
+ * - Phase 2: approvals and clarify questions of a channel turn are asked in its
88
+ * chat (ChannelPrompts) — interactionFor() is the channel side of the
89
+ * agent's interaction router. /approve, /deny and /model are added.
3
90
  */
4
91
  export class ChannelManager {
92
+ deps;
93
+ live = new Map();
94
+ states = new Map();
95
+ /** channelId -> senders waiting for approval. */
96
+ pairings = new Map();
97
+ /** chat key -> the chat's current session. */
98
+ chatSessions = new Map();
99
+ /** chat key -> the last queued message of that chat. */
100
+ chatQueues = new Map();
101
+ /** chat key -> the running turn, for /stop. */
102
+ chatRuns = new Map();
103
+ /** channelId -> serialized connect/disconnect operations. */
104
+ ops = new Map();
105
+ seen = new Set();
106
+ /** sessionId -> the chat of the channel turn running in it (interaction routing). */
107
+ activeTurns = new Map();
108
+ prompts;
109
+ /** Scheduled-job results being sent (phase 3) — dispose() waits for them. */
110
+ deliveries = new Set();
111
+ unsubscribe;
112
+ generation = 0;
113
+ started = false;
114
+ disposed = false;
115
+ now;
116
+ constructor(deps) {
117
+ this.deps = deps;
118
+ this.now = deps.now ?? Date.now;
119
+ this.prompts = new ChannelPrompts({
120
+ send: async (chat, message) => {
121
+ const live = this.live.get(chat.channelId);
122
+ if (!live)
123
+ return undefined;
124
+ try {
125
+ return await live.adapter.send(chat.target, message);
126
+ }
127
+ catch (err) {
128
+ this.warn(chat.channelId, `could not ask in the chat: ${errorMessage(err)}`);
129
+ return undefined;
130
+ }
131
+ },
132
+ edit: async (chat, ref, message) => {
133
+ const adapter = this.live.get(chat.channelId)?.adapter;
134
+ await adapter?.edit?.(ref, message).catch(() => undefined);
135
+ },
136
+ buttons: (channelId) => this.live.get(channelId)?.adapter.capabilities.buttons === true,
137
+ approvers: (channelId) => this.live.get(channelId)?.channel.access.allowFrom ?? [],
138
+ agentName: () => deps.getAgentName(),
139
+ ...(deps.promptTimeoutMs !== undefined
140
+ ? { timeoutMs: deps.promptTimeoutMs }
141
+ : {}),
142
+ });
143
+ // Phase 3: a prompt job that delivers to one of this agent's chats — the scheduler only
144
+ // publishes how the run ended; sending it is the channel side's job.
145
+ // A-70: a trigger run with a delivery — the trigger manager only publishes how it ended.
146
+ // Update (A-126): one event for both — job:run-finished, from the JobManager.
147
+ this.unsubscribe = [
148
+ deps.eventBus.on(SDKEventType.JobRunFinished, (event) => this.onJobRunFinished(event)),
149
+ ];
150
+ }
151
+ /**
152
+ * The InteractionHandler for a session while a channel turn runs in it: its
153
+ * approvals and questions are asked in the chat. Undefined for any other
154
+ * session (a web chat of the same session included) — the host's handler applies.
155
+ */
156
+ interactionFor(sessionId) {
157
+ const chat = this.activeTurns.get(sessionId);
158
+ if (!chat)
159
+ return undefined;
160
+ return {
161
+ askUser: (request) => this.prompts.askUser(chat, request),
162
+ requestApproval: (request) => this.prompts.requestApproval(chat, request),
163
+ };
164
+ }
165
+ /**
166
+ * A-100 phase 3: the delivery of a job scheduled from a session while a channel turn runs
167
+ * in it — back to that chat, as "home" when it is the channel's home chat (so a later
168
+ * /sethome moves it along). Undefined for any other session: a web chat schedules jobs
169
+ * that keep their results in their conversation.
170
+ * Update (A-127): deliveryOptions — that chat (here) and every running channel with a
171
+ * home chat (homes), so a job made outside the chat app (a web chat) still reports to
172
+ * the home chats, and one made in a chat can go to them all.
173
+ */
174
+ deliveryOptions(sessionId) {
175
+ const here = this.deliveryHere(sessionId);
176
+ return { ...(here ? { here } : {}), homes: this.homes() };
177
+ }
178
+ /** The chat of the channel turn running in the session; undefined when none does. */
179
+ deliveryHere(sessionId) {
180
+ const chat = this.activeTurns.get(sessionId);
181
+ if (!chat)
182
+ return undefined;
183
+ const home = this.live.get(chat.channelId)?.channel.home;
184
+ const atHome = home !== undefined &&
185
+ home.chatId === chat.target.chatId &&
186
+ (home.threadId ?? "") === (chat.target.threadId ?? "");
187
+ if (atHome)
188
+ return { channelId: chat.channelId, target: "home", when: "always" };
189
+ return {
190
+ channelId: chat.channelId,
191
+ target: chat.target.chatId,
192
+ ...(chat.target.threadId ? { threadId: chat.target.threadId } : {}),
193
+ when: "always",
194
+ };
195
+ }
196
+ /** The running channels that have a home chat, by name. */
197
+ homes() {
198
+ const homes = [];
199
+ for (const [id, live] of this.live) {
200
+ if (!live.channel.home || this.state(id).status === "failed")
201
+ continue;
202
+ homes.push({ channelId: id, name: live.channel.name, platform: live.channel.platform });
203
+ }
204
+ const order = (x, y) => (x < y ? -1 : x > y ? 1 : 0);
205
+ return homes.sort((a, b) => order(a.name, b.name) || order(a.channelId, b.channelId));
206
+ }
207
+ // ---------------------------------------------------------------------------
208
+ // Lifecycle
209
+ // ---------------------------------------------------------------------------
210
+ /**
211
+ * Connect this agent's stored, enabled channels. A channel that cannot connect
212
+ * shows "failed" in state(); it does not stop the others. Idempotent.
213
+ */
214
+ async start() {
215
+ if (this.started || this.disposed)
216
+ return;
217
+ this.started = true;
218
+ const channels = (await this.store().listByAgent(this.deps.agentId)).map(withDefaults);
219
+ await Promise.allSettled(channels
220
+ .filter((c) => c.enabled)
221
+ .map((c) => this.serial(c.id, () => this.connect(c))));
222
+ }
223
+ /** Disconnect every channel and stop the turns in progress. No new turns start after this. */
224
+ async dispose() {
225
+ this.disposed = true;
226
+ for (const off of this.unsubscribe)
227
+ off();
228
+ await Promise.allSettled([...this.deliveries]);
229
+ for (const controller of this.chatRuns.values())
230
+ controller.abort();
231
+ await Promise.allSettled([...this.live.keys()].map((id) => this.serial(id, () => this.disconnect(id))));
232
+ await Promise.allSettled([...this.chatQueues.values()]);
233
+ }
234
+ //#region Manage Channels
235
+ async list() {
236
+ return (await this.store().listByAgent(this.deps.agentId)).map(withDefaults);
237
+ }
238
+ async get(id) {
239
+ const channel = await this.store().get(id);
240
+ return channel && channel.agentId === this.deps.agentId
241
+ ? withDefaults(channel)
242
+ : null;
243
+ }
244
+ async create(input) {
245
+ if (this.disposed)
246
+ throw new ChannelError("The agent is disposed", "invalid_argument");
247
+ const platform = this.requirePlatform(input.platform);
248
+ const existing = await this.list();
249
+ if (existing.length >= MAX_CHANNELS_PER_AGENT) {
250
+ throw new ChannelError(`An agent can have at most ${MAX_CHANNELS_PER_AGENT} channels`, "limit_reached");
251
+ }
252
+ const nowIso = this.iso(this.now());
253
+ let channel = {
254
+ id: randomUUID(),
255
+ agentId: this.deps.agentId,
256
+ platform: platform.name,
257
+ name: input.name === undefined ? "" : validateName(input.name),
258
+ credentials: validateCredentials(platform, input.credentials),
259
+ access: validateAccess({ ...DEFAULT_ACCESS, ...input.access }),
260
+ settings: validateSettings({ ...DEFAULT_SETTINGS, ...input.settings }),
261
+ enabled: input.enabled ?? true,
262
+ createdAt: nowIso,
263
+ updatedAt: nowIso,
264
+ };
265
+ if (channel.enabled) {
266
+ // Connect first: a channel whose credentials the platform rejects is never saved.
267
+ const connected = await this.serial(channel.id, () => this.connect(channel));
268
+ if (!connected) {
269
+ const error = this.state(channel.id).error;
270
+ this.states.delete(channel.id);
271
+ throw new ChannelError(`Could not connect to ${platformLabel(platform)}: ${error ?? "unknown error"}`, "connect_failed", channel.id);
272
+ }
273
+ channel = { ...channel, account: connected };
274
+ }
275
+ if (!channel.name)
276
+ channel = {
277
+ ...channel,
278
+ name: channel.account?.displayName ?? platformLabel(platform),
279
+ };
280
+ await this.store().save(channel);
281
+ const live = this.live.get(channel.id);
282
+ if (live)
283
+ live.channel = channel;
284
+ return channel;
285
+ }
286
+ async update(id, patch) {
287
+ const current = await this.require(id);
288
+ const platform = this.requirePlatform(current.platform);
289
+ const credentials = patch.credentials
290
+ ? validateCredentials(platform, {
291
+ ...current.credentials,
292
+ ...patch.credentials,
293
+ })
294
+ : current.credentials;
295
+ const credentialsChanged = Object.keys(credentials).some((k) => credentials[k] !== current.credentials[k]);
296
+ let updated = {
297
+ ...current,
298
+ ...(patch.name !== undefined ? { name: validateName(patch.name) } : {}),
299
+ credentials,
300
+ access: patch.access
301
+ ? validateAccess({ ...current.access, ...patch.access })
302
+ : current.access,
303
+ settings: patch.settings
304
+ ? validateSettings({ ...current.settings, ...patch.settings })
305
+ : current.settings,
306
+ ...(patch.enabled !== undefined ? { enabled: patch.enabled } : {}),
307
+ updatedAt: this.iso(this.now()),
308
+ };
309
+ if (patch.home === null)
310
+ delete updated.home;
311
+ else if (patch.home !== undefined)
312
+ updated.home = validateHome(patch.home, updated.updatedAt);
313
+ // A new bot token may be another bot: its account is read again on connect.
314
+ if (credentialsChanged)
315
+ delete updated.account;
316
+ await this.store().save(updated);
317
+ await this.serial(id, async () => {
318
+ const live = this.live.get(id);
319
+ if (!updated.enabled || this.disposed) {
320
+ if (live)
321
+ await this.disconnect(id);
322
+ return;
323
+ }
324
+ if (live && !credentialsChanged) {
325
+ live.channel = updated;
326
+ return;
327
+ }
328
+ if (live)
329
+ await this.disconnect(id);
330
+ // A failed reconnect is reported through state(), not thrown: the change is saved.
331
+ await this.connect(updated);
332
+ });
333
+ updated = (await this.get(id)) ?? updated;
334
+ return updated;
335
+ }
336
+ async delete(id) {
337
+ await this.require(id);
338
+ await this.serial(id, () => this.disconnect(id));
339
+ this.pairings.delete(id);
340
+ for (const key of [...this.chatSessions.keys()]) {
341
+ if (key.startsWith(`${id}\u0000`))
342
+ this.chatSessions.delete(key);
343
+ }
344
+ this.states.delete(id);
345
+ await this.store().delete(id);
346
+ }
347
+ state(id) {
348
+ return this.states.get(id) ?? { status: "stopped", since: this.iso(0) };
349
+ }
350
+ async listPairings(id) {
351
+ await this.require(id);
352
+ return this.pendingPairings(id).map((p) => ({ ...p }));
353
+ }
354
+ async approvePairing(id, code) {
355
+ const channel = await this.require(id);
356
+ const pairing = this.takePairing(id, code);
357
+ const updated = channel.access.allowFrom.includes(pairing.senderId)
358
+ ? channel
359
+ : {
360
+ ...channel,
361
+ access: {
362
+ ...channel.access,
363
+ allowFrom: [...channel.access.allowFrom, pairing.senderId],
364
+ },
365
+ updatedAt: this.iso(this.now()),
366
+ };
367
+ if (updated !== channel)
368
+ await this.store().save(updated);
369
+ const live = this.live.get(id);
370
+ if (live) {
371
+ live.channel = updated;
372
+ await this.reply(live, { chatId: pairing.chatId }, `You're approved! Send a message to start talking to ${this.deps.getAgentName()}.`);
373
+ }
374
+ return updated;
375
+ }
376
+ async rejectPairing(id, code) {
377
+ await this.require(id);
378
+ this.takePairing(id, code);
379
+ }
380
+ async send(id, target, text) {
381
+ await this.require(id);
382
+ const live = this.live.get(id);
383
+ if (!live || this.state(id).status === "failed") {
384
+ throw new ChannelError("The channel is not connected", "not_running", id);
385
+ }
386
+ return this.sendText(live, target, text);
387
+ }
388
+ async handleWebhook(id, request) {
389
+ if (!(await this.get(id)))
390
+ return { status: 404, body: { error: "Channel not found" } };
391
+ const live = this.live.get(id);
392
+ if (!live || this.state(id).status === "failed")
393
+ return { status: 503, body: { error: "The channel is not connected" } };
394
+ if (!live.adapter.handleWebhook)
395
+ return {
396
+ status: 405,
397
+ body: { error: "This channel's platform takes no webhooks" },
398
+ };
399
+ return live.adapter.handleWebhook(request);
400
+ }
401
+ //#endregion
402
+ //#region Manage Channel's connection (connect, disconnect, ...)
403
+ /**
404
+ * Build the channel's adapter and connect it. Returns the bot account, or null
405
+ * when it failed (the reason is in state()). Runs inside serial(channel.id).
406
+ */
407
+ async connect(channel) {
408
+ const platform = this.deps.getPlatformHub()?.get(channel.platform);
409
+ if (!platform) {
410
+ this.setState(channel, "failed", `No "${channel.platform}" platform is registered on this host`);
411
+ return null;
412
+ }
413
+ const generation = ++this.generation;
414
+ let adapter;
415
+ try {
416
+ adapter = platform.create(channel);
417
+ }
418
+ catch (err) {
419
+ this.setState(channel, "failed", errorMessage(err));
420
+ return null;
421
+ }
422
+ const entry = { channel, platform, adapter, generation };
423
+ const current = () => this.live.get(channel.id)?.generation === generation;
424
+ this.live.set(channel.id, entry);
425
+ this.setState(channel, "connecting");
426
+ let account;
427
+ try {
428
+ account = await adapter.start({
429
+ message: (message) => {
430
+ if (current())
431
+ this.onInbound(entry, message);
432
+ },
433
+ button: (press) => {
434
+ if (current())
435
+ this.onButton(entry, press);
436
+ },
437
+ status: (status, error) => {
438
+ if (!current())
439
+ return;
440
+ if (status === "failed") {
441
+ // The adapter gave up and stopped itself.
442
+ this.live.delete(channel.id);
443
+ this.deps.getPlatformHub()?.release(channel.id);
444
+ this.abortChats(channel.id);
445
+ }
446
+ this.setState(entry.channel, status, error);
447
+ },
448
+ });
449
+ }
450
+ catch (err) {
451
+ if (current())
452
+ this.live.delete(channel.id);
453
+ this.setState(channel, "failed", errorMessage(err));
454
+ return null;
455
+ }
456
+ if (!current())
457
+ return null;
458
+ const holder = this.deps
459
+ .getPlatformHub()
460
+ ?.claim(platform.name, account.id, channel.id);
461
+ if (holder !== undefined) {
462
+ this.live.delete(channel.id);
463
+ await adapter.stop().catch(() => undefined);
464
+ this.setState(channel, "failed", `This bot is already connected through another channel (${holder})`);
465
+ return null;
466
+ }
467
+ // Record the account on the stored channel (a new one may not be saved yet — create() saves it).
468
+ const storedRaw = await this.store().get(channel.id);
469
+ const stored = storedRaw ? withDefaults(storedRaw) : null;
470
+ if (stored && !sameAccount(stored.account, account)) {
471
+ const withAccount = { ...stored, account };
472
+ await this.store().save(withAccount);
473
+ entry.channel = withAccount;
474
+ }
475
+ else if (stored) {
476
+ entry.channel = stored;
477
+ }
478
+ if (current())
479
+ this.setState(entry.channel, "running");
480
+ if (current())
481
+ await this.publishCommands(entry);
482
+ return account;
483
+ }
484
+ /** Publish the chat commands to the platform, when the adapter can. A failure is logged, not thrown. */
485
+ async publishCommands(live) {
486
+ if (!live.adapter.setCommands)
487
+ return;
488
+ try {
489
+ await live.adapter.setCommands(this.botCommands());
490
+ }
491
+ catch (err) {
492
+ console.warn(`[channels] agent=${this.deps.agentId} channel=${live.channel.id} could not publish the commands: ${errorMessage(err)}`);
493
+ }
494
+ }
495
+ /** Stop the channel's adapter and its chats' turns. Runs inside serial(id). */
496
+ async disconnect(id) {
497
+ const live = this.live.get(id);
498
+ this.live.delete(id);
499
+ this.deps.getPlatformHub()?.release(id);
500
+ this.abortChats(id);
501
+ if (!live)
502
+ return;
503
+ try {
504
+ await live.adapter.stop();
505
+ }
506
+ catch (err) {
507
+ console.warn(`[channels] agent=${this.deps.agentId} channel=${id} did not stop cleanly:`, err);
508
+ }
509
+ this.setState(live.channel, "stopped");
510
+ }
511
+ /** Connect and disconnect calls of one channel run one at a time, in call order. */
512
+ serial(id, op) {
513
+ const prev = this.ops.get(id) ?? Promise.resolve();
514
+ const next = prev.catch(() => undefined).then(op);
515
+ this.ops.set(id, next);
516
+ void next
517
+ .finally(() => {
518
+ if (this.ops.get(id) === next)
519
+ this.ops.delete(id);
520
+ })
521
+ .catch(() => undefined);
522
+ return next;
523
+ }
524
+ setState(channel, status, error) {
525
+ const previous = this.states.get(channel.id);
526
+ if (previous?.status === status && previous.error === error)
527
+ return;
528
+ this.states.set(channel.id, {
529
+ status,
530
+ ...(error ? { error } : {}),
531
+ since: this.iso(this.now()),
532
+ });
533
+ if (status === "failed" || status === "retrying") {
534
+ console.warn(`[channels] agent=${this.deps.agentId} channel=${channel.id} (${channel.platform}) ${status}: ${error}`);
535
+ }
536
+ this.emit(SDKEventType.ChannelStatusChanged, "", {
537
+ agentId: this.deps.agentId,
538
+ channelId: channel.id,
539
+ platform: channel.platform,
540
+ status,
541
+ ...(error ? { error } : {}),
542
+ });
543
+ }
544
+ //#endregion
545
+ //#region Handle inbound messages
546
+ onInbound(live, message) {
547
+ if (this.disposed)
548
+ return;
549
+ const channel = live.channel;
550
+ if (this.isDuplicate(`${channel.id}\u0000${message.chat.id}\u0000${message.messageId}`))
551
+ return;
552
+ if (message.sender.isBot)
553
+ return;
554
+ // Only direct messages for now; group chats need mention rules first.
555
+ // -> Phase 2: group chats by groupPolicy and requireMention; broadcast channels stay ignored.
556
+ if (message.chat.type === "channel")
557
+ return;
558
+ const target = {
559
+ chatId: message.chat.id,
560
+ ...(message.chat.threadId ? { threadId: message.chat.threadId } : {}),
561
+ };
562
+ const command = parseCommand(message.text);
563
+ const username = channel.account?.username;
564
+ if (command?.target &&
565
+ username &&
566
+ command.target.toLowerCase() !== username.toLowerCase())
567
+ return;
568
+ if (message.chat.type === "group") {
569
+ // /whoami answers anywhere, so the owner can learn a group's id to allow it.
570
+ if (command?.name !== "whoami" &&
571
+ !this.groupAllowed(channel, message.chat.id))
572
+ return;
573
+ // A command counts as addressed to the bot (platforms deliver commands to it).
574
+ if (channel.access.requireMention &&
575
+ !command &&
576
+ !message.mentionsBot &&
577
+ !message.replyToBot)
578
+ return;
579
+ }
580
+ const handle = () => this.handleInbound(live, message, target, command).catch((err) => {
581
+ console.error(`[channels] agent=${this.deps.agentId} channel=${channel.id} could not handle a message:`, err);
582
+ });
583
+ const key = chatKey(channel.id, message);
584
+ // The answer to a question the running turn asked: it cannot wait in the queue behind that turn.
585
+ if (!command &&
586
+ this.mayTalk(channel, message) &&
587
+ this.prompts.hasQuestion(key)) {
588
+ if (this.prompts.answerText(key, message.sender, this.agentText(live, message, false)))
589
+ return;
590
+ }
591
+ if (command && IMMEDIATE_COMMANDS.includes(command.name)) {
592
+ // Answered at once, even while a turn of the chat is running.
593
+ void handle();
594
+ return;
595
+ }
596
+ // Everything else is handled in the chat's arrival order; other chats are not held up.
597
+ const prev = this.chatQueues.get(key) ?? Promise.resolve();
598
+ const next = prev.then(handle);
599
+ this.chatQueues.set(key, next);
600
+ void next.finally(() => {
601
+ if (this.chatQueues.get(key) === next)
602
+ this.chatQueues.delete(key);
603
+ });
604
+ }
605
+ async handleInbound(live, message, target, command) {
606
+ const channel = live.channel;
607
+ const label = platformLabel(live.platform);
608
+ // Answered for anyone, so a sender can tell the owner which id to allow.
609
+ if (command?.name === "whoami") {
610
+ const group = message.chat.type === "group"
611
+ ? `\nThis group's id is ${message.chat.id}.`
612
+ : "";
613
+ await this.reply(live, target, `Your ${label} id is ${message.sender.id}.${group}`);
614
+ return;
615
+ }
616
+ const access = channel.access;
617
+ // Group access was checked on arrival (groupAllowed); any member of an allowed group may talk.
618
+ if (message.chat.type === "dm" && access.dmPolicy === "disabled")
619
+ return;
620
+ if (!this.mayTalk(channel, message)) {
621
+ if (access.dmPolicy === "allowlist") {
622
+ await this.reply(live, target, `This bot is private. Ask its owner to add your ${label} id: ${message.sender.id}`);
623
+ }
624
+ else {
625
+ await this.requestPairing(live, message, target);
626
+ }
627
+ return;
628
+ }
629
+ const key = chatKey(channel.id, message);
630
+ // A-136: the agent's commands (its CommandManager) — all but the chat's own.
631
+ const commands = command && !CHAT_COMMANDS.has(command.name) ? this.deps.getCommands?.() : undefined;
632
+ const info = command && commands?.get(command.name, { client: "channel" });
633
+ if (command && commands && info) {
634
+ await this.runAgentCommand(live, message, target, key, command, commands, info);
635
+ return;
636
+ }
637
+ switch (command?.name) {
638
+ case "start":
639
+ case "help":
640
+ await this.reply(live, target, this.helpText());
641
+ return;
642
+ case "new":
643
+ case "reset":
644
+ // A-136: the CommandManager's /clear, done the chat's way (a session named after the chat).
645
+ case "clear": {
646
+ const session = await this.createSession(channel, message, live.platform);
647
+ this.chatSessions.set(key, session);
648
+ await this.reply(live, target, "Started a new conversation.");
649
+ return;
650
+ }
651
+ case "stop": {
652
+ const controller = this.chatRuns.get(key);
653
+ controller?.abort();
654
+ // Not running from now on, even before the turn has finished unwinding.
655
+ if (controller)
656
+ this.chatRuns.delete(key);
657
+ await this.reply(live, target, controller ? "Stopped." : "Nothing is running.");
658
+ return;
659
+ }
660
+ case "status": {
661
+ await this.reply(live, target, await this.statusText(channel, message, key));
662
+ return;
663
+ }
664
+ case "approve":
665
+ case "deny": {
666
+ const answer = this.prompts.answerCommand(key, message.sender, command.name === "approve", command.args);
667
+ if (answer.handled && answer.notice)
668
+ await this.reply(live, target, answer.notice);
669
+ return;
670
+ }
671
+ case "model":
672
+ await this.reply(live, target, await this.modelCommand(live, message, key, command.args));
673
+ return;
674
+ case "sethome":
675
+ await this.reply(live, target, await this.setHome(live, message));
676
+ return;
677
+ case "yolo":
678
+ await this.reply(live, target, await this.yoloCommand(live, message, key, command.args));
679
+ return;
680
+ }
681
+ if (!message.text.trim()) {
682
+ await this.reply(live, target, "I can only read text messages for now.");
683
+ return;
684
+ }
685
+ // handleInbound runs in the chat's queue here, so the turn runs in arrival order.
686
+ await this.runTurn(channel.id, message, target, key);
687
+ }
688
+ async runTurn(channelId, message, target, key,
689
+ /** A-136: a command's prompt (/review, /init) to send instead of the message's text. */
690
+ prompt) {
691
+ // Read again: the channel may have been stopped or edited while this message waited.
692
+ const live = this.live.get(channelId);
693
+ if (!live || this.disposed)
694
+ return;
695
+ const channel = live.channel;
696
+ if (!this.mayTalk(channel, message))
697
+ return;
698
+ if (message.chat.type === "group" &&
699
+ !this.groupAllowed(channel, message.chat.id))
700
+ return;
701
+ const sessionId = await this.resolveSession(channel, message, live.platform, key);
702
+ const controller = new AbortController();
703
+ this.chatRuns.set(key, controller);
704
+ this.emit(SDKEventType.ChannelMessageReceived, sessionId, {
705
+ agentId: this.deps.agentId,
706
+ channelId,
707
+ platform: channel.platform,
708
+ chatId: message.chat.id,
709
+ senderId: message.sender.id,
710
+ messageId: message.messageId,
711
+ });
712
+ const typing = this.keepTyping(live, target);
713
+ const view = new TurnView({
714
+ adapter: live.adapter,
715
+ target,
716
+ settings: channel.settings,
717
+ onError: (err) => this.warn(channelId, `could not update the chat: ${errorMessage(err)}`),
718
+ });
719
+ // Approvals and questions of this turn are asked in the chat (interactionFor).
720
+ this.activeTurns.set(sessionId, {
721
+ channelId,
722
+ key,
723
+ target,
724
+ chatType: message.chat.type,
725
+ initiator: message.sender,
726
+ });
727
+ let output;
728
+ try {
729
+ const result = await this.deps.getRunner()({
730
+ agentId: this.deps.agentId,
731
+ channel,
732
+ sessionId,
733
+ message,
734
+ text: prompt?.text ?? this.agentText(live, message, true),
735
+ signal: controller.signal,
736
+ ...(prompt?.readOnly ? { readOnly: true } : {}),
737
+ onChunk: (chunk) => view.chunk(chunk),
738
+ });
739
+ if (result.aborted || controller.signal.aborted) {
740
+ await view.abandon();
741
+ return;
742
+ }
743
+ output = result.output?.trim() ?? "";
744
+ if (!output && result.stopReason)
745
+ output = `(The agent stopped without a reply: ${result.stopReason}.)`;
746
+ }
747
+ catch (err) {
748
+ await view.abandon();
749
+ if (controller.signal.aborted)
750
+ return;
751
+ const error = errorMessage(err);
752
+ console.error(`[channels] agent=${this.deps.agentId} channel=${channelId} chat=${message.chat.id} turn failed: ${error}`);
753
+ this.emit(SDKEventType.ChannelFailed, sessionId, {
754
+ agentId: this.deps.agentId,
755
+ channelId,
756
+ platform: channel.platform,
757
+ chatId: message.chat.id,
758
+ error,
759
+ });
760
+ await this.reply(live, target, `Sorry, something went wrong: ${error}`);
761
+ return;
762
+ }
763
+ finally {
764
+ typing();
765
+ if (this.chatRuns.get(key) === controller)
766
+ this.chatRuns.delete(key);
767
+ if (this.activeTurns.get(sessionId)?.key === key)
768
+ this.activeTurns.delete(sessionId);
769
+ this.prompts.cancelChat(key, "the turn ended before anyone answered");
770
+ }
771
+ if (!output) {
772
+ await view.abandon();
773
+ return;
774
+ }
775
+ try {
776
+ const refs = await view.finish(output);
777
+ this.emit(SDKEventType.ChannelMessageSent, sessionId, {
778
+ agentId: this.deps.agentId,
779
+ channelId,
780
+ platform: channel.platform,
781
+ chatId: message.chat.id,
782
+ parts: refs.length,
783
+ });
784
+ }
785
+ catch (err) {
786
+ const error = errorMessage(err);
787
+ console.error(`[channels] agent=${this.deps.agentId} channel=${channelId} chat=${message.chat.id} reply failed: ${error}`);
788
+ this.emit(SDKEventType.ChannelFailed, sessionId, {
789
+ agentId: this.deps.agentId,
790
+ channelId,
791
+ platform: channel.platform,
792
+ chatId: message.chat.id,
793
+ error,
794
+ });
795
+ }
796
+ }
797
+ /** Shows "typing…" until the returned function is called. */
798
+ keepTyping(live, target) {
799
+ const sendTyping = live.adapter.sendTyping?.bind(live.adapter);
800
+ if (!sendTyping)
801
+ return () => undefined;
802
+ const tick = () => {
803
+ void sendTyping(target).catch(() => undefined);
804
+ };
805
+ tick();
806
+ const timer = setInterval(tick, TYPING_INTERVAL_MS);
807
+ timer.unref?.();
808
+ return () => clearInterval(timer);
809
+ }
810
+ //#endregion
811
+ //#region Sessions
812
+ /** The chat's current session: cached, else the newest one stored for it, else a new one. */
813
+ async resolveSession(channel, message, platform, key) {
814
+ const sessions = this.deps.getSessions();
815
+ const cached = this.chatSessions.get(key);
816
+ if (cached && (await sessions.get(cached)))
817
+ return cached;
818
+ const found = await this.findSession(channel, chatKeyOf(message));
819
+ const id = found ?? (await this.createSession(channel, message, platform));
820
+ this.chatSessions.set(key, id);
821
+ return id;
822
+ }
823
+ /** A-136: the chat's current session when it has one (cached, else stored) — never a new one. */
824
+ async existingSession(channel, message, key) {
825
+ const cached = this.chatSessions.get(key);
826
+ if (cached && (await this.deps.getSessions().get(cached)))
827
+ return cached;
828
+ return this.findSession(channel, chatKeyOf(message));
829
+ }
830
+ /**
831
+ * Phase 3: the current session of a chat the agent posts to unprompted (a job's result):
832
+ * the one its messages use, else a new one, so the chat's next message continues it.
833
+ */
834
+ async chatSession(channel, platform, target) {
835
+ const sessions = this.deps.getSessions();
836
+ const chatKey = target.threadId
837
+ ? `${target.chatId}:${target.threadId}`
838
+ : target.chatId;
839
+ const key = `${channel.id}\u0000${chatKey}`;
840
+ const cached = this.chatSessions.get(key);
841
+ if (cached && (await sessions.get(cached)))
842
+ return cached;
843
+ let id = await this.findSession(channel, chatKey);
844
+ if (!id) {
845
+ const home = isHomeTarget(channel.home, target) ? channel.home : undefined;
846
+ id = (await sessions.create({
847
+ agentId: this.deps.agentId,
848
+ source: "channel",
849
+ channelId: channel.id,
850
+ platform: channel.platform,
851
+ chatKey,
852
+ chatId: target.chatId,
853
+ title: `${home?.title ?? target.chatId} · ${platformLabel(platform)}`,
854
+ })).id;
855
+ }
856
+ this.chatSessions.set(key, id);
857
+ return id;
858
+ }
859
+ async findSession(channel, chatKey) {
860
+ const stored = await this.deps.getSessions().list({
861
+ metadata: {
862
+ agentId: this.deps.agentId,
863
+ source: "channel",
864
+ channelId: channel.id,
865
+ chatKey,
866
+ },
867
+ });
868
+ // A-136: the most recently used one (was: the newest created), so a conversation /resume
869
+ // went back to stays the chat's after a restart.
870
+ let newest;
871
+ for (const session of stored) {
872
+ if (!newest || session.updatedAt > newest.updatedAt)
873
+ newest = session;
874
+ }
875
+ return newest?.id;
876
+ }
877
+ async createSession(channel, message, platform) {
878
+ const sender = message.sender.name ??
879
+ (message.sender.username
880
+ ? `@${message.sender.username}`
881
+ : message.sender.id);
882
+ const session = await this.deps.getSessions().create({
883
+ // Same ownership key the host routes use, so the session lists and opens like any other.
884
+ agentId: this.deps.agentId,
885
+ source: "channel",
886
+ channelId: channel.id,
887
+ platform: channel.platform,
888
+ chatKey: chatKeyOf(message),
889
+ chatId: message.chat.id,
890
+ chatType: message.chat.type,
891
+ senderId: message.sender.id,
892
+ ...(message.sender.name ? { senderName: message.sender.name } : {}),
893
+ // A group's session is shared by its members, so it is named after the group.
894
+ title: `${message.chat.type === "group" && message.chat.title ? message.chat.title : sender} · ${platformLabel(platform)}`,
895
+ });
896
+ return session.id;
897
+ }
898
+ //#endregion
899
+ //#region Pairing
900
+ async requestPairing(live, message, target) {
901
+ const channel = live.channel;
902
+ const pending = this.pendingPairings(channel.id);
903
+ let pairing = pending.find((p) => p.senderId === message.sender.id);
904
+ if (!pairing) {
905
+ if (pending.length >= MAX_PENDING_PAIRINGS) {
906
+ await this.reply(live, target, "This bot is private, and too many people are waiting for approval right now. Please try again later.");
907
+ return;
908
+ }
909
+ const now = this.now();
910
+ pairing = {
911
+ code: pairingCode(),
912
+ channelId: channel.id,
913
+ senderId: message.sender.id,
914
+ ...(message.sender.name ? { senderName: message.sender.name } : {}),
915
+ chatId: message.chat.id,
916
+ requestedAt: this.iso(now),
917
+ expiresAt: this.iso(now + PAIRING_TTL_MS),
918
+ };
919
+ this.pairings.set(channel.id, [...pending, pairing]);
920
+ this.emit(SDKEventType.ChannelPairingRequested, "", {
921
+ agentId: this.deps.agentId,
922
+ channelId: channel.id,
923
+ platform: channel.platform,
924
+ code: pairing.code,
925
+ senderId: pairing.senderId,
926
+ ...(pairing.senderName ? { senderName: pairing.senderName } : {}),
927
+ expiresAt: pairing.expiresAt,
928
+ });
929
+ }
930
+ await this.reply(live, target, `This bot is private. Your pairing code is ${pairing.code} — ask its owner to approve it. The code expires in an hour.`);
931
+ }
932
+ /** The channel's unexpired pairings (expired ones are dropped). */
933
+ pendingPairings(channelId) {
934
+ const nowIso = this.iso(this.now());
935
+ const pending = (this.pairings.get(channelId) ?? []).filter((p) => p.expiresAt > nowIso);
936
+ if (pending.length)
937
+ this.pairings.set(channelId, pending);
938
+ else
939
+ this.pairings.delete(channelId);
940
+ return pending;
941
+ }
942
+ takePairing(channelId, code) {
943
+ const wanted = code.trim().toUpperCase();
944
+ const pending = this.pendingPairings(channelId);
945
+ const pairing = pending.find((p) => p.code === wanted);
946
+ if (!pairing)
947
+ throw new ChannelError(`No pending pairing with code "${code}"`, "not_found", channelId);
948
+ const rest = pending.filter((p) => p !== pairing);
949
+ if (rest.length)
950
+ this.pairings.set(channelId, rest);
951
+ else
952
+ this.pairings.delete(channelId);
953
+ return pairing;
954
+ }
955
+ //#endregion
956
+ //#region Home chat and scheduled-job delivery (phase 3)
957
+ /**
958
+ * /sethome — make this chat the channel's home, where jobs delivering to "home" post.
959
+ * Only the bot's owners (allowFrom) may: in an open DM or group anyone can talk, and
960
+ * the home chat receives what the agent produces unattended.
961
+ */
962
+ async setHome(live, message) {
963
+ if (!live.channel.access.allowFrom.includes(message.sender.id))
964
+ return "Only the bot's owners (the senders on its allow list) can choose the home chat.";
965
+ // Re-read so a change saved since this channel connected is not lost.
966
+ const stored = await this.require(live.channel.id);
967
+ const nowIso = this.iso(this.now());
968
+ const sender = message.sender.name ??
969
+ (message.sender.username
970
+ ? `@${message.sender.username}`
971
+ : message.sender.id);
972
+ const title = message.chat.type === "dm" ? sender : (message.chat.title ?? sender);
973
+ const home = {
974
+ chatId: message.chat.id,
975
+ ...(message.chat.threadId ? { threadId: message.chat.threadId } : {}),
976
+ title,
977
+ setBy: message.sender.id,
978
+ setAt: nowIso,
979
+ };
980
+ const updated = { ...stored, home, updatedAt: nowIso };
981
+ await this.store().save(updated);
982
+ const current = this.live.get(updated.id);
983
+ if (current)
984
+ current.channel = updated;
985
+ return `This is now the home chat of ${updated.name}: jobs that deliver to "home" post their results here.`;
986
+ }
987
+ /**
988
+ * A prompt job of this agent ended; send its result when its delivery asks for it.
989
+ * A-70: a trigger run of this agent ended; send its result when the trigger's delivery asks
990
+ * for it. Sent with the run's session, so a delivery failure (channel:error) carries the
991
+ * run's depth and can't wake another trigger by default.
992
+ * Update (A-126): one handler for every job run (schedule, event or webhook).
993
+ */
994
+ onJobRunFinished(event) {
995
+ const payload = event.payload;
996
+ if (this.disposed || payload.agentId !== this.deps.agentId)
997
+ return;
998
+ // Update (A-127): each delivery on its own — its own "when", and one chat that fails
999
+ // does not stop the others.
1000
+ for (const delivery of payload.deliveries ?? []) {
1001
+ const result = jobResult(payload, delivery);
1002
+ if (!result)
1003
+ continue;
1004
+ this.track(delivery, { name: payload.jobName ?? "job", id: payload.jobId }, event.sessionId, result);
1005
+ }
1006
+ }
1007
+ /** Start one delivery; dispose waits for the ones still sending. */
1008
+ track(delivery, origin, sessionId, result) {
1009
+ const done = this.deliver(delivery, origin, sessionId, result).catch((err) => this.warn(delivery.channelId, `could not deliver ${originLabel(origin)}: ${errorMessage(err)}`));
1010
+ this.deliveries.add(done);
1011
+ void done.finally(() => this.deliveries.delete(done));
1012
+ }
1013
+ /** Send one job (or trigger run) result. Failures are logged and published as channel:error, never thrown. */
1014
+ async deliver(delivery, origin, sessionId, result) {
1015
+ const channel = await this.get(delivery.channelId);
1016
+ const fail = (error, chatId) => {
1017
+ this.warn(delivery.channelId, `could not deliver ${originLabel(origin)}: ${error}`);
1018
+ this.emit(SDKEventType.ChannelFailed, sessionId, {
1019
+ agentId: this.deps.agentId,
1020
+ channelId: delivery.channelId,
1021
+ platform: channel?.platform ?? "",
1022
+ ...(chatId ? { chatId } : {}),
1023
+ error,
1024
+ ...originIds(origin),
1025
+ });
1026
+ };
1027
+ if (!channel) {
1028
+ fail("this agent has no such channel");
1029
+ return;
1030
+ }
1031
+ let target;
1032
+ if (delivery.target === "home") {
1033
+ if (!channel.home) {
1034
+ fail(`the channel "${channel.name}" has no home chat — send /sethome in the chat that should get the results`);
1035
+ return;
1036
+ }
1037
+ target = {
1038
+ chatId: channel.home.chatId,
1039
+ ...(channel.home.threadId ? { threadId: channel.home.threadId } : {}),
1040
+ };
1041
+ }
1042
+ else {
1043
+ target = {
1044
+ chatId: delivery.target,
1045
+ ...(delivery.threadId ? { threadId: delivery.threadId } : {}),
1046
+ };
1047
+ }
1048
+ // A channel still connecting (a catch-up run right after a restart) is waited for.
1049
+ await this.ops.get(channel.id)?.catch(() => undefined);
1050
+ const live = this.live.get(channel.id);
1051
+ if (!live || this.state(channel.id).status === "failed") {
1052
+ fail("the channel is not connected", target.chatId);
1053
+ return;
1054
+ }
1055
+ try {
1056
+ const refs = await this.sendResult(live, target, origin, result);
1057
+ this.emit(SDKEventType.ChannelMessageSent, sessionId, {
1058
+ agentId: this.deps.agentId,
1059
+ channelId: channel.id,
1060
+ platform: channel.platform,
1061
+ chatId: target.chatId,
1062
+ parts: refs.length,
1063
+ ...originIds(origin),
1064
+ });
1065
+ }
1066
+ catch (err) {
1067
+ fail(errorMessage(err), target.chatId);
1068
+ return;
1069
+ }
1070
+ await this.recordResult(channel, live.platform, target, origin, result);
1071
+ }
1072
+ /**
1073
+ * Add a delivered result to the chat's conversation as the agent's message, so the
1074
+ * chat's next turn knows what was posted. The job's own session keeps the run as before.
1075
+ * A failure is logged: the result was delivered either way.
1076
+ */
1077
+ async recordResult(channel, platform, target, origin, result) {
1078
+ if (!this.deps.appendMessage)
1079
+ return;
1080
+ try {
1081
+ const sessionId = await this.chatSession(channel, platform, target);
1082
+ await this.deps.appendMessage(sessionId, {
1083
+ role: "assistant",
1084
+ content: resultText(origin, result, true),
1085
+ });
1086
+ }
1087
+ catch (err) {
1088
+ this.warn(channel.id, `could not add ${originLabel(origin)} to the chat's conversation: ${errorMessage(err)}`);
1089
+ }
1090
+ }
1091
+ /** The job's result as chat messages: Markdown when the adapter renders it, split to its length. */
1092
+ async sendResult(live, target, origin, result) {
1093
+ const { maxMessageLength, markdown } = live.adapter.capabilities;
1094
+ const text = resultText(origin, result, markdown === true);
1095
+ const parts = markdown
1096
+ ? splitMarkdown(text, maxMessageLength)
1097
+ : splitMessage(text, maxMessageLength);
1098
+ const refs = [];
1099
+ for (const part of parts) {
1100
+ refs.push(await live.adapter.send(target, markdown ? { text: part, format: "markdown" } : { text: part }));
1101
+ }
1102
+ return refs;
1103
+ }
1104
+ //#endregion
1105
+ //#region Helpers
1106
+ async sendText(live, target, text) {
1107
+ const refs = [];
1108
+ for (const part of splitMessage(text, live.adapter.capabilities.maxMessageLength)) {
1109
+ refs.push(await live.adapter.send(target, { text: part }));
1110
+ }
1111
+ return refs;
1112
+ }
1113
+ /** Send a short notice; a failure is logged, not thrown. */
1114
+ async reply(live, target, text) {
1115
+ try {
1116
+ await this.sendText(live, target, text);
1117
+ }
1118
+ catch (err) {
1119
+ console.warn(`[channels] agent=${this.deps.agentId} channel=${live.channel.id} could not reply: ${errorMessage(err)}`);
1120
+ }
1121
+ }
1122
+ helpText() {
1123
+ return [
1124
+ `Hi! Send a message to talk to ${this.deps.getAgentName()}.`,
1125
+ "",
1126
+ ...CHANNEL_COMMANDS.filter((c) => c.name !== "help").map((c) => `/${c.name} — ${c.description.charAt(0).toLowerCase()}${c.description.slice(1)}`),
1127
+ // A-136: and the agent's commands that work in a chat.
1128
+ ...this.agentCommands().map(helpLine),
1129
+ ].join("\n");
1130
+ }
1131
+ /** A-136: the agent's commands a chat can run (not the chat's own, none needing a client capability). */
1132
+ agentCommands() {
1133
+ return (this.deps.getCommands?.()?.list({ client: "channel" }) ?? []).filter((c) => c.available && !CHAT_COMMANDS.has(c.name));
1134
+ }
1135
+ /** The commands published to the platform: the chat's own, then the agent's (the names a platform takes). */
1136
+ botCommands() {
1137
+ const names = new Set(CHANNEL_COMMANDS.map((c) => c.name));
1138
+ const extra = this.agentCommands()
1139
+ .filter((c) => PUBLISHABLE_NAME.test(c.name) && !names.has(c.name))
1140
+ .map((c) => ({ name: c.name, description: c.description }));
1141
+ return [...CHANNEL_COMMANDS, ...extra].slice(0, MAX_PUBLISHED_COMMANDS);
1142
+ }
1143
+ /**
1144
+ * A-136: run one of the agent's commands in the chat. Privileged ones that change something
1145
+ * (/permissions yolo) are for the bot's owners only — they typed it, which counts as the
1146
+ * confirmation the web app asks for. The result's action is carried out here: a session
1147
+ * picked by /resume becomes the chat's, a prompt (/plan <prompt>, /init, /review) runs as a turn.
1148
+ */
1149
+ async runAgentCommand(live, message, target, key, command, commands, info) {
1150
+ const channel = live.channel;
1151
+ const owner = channel.access.allowFrom.includes(message.sender.id);
1152
+ if (info.safety === "privileged" && command.args && !owner) {
1153
+ await this.reply(live, target, info.name === "yolo"
1154
+ ? "Only the bot's owners (the senders on its allow list) can switch YOLO mode."
1155
+ : `Only the bot's owners (the senders on its allow list) can use /${info.name} to change things.`);
1156
+ return;
1157
+ }
1158
+ // A read-only command does not start a conversation the chat does not have yet.
1159
+ let sessionId;
1160
+ if (info.safety === "read-only") {
1161
+ const existing = await this.existingSession(channel, message, key);
1162
+ if (!existing) {
1163
+ await this.reply(live, target, info.name === "status" ? await this.statusText(channel, message, key) : "No conversation yet.");
1164
+ return;
1165
+ }
1166
+ sessionId = existing;
1167
+ }
1168
+ else {
1169
+ sessionId = await this.resolveSession(channel, message, live.platform, key);
1170
+ }
1171
+ const result = await commands.run(`/${info.name}${command.args ? ` ${command.args}` : ""}`, {
1172
+ sessionId,
1173
+ client: "channel",
1174
+ confirmed: true,
1175
+ sessionScope: { agentId: this.deps.agentId, source: "channel", channelId: channel.id, chatKey: chatKeyOf(message) },
1176
+ });
1177
+ let text = result.text;
1178
+ if (info.name === "status" && !result.error) {
1179
+ const extra = [];
1180
+ if (isHome(channel.home, message))
1181
+ extra.push("This is the home chat: job results are sent here.");
1182
+ if (this.chatRuns.has(key))
1183
+ extra.push("A reply is in progress (/stop to stop it).");
1184
+ if (extra.length)
1185
+ text = `${text}\n${extra.join("\n")}`;
1186
+ }
1187
+ await this.reply(live, target, text);
1188
+ const action = result.action;
1189
+ if (action?.type === "open-session")
1190
+ this.chatSessions.set(key, action.sessionId);
1191
+ else if (action?.type === "send-prompt") {
1192
+ await this.runTurn(channel.id, message, target, key, {
1193
+ text: action.prompt,
1194
+ ...(action.readOnly ? { readOnly: true } : {}),
1195
+ });
1196
+ }
1197
+ }
1198
+ /** A button press: an approval or a question's choice. */
1199
+ onButton(live, press) {
1200
+ if (this.disposed || press.sender.isBot)
1201
+ return;
1202
+ const channel = live.channel;
1203
+ const message = {
1204
+ messageId: press.messageId,
1205
+ chat: press.chat,
1206
+ sender: press.sender,
1207
+ text: "",
1208
+ };
1209
+ if (press.chat.type === "group"
1210
+ ? !this.groupAllowed(channel, press.chat.id)
1211
+ : !this.mayTalk(channel, message))
1212
+ return;
1213
+ const answer = this.prompts.answerButton(chatKey(channel.id, message), press.sender, press.data);
1214
+ if (answer.handled && answer.notice) {
1215
+ void this.reply(live, {
1216
+ chatId: press.chat.id,
1217
+ ...(press.chat.threadId ? { threadId: press.chat.threadId } : {}),
1218
+ }, answer.notice);
1219
+ }
1220
+ }
1221
+ /**
1222
+ * Whether the sender may talk to the agent in this chat: in a direct message by
1223
+ * dmPolicy and allowFrom; in a group, any member once the group is allowed.
1224
+ */
1225
+ mayTalk(channel, message) {
1226
+ if (message.chat.type === "group")
1227
+ return this.groupAllowed(channel, message.chat.id);
1228
+ const access = channel.access;
1229
+ if (access.dmPolicy === "disabled")
1230
+ return false;
1231
+ return (access.dmPolicy === "open" || access.allowFrom.includes(message.sender.id));
1232
+ }
1233
+ groupAllowed(channel, chatId) {
1234
+ const access = channel.access;
1235
+ return (access.groupPolicy === "open" ||
1236
+ (access.groupPolicy === "allowlist" && access.groups.includes(chatId)));
1237
+ }
1238
+ /**
1239
+ * The message as the agent reads it: the bot's @-mention removed, and in a group
1240
+ * (`withSender`) prefixed with who wrote it, since several people share the session.
1241
+ */
1242
+ agentText(live, message, withSender) {
1243
+ let text = message.text;
1244
+ const username = live.channel.account?.username;
1245
+ if (username)
1246
+ text = text
1247
+ .replace(new RegExp(`@${escapeRegExp(username)}\\b`, "gi"), " ")
1248
+ .replace(/[ \t]{2,}/g, " ");
1249
+ text = text.trim();
1250
+ if (!withSender || message.chat.type !== "group")
1251
+ return text;
1252
+ const sender = message.sender.name ??
1253
+ (message.sender.username
1254
+ ? `@${message.sender.username}`
1255
+ : message.sender.id);
1256
+ return `[${sender}]: ${text}`;
1257
+ }
1258
+ /** /model — show the conversation's model, or switch it ("/model default" goes back to the agent's). */
1259
+ async modelCommand(live, message, key, args) {
1260
+ const sessions = this.deps.getSessions();
1261
+ const sessionId = await this.resolveSession(live.channel, message, live.platform, key);
1262
+ const session = await sessions.get(sessionId);
1263
+ if (!session)
1264
+ return "No conversation yet.";
1265
+ const agentModel = this.deps.getDefaultModel?.();
1266
+ let models;
1267
+ try {
1268
+ models = await this.deps.listModels?.();
1269
+ }
1270
+ catch {
1271
+ models = undefined;
1272
+ }
1273
+ const wanted = args.trim();
1274
+ if (!wanted) {
1275
+ const lines = [
1276
+ session.llmModel
1277
+ ? `Model: ${session.llmModel}`
1278
+ : `Model: ${agentModel ?? "the provider's default"} (the agent's default)`,
1279
+ ];
1280
+ if (models?.length) {
1281
+ lines.push("", "Available:", ...models.slice(0, MAX_LISTED_MODELS).map((m) => `• ${m}`));
1282
+ if (models.length > MAX_LISTED_MODELS)
1283
+ lines.push(`… and ${models.length - MAX_LISTED_MODELS} more`);
1284
+ }
1285
+ lines.push("", "Switch with /model <name>; /model default goes back to the agent's model.");
1286
+ return lines.join("\n");
1287
+ }
1288
+ if (wanted.toLowerCase() === "default") {
1289
+ delete session.llmModel;
1290
+ }
1291
+ else {
1292
+ const match = models?.find((m) => m.toLowerCase() === wanted.toLowerCase());
1293
+ if (models?.length && !match)
1294
+ return `There is no model "${wanted}". Send /model to see the list.`;
1295
+ session.llmModel = match ?? wanted;
1296
+ }
1297
+ session.updatedAt = this.now();
1298
+ await sessions.update(session);
1299
+ return session.llmModel
1300
+ ? `This conversation now uses ${session.llmModel}.`
1301
+ : `This conversation now uses the agent's model${agentModel ? ` (${agentModel})` : ""}.`;
1302
+ }
1303
+ /**
1304
+ * A-135: /yolo [on|off] — show or switch the conversation's approval mode. In YOLO mode
1305
+ * the agent runs tools that need approval without asking here. Only the bot's owners
1306
+ * (allowFrom) may switch it: in an open DM or group anyone can talk.
1307
+ */
1308
+ async yoloCommand(live, message, key, args) {
1309
+ const { getApprovalMode, setApprovalMode } = this.deps;
1310
+ if (!getApprovalMode || !setApprovalMode)
1311
+ return "YOLO mode is not available for this agent.";
1312
+ const sessionId = await this.resolveSession(live.channel, message, live.platform, key);
1313
+ const wanted = args.trim().toLowerCase();
1314
+ if (!wanted) {
1315
+ return (await getApprovalMode(sessionId)) === "yolo"
1316
+ ? "YOLO mode is on: tools run without asking. Send /yolo off to ask again."
1317
+ : "YOLO mode is off: tools that need approval ask here first. Send /yolo on to run them without asking.";
1318
+ }
1319
+ if (wanted !== "on" && wanted !== "off")
1320
+ return "Send /yolo on or /yolo off.";
1321
+ if (!live.channel.access.allowFrom.includes(message.sender.id))
1322
+ return "Only the bot's owners (the senders on its allow list) can switch YOLO mode.";
1323
+ await setApprovalMode(sessionId, wanted === "on" ? "yolo" : "ask");
1324
+ return wanted === "on"
1325
+ ? "YOLO mode is on: tools in this conversation run without asking, until /yolo off."
1326
+ : "YOLO mode is off: tools that need approval ask here first.";
1327
+ }
1328
+ warn(channelId, text) {
1329
+ console.warn(`[channels] agent=${this.deps.agentId} channel=${channelId} ${text}`);
1330
+ }
1331
+ async statusText(channel, message, key) {
1332
+ const sessions = this.deps.getSessions();
1333
+ const cached = this.chatSessions.get(key);
1334
+ const sessionId = (cached && (await sessions.get(cached)) ? cached : undefined) ??
1335
+ (await this.findSession(channel, chatKeyOf(message)));
1336
+ const session = sessionId ? await sessions.get(sessionId) : null;
1337
+ const lines = [`Agent: ${this.deps.getAgentName()}`];
1338
+ lines.push(session
1339
+ ? `Conversation started ${this.iso(session.createdAt).slice(0, 16).replace("T", " ")} UTC`
1340
+ : "No conversation yet.");
1341
+ const model = session?.llmModel ?? this.deps.getDefaultModel?.();
1342
+ if (model)
1343
+ lines.push(`Model: ${model}`);
1344
+ if (session && (await this.deps.getApprovalMode?.(session.id)) === "yolo")
1345
+ lines.push("YOLO mode: tools run without asking (/yolo off to stop).");
1346
+ if (isHome(channel.home, message))
1347
+ lines.push("This is the home chat: job results are sent here.");
1348
+ if (this.chatRuns.has(key))
1349
+ lines.push("A reply is in progress (/stop to stop it).");
1350
+ return lines.join("\n");
1351
+ }
1352
+ abortChats(channelId) {
1353
+ for (const [key, controller] of this.chatRuns) {
1354
+ if (key.startsWith(`${channelId}\u0000`))
1355
+ controller.abort();
1356
+ }
1357
+ this.prompts.cancelPrefix(`${channelId}\u0000`, "the channel stopped");
1358
+ }
1359
+ isDuplicate(key) {
1360
+ if (this.seen.has(key))
1361
+ return true;
1362
+ this.seen.add(key);
1363
+ if (this.seen.size > MAX_SEEN_MESSAGES) {
1364
+ const oldest = this.seen.values().next().value;
1365
+ if (oldest !== undefined)
1366
+ this.seen.delete(oldest);
1367
+ }
1368
+ return false;
1369
+ }
1370
+ requirePlatform(name) {
1371
+ const platform = this.deps.getPlatformHub()?.get(name);
1372
+ if (!platform)
1373
+ throw new ChannelError(`No "${name}" channel platform is registered on this host`, "unknown_platform");
1374
+ return platform;
1375
+ }
1376
+ async require(id) {
1377
+ const channel = await this.get(id);
1378
+ if (!channel)
1379
+ throw new ChannelError(`No channel "${id}" for this agent`, "not_found", id);
1380
+ return channel;
1381
+ }
1382
+ emit(type, sessionId, payload) {
1383
+ this.deps.eventBus.emit({ type, sessionId, payload });
1384
+ }
1385
+ store() {
1386
+ return this.deps.getStore();
1387
+ }
1388
+ iso(ms) {
1389
+ return new Date(ms).toISOString();
1390
+ }
1391
+ }
1392
+ function originLabel(origin) {
1393
+ return `job "${origin.name}"`;
1394
+ }
1395
+ /** The jobId field of channel events about a delivery. */
1396
+ function originIds(origin) {
1397
+ return { jobId: origin.id };
1398
+ }
1399
+ /**
1400
+ * The result to deliver for a finished trigger run, or undefined when there is nothing to send.
1401
+ * Update (A-126): for any job run; a silent run ([[SILENT]]) has nothing to send.
1402
+ */
1403
+ function jobResult(payload, delivery) {
1404
+ // Suppressed (resolved, stale, disabled) and stopped runs did nothing worth reporting.
1405
+ if (payload.status === "suppressed" || payload.status === "stopped")
1406
+ return undefined;
1407
+ if (payload.silent)
1408
+ return undefined;
1409
+ if (payload.status === "failed" || payload.status === "blocked") {
1410
+ // A-103: a run that paused its job is always reported, so the job never goes quiet unseen.
1411
+ if (delivery.when === "on-output" && !payload.paused)
1412
+ return undefined;
1413
+ const paused = payload.paused ? { paused: true } : {};
1414
+ return payload.status === "failed"
1415
+ ? { kind: "failed", error: payload.error ?? "the run failed", ...paused }
1416
+ : {
1417
+ kind: "blocked",
1418
+ reason: payload.reason ?? "the run was blocked",
1419
+ // What the agent said about it (e.g. which approval it needed).
1420
+ ...(payload.output?.trim() ? { text: payload.output.trim() } : {}),
1421
+ ...paused,
1422
+ };
1423
+ }
1424
+ if (delivery.when === "on-failure")
1425
+ return undefined;
1426
+ const text = payload.output?.trim() ?? "";
1427
+ if (text)
1428
+ return { kind: "reply", text };
1429
+ return delivery.when === "always" ? { kind: "empty" } : undefined;
1430
+ }
1431
+ /** What the chat sees for a job's (or trigger's) result; `markdown` bolds its name. */
1432
+ function resultText(origin, result, markdown) {
1433
+ const name = origin.name;
1434
+ const what = "Job";
1435
+ if (result.kind === "reply")
1436
+ return `${markdown ? `**${name}**` : name}\n\n${result.text}`;
1437
+ if (result.kind === "empty")
1438
+ return `${what} "${name}" finished without a reply.`;
1439
+ // A-103: the job turned itself off after this run.
1440
+ const pausedNote = "paused" in result && result.paused
1441
+ ? `
1442
+
1443
+ The job is now paused after too many failed runs in a row. Turn it back on on the agent's Jobs page once it's fixed.`
1444
+ : "";
1445
+ if (result.kind === "blocked")
1446
+ return `${what} "${name}" stopped without finishing: ${result.reason}${result.text ? `
1447
+
1448
+ ${result.text}` : ""}${pausedNote}`;
1449
+ return `${what} "${name}" failed: ${result.error}${pausedNote}`;
1450
+ }
1451
+ function isHomeTarget(home, target) {
1452
+ return (home !== undefined &&
1453
+ home.chatId === target.chatId &&
1454
+ (home.threadId ?? "") === (target.threadId ?? ""));
1455
+ }
1456
+ function isHome(home, message) {
1457
+ return (home !== undefined &&
1458
+ home.chatId === message.chat.id &&
1459
+ (home.threadId ?? "") === (message.chat.threadId ?? ""));
1460
+ }
1461
+ function validateHome(value, setAt) {
1462
+ if (typeof value !== "object" || value === null || Array.isArray(value))
1463
+ throw new ChannelError('"home" must be { chatId, threadId?, title? } or null', "invalid_argument");
1464
+ const v = value;
1465
+ const field = (key) => {
1466
+ const raw = v[key];
1467
+ if (raw === undefined)
1468
+ return undefined;
1469
+ if (typeof raw !== "string")
1470
+ throw new ChannelError(`"home.${key}" must be a string`, "invalid_argument");
1471
+ return raw.trim() || undefined;
1472
+ };
1473
+ const chatId = field("chatId");
1474
+ if (!chatId)
1475
+ throw new ChannelError('"home.chatId" is required', "invalid_argument");
1476
+ const threadId = field("threadId");
1477
+ const title = field("title");
1478
+ return {
1479
+ chatId,
1480
+ ...(threadId ? { threadId } : {}),
1481
+ ...(title ? { title } : {}),
1482
+ setAt,
1483
+ };
1484
+ }
1485
+ /** A chat inside its channel: the chat id, plus the thread when there is one. */
1486
+ function chatKeyOf(message) {
1487
+ return message.chat.threadId
1488
+ ? `${message.chat.id}:${message.chat.threadId}`
1489
+ : message.chat.id;
1490
+ }
1491
+ function chatKey(channelId, message) {
1492
+ return `${channelId}\u0000${chatKeyOf(message)}`;
1493
+ }
1494
+ function platformLabel(platform) {
1495
+ return platform.displayName ?? platform.name;
1496
+ }
1497
+ function sameAccount(a, b) {
1498
+ return (a?.id === b?.id &&
1499
+ a?.username === b?.username &&
1500
+ a?.displayName === b?.displayName);
1501
+ }
1502
+ function pairingCode() {
1503
+ let code = "";
1504
+ for (let i = 0; i < PAIRING_CODE_LENGTH; i++)
1505
+ code += PAIRING_ALPHABET[randomInt(PAIRING_ALPHABET.length)];
1506
+ return code;
1507
+ }
1508
+ function errorMessage(err) {
1509
+ return err instanceof Error ? err.message : String(err);
1510
+ }
1511
+ function validateName(value) {
1512
+ const name = typeof value === "string" ? value.trim() : "";
1513
+ if (!name)
1514
+ throw new ChannelError('A channel "name" cannot be empty', "invalid_argument");
1515
+ if (name.length > MAX_CHANNEL_NAME_LENGTH)
1516
+ throw new ChannelError(`Channel name is longer than ${MAX_CHANNEL_NAME_LENGTH} characters`, "invalid_argument");
1517
+ return name;
1518
+ }
1519
+ function validateCredentials(platform, value) {
1520
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
1521
+ throw new ChannelError('"credentials" must be an object of strings', "invalid_argument");
1522
+ }
1523
+ const credentials = {};
1524
+ for (const [key, v] of Object.entries(value)) {
1525
+ if (typeof v !== "string")
1526
+ throw new ChannelError(`Credential "${key}" must be a string`, "invalid_argument");
1527
+ credentials[key] = v.trim();
1528
+ }
1529
+ for (const key of platform.credentialKeys) {
1530
+ if (!credentials[key])
1531
+ throw new ChannelError(`${platformLabel(platform)} needs the "${key}" credential`, "invalid_argument");
1532
+ }
1533
+ return credentials;
1534
+ }
1535
+ function validateAccess(value) {
1536
+ const policies = ["pairing", "allowlist", "open", "disabled"];
1537
+ if (!policies.includes(value.dmPolicy)) {
1538
+ throw new ChannelError(`"dmPolicy" must be one of ${policies.join(", ")}`, "invalid_argument");
1539
+ }
1540
+ if (!Array.isArray(value.allowFrom) ||
1541
+ value.allowFrom.some((id) => typeof id !== "string")) {
1542
+ throw new ChannelError('"allowFrom" must be a list of sender ids', "invalid_argument");
1543
+ }
1544
+ const allowFrom = [
1545
+ ...new Set(value.allowFrom.map((id) => id.trim()).filter(Boolean)),
1546
+ ];
1547
+ const groupPolicies = ["disabled", "allowlist", "open"];
1548
+ if (!groupPolicies.includes(value.groupPolicy)) {
1549
+ throw new ChannelError(`"groupPolicy" must be one of ${groupPolicies.join(", ")}`, "invalid_argument");
1550
+ }
1551
+ if (!Array.isArray(value.groups) ||
1552
+ value.groups.some((id) => typeof id !== "string")) {
1553
+ throw new ChannelError('"groups" must be a list of group chat ids', "invalid_argument");
1554
+ }
1555
+ if (typeof value.requireMention !== "boolean") {
1556
+ throw new ChannelError('"requireMention" must be true or false', "invalid_argument");
1557
+ }
1558
+ const groups = [
1559
+ ...new Set(value.groups.map((id) => id.trim()).filter(Boolean)),
1560
+ ];
1561
+ return {
1562
+ dmPolicy: value.dmPolicy,
1563
+ allowFrom,
1564
+ groupPolicy: value.groupPolicy,
1565
+ groups,
1566
+ requireMention: value.requireMention,
1567
+ };
1568
+ }
1569
+ function validateSettings(value) {
1570
+ if (typeof value.streaming !== "boolean")
1571
+ throw new ChannelError('"streaming" must be true or false', "invalid_argument");
1572
+ if (typeof value.toolProgress !== "boolean")
1573
+ throw new ChannelError('"toolProgress" must be true or false', "invalid_argument");
1574
+ return { streaming: value.streaming, toolProgress: value.toolProgress };
1575
+ }
1576
+ /** A stored channel with the fields added after it was saved (phase 2) set to their defaults. */
1577
+ function withDefaults(channel) {
1578
+ const access = channel.access;
1579
+ const settings = channel.settings;
1580
+ return {
1581
+ ...channel,
1582
+ access: { ...DEFAULT_ACCESS, ...access },
1583
+ settings: { ...DEFAULT_SETTINGS, ...settings },
1584
+ };
1585
+ }
1586
+ function escapeRegExp(text) {
1587
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5
1588
  }
6
1589
  //# sourceMappingURL=channel-manager.js.map