@xopcai/xopc 0.0.103 → 0.0.105

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 (950) hide show
  1. package/README.md +7 -4
  2. package/README.zh-CN.md +7 -4
  3. package/dist/_virtual/_rolldown/runtime.js +2 -3
  4. package/dist/browser-ext/manifest.json +1 -1
  5. package/dist/extensions/feishu/src/adapters/cli-login.d.ts +1 -1
  6. package/dist/extensions/feishu/src/adapters/cli-login.js +1 -1
  7. package/dist/extensions/feishu/src/adapters/cli-login.js.map +1 -1
  8. package/dist/extensions/feishu/src/adapters/gateway-setup.d.ts +2 -0
  9. package/dist/extensions/feishu/src/adapters/gateway-setup.js +225 -0
  10. package/dist/extensions/feishu/src/adapters/gateway-setup.js.map +1 -0
  11. package/dist/extensions/feishu/src/index.d.ts +8 -1
  12. package/dist/extensions/feishu/src/index.js +14 -1
  13. package/dist/extensions/feishu/src/index.js.map +1 -0
  14. package/dist/extensions/feishu/src/outbound/outbound-adapter.js +1 -1
  15. package/dist/extensions/feishu/src/plugin.d.ts +2 -1
  16. package/dist/extensions/feishu/src/plugin.js +2 -0
  17. package/dist/extensions/feishu/src/plugin.js.map +1 -1
  18. package/dist/extensions/feishu/src/streaming/streaming-adapter.js +1 -1
  19. package/dist/extensions/feishu/src/transport/webhook/monitor.js +1 -1
  20. package/dist/extensions/feishu/xopc.extension.json +66 -1
  21. package/dist/extensions/telegram/src/adapters/gateway-setup.d.ts +2 -0
  22. package/dist/extensions/telegram/src/adapters/gateway-setup.js +146 -0
  23. package/dist/extensions/telegram/src/adapters/gateway-setup.js.map +1 -0
  24. package/dist/extensions/telegram/src/adapters/security-adapter.js +1 -1
  25. package/dist/extensions/telegram/src/command-handler.js +1 -2
  26. package/dist/extensions/telegram/src/command-handler.js.map +1 -1
  27. package/dist/extensions/telegram/src/config-schema.js +2 -2
  28. package/dist/extensions/telegram/src/config-schema.js.map +1 -1
  29. package/dist/extensions/telegram/src/doctor.d.ts +1 -0
  30. package/dist/extensions/telegram/src/doctor.js +68 -0
  31. package/dist/extensions/telegram/src/doctor.js.map +1 -1
  32. package/dist/extensions/telegram/src/index.d.ts +8 -1
  33. package/dist/extensions/telegram/src/index.js +15 -2
  34. package/dist/extensions/telegram/src/index.js.map +1 -0
  35. package/dist/extensions/telegram/src/plugin.d.ts +13 -5
  36. package/dist/extensions/telegram/src/plugin.js +32 -12
  37. package/dist/extensions/telegram/src/plugin.js.map +1 -1
  38. package/dist/extensions/telegram/src/proxy-fetch.js +22 -5
  39. package/dist/extensions/telegram/src/proxy-fetch.js.map +1 -1
  40. package/dist/extensions/telegram/xopc.extension.json +412 -5
  41. package/dist/extensions/weixin/src/adapters/onboard-cli.js +2 -2
  42. package/dist/extensions/weixin/src/adapters/onboard-cli.js.map +1 -1
  43. package/dist/extensions/weixin/src/api/api.js +1 -1
  44. package/dist/extensions/weixin/src/index.d.ts +8 -0
  45. package/dist/extensions/weixin/src/index.js +12 -1
  46. package/dist/extensions/weixin/src/index.js.map +1 -0
  47. package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
  48. package/dist/extensions/weixin/src/plugin.d.ts +2 -1
  49. package/dist/extensions/weixin/src/plugin.js +77 -2
  50. package/dist/extensions/weixin/src/plugin.js.map +1 -1
  51. package/dist/extensions/weixin/xopc.extension.json +52 -0
  52. package/dist/gateway/static/root/assets/agents-XzgIVKcI.js +396 -0
  53. package/dist/gateway/static/root/assets/{apps-page-C5RmwmTT.js → apps-page-B7Us3RMl.js} +1 -1
  54. package/dist/gateway/static/root/assets/browser-BLJWD7WI.js +8 -0
  55. package/dist/gateway/static/root/assets/channels-settings-BgeV6fzw.js +1 -0
  56. package/dist/gateway/static/root/assets/cron-page-DKGHEeAU.js +1 -0
  57. package/dist/gateway/static/root/assets/{dist-CWm8hTXZ.js → dist-DJDkNhu5.js} +1 -1
  58. package/dist/gateway/static/root/assets/{extension-debug-page-BzYgTkS9.js → extension-debug-page-DI1XJTJi.js} +1 -1
  59. package/dist/gateway/static/root/assets/{extension-page-BmTZH6gL.js → extension-page-SuafGTT_.js} +1 -1
  60. package/dist/gateway/static/root/assets/extension-settings-page-cKmGax9v.js +1 -0
  61. package/dist/gateway/static/root/assets/{fetch-CMoWY2Si.js → fetch-CkvRO30i.js} +1 -1
  62. package/dist/gateway/static/root/assets/gateway-startup-retry-BkKyRDrF.js +1 -0
  63. package/dist/gateway/static/root/assets/heartbeat-config-api-CRiDcxtt.js +1 -0
  64. package/dist/gateway/static/root/assets/index-50FVtgXU.js +4845 -0
  65. package/dist/gateway/static/root/assets/index-BPYKW7FB.css +1 -0
  66. package/dist/gateway/static/root/assets/{logs-page-BjdQjHwk.js → logs-page-DM8o5-Bm.js} +2 -2
  67. package/dist/gateway/static/root/assets/{note-detail-page-8Er4197b.js → note-detail-page-j53jtvq9.js} +53 -53
  68. package/dist/gateway/static/root/assets/{note-time-CF3vf1jm.js → note-time-Ck2H2Qpw.js} +1 -1
  69. package/dist/gateway/static/root/assets/notes-page-CsWIw35Q.js +1 -0
  70. package/dist/gateway/static/root/assets/schema-form-BvmGNxiJ.js +1 -0
  71. package/dist/gateway/static/root/assets/sessions-page-CLPsbyOW.js +1 -0
  72. package/dist/gateway/static/root/assets/settings-advanced-gate-DRdayl8P.js +2 -0
  73. package/dist/gateway/static/root/assets/{settings-form-section-C7qA7y0J.js → settings-form-section-BlIYg2gZ.js} +1 -1
  74. package/dist/gateway/static/root/assets/settings-page-CRGHT_bm.js +3 -0
  75. package/dist/gateway/static/root/assets/{share-preview-page-Tvr5Mtq5.js → share-preview-page-BlT6Akvk.js} +1 -1
  76. package/dist/gateway/static/root/assets/skills-page-Ce-RIH2y.js +2 -0
  77. package/dist/gateway/static/root/assets/{theme-store-HTvJlFLL.js → theme-store-DYgVdRB4.js} +1 -1
  78. package/dist/gateway/static/root/assets/url-DPEStU4M.js +3 -0
  79. package/dist/gateway/static/root/assets/voice-api-key-field-CJGTidqc.js +1 -0
  80. package/dist/gateway/static/root/assets/{workflow-page.utils-CeBkAjP7.js → workflow-page.utils-_sjXCMvi.js} +1 -1
  81. package/dist/gateway/static/root/assets/workflows-page-o63aaARK.js +27 -0
  82. package/dist/gateway/static/root/index.html +6 -5
  83. package/dist/package.js +1 -1
  84. package/dist/src/agent/agent-manager.d.ts +18 -6
  85. package/dist/src/agent/agent-manager.js +60 -35
  86. package/dist/src/agent/agent-manager.js.map +1 -1
  87. package/dist/src/agent/builtin-agent-ids.d.ts +2 -0
  88. package/dist/src/agent/builtin-agent-ids.js +17 -0
  89. package/dist/src/agent/builtin-agent-ids.js.map +1 -0
  90. package/dist/src/agent/child-agent-factory.d.ts +4 -0
  91. package/dist/src/agent/child-agent-factory.js +28 -8
  92. package/dist/src/agent/child-agent-factory.js.map +1 -1
  93. package/dist/src/agent/context/workspace-templates/AGENTS.md +23 -184
  94. package/dist/src/agent/embedded/run-turn.js +8 -2
  95. package/dist/src/agent/embedded/run-turn.js.map +1 -1
  96. package/dist/src/agent/embedded/session-tool-result-guard.js +1 -1
  97. package/dist/src/agent/embedded/subscribe-session.js +33 -51
  98. package/dist/src/agent/embedded/subscribe-session.js.map +1 -1
  99. package/dist/src/agent/embedded/types.d.ts +36 -35
  100. package/dist/src/agent/fallback/candidates.js +1 -1
  101. package/dist/src/agent/fallback/candidates.js.map +1 -1
  102. package/dist/src/agent/inbound/inbound-loop.js +1 -1
  103. package/dist/src/agent/inbound/turn-dispatcher.d.ts +3 -0
  104. package/dist/src/agent/inbound/turn-dispatcher.js +25 -5
  105. package/dist/src/agent/inbound/turn-dispatcher.js.map +1 -1
  106. package/dist/src/agent/models/manager.d.ts +1 -1
  107. package/dist/src/agent/models/manager.js +1 -1
  108. package/dist/src/agent/models/manager.js.map +1 -1
  109. package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.d.ts +1 -1
  110. package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.js +1 -1
  111. package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.js.map +1 -1
  112. package/dist/src/agent/prompt/memory/index.js +30 -2
  113. package/dist/src/agent/prompt/memory/index.js.map +1 -1
  114. package/dist/src/agent/prompt/sections/tooling.js +4 -0
  115. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  116. package/dist/src/agent/service/direct-turn-helpers.d.ts +3 -0
  117. package/dist/src/agent/service/direct-turn-helpers.js +6 -3
  118. package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
  119. package/dist/src/agent/service/process-direct-streaming.d.ts +3 -0
  120. package/dist/src/agent/service/process-direct-streaming.js +50 -19
  121. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  122. package/dist/src/agent/service-inbound-utils.d.ts +0 -1
  123. package/dist/src/agent/service-inbound-utils.js +1 -17
  124. package/dist/src/agent/service-inbound-utils.js.map +1 -1
  125. package/dist/src/agent/service.d.ts +4 -4
  126. package/dist/src/agent/service.js +29 -16
  127. package/dist/src/agent/service.js.map +1 -1
  128. package/dist/src/agent/service.types.d.ts +3 -0
  129. package/dist/src/agent/session/session-config-service.d.ts +1 -0
  130. package/dist/src/agent/session/session-config-service.js +9 -1
  131. package/dist/src/agent/session/session-config-service.js.map +1 -1
  132. package/dist/src/agent/session/session-inspector.d.ts +2 -1
  133. package/dist/src/agent/session/session-inspector.js +4 -0
  134. package/dist/src/agent/session/session-inspector.js.map +1 -1
  135. package/dist/src/agent/skills/config.js +1 -3
  136. package/dist/src/agent/skills/config.js.map +1 -1
  137. package/dist/src/agent/skills/format-skills-prompt.d.ts +1 -0
  138. package/dist/src/agent/skills/format-skills-prompt.js +3 -2
  139. package/dist/src/agent/skills/format-skills-prompt.js.map +1 -1
  140. package/dist/src/agent/skills/index.js +20 -5
  141. package/dist/src/agent/skills/index.js.map +1 -1
  142. package/dist/src/agent/skills/installer.js +14 -27
  143. package/dist/src/agent/skills/installer.js.map +1 -1
  144. package/dist/src/agent/skills/marketplace/adapters/clawhub/adapter.js +11 -1
  145. package/dist/src/agent/skills/marketplace/adapters/clawhub/adapter.js.map +1 -1
  146. package/dist/src/agent/skills/marketplace/adapters/skillhub/adapter.js +18 -4
  147. package/dist/src/agent/skills/marketplace/adapters/skillhub/adapter.js.map +1 -1
  148. package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +11 -2
  149. package/dist/src/agent/skills/marketplace/adapters/store/adapter.js.map +1 -1
  150. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +2 -2
  151. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js.map +1 -1
  152. package/dist/src/agent/skills/skill-manager.d.ts +4 -1
  153. package/dist/src/agent/skills/skill-manager.js +3 -3
  154. package/dist/src/agent/skills/skill-manager.js.map +1 -1
  155. package/dist/src/agent/skills/skill-view-path.d.ts +1 -17
  156. package/dist/src/agent/skills/skill-view-path.js +3 -66
  157. package/dist/src/agent/skills/skill-view-path.js.map +1 -1
  158. package/dist/src/agent/skills/test-framework.js +2 -3
  159. package/dist/src/agent/skills/test-framework.js.map +1 -1
  160. package/dist/src/agent/source-context/index.d.ts +2 -0
  161. package/dist/src/agent/source-context/index.js +3 -0
  162. package/dist/src/agent/source-context/injector.d.ts +3 -0
  163. package/dist/src/agent/source-context/injector.js +36 -0
  164. package/dist/src/agent/source-context/injector.js.map +1 -0
  165. package/dist/src/agent/source-context/types.d.ts +19 -0
  166. package/dist/src/agent/source-context/types.js +10 -0
  167. package/dist/src/agent/source-context/types.js.map +1 -0
  168. package/dist/src/agent/streaming/reasoning-visibility-sse.js +1 -0
  169. package/dist/src/agent/streaming/reasoning-visibility-sse.js.map +1 -1
  170. package/dist/src/agent/tool-manuals/browser.d.ts +1 -0
  171. package/{skills/browser/SKILL.md → dist/src/agent/tool-manuals/browser.js} +51 -54
  172. package/dist/src/agent/tool-manuals/browser.js.map +1 -0
  173. package/dist/src/agent/tool-manuals/index.d.ts +10 -0
  174. package/dist/src/agent/tool-manuals/index.js +28 -0
  175. package/dist/src/agent/tool-manuals/index.js.map +1 -0
  176. package/dist/src/agent/tools/browser/tool/browser-use-tool.js +1 -1
  177. package/dist/src/agent/tools/browser/tool/browser-use-tool.js.map +1 -1
  178. package/dist/src/agent/tools/factory.js +2 -0
  179. package/dist/src/agent/tools/factory.js.map +1 -1
  180. package/dist/src/agent/tools/index.d.ts +1 -0
  181. package/dist/src/agent/tools/index.js +2 -1
  182. package/dist/src/agent/tools/skills-tools.js +37 -8
  183. package/dist/src/agent/tools/skills-tools.js.map +1 -1
  184. package/dist/src/agent/tools/tool-manual-tool.d.ts +6 -0
  185. package/dist/src/agent/tools/tool-manual-tool.js +34 -0
  186. package/dist/src/agent/tools/tool-manual-tool.js.map +1 -0
  187. package/dist/src/agent/workflow/catalog.d.ts +7 -2
  188. package/dist/src/agent/workflow/catalog.js +66 -25
  189. package/dist/src/agent/workflow/catalog.js.map +1 -1
  190. package/dist/src/agent/workflow/subagent-runner.d.ts +3 -0
  191. package/dist/src/agent/workflow/subagent-runner.js +50 -4
  192. package/dist/src/agent/workflow/subagent-runner.js.map +1 -1
  193. package/dist/src/agent/workflow/types.d.ts +10 -0
  194. package/dist/src/auth/credentials.js +10 -5
  195. package/dist/src/auth/credentials.js.map +1 -1
  196. package/dist/src/channels/catalog/channel-catalog-service.d.ts +11 -0
  197. package/dist/src/channels/catalog/channel-catalog-service.js +168 -0
  198. package/dist/src/channels/catalog/channel-catalog-service.js.map +1 -0
  199. package/dist/src/channels/catalog/channel-catalog-types.d.ts +22 -0
  200. package/dist/src/channels/catalog/channel-catalog-types.js +1 -0
  201. package/dist/src/channels/dock.d.ts +0 -7
  202. package/dist/src/channels/dock.js +1 -21
  203. package/dist/src/channels/index.d.ts +1 -3
  204. package/dist/src/channels/index.js +1 -5
  205. package/dist/src/channels/lifecycle-supervisor.d.ts +1 -0
  206. package/dist/src/channels/lifecycle-supervisor.js +11 -0
  207. package/dist/src/channels/lifecycle-supervisor.js.map +1 -1
  208. package/dist/src/channels/manager.d.ts +1 -0
  209. package/dist/src/channels/manager.js +3 -0
  210. package/dist/src/channels/manager.js.map +1 -1
  211. package/dist/src/channels/pairing/pairing-channel.d.ts +2 -3
  212. package/dist/src/channels/pairing/pairing-messages.js +1 -1
  213. package/dist/src/channels/pairing/pairing-messages.js.map +1 -1
  214. package/dist/src/channels/pairing/pairing-service.d.ts +1 -1
  215. package/dist/src/channels/pairing/pairing-service.js +8 -27
  216. package/dist/src/channels/pairing/pairing-service.js.map +1 -1
  217. package/dist/src/channels/plugin-types.d.ts +3 -1
  218. package/dist/src/channels/plugins/types.adapters.d.ts +55 -2
  219. package/dist/src/channels/telegram/index.js +1 -1
  220. package/dist/src/chat-commands/builtins/config.js +4 -4
  221. package/dist/src/chat-commands/builtins/config.js.map +1 -1
  222. package/dist/src/chat-commands/config-paths.js +1 -1
  223. package/dist/src/chat-commands/config-paths.js.map +1 -1
  224. package/dist/src/chat-commands/context.js +1 -1
  225. package/dist/src/chat-commands/context.js.map +1 -1
  226. package/dist/src/cli/bin.js +1 -1
  227. package/dist/src/cli/command-manifest.js +1 -1
  228. package/dist/src/cli/command-manifest.js.map +1 -1
  229. package/dist/src/cli/commands/agent.js +2 -2
  230. package/dist/src/cli/commands/agent.js.map +1 -1
  231. package/dist/src/cli/commands/agents.js +2 -4
  232. package/dist/src/cli/commands/agents.js.map +1 -1
  233. package/dist/src/cli/commands/auth.js +1 -1
  234. package/dist/src/cli/commands/channels.d.ts +1 -5
  235. package/dist/src/cli/commands/channels.js +115 -281
  236. package/dist/src/cli/commands/channels.js.map +1 -1
  237. package/dist/src/cli/commands/config.js +2 -2
  238. package/dist/src/cli/commands/config.js.map +1 -1
  239. package/dist/src/cli/commands/doctor/checks/channel-config.js +16 -69
  240. package/dist/src/cli/commands/doctor/checks/channel-config.js.map +1 -1
  241. package/dist/src/cli/commands/doctor/checks/channel-pairing-pending.js +6 -4
  242. package/dist/src/cli/commands/doctor/checks/channel-pairing-pending.js.map +1 -1
  243. package/dist/src/cli/commands/doctor/checks/channel-plugins.js +2 -2
  244. package/dist/src/cli/commands/doctor/checks/channel-plugins.js.map +1 -1
  245. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  246. package/dist/src/cli/commands/doctor/checks/provider-auth.js +13 -9
  247. package/dist/src/cli/commands/doctor/checks/provider-auth.js.map +1 -1
  248. package/dist/src/cli/commands/extension-dev.js +2 -1
  249. package/dist/src/cli/commands/extension-dev.js.map +1 -1
  250. package/dist/src/cli/commands/extension-marketplace.js +2 -1
  251. package/dist/src/cli/commands/extension-marketplace.js.map +1 -1
  252. package/dist/src/cli/commands/extension-pack.js +2 -1
  253. package/dist/src/cli/commands/extension-pack.js.map +1 -1
  254. package/dist/src/cli/commands/models.js +7 -4
  255. package/dist/src/cli/commands/models.js.map +1 -1
  256. package/dist/src/cli/commands/onboard/channels/index.js +1 -1
  257. package/dist/src/cli/commands/onboard/channels/index.js.map +1 -1
  258. package/dist/src/cli/commands/onboard/channels/registry.d.ts +2 -1
  259. package/dist/src/cli/commands/onboard/channels/registry.js +32 -8
  260. package/dist/src/cli/commands/onboard/channels/registry.js.map +1 -1
  261. package/dist/src/cli/commands/onboard/model.js +8 -5
  262. package/dist/src/cli/commands/onboard/model.js.map +1 -1
  263. package/dist/src/cli/commands/onboard.js +4 -6
  264. package/dist/src/cli/commands/onboard.js.map +1 -1
  265. package/dist/src/cli/commands/setup-shared/runner.d.ts +1 -1
  266. package/dist/src/cli/commands/setup-shared/runner.js.map +1 -1
  267. package/dist/src/cli/commands/setup-shared/types.d.ts +1 -1
  268. package/dist/src/cli/commands/setup-shared/types.js.map +1 -1
  269. package/dist/src/cli/commands/tui.js +13 -5
  270. package/dist/src/cli/commands/tui.js.map +1 -1
  271. package/dist/src/cli/extension-cli-register.js +1 -1
  272. package/dist/src/commands/agents.config.d.ts +3 -3
  273. package/dist/src/commands/agents.config.js +7 -7
  274. package/dist/src/commands/agents.config.js.map +1 -1
  275. package/dist/src/config/agent-profile.d.ts +1 -1
  276. package/dist/src/config/agent-profile.js +6 -2
  277. package/dist/src/config/agent-profile.js.map +1 -1
  278. package/dist/src/config/agent-typed-models.d.ts +2 -2
  279. package/dist/src/config/agent-typed-models.js +13 -2
  280. package/dist/src/config/agent-typed-models.js.map +1 -1
  281. package/dist/src/config/index.js +3 -3
  282. package/dist/src/config/integration.d.ts +1 -1
  283. package/dist/src/config/loader.d.ts +0 -1
  284. package/dist/src/config/loader.js +4 -9
  285. package/dist/src/config/loader.js.map +1 -1
  286. package/dist/src/config/models-json.d.ts +6 -6
  287. package/dist/src/config/paths.d.ts +1 -0
  288. package/dist/src/config/paths.js +5 -1
  289. package/dist/src/config/paths.js.map +1 -1
  290. package/dist/src/config/rules.js +2 -12
  291. package/dist/src/config/rules.js.map +1 -1
  292. package/dist/src/config/schema.d.ts +74 -47
  293. package/dist/src/config/schema.js +28 -66
  294. package/dist/src/config/schema.js.map +1 -1
  295. package/dist/src/config/validate-channel-configs.d.ts +0 -3
  296. package/dist/src/config/validate-channel-configs.js +29 -10
  297. package/dist/src/config/validate-channel-configs.js.map +1 -1
  298. package/dist/src/cron/executor.js +1 -4
  299. package/dist/src/cron/executor.js.map +1 -1
  300. package/dist/src/document-understanding/extract.d.ts +13 -0
  301. package/dist/src/document-understanding/extract.js +63 -0
  302. package/dist/src/document-understanding/extract.js.map +1 -0
  303. package/dist/src/extensions/activation-context.js +3 -1
  304. package/dist/src/extensions/activation-context.js.map +1 -1
  305. package/dist/src/extensions/activation-planner.js +12 -0
  306. package/dist/src/extensions/activation-planner.js.map +1 -1
  307. package/dist/src/extensions/api.d.ts +5 -1
  308. package/dist/src/extensions/api.js +12 -0
  309. package/dist/src/extensions/api.js.map +1 -1
  310. package/dist/src/extensions/discover-extensions.js +17 -13
  311. package/dist/src/extensions/discover-extensions.js.map +1 -1
  312. package/dist/src/extensions/extension-metadata-snapshot.js +11 -5
  313. package/dist/src/extensions/extension-metadata-snapshot.js.map +1 -1
  314. package/dist/src/extensions/index.js +12 -4
  315. package/dist/src/extensions/index.js.map +1 -0
  316. package/dist/src/extensions/loader.d.ts +5 -1
  317. package/dist/src/extensions/loader.js +12 -11
  318. package/dist/src/extensions/loader.js.map +1 -1
  319. package/dist/src/extensions/manifest-registry.js +98 -93
  320. package/dist/src/extensions/manifest-registry.js.map +1 -1
  321. package/dist/src/extensions/normalize-manifest.js +91 -15
  322. package/dist/src/extensions/normalize-manifest.js.map +1 -1
  323. package/dist/src/extensions/sdk/index.js +1 -1
  324. package/dist/src/extensions/sdk/testing.js +4 -0
  325. package/dist/src/extensions/sdk/testing.js.map +1 -1
  326. package/dist/src/extensions/types/core.d.ts +32 -1
  327. package/dist/src/extensions/types/manifest.d.ts +60 -0
  328. package/dist/src/extensions/types/tui.d.ts +414 -5
  329. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  330. package/dist/src/gateway/agent-builtin-tools.js +16 -0
  331. package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
  332. package/dist/src/gateway/agent-run-relay.d.ts +2 -3
  333. package/dist/src/gateway/agent-run-relay.js +10 -3
  334. package/dist/src/gateway/agent-run-relay.js.map +1 -1
  335. package/dist/src/gateway/agents-admin.d.ts +32 -19
  336. package/dist/src/gateway/agents-admin.js +113 -93
  337. package/dist/src/gateway/agents-admin.js.map +1 -1
  338. package/dist/src/gateway/chat-stream/mapper.d.ts +34 -0
  339. package/dist/src/gateway/chat-stream/mapper.js +244 -0
  340. package/dist/src/gateway/chat-stream/mapper.js.map +1 -0
  341. package/dist/src/gateway/chat-stream/protocol.d.ts +100 -0
  342. package/dist/src/gateway/chat-stream/protocol.js +1 -0
  343. package/dist/src/gateway/heartbeat/service.js +1 -1
  344. package/dist/src/gateway/hono/lib/agent-model.d.ts +4 -4
  345. package/dist/src/gateway/hono/lib/agent-model.js +13 -11
  346. package/dist/src/gateway/hono/lib/agent-model.js.map +1 -1
  347. package/dist/src/gateway/hono/lib/config-payload.d.ts +19 -7
  348. package/dist/src/gateway/hono/lib/config-payload.js +16 -15
  349. package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
  350. package/dist/src/gateway/hono/routes/agents.js +83 -48
  351. package/dist/src/gateway/hono/routes/agents.js.map +1 -1
  352. package/dist/src/gateway/hono/routes/channels.js +134 -214
  353. package/dist/src/gateway/hono/routes/channels.js.map +1 -1
  354. package/dist/src/gateway/hono/routes/commands-skills.js +10 -4
  355. package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
  356. package/dist/src/gateway/hono/routes/config-patch/agents.js +26 -13
  357. package/dist/src/gateway/hono/routes/config-patch/agents.js.map +1 -1
  358. package/dist/src/gateway/hono/routes/config-patch/channels.d.ts +1 -11
  359. package/dist/src/gateway/hono/routes/config-patch/channels.js +18 -165
  360. package/dist/src/gateway/hono/routes/config-patch/channels.js.map +1 -1
  361. package/dist/src/gateway/hono/routes/config.js +5 -2
  362. package/dist/src/gateway/hono/routes/config.js.map +1 -1
  363. package/dist/src/gateway/hono/routes/dreaming.js +1 -1
  364. package/dist/src/gateway/hono/routes/lazy-bundles.js +13 -1
  365. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  366. package/dist/src/gateway/hono/routes/notes.js +46 -27
  367. package/dist/src/gateway/hono/routes/notes.js.map +1 -1
  368. package/dist/src/gateway/hono/routes/public-gateway.js +2 -4
  369. package/dist/src/gateway/hono/routes/public-gateway.js.map +1 -1
  370. package/dist/src/gateway/hono/routes/sessions.js +179 -0
  371. package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
  372. package/dist/src/gateway/hono/routes/tui.d.ts +3 -0
  373. package/dist/src/gateway/hono/routes/tui.js +16 -0
  374. package/dist/src/gateway/hono/routes/tui.js.map +1 -0
  375. package/dist/src/gateway/hono/routes/workflows.js +25 -1
  376. package/dist/src/gateway/hono/routes/workflows.js.map +1 -1
  377. package/dist/src/gateway/hono/sse.d.ts +5 -7
  378. package/dist/src/gateway/hono/sse.js +21 -38
  379. package/dist/src/gateway/hono/sse.js.map +1 -1
  380. package/dist/src/gateway/protocol.js.map +1 -1
  381. package/dist/src/gateway/service/agent-runner.d.ts +2 -4
  382. package/dist/src/gateway/service/agent-runner.js +1 -1
  383. package/dist/src/gateway/service/agent-runner.js.map +1 -1
  384. package/dist/src/gateway/service/marketplace-service.d.ts +4 -3
  385. package/dist/src/gateway/service/marketplace-service.js +7 -4
  386. package/dist/src/gateway/service/marketplace-service.js.map +1 -1
  387. package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -6
  388. package/dist/src/gateway/service/run-gateway-agent.js +63 -36
  389. package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
  390. package/dist/src/gateway/service/sessions-api.d.ts +19 -0
  391. package/dist/src/gateway/service/sessions-api.js +12 -0
  392. package/dist/src/gateway/service/sessions-api.js.map +1 -1
  393. package/dist/src/gateway/service.d.ts +6 -0
  394. package/dist/src/gateway/service.js +84 -57
  395. package/dist/src/gateway/service.js.map +1 -1
  396. package/dist/src/heartbeat/index.js +1 -1
  397. package/dist/src/notes/agent-context.d.ts +40 -0
  398. package/dist/src/notes/agent-context.js +383 -0
  399. package/dist/src/notes/agent-context.js.map +1 -0
  400. package/dist/src/notes/index.d.ts +2 -0
  401. package/dist/src/notes/index.js +2 -1
  402. package/dist/src/notes/service.d.ts +5 -0
  403. package/dist/src/notes/service.js +22 -0
  404. package/dist/src/notes/service.js.map +1 -1
  405. package/dist/src/notes/store.js +2 -0
  406. package/dist/src/notes/store.js.map +1 -1
  407. package/dist/src/project-trust/trust-store.d.ts +30 -0
  408. package/dist/src/project-trust/trust-store.js +194 -0
  409. package/dist/src/project-trust/trust-store.js.map +1 -0
  410. package/dist/src/providers/index.d.ts +1 -1
  411. package/dist/src/providers/index.js +18 -7
  412. package/dist/src/providers/index.js.map +1 -1
  413. package/dist/src/routing/resolve-route.d.ts +0 -3
  414. package/dist/src/routing/resolve-route.js.map +1 -1
  415. package/dist/src/routing/resolve-tui-session-key.d.ts +2 -0
  416. package/dist/src/routing/resolve-tui-session-key.js +8 -3
  417. package/dist/src/routing/resolve-tui-session-key.js.map +1 -1
  418. package/dist/src/session/client-history.d.ts +32 -0
  419. package/dist/src/session/client-history.js +232 -1
  420. package/dist/src/session/client-history.js.map +1 -1
  421. package/dist/src/session/manager.d.ts +37 -4
  422. package/dist/src/session/manager.js +39 -15
  423. package/dist/src/session/manager.js.map +1 -1
  424. package/dist/src/session/session-context-for-llm.d.ts +93 -1
  425. package/dist/src/session/session-context-for-llm.js +105 -2
  426. package/dist/src/session/session-context-for-llm.js.map +1 -1
  427. package/dist/src/session/store.d.ts +37 -0
  428. package/dist/src/session/store.js +127 -2
  429. package/dist/src/session/store.js.map +1 -1
  430. package/dist/src/session/stored-rows-to-file-entries.js +37 -1
  431. package/dist/src/session/stored-rows-to-file-entries.js.map +1 -1
  432. package/dist/src/session/types.d.ts +14 -1
  433. package/dist/src/session/types.js.map +1 -1
  434. package/dist/src/storage/sqlite/index.d.ts +1 -0
  435. package/dist/src/storage/sqlite/index.js +2 -1
  436. package/dist/src/storage/sqlite/migrations/004_add_session_type_metadata.sql +15 -0
  437. package/dist/src/storage/sqlite/migrations/005_add_note_agent_contexts.sql +10 -0
  438. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  439. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  440. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  441. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  442. package/dist/src/storage/sqlite/note-agent-context-repository.d.ts +10 -0
  443. package/dist/src/storage/sqlite/note-agent-context-repository.js +35 -0
  444. package/dist/src/storage/sqlite/note-agent-context-repository.js.map +1 -0
  445. package/dist/src/storage/sqlite/row-mappers.d.ts +14 -1
  446. package/dist/src/storage/sqlite/row-mappers.js +14 -1
  447. package/dist/src/storage/sqlite/row-mappers.js.map +1 -1
  448. package/dist/src/storage/sqlite/schema.js +1 -1
  449. package/dist/src/storage/sqlite/session-metadata.js +1 -0
  450. package/dist/src/storage/sqlite/session-metadata.js.map +1 -1
  451. package/dist/src/storage/sqlite/session-repository.js +52 -25
  452. package/dist/src/storage/sqlite/session-repository.js.map +1 -1
  453. package/dist/src/tui/backends/embedded-backend.d.ts +53 -4
  454. package/dist/src/tui/backends/embedded-backend.js +227 -39
  455. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  456. package/dist/src/tui/backends/gateway-sse-backend.d.ts +59 -3
  457. package/dist/src/tui/backends/gateway-sse-backend.js +416 -26
  458. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  459. package/dist/src/tui/chat-history.d.ts +5 -1
  460. package/dist/src/tui/chat-history.js +78 -8
  461. package/dist/src/tui/chat-history.js.map +1 -1
  462. package/dist/src/tui/clipboard-text.d.ts +5 -0
  463. package/dist/src/tui/clipboard-text.js +46 -0
  464. package/dist/src/tui/clipboard-text.js.map +1 -0
  465. package/dist/src/tui/components/assistant-message.d.ts +19 -3
  466. package/dist/src/tui/components/assistant-message.js +115 -9
  467. package/dist/src/tui/components/assistant-message.js.map +1 -1
  468. package/dist/src/tui/components/bash-execution.d.ts +3 -2
  469. package/dist/src/tui/components/bash-execution.js +31 -3
  470. package/dist/src/tui/components/bash-execution.js.map +1 -1
  471. package/dist/src/tui/components/bash-summary.d.ts +23 -0
  472. package/dist/src/tui/components/bash-summary.js +87 -0
  473. package/dist/src/tui/components/bash-summary.js.map +1 -0
  474. package/dist/src/tui/components/branch-message-summary.d.ts +17 -0
  475. package/dist/src/tui/components/branch-message-summary.js +43 -0
  476. package/dist/src/tui/components/branch-message-summary.js.map +1 -0
  477. package/dist/src/tui/components/branch-summary.d.ts +13 -0
  478. package/dist/src/tui/components/branch-summary.js +51 -0
  479. package/dist/src/tui/components/branch-summary.js.map +1 -0
  480. package/dist/src/tui/components/chat-log.d.ts +46 -6
  481. package/dist/src/tui/components/chat-log.js +183 -21
  482. package/dist/src/tui/components/chat-log.js.map +1 -1
  483. package/dist/src/tui/components/compaction-summary.d.ts +13 -0
  484. package/dist/src/tui/components/compaction-summary.js +46 -0
  485. package/dist/src/tui/components/compaction-summary.js.map +1 -0
  486. package/dist/src/tui/components/custom-editor.d.ts +1 -0
  487. package/dist/src/tui/components/custom-editor.js +2 -0
  488. package/dist/src/tui/components/custom-editor.js.map +1 -1
  489. package/dist/src/tui/components/custom-message.d.ts +23 -0
  490. package/dist/src/tui/components/custom-message.js +65 -0
  491. package/dist/src/tui/components/custom-message.js.map +1 -0
  492. package/dist/src/tui/components/extension-dialog.d.ts +42 -0
  493. package/dist/src/tui/components/extension-dialog.js +127 -0
  494. package/dist/src/tui/components/extension-dialog.js.map +1 -0
  495. package/dist/src/tui/components/scoped-models-selector.d.ts +7 -2
  496. package/dist/src/tui/components/scoped-models-selector.js +89 -16
  497. package/dist/src/tui/components/scoped-models-selector.js.map +1 -1
  498. package/dist/src/tui/components/searchable-select-list.d.ts +30 -3
  499. package/dist/src/tui/components/searchable-select-list.js +82 -10
  500. package/dist/src/tui/components/searchable-select-list.js.map +1 -1
  501. package/dist/src/tui/components/session-selector.d.ts +18 -4
  502. package/dist/src/tui/components/session-selector.js +207 -40
  503. package/dist/src/tui/components/session-selector.js.map +1 -1
  504. package/dist/src/tui/components/settings-selector.d.ts +6 -2
  505. package/dist/src/tui/components/settings-selector.js +126 -7
  506. package/dist/src/tui/components/settings-selector.js.map +1 -1
  507. package/dist/src/tui/components/thinking-selector.d.ts +12 -0
  508. package/dist/src/tui/components/thinking-selector.js +48 -0
  509. package/dist/src/tui/components/thinking-selector.js.map +1 -0
  510. package/dist/src/tui/components/tool-execution.d.ts +57 -3
  511. package/dist/src/tui/components/tool-execution.js +378 -28
  512. package/dist/src/tui/components/tool-execution.js.map +1 -1
  513. package/dist/src/tui/components/tui-bottom-bar.d.ts +9 -1
  514. package/dist/src/tui/components/tui-bottom-bar.js +56 -11
  515. package/dist/src/tui/components/tui-bottom-bar.js.map +1 -1
  516. package/dist/src/tui/components/tui-header.d.ts +9 -2
  517. package/dist/src/tui/components/tui-header.js +25 -5
  518. package/dist/src/tui/components/tui-header.js.map +1 -1
  519. package/dist/src/tui/components/user-message.d.ts +4 -2
  520. package/dist/src/tui/components/user-message.js +42 -9
  521. package/dist/src/tui/components/user-message.js.map +1 -1
  522. package/dist/src/tui/components/visual-truncate.d.ts +11 -0
  523. package/dist/src/tui/components/visual-truncate.js +27 -0
  524. package/dist/src/tui/components/visual-truncate.js.map +1 -0
  525. package/dist/src/tui/extension-host/autocomplete.d.ts +43 -0
  526. package/dist/src/tui/extension-host/autocomplete.js +116 -0
  527. package/dist/src/tui/extension-host/autocomplete.js.map +1 -0
  528. package/dist/src/tui/extension-host/host.d.ts +31 -1
  529. package/dist/src/tui/extension-host/host.js +123 -6
  530. package/dist/src/tui/extension-host/host.js.map +1 -1
  531. package/dist/src/tui/extension-host/load-extensions.d.ts +6 -1
  532. package/dist/src/tui/extension-host/load-extensions.js +4 -3
  533. package/dist/src/tui/extension-host/load-extensions.js.map +1 -1
  534. package/dist/src/tui/extension-host/runtime-context.d.ts +21 -0
  535. package/dist/src/tui/extension-host/runtime-context.js +152 -0
  536. package/dist/src/tui/extension-host/runtime-context.js.map +1 -0
  537. package/dist/src/tui/extension-host/runtime.d.ts +52 -4
  538. package/dist/src/tui/extension-host/runtime.js +547 -85
  539. package/dist/src/tui/extension-host/runtime.js.map +1 -1
  540. package/dist/src/tui/extension-host/surface.d.ts +20 -0
  541. package/dist/src/tui/extension-host/surface.js +30 -6
  542. package/dist/src/tui/extension-host/surface.js.map +1 -1
  543. package/dist/src/tui/extension-host/tool-renderers.d.ts +6 -3
  544. package/dist/src/tui/extension-host/tool-renderers.js +43 -5
  545. package/dist/src/tui/extension-host/tool-renderers.js.map +1 -1
  546. package/dist/src/tui/format-tui-hotkeys.d.ts +12 -2
  547. package/dist/src/tui/format-tui-hotkeys.js +22 -5
  548. package/dist/src/tui/format-tui-hotkeys.js.map +1 -1
  549. package/dist/src/tui/tui-agent-events.d.ts +8 -6
  550. package/dist/src/tui/tui-agent-events.js +200 -59
  551. package/dist/src/tui/tui-agent-events.js.map +1 -1
  552. package/dist/src/tui/tui-backend.d.ts +169 -3
  553. package/dist/src/tui/tui-command-formatters.d.ts +76 -0
  554. package/dist/src/tui/tui-command-formatters.js +594 -0
  555. package/dist/src/tui/tui-command-formatters.js.map +1 -0
  556. package/dist/src/tui/tui-commands.d.ts +57 -7
  557. package/dist/src/tui/tui-commands.js +639 -43
  558. package/dist/src/tui/tui-commands.js.map +1 -1
  559. package/dist/src/tui/tui-context-usage.d.ts +1 -1
  560. package/dist/src/tui/tui-context-usage.js +9 -1
  561. package/dist/src/tui/tui-context-usage.js.map +1 -1
  562. package/dist/src/tui/tui-extension-user-message.d.ts +8 -0
  563. package/dist/src/tui/tui-extension-user-message.js +32 -0
  564. package/dist/src/tui/tui-extension-user-message.js.map +1 -0
  565. package/dist/src/tui/tui-follow-up-queue.d.ts +9 -0
  566. package/dist/src/tui/tui-follow-up-queue.js +18 -0
  567. package/dist/src/tui/tui-follow-up-queue.js.map +1 -0
  568. package/dist/src/tui/tui-local-shell.d.ts +11 -1
  569. package/dist/src/tui/tui-local-shell.js +50 -8
  570. package/dist/src/tui/tui-local-shell.js.map +1 -1
  571. package/dist/src/tui/tui-model-picker.d.ts +26 -0
  572. package/dist/src/tui/tui-model-picker.js +152 -0
  573. package/dist/src/tui/tui-model-picker.js.map +1 -0
  574. package/dist/src/tui/tui-oauth-login.d.ts +16 -0
  575. package/dist/src/tui/tui-oauth-login.js +189 -0
  576. package/dist/src/tui/tui-oauth-login.js.map +1 -0
  577. package/dist/src/tui/tui-overlays.d.ts +3 -3
  578. package/dist/src/tui/tui-overlays.js +6 -7
  579. package/dist/src/tui/tui-overlays.js.map +1 -1
  580. package/dist/src/tui/tui-picker-overlay.d.ts +27 -32
  581. package/dist/src/tui/tui-picker-overlay.js +340 -30
  582. package/dist/src/tui/tui-picker-overlay.js.map +1 -1
  583. package/dist/src/tui/tui-picker-services.d.ts +41 -0
  584. package/dist/src/tui/tui-picker-services.js +1 -0
  585. package/dist/src/tui/tui-run-state.d.ts +11 -0
  586. package/dist/src/tui/tui-run-state.js +114 -0
  587. package/dist/src/tui/tui-run-state.js.map +1 -0
  588. package/dist/src/tui/tui-runtime-hints.d.ts +4 -0
  589. package/dist/src/tui/tui-runtime-hints.js +18 -0
  590. package/dist/src/tui/tui-runtime-hints.js.map +1 -0
  591. package/dist/src/tui/tui-scoped-models.d.ts +1 -1
  592. package/dist/src/tui/tui-scoped-models.js +2 -2
  593. package/dist/src/tui/tui-scoped-models.js.map +1 -1
  594. package/dist/src/tui/tui-session-actions.d.ts +5 -3
  595. package/dist/src/tui/tui-session-actions.js +21 -9
  596. package/dist/src/tui/tui-session-actions.js.map +1 -1
  597. package/dist/src/tui/tui-session-format.d.ts +4 -1
  598. package/dist/src/tui/tui-session-format.js +17 -3
  599. package/dist/src/tui/tui-session-format.js.map +1 -1
  600. package/dist/src/tui/tui-session-snapshot.d.ts +82 -0
  601. package/dist/src/tui/tui-session-snapshot.js +184 -0
  602. package/dist/src/tui/tui-session-snapshot.js.map +1 -0
  603. package/dist/src/tui/tui-session-stats.d.ts +3 -0
  604. package/dist/src/tui/tui-session-stats.js +59 -0
  605. package/dist/src/tui/tui-session-stats.js.map +1 -0
  606. package/dist/src/tui/tui-settings.d.ts +21 -0
  607. package/dist/src/tui/tui-settings.js +28 -1
  608. package/dist/src/tui/tui-settings.js.map +1 -1
  609. package/dist/src/tui/tui-skills-autocomplete.js +1 -1
  610. package/dist/src/tui/tui-skills-autocomplete.js.map +1 -1
  611. package/dist/src/tui/tui-startup-resources.d.ts +3 -0
  612. package/dist/src/tui/tui-startup-resources.js +39 -0
  613. package/dist/src/tui/tui-startup-resources.js.map +1 -0
  614. package/dist/src/tui/tui-startup-text.d.ts +10 -0
  615. package/dist/src/tui/tui-startup-text.js +58 -0
  616. package/dist/src/tui/tui-startup-text.js.map +1 -0
  617. package/dist/src/tui/tui-stdio-filter.d.ts +1 -0
  618. package/dist/src/tui/tui-stdio-filter.js +11 -7
  619. package/dist/src/tui/tui-stdio-filter.js.map +1 -1
  620. package/dist/src/tui/tui-submit.d.ts +2 -0
  621. package/dist/src/tui/tui-submit.js +2 -1
  622. package/dist/src/tui/tui-submit.js.map +1 -1
  623. package/dist/src/tui/tui-tool-diff.js +61 -7
  624. package/dist/src/tui/tui-tool-diff.js.map +1 -1
  625. package/dist/src/tui/tui-tool-result.d.ts +17 -0
  626. package/dist/src/tui/tui-tool-result.js +74 -0
  627. package/dist/src/tui/tui-tool-result.js.map +1 -0
  628. package/dist/src/tui/tui-transcript-tree-picker.d.ts +57 -0
  629. package/dist/src/tui/tui-transcript-tree-picker.js +604 -0
  630. package/dist/src/tui/tui-transcript-tree-picker.js.map +1 -0
  631. package/dist/src/tui/tui-transcript-tree.d.ts +7 -0
  632. package/dist/src/tui/tui-transcript-tree.js +316 -0
  633. package/dist/src/tui/tui-transcript-tree.js.map +1 -0
  634. package/dist/src/tui/tui-types.d.ts +25 -34
  635. package/dist/src/tui/tui-types.js +12 -0
  636. package/dist/src/tui/tui-types.js.map +1 -1
  637. package/dist/src/tui/tui.js +1288 -112
  638. package/dist/src/tui/tui.js.map +1 -1
  639. package/dist/src/tui/xopc-tui-keybindings.d.ts +127 -2
  640. package/dist/src/tui/xopc-tui-keybindings.js +127 -2
  641. package/dist/src/tui/xopc-tui-keybindings.js.map +1 -1
  642. package/dist/src/workflows/domain/definition-utils.d.ts +2 -1
  643. package/dist/src/workflows/domain/definition-utils.js +18 -8
  644. package/dist/src/workflows/domain/definition-utils.js.map +1 -1
  645. package/dist/src/workflows/domain/definition.d.ts +25 -0
  646. package/dist/src/workflows/domain/event.d.ts +1 -0
  647. package/dist/src/workflows/domain/result.d.ts +15 -0
  648. package/dist/src/workflows/domain/run.d.ts +2 -0
  649. package/dist/src/workflows/domain/run.js.map +1 -1
  650. package/dist/src/workflows/engine/projector.js +4 -0
  651. package/dist/src/workflows/engine/projector.js.map +1 -1
  652. package/dist/src/workflows/engine/workflow-engine.d.ts +37 -1
  653. package/dist/src/workflows/engine/workflow-engine.js +75 -11
  654. package/dist/src/workflows/engine/workflow-engine.js.map +1 -1
  655. package/dist/src/workflows/index.d.ts +1 -0
  656. package/dist/src/workflows/index.js +4 -1
  657. package/dist/src/workflows/registry/catalog-workflow-definition-registry.d.ts +9 -0
  658. package/dist/src/workflows/registry/catalog-workflow-definition-registry.js +40 -0
  659. package/dist/src/workflows/registry/catalog-workflow-definition-registry.js.map +1 -0
  660. package/dist/src/workflows/registry/index.d.ts +2 -0
  661. package/dist/src/workflows/registry/index.js +2 -0
  662. package/dist/src/workflows/registry/workflow-definition-registry.d.ts +15 -0
  663. package/dist/src/workflows/registry/workflow-definition-registry.js +1 -0
  664. package/dist/src/workflows/runtime/index.d.ts +2 -0
  665. package/dist/src/workflows/runtime/index.js +2 -1
  666. package/dist/src/workflows/runtime/script-workflow-runtime.d.ts +5 -0
  667. package/dist/src/workflows/runtime/script-workflow-runtime.js +15 -0
  668. package/dist/src/workflows/runtime/script-workflow-runtime.js.map +1 -0
  669. package/dist/src/workflows/runtime/workflow-runtime-port.d.ts +16 -0
  670. package/dist/src/workflows/runtime/workflow-runtime-port.js +1 -0
  671. package/dist/src/workflows/service/run-view-to-snapshot.js +3 -0
  672. package/dist/src/workflows/service/run-view-to-snapshot.js.map +1 -1
  673. package/dist/src/workflows/service/workflow-run-service.d.ts +3 -0
  674. package/dist/src/workflows/service/workflow-run-service.js +10 -15
  675. package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
  676. package/dist/src/workflows/service/workflow-session-bridge.d.ts +1 -1
  677. package/dist/src/workflows/service/workflow-session-bridge.js +4 -1
  678. package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
  679. package/package.json +23 -17
  680. package/skills/creative/frontend-design/SKILL.md +1 -1
  681. package/skills/creative/theme-factory/SKILL.md +1 -1
  682. package/skills/documents/xlsx/SKILL.md +1 -1
  683. package/skills/engineering/diagnose/SKILL.md +2 -2
  684. package/skills/engineering/tdd/SKILL.md +1 -1
  685. package/skills/tools/github/SKILL.md +6 -1
  686. package/skills/tools/webapp-testing/SKILL.md +4 -1
  687. package/dist/extensions/telegram/src/adapters/config-surface.d.ts +0 -2
  688. package/dist/extensions/telegram/src/adapters/config-surface.js +0 -26
  689. package/dist/extensions/telegram/src/adapters/config-surface.js.map +0 -1
  690. package/dist/extensions/weixin/src/__tests__/workflow-progress.test.js +0 -158
  691. package/dist/extensions/weixin/src/__tests__/workflow-progress.test.js.map +0 -1
  692. package/dist/gateway/static/root/assets/agents-BwXkia_W.js +0 -222
  693. package/dist/gateway/static/root/assets/channels-settings-tlOTdaXw.js +0 -1
  694. package/dist/gateway/static/root/assets/channels-status-swr-D4XjqwqC.js +0 -8
  695. package/dist/gateway/static/root/assets/cron-api-DcmfGuj0.js +0 -1
  696. package/dist/gateway/static/root/assets/cron-page-CijJ4G6F.js +0 -1
  697. package/dist/gateway/static/root/assets/extension-settings-page-CyJk_G64.js +0 -1
  698. package/dist/gateway/static/root/assets/field-primitives-C4GpxsDo.js +0 -1
  699. package/dist/gateway/static/root/assets/heartbeat-config-api-CLD0Gpi3.js +0 -1
  700. package/dist/gateway/static/root/assets/index-0HmunJW9.js +0 -4845
  701. package/dist/gateway/static/root/assets/index-Bk75Phrd.css +0 -1
  702. package/dist/gateway/static/root/assets/notes-page-BBnTh0uI.js +0 -1
  703. package/dist/gateway/static/root/assets/sessions-page-B0riYK7j.js +0 -1
  704. package/dist/gateway/static/root/assets/settings-advanced-gate-DiP_WHu_.js +0 -2
  705. package/dist/gateway/static/root/assets/settings-page-1ZPhcCZ9.js +0 -3
  706. package/dist/gateway/static/root/assets/skills-page-BQ1hllKD.js +0 -2
  707. package/dist/gateway/static/root/assets/url-F3_D_6zZ.js +0 -3
  708. package/dist/gateway/static/root/assets/utils-CPr3FBh2.js +0 -1
  709. package/dist/gateway/static/root/assets/voice-api-key-field-BkbDl6dH.js +0 -1
  710. package/dist/gateway/static/root/assets/workflows-page-D059ysoF.js +0 -27
  711. package/dist/src/agent/embedded/map-stream-events.d.ts +0 -9
  712. package/dist/src/agent/embedded/map-stream-events.js +0 -63
  713. package/dist/src/agent/embedded/map-stream-events.js.map +0 -1
  714. package/dist/src/channels/dock.js.map +0 -1
  715. package/dist/src/channels/plugins/bundled.d.ts +0 -11
  716. package/dist/src/channels/plugins/bundled.js +0 -10
  717. package/dist/src/channels/plugins/bundled.js.map +0 -1
  718. package/dist/src/channels/registry.d.ts +0 -25
  719. package/dist/src/channels/registry.js +0 -82
  720. package/dist/src/channels/registry.js.map +0 -1
  721. package/dist/src/config/localized-text.d.ts +0 -6
  722. package/dist/src/config/localized-text.js +0 -42
  723. package/dist/src/config/localized-text.js.map +0 -1
  724. package/dist/src/generated/bundled-channel-plugins.d.ts +0 -10
  725. package/dist/src/generated/bundled-channel-plugins.js +0 -16
  726. package/dist/src/generated/bundled-channel-plugins.js.map +0 -1
  727. package/dist/src/tui/stream-assembler.d.ts +0 -22
  728. package/dist/src/tui/stream-assembler.js +0 -63
  729. package/dist/src/tui/stream-assembler.js.map +0 -1
  730. package/skills/browser/SKILL-zh.md +0 -188
  731. package/skills/business/company-values/SKILL-zh.md +0 -80
  732. package/skills/business/company-values/SKILL.md +0 -80
  733. package/skills/business/find-community/SKILL-zh.md +0 -50
  734. package/skills/business/find-community/SKILL.md +0 -50
  735. package/skills/business/first-customers/SKILL-zh.md +0 -76
  736. package/skills/business/first-customers/SKILL.md +0 -76
  737. package/skills/business/grow-sustainably/SKILL-zh.md +0 -92
  738. package/skills/business/grow-sustainably/SKILL.md +0 -92
  739. package/skills/business/marketing-plan/SKILL-zh.md +0 -100
  740. package/skills/business/marketing-plan/SKILL.md +0 -100
  741. package/skills/business/minimalist-review/SKILL-zh.md +0 -82
  742. package/skills/business/minimalist-review/SKILL.md +0 -82
  743. package/skills/business/mvp/SKILL-zh.md +0 -81
  744. package/skills/business/mvp/SKILL.md +0 -81
  745. package/skills/business/pricing/SKILL-zh.md +0 -64
  746. package/skills/business/pricing/SKILL.md +0 -64
  747. package/skills/business/processize/SKILL-zh.md +0 -91
  748. package/skills/business/processize/SKILL.md +0 -91
  749. package/skills/business/validate-idea/SKILL-zh.md +0 -68
  750. package/skills/business/validate-idea/SKILL.md +0 -68
  751. package/skills/creative/algorithmic-art/LICENSE.txt +0 -202
  752. package/skills/creative/algorithmic-art/SKILL-zh.md +0 -405
  753. package/skills/creative/algorithmic-art/SKILL.md +0 -405
  754. package/skills/creative/algorithmic-art/templates/generator_template.js +0 -223
  755. package/skills/creative/algorithmic-art/templates/viewer.html +0 -599
  756. package/skills/creative/frontend-design/SKILL-zh.md +0 -42
  757. package/skills/creative/theme-factory/SKILL-zh.md +0 -59
  758. package/skills/creative/web-artifacts-builder/LICENSE.txt +0 -202
  759. package/skills/creative/web-artifacts-builder/SKILL-zh.md +0 -74
  760. package/skills/creative/web-artifacts-builder/SKILL.md +0 -74
  761. package/skills/creative/web-artifacts-builder/scripts/bundle-artifact.sh +0 -54
  762. package/skills/creative/web-artifacts-builder/scripts/init-artifact.sh +0 -322
  763. package/skills/creative/web-artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
  764. package/skills/documents/doc-coauthoring/SKILL-zh.md +0 -375
  765. package/skills/documents/doc-coauthoring/SKILL.md +0 -375
  766. package/skills/documents/docx/LICENSE.txt +0 -30
  767. package/skills/documents/docx/SKILL-zh.md +0 -590
  768. package/skills/documents/docx/SKILL.md +0 -590
  769. package/skills/documents/docx/scripts/__init__.py +0 -1
  770. package/skills/documents/docx/scripts/accept_changes.py +0 -135
  771. package/skills/documents/docx/scripts/comment.py +0 -318
  772. package/skills/documents/docx/scripts/office/helpers/__init__.py +0 -0
  773. package/skills/documents/docx/scripts/office/helpers/merge_runs.py +0 -199
  774. package/skills/documents/docx/scripts/office/helpers/simplify_redlines.py +0 -197
  775. package/skills/documents/docx/scripts/office/pack.py +0 -159
  776. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +0 -1499
  777. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +0 -146
  778. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +0 -1085
  779. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +0 -11
  780. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +0 -3081
  781. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +0 -23
  782. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +0 -185
  783. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +0 -287
  784. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +0 -1676
  785. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +0 -28
  786. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +0 -144
  787. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +0 -174
  788. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +0 -25
  789. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +0 -18
  790. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +0 -59
  791. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +0 -56
  792. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +0 -195
  793. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +0 -582
  794. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +0 -25
  795. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +0 -4439
  796. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +0 -570
  797. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +0 -509
  798. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +0 -12
  799. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +0 -108
  800. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +0 -96
  801. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +0 -3646
  802. package/skills/documents/docx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +0 -116
  803. package/skills/documents/docx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +0 -42
  804. package/skills/documents/docx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +0 -50
  805. package/skills/documents/docx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +0 -49
  806. package/skills/documents/docx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +0 -33
  807. package/skills/documents/docx/scripts/office/schemas/mce/mc.xsd +0 -75
  808. package/skills/documents/docx/scripts/office/schemas/microsoft/wml-2010.xsd +0 -560
  809. package/skills/documents/docx/scripts/office/schemas/microsoft/wml-2012.xsd +0 -67
  810. package/skills/documents/docx/scripts/office/schemas/microsoft/wml-2018.xsd +0 -14
  811. package/skills/documents/docx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +0 -20
  812. package/skills/documents/docx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +0 -13
  813. package/skills/documents/docx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +0 -4
  814. package/skills/documents/docx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +0 -8
  815. package/skills/documents/docx/scripts/office/soffice.py +0 -183
  816. package/skills/documents/docx/scripts/office/unpack.py +0 -132
  817. package/skills/documents/docx/scripts/office/validate.py +0 -111
  818. package/skills/documents/docx/scripts/office/validators/__init__.py +0 -15
  819. package/skills/documents/docx/scripts/office/validators/base.py +0 -847
  820. package/skills/documents/docx/scripts/office/validators/docx.py +0 -446
  821. package/skills/documents/docx/scripts/office/validators/pptx.py +0 -275
  822. package/skills/documents/docx/scripts/office/validators/redlining.py +0 -247
  823. package/skills/documents/docx/scripts/templates/comments.xml +0 -3
  824. package/skills/documents/docx/scripts/templates/commentsExtended.xml +0 -3
  825. package/skills/documents/docx/scripts/templates/commentsExtensible.xml +0 -3
  826. package/skills/documents/docx/scripts/templates/commentsIds.xml +0 -3
  827. package/skills/documents/docx/scripts/templates/people.xml +0 -3
  828. package/skills/documents/pdf/LICENSE.txt +0 -30
  829. package/skills/documents/pdf/SKILL-zh.md +0 -314
  830. package/skills/documents/pdf/SKILL.md +0 -314
  831. package/skills/documents/pdf/forms.md +0 -294
  832. package/skills/documents/pdf/reference.md +0 -612
  833. package/skills/documents/pdf/scripts/check_bounding_boxes.py +0 -65
  834. package/skills/documents/pdf/scripts/check_fillable_fields.py +0 -11
  835. package/skills/documents/pdf/scripts/convert_pdf_to_images.py +0 -33
  836. package/skills/documents/pdf/scripts/create_validation_image.py +0 -37
  837. package/skills/documents/pdf/scripts/extract_form_field_info.py +0 -122
  838. package/skills/documents/pdf/scripts/extract_form_structure.py +0 -115
  839. package/skills/documents/pdf/scripts/fill_fillable_fields.py +0 -98
  840. package/skills/documents/pdf/scripts/fill_pdf_form_with_annotations.py +0 -107
  841. package/skills/documents/pptx/LICENSE.txt +0 -30
  842. package/skills/documents/pptx/SKILL-zh.md +0 -232
  843. package/skills/documents/pptx/SKILL.md +0 -232
  844. package/skills/documents/pptx/editing.md +0 -205
  845. package/skills/documents/pptx/pptxgenjs.md +0 -420
  846. package/skills/documents/pptx/scripts/__init__.py +0 -0
  847. package/skills/documents/pptx/scripts/add_slide.py +0 -195
  848. package/skills/documents/pptx/scripts/clean.py +0 -286
  849. package/skills/documents/pptx/scripts/office/helpers/__init__.py +0 -0
  850. package/skills/documents/pptx/scripts/office/helpers/merge_runs.py +0 -199
  851. package/skills/documents/pptx/scripts/office/helpers/simplify_redlines.py +0 -197
  852. package/skills/documents/pptx/scripts/office/pack.py +0 -159
  853. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chart.xsd +0 -1499
  854. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-chartDrawing.xsd +0 -146
  855. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-diagram.xsd +0 -1085
  856. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-lockedCanvas.xsd +0 -11
  857. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-main.xsd +0 -3081
  858. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-picture.xsd +0 -23
  859. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-spreadsheetDrawing.xsd +0 -185
  860. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/dml-wordprocessingDrawing.xsd +0 -287
  861. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/pml.xsd +0 -1676
  862. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-additionalCharacteristics.xsd +0 -28
  863. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-bibliography.xsd +0 -144
  864. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-commonSimpleTypes.xsd +0 -174
  865. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlDataProperties.xsd +0 -25
  866. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-customXmlSchemaProperties.xsd +0 -18
  867. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesCustom.xsd +0 -59
  868. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesExtended.xsd +0 -56
  869. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-documentPropertiesVariantTypes.xsd +0 -195
  870. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-math.xsd +0 -582
  871. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/shared-relationshipReference.xsd +0 -25
  872. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/sml.xsd +0 -4439
  873. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-main.xsd +0 -570
  874. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-officeDrawing.xsd +0 -509
  875. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-presentationDrawing.xsd +0 -12
  876. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-spreadsheetDrawing.xsd +0 -108
  877. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/vml-wordprocessingDrawing.xsd +0 -96
  878. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/wml.xsd +0 -3646
  879. package/skills/documents/pptx/scripts/office/schemas/ISO-IEC29500-4_2016/xml.xsd +0 -116
  880. package/skills/documents/pptx/scripts/office/schemas/ecma/fouth-edition/opc-contentTypes.xsd +0 -42
  881. package/skills/documents/pptx/scripts/office/schemas/ecma/fouth-edition/opc-coreProperties.xsd +0 -50
  882. package/skills/documents/pptx/scripts/office/schemas/ecma/fouth-edition/opc-digSig.xsd +0 -49
  883. package/skills/documents/pptx/scripts/office/schemas/ecma/fouth-edition/opc-relationships.xsd +0 -33
  884. package/skills/documents/pptx/scripts/office/schemas/mce/mc.xsd +0 -75
  885. package/skills/documents/pptx/scripts/office/schemas/microsoft/wml-2010.xsd +0 -560
  886. package/skills/documents/pptx/scripts/office/schemas/microsoft/wml-2012.xsd +0 -67
  887. package/skills/documents/pptx/scripts/office/schemas/microsoft/wml-2018.xsd +0 -14
  888. package/skills/documents/pptx/scripts/office/schemas/microsoft/wml-cex-2018.xsd +0 -20
  889. package/skills/documents/pptx/scripts/office/schemas/microsoft/wml-cid-2016.xsd +0 -13
  890. package/skills/documents/pptx/scripts/office/schemas/microsoft/wml-sdtdatahash-2020.xsd +0 -4
  891. package/skills/documents/pptx/scripts/office/schemas/microsoft/wml-symex-2015.xsd +0 -8
  892. package/skills/documents/pptx/scripts/office/soffice.py +0 -183
  893. package/skills/documents/pptx/scripts/office/unpack.py +0 -132
  894. package/skills/documents/pptx/scripts/office/validate.py +0 -111
  895. package/skills/documents/pptx/scripts/office/validators/__init__.py +0 -15
  896. package/skills/documents/pptx/scripts/office/validators/base.py +0 -847
  897. package/skills/documents/pptx/scripts/office/validators/docx.py +0 -446
  898. package/skills/documents/pptx/scripts/office/validators/pptx.py +0 -275
  899. package/skills/documents/pptx/scripts/office/validators/redlining.py +0 -247
  900. package/skills/documents/pptx/scripts/thumbnail.py +0 -289
  901. package/skills/documents/xlsx/SKILL-zh.md +0 -292
  902. package/skills/engineering/diagnose/SKILL-zh.md +0 -117
  903. package/skills/engineering/grill-with-docs/ADR-FORMAT.md +0 -47
  904. package/skills/engineering/grill-with-docs/CONTEXT-FORMAT.md +0 -77
  905. package/skills/engineering/grill-with-docs/SKILL-zh.md +0 -88
  906. package/skills/engineering/grill-with-docs/SKILL.md +0 -88
  907. package/skills/engineering/improve-codebase-architecture/DEEPENING.md +0 -37
  908. package/skills/engineering/improve-codebase-architecture/INTERFACE-DESIGN.md +0 -44
  909. package/skills/engineering/improve-codebase-architecture/LANGUAGE.md +0 -53
  910. package/skills/engineering/improve-codebase-architecture/SKILL-zh.md +0 -71
  911. package/skills/engineering/improve-codebase-architecture/SKILL.md +0 -71
  912. package/skills/engineering/tdd/SKILL-zh.md +0 -109
  913. package/skills/engineering/to-issues/SKILL-zh.md +0 -81
  914. package/skills/engineering/to-issues/SKILL.md +0 -81
  915. package/skills/engineering/to-prd/SKILL-zh.md +0 -76
  916. package/skills/engineering/to-prd/SKILL.md +0 -74
  917. package/skills/engineering/zoom-out/SKILL-zh.md +0 -7
  918. package/skills/engineering/zoom-out/SKILL.md +0 -7
  919. package/skills/tools/find-skills/SKILL-zh.md +0 -440
  920. package/skills/tools/github/SKILL-zh.md +0 -48
  921. package/skills/tools/internal-comms/LICENSE.txt +0 -202
  922. package/skills/tools/internal-comms/SKILL-zh.md +0 -32
  923. package/skills/tools/internal-comms/SKILL.md +0 -32
  924. package/skills/tools/internal-comms/examples/3p-updates.md +0 -47
  925. package/skills/tools/internal-comms/examples/company-newsletter.md +0 -65
  926. package/skills/tools/internal-comms/examples/faq-answers.md +0 -30
  927. package/skills/tools/internal-comms/examples/general-comms.md +0 -16
  928. package/skills/tools/skill-creator/LICENSE.txt +0 -202
  929. package/skills/tools/skill-creator/SKILL-zh.md +0 -483
  930. package/skills/tools/skill-creator/SKILL.md +0 -485
  931. package/skills/tools/skill-creator/agents/analyzer.md +0 -274
  932. package/skills/tools/skill-creator/agents/comparator.md +0 -202
  933. package/skills/tools/skill-creator/agents/grader.md +0 -223
  934. package/skills/tools/skill-creator/assets/eval_review.html +0 -146
  935. package/skills/tools/skill-creator/eval-viewer/generate_review.py +0 -471
  936. package/skills/tools/skill-creator/eval-viewer/viewer.html +0 -1325
  937. package/skills/tools/skill-creator/references/schemas.md +0 -430
  938. package/skills/tools/skill-creator/scripts/__init__.py +0 -0
  939. package/skills/tools/skill-creator/scripts/aggregate_benchmark.py +0 -401
  940. package/skills/tools/skill-creator/scripts/generate_report.py +0 -326
  941. package/skills/tools/skill-creator/scripts/improve_description.py +0 -247
  942. package/skills/tools/skill-creator/scripts/package_skill.py +0 -136
  943. package/skills/tools/skill-creator/scripts/quick_validate.py +0 -103
  944. package/skills/tools/skill-creator/scripts/run_eval.py +0 -310
  945. package/skills/tools/skill-creator/scripts/run_loop.py +0 -328
  946. package/skills/tools/skill-creator/scripts/utils.py +0 -47
  947. package/skills/tools/summarize/SKILL-zh.md +0 -47
  948. package/skills/tools/weather/SKILL-zh.md +0 -46
  949. package/skills/tools/weather/SKILL.md +0 -46
  950. package/skills/tools/webapp-testing/SKILL-zh.md +0 -96
@@ -1,6 +1,9 @@
1
1
  import { hasTelegramBotEndpointApiRoot, normalizeTelegramApiRoot } from "./api-root.js";
2
2
  import { resolveTelegramBotToken } from "./token-resolver.js";
3
+ import { isTelegramUnauthorizedTokenError } from "./startup-errors.js";
4
+ import { createProxyFetch } from "./proxy-fetch.js";
3
5
  //#region extensions/telegram/src/doctor.ts
6
+ const TELEGRAM_DOCTOR_GETME_TIMEOUT_MS = 1e4;
4
7
  function collectTokens(cfg) {
5
8
  const map = /* @__PURE__ */ new Map();
6
9
  const accounts = cfg.accounts ?? {};
@@ -16,6 +19,64 @@ function collectTokens(cfg) {
16
19
  }
17
20
  return map;
18
21
  }
22
+ function formatGetMeError(err) {
23
+ if (err instanceof Error) return err.message;
24
+ return String(err);
25
+ }
26
+ function createTimeoutSignal(timeoutMs) {
27
+ const controller = new AbortController();
28
+ const timer = setTimeout(() => controller.abort(/* @__PURE__ */ new Error(`Timed out after ${timeoutMs}ms`)), timeoutMs);
29
+ timer.unref?.();
30
+ return {
31
+ signal: controller.signal,
32
+ dispose: () => clearTimeout(timer)
33
+ };
34
+ }
35
+ async function checkGetMe(params) {
36
+ const apiRoot = normalizeTelegramApiRoot(params.apiRoot);
37
+ const url = `${apiRoot}/bot${params.token}/getMe`;
38
+ const timeout = createTimeoutSignal(TELEGRAM_DOCTOR_GETME_TIMEOUT_MS);
39
+ const fetchImpl = params.proxy ? createProxyFetch(params.proxy) : params.fetchImpl ?? fetch;
40
+ try {
41
+ const startedAt = Date.now();
42
+ const response = await fetchImpl(url, { signal: timeout.signal });
43
+ const elapsedMs = Date.now() - startedAt;
44
+ const body = await response.json().catch(() => void 0);
45
+ if (response.ok && body?.ok === true) {
46
+ const username = body.result?.username ? ` @${body.result.username}` : "";
47
+ return {
48
+ id: `telegram-account-getme-${params.accountId}`,
49
+ label: `Telegram getMe (${params.accountId})`,
50
+ status: "pass",
51
+ message: `getMe succeeded${username} in ${elapsedMs}ms.`,
52
+ hints: params.proxy ? [`Using proxy: ${params.proxy}`] : []
53
+ };
54
+ }
55
+ const description = body?.description || `HTTP ${response.status}`;
56
+ return {
57
+ id: `telegram-account-getme-${params.accountId}`,
58
+ label: `Telegram getMe (${params.accountId})`,
59
+ status: isTelegramUnauthorizedTokenError(description) ? "fail" : "warn",
60
+ message: `getMe failed: ${description}`,
61
+ hints: isTelegramUnauthorizedTokenError(description) ? ["Verify the bot token from @BotFather."] : ["Check channels.telegram.apiRoot / account apiRoot and network access."]
62
+ };
63
+ } catch (err) {
64
+ const message = formatGetMeError(err);
65
+ return {
66
+ id: `telegram-account-getme-${params.accountId}`,
67
+ label: `Telegram getMe (${params.accountId})`,
68
+ status: "fail",
69
+ message: `getMe network check failed: ${message}`,
70
+ hints: [
71
+ "Verify this host can reach the Telegram Bot API.",
72
+ "If your shell uses HTTP(S)_PROXY, also set channels.telegram.proxy because Node fetch does not use env proxy automatically.",
73
+ `Effective apiRoot: ${apiRoot}`
74
+ ]
75
+ };
76
+ } finally {
77
+ timeout.dispose();
78
+ }
79
+ }
19
80
  async function runTelegramDoctorChecks(params) {
20
81
  const results = [];
21
82
  const tg = params.cfg.channels?.telegram;
@@ -71,6 +132,13 @@ async function runTelegramDoctorChecks(params) {
71
132
  message: `Account "${id}" bot token looks too short.`,
72
133
  hints: ["Verify the token from @BotFather."]
73
134
  });
135
+ if (tg.enabled && token && acc.enabled !== false) results.push(await checkGetMe({
136
+ accountId: id,
137
+ token,
138
+ apiRoot: acc.apiRoot || tg.apiRoot,
139
+ proxy: acc.proxy || tg.proxy,
140
+ fetchImpl: params.fetchImpl
141
+ }));
74
142
  }
75
143
  return results;
76
144
  }
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.js","names":[],"sources":["../../../../extensions/telegram/src/doctor.ts"],"sourcesContent":["import type { Config } from '@xopcai/xopc/config/index.js';\nimport type { ChannelDoctorCheckResult } from '@xopcai/xopc/channels/plugin-types.js';\nimport { hasTelegramBotEndpointApiRoot, normalizeTelegramApiRoot } from './api-root.js';\nimport { resolveTelegramBotToken } from './token-resolver.js';\n\ntype TelegramCfg = {\n enabled?: boolean;\n dmPolicy?: string;\n allowFrom?: Array<string | number>;\n apiRoot?: string;\n accounts?: Record<\n string,\n {\n botToken?: string;\n tokenFile?: string;\n apiRoot?: string;\n dmPolicy?: string;\n allowFrom?: Array<string | number>;\n }\n >;\n};\n\nfunction collectTokens(cfg: TelegramCfg): Map<string, string[]> {\n const map = new Map<string, string[]>();\n const accounts = cfg.accounts ?? {};\n for (const [id, acc] of Object.entries(accounts)) {\n const { token } = resolveTelegramBotToken({\n botToken: acc.botToken,\n tokenFile: acc.tokenFile,\n });\n if (!token) continue;\n const list = map.get(token) ?? [];\n list.push(id);\n map.set(token, list);\n }\n return map;\n}\n\nexport async function runTelegramDoctorChecks(params: {\n cfg: Config;\n}): Promise<ChannelDoctorCheckResult[]> {\n const results: ChannelDoctorCheckResult[] = [];\n const tg = params.cfg.channels?.telegram as TelegramCfg | undefined;\n if (!tg) {\n return results;\n }\n\n if (tg.enabled && tg.dmPolicy === 'open') {\n const allow = tg.allowFrom ?? [];\n const hasWildcard = allow.some((e) => String(e).trim() === '*');\n results.push({\n id: 'telegram-dm-open-wildcard',\n label: 'Telegram DM open policy',\n status: hasWildcard ? 'pass' : 'warn',\n message: hasWildcard\n ? 'DM policy is open with allowFrom wildcard.'\n : 'dmPolicy \"open\" should include allowFrom: [\"*\"] for explicit opt-in.',\n hints: hasWildcard ? [] : ['Add `\"allowFrom\": [\"*\"]` or switch to pairing/allowlist.'],\n });\n }\n\n if (hasTelegramBotEndpointApiRoot(tg.apiRoot)) {\n results.push({\n id: 'telegram-api-root-bot-endpoint',\n label: 'Telegram apiRoot',\n status: 'warn',\n message: 'apiRoot includes a bot token path segment; it will be normalized to the API root.',\n hints: [`Use \"${normalizeTelegramApiRoot(tg.apiRoot)}\" instead.`],\n });\n }\n\n const tokenMap = collectTokens(tg);\n for (const [token, accountIds] of tokenMap) {\n if (accountIds.length > 1) {\n results.push({\n id: `telegram-duplicate-token-${accountIds.join('-')}`,\n label: 'Telegram duplicate bot token',\n status: 'fail',\n message: `Bot token is shared by accounts: ${accountIds.join(', ')}.`,\n hints: ['Use one token per account or disable duplicate accounts.'],\n });\n }\n void token;\n }\n\n for (const [id, acc] of Object.entries(tg.accounts ?? {})) {\n if (hasTelegramBotEndpointApiRoot(acc.apiRoot)) {\n results.push({\n id: `telegram-account-api-root-${id}`,\n label: `Telegram apiRoot (${id})`,\n status: 'warn',\n message: `Account \"${id}\" apiRoot includes bot endpoint; will be normalized.`,\n hints: [`Use \"${normalizeTelegramApiRoot(acc.apiRoot)}\"`],\n });\n }\n const { token, source } = resolveTelegramBotToken({\n botToken: acc.botToken,\n tokenFile: acc.tokenFile,\n });\n if (tg.enabled && acc && source === 'none' && (acc as { enabled?: boolean }).enabled !== false) {\n results.push({\n id: `telegram-account-token-${id}`,\n label: `Telegram token (${id})`,\n status: 'fail',\n message: `Account \"${id}\" has no bot token or readable tokenFile.`,\n hints: ['Set botToken or tokenFile in channels.telegram.accounts.' + id],\n });\n }\n if (token && token.length < 20) {\n results.push({\n id: `telegram-account-token-short-${id}`,\n label: `Telegram token (${id})`,\n status: 'warn',\n message: `Account \"${id}\" bot token looks too short.`,\n hints: ['Verify the token from @BotFather.'],\n });\n }\n }\n\n return results;\n}\n"],"mappings":";;;AAsBA,SAAS,cAAc,KAAyC;CAC9D,MAAM,sBAAM,IAAI,KAAuB;CACvC,MAAM,WAAW,IAAI,YAAY,EAAE;AACnC,MAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,SAAS,EAAE;EAChD,MAAM,EAAE,UAAU,wBAAwB;GACxC,UAAU,IAAI;GACd,WAAW,IAAI;GAChB,CAAC;AACF,MAAI,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AC1D,CAAC;EAEJ,MAAM,EAAE,OAAO,WAAW,wBAAwB;GAChD,UAAU,IAAI;GACd,WAAW,IAAI;GAChB,CAAC;AACF,MAAI,GAAG,WAAW,OAAO,WAAW,UAAW,IAA8B,YAAY,MACvF,SAAQ,KAAK;GACX,IAAI,0BAA0B;GAC9B,OAAO,mBAAmB,GAAG;GAC7B,QAAQ;GACR,SAAS,YAAY,GAAG;GACxB,OAAO,CAAC,6DAA6D,GAAG;GACzE,CAAC;AAEJ,MAAI,SAAS,MAAM,SAAS,GAC1B,SAAQ,KAAK;GACX,IAAI,gCAAgC;GACpC,OAAO,mBAAmB,GAAG;GAC7B,QAAQ;GACR,SAAS,YAAY,GAAG;GACxB,OAAO,CAAC,oCAAoC;GAC7C,CAAC;;AAIN,QAAO"}
1
+ {"version":3,"file":"doctor.js","names":[],"sources":["../../../../extensions/telegram/src/doctor.ts"],"sourcesContent":["import type { Config } from '@xopcai/xopc/config/index.js';\nimport type { ChannelDoctorCheckResult } from '@xopcai/xopc/channels/plugin-types.js';\nimport { hasTelegramBotEndpointApiRoot, normalizeTelegramApiRoot } from './api-root.js';\nimport { createProxyFetch } from './proxy-fetch.js';\nimport { isTelegramUnauthorizedTokenError } from './startup-errors.js';\nimport { resolveTelegramBotToken } from './token-resolver.js';\n\nconst TELEGRAM_DOCTOR_GETME_TIMEOUT_MS = 10_000;\n\ntype TelegramCfg = {\n enabled?: boolean;\n dmPolicy?: string;\n allowFrom?: Array<string | number>;\n apiRoot?: string;\n proxy?: string;\n accounts?: Record<\n string,\n {\n enabled?: boolean;\n botToken?: string;\n tokenFile?: string;\n apiRoot?: string;\n proxy?: string;\n dmPolicy?: string;\n allowFrom?: Array<string | number>;\n }\n >;\n};\n\nfunction collectTokens(cfg: TelegramCfg): Map<string, string[]> {\n const map = new Map<string, string[]>();\n const accounts = cfg.accounts ?? {};\n for (const [id, acc] of Object.entries(accounts)) {\n const { token } = resolveTelegramBotToken({\n botToken: acc.botToken,\n tokenFile: acc.tokenFile,\n });\n if (!token) continue;\n const list = map.get(token) ?? [];\n list.push(id);\n map.set(token, list);\n }\n return map;\n}\n\nfunction formatGetMeError(err: unknown): string {\n if (err instanceof Error) return err.message;\n return String(err);\n}\n\nfunction createTimeoutSignal(timeoutMs: number): { signal: AbortSignal; dispose: () => void } {\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(new Error(`Timed out after ${timeoutMs}ms`)), timeoutMs);\n timer.unref?.();\n return {\n signal: controller.signal,\n dispose: () => clearTimeout(timer),\n };\n}\n\nasync function checkGetMe(params: {\n accountId: string;\n token: string;\n apiRoot?: string;\n proxy?: string;\n fetchImpl?: typeof fetch;\n}): Promise<ChannelDoctorCheckResult> {\n const apiRoot = normalizeTelegramApiRoot(params.apiRoot);\n const url = `${apiRoot}/bot${params.token}/getMe`;\n const timeout = createTimeoutSignal(TELEGRAM_DOCTOR_GETME_TIMEOUT_MS);\n const fetchImpl = params.proxy ? createProxyFetch(params.proxy) : (params.fetchImpl ?? fetch);\n\n try {\n const startedAt = Date.now();\n const response = await fetchImpl(url, { signal: timeout.signal });\n const elapsedMs = Date.now() - startedAt;\n const body = (await response.json().catch(() => undefined)) as\n | { ok?: boolean; result?: { username?: string }; description?: string }\n | undefined;\n\n if (response.ok && body?.ok === true) {\n const username = body.result?.username ? ` @${body.result.username}` : '';\n return {\n id: `telegram-account-getme-${params.accountId}`,\n label: `Telegram getMe (${params.accountId})`,\n status: 'pass',\n message: `getMe succeeded${username} in ${elapsedMs}ms.`,\n hints: params.proxy ? [`Using proxy: ${params.proxy}`] : [],\n };\n }\n\n const description = body?.description || `HTTP ${response.status}`;\n return {\n id: `telegram-account-getme-${params.accountId}`,\n label: `Telegram getMe (${params.accountId})`,\n status: isTelegramUnauthorizedTokenError(description) ? 'fail' : 'warn',\n message: `getMe failed: ${description}`,\n hints: isTelegramUnauthorizedTokenError(description)\n ? ['Verify the bot token from @BotFather.']\n : ['Check channels.telegram.apiRoot / account apiRoot and network access.'],\n };\n } catch (err) {\n const message = formatGetMeError(err);\n return {\n id: `telegram-account-getme-${params.accountId}`,\n label: `Telegram getMe (${params.accountId})`,\n status: 'fail',\n message: `getMe network check failed: ${message}`,\n hints: [\n 'Verify this host can reach the Telegram Bot API.',\n 'If your shell uses HTTP(S)_PROXY, also set channels.telegram.proxy because Node fetch does not use env proxy automatically.',\n `Effective apiRoot: ${apiRoot}`,\n ],\n };\n } finally {\n timeout.dispose();\n }\n}\n\nexport async function runTelegramDoctorChecks(params: {\n cfg: Config;\n fetchImpl?: typeof fetch;\n}): Promise<ChannelDoctorCheckResult[]> {\n const results: ChannelDoctorCheckResult[] = [];\n const tg = params.cfg.channels?.telegram as TelegramCfg | undefined;\n if (!tg) {\n return results;\n }\n\n if (tg.enabled && tg.dmPolicy === 'open') {\n const allow = tg.allowFrom ?? [];\n const hasWildcard = allow.some((e) => String(e).trim() === '*');\n results.push({\n id: 'telegram-dm-open-wildcard',\n label: 'Telegram DM open policy',\n status: hasWildcard ? 'pass' : 'warn',\n message: hasWildcard\n ? 'DM policy is open with allowFrom wildcard.'\n : 'dmPolicy \"open\" should include allowFrom: [\"*\"] for explicit opt-in.',\n hints: hasWildcard ? [] : ['Add `\"allowFrom\": [\"*\"]` or switch to pairing/allowlist.'],\n });\n }\n\n if (hasTelegramBotEndpointApiRoot(tg.apiRoot)) {\n results.push({\n id: 'telegram-api-root-bot-endpoint',\n label: 'Telegram apiRoot',\n status: 'warn',\n message: 'apiRoot includes a bot token path segment; it will be normalized to the API root.',\n hints: [`Use \"${normalizeTelegramApiRoot(tg.apiRoot)}\" instead.`],\n });\n }\n\n const tokenMap = collectTokens(tg);\n for (const [token, accountIds] of tokenMap) {\n if (accountIds.length > 1) {\n results.push({\n id: `telegram-duplicate-token-${accountIds.join('-')}`,\n label: 'Telegram duplicate bot token',\n status: 'fail',\n message: `Bot token is shared by accounts: ${accountIds.join(', ')}.`,\n hints: ['Use one token per account or disable duplicate accounts.'],\n });\n }\n void token;\n }\n\n for (const [id, acc] of Object.entries(tg.accounts ?? {})) {\n if (hasTelegramBotEndpointApiRoot(acc.apiRoot)) {\n results.push({\n id: `telegram-account-api-root-${id}`,\n label: `Telegram apiRoot (${id})`,\n status: 'warn',\n message: `Account \"${id}\" apiRoot includes bot endpoint; will be normalized.`,\n hints: [`Use \"${normalizeTelegramApiRoot(acc.apiRoot)}\"`],\n });\n }\n const { token, source } = resolveTelegramBotToken({\n botToken: acc.botToken,\n tokenFile: acc.tokenFile,\n });\n if (tg.enabled && acc && source === 'none' && (acc as { enabled?: boolean }).enabled !== false) {\n results.push({\n id: `telegram-account-token-${id}`,\n label: `Telegram token (${id})`,\n status: 'fail',\n message: `Account \"${id}\" has no bot token or readable tokenFile.`,\n hints: ['Set botToken or tokenFile in channels.telegram.accounts.' + id],\n });\n }\n if (token && token.length < 20) {\n results.push({\n id: `telegram-account-token-short-${id}`,\n label: `Telegram token (${id})`,\n status: 'warn',\n message: `Account \"${id}\" bot token looks too short.`,\n hints: ['Verify the token from @BotFather.'],\n });\n }\n\n if (tg.enabled && token && acc.enabled !== false) {\n results.push(\n await checkGetMe({\n accountId: id,\n token,\n apiRoot: acc.apiRoot || tg.apiRoot,\n proxy: acc.proxy || tg.proxy,\n fetchImpl: params.fetchImpl,\n }),\n );\n }\n }\n\n return results;\n}\n"],"mappings":";;;;;AAOA,MAAM,mCAAmC;AAsBzC,SAAS,cAAc,KAAyC;CAC9D,MAAM,sBAAM,IAAI,KAAuB;CACvC,MAAM,WAAW,IAAI,YAAY,EAAE;AACnC,MAAK,MAAM,CAAC,IAAI,QAAQ,OAAO,QAAQ,SAAS,EAAE;EAChD,MAAM,EAAE,UAAU,wBAAwB;GACxC,UAAU,IAAI;GACd,WAAW,IAAI;GAChB,CAAC;AACF,MAAI,CAAC,MAAO;EACZ,MAAM,OAAO,IAAI,IAAI,MAAM,IAAI,EAAE;AACjC,OAAK,KAAK,GAAG;AACb,MAAI,IAAI,OAAO,KAAK;;AAEtB,QAAO;;AAGT,SAAS,iBA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AK;GACX,IAAI,6BAA6B;GACjC,OAAO,qBAAqB,GAAG;GAC/B,QAAQ;GACR,SAAS,YAAY,GAAG;GACxB,OAAO,CAAC,QAAQ,yBAAyB,IAAI,QAAQ,CAAC,GAAG;GAC1D,CAAC;EAEJ,MAAM,EAAE,OAAO,WAAW,wBAAwB;GAChD,UAAU,IAAI;GACd,WAAW,IAAI;GAChB,CAAC;AACF,MAAI,GAAG,WAAW,OAAO,WAAW,UAAW,IAA8B,YAAY,MACvF,SAAQ,KAAK;GACX,IAAI,0BAA0B;GAC9B,OAAO,mBAAmB,GAAG;GAC7B,QAAQ;GACR,SAAS,YAAY,GAAG;GACxB,OAAO,CAAC,6DAA6D,GAAG;GACzE,CAAC;AAEJ,MAAI,SAAS,MAAM,SAAS,GAC1B,SAAQ,KAAK;GACX,IAAI,gCAAgC;GACpC,OAAO,mBAAmB,GAAG;GAC7B,QAAQ;GACR,SAAS,YAAY,GAAG;GACxB,OAAO,CAAC,oCAAoC;GAC7C,CAAC;AAGJ,MAAI,GAAG,WAAW,SAAS,IAAI,YAAY,MACzC,SAAQ,KACN,MAAM,WAAW;GACf,WAAW;GACX;GACA,SAAS,IAAI,WAAW,GAAG;GAC3B,OAAO,IAAI,SAAS,GAAG;GACvB,WAAW,OAAO;GACnB,CAAC,CACH;;AAIL,QAAO"}
@@ -1,6 +1,13 @@
1
1
  /**
2
- * Bundled Telegram channel extension entry (registration helper).
2
+ * Bundled Telegram channel extension entry.
3
3
  */
4
4
  export { telegramPlugin } from './plugin.js';
5
5
  export type { TelegramAccount } from './plugin.js';
6
6
  export { defineChannelPluginEntry } from '@xopcai/xopc/extensions/sdk/channel-entry.js';
7
+ declare const _default: {
8
+ id: string;
9
+ name: string;
10
+ description: string;
11
+ register(api: import("@xopcai/xopc/extension-sdk").ExtensionApi): void;
12
+ };
13
+ export default _default;
@@ -1,3 +1,16 @@
1
- import { telegramPlugin } from "./plugin.js";
2
1
  import { defineChannelPluginEntry } from "../../../src/extensions/sdk/channel-entry.js";
3
- export { defineChannelPluginEntry, telegramPlugin };
2
+ import { telegramPlugin } from "./plugin.js";
3
+ //#region extensions/telegram/src/index.ts
4
+ /**
5
+ * Bundled Telegram channel extension entry.
6
+ */
7
+ var src_default = defineChannelPluginEntry({
8
+ id: "telegram",
9
+ name: "Telegram",
10
+ description: "Telegram Bot API channel",
11
+ plugin: telegramPlugin
12
+ });
13
+ //#endregion
14
+ export { src_default as default, defineChannelPluginEntry, telegramPlugin };
15
+
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../extensions/telegram/src/index.ts"],"sourcesContent":["/**\n * Bundled Telegram channel extension entry.\n */\n\nimport { defineChannelPluginEntry } from '@xopcai/xopc/extensions/sdk/channel-entry.js';\n\nimport { telegramPlugin } from './plugin.js';\n\nexport { telegramPlugin } from './plugin.js';\nexport type { TelegramAccount } from './plugin.js';\nexport { defineChannelPluginEntry } from '@xopcai/xopc/extensions/sdk/channel-entry.js';\n\nexport default defineChannelPluginEntry({\n id: 'telegram',\n name: 'Telegram',\n description: 'Telegram Bot API channel',\n plugin: telegramPlugin,\n});\n"],"mappings":";;;;;;AAYA,IAAA,cAAe,yBAAyB;CACtC,IAAI;CACJ,MAAM;CACN,aAAa;CACb,QAAQ;CACT,CAAC"}
@@ -14,15 +14,23 @@ export declare class TelegramChannelPlugin implements ChannelPlugin<TelegramReso
14
14
  readonly id: "telegram";
15
15
  readonly reload: ChannelPluginReloadMeta;
16
16
  readonly meta: {
17
- readonly id: "telegram" | "feishu" | "weixin";
18
- readonly label: string;
17
+ readonly id: "telegram";
18
+ readonly label: "Telegram";
19
19
  readonly selectionLabel: "Telegram Bot";
20
20
  readonly docsPath: "/channels/telegram";
21
- readonly blurb: string;
21
+ readonly blurb: "Telegram Bot API channel";
22
22
  readonly order: 0;
23
23
  readonly deferConnectUntilAfterListen: true;
24
24
  };
25
- readonly capabilities: import("@xopcai/xopc/channels/plugin-types.js").ChannelCapabilities;
25
+ readonly capabilities: {
26
+ readonly chatTypes: Array<"direct" | "group" | "channel" | "thread">;
27
+ readonly reactions: true;
28
+ readonly threads: true;
29
+ readonly media: true;
30
+ readonly polls: false;
31
+ readonly nativeCommands: true;
32
+ readonly blockStreaming: true;
33
+ };
26
34
  readonly defaults: ChannelPluginDefaults;
27
35
  readonly setupWizard: import("@xopcai/xopc/channels/setup-wizard.js").ChannelSetupWizard;
28
36
  readonly configSchema: {
@@ -36,8 +44,8 @@ export declare class TelegramChannelPlugin implements ChannelPlugin<TelegramReso
36
44
  };
37
45
  };
38
46
  readonly cronDelivery: ChannelCronDeliveryAdapter;
39
- readonly configSurface: import("@xopcai/xopc/channels/plugins/types.adapters.js").ChannelConfigSurfaceAdapter;
40
47
  readonly onboard: import("@xopcai/xopc/channels/plugins/types.adapters.js").ChannelOnboardAdapter;
48
+ readonly runtimeActions: import("@xopcai/xopc/channels/plugins/types.adapters.js").ChannelRuntimeActionAdapter;
41
49
  readonly doctor: {
42
50
  check: (params: {
43
51
  cfg: Config;
@@ -14,7 +14,6 @@ import { issuePairingChallenge } from "../../../src/channels/pairing/pairing-cha
14
14
  import { createStandardPairingAdapter } from "../../../src/channels/pairing/pairing-store-adapter.js";
15
15
  import { createTimeoutAbortSignal } from "./timeout-abort.js";
16
16
  import { createInboundDebouncer } from "../../../src/infra/debounce.js";
17
- import { getChatChannelMeta } from "../../../src/channels/registry.js";
18
17
  import { getMimeType } from "../../../src/channels/media.js";
19
18
  import { TelegramAccountManager } from "./account-manager.js";
20
19
  import { createOutboundSender } from "./outbound-sender.js";
@@ -34,8 +33,8 @@ import { createTelegramStreamingAdapter } from "./adapters/streaming-adapter.js"
34
33
  import { createTelegramCommandAdapter } from "./adapters/command-adapter.js";
35
34
  import "./channel.js";
36
35
  import { normalizeTelegramDeliveryChatId } from "./delivery-chat-id.js";
37
- import { telegramConfigSurface } from "./adapters/config-surface.js";
38
36
  import { telegramOnboardAdapter } from "./adapters/onboard-cli.js";
37
+ import { telegramGatewaySetupActions } from "./adapters/gateway-setup.js";
39
38
  import { normalizeTelegramApiRoot } from "./api-root.js";
40
39
  import { resolveTelegramBotToken } from "./token-resolver.js";
41
40
  import { formatTelegramStartupError, isTelegramUnauthorizedTokenError } from "./startup-errors.js";
@@ -64,20 +63,44 @@ const TELEGRAM_GETME_TIMEOUT_MS = 2e4;
64
63
  /** grammY per-request ceiling; must exceed long-poll `getUpdates` (~30s) but avoid multi-minute hangs on bad hosts. */
65
64
  const TELEGRAM_CLIENT_TIMEOUT_SECONDS = 75;
66
65
  const log = createLogger("TelegramPlugin");
67
- const TELEGRAM_REGISTRY_META = getChatChannelMeta("telegram");
66
+ function contextWithMessage(ctx, message) {
67
+ if (ctx.message === message) return ctx;
68
+ const clone = Object.create(Object.getPrototypeOf(ctx));
69
+ Object.defineProperties(clone, Object.getOwnPropertyDescriptors(ctx));
70
+ Object.defineProperty(clone, "message", {
71
+ configurable: true,
72
+ enumerable: true,
73
+ value: message,
74
+ writable: true
75
+ });
76
+ return clone;
77
+ }
68
78
  var TelegramChannelPlugin = class {
69
79
  id = "telegram";
70
80
  reload = { configPrefixes: ["channels.telegram"] };
71
81
  meta = {
72
- id: TELEGRAM_REGISTRY_META.id,
73
- label: TELEGRAM_REGISTRY_META.label,
82
+ id: "telegram",
83
+ label: "Telegram",
74
84
  selectionLabel: "Telegram Bot",
75
85
  docsPath: "/channels/telegram",
76
- blurb: TELEGRAM_REGISTRY_META.description,
86
+ blurb: "Telegram Bot API channel",
77
87
  order: 0,
78
88
  deferConnectUntilAfterListen: true
79
89
  };
80
- capabilities = TELEGRAM_REGISTRY_META.capabilities;
90
+ capabilities = {
91
+ chatTypes: [
92
+ "direct",
93
+ "group",
94
+ "channel",
95
+ "thread"
96
+ ],
97
+ reactions: true,
98
+ threads: true,
99
+ media: true,
100
+ polls: false,
101
+ nativeCommands: true,
102
+ blockStreaming: true
103
+ };
81
104
  defaults = {
82
105
  queue: { debounceMs: TELEGRAM_CHANNEL_DEFAULTS.queue.debounceMs },
83
106
  outbound: { textChunkLimit: TELEGRAM_CHANNEL_DEFAULTS.outbound.textChunkLimit }
@@ -96,8 +119,8 @@ var TelegramChannelPlugin = class {
96
119
  cronDelivery = { async normalizeDeliveryTarget(to) {
97
120
  return { chatId: normalizeTelegramDeliveryChatId(to) };
98
121
  } };
99
- configSurface = telegramConfigSurface;
100
122
  onboard = telegramOnboardAdapter;
123
+ runtimeActions = telegramGatewaySetupActions;
101
124
  doctor = { check: (params) => runTelegramDoctorChecks(params) };
102
125
  pairing = createStandardPairingAdapter("telegram");
103
126
  bus;
@@ -423,10 +446,7 @@ var TelegramChannelPlugin = class {
423
446
  for (const msg of batch.messages) {
424
447
  const batchCtx = batch.ctx;
425
448
  await this.debouncer.enqueue({
426
- ctx: {
427
- ...batchCtx,
428
- message: msg
429
- },
449
+ ctx: contextWithMessage(batchCtx, msg),
430
450
  accountId: batch.accountId,
431
451
  message: msg
432
452
  });
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","names":["sttTranscribe"],"sources":["../../../../extensions/telegram/src/plugin.ts"],"sourcesContent":["/**\n * Telegram Channel Plugin - Implementation based on ChannelPlugin interface\n *\n * This plugin integrates Telegram with the ChannelPlugin architecture.\n * It reuses components from this package's src tree where possible.\n */\n\nimport { isDeepStrictEqual } from 'node:util';\n\nimport { Bot, type Context } from 'grammy';\n\nimport type { Config } from '@xopcai/xopc/config/index.js';\nimport type {\n ChannelPlugin,\n ChannelPluginDefaults,\n ChannelPluginInitOptions,\n ChannelPluginReloadMeta,\n ChannelPluginSessionModelHooks,\n ChannelPluginStartOptions,\n ChannelOutboundAdapter,\n ChannelSecurityContext,\n ChannelGatewayAdapter,\n ChannelStreamingAdapter,\n ChannelCommandAdapter,\n} from '@xopcai/xopc/channels/plugin-types.js';\nimport { generateSessionKey } from '@xopcai/xopc/chat-commands/session-key.js';\nimport { submitClarifyChoiceFromChannel } from '@xopcai/xopc/gateway/clarify-runtime.js';\n\nimport { createLogger } from '@xopcai/xopc/utils/logger.js';\nimport { issuePairingChallenge, resolveStandardPairingPath } from '@xopcai/xopc/channels/pairing/index.js';\nimport { createStandardPairingAdapter } from '@xopcai/xopc/channels/pairing/pairing-store-adapter.js';\nimport { createTimeoutAbortSignal } from './timeout-abort.js';\nimport { createInboundDebouncer } from '@xopcai/xopc/infra/debounce.js';\nimport { getChatChannelMeta } from '@xopcai/xopc/channels/registry.js';\nimport { getMimeType } from '@xopcai/xopc/channels/media.js';\nimport { transcribe as sttTranscribe, isSTTAvailable } from '@xopcai/xopc/voice/stt/index.js';\nimport type { STTConfig } from '@xopcai/xopc/voice/stt/types.js';\n\nimport { TelegramAccountManager } from './account-manager.js';\nimport { createOutboundSender } from './outbound-sender.js';\nimport { getWorkflowProgressBroker } from '@xopcai/xopc/agent/workflow/index.js';\nimport { createTelegramWorkflowProgressCapability } from './workflow-progress.js';\nimport { createTelegramCommandHandler } from './command-handler.js';\nimport { createInboundProcessor } from './inbound-processor.js';\nimport { TELEGRAM_CHANNEL_DEFAULTS } from './plugin-defaults.js';\nimport {\n createTelegramPluginAdapters,\n createTelegramSetupWizard,\n createTelegramOutboundSendMethods,\n telegramTextChunker,\n TELEGRAM_OUTBOUND_DEFAULTS,\n createTelegramInboundAccessControl,\n telegramDebouncerKeyPolicy,\n type TelegramMessageEvent,\n} from './adapters/index.js';\nimport {\n createTelegramGatewayAdapter,\n createTelegramStreamingAdapter,\n createTelegramCommandAdapter,\n} from './channel.js';\nimport type { TelegramResolvedAccount } from './adapters/index.js';\nimport type { ChannelCronDeliveryAdapter } from '@xopcai/xopc/channels/plugins/types.adapters.js';\nimport { normalizeTelegramDeliveryChatId } from './delivery-chat-id.js';\nimport { telegramConfigSurface } from './adapters/config-surface.js';\nimport { telegramOnboardAdapter } from './adapters/onboard-cli.js';\nimport { TelegramConfigSchema } from './config-schema.js';\nimport { normalizeTelegramApiRoot } from './api-root.js';\nimport { resolveTelegramBotToken } from './token-resolver.js';\nimport { formatTelegramStartupError, isTelegramUnauthorizedTokenError } from './startup-errors.js';\nimport { startTelegramPollingSession } from './polling-session.js';\nimport { createProxyFetch } from './proxy-fetch.js';\nimport { runTelegramDoctorChecks } from './doctor.js';\nimport { telegramReplyTracker } from './reply-params.js';\nimport { createTelegramInboundCoalescer } from './inbound-coalescer.js';\nimport { sendTelegramAckReaction, handleTelegramMessageReaction } from './reactions.js';\nimport { handleTelegramChannelAction, bindTelegramMessageActionAccountManager } from './actions/message-actions.js';\nimport { registerChannelExecApprovalHandler } from '@xopcai/xopc/channels/exec-approval-runtime.js';\nimport { createTelegramExecApprovalHandler } from './exec-approval-handler.js';\nimport { handleTelegramFocusCommand } from './focus-handler.js';\nimport { resolveTelegramApproval } from './approval-store.js';\nimport { isTelegramExecApprovalApprover } from './exec-approvals.js';\n\n/** Bound initial `getMe` so a bad `apiRoot` or unreachable API cannot block gateway startup for minutes. */\nconst TELEGRAM_GETME_TIMEOUT_MS = 20_000;\n/** grammY per-request ceiling; must exceed long-poll `getUpdates` (~30s) but avoid multi-minute hangs on bad hosts. */\nconst TELEGRAM_CLIENT_TIMEOUT_SECONDS = 75;\n\nconst log = createLogger('TelegramPlugin');\n\nconst TELEGRAM_REGISTRY_META = getChatChannelMeta('telegram');\n\nexport type { TelegramResolvedAccount as TelegramAccount } from './channel.js';\n\nexport class TelegramChannelPlugin implements ChannelPlugin<TelegramResolvedAccount> {\n readonly id = 'telegram' as const;\n\n readonly reload: ChannelPluginReloadMeta = {\n configPrefixes: ['channels.telegram'],\n };\n\n readonly meta = {\n id: TELEGRAM_REGISTRY_META.id,\n label: TELEGRAM_REGISTRY_META.label,\n selectionLabel: 'Telegram Bot',\n docsPath: '/channels/telegram',\n blurb: TELEGRAM_REGISTRY_META.description,\n order: 0,\n deferConnectUntilAfterListen: true,\n } as const;\n\n readonly capabilities = TELEGRAM_REGISTRY_META.capabilities;\n\n readonly defaults: ChannelPluginDefaults = {\n queue: { debounceMs: TELEGRAM_CHANNEL_DEFAULTS.queue.debounceMs },\n outbound: { textChunkLimit: TELEGRAM_CHANNEL_DEFAULTS.outbound.textChunkLimit },\n };\n\n readonly setupWizard = createTelegramSetupWizard();\n\n readonly configSchema = {\n schema: {},\n validate: (raw: unknown) => {\n const r = TelegramConfigSchema.safeParse(raw);\n return r.success ? { ok: true as const } : { ok: false as const, errors: [r.error.message] };\n },\n };\n\n readonly cronDelivery: ChannelCronDeliveryAdapter = {\n async normalizeDeliveryTarget(to) {\n return { chatId: normalizeTelegramDeliveryChatId(to) };\n },\n };\n\n readonly configSurface = telegramConfigSurface;\n\n readonly onboard = telegramOnboardAdapter;\n\n readonly doctor = {\n check: (params: { cfg: Config }) => runTelegramDoctorChecks(params),\n };\n\n readonly pairing = createStandardPairingAdapter('telegram');\n\n private bus!: NonNullable<ChannelPluginInitOptions['bus']>;\n private cfg!: NonNullable<ChannelPluginInitOptions['config']>;\n private debouncer!: ReturnType<typeof createInboundDebouncer<TelegramMessageEvent>>;\n\n private accountManager!: TelegramAccountManager;\n private outboundSender!: ReturnType<typeof createOutboundSender>;\n private commandHandler!: ReturnType<typeof createTelegramCommandHandler>;\n private inboundProcessor!: ReturnType<typeof createInboundProcessor>;\n private sessionModelHooks?: ChannelPluginSessionModelHooks;\n /** Unregister fn for the workflow-progress capability registered against the global broker. */\n private workflowProgressUnregister: (() => void) | null = null;\n private inboundCoalescer = createTelegramInboundCoalescer();\n private execApprovalUnregister: (() => void) | null = null;\n\n readonly actions = {\n handleAction: handleTelegramChannelAction,\n };\n\n config!: import('@xopcai/xopc/channels/plugin-types.js').ChannelConfigAdapter<TelegramResolvedAccount>;\n security!: import('@xopcai/xopc/channels/plugin-types.js').ChannelSecurityAdapter<TelegramResolvedAccount>;\n status!: import('@xopcai/xopc/channels/plugin-types.js').ChannelStatusAdapter<TelegramResolvedAccount>;\n\n outbound!: ChannelOutboundAdapter;\n\n gateway!: ChannelGatewayAdapter<TelegramResolvedAccount>;\n\n streaming!: ChannelStreamingAdapter;\n\n commands!: ChannelCommandAdapter;\n\n async init(options: ChannelPluginInitOptions): Promise<void> {\n this.bus = options.bus;\n this.cfg = options.config;\n this.sessionModelHooks = options.sessionModel;\n\n this.accountManager = new TelegramAccountManager();\n this.loadAccounts();\n this.bindOutboundComponents();\n bindTelegramMessageActionAccountManager(this.accountManager);\n this.execApprovalUnregister?.();\n this.execApprovalUnregister = registerChannelExecApprovalHandler(\n 'telegram',\n createTelegramExecApprovalHandler({\n accountManager: this.accountManager,\n getConfig: () => this.cfg,\n }),\n );\n\n // Workflow progress is fed from the agent-side broker (subscribes to\n // tool_execution_update for the `workflow` tool); the capability turns\n // each snapshot into an edit-in-place Telegram message. Registration is\n // idempotent — the broker replaces a prior cap with the same channelId.\n this.workflowProgressUnregister = getWorkflowProgressBroker().registerChannel(\n createTelegramWorkflowProgressCapability(this.accountManager),\n );\n\n const debounceMs =\n this.defaults.queue?.debounceMs ?? TELEGRAM_CHANNEL_DEFAULTS.queue.debounceMs;\n const keyPolicy = telegramDebouncerKeyPolicy();\n this.debouncer = createInboundDebouncer<TelegramMessageEvent>({\n debounceMs,\n ...keyPolicy,\n onFlush: async (items) => {\n await this.processMessages(items);\n },\n onError: (err, items) => {\n log.error({ err, count: items.length }, 'Debounced message processing failed');\n },\n });\n\n log.debug('Telegram plugin initialized');\n }\n\n private bindOutboundComponents(): void {\n this.outboundSender = createOutboundSender({\n accountManager: this.accountManager,\n config: this.cfg,\n });\n const sm = this.sessionModelHooks;\n this.commandHandler = createTelegramCommandHandler({\n bus: this.bus,\n config: this.cfg,\n accountManager: this.accountManager,\n getSessionModel: (sessionKey) => sm?.getModelForSession(sessionKey),\n setSessionModel: (sessionKey, modelId) => {\n if (!sm) return;\n void sm.switchModelForSession(sessionKey, modelId);\n },\n });\n const adapters = createTelegramPluginAdapters({\n accountManager: this.accountManager,\n });\n this.config = adapters.config;\n this.security = adapters.security;\n this.status = adapters.status;\n\n const accessControl = createTelegramInboundAccessControl();\n\n this.inboundProcessor = createInboundProcessor({\n bus: this.bus,\n config: this.cfg,\n accountManager: this.accountManager,\n accessControl,\n sessionKeyService: {\n generateSessionKey: (opts) =>\n generateSessionKey({\n source: 'telegram',\n chatId: opts.chatId,\n senderId: opts.senderId,\n isGroup: opts.isGroup,\n threadId: opts.threadId,\n accountId: opts.accountId,\n }),\n },\n sttService: {\n transcribe: async (buffer, config, options) => {\n const result = await sttTranscribe(buffer, config as STTConfig, options);\n return { text: result.text };\n },\n isSTTAvailable: (config) => isSTTAvailable(config as STTConfig | undefined),\n },\n mediaUtils: { getMimeType },\n });\n\n const sends = createTelegramOutboundSendMethods(\n (opts) => this.outboundSender.send(opts),\n this.accountManager,\n );\n this.outbound = {\n deliveryMode: 'direct',\n chunker: telegramTextChunker,\n chunkerMode: 'text',\n textChunkLimit: TELEGRAM_OUTBOUND_DEFAULTS.textChunkLimit,\n ...sends,\n };\n\n this.gateway = createTelegramGatewayAdapter({\n startAccount: (account) => this.startAccount(account),\n stopAccount: (accountId) => this.accountManager.stopRunner(accountId),\n });\n this.streaming = createTelegramStreamingAdapter({ accountManager: this.accountManager });\n this.commands = createTelegramCommandAdapter();\n }\n\n async onConfigUpdated(cfg: Config): Promise<void> {\n const prevTg = this.cfg.channels?.telegram as unknown;\n const nextTg = cfg.channels?.telegram as { enabled?: boolean } | undefined;\n // Match Weixin: only `enabled === true` keeps inbound (polling). Stops immediately on disable / missing section.\n const channelOff = !nextTg || nextTg.enabled !== true;\n if (channelOff) {\n this.cfg = cfg;\n await this.stop();\n this.accountManager.reset();\n this.bindOutboundComponents();\n return;\n }\n\n if (isDeepStrictEqual(prevTg, nextTg)) {\n this.cfg = cfg;\n this.bindOutboundComponents();\n // Config unchanged but runners may be stopped (e.g. disable → enable with identical JSON shape after normalize).\n if (!this.channelIsRunning(cfg)) {\n await this.reapplyFromConfig(cfg);\n }\n return;\n }\n await this.reapplyFromConfig(cfg);\n }\n\n private async reapplyFromConfig(cfg: Config): Promise<void> {\n this.cfg = cfg;\n await this.stop();\n this.accountManager.reset();\n const telegramCfg = cfg.channels?.telegram as Record<string, unknown> | undefined;\n const channelOn = telegramCfg != null && telegramCfg.enabled === true;\n if (!channelOn) {\n this.bindOutboundComponents();\n return;\n }\n this.loadAccounts();\n this.bindOutboundComponents();\n await this.start();\n }\n\n private loadAccounts(): void {\n const telegramCfg = this.cfg.channels?.telegram as Record<string, unknown> | undefined;\n if (!telegramCfg) return;\n if (telegramCfg.enabled !== true) {\n return;\n }\n\n const accounts = telegramCfg.accounts as Record<string, Record<string, unknown>> | undefined;\n if (!accounts || Object.keys(accounts).length === 0) return;\n\n const channelApiRoot =\n typeof telegramCfg.apiRoot === 'string'\n ? normalizeTelegramApiRoot(telegramCfg.apiRoot)\n : undefined;\n const channelProxy =\n typeof telegramCfg.proxy === 'string' && telegramCfg.proxy.trim()\n ? telegramCfg.proxy.trim()\n : undefined;\n const channelReplyToMode = telegramCfg.replyToMode as TelegramResolvedAccount['replyToMode'];\n const channelStreaming = telegramCfg.streaming as TelegramResolvedAccount['streaming'];\n\n const tokenOwners = new Map<string, string[]>();\n\n for (const [id, account] of Object.entries(accounts)) {\n const { token, source } = resolveTelegramBotToken({\n botToken: typeof account.botToken === 'string' ? account.botToken : undefined,\n tokenFile: typeof account.tokenFile === 'string' ? account.tokenFile : undefined,\n });\n if (token) {\n const owners = tokenOwners.get(token) ?? [];\n owners.push(id);\n tokenOwners.set(token, owners);\n }\n\n const accApiRoot =\n typeof account.apiRoot === 'string'\n ? normalizeTelegramApiRoot(account.apiRoot)\n : undefined;\n const accProxy =\n typeof account.proxy === 'string' && account.proxy.trim() ? account.proxy.trim() : undefined;\n\n this.accountManager.registerAccount({\n ...account,\n accountId: id,\n botToken: token,\n tokenFile: typeof account.tokenFile === 'string' ? account.tokenFile : undefined,\n tokenSource: source,\n ...(accApiRoot || channelApiRoot ? { apiRoot: accApiRoot || channelApiRoot } : {}),\n ...(accProxy || channelProxy ? { proxy: accProxy || channelProxy } : {}),\n replyToMode:\n (account.replyToMode as TelegramResolvedAccount['replyToMode']) ?? channelReplyToMode,\n streaming:\n (account.streaming as TelegramResolvedAccount['streaming']) ?? channelStreaming,\n } as import('@xopcai/xopc/channels/channel-domain.js').TelegramAccountConfig);\n }\n\n for (const [token, owners] of tokenOwners) {\n if (owners.length > 1) {\n log.error(\n { accountIds: owners, tokenPreview: `${token.slice(0, 8)}…` },\n `Duplicate Telegram bot token across accounts: ${owners.join(', ')}`,\n );\n }\n }\n }\n\n channelIsRunning(cfg: Config): boolean {\n return this.accountManager.getAllAccounts().some(\n (a) => a.enabled !== false && !!a.botToken && this.accountManager.isRunning(a.accountId),\n );\n }\n\n async start(options?: ChannelPluginStartOptions): Promise<void> {\n const section = this.cfg.channels?.telegram as { enabled?: boolean } | undefined;\n if (!section || section.enabled !== true) {\n return;\n }\n\n const accountIds = options?.accountId\n ? [options.accountId]\n : this.config.listAccountIds(this.cfg);\n\n for (const accountId of accountIds) {\n const account = this.config.resolveAccount(this.cfg, accountId);\n if (!account.enabled || !account.botToken) continue;\n await this.startAccount(account);\n }\n }\n\n async stop(accountId?: string): Promise<void> {\n if (!this.config) return;\n const ids = accountId ? [accountId] : this.config.listAccountIds(this.cfg);\n for (const id of ids) {\n await this.accountManager.stopRunner(id);\n log.info({ accountId: id }, 'Telegram account stopped');\n }\n // Only unregister the broker capability on a full stop (no specific\n // account). A per-account stop still leaves other accounts capable of\n // sending progress through the same registered cap.\n if (!accountId) {\n this.workflowProgressUnregister?.();\n this.workflowProgressUnregister = null;\n this.execApprovalUnregister?.();\n this.execApprovalUnregister = null;\n }\n }\n\n private async startAccount(account: TelegramResolvedAccount): Promise<void> {\n if (this.accountManager.isRunning(account.accountId)) return;\n\n const resolved = resolveTelegramBotToken({\n botToken: account.botToken,\n tokenFile: account.tokenFile,\n });\n if (!resolved.token) return;\n\n const duplicateAccounts = this.accountManager\n .getAllAccounts()\n .filter((a) => {\n const t = resolveTelegramBotToken({\n botToken: a.botToken,\n tokenFile: a.tokenFile,\n }).token;\n return t === resolved.token && a.accountId !== account.accountId;\n })\n .map((a) => a.accountId);\n if (duplicateAccounts.length > 0) {\n const em = `Duplicate bot token shared with account(s): ${duplicateAccounts.join(', ')}`;\n log.error({ accountId: account.accountId, duplicateAccounts }, em);\n this.accountManager.updateStatus({\n accountId: account.accountId,\n running: false,\n mode: 'stopped',\n lastError: em,\n });\n return;\n }\n\n this.accountManager.markStarting(account.accountId);\n\n try {\n const client: {\n timeoutSeconds: number;\n apiRoot?: string;\n fetch?: typeof fetch;\n } = {\n timeoutSeconds: TELEGRAM_CLIENT_TIMEOUT_SECONDS,\n ...(account.apiRoot ? { apiRoot: account.apiRoot } : {}),\n ...(account.proxy ? { fetch: createProxyFetch(account.proxy) } : {}),\n };\n const bot = new Bot(resolved.token, { client });\n const getMeSignal = createTimeoutAbortSignal(TELEGRAM_GETME_TIMEOUT_MS);\n let me;\n try {\n me = await bot.api.getMe(getMeSignal.signal);\n } finally {\n getMeSignal.dispose();\n }\n\n this.accountManager.registerBot(account.accountId, bot);\n this.accountManager.setBotUsername(account.accountId, me.username);\n this.setupMessageHandler(account.accountId, bot);\n\n const session = startTelegramPollingSession({\n accountId: account.accountId,\n botToken: resolved.token,\n bot,\n stallThresholdMs: account.pollingStallThresholdMs,\n onExit: () => {\n void this.accountManager.stopRunner(account.accountId);\n },\n });\n this.accountManager.registerPollingSession(account.accountId, session);\n this.accountManager.updateStatus({\n accountId: account.accountId,\n running: true,\n mode: 'polling',\n });\n\n log.info({ accountId: account.accountId, username: me.username }, 'Telegram account started');\n } catch (err) {\n const em = formatTelegramStartupError(err);\n const level = isTelegramUnauthorizedTokenError(err) ? 'error' : 'warn';\n log[level](\n {\n accountId: account.accountId,\n apiRootConfigured: !!account.apiRoot,\n unauthorized: isTelegramUnauthorizedTokenError(err),\n errorMessage: em,\n },\n `Telegram account not started: ${em}`,\n );\n this.accountManager.updateStatus({\n accountId: account.accountId,\n running: false,\n mode: 'stopped',\n lastError: em.slice(0, 400),\n });\n } finally {\n this.accountManager.markStartComplete(account.accountId);\n }\n }\n\n private attachRunnerExitHandler(_accountId: string, _runner: unknown): void {\n // Polling exit is handled by startTelegramPollingSession.onExit.\n }\n\n private setupMessageHandler(accountId: string, bot: Bot): void {\n const account = this.config.resolveAccount(this.cfg, accountId);\n\n const handleInboundMessage = async (ctx: Context) => {\n const text = ctx.message?.text ?? ctx.message?.caption ?? ctx.channelPost?.text ?? ctx.channelPost?.caption ?? '';\n const command = text.trim().split(' ')[0].split('@')[0].toLowerCase();\n\n if (command === '/models') {\n await this.commandHandler.handleModels(ctx);\n return;\n }\n if (command === '/start') {\n await this.commandHandler.handleStart(ctx);\n return;\n }\n if (command === '/cleanup') {\n await this.commandHandler.handleCleanup(ctx);\n return;\n }\n if (command === '/focus') {\n await handleTelegramFocusCommand({ ctx, accountId, config: this.cfg });\n return;\n }\n\n const message = ctx.message ?? ctx.channelPost;\n if (!message) return;\n\n await this.inboundCoalescer.enqueue({\n ctx,\n accountId,\n message,\n onReady: async (batch) => {\n for (const msg of batch.messages) {\n const batchCtx = batch.ctx;\n await this.debouncer.enqueue({\n ctx: { ...batchCtx, message: msg } as Context,\n accountId: batch.accountId,\n message: msg,\n });\n }\n },\n });\n };\n\n bot.on('message', async (ctx) => {\n try {\n await handleInboundMessage(ctx);\n } catch (err) {\n log.error({ accountId, err }, 'Message handler error');\n }\n });\n\n bot.on('channel_post', async (ctx) => {\n try {\n await handleInboundMessage(ctx);\n } catch (err) {\n log.error({ accountId, err }, 'Channel post handler error');\n }\n });\n\n bot.on('message_reaction', async (ctx) => {\n try {\n await handleTelegramMessageReaction({\n ctx,\n accountId,\n bus: this.bus,\n mode: account.reactionNotifications as 'off' | 'own' | 'all' | undefined,\n });\n } catch (err) {\n log.error({ accountId, err }, 'Message reaction handler error');\n }\n });\n\n bot.on('callback_query:data', async (ctx) => {\n try {\n await this.handleCallbackQuery(ctx, accountId);\n } catch (err) {\n log.error({ accountId, err }, 'Callback query handler error');\n await ctx.answerCallbackQuery('An error occurred').catch(() => {});\n }\n });\n }\n\n private async handleCallbackQuery(ctx: Context, _accountId: string): Promise<void> {\n const data = ctx.callbackQuery?.data;\n if (!data) return;\n\n if (data.startsWith('provider:')) {\n const providerId = data.substring('provider:'.length);\n await this.commandHandler.handleProviderSelect(ctx, providerId);\n return;\n }\n\n if (data.startsWith('model:')) {\n const modelId = data.substring('model:'.length);\n await this.commandHandler.handleModelSelect(ctx, modelId);\n return;\n }\n\n if (data === 'cancel') {\n await this.commandHandler.handleCancel(ctx);\n return;\n }\n\n if (data === 'providers') {\n await this.commandHandler.handleShowProviders(ctx);\n return;\n }\n\n if (data === 'cleanup:confirm') {\n await this.commandHandler.handleCleanupConfirm(ctx);\n return;\n }\n\n if (data.startsWith('clarify:')) {\n const rest = data.slice('clarify:'.length);\n const lastColon = rest.lastIndexOf(':');\n if (lastColon > 0) {\n const requestId = rest.slice(0, lastColon);\n const idx = Number.parseInt(rest.slice(lastColon + 1), 10);\n if (requestId && Number.isFinite(idx) && submitClarifyChoiceFromChannel(requestId, idx)) {\n await ctx.answerCallbackQuery();\n return;\n }\n }\n await ctx.answerCallbackQuery('No pending question');\n return;\n }\n\n if (data.startsWith('approval:approve:') || data.startsWith('approval:deny:')) {\n const approved = data.startsWith('approval:approve:');\n const approvalId = data.slice(approved ? 'approval:approve:'.length : 'approval:deny:'.length);\n const senderId = String(ctx.from?.id ?? '');\n if (\n !isTelegramExecApprovalApprover({\n cfg: this.cfg,\n accountId: _accountId,\n senderId,\n })\n ) {\n await ctx.answerCallbackQuery('Not authorized');\n return;\n }\n if (resolveTelegramApproval(approvalId, approved)) {\n await ctx.answerCallbackQuery(approved ? 'Approved' : 'Denied');\n } else {\n await ctx.answerCallbackQuery('Approval expired or already resolved');\n }\n return;\n }\n\n await ctx.answerCallbackQuery('Unknown action');\n }\n\n private async processMessages(items: TelegramMessageEvent[]): Promise<void> {\n if (items.length === 0) return;\n\n const tgSection = this.cfg.channels?.telegram as { enabled?: boolean } | undefined;\n if (!tgSection || tgSection.enabled !== true) {\n return;\n }\n\n const last = items[items.length - 1];\n const ctx = last.ctx;\n const accountId = last.accountId;\n if (!this.accountManager.getAccount(accountId)) {\n log.warn({ accountId }, 'Unknown account');\n return;\n }\n\n const account = this.config.resolveAccount(this.cfg, accountId);\n\n const isGroup = ctx.chat?.type === 'group' || ctx.chat?.type === 'supergroup';\n const senderId = ctx.from?.id?.toString() ?? '';\n const senderUsername = ctx.from?.username;\n const chatId = ctx.chat?.id?.toString() ?? '';\n telegramReplyTracker.reset(accountId, chatId);\n\n const securityCtx: ChannelSecurityContext = {\n accountId,\n chatId,\n senderId,\n senderName: senderUsername,\n isGroup,\n };\n\n const accessResult = this.security.checkAccess?.(securityCtx, account, this.cfg);\n\n if (!accessResult?.allowed) {\n if (!isGroup && accessResult?.reason === 'pairing-required') {\n const cid = ctx.chat?.id;\n const bot = cid != null ? this.accountManager.getBot(accountId) : undefined;\n if (bot && cid != null && senderId) {\n void issuePairingChallenge({\n channel: 'telegram',\n pairingFilePath: resolveStandardPairingPath('telegram', accountId),\n accountId,\n senderId,\n senderIdLine: `Your Telegram user id: ${senderId}`,\n sendPairingReply: async (text) => {\n await bot.api.sendMessage(cid, text);\n },\n onCreated: ({ code }) => {\n log.info({ accountId, senderId, code }, 'Telegram DM pairing code issued');\n },\n onReplyError: (err) => {\n log.warn({ err, accountId, chatId: String(cid) }, 'Telegram pairing reply failed');\n },\n });\n }\n return;\n }\n log.warn(\n {\n accountId,\n chatId,\n senderId,\n isGroup,\n reason: accessResult?.reason,\n dmPolicy: account.dmPolicy,\n groupPolicy: account.groupPolicy,\n },\n 'Telegram: message dropped by channel security (check dmPolicy/groupPolicy and allowFrom)',\n );\n return;\n }\n\n const bot = this.accountManager.getBot(accountId);\n const messageId = ctx.message?.message_id;\n const reactionLevel = (account as { reactionLevel?: string }).reactionLevel ?? 'ack';\n const ackEmoji = (account as { ackReaction?: string }).ackReaction ?? '👀';\n if (\n bot &&\n messageId &&\n reactionLevel !== 'off' &&\n ctx.chat?.id != null &&\n !ctx.channelPost\n ) {\n void sendTelegramAckReaction({\n bot,\n chatId: ctx.chat.id,\n messageId,\n emoji: ackEmoji,\n });\n }\n\n await this.inboundProcessor(ctx, accountId);\n }\n}\n\nexport const telegramPlugin = new TelegramChannelPlugin();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA4B4D;oBAqCF;;AAkB1D,MAAM,4BAA4B;;AAElC,MAAM,kCAAkC;AAExC,MAAM,MAAM,aAAa,iBAAiB;AAE1C,MAAM,yBAAyB,mBAAmB,WAAW;AAI7D,IAAa,wBAAb,MAAqF;CACnF,KAAc;CAEd,SAA2C,EACzC,gBAAgB,CAAC,oBAAoB,EACtC;CAED,OAAgB;EACd,IAAI,uBAAuB;EAC3B,OAAO,uBAAuB;EAC9B,gBAAgB;EAChB,UAAU;EACV,OAAO,uBAAuB;EAC9B,OAAO;EACP,8BAA8B;EAC/B;CAED,eAAwB,uBAAuB;CAE/C,WAA2C;EACzC,OAAO,EAAE,YAAY,0BAA0B,MAAM,YAAY;EACjE,UAAU,EAAE,gBAAgB,0BAA0B,SAAS,gBAAgB;EAChF;CAED,cAAuB,2BAA2B;CAElD,eAAwB;EACtB,QAAQ,EAAE;EACV,WAAW,QAAiB;GAC1B,MAAM,IAAI,qBAAqB,UAAU,IAAI;AAC7C,UAAO,EAAE,UAAU,EAAE,IAAI,MAAe,GAAG;IAAE,IAAI;IAAgB,QAAQ,CAAC,EAAE,MAAM,QAAQ;IAAE;;EAE/F;CAED,eAAoD,EAClD,MAAM,wBAAwB,IAAI;AAChC,SAAO,EAAE,QAAQ,gCAAgC,GAAG,EAAE;IAEzD;CAED,gBAAyB;CAEzB,UAAmB;CAEnB,SAAkB,EAChB,QAAQ,WAA4B,wBAAwB,OAAO,EACpE;CAED,UAAmB,6BAA6B,WAAW;CAE3D;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;;CAEA,6BAA0D;CAC1D,mBAA2B,gCAAgC;CA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BAAsB;KACzB,SAAS;KACT,iBAAiB,2BAA2B,YAAY,UAAU;KAClE;KACA;KACA,cAAc,0BAA0B;KACxC,kBAAkB,OAAO,SAAS;AAChC,YAAM,IAAI,IAAI,YAAY,KAAK,KAAK;;KAEtC,YAAY,EAAE,WAAW;AACvB,UAAI,KAAK;OAAE;OAAW;OAAU;OAAM,EAAE,kCAAkC;;KAE5E,eAAe,QAAQ;AACrB,UAAI,KAAK;OAAE;OAAK;OAAW,QAAQ,OAAO,IAAI;OAAE,EAAE,gCAAgC;;KAErF,CAAC;AAEJ;;AAEF,OAAI,KACF;IACE;IACA;IACA;IACA;IACA,QAAQ,cAAc;IACtB,UAAU,QAAQ;IAClB,aAAa,QAAQ;IACtB,EACD,2FACD;AACD;;EAGF,MAAM,MAAM,KAAK,eAAe,OAAO,UAAU;EACjD,MAAM,YAAY,IAAI,SAAS;EAC/B,MAAM,gBAAiB,QAAuC,iBAAiB;EAC/E,MAAM,WAAY,QAAqC,eAAe;AACtE,MACE,OACA,aACA,kBAAkB,SAClB,IAAI,MAAM,MAAM,QAChB,CAAC,IAAI,YAEA,yBAAwB;GAC3B;GACA,QAAQ,IAAI,KAAK;GACjB;GACA,OAAO;GACR,CAAC;AAGJ,QAAM,KAAK,iBAAiB,KAAK,UAAU;;;AAI/C,MAAa,iBAAiB,IAAI,uBAAuB"}
1
+ {"version":3,"file":"plugin.js","names":["sttTranscribe"],"sources":["../../../../extensions/telegram/src/plugin.ts"],"sourcesContent":["/**\n * Telegram Channel Plugin - Implementation based on ChannelPlugin interface\n *\n * This plugin integrates Telegram with the ChannelPlugin architecture.\n * It reuses components from this package's src tree where possible.\n */\n\nimport { isDeepStrictEqual } from 'node:util';\n\nimport { Bot, type Context } from 'grammy';\n\nimport type { Config } from '@xopcai/xopc/config/index.js';\nimport type {\n ChannelPlugin,\n ChannelPluginDefaults,\n ChannelPluginInitOptions,\n ChannelPluginReloadMeta,\n ChannelPluginSessionModelHooks,\n ChannelPluginStartOptions,\n ChannelOutboundAdapter,\n ChannelSecurityContext,\n ChannelGatewayAdapter,\n ChannelStreamingAdapter,\n ChannelCommandAdapter,\n} from '@xopcai/xopc/channels/plugin-types.js';\nimport { generateSessionKey } from '@xopcai/xopc/chat-commands/session-key.js';\nimport { submitClarifyChoiceFromChannel } from '@xopcai/xopc/gateway/clarify-runtime.js';\n\nimport { createLogger } from '@xopcai/xopc/utils/logger.js';\nimport { issuePairingChallenge, resolveStandardPairingPath } from '@xopcai/xopc/channels/pairing/index.js';\nimport { createStandardPairingAdapter } from '@xopcai/xopc/channels/pairing/pairing-store-adapter.js';\nimport { createTimeoutAbortSignal } from './timeout-abort.js';\nimport { createInboundDebouncer } from '@xopcai/xopc/infra/debounce.js';\nimport { getMimeType } from '@xopcai/xopc/channels/media.js';\nimport { transcribe as sttTranscribe, isSTTAvailable } from '@xopcai/xopc/voice/stt/index.js';\nimport type { STTConfig } from '@xopcai/xopc/voice/stt/types.js';\n\nimport { TelegramAccountManager } from './account-manager.js';\nimport { createOutboundSender } from './outbound-sender.js';\nimport { getWorkflowProgressBroker } from '@xopcai/xopc/agent/workflow/index.js';\nimport { createTelegramWorkflowProgressCapability } from './workflow-progress.js';\nimport { createTelegramCommandHandler } from './command-handler.js';\nimport { createInboundProcessor } from './inbound-processor.js';\nimport { TELEGRAM_CHANNEL_DEFAULTS } from './plugin-defaults.js';\nimport {\n createTelegramPluginAdapters,\n createTelegramSetupWizard,\n createTelegramOutboundSendMethods,\n telegramTextChunker,\n TELEGRAM_OUTBOUND_DEFAULTS,\n createTelegramInboundAccessControl,\n telegramDebouncerKeyPolicy,\n type TelegramMessageEvent,\n} from './adapters/index.js';\nimport {\n createTelegramGatewayAdapter,\n createTelegramStreamingAdapter,\n createTelegramCommandAdapter,\n} from './channel.js';\nimport type { TelegramResolvedAccount } from './adapters/index.js';\nimport type { ChannelCronDeliveryAdapter } from '@xopcai/xopc/channels/plugins/types.adapters.js';\nimport { normalizeTelegramDeliveryChatId } from './delivery-chat-id.js';\nimport { telegramOnboardAdapter } from './adapters/onboard-cli.js';\nimport { telegramGatewaySetupActions } from './adapters/gateway-setup.js';\nimport { TelegramConfigSchema } from './config-schema.js';\nimport { normalizeTelegramApiRoot } from './api-root.js';\nimport { resolveTelegramBotToken } from './token-resolver.js';\nimport { formatTelegramStartupError, isTelegramUnauthorizedTokenError } from './startup-errors.js';\nimport { startTelegramPollingSession } from './polling-session.js';\nimport { createProxyFetch } from './proxy-fetch.js';\nimport { runTelegramDoctorChecks } from './doctor.js';\nimport { telegramReplyTracker } from './reply-params.js';\nimport { createTelegramInboundCoalescer } from './inbound-coalescer.js';\nimport { sendTelegramAckReaction, handleTelegramMessageReaction } from './reactions.js';\nimport { handleTelegramChannelAction, bindTelegramMessageActionAccountManager } from './actions/message-actions.js';\nimport { registerChannelExecApprovalHandler } from '@xopcai/xopc/channels/exec-approval-runtime.js';\nimport { createTelegramExecApprovalHandler } from './exec-approval-handler.js';\nimport { handleTelegramFocusCommand } from './focus-handler.js';\nimport { resolveTelegramApproval } from './approval-store.js';\nimport { isTelegramExecApprovalApprover } from './exec-approvals.js';\n\n/** Bound initial `getMe` so a bad `apiRoot` or unreachable API cannot block gateway startup for minutes. */\nconst TELEGRAM_GETME_TIMEOUT_MS = 20_000;\n/** grammY per-request ceiling; must exceed long-poll `getUpdates` (~30s) but avoid multi-minute hangs on bad hosts. */\nconst TELEGRAM_CLIENT_TIMEOUT_SECONDS = 75;\n\nconst log = createLogger('TelegramPlugin');\n\nfunction contextWithMessage(ctx: Context, message: import('@grammyjs/types').Message): Context {\n if (ctx.message === message) return ctx;\n\n const clone = Object.create(Object.getPrototypeOf(ctx)) as Context;\n Object.defineProperties(clone, Object.getOwnPropertyDescriptors(ctx));\n Object.defineProperty(clone, 'message', {\n configurable: true,\n enumerable: true,\n value: message,\n writable: true,\n });\n return clone;\n}\n\nexport type { TelegramResolvedAccount as TelegramAccount } from './channel.js';\n\nexport class TelegramChannelPlugin implements ChannelPlugin<TelegramResolvedAccount> {\n readonly id = 'telegram' as const;\n\n readonly reload: ChannelPluginReloadMeta = {\n configPrefixes: ['channels.telegram'],\n };\n\n readonly meta = {\n id: 'telegram',\n label: 'Telegram',\n selectionLabel: 'Telegram Bot',\n docsPath: '/channels/telegram',\n blurb: 'Telegram Bot API channel',\n order: 0,\n deferConnectUntilAfterListen: true,\n } as const;\n\n readonly capabilities = {\n chatTypes: ['direct', 'group', 'channel', 'thread'] as Array<'direct' | 'group' | 'channel' | 'thread'>,\n reactions: true,\n threads: true,\n media: true,\n polls: false,\n nativeCommands: true,\n blockStreaming: true,\n } as const;\n\n readonly defaults: ChannelPluginDefaults = {\n queue: { debounceMs: TELEGRAM_CHANNEL_DEFAULTS.queue.debounceMs },\n outbound: { textChunkLimit: TELEGRAM_CHANNEL_DEFAULTS.outbound.textChunkLimit },\n };\n\n readonly setupWizard = createTelegramSetupWizard();\n\n readonly configSchema = {\n schema: {},\n validate: (raw: unknown) => {\n const r = TelegramConfigSchema.safeParse(raw);\n return r.success ? { ok: true as const } : { ok: false as const, errors: [r.error.message] };\n },\n };\n\n readonly cronDelivery: ChannelCronDeliveryAdapter = {\n async normalizeDeliveryTarget(to) {\n return { chatId: normalizeTelegramDeliveryChatId(to) };\n },\n };\n\n readonly onboard = telegramOnboardAdapter;\n\n readonly runtimeActions = telegramGatewaySetupActions;\n\n readonly doctor = {\n check: (params: { cfg: Config }) => runTelegramDoctorChecks(params),\n };\n\n readonly pairing = createStandardPairingAdapter('telegram');\n\n private bus!: NonNullable<ChannelPluginInitOptions['bus']>;\n private cfg!: NonNullable<ChannelPluginInitOptions['config']>;\n private debouncer!: ReturnType<typeof createInboundDebouncer<TelegramMessageEvent>>;\n\n private accountManager!: TelegramAccountManager;\n private outboundSender!: ReturnType<typeof createOutboundSender>;\n private commandHandler!: ReturnType<typeof createTelegramCommandHandler>;\n private inboundProcessor!: ReturnType<typeof createInboundProcessor>;\n private sessionModelHooks?: ChannelPluginSessionModelHooks;\n /** Unregister fn for the workflow-progress capability registered against the global broker. */\n private workflowProgressUnregister: (() => void) | null = null;\n private inboundCoalescer = createTelegramInboundCoalescer();\n private execApprovalUnregister: (() => void) | null = null;\n\n readonly actions = {\n handleAction: handleTelegramChannelAction,\n };\n\n config!: import('@xopcai/xopc/channels/plugin-types.js').ChannelConfigAdapter<TelegramResolvedAccount>;\n security!: import('@xopcai/xopc/channels/plugin-types.js').ChannelSecurityAdapter<TelegramResolvedAccount>;\n status!: import('@xopcai/xopc/channels/plugin-types.js').ChannelStatusAdapter<TelegramResolvedAccount>;\n\n outbound!: ChannelOutboundAdapter;\n\n gateway!: ChannelGatewayAdapter<TelegramResolvedAccount>;\n\n streaming!: ChannelStreamingAdapter;\n\n commands!: ChannelCommandAdapter;\n\n async init(options: ChannelPluginInitOptions): Promise<void> {\n this.bus = options.bus;\n this.cfg = options.config;\n this.sessionModelHooks = options.sessionModel;\n\n this.accountManager = new TelegramAccountManager();\n this.loadAccounts();\n this.bindOutboundComponents();\n bindTelegramMessageActionAccountManager(this.accountManager);\n this.execApprovalUnregister?.();\n this.execApprovalUnregister = registerChannelExecApprovalHandler(\n 'telegram',\n createTelegramExecApprovalHandler({\n accountManager: this.accountManager,\n getConfig: () => this.cfg,\n }),\n );\n\n // Workflow progress is fed from the agent-side broker (subscribes to\n // tool_execution_update for the `workflow` tool); the capability turns\n // each snapshot into an edit-in-place Telegram message. Registration is\n // idempotent — the broker replaces a prior cap with the same channelId.\n this.workflowProgressUnregister = getWorkflowProgressBroker().registerChannel(\n createTelegramWorkflowProgressCapability(this.accountManager),\n );\n\n const debounceMs =\n this.defaults.queue?.debounceMs ?? TELEGRAM_CHANNEL_DEFAULTS.queue.debounceMs;\n const keyPolicy = telegramDebouncerKeyPolicy();\n this.debouncer = createInboundDebouncer<TelegramMessageEvent>({\n debounceMs,\n ...keyPolicy,\n onFlush: async (items) => {\n await this.processMessages(items);\n },\n onError: (err, items) => {\n log.error({ err, count: items.length }, 'Debounced message processing failed');\n },\n });\n\n log.debug('Telegram plugin initialized');\n }\n\n private bindOutboundComponents(): void {\n this.outboundSender = createOutboundSender({\n accountManager: this.accountManager,\n config: this.cfg,\n });\n const sm = this.sessionModelHooks;\n this.commandHandler = createTelegramCommandHandler({\n bus: this.bus,\n config: this.cfg,\n accountManager: this.accountManager,\n getSessionModel: (sessionKey) => sm?.getModelForSession(sessionKey),\n setSessionModel: (sessionKey, modelId) => {\n if (!sm) return;\n void sm.switchModelForSession(sessionKey, modelId);\n },\n });\n const adapters = createTelegramPluginAdapters({\n accountManager: this.accountManager,\n });\n this.config = adapters.config;\n this.security = adapters.security;\n this.status = adapters.status;\n\n const accessControl = createTelegramInboundAccessControl();\n\n this.inboundProcessor = createInboundProcessor({\n bus: this.bus,\n config: this.cfg,\n accountManager: this.accountManager,\n accessControl,\n sessionKeyService: {\n generateSessionKey: (opts) =>\n generateSessionKey({\n source: 'telegram',\n chatId: opts.chatId,\n senderId: opts.senderId,\n isGroup: opts.isGroup,\n threadId: opts.threadId,\n accountId: opts.accountId,\n }),\n },\n sttService: {\n transcribe: async (buffer, config, options) => {\n const result = await sttTranscribe(buffer, config as STTConfig, options);\n return { text: result.text };\n },\n isSTTAvailable: (config) => isSTTAvailable(config as STTConfig | undefined),\n },\n mediaUtils: { getMimeType },\n });\n\n const sends = createTelegramOutboundSendMethods(\n (opts) => this.outboundSender.send(opts),\n this.accountManager,\n );\n this.outbound = {\n deliveryMode: 'direct',\n chunker: telegramTextChunker,\n chunkerMode: 'text',\n textChunkLimit: TELEGRAM_OUTBOUND_DEFAULTS.textChunkLimit,\n ...sends,\n };\n\n this.gateway = createTelegramGatewayAdapter({\n startAccount: (account) => this.startAccount(account),\n stopAccount: (accountId) => this.accountManager.stopRunner(accountId),\n });\n this.streaming = createTelegramStreamingAdapter({ accountManager: this.accountManager });\n this.commands = createTelegramCommandAdapter();\n }\n\n async onConfigUpdated(cfg: Config): Promise<void> {\n const prevTg = this.cfg.channels?.telegram as unknown;\n const nextTg = cfg.channels?.telegram as { enabled?: boolean } | undefined;\n // Match Weixin: only `enabled === true` keeps inbound (polling). Stops immediately on disable / missing section.\n const channelOff = !nextTg || nextTg.enabled !== true;\n if (channelOff) {\n this.cfg = cfg;\n await this.stop();\n this.accountManager.reset();\n this.bindOutboundComponents();\n return;\n }\n\n if (isDeepStrictEqual(prevTg, nextTg)) {\n this.cfg = cfg;\n this.bindOutboundComponents();\n // Config unchanged but runners may be stopped (e.g. disable → enable with identical JSON shape after normalize).\n if (!this.channelIsRunning(cfg)) {\n await this.reapplyFromConfig(cfg);\n }\n return;\n }\n await this.reapplyFromConfig(cfg);\n }\n\n private async reapplyFromConfig(cfg: Config): Promise<void> {\n this.cfg = cfg;\n await this.stop();\n this.accountManager.reset();\n const telegramCfg = cfg.channels?.telegram as Record<string, unknown> | undefined;\n const channelOn = telegramCfg != null && telegramCfg.enabled === true;\n if (!channelOn) {\n this.bindOutboundComponents();\n return;\n }\n this.loadAccounts();\n this.bindOutboundComponents();\n await this.start();\n }\n\n private loadAccounts(): void {\n const telegramCfg = this.cfg.channels?.telegram as Record<string, unknown> | undefined;\n if (!telegramCfg) return;\n if (telegramCfg.enabled !== true) {\n return;\n }\n\n const accounts = telegramCfg.accounts as Record<string, Record<string, unknown>> | undefined;\n if (!accounts || Object.keys(accounts).length === 0) return;\n\n const channelApiRoot =\n typeof telegramCfg.apiRoot === 'string'\n ? normalizeTelegramApiRoot(telegramCfg.apiRoot)\n : undefined;\n const channelProxy =\n typeof telegramCfg.proxy === 'string' && telegramCfg.proxy.trim()\n ? telegramCfg.proxy.trim()\n : undefined;\n const channelReplyToMode = telegramCfg.replyToMode as TelegramResolvedAccount['replyToMode'];\n const channelStreaming = telegramCfg.streaming as TelegramResolvedAccount['streaming'];\n\n const tokenOwners = new Map<string, string[]>();\n\n for (const [id, account] of Object.entries(accounts)) {\n const { token, source } = resolveTelegramBotToken({\n botToken: typeof account.botToken === 'string' ? account.botToken : undefined,\n tokenFile: typeof account.tokenFile === 'string' ? account.tokenFile : undefined,\n });\n if (token) {\n const owners = tokenOwners.get(token) ?? [];\n owners.push(id);\n tokenOwners.set(token, owners);\n }\n\n const accApiRoot =\n typeof account.apiRoot === 'string'\n ? normalizeTelegramApiRoot(account.apiRoot)\n : undefined;\n const accProxy =\n typeof account.proxy === 'string' && account.proxy.trim() ? account.proxy.trim() : undefined;\n\n this.accountManager.registerAccount({\n ...account,\n accountId: id,\n botToken: token,\n tokenFile: typeof account.tokenFile === 'string' ? account.tokenFile : undefined,\n tokenSource: source,\n ...(accApiRoot || channelApiRoot ? { apiRoot: accApiRoot || channelApiRoot } : {}),\n ...(accProxy || channelProxy ? { proxy: accProxy || channelProxy } : {}),\n replyToMode:\n (account.replyToMode as TelegramResolvedAccount['replyToMode']) ?? channelReplyToMode,\n streaming:\n (account.streaming as TelegramResolvedAccount['streaming']) ?? channelStreaming,\n } as import('@xopcai/xopc/channels/channel-domain.js').TelegramAccountConfig);\n }\n\n for (const [token, owners] of tokenOwners) {\n if (owners.length > 1) {\n log.error(\n { accountIds: owners, tokenPreview: `${token.slice(0, 8)}…` },\n `Duplicate Telegram bot token across accounts: ${owners.join(', ')}`,\n );\n }\n }\n }\n\n channelIsRunning(cfg: Config): boolean {\n return this.accountManager.getAllAccounts().some(\n (a) => a.enabled !== false && !!a.botToken && this.accountManager.isRunning(a.accountId),\n );\n }\n\n async start(options?: ChannelPluginStartOptions): Promise<void> {\n const section = this.cfg.channels?.telegram as { enabled?: boolean } | undefined;\n if (!section || section.enabled !== true) {\n return;\n }\n\n const accountIds = options?.accountId\n ? [options.accountId]\n : this.config.listAccountIds(this.cfg);\n\n for (const accountId of accountIds) {\n const account = this.config.resolveAccount(this.cfg, accountId);\n if (!account.enabled || !account.botToken) continue;\n await this.startAccount(account);\n }\n }\n\n async stop(accountId?: string): Promise<void> {\n if (!this.config) return;\n const ids = accountId ? [accountId] : this.config.listAccountIds(this.cfg);\n for (const id of ids) {\n await this.accountManager.stopRunner(id);\n log.info({ accountId: id }, 'Telegram account stopped');\n }\n // Only unregister the broker capability on a full stop (no specific\n // account). A per-account stop still leaves other accounts capable of\n // sending progress through the same registered cap.\n if (!accountId) {\n this.workflowProgressUnregister?.();\n this.workflowProgressUnregister = null;\n this.execApprovalUnregister?.();\n this.execApprovalUnregister = null;\n }\n }\n\n private async startAccount(account: TelegramResolvedAccount): Promise<void> {\n if (this.accountManager.isRunning(account.accountId)) return;\n\n const resolved = resolveTelegramBotToken({\n botToken: account.botToken,\n tokenFile: account.tokenFile,\n });\n if (!resolved.token) return;\n\n const duplicateAccounts = this.accountManager\n .getAllAccounts()\n .filter((a) => {\n const t = resolveTelegramBotToken({\n botToken: a.botToken,\n tokenFile: a.tokenFile,\n }).token;\n return t === resolved.token && a.accountId !== account.accountId;\n })\n .map((a) => a.accountId);\n if (duplicateAccounts.length > 0) {\n const em = `Duplicate bot token shared with account(s): ${duplicateAccounts.join(', ')}`;\n log.error({ accountId: account.accountId, duplicateAccounts }, em);\n this.accountManager.updateStatus({\n accountId: account.accountId,\n running: false,\n mode: 'stopped',\n lastError: em,\n });\n return;\n }\n\n this.accountManager.markStarting(account.accountId);\n\n try {\n const client: {\n timeoutSeconds: number;\n apiRoot?: string;\n fetch?: typeof fetch;\n } = {\n timeoutSeconds: TELEGRAM_CLIENT_TIMEOUT_SECONDS,\n ...(account.apiRoot ? { apiRoot: account.apiRoot } : {}),\n ...(account.proxy ? { fetch: createProxyFetch(account.proxy) } : {}),\n };\n const bot = new Bot(resolved.token, { client });\n const getMeSignal = createTimeoutAbortSignal(TELEGRAM_GETME_TIMEOUT_MS);\n let me;\n try {\n me = await bot.api.getMe(getMeSignal.signal);\n } finally {\n getMeSignal.dispose();\n }\n\n this.accountManager.registerBot(account.accountId, bot);\n this.accountManager.setBotUsername(account.accountId, me.username);\n this.setupMessageHandler(account.accountId, bot);\n\n const session = startTelegramPollingSession({\n accountId: account.accountId,\n botToken: resolved.token,\n bot,\n stallThresholdMs: account.pollingStallThresholdMs,\n onExit: () => {\n void this.accountManager.stopRunner(account.accountId);\n },\n });\n this.accountManager.registerPollingSession(account.accountId, session);\n this.accountManager.updateStatus({\n accountId: account.accountId,\n running: true,\n mode: 'polling',\n });\n\n log.info({ accountId: account.accountId, username: me.username }, 'Telegram account started');\n } catch (err) {\n const em = formatTelegramStartupError(err);\n const level = isTelegramUnauthorizedTokenError(err) ? 'error' : 'warn';\n log[level](\n {\n accountId: account.accountId,\n apiRootConfigured: !!account.apiRoot,\n unauthorized: isTelegramUnauthorizedTokenError(err),\n errorMessage: em,\n },\n `Telegram account not started: ${em}`,\n );\n this.accountManager.updateStatus({\n accountId: account.accountId,\n running: false,\n mode: 'stopped',\n lastError: em.slice(0, 400),\n });\n } finally {\n this.accountManager.markStartComplete(account.accountId);\n }\n }\n\n private attachRunnerExitHandler(_accountId: string, _runner: unknown): void {\n // Polling exit is handled by startTelegramPollingSession.onExit.\n }\n\n private setupMessageHandler(accountId: string, bot: Bot): void {\n const account = this.config.resolveAccount(this.cfg, accountId);\n\n const handleInboundMessage = async (ctx: Context) => {\n const text = ctx.message?.text ?? ctx.message?.caption ?? ctx.channelPost?.text ?? ctx.channelPost?.caption ?? '';\n const command = text.trim().split(' ')[0].split('@')[0].toLowerCase();\n\n if (command === '/models') {\n await this.commandHandler.handleModels(ctx);\n return;\n }\n if (command === '/start') {\n await this.commandHandler.handleStart(ctx);\n return;\n }\n if (command === '/cleanup') {\n await this.commandHandler.handleCleanup(ctx);\n return;\n }\n if (command === '/focus') {\n await handleTelegramFocusCommand({ ctx, accountId, config: this.cfg });\n return;\n }\n\n const message = ctx.message ?? ctx.channelPost;\n if (!message) return;\n\n await this.inboundCoalescer.enqueue({\n ctx,\n accountId,\n message,\n onReady: async (batch) => {\n for (const msg of batch.messages) {\n const batchCtx = batch.ctx;\n await this.debouncer.enqueue({\n ctx: contextWithMessage(batchCtx, msg),\n accountId: batch.accountId,\n message: msg,\n });\n }\n },\n });\n };\n\n bot.on('message', async (ctx) => {\n try {\n await handleInboundMessage(ctx);\n } catch (err) {\n log.error({ accountId, err }, 'Message handler error');\n }\n });\n\n bot.on('channel_post', async (ctx) => {\n try {\n await handleInboundMessage(ctx);\n } catch (err) {\n log.error({ accountId, err }, 'Channel post handler error');\n }\n });\n\n bot.on('message_reaction', async (ctx) => {\n try {\n await handleTelegramMessageReaction({\n ctx,\n accountId,\n bus: this.bus,\n mode: account.reactionNotifications as 'off' | 'own' | 'all' | undefined,\n });\n } catch (err) {\n log.error({ accountId, err }, 'Message reaction handler error');\n }\n });\n\n bot.on('callback_query:data', async (ctx) => {\n try {\n await this.handleCallbackQuery(ctx, accountId);\n } catch (err) {\n log.error({ accountId, err }, 'Callback query handler error');\n await ctx.answerCallbackQuery('An error occurred').catch(() => {});\n }\n });\n }\n\n private async handleCallbackQuery(ctx: Context, _accountId: string): Promise<void> {\n const data = ctx.callbackQuery?.data;\n if (!data) return;\n\n if (data.startsWith('provider:')) {\n const providerId = data.substring('provider:'.length);\n await this.commandHandler.handleProviderSelect(ctx, providerId);\n return;\n }\n\n if (data.startsWith('model:')) {\n const modelId = data.substring('model:'.length);\n await this.commandHandler.handleModelSelect(ctx, modelId);\n return;\n }\n\n if (data === 'cancel') {\n await this.commandHandler.handleCancel(ctx);\n return;\n }\n\n if (data === 'providers') {\n await this.commandHandler.handleShowProviders(ctx);\n return;\n }\n\n if (data === 'cleanup:confirm') {\n await this.commandHandler.handleCleanupConfirm(ctx);\n return;\n }\n\n if (data.startsWith('clarify:')) {\n const rest = data.slice('clarify:'.length);\n const lastColon = rest.lastIndexOf(':');\n if (lastColon > 0) {\n const requestId = rest.slice(0, lastColon);\n const idx = Number.parseInt(rest.slice(lastColon + 1), 10);\n if (requestId && Number.isFinite(idx) && submitClarifyChoiceFromChannel(requestId, idx)) {\n await ctx.answerCallbackQuery();\n return;\n }\n }\n await ctx.answerCallbackQuery('No pending question');\n return;\n }\n\n if (data.startsWith('approval:approve:') || data.startsWith('approval:deny:')) {\n const approved = data.startsWith('approval:approve:');\n const approvalId = data.slice(approved ? 'approval:approve:'.length : 'approval:deny:'.length);\n const senderId = String(ctx.from?.id ?? '');\n if (\n !isTelegramExecApprovalApprover({\n cfg: this.cfg,\n accountId: _accountId,\n senderId,\n })\n ) {\n await ctx.answerCallbackQuery('Not authorized');\n return;\n }\n if (resolveTelegramApproval(approvalId, approved)) {\n await ctx.answerCallbackQuery(approved ? 'Approved' : 'Denied');\n } else {\n await ctx.answerCallbackQuery('Approval expired or already resolved');\n }\n return;\n }\n\n await ctx.answerCallbackQuery('Unknown action');\n }\n\n private async processMessages(items: TelegramMessageEvent[]): Promise<void> {\n if (items.length === 0) return;\n\n const tgSection = this.cfg.channels?.telegram as { enabled?: boolean } | undefined;\n if (!tgSection || tgSection.enabled !== true) {\n return;\n }\n\n const last = items[items.length - 1];\n const ctx = last.ctx;\n const accountId = last.accountId;\n if (!this.accountManager.getAccount(accountId)) {\n log.warn({ accountId }, 'Unknown account');\n return;\n }\n\n const account = this.config.resolveAccount(this.cfg, accountId);\n\n const isGroup = ctx.chat?.type === 'group' || ctx.chat?.type === 'supergroup';\n const senderId = ctx.from?.id?.toString() ?? '';\n const senderUsername = ctx.from?.username;\n const chatId = ctx.chat?.id?.toString() ?? '';\n telegramReplyTracker.reset(accountId, chatId);\n\n const securityCtx: ChannelSecurityContext = {\n accountId,\n chatId,\n senderId,\n senderName: senderUsername,\n isGroup,\n };\n\n const accessResult = this.security.checkAccess?.(securityCtx, account, this.cfg);\n\n if (!accessResult?.allowed) {\n if (!isGroup && accessResult?.reason === 'pairing-required') {\n const cid = ctx.chat?.id;\n const bot = cid != null ? this.accountManager.getBot(accountId) : undefined;\n if (bot && cid != null && senderId) {\n void issuePairingChallenge({\n channel: 'telegram',\n pairingFilePath: resolveStandardPairingPath('telegram', accountId),\n accountId,\n senderId,\n senderIdLine: `Your Telegram user id: ${senderId}`,\n sendPairingReply: async (text) => {\n await bot.api.sendMessage(cid, text);\n },\n onCreated: ({ code }) => {\n log.info({ accountId, senderId, code }, 'Telegram DM pairing code issued');\n },\n onReplyError: (err) => {\n log.warn({ err, accountId, chatId: String(cid) }, 'Telegram pairing reply failed');\n },\n });\n }\n return;\n }\n log.warn(\n {\n accountId,\n chatId,\n senderId,\n isGroup,\n reason: accessResult?.reason,\n dmPolicy: account.dmPolicy,\n groupPolicy: account.groupPolicy,\n },\n 'Telegram: message dropped by channel security (check dmPolicy/groupPolicy and allowFrom)',\n );\n return;\n }\n\n const bot = this.accountManager.getBot(accountId);\n const messageId = ctx.message?.message_id;\n const reactionLevel = (account as { reactionLevel?: string }).reactionLevel ?? 'ack';\n const ackEmoji = (account as { ackReaction?: string }).ackReaction ?? '👀';\n if (\n bot &&\n messageId &&\n reactionLevel !== 'off' &&\n ctx.chat?.id != null &&\n !ctx.channelPost\n ) {\n void sendTelegramAckReaction({\n bot,\n chatId: ctx.chat.id,\n messageId,\n emoji: ackEmoji,\n });\n }\n\n await this.inboundProcessor(ctx, accountId);\n }\n}\n\nexport const telegramPlugin = new TelegramChannelPlugin();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA4B4D;oBAoCF;;AAkB1D,MAAM,4BAA4B;;AAElC,MAAM,kCAAkC;AAExC,MAAM,MAAM,aAAa,iBAAiB;AAE1C,SAAS,mBAAmB,KAAc,SAAqD;AAC7F,KAAI,IAAI,YAAY,QAAS,QAAO;CAEpC,MAAM,QAAQ,OAAO,OAAO,OAAO,eAAe,IAAI,CAAC;AACvD,QAAO,iBAAiB,OAAO,OAAO,0BAA0B,IAAI,CAAC;AACrE,QAAO,eAAe,OAAO,WAAW;EACtC,cAAc;EACd,YAAY;EACZ,OAAO;EACP,UAAU;EACX,CAAC;AACF,QAAO;;AAKT,IAAa,wBAAb,MAAqF;CACnF,KAAc;CAEd,SAA2C,EACzC,gBAAgB,CAAC,oBAAoB,EACtC;CAED,OAAgB;EACd,IAAI;EACJ,OAAO;EACP,gBAAgB;EAChB,UAAU;EACV,OAAO;EACP,OAAO;EACP,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AGF,MAAM,MAAM,KAAK,eAAe,OAAO,UAAU;EACjD,MAAM,YAAY,IAAI,SAAS;EAC/B,MAAM,gBAAiB,QAAuC,iBAAiB;EAC/E,MAAM,WAAY,QAAqC,eAAe;AACtE,MACE,OACA,aACA,kBAAkB,SAClB,IAAI,MAAM,MAAM,QAChB,CAAC,IAAI,YAEA,yBAAwB;GAC3B;GACA,QAAQ,IAAI,KAAK;GACjB;GACA,OAAO;GACR,CAAC;AAGJ,QAAM,KAAK,iBAAiB,KAAK,UAAU;;;AAI/C,MAAa,iBAAiB,IAAI,uBAAuB"}
@@ -1,12 +1,29 @@
1
1
  import { ProxyAgent, fetch } from "undici";
2
2
  //#region extensions/telegram/src/proxy-fetch.ts
3
+ function toNativeAbortSignal(signal) {
4
+ if (!signal) return void 0;
5
+ if (signal instanceof AbortSignal) return signal;
6
+ const maybeSignal = signal;
7
+ if (typeof maybeSignal.addEventListener !== "function") return void 0;
8
+ const controller = new AbortController();
9
+ if (maybeSignal.aborted) {
10
+ controller.abort(maybeSignal.reason);
11
+ return controller.signal;
12
+ }
13
+ maybeSignal.addEventListener("abort", () => controller.abort(maybeSignal.reason), { once: true });
14
+ return controller.signal;
15
+ }
3
16
  /** Build a fetch compatible with grammY client when an HTTP proxy is configured. */
4
17
  function createProxyFetch(proxyUrl) {
5
- const agent = new ProxyAgent(proxyUrl);
6
- return ((input, init) => fetch(input, {
7
- ...init,
8
- dispatcher: agent
9
- }));
18
+ const dispatcher = new ProxyAgent(proxyUrl);
19
+ return ((input, init) => {
20
+ const { agent: _agent, compress: _compress, signal, ...rest } = init ?? {};
21
+ return fetch(input, {
22
+ ...rest,
23
+ signal: toNativeAbortSignal(signal),
24
+ dispatcher
25
+ });
26
+ });
10
27
  }
11
28
  //#endregion
12
29
  export { createProxyFetch };
@@ -1 +1 @@
1
- {"version":3,"file":"proxy-fetch.js","names":["undiciFetch"],"sources":["../../../../extensions/telegram/src/proxy-fetch.ts"],"sourcesContent":["import { ProxyAgent, fetch as undiciFetch } from 'undici';\n\n/** Build a fetch compatible with grammY client when an HTTP proxy is configured. */\nexport function createProxyFetch(proxyUrl: string): typeof fetch {\n const agent = new ProxyAgent(proxyUrl);\n return ((input: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) =>\n undiciFetch(input as string, {\n ...(init as Record<string, unknown>),\n dispatcher: agent,\n }) as unknown as Promise<Response>) as typeof fetch;\n}\n"],"mappings":";;;AAGA,SAAgB,iBAAiB,UAAgC;CAC/D,MAAM,QAAQ,IAAI,WAAW,SAAS;AACtC,UAAS,OAAoC,SAC3CA,MAAY,OAAiB;EAC3B,GAAI;EACJ,YAAY;EACb,CAAC"}
1
+ {"version":3,"file":"proxy-fetch.js","names":["undiciFetch"],"sources":["../../../../extensions/telegram/src/proxy-fetch.ts"],"sourcesContent":["import { ProxyAgent, fetch as undiciFetch } from 'undici';\n\nfunction toNativeAbortSignal(signal: unknown): AbortSignal | undefined {\n if (!signal) return undefined;\n if (signal instanceof AbortSignal) return signal;\n\n const maybeSignal = signal as {\n aborted?: boolean;\n reason?: unknown;\n addEventListener?: (type: 'abort', listener: () => void, opts?: { once?: boolean }) => void;\n };\n if (typeof maybeSignal.addEventListener !== 'function') return undefined;\n\n const controller = new AbortController();\n if (maybeSignal.aborted) {\n controller.abort(maybeSignal.reason);\n return controller.signal;\n }\n maybeSignal.addEventListener('abort', () => controller.abort(maybeSignal.reason), { once: true });\n return controller.signal;\n}\n\n/** Build a fetch compatible with grammY client when an HTTP proxy is configured. */\nexport function createProxyFetch(proxyUrl: string): typeof fetch {\n const dispatcher = new ProxyAgent(proxyUrl);\n return ((input: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) => {\n const { agent: _agent, compress: _compress, signal, ...rest } = (init ?? {}) as Record<string, unknown>;\n return undiciFetch(input as string, {\n ...rest,\n signal: toNativeAbortSignal(signal),\n dispatcher,\n }) as unknown as Promise<Response>;\n }) as typeof fetch;\n}\n"],"mappings":";;AAEA,SAAS,oBAAoB,QAA0C;AACrE,KAAI,CAAC,OAAQ,QAAO,KAAA;AACpB,KAAI,kBAAkB,YAAa,QAAO;CAE1C,MAAM,cAAc;AAKpB,KAAI,OAAO,YAAY,qBAAqB,WAAY,QAAO,KAAA;CAE/D,MAAM,aAAa,IAAI,iBAAiB;AACxC,KAAI,YAAY,SAAS;AACvB,aAAW,MAAM,YAAY,OAAO;AACpC,SAAO,WAAW;;AAEpB,aAAY,iBAAiB,eAAe,WAAW,MAAM,YAAY,OAAO,EAAE,EAAE,MAAM,MAAM,CAAC;AACjG,QAAO,WAAW;;;AAIpB,SAAgB,iBAAiB,UAAgC;CAC/D,MAAM,aAAa,IAAI,WAAW,SAAS;AAC3C,UAAS,OAAoC,SAAuC;EAClF,MAAM,EAAE,OAAO,QAAQ,UAAU,WAAW,QAAQ,GAAG,SAAU,QAAQ,EAAE;AAC3E,SAAOA,MAAY,OAAiB;GAClC,GAAG;GACH,QAAQ,oBAAoB,OAAO;GACnC;GACD,CAAC"}