@fased/fased 0.1.41 → 0.1.43

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 (2353) hide show
  1. package/dist/brand.js +1 -1
  2. package/dist/build-info.json +3 -3
  3. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  4. package/dist/cli/daemon-cli/restart-health.js +49 -13
  5. package/dist/cli/plugins-cli.js +6 -103
  6. package/dist/cli/plugins-doctor-cli.js +45 -0
  7. package/dist/cli/plugins-info-cli.js +50 -0
  8. package/dist/cli/plugins-status-cli.js +4 -0
  9. package/dist/cli/program/routes.js +38 -0
  10. package/dist/cli/update-cli/shared.js +1 -29
  11. package/dist/cli/update-cli/update-command.js +87 -28
  12. package/dist/config/legacy.migrations.part-3.js +25 -0
  13. package/dist/gateway/server-plugins.js +12 -0
  14. package/dist/infra/hosted-runtime-artifact.js +40 -1
  15. package/dist/infra/update-global.js +1 -0
  16. package/dist/infra/update-runner.js +318 -38
  17. package/dist/light-plugin-doctor.js +1 -0
  18. package/dist/light-plugin-info.js +2 -0
  19. package/dist/light-update-precheck.js +1 -0
  20. package/dist/light-update-status.js +12 -0
  21. package/dist/plugin-sdk/account-id.d.ts +2 -1
  22. package/dist/plugin-sdk/account-id.js +1 -32
  23. package/dist/plugin-sdk/accounts-Bz_2QZSt.js +305 -0
  24. package/dist/plugin-sdk/accounts-CuqIKU8X.js +84 -0
  25. package/dist/plugin-sdk/accounts-RHZyaB73.js +63 -0
  26. package/dist/plugin-sdk/actions-CysoQjk1.js +150 -0
  27. package/dist/plugin-sdk/active-listener-C5ALSs7Y.js +37 -0
  28. package/dist/plugin-sdk/agent-scope-BbgPlhtw.js +1372 -0
  29. package/dist/plugin-sdk/allow-list-yqasgPpz.js +479 -0
  30. package/dist/plugin-sdk/audio-preflight-CzG6BjAn.js +107 -0
  31. package/dist/plugin-sdk/audit-BFnu5TVB.js +90 -0
  32. package/dist/plugin-sdk/blocks-input-DdQwSVtP.js +30 -0
  33. package/dist/plugin-sdk/channel-access-BiWxa3LR.js +68 -0
  34. package/dist/plugin-sdk/channel-access-configure-gJvqbbXB.js +28 -0
  35. package/dist/plugin-sdk/channel-adapters.discord-g8Do3f5N.js +35 -0
  36. package/dist/plugin-sdk/channel-core-CMPoGCik.js +1 -0
  37. package/dist/plugin-sdk/channel-plugin-common.d.ts +5 -1
  38. package/dist/plugin-sdk/channel-plugin-common.js +18 -1014
  39. package/dist/plugin-sdk/chat-type-CK5stkc4.d.ts +4 -0
  40. package/dist/plugin-sdk/chunk-CuJIMshx.js +341 -0
  41. package/dist/plugin-sdk/chunk-items-CxRDAM7m.js +34 -0
  42. package/dist/plugin-sdk/command-status.d.ts +20 -1
  43. package/dist/plugin-sdk/command-status.js +58 -47
  44. package/dist/plugin-sdk/commands-registry-DwQIFJmL.js +1337 -0
  45. package/dist/plugin-sdk/common-C90EHP1w.js +440 -0
  46. package/dist/plugin-sdk/config-DKNrb8oT.js +23271 -0
  47. package/dist/plugin-sdk/device-pair.d.ts +3 -1
  48. package/dist/plugin-sdk/device-pair.js +8 -840
  49. package/dist/plugin-sdk/device-pairing-J1IH1jFl.js +156 -0
  50. package/dist/plugin-sdk/diagnostic-C16gioN6.js +282 -0
  51. package/dist/plugin-sdk/directory-live-DK_83362.js +105 -0
  52. package/dist/plugin-sdk/directory-live-G7AN8y8N.js +88 -0
  53. package/dist/plugin-sdk/discord.d.ts +91 -1
  54. package/dist/plugin-sdk/discord.js +71 -3287
  55. package/dist/plugin-sdk/draft-stream-controls-DGYBMJYc.js +323 -0
  56. package/dist/plugin-sdk/exec-DQ8j4Fm3.js +230 -0
  57. package/dist/plugin-sdk/fetch-RV7QDF43.js +68 -0
  58. package/dist/plugin-sdk/fetch-guard-CxXvFYq5.js +168 -0
  59. package/dist/plugin-sdk/filesystem-manager-CeSmCA_A.js +188 -0
  60. package/dist/plugin-sdk/fs-safe-DztQeyQe.js +192 -0
  61. package/dist/plugin-sdk/group-mentions-DLOOve8d.d.ts +108 -0
  62. package/dist/plugin-sdk/guilds-n7MMnX1c.js +13 -0
  63. package/dist/plugin-sdk/handle-action-DkfMckah.js +1450 -0
  64. package/dist/plugin-sdk/helpers-C1pcZJsv.js +439 -0
  65. package/dist/plugin-sdk/image-ops-BSQmb-17.js +510 -0
  66. package/dist/plugin-sdk/index.d.ts +2575 -1
  67. package/dist/plugin-sdk/index.js +63 -783
  68. package/dist/plugin-sdk/ip-BkeyFRJr.js +181 -0
  69. package/dist/plugin-sdk/links-D5ecKoG9.js +74 -0
  70. package/dist/plugin-sdk/logger-BbFvCoKk.js +48 -0
  71. package/dist/plugin-sdk/login-YbYyMkkE.js +61 -0
  72. package/dist/plugin-sdk/login-qr-DvJw8_2g.js +326 -0
  73. package/dist/plugin-sdk/manager-DQ1dH8OM.js +3792 -0
  74. package/dist/plugin-sdk/markdown-tables-DrB-IM8r.js +29 -0
  75. package/dist/plugin-sdk/media-D8pWjqEt.js +1137 -0
  76. package/dist/plugin-sdk/memory-search-DHSeU4pJ.js +242 -0
  77. package/dist/plugin-sdk/monitor-B1PUtkd6.js +4539 -0
  78. package/dist/plugin-sdk/monitor-BrxWsb7H.js +7739 -0
  79. package/dist/plugin-sdk/openresponses-http-DJ2lfMja.js +923 -0
  80. package/dist/plugin-sdk/optional-runtime-dependency-Bt_3Yigu.js +41 -0
  81. package/dist/plugin-sdk/outbound-B5ukMdUv.js +224 -0
  82. package/dist/plugin-sdk/outbound-attachment-C9oadpUP.js +95 -0
  83. package/dist/plugin-sdk/pairing-message-B787pcJI.js +293 -0
  84. package/dist/plugin-sdk/pairing-message-DWXHX-jt.d.ts +46 -0
  85. package/dist/plugin-sdk/pairing-store-BdOcH_GA.js +437 -0
  86. package/dist/plugin-sdk/pairing-token-HQpaqod5.js +91 -0
  87. package/dist/plugin-sdk/path-alias-guards-BlIJ0AmG.js +43 -0
  88. package/dist/plugin-sdk/pi-embedded-runner-DMfkIj60.js +95517 -0
  89. package/dist/plugin-sdk/pi-model-discovery-DQdXL_-F.js +134 -0
  90. package/dist/plugin-sdk/pi-model-discovery-runtime-IwiWDCQ3.js +14 -0
  91. package/dist/plugin-sdk/probe-CJ6lN-jD.js +41 -0
  92. package/dist/plugin-sdk/probe-CvXWxzag.js +68 -0
  93. package/dist/plugin-sdk/probe-DO4M1Qd1.js +109 -0
  94. package/dist/plugin-sdk/probe-DbhD54Aw.js +89 -0
  95. package/dist/plugin-sdk/provider-web-search-config-contract.d.ts +42 -1
  96. package/dist/plugin-sdk/pw-ai-BgsJH_P8.js +1931 -0
  97. package/dist/plugin-sdk/qmd-manager-D2LMB27z.js +1335 -0
  98. package/dist/plugin-sdk/query-expansion-BM7lmqaP.js +769 -0
  99. package/dist/plugin-sdk/replies-BPFt4O-j.js +107 -0
  100. package/dist/plugin-sdk/reply-prefix-CbPHNXlm.js +171 -0
  101. package/dist/plugin-sdk/resolve-channels-B-dUtZYa.js +4 -0
  102. package/dist/plugin-sdk/resolve-channels-sscr14hU.js +208 -0
  103. package/dist/plugin-sdk/resolve-outbound-target-BP_JscKT.js +40 -0
  104. package/dist/plugin-sdk/resolve-route-wp5xq4Ws.js +249 -0
  105. package/dist/plugin-sdk/resolve-users-B63RqPIO.js +118 -0
  106. package/dist/plugin-sdk/resolve-users-C1sjzEsV.js +125 -0
  107. package/dist/plugin-sdk/retry-policy-BTH89onl.js +70 -0
  108. package/dist/plugin-sdk/run-command-i_W6EFb1.d.ts +99 -0
  109. package/dist/plugin-sdk/runtime-BUpqjZNM.js +6821 -0
  110. package/dist/plugin-sdk/runtime-dependency-pUwxUAJp.js +2110 -0
  111. package/dist/plugin-sdk/sandbox-paths-fc-HFGJr.js +158 -0
  112. package/dist/plugin-sdk/sat-runtime.d.ts +932 -1
  113. package/dist/plugin-sdk/sat-runtime.js +23 -11815
  114. package/dist/plugin-sdk/send-CRI83FPV.js +1353 -0
  115. package/dist/plugin-sdk/send-DGUAXb2b.js +518 -0
  116. package/dist/plugin-sdk/send-DUp9GIX8.js +329 -0
  117. package/dist/plugin-sdk/send-DWB5HFdb.js +547 -0
  118. package/dist/plugin-sdk/send-zn5KBXIN.js +2250 -0
  119. package/dist/plugin-sdk/session-BLyxz03u.js +175 -0
  120. package/dist/plugin-sdk/session-key--_1zVBRB.d.ts +17 -0
  121. package/dist/plugin-sdk/shared-V35XNAbz.js +37 -0
  122. package/dist/plugin-sdk/skill-commands-DCnCOVR_.js +1514 -0
  123. package/dist/plugin-sdk/slack-B6lIY1Jk.js +3742 -0
  124. package/dist/plugin-sdk/slack-actions-Dwy-8Zg7.js +254 -0
  125. package/dist/plugin-sdk/slack.d.ts +73 -1
  126. package/dist/plugin-sdk/slack.js +28 -2568
  127. package/dist/plugin-sdk/ssrf-D_4q0mKh.js +209 -0
  128. package/dist/plugin-sdk/sticker-cache-D4Ljzv1P.js +170 -0
  129. package/dist/plugin-sdk/tables-DX84FwPB.js +55 -0
  130. package/dist/plugin-sdk/tailscale-status-BGBRraZW.js +104 -0
  131. package/dist/plugin-sdk/targets-BgSHco9b.js +101 -0
  132. package/dist/plugin-sdk/targets-CuTZl1mO.js +79 -0
  133. package/dist/plugin-sdk/telegram-actions-tOhBd6st.js +319 -0
  134. package/dist/plugin-sdk/telegram.d.ts +39 -1
  135. package/dist/plugin-sdk/telegram.js +26 -2530
  136. package/dist/plugin-sdk/thread-bindings.lifecycle-DjpMLjhY.js +823 -0
  137. package/dist/plugin-sdk/thread-bindings.state-DYYR9qeT.js +643 -0
  138. package/dist/plugin-sdk/tmp-fased-dir-Be1wBhVz.d.ts +77 -0
  139. package/dist/plugin-sdk/tokens-Do_JU4Rh.js +21 -0
  140. package/dist/plugin-sdk/types-CBCtqtMn.d.ts +54 -0
  141. package/dist/plugin-sdk/types-CJGVZX6j.d.ts +1795 -0
  142. package/dist/plugin-sdk/types-CXLEOrJX.d.ts +3359 -0
  143. package/dist/plugin-sdk/types.plugin-CvUiB3Kh.d.ts +4959 -0
  144. package/dist/plugin-sdk/ui-KGr1WRXC.js +33 -0
  145. package/dist/plugin-sdk/wallet-status-CdxTkLWz.js +11880 -0
  146. package/dist/plugin-sdk/web-CX12Rpz1.js +2238 -0
  147. package/dist/plugin-sdk/whatsapp-actions-DISRDbu1.js +92 -0
  148. package/dist/plugin-sdk/whatsapp-heartbeat-KM3lYpt-.js +70 -0
  149. package/dist/plugin-sdk/whatsapp.d.ts +239 -1
  150. package/dist/plugin-sdk/whatsapp.js +29 -2474
  151. package/dist/plugin-sdk/ws-CxmRDbD9.js +114 -0
  152. package/dist/plugin-sdk/wsl-Cw-xOsqF.js +554 -0
  153. package/dist/plugin-sdk/zod-schema.providers-core-BEbNizPe.d.ts +1773 -0
  154. package/dist/plugins/status-cache.js +112 -0
  155. package/dist/plugins/status-manifest.js +61 -0
  156. package/dist/plugins/status.js +23 -2
  157. package/dist/wizard/onboarding.gateway-config.js +0 -21
  158. package/extensions/acpx/package.json +1 -1
  159. package/extensions/bluebubbles/package.json +1 -1
  160. package/extensions/copilot-proxy/package.json +1 -1
  161. package/extensions/diagnostics-otel/package.json +1 -1
  162. package/extensions/fased-federation/package.json +1 -1
  163. package/extensions/google-gemini-cli-auth/package.json +1 -1
  164. package/extensions/imessage/package.json +1 -1
  165. package/extensions/irc/package.json +1 -1
  166. package/extensions/line/package.json +1 -1
  167. package/extensions/llm-task/package.json +1 -1
  168. package/extensions/lobster/package.json +1 -1
  169. package/extensions/matrix/CHANGELOG.md +6 -0
  170. package/extensions/matrix/package.json +1 -1
  171. package/extensions/mattermost/package.json +1 -1
  172. package/extensions/memory-core/package.json +2 -2
  173. package/extensions/memory-lancedb/package.json +1 -1
  174. package/extensions/minimax-portal-auth/package.json +1 -1
  175. package/extensions/msteams/CHANGELOG.md +6 -0
  176. package/extensions/msteams/package.json +1 -1
  177. package/extensions/nextcloud-talk/package.json +1 -1
  178. package/extensions/nostr/CHANGELOG.md +6 -0
  179. package/extensions/nostr/package.json +1 -1
  180. package/extensions/open-prose/package.json +1 -1
  181. package/extensions/sat-mining/package.json +1 -1
  182. package/extensions/signal/package.json +1 -1
  183. package/extensions/synology-chat/package.json +1 -1
  184. package/extensions/tlon/package.json +1 -1
  185. package/extensions/twitch/CHANGELOG.md +6 -0
  186. package/extensions/twitch/package.json +1 -1
  187. package/extensions/voice-call/CHANGELOG.md +6 -0
  188. package/extensions/voice-call/package.json +1 -1
  189. package/extensions/zalo/CHANGELOG.md +6 -0
  190. package/extensions/zalo/package.json +1 -1
  191. package/extensions/zalouser/CHANGELOG.md +6 -0
  192. package/extensions/zalouser/package.json +1 -1
  193. package/fased.mjs +29 -1
  194. package/package.json +6 -4
  195. package/dist/plugin-sdk/account-helpers-CMvQP0I-.js +0 -38
  196. package/dist/plugin-sdk/accounts-BJFheJNv.js +0 -62
  197. package/dist/plugin-sdk/accounts-BRbbLNW_.js +0 -76
  198. package/dist/plugin-sdk/accounts-BwkH5bTD.js +0 -304
  199. package/dist/plugin-sdk/accounts-COY-15zJ.js +0 -231
  200. package/dist/plugin-sdk/accounts-D7_p-Ivb.js +0 -62
  201. package/dist/plugin-sdk/accounts-DTdM1xcj.js +0 -76
  202. package/dist/plugin-sdk/accounts-RT6y7n3H.js +0 -304
  203. package/dist/plugin-sdk/actions-BrU_JMqM.js +0 -149
  204. package/dist/plugin-sdk/actions-CUdVHzeJ.js +0 -149
  205. package/dist/plugin-sdk/active-listener-CE8t5g6l.js +0 -37
  206. package/dist/plugin-sdk/active-listener-Dx1SEGDn.js +0 -37
  207. package/dist/plugin-sdk/agent-scope-BuTbywla.js +0 -1641
  208. package/dist/plugin-sdk/agent-scope-kIJqg5PA.js +0 -1641
  209. package/dist/plugin-sdk/allow-list-C9N6FKeC.js +0 -479
  210. package/dist/plugin-sdk/allow-list-CBtbuDI8.js +0 -473
  211. package/dist/plugin-sdk/allow-list-Cgjx0Mc-.js +0 -215
  212. package/dist/plugin-sdk/audio-preflight-Chxqjwxe.js +0 -96
  213. package/dist/plugin-sdk/audio-preflight-aupYKWfa.js +0 -96
  214. package/dist/plugin-sdk/audit-DxB2Kml5.js +0 -78
  215. package/dist/plugin-sdk/audit-sSeRDwJb.js +0 -78
  216. package/dist/plugin-sdk/channel-adapters.discord-Chc31YZN.js +0 -35
  217. package/dist/plugin-sdk/channel-adapters.discord-DXVW1q8n.js +0 -35
  218. package/dist/plugin-sdk/chat-type-CH3W-zKy.js +0 -11
  219. package/dist/plugin-sdk/chunk-KCxbJLsV.js +0 -341
  220. package/dist/plugin-sdk/chunk-M2d7r-Zt.js +0 -341
  221. package/dist/plugin-sdk/chunk-items-BDhRe_xU.js +0 -34
  222. package/dist/plugin-sdk/client-DP_eXDIO.js +0 -22
  223. package/dist/plugin-sdk/client-Dn_01zRN.js +0 -28
  224. package/dist/plugin-sdk/command-poll-backoff-q0xAK3nQ.js +0 -65
  225. package/dist/plugin-sdk/commands-registry-CdT-nl7v.js +0 -1337
  226. package/dist/plugin-sdk/commands-registry-DoWdYAJd.js +0 -1337
  227. package/dist/plugin-sdk/common-Cpw-vuuM.js +0 -440
  228. package/dist/plugin-sdk/common-DJWrErdE.js +0 -440
  229. package/dist/plugin-sdk/config-B6SjJFp-.js +0 -20435
  230. package/dist/plugin-sdk/config-BULEb5QB.js +0 -19698
  231. package/dist/plugin-sdk/config-C0qggNKQ.js +0 -20423
  232. package/dist/plugin-sdk/config-CgwTaper.js +0 -22905
  233. package/dist/plugin-sdk/config-DLVjQxOu.js +0 -20435
  234. package/dist/plugin-sdk/config-DgD5T-Ui.js +0 -20656
  235. package/dist/plugin-sdk/config-DtqAN2L3.js +0 -23249
  236. package/dist/plugin-sdk/conversation-label-CDH4rKMG.js +0 -36
  237. package/dist/plugin-sdk/date-time-BtRPVcm7.js +0 -120
  238. package/dist/plugin-sdk/diagnostic-CuhHqubd.js +0 -282
  239. package/dist/plugin-sdk/diagnostic-DpyvOvs2.js +0 -275
  240. package/dist/plugin-sdk/diagnostic-session-state-Zw87xFym.js +0 -59
  241. package/dist/plugin-sdk/directory-live-8umGGN7a.js +0 -88
  242. package/dist/plugin-sdk/directory-live-BC7oHcsY.js +0 -105
  243. package/dist/plugin-sdk/directory-live-BJgud06p.js +0 -105
  244. package/dist/plugin-sdk/directory-live-BxSH0XXX.js +0 -88
  245. package/dist/plugin-sdk/draft-stream-controls-Bfbhumzv.js +0 -323
  246. package/dist/plugin-sdk/draft-stream-controls-v_5gdUYG.js +0 -323
  247. package/dist/plugin-sdk/draft-stream-loop-B3uUPmuU.js +0 -81
  248. package/dist/plugin-sdk/extensions/sat-mining/src/config.d.ts +0 -117
  249. package/dist/plugin-sdk/extensions/sat-mining/src/hash-spec.d.ts +0 -58
  250. package/dist/plugin-sdk/extensions/sat-mining/src/rpc-read.d.ts +0 -648
  251. package/dist/plugin-sdk/extensions/sat-mining/src/sat-bond-layout.d.ts +0 -110
  252. package/dist/plugin-sdk/extensions/sat-mining/src/solana-submit.d.ts +0 -297
  253. package/dist/plugin-sdk/fetch-D70syO9t.js +0 -68
  254. package/dist/plugin-sdk/fetch-guard-BLdujDnt.js +0 -163
  255. package/dist/plugin-sdk/fetch-guard-DTKgMN9f.js +0 -163
  256. package/dist/plugin-sdk/fetch-headers-my7hgV2G.js +0 -26
  257. package/dist/plugin-sdk/fetch-timeout-l_6RdoMw.js +0 -43
  258. package/dist/plugin-sdk/fetch-xfeOsibm.js +0 -68
  259. package/dist/plugin-sdk/filesystem-manager-BEd8NKL9.js +0 -186
  260. package/dist/plugin-sdk/filesystem-manager-D-4lQ3Af.js +0 -186
  261. package/dist/plugin-sdk/fs-safe-BDnJzutp.js +0 -192
  262. package/dist/plugin-sdk/fs-safe-BPYS6-j1.js +0 -192
  263. package/dist/plugin-sdk/gateway-registry-w_Z-PHGf.js +0 -58
  264. package/dist/plugin-sdk/github-copilot-token-Djqpy66R.js +0 -127
  265. package/dist/plugin-sdk/globals-BtKmaIS3.js +0 -439
  266. package/dist/plugin-sdk/guilds-BdkvRFue.js +0 -13
  267. package/dist/plugin-sdk/guilds-DmzO7n0X.js +0 -13
  268. package/dist/plugin-sdk/guilds-iTYlgBat.js +0 -13
  269. package/dist/plugin-sdk/handle-action-B61D85yo.js +0 -1445
  270. package/dist/plugin-sdk/handle-action-CjcxGzQD.js +0 -1445
  271. package/dist/plugin-sdk/inbound-context-CeJDjLk-.js +0 -68
  272. package/dist/plugin-sdk/internal-DMTDEiDF.js +0 -247
  273. package/dist/plugin-sdk/ip-Ddk9SPR-.js +0 -47
  274. package/dist/plugin-sdk/login-CB_nCjX3.js +0 -61
  275. package/dist/plugin-sdk/login-CzUuDd1v.js +0 -61
  276. package/dist/plugin-sdk/login-YveoqEvH.js +0 -268
  277. package/dist/plugin-sdk/login-qr-D7MEpFza.js +0 -324
  278. package/dist/plugin-sdk/login-qr-DgxfBFVN.js +0 -324
  279. package/dist/plugin-sdk/manager-9see0IX5.js +0 -3792
  280. package/dist/plugin-sdk/manager-D2kZ0Cps.js +0 -3792
  281. package/dist/plugin-sdk/markdown-tables-CCSD52rA.js +0 -29
  282. package/dist/plugin-sdk/markdown-tables-DWUNvLrc.js +0 -29
  283. package/dist/plugin-sdk/media-C7YT4DeU.js +0 -1641
  284. package/dist/plugin-sdk/media-Cxw-xLGU.js +0 -1641
  285. package/dist/plugin-sdk/memory-search-B-0Fwnrp.js +0 -242
  286. package/dist/plugin-sdk/memory-search-J6AYuENR.js +0 -242
  287. package/dist/plugin-sdk/monitor-38DGeIwS.js +0 -4528
  288. package/dist/plugin-sdk/monitor-CYCSEVee.js +0 -7743
  289. package/dist/plugin-sdk/monitor-Ceu-Wayc.js +0 -4528
  290. package/dist/plugin-sdk/monitor-DCyBaUCs.js +0 -7728
  291. package/dist/plugin-sdk/openresponses-http-CCfimy89.js +0 -912
  292. package/dist/plugin-sdk/openresponses-http-DAL_9jE-.js +0 -912
  293. package/dist/plugin-sdk/optional-runtime-dependency-szS49voX.js +0 -426
  294. package/dist/plugin-sdk/outbound-BCxOxdi-.js +0 -224
  295. package/dist/plugin-sdk/outbound-JIwQbpRY.js +0 -224
  296. package/dist/plugin-sdk/outbound-attachment-C-jSFaEB.js +0 -94
  297. package/dist/plugin-sdk/outbound-attachment-D6tj5Y5H.js +0 -78
  298. package/dist/plugin-sdk/path-alias-guards-C76pC928.js +0 -43
  299. package/dist/plugin-sdk/path-alias-guards-CcQroDXQ.js +0 -43
  300. package/dist/plugin-sdk/paths-DTurNPnO.js +0 -158
  301. package/dist/plugin-sdk/paths-GdhK5mV_.js +0 -191
  302. package/dist/plugin-sdk/pi-embedded-runner-Dum71Tdo.js +0 -107134
  303. package/dist/plugin-sdk/pi-model-discovery-DadlvsZW.js +0 -134
  304. package/dist/plugin-sdk/pi-model-discovery-G2L8gMcs.js +0 -22703
  305. package/dist/plugin-sdk/pi-model-discovery-runtime-BpR1pe7K.js +0 -3
  306. package/dist/plugin-sdk/pi-model-discovery-runtime-C5ssE6EW.js +0 -127
  307. package/dist/plugin-sdk/pi-model-discovery-runtime-CQOauapl.js +0 -127
  308. package/dist/plugin-sdk/pi-model-discovery-runtime-DAaOPt64.js +0 -12
  309. package/dist/plugin-sdk/pi-model-discovery-runtime-DYfUuqPN.js +0 -127
  310. package/dist/plugin-sdk/pi-model-discovery-runtime-DyOIGBor.js +0 -127
  311. package/dist/plugin-sdk/pi-model-discovery-runtime-gd77b0UF.js +0 -12
  312. package/dist/plugin-sdk/pi-model-discovery-runtime-w4DRRv53.js +0 -128
  313. package/dist/plugin-sdk/pi-model-discovery-yifTIDIn.js +0 -134
  314. package/dist/plugin-sdk/polls-D0YNJBfc.js +0 -33
  315. package/dist/plugin-sdk/probe-0Xt6fbw2.js +0 -109
  316. package/dist/plugin-sdk/probe-1paqsAk5.js +0 -89
  317. package/dist/plugin-sdk/probe-BPYqD-cg.js +0 -68
  318. package/dist/plugin-sdk/probe-Ba4KG8Vi.js +0 -41
  319. package/dist/plugin-sdk/probe-BfzwvkxZ.js +0 -68
  320. package/dist/plugin-sdk/probe-CsFmvxbr.js +0 -89
  321. package/dist/plugin-sdk/probe-Dqx0N4uk.js +0 -109
  322. package/dist/plugin-sdk/probe-DrTulmwQ.js +0 -41
  323. package/dist/plugin-sdk/proxy-CV9uL4Wi.js +0 -16
  324. package/dist/plugin-sdk/pw-ai-SNCI9UXT.js +0 -1926
  325. package/dist/plugin-sdk/pw-ai-sH1Pi-Fh.js +0 -1926
  326. package/dist/plugin-sdk/qmd-manager-BfJXNhlO.js +0 -1333
  327. package/dist/plugin-sdk/qmd-manager-QNVr__Z6.js +0 -1333
  328. package/dist/plugin-sdk/qmd-scope-Cei2-7Q5.js +0 -78
  329. package/dist/plugin-sdk/query-expansion-DjJAUtDU.js +0 -769
  330. package/dist/plugin-sdk/query-expansion-VePrajug.js +0 -769
  331. package/dist/plugin-sdk/redact-Ck-wgswc.js +0 -188
  332. package/dist/plugin-sdk/redact-identifier-DdQO7P4_.js +0 -15
  333. package/dist/plugin-sdk/registry-DNkJsNsz.js +0 -6463
  334. package/dist/plugin-sdk/replies-fvzN5wnU.js +0 -107
  335. package/dist/plugin-sdk/replies-zebgZCHX.js +0 -107
  336. package/dist/plugin-sdk/reply-prefix-DqlCqHXT.js +0 -171
  337. package/dist/plugin-sdk/reply-prefix-Y14LY6Rn.js +0 -171
  338. package/dist/plugin-sdk/reply-reference-mUSl_ExV.js +0 -35
  339. package/dist/plugin-sdk/resolve-channels-CGCkchAo.js +0 -208
  340. package/dist/plugin-sdk/resolve-channels-CHkzoB7d.js +0 -4
  341. package/dist/plugin-sdk/resolve-channels-CIoMOUEH.js +0 -88
  342. package/dist/plugin-sdk/resolve-channels-CU3vZXOG.js +0 -4
  343. package/dist/plugin-sdk/resolve-channels-J5m_-ZOk.js +0 -208
  344. package/dist/plugin-sdk/resolve-channels-gIpOj1wt.js +0 -206
  345. package/dist/plugin-sdk/resolve-route-CNhTJG_2.js +0 -248
  346. package/dist/plugin-sdk/resolve-route-DO0WR4nB.js +0 -248
  347. package/dist/plugin-sdk/resolve-users-Bm78yvE3.js +0 -123
  348. package/dist/plugin-sdk/resolve-users-C0F3LQs2.js +0 -118
  349. package/dist/plugin-sdk/resolve-users-CTKaESmf.js +0 -116
  350. package/dist/plugin-sdk/resolve-users-Ct0fO5kP.js +0 -125
  351. package/dist/plugin-sdk/resolve-users-DlpsBzVS.js +0 -118
  352. package/dist/plugin-sdk/resolve-users-sv9og6yh.js +0 -125
  353. package/dist/plugin-sdk/resolve-utils-r6ef8mj8.js +0 -147
  354. package/dist/plugin-sdk/retry-CB29XXbz.js +0 -780
  355. package/dist/plugin-sdk/retry-Cq65ROXv.js +0 -77
  356. package/dist/plugin-sdk/retry-policy-BLYEgIwP.js +0 -70
  357. package/dist/plugin-sdk/retry-policy-sM01QZT2.js +0 -70
  358. package/dist/plugin-sdk/run-with-concurrency-CavAFhML.js +0 -42
  359. package/dist/plugin-sdk/runtime-BPyuAmka.js +0 -6577
  360. package/dist/plugin-sdk/runtime-dependency-B-1u41Ph.js +0 -2217
  361. package/dist/plugin-sdk/runtime-dependency-Csswyv5r.js +0 -2217
  362. package/dist/plugin-sdk/sandbox-paths-CkTERCrj.js +0 -158
  363. package/dist/plugin-sdk/sandbox-paths-DMnFyOaA.js +0 -158
  364. package/dist/plugin-sdk/secure-random-DLpYiUzR.js +0 -12
  365. package/dist/plugin-sdk/send-B09HRfHN.js +0 -1351
  366. package/dist/plugin-sdk/send-BBYcgXA4.js +0 -546
  367. package/dist/plugin-sdk/send-BQXQA81e.js +0 -2249
  368. package/dist/plugin-sdk/send-BzFdvD_i.js +0 -1351
  369. package/dist/plugin-sdk/send-C3u-F_8s.js +0 -2249
  370. package/dist/plugin-sdk/send-D3836_UN.js +0 -505
  371. package/dist/plugin-sdk/send-D7tr-EsH.js +0 -546
  372. package/dist/plugin-sdk/send-DRGzRdI3.js +0 -518
  373. package/dist/plugin-sdk/send-DfkPKz_0.js +0 -356
  374. package/dist/plugin-sdk/send-DsxFXrCO.js +0 -356
  375. package/dist/plugin-sdk/session-DG_bYisw.js +0 -175
  376. package/dist/plugin-sdk/session-EIStzK0E.js +0 -175
  377. package/dist/plugin-sdk/session-key-Bp3qq3bm.js +0 -228
  378. package/dist/plugin-sdk/skill-commands-CkgGmWBS.js +0 -1600
  379. package/dist/plugin-sdk/skill-commands-hyZA0LE3.js +0 -1571
  380. package/dist/plugin-sdk/slack-B0dLDyHM.js +0 -3731
  381. package/dist/plugin-sdk/slack-Dv4zCw-x.js +0 -3730
  382. package/dist/plugin-sdk/slack-actions-BQawWGTJ.js +0 -248
  383. package/dist/plugin-sdk/slack-actions-DDMszx56.js +0 -248
  384. package/dist/plugin-sdk/src/acp/acpx-mutating-wrapper-policy.d.ts +0 -35
  385. package/dist/plugin-sdk/src/acp/acpx-push-test-approval-contract.d.ts +0 -62
  386. package/dist/plugin-sdk/src/acp/acpx-push-test-execution-adapter.d.ts +0 -44
  387. package/dist/plugin-sdk/src/acp/control-plane/manager.core.d.ts +0 -74
  388. package/dist/plugin-sdk/src/acp/control-plane/manager.d.ts +0 -7
  389. package/dist/plugin-sdk/src/acp/control-plane/manager.identity-reconcile.d.ts +0 -23
  390. package/dist/plugin-sdk/src/acp/control-plane/manager.runtime-controls.d.ts +0 -14
  391. package/dist/plugin-sdk/src/acp/control-plane/manager.types.d.ts +0 -103
  392. package/dist/plugin-sdk/src/acp/control-plane/manager.utils.d.ts +0 -14
  393. package/dist/plugin-sdk/src/acp/control-plane/runtime-cache.d.ts +0 -38
  394. package/dist/plugin-sdk/src/acp/control-plane/runtime-options.d.ts +0 -23
  395. package/dist/plugin-sdk/src/acp/control-plane/session-actor-queue.d.ts +0 -8
  396. package/dist/plugin-sdk/src/acp/control-plane/spawn.d.ts +0 -25
  397. package/dist/plugin-sdk/src/acp/policy.d.ts +0 -10
  398. package/dist/plugin-sdk/src/acp/runtime/error-text.d.ts +0 -7
  399. package/dist/plugin-sdk/src/acp/runtime/errors.d.ts +0 -20
  400. package/dist/plugin-sdk/src/acp/runtime/registry.d.ts +0 -18
  401. package/dist/plugin-sdk/src/acp/runtime/session-identifiers.d.ts +0 -17
  402. package/dist/plugin-sdk/src/acp/runtime/session-identity.d.ts +0 -23
  403. package/dist/plugin-sdk/src/acp/runtime/session-meta.d.ts +0 -30
  404. package/dist/plugin-sdk/src/acp/runtime/types.d.ts +0 -102
  405. package/dist/plugin-sdk/src/acp/status-snapshot.d.ts +0 -54
  406. package/dist/plugin-sdk/src/agents/acp-spawn-parent-stream.d.ts +0 -20
  407. package/dist/plugin-sdk/src/agents/acp-spawn.d.ts +0 -39
  408. package/dist/plugin-sdk/src/agents/agent-model-providers.d.ts +0 -47
  409. package/dist/plugin-sdk/src/agents/agent-paths.d.ts +0 -4
  410. package/dist/plugin-sdk/src/agents/agent-scope.d.ts +0 -71
  411. package/dist/plugin-sdk/src/agents/announce-idempotency.d.ts +0 -11
  412. package/dist/plugin-sdk/src/agents/anthropic-payload-log.d.ts +0 -20
  413. package/dist/plugin-sdk/src/agents/api-key-rotation.d.ts +0 -22
  414. package/dist/plugin-sdk/src/agents/apply-patch-update.d.ts +0 -10
  415. package/dist/plugin-sdk/src/agents/apply-patch.d.ts +0 -35
  416. package/dist/plugin-sdk/src/agents/auth-health.d.ts +0 -40
  417. package/dist/plugin-sdk/src/agents/auth-profiles/constants.d.ts +0 -19
  418. package/dist/plugin-sdk/src/agents/auth-profiles/display.d.ts +0 -7
  419. package/dist/plugin-sdk/src/agents/auth-profiles/doctor.d.ts +0 -8
  420. package/dist/plugin-sdk/src/agents/auth-profiles/external-cli-sync.d.ts +0 -7
  421. package/dist/plugin-sdk/src/agents/auth-profiles/oauth.d.ts +0 -14
  422. package/dist/plugin-sdk/src/agents/auth-profiles/order.d.ts +0 -8
  423. package/dist/plugin-sdk/src/agents/auth-profiles/paths.d.ts +0 -4
  424. package/dist/plugin-sdk/src/agents/auth-profiles/profiles.d.ts +0 -25
  425. package/dist/plugin-sdk/src/agents/auth-profiles/repair.d.ts +0 -14
  426. package/dist/plugin-sdk/src/agents/auth-profiles/session-override.d.ts +0 -19
  427. package/dist/plugin-sdk/src/agents/auth-profiles/store.d.ts +0 -24
  428. package/dist/plugin-sdk/src/agents/auth-profiles/types.d.ts +0 -65
  429. package/dist/plugin-sdk/src/agents/auth-profiles/usage.d.ts +0 -85
  430. package/dist/plugin-sdk/src/agents/auth-profiles.d.ts +0 -11
  431. package/dist/plugin-sdk/src/agents/bash-process-registry.d.ts +0 -72
  432. package/dist/plugin-sdk/src/agents/bash-tools.d.ts +0 -4
  433. package/dist/plugin-sdk/src/agents/bash-tools.exec-approval-followup.d.ts +0 -12
  434. package/dist/plugin-sdk/src/agents/bash-tools.exec-approval-request.d.ts +0 -70
  435. package/dist/plugin-sdk/src/agents/bash-tools.exec-host-gateway.d.ts +0 -34
  436. package/dist/plugin-sdk/src/agents/bash-tools.exec-host-node.d.ts +0 -26
  437. package/dist/plugin-sdk/src/agents/bash-tools.exec-host-shared.d.ts +0 -155
  438. package/dist/plugin-sdk/src/agents/bash-tools.exec-runtime.d.ts +0 -116
  439. package/dist/plugin-sdk/src/agents/bash-tools.exec-types.d.ts +0 -76
  440. package/dist/plugin-sdk/src/agents/bash-tools.exec.d.ts +0 -6
  441. package/dist/plugin-sdk/src/agents/bash-tools.process.d.ts +0 -11
  442. package/dist/plugin-sdk/src/agents/bash-tools.shared.d.ts +0 -56
  443. package/dist/plugin-sdk/src/agents/bootstrap-budget.d.ts +0 -87
  444. package/dist/plugin-sdk/src/agents/bootstrap-cache.d.ts +0 -11
  445. package/dist/plugin-sdk/src/agents/bootstrap-files.d.ts +0 -32
  446. package/dist/plugin-sdk/src/agents/bootstrap-hooks.d.ts +0 -10
  447. package/dist/plugin-sdk/src/agents/byteplus-models.d.ts +0 -128
  448. package/dist/plugin-sdk/src/agents/cache-trace.d.ts +0 -49
  449. package/dist/plugin-sdk/src/agents/channel-tools.d.ts +0 -30
  450. package/dist/plugin-sdk/src/agents/chutes-models.d.ts +0 -25
  451. package/dist/plugin-sdk/src/agents/chutes-oauth.d.ts +0 -46
  452. package/dist/plugin-sdk/src/agents/cli-backends.d.ts +0 -8
  453. package/dist/plugin-sdk/src/agents/cli-credentials.d.ts +0 -72
  454. package/dist/plugin-sdk/src/agents/cli-runner/helpers.d.ts +0 -72
  455. package/dist/plugin-sdk/src/agents/cli-runner/reliability.d.ts +0 -11
  456. package/dist/plugin-sdk/src/agents/cli-runner.d.ts +0 -42
  457. package/dist/plugin-sdk/src/agents/cli-session.d.ts +0 -3
  458. package/dist/plugin-sdk/src/agents/cli-watchdog-defaults.d.ts +0 -11
  459. package/dist/plugin-sdk/src/agents/cloudflare-ai-gateway.d.ts +0 -1
  460. package/dist/plugin-sdk/src/agents/command-poll-backoff.d.ts +0 -28
  461. package/dist/plugin-sdk/src/agents/compaction.d.ts +0 -72
  462. package/dist/plugin-sdk/src/agents/content-blocks.d.ts +0 -1
  463. package/dist/plugin-sdk/src/agents/context-window-guard.d.ts +0 -25
  464. package/dist/plugin-sdk/src/agents/context.d.ts +0 -38
  465. package/dist/plugin-sdk/src/agents/current-model-catalog.d.ts +0 -5
  466. package/dist/plugin-sdk/src/agents/current-time.d.ts +0 -17
  467. package/dist/plugin-sdk/src/agents/date-time.d.ts +0 -13
  468. package/dist/plugin-sdk/src/agents/defaults.d.ts +0 -3
  469. package/dist/plugin-sdk/src/agents/docs-path.d.ts +0 -6
  470. package/dist/plugin-sdk/src/agents/doubao-models.d.ts +0 -128
  471. package/dist/plugin-sdk/src/agents/embedded-pi-mcp.d.ts +0 -13
  472. package/dist/plugin-sdk/src/agents/exec-approval-result.d.ts +0 -21
  473. package/dist/plugin-sdk/src/agents/failover-error.d.ts +0 -33
  474. package/dist/plugin-sdk/src/agents/fased-tools.d.ts +0 -58
  475. package/dist/plugin-sdk/src/agents/glob-pattern.d.ts +0 -18
  476. package/dist/plugin-sdk/src/agents/huggingface-models.d.ts +0 -14
  477. package/dist/plugin-sdk/src/agents/identity-avatar.d.ts +0 -17
  478. package/dist/plugin-sdk/src/agents/identity-file.d.ts +0 -12
  479. package/dist/plugin-sdk/src/agents/identity.d.ts +0 -28
  480. package/dist/plugin-sdk/src/agents/image-sanitization.d.ts +0 -8
  481. package/dist/plugin-sdk/src/agents/lanes.d.ts +0 -4
  482. package/dist/plugin-sdk/src/agents/live-auth-keys.d.ts +0 -6
  483. package/dist/plugin-sdk/src/agents/mcp-config-shared.d.ts +0 -5
  484. package/dist/plugin-sdk/src/agents/mcp-http.d.ts +0 -19
  485. package/dist/plugin-sdk/src/agents/mcp-stdio.d.ts +0 -16
  486. package/dist/plugin-sdk/src/agents/mcp-transport-config.d.ts +0 -23
  487. package/dist/plugin-sdk/src/agents/mcp-transport.d.ts +0 -9
  488. package/dist/plugin-sdk/src/agents/memory-search.d.ts +0 -80
  489. package/dist/plugin-sdk/src/agents/minimax-vlm.d.ts +0 -8
  490. package/dist/plugin-sdk/src/agents/model-alias-lines.d.ts +0 -2
  491. package/dist/plugin-sdk/src/agents/model-auth-label.d.ts +0 -8
  492. package/dist/plugin-sdk/src/agents/model-auth.d.ts +0 -37
  493. package/dist/plugin-sdk/src/agents/model-catalog-access.d.ts +0 -30
  494. package/dist/plugin-sdk/src/agents/model-catalog-normalized.d.ts +0 -27
  495. package/dist/plugin-sdk/src/agents/model-catalog-source.d.ts +0 -41
  496. package/dist/plugin-sdk/src/agents/model-catalog-status.d.ts +0 -92
  497. package/dist/plugin-sdk/src/agents/model-catalog.d.ts +0 -35
  498. package/dist/plugin-sdk/src/agents/model-compat.d.ts +0 -2
  499. package/dist/plugin-sdk/src/agents/model-fallback.d.ts +0 -54
  500. package/dist/plugin-sdk/src/agents/model-forward-compat.d.ts +0 -3
  501. package/dist/plugin-sdk/src/agents/model-metadata.d.ts +0 -49
  502. package/dist/plugin-sdk/src/agents/model-ref-profile.d.ts +0 -4
  503. package/dist/plugin-sdk/src/agents/model-selection.d.ts +0 -130
  504. package/dist/plugin-sdk/src/agents/models-config.d.ts +0 -9
  505. package/dist/plugin-sdk/src/agents/models-config.providers.d.ts +0 -40
  506. package/dist/plugin-sdk/src/agents/opencode-zen-models.d.ts +0 -46
  507. package/dist/plugin-sdk/src/agents/owner-display.d.ts +0 -19
  508. package/dist/plugin-sdk/src/agents/payload-redaction.d.ts +0 -10
  509. package/dist/plugin-sdk/src/agents/pi-auth-credentials.d.ts +0 -16
  510. package/dist/plugin-sdk/src/agents/pi-bundle-mcp-materialize.d.ts +0 -12
  511. package/dist/plugin-sdk/src/agents/pi-bundle-mcp-names.d.ts +0 -9
  512. package/dist/plugin-sdk/src/agents/pi-bundle-mcp-runtime.d.ts +0 -21
  513. package/dist/plugin-sdk/src/agents/pi-bundle-mcp-tools.d.ts +0 -3
  514. package/dist/plugin-sdk/src/agents/pi-bundle-mcp-types.d.ts +0 -52
  515. package/dist/plugin-sdk/src/agents/pi-embedded-block-chunker.d.ts +0 -19
  516. package/dist/plugin-sdk/src/agents/pi-embedded-helpers/bootstrap.d.ts +0 -33
  517. package/dist/plugin-sdk/src/agents/pi-embedded-helpers/errors.d.ts +0 -70
  518. package/dist/plugin-sdk/src/agents/pi-embedded-helpers/google.d.ts +0 -3
  519. package/dist/plugin-sdk/src/agents/pi-embedded-helpers/images.d.ts +0 -22
  520. package/dist/plugin-sdk/src/agents/pi-embedded-helpers/messaging-dedupe.d.ts +0 -10
  521. package/dist/plugin-sdk/src/agents/pi-embedded-helpers/openai.d.ts +0 -17
  522. package/dist/plugin-sdk/src/agents/pi-embedded-helpers/thinking.d.ts +0 -5
  523. package/dist/plugin-sdk/src/agents/pi-embedded-helpers/turns.d.ts +0 -21
  524. package/dist/plugin-sdk/src/agents/pi-embedded-helpers/types.d.ts +0 -5
  525. package/dist/plugin-sdk/src/agents/pi-embedded-helpers.d.ts +0 -11
  526. package/dist/plugin-sdk/src/agents/pi-embedded-messaging.d.ts +0 -9
  527. package/dist/plugin-sdk/src/agents/pi-embedded-payloads.d.ts +0 -9
  528. package/dist/plugin-sdk/src/agents/pi-embedded-runner/abort.d.ts +0 -6
  529. package/dist/plugin-sdk/src/agents/pi-embedded-runner/cache-ttl.d.ts +0 -17
  530. package/dist/plugin-sdk/src/agents/pi-embedded-runner/compact.d.ts +0 -57
  531. package/dist/plugin-sdk/src/agents/pi-embedded-runner/compaction-safety-timeout.d.ts +0 -7
  532. package/dist/plugin-sdk/src/agents/pi-embedded-runner/extensions.d.ts +0 -12
  533. package/dist/plugin-sdk/src/agents/pi-embedded-runner/extra-params.d.ts +0 -76
  534. package/dist/plugin-sdk/src/agents/pi-embedded-runner/google.d.ts +0 -42
  535. package/dist/plugin-sdk/src/agents/pi-embedded-runner/history.d.ts +0 -18
  536. package/dist/plugin-sdk/src/agents/pi-embedded-runner/lanes.d.ts +0 -3
  537. package/dist/plugin-sdk/src/agents/pi-embedded-runner/logger.d.ts +0 -1
  538. package/dist/plugin-sdk/src/agents/pi-embedded-runner/model.d.ts +0 -30
  539. package/dist/plugin-sdk/src/agents/pi-embedded-runner/run/attempt.d.ts +0 -30
  540. package/dist/plugin-sdk/src/agents/pi-embedded-runner/run/compaction-timeout.d.ts +0 -20
  541. package/dist/plugin-sdk/src/agents/pi-embedded-runner/run/history-image-prune.d.ts +0 -7
  542. package/dist/plugin-sdk/src/agents/pi-embedded-runner/run/images.d.ts +0 -83
  543. package/dist/plugin-sdk/src/agents/pi-embedded-runner/run/llm-idle-timeout.d.ts +0 -9
  544. package/dist/plugin-sdk/src/agents/pi-embedded-runner/run/params.d.ts +0 -128
  545. package/dist/plugin-sdk/src/agents/pi-embedded-runner/run/payloads.d.ts +0 -42
  546. package/dist/plugin-sdk/src/agents/pi-embedded-runner/run/types.d.ts +0 -67
  547. package/dist/plugin-sdk/src/agents/pi-embedded-runner/run.d.ts +0 -3
  548. package/dist/plugin-sdk/src/agents/pi-embedded-runner/runs.d.ts +0 -32
  549. package/dist/plugin-sdk/src/agents/pi-embedded-runner/sandbox-info.d.ts +0 -4
  550. package/dist/plugin-sdk/src/agents/pi-embedded-runner/session-manager-cache.d.ts +0 -2
  551. package/dist/plugin-sdk/src/agents/pi-embedded-runner/session-manager-init.d.ts +0 -17
  552. package/dist/plugin-sdk/src/agents/pi-embedded-runner/system-prompt.d.ts +0 -55
  553. package/dist/plugin-sdk/src/agents/pi-embedded-runner/thinking.d.ts +0 -17
  554. package/dist/plugin-sdk/src/agents/pi-embedded-runner/tool-name-allowlist.d.ts +0 -6
  555. package/dist/plugin-sdk/src/agents/pi-embedded-runner/tool-result-context-guard.d.ts +0 -8
  556. package/dist/plugin-sdk/src/agents/pi-embedded-runner/tool-result-truncation.d.ts +0 -79
  557. package/dist/plugin-sdk/src/agents/pi-embedded-runner/tool-split.d.ts +0 -11
  558. package/dist/plugin-sdk/src/agents/pi-embedded-runner/types.d.ts +0 -95
  559. package/dist/plugin-sdk/src/agents/pi-embedded-runner/utils.d.ts +0 -5
  560. package/dist/plugin-sdk/src/agents/pi-embedded-runner/wait-for-idle-before-flush.d.ts +0 -14
  561. package/dist/plugin-sdk/src/agents/pi-embedded-runner.d.ts +0 -12
  562. package/dist/plugin-sdk/src/agents/pi-embedded-subscribe.d.ts +0 -34
  563. package/dist/plugin-sdk/src/agents/pi-embedded-subscribe.handlers.compaction.d.ts +0 -6
  564. package/dist/plugin-sdk/src/agents/pi-embedded-subscribe.handlers.d.ts +0 -2
  565. package/dist/plugin-sdk/src/agents/pi-embedded-subscribe.handlers.lifecycle.d.ts +0 -4
  566. package/dist/plugin-sdk/src/agents/pi-embedded-subscribe.handlers.messages.d.ts +0 -16
  567. package/dist/plugin-sdk/src/agents/pi-embedded-subscribe.handlers.tools.d.ts +0 -18
  568. package/dist/plugin-sdk/src/agents/pi-embedded-subscribe.handlers.types.d.ts +0 -152
  569. package/dist/plugin-sdk/src/agents/pi-embedded-subscribe.raw-stream.d.ts +0 -1
  570. package/dist/plugin-sdk/src/agents/pi-embedded-subscribe.tools.d.ts +0 -20
  571. package/dist/plugin-sdk/src/agents/pi-embedded-subscribe.types.d.ts +0 -45
  572. package/dist/plugin-sdk/src/agents/pi-embedded-utils.d.ts +0 -42
  573. package/dist/plugin-sdk/src/agents/pi-embedded.d.ts +0 -2
  574. package/dist/plugin-sdk/src/agents/pi-extensions/compaction-safeguard-runtime.d.ts +0 -16
  575. package/dist/plugin-sdk/src/agents/pi-extensions/compaction-safeguard.d.ts +0 -22
  576. package/dist/plugin-sdk/src/agents/pi-extensions/context-pruning/extension.d.ts +0 -7
  577. package/dist/plugin-sdk/src/agents/pi-extensions/context-pruning/pruner.d.ts +0 -10
  578. package/dist/plugin-sdk/src/agents/pi-extensions/context-pruning/runtime.d.ts +0 -9
  579. package/dist/plugin-sdk/src/agents/pi-extensions/context-pruning/settings.d.ts +0 -44
  580. package/dist/plugin-sdk/src/agents/pi-extensions/context-pruning/tools.d.ts +0 -2
  581. package/dist/plugin-sdk/src/agents/pi-extensions/context-pruning.d.ts +0 -10
  582. package/dist/plugin-sdk/src/agents/pi-extensions/session-manager-runtime-registry.d.ts +0 -4
  583. package/dist/plugin-sdk/src/agents/pi-model-discovery-runtime.d.ts +0 -1
  584. package/dist/plugin-sdk/src/agents/pi-model-discovery.d.ts +0 -7
  585. package/dist/plugin-sdk/src/agents/pi-project-settings.d.ts +0 -28
  586. package/dist/plugin-sdk/src/agents/pi-settings.d.ts +0 -45
  587. package/dist/plugin-sdk/src/agents/pi-tool-definition-adapter.d.ts +0 -8
  588. package/dist/plugin-sdk/src/agents/pi-tools.abort.d.ts +0 -2
  589. package/dist/plugin-sdk/src/agents/pi-tools.before-tool-call.d.ts +0 -31
  590. package/dist/plugin-sdk/src/agents/pi-tools.d.ts +0 -84
  591. package/dist/plugin-sdk/src/agents/pi-tools.policy.d.ts +0 -38
  592. package/dist/plugin-sdk/src/agents/pi-tools.read.d.ts +0 -61
  593. package/dist/plugin-sdk/src/agents/pi-tools.schema.d.ts +0 -9
  594. package/dist/plugin-sdk/src/agents/pi-tools.types.d.ts +0 -2
  595. package/dist/plugin-sdk/src/agents/prompt-cache-stability.d.ts +0 -2
  596. package/dist/plugin-sdk/src/agents/provider-attribution.d.ts +0 -70
  597. package/dist/plugin-sdk/src/agents/provider-auth-aliases.d.ts +0 -9
  598. package/dist/plugin-sdk/src/agents/provider-extension-catalog-index.d.ts +0 -37
  599. package/dist/plugin-sdk/src/agents/provider-extension-catalog-manifest.d.ts +0 -29
  600. package/dist/plugin-sdk/src/agents/provider-id.d.ts +0 -5
  601. package/dist/plugin-sdk/src/agents/provider-request-config.d.ts +0 -194
  602. package/dist/plugin-sdk/src/agents/pty-dsr.d.ts +0 -5
  603. package/dist/plugin-sdk/src/agents/pty-keys.d.ts +0 -14
  604. package/dist/plugin-sdk/src/agents/queued-file-writer.d.ts +0 -5
  605. package/dist/plugin-sdk/src/agents/sandbox/backend.d.ts +0 -29
  606. package/dist/plugin-sdk/src/agents/sandbox/bind-spec.d.ts +0 -7
  607. package/dist/plugin-sdk/src/agents/sandbox/browser-bridges.d.ts +0 -7
  608. package/dist/plugin-sdk/src/agents/sandbox/browser.d.ts +0 -12
  609. package/dist/plugin-sdk/src/agents/sandbox/config-hash.d.ts +0 -18
  610. package/dist/plugin-sdk/src/agents/sandbox/config.d.ts +0 -32
  611. package/dist/plugin-sdk/src/agents/sandbox/constants.d.ts +0 -21
  612. package/dist/plugin-sdk/src/agents/sandbox/context.d.ts +0 -20
  613. package/dist/plugin-sdk/src/agents/sandbox/docker.d.ts +0 -48
  614. package/dist/plugin-sdk/src/agents/sandbox/fs-bridge.d.ts +0 -56
  615. package/dist/plugin-sdk/src/agents/sandbox/fs-paths.d.ts +0 -28
  616. package/dist/plugin-sdk/src/agents/sandbox/hash.d.ts +0 -1
  617. package/dist/plugin-sdk/src/agents/sandbox/host-paths.d.ts +0 -9
  618. package/dist/plugin-sdk/src/agents/sandbox/manage.d.ts +0 -13
  619. package/dist/plugin-sdk/src/agents/sandbox/network-mode.d.ts +0 -7
  620. package/dist/plugin-sdk/src/agents/sandbox/novnc-auth.d.ts +0 -15
  621. package/dist/plugin-sdk/src/agents/sandbox/path-utils.d.ts +0 -2
  622. package/dist/plugin-sdk/src/agents/sandbox/prune.d.ts +0 -3
  623. package/dist/plugin-sdk/src/agents/sandbox/registry.d.ts +0 -31
  624. package/dist/plugin-sdk/src/agents/sandbox/runtime-status.d.ts +0 -18
  625. package/dist/plugin-sdk/src/agents/sandbox/sanitize-env-vars.d.ts +0 -14
  626. package/dist/plugin-sdk/src/agents/sandbox/shared.d.ts +0 -4
  627. package/dist/plugin-sdk/src/agents/sandbox/tool-policy.d.ts +0 -4
  628. package/dist/plugin-sdk/src/agents/sandbox/types.d.ts +0 -91
  629. package/dist/plugin-sdk/src/agents/sandbox/types.docker.d.ts +0 -4
  630. package/dist/plugin-sdk/src/agents/sandbox/validate-sandbox-security.d.ts +0 -68
  631. package/dist/plugin-sdk/src/agents/sandbox/workspace.d.ts +0 -1
  632. package/dist/plugin-sdk/src/agents/sandbox-media-paths.d.ts +0 -17
  633. package/dist/plugin-sdk/src/agents/sandbox-paths.d.ts +0 -24
  634. package/dist/plugin-sdk/src/agents/sandbox-tool-policy.d.ts +0 -8
  635. package/dist/plugin-sdk/src/agents/sandbox.d.ts +0 -8
  636. package/dist/plugin-sdk/src/agents/sanitize-for-prompt.d.ts +0 -21
  637. package/dist/plugin-sdk/src/agents/schema/clean-for-gemini.d.ts +0 -2
  638. package/dist/plugin-sdk/src/agents/schema/typebox.d.ts +0 -14
  639. package/dist/plugin-sdk/src/agents/session-dirs.d.ts +0 -3
  640. package/dist/plugin-sdk/src/agents/session-file-repair.d.ts +0 -11
  641. package/dist/plugin-sdk/src/agents/session-slug.d.ts +0 -1
  642. package/dist/plugin-sdk/src/agents/session-tool-result-guard-wrapper.d.ts +0 -19
  643. package/dist/plugin-sdk/src/agents/session-tool-result-guard.d.ts +0 -40
  644. package/dist/plugin-sdk/src/agents/session-transcript-repair.d.ts +0 -34
  645. package/dist/plugin-sdk/src/agents/session-write-lock.d.ts +0 -54
  646. package/dist/plugin-sdk/src/agents/shell-utils.d.ts +0 -9
  647. package/dist/plugin-sdk/src/agents/skills/agent-filter.d.ts +0 -6
  648. package/dist/plugin-sdk/src/agents/skills/bundled-context.d.ts +0 -6
  649. package/dist/plugin-sdk/src/agents/skills/bundled-dir.d.ts +0 -7
  650. package/dist/plugin-sdk/src/agents/skills/config.d.ts +0 -13
  651. package/dist/plugin-sdk/src/agents/skills/env-overrides.d.ts +0 -11
  652. package/dist/plugin-sdk/src/agents/skills/filter.d.ts +0 -3
  653. package/dist/plugin-sdk/src/agents/skills/frontmatter.d.ts +0 -6
  654. package/dist/plugin-sdk/src/agents/skills/local-loader.d.ts +0 -13
  655. package/dist/plugin-sdk/src/agents/skills/plugin-skills.d.ts +0 -5
  656. package/dist/plugin-sdk/src/agents/skills/refresh-state.d.ts +0 -15
  657. package/dist/plugin-sdk/src/agents/skills/refresh.d.ts +0 -8
  658. package/dist/plugin-sdk/src/agents/skills/serialize.d.ts +0 -1
  659. package/dist/plugin-sdk/src/agents/skills/skill-contract.d.ts +0 -27
  660. package/dist/plugin-sdk/src/agents/skills/source.d.ts +0 -2
  661. package/dist/plugin-sdk/src/agents/skills/types.d.ts +0 -105
  662. package/dist/plugin-sdk/src/agents/skills/workspace.d.ts +0 -54
  663. package/dist/plugin-sdk/src/agents/skills-clawhub.d.ts +0 -150
  664. package/dist/plugin-sdk/src/agents/skills-install-plan.d.ts +0 -25
  665. package/dist/plugin-sdk/src/agents/skills-install-trust.d.ts +0 -8
  666. package/dist/plugin-sdk/src/agents/skills-marketplace-policy.d.ts +0 -29
  667. package/dist/plugin-sdk/src/agents/skills-marketplace-scan.d.ts +0 -17
  668. package/dist/plugin-sdk/src/agents/skills-status.d.ts +0 -65
  669. package/dist/plugin-sdk/src/agents/skills.d.ts +0 -7
  670. package/dist/plugin-sdk/src/agents/spawned-context.d.ts +0 -30
  671. package/dist/plugin-sdk/src/agents/stable-stringify.d.ts +0 -1
  672. package/dist/plugin-sdk/src/agents/subagent-announce-dispatch.d.ts +0 -22
  673. package/dist/plugin-sdk/src/agents/subagent-announce-output.d.ts +0 -97
  674. package/dist/plugin-sdk/src/agents/subagent-announce-queue.d.ts +0 -24
  675. package/dist/plugin-sdk/src/agents/subagent-announce.d.ts +0 -51
  676. package/dist/plugin-sdk/src/agents/subagent-announce.runtime.d.ts +0 -4
  677. package/dist/plugin-sdk/src/agents/subagent-depth.d.ts +0 -11
  678. package/dist/plugin-sdk/src/agents/subagent-lifecycle-events.d.ts +0 -18
  679. package/dist/plugin-sdk/src/agents/subagent-registry-cleanup.d.ts +0 -25
  680. package/dist/plugin-sdk/src/agents/subagent-registry-completion.d.ts +0 -15
  681. package/dist/plugin-sdk/src/agents/subagent-registry-queries.d.ts +0 -17
  682. package/dist/plugin-sdk/src/agents/subagent-registry-state.d.ts +0 -7
  683. package/dist/plugin-sdk/src/agents/subagent-registry.d.ts +0 -67
  684. package/dist/plugin-sdk/src/agents/subagent-registry.store.d.ts +0 -5
  685. package/dist/plugin-sdk/src/agents/subagent-registry.types.d.ts +0 -62
  686. package/dist/plugin-sdk/src/agents/subagent-spawn.d.ts +0 -49
  687. package/dist/plugin-sdk/src/agents/synthetic-models.d.ts +0 -1
  688. package/dist/plugin-sdk/src/agents/system-prompt-cache-boundary.d.ts +0 -10
  689. package/dist/plugin-sdk/src/agents/system-prompt-params.d.ts +0 -30
  690. package/dist/plugin-sdk/src/agents/system-prompt-report.d.ts +0 -22
  691. package/dist/plugin-sdk/src/agents/system-prompt.d.ts +0 -77
  692. package/dist/plugin-sdk/src/agents/timeout.d.ts +0 -8
  693. package/dist/plugin-sdk/src/agents/together-models.d.ts +0 -1
  694. package/dist/plugin-sdk/src/agents/tool-call-id.d.ts +0 -29
  695. package/dist/plugin-sdk/src/agents/tool-catalog.d.ts +0 -35
  696. package/dist/plugin-sdk/src/agents/tool-description-presets.d.ts +0 -15
  697. package/dist/plugin-sdk/src/agents/tool-description-summary.d.ts +0 -11
  698. package/dist/plugin-sdk/src/agents/tool-display-common.d.ts +0 -70
  699. package/dist/plugin-sdk/src/agents/tool-display-config.d.ts +0 -11
  700. package/dist/plugin-sdk/src/agents/tool-display-exec-shell.d.ts +0 -17
  701. package/dist/plugin-sdk/src/agents/tool-display-exec.d.ts +0 -1
  702. package/dist/plugin-sdk/src/agents/tool-display.d.ts +0 -15
  703. package/dist/plugin-sdk/src/agents/tool-fs-policy.d.ts +0 -21
  704. package/dist/plugin-sdk/src/agents/tool-images.d.ts +0 -11
  705. package/dist/plugin-sdk/src/agents/tool-loop-detection.d.ts +0 -55
  706. package/dist/plugin-sdk/src/agents/tool-mutation.d.ts +0 -14
  707. package/dist/plugin-sdk/src/agents/tool-policy-match.d.ts +0 -3
  708. package/dist/plugin-sdk/src/agents/tool-policy-pipeline.d.ts +0 -32
  709. package/dist/plugin-sdk/src/agents/tool-policy-shared.d.ts +0 -11
  710. package/dist/plugin-sdk/src/agents/tool-policy.d.ts +0 -35
  711. package/dist/plugin-sdk/src/agents/tool-summaries.d.ts +0 -2
  712. package/dist/plugin-sdk/src/agents/tools/agent-step.d.ts +0 -23
  713. package/dist/plugin-sdk/src/agents/tools/agents-list-tool.d.ts +0 -6
  714. package/dist/plugin-sdk/src/agents/tools/browser-tool.d.ts +0 -5
  715. package/dist/plugin-sdk/src/agents/tools/browser-tool.schema.d.ts +0 -50
  716. package/dist/plugin-sdk/src/agents/tools/canvas-tool.d.ts +0 -5
  717. package/dist/plugin-sdk/src/agents/tools/common.d.ts +0 -86
  718. package/dist/plugin-sdk/src/agents/tools/cron-tool.d.ts +0 -11
  719. package/dist/plugin-sdk/src/agents/tools/diff-view-tool.d.ts +0 -2
  720. package/dist/plugin-sdk/src/agents/tools/discord-actions-guild.d.ts +0 -4
  721. package/dist/plugin-sdk/src/agents/tools/discord-actions-messaging.d.ts +0 -6
  722. package/dist/plugin-sdk/src/agents/tools/discord-actions-moderation-shared.d.ts +0 -13
  723. package/dist/plugin-sdk/src/agents/tools/discord-actions-moderation.d.ts +0 -4
  724. package/dist/plugin-sdk/src/agents/tools/discord-actions-presence.d.ts +0 -4
  725. package/dist/plugin-sdk/src/agents/tools/discord-actions.d.ts +0 -5
  726. package/dist/plugin-sdk/src/agents/tools/gateway-tool.d.ts +0 -14
  727. package/dist/plugin-sdk/src/agents/tools/gateway.d.ts +0 -20
  728. package/dist/plugin-sdk/src/agents/tools/image-tool.d.ts +0 -37
  729. package/dist/plugin-sdk/src/agents/tools/image-tool.helpers.d.ts +0 -21
  730. package/dist/plugin-sdk/src/agents/tools/marketplace-offer-draft-tool.d.ts +0 -5
  731. package/dist/plugin-sdk/src/agents/tools/memory-tool.d.ts +0 -10
  732. package/dist/plugin-sdk/src/agents/tools/message-tool.d.ts +0 -26
  733. package/dist/plugin-sdk/src/agents/tools/mining-tool.d.ts +0 -8
  734. package/dist/plugin-sdk/src/agents/tools/nodes-tool.d.ts +0 -13
  735. package/dist/plugin-sdk/src/agents/tools/nodes-utils.d.ts +0 -13
  736. package/dist/plugin-sdk/src/agents/tools/session-status-tool.d.ts +0 -7
  737. package/dist/plugin-sdk/src/agents/tools/sessions-access.d.ts +0 -42
  738. package/dist/plugin-sdk/src/agents/tools/sessions-announce-target.d.ts +0 -5
  739. package/dist/plugin-sdk/src/agents/tools/sessions-helpers.d.ts +0 -54
  740. package/dist/plugin-sdk/src/agents/tools/sessions-history-tool.d.ts +0 -11
  741. package/dist/plugin-sdk/src/agents/tools/sessions-list-tool.d.ts +0 -11
  742. package/dist/plugin-sdk/src/agents/tools/sessions-resolution.d.ts +0 -67
  743. package/dist/plugin-sdk/src/agents/tools/sessions-send-helpers.d.ts +0 -34
  744. package/dist/plugin-sdk/src/agents/tools/sessions-send-tool.a2a.d.ts +0 -20
  745. package/dist/plugin-sdk/src/agents/tools/sessions-send-tool.d.ts +0 -13
  746. package/dist/plugin-sdk/src/agents/tools/sessions-spawn-tool.d.ts +0 -16
  747. package/dist/plugin-sdk/src/agents/tools/slack-actions.d.ts +0 -15
  748. package/dist/plugin-sdk/src/agents/tools/subagents-tool.d.ts +0 -4
  749. package/dist/plugin-sdk/src/agents/tools/telegram-actions.d.ts +0 -7
  750. package/dist/plugin-sdk/src/agents/tools/tts-tool.d.ts +0 -7
  751. package/dist/plugin-sdk/src/agents/tools/wallet-action-tool.d.ts +0 -9
  752. package/dist/plugin-sdk/src/agents/tools/wallet-skill-policy.d.ts +0 -39
  753. package/dist/plugin-sdk/src/agents/tools/wallet-tool.d.ts +0 -9
  754. package/dist/plugin-sdk/src/agents/tools/web-fetch-utils.d.ts +0 -18
  755. package/dist/plugin-sdk/src/agents/tools/web-fetch-visibility.d.ts +0 -2
  756. package/dist/plugin-sdk/src/agents/tools/web-fetch.d.ts +0 -25
  757. package/dist/plugin-sdk/src/agents/tools/web-guarded-fetch.d.ts +0 -12
  758. package/dist/plugin-sdk/src/agents/tools/web-search.d.ts +0 -148
  759. package/dist/plugin-sdk/src/agents/tools/web-shared.d.ts +0 -24
  760. package/dist/plugin-sdk/src/agents/tools/web-tools.d.ts +0 -2
  761. package/dist/plugin-sdk/src/agents/tools/whatsapp-actions.d.ts +0 -3
  762. package/dist/plugin-sdk/src/agents/tools/whatsapp-target-auth.d.ts +0 -10
  763. package/dist/plugin-sdk/src/agents/tools-effective-inventory.d.ts +0 -49
  764. package/dist/plugin-sdk/src/agents/trace-base.d.ts +0 -10
  765. package/dist/plugin-sdk/src/agents/transcript-policy.d.ts +0 -25
  766. package/dist/plugin-sdk/src/agents/usage.d.ts +0 -65
  767. package/dist/plugin-sdk/src/agents/venice-models.d.ts +0 -7
  768. package/dist/plugin-sdk/src/agents/volc-models.shared.d.ts +0 -90
  769. package/dist/plugin-sdk/src/agents/workspace-dir.d.ts +0 -2
  770. package/dist/plugin-sdk/src/agents/workspace-dirs.d.ts +0 -2
  771. package/dist/plugin-sdk/src/agents/workspace-run.d.ts +0 -18
  772. package/dist/plugin-sdk/src/agents/workspace-templates.d.ts +0 -6
  773. package/dist/plugin-sdk/src/agents/workspace.d.ts +0 -45
  774. package/dist/plugin-sdk/src/auto-reply/chunk.d.ts +0 -45
  775. package/dist/plugin-sdk/src/auto-reply/command-auth.d.ts +0 -17
  776. package/dist/plugin-sdk/src/auto-reply/command-detection.d.ts +0 -13
  777. package/dist/plugin-sdk/src/auto-reply/commands-args.d.ts +0 -3
  778. package/dist/plugin-sdk/src/auto-reply/commands-registry.d.ts +0 -55
  779. package/dist/plugin-sdk/src/auto-reply/commands-registry.data.d.ts +0 -3
  780. package/dist/plugin-sdk/src/auto-reply/commands-registry.types.d.ts +0 -66
  781. package/dist/plugin-sdk/src/auto-reply/dispatch.d.ts +0 -32
  782. package/dist/plugin-sdk/src/auto-reply/envelope.d.ts +0 -58
  783. package/dist/plugin-sdk/src/auto-reply/fallback-state.d.ts +0 -55
  784. package/dist/plugin-sdk/src/auto-reply/group-activation.d.ts +0 -6
  785. package/dist/plugin-sdk/src/auto-reply/heartbeat-reply-payload.d.ts +0 -2
  786. package/dist/plugin-sdk/src/auto-reply/heartbeat.d.ts +0 -26
  787. package/dist/plugin-sdk/src/auto-reply/inbound-debounce.d.ts +0 -17
  788. package/dist/plugin-sdk/src/auto-reply/media-note.d.ts +0 -2
  789. package/dist/plugin-sdk/src/auto-reply/model-runtime.d.ts +0 -17
  790. package/dist/plugin-sdk/src/auto-reply/model.d.ts +0 -8
  791. package/dist/plugin-sdk/src/auto-reply/reply/abort-cutoff.d.ts +0 -28
  792. package/dist/plugin-sdk/src/auto-reply/reply/abort.d.ts +0 -33
  793. package/dist/plugin-sdk/src/auto-reply/reply/acp-projector.d.ts +0 -15
  794. package/dist/plugin-sdk/src/auto-reply/reply/agent-runner-execution.d.ts +0 -59
  795. package/dist/plugin-sdk/src/auto-reply/reply/agent-runner-helpers.d.ts +0 -15
  796. package/dist/plugin-sdk/src/auto-reply/reply/agent-runner-memory.d.ts +0 -20
  797. package/dist/plugin-sdk/src/auto-reply/reply/agent-runner-payloads.d.ts +0 -27
  798. package/dist/plugin-sdk/src/auto-reply/reply/agent-runner-utils.d.ts +0 -148
  799. package/dist/plugin-sdk/src/auto-reply/reply/agent-runner.d.ts +0 -38
  800. package/dist/plugin-sdk/src/auto-reply/reply/bash-command.d.ts +0 -19
  801. package/dist/plugin-sdk/src/auto-reply/reply/block-reply-coalescer.d.ts +0 -15
  802. package/dist/plugin-sdk/src/auto-reply/reply/block-reply-pipeline.d.ts +0 -31
  803. package/dist/plugin-sdk/src/auto-reply/reply/block-streaming.d.ts +0 -36
  804. package/dist/plugin-sdk/src/auto-reply/reply/body.d.ts +0 -10
  805. package/dist/plugin-sdk/src/auto-reply/reply/command-gates.d.ts +0 -18
  806. package/dist/plugin-sdk/src/auto-reply/reply/commands-acp/context.d.ts +0 -12
  807. package/dist/plugin-sdk/src/auto-reply/reply/commands-acp/diagnostics.d.ts +0 -4
  808. package/dist/plugin-sdk/src/auto-reply/reply/commands-acp/lifecycle.d.ts +0 -5
  809. package/dist/plugin-sdk/src/auto-reply/reply/commands-acp/runtime-options.d.ts +0 -9
  810. package/dist/plugin-sdk/src/auto-reply/reply/commands-acp/shared.d.ts +0 -97
  811. package/dist/plugin-sdk/src/auto-reply/reply/commands-acp/targets.d.ts +0 -12
  812. package/dist/plugin-sdk/src/auto-reply/reply/commands-acp.d.ts +0 -2
  813. package/dist/plugin-sdk/src/auto-reply/reply/commands-allowlist.d.ts +0 -2
  814. package/dist/plugin-sdk/src/auto-reply/reply/commands-approve.d.ts +0 -2
  815. package/dist/plugin-sdk/src/auto-reply/reply/commands-bash.d.ts +0 -2
  816. package/dist/plugin-sdk/src/auto-reply/reply/commands-compact.d.ts +0 -2
  817. package/dist/plugin-sdk/src/auto-reply/reply/commands-config.d.ts +0 -3
  818. package/dist/plugin-sdk/src/auto-reply/reply/commands-context-report.d.ts +0 -3
  819. package/dist/plugin-sdk/src/auto-reply/reply/commands-context.d.ts +0 -12
  820. package/dist/plugin-sdk/src/auto-reply/reply/commands-control.d.ts +0 -5
  821. package/dist/plugin-sdk/src/auto-reply/reply/commands-core.d.ts +0 -13
  822. package/dist/plugin-sdk/src/auto-reply/reply/commands-export-session.d.ts +0 -3
  823. package/dist/plugin-sdk/src/auto-reply/reply/commands-info.d.ts +0 -11
  824. package/dist/plugin-sdk/src/auto-reply/reply/commands-models.d.ts +0 -36
  825. package/dist/plugin-sdk/src/auto-reply/reply/commands-plugin.d.ts +0 -13
  826. package/dist/plugin-sdk/src/auto-reply/reply/commands-session-abort.d.ts +0 -3
  827. package/dist/plugin-sdk/src/auto-reply/reply/commands-session-store.d.ts +0 -13
  828. package/dist/plugin-sdk/src/auto-reply/reply/commands-session.d.ts +0 -8
  829. package/dist/plugin-sdk/src/auto-reply/reply/commands-setunset-standard.d.ts +0 -10
  830. package/dist/plugin-sdk/src/auto-reply/reply/commands-setunset.d.ts +0 -34
  831. package/dist/plugin-sdk/src/auto-reply/reply/commands-slash-parse.d.ts +0 -24
  832. package/dist/plugin-sdk/src/auto-reply/reply/commands-status.d.ts +0 -26
  833. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/action-agents.d.ts +0 -3
  834. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/action-focus.d.ts +0 -3
  835. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/action-help.d.ts +0 -2
  836. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/action-info.d.ts +0 -3
  837. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/action-kill.d.ts +0 -3
  838. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/action-list.d.ts +0 -3
  839. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/action-log.d.ts +0 -3
  840. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/action-send.d.ts +0 -3
  841. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/action-spawn.d.ts +0 -3
  842. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/action-unfocus.d.ts +0 -3
  843. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents/shared.d.ts +0 -81
  844. package/dist/plugin-sdk/src/auto-reply/reply/commands-subagents.d.ts +0 -4
  845. package/dist/plugin-sdk/src/auto-reply/reply/commands-system-prompt.d.ts +0 -14
  846. package/dist/plugin-sdk/src/auto-reply/reply/commands-tts.d.ts +0 -2
  847. package/dist/plugin-sdk/src/auto-reply/reply/commands-types.d.ts +0 -63
  848. package/dist/plugin-sdk/src/auto-reply/reply/commands.d.ts +0 -4
  849. package/dist/plugin-sdk/src/auto-reply/reply/config-commands.d.ts +0 -15
  850. package/dist/plugin-sdk/src/auto-reply/reply/config-value.d.ts +0 -4
  851. package/dist/plugin-sdk/src/auto-reply/reply/debug-commands.d.ts +0 -16
  852. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.auth.d.ts +0 -19
  853. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.d.ts +0 -6
  854. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.fast-lane.d.ts +0 -7
  855. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.impl.d.ts +0 -3
  856. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.levels.d.ts +0 -20
  857. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.model-picker.d.ts +0 -13
  858. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.model.d.ts +0 -44
  859. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.params.d.ts +0 -51
  860. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.parse.d.ts +0 -62
  861. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.persist.d.ts +0 -37
  862. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.queue-validation.d.ts +0 -10
  863. package/dist/plugin-sdk/src/auto-reply/reply/directive-handling.shared.d.ts +0 -28
  864. package/dist/plugin-sdk/src/auto-reply/reply/directive-parsing.d.ts +0 -5
  865. package/dist/plugin-sdk/src/auto-reply/reply/directives.d.ts +0 -38
  866. package/dist/plugin-sdk/src/auto-reply/reply/dispatch-acp.d.ts +0 -30
  867. package/dist/plugin-sdk/src/auto-reply/reply/dispatch-from-config.d.ts +0 -16
  868. package/dist/plugin-sdk/src/auto-reply/reply/dispatcher-registry.d.ts +0 -24
  869. package/dist/plugin-sdk/src/auto-reply/reply/elevated-allowlist-matcher.d.ts +0 -20
  870. package/dist/plugin-sdk/src/auto-reply/reply/elevated-unavailable.d.ts +0 -8
  871. package/dist/plugin-sdk/src/auto-reply/reply/exec/directive.d.ts +0 -20
  872. package/dist/plugin-sdk/src/auto-reply/reply/exec.d.ts +0 -1
  873. package/dist/plugin-sdk/src/auto-reply/reply/followup-runner.d.ts +0 -16
  874. package/dist/plugin-sdk/src/auto-reply/reply/get-reply-directives-apply.d.ts +0 -64
  875. package/dist/plugin-sdk/src/auto-reply/reply/get-reply-directives-utils.d.ts +0 -3
  876. package/dist/plugin-sdk/src/auto-reply/reply/get-reply-directives.d.ts +0 -92
  877. package/dist/plugin-sdk/src/auto-reply/reply/get-reply-inline-actions.d.ts +0 -59
  878. package/dist/plugin-sdk/src/auto-reply/reply/get-reply-run.d.ts +0 -69
  879. package/dist/plugin-sdk/src/auto-reply/reply/get-reply.d.ts +0 -4
  880. package/dist/plugin-sdk/src/auto-reply/reply/groups.d.ts +0 -26
  881. package/dist/plugin-sdk/src/auto-reply/reply/history.d.ts +0 -72
  882. package/dist/plugin-sdk/src/auto-reply/reply/inbound-context.d.ts +0 -8
  883. package/dist/plugin-sdk/src/auto-reply/reply/inbound-dedupe.d.ts +0 -8
  884. package/dist/plugin-sdk/src/auto-reply/reply/inbound-meta.d.ts +0 -3
  885. package/dist/plugin-sdk/src/auto-reply/reply/inbound-text.d.ts +0 -2
  886. package/dist/plugin-sdk/src/auto-reply/reply/line-directives.d.ts +0 -22
  887. package/dist/plugin-sdk/src/auto-reply/reply/memory-flush.d.ts +0 -28
  888. package/dist/plugin-sdk/src/auto-reply/reply/mentions.d.ts +0 -19
  889. package/dist/plugin-sdk/src/auto-reply/reply/model-selection.d.ts +0 -67
  890. package/dist/plugin-sdk/src/auto-reply/reply/normalize-reply.d.ts +0 -13
  891. package/dist/plugin-sdk/src/auto-reply/reply/origin-routing.d.ts +0 -13
  892. package/dist/plugin-sdk/src/auto-reply/reply/post-compaction-audit.d.ts +0 -26
  893. package/dist/plugin-sdk/src/auto-reply/reply/post-compaction-context.d.ts +0 -12
  894. package/dist/plugin-sdk/src/auto-reply/reply/provider-dispatcher.d.ts +0 -19
  895. package/dist/plugin-sdk/src/auto-reply/reply/queue/cleanup.d.ts +0 -11
  896. package/dist/plugin-sdk/src/auto-reply/reply/queue/directive.d.ts +0 -15
  897. package/dist/plugin-sdk/src/auto-reply/reply/queue/drain.d.ts +0 -2
  898. package/dist/plugin-sdk/src/auto-reply/reply/queue/enqueue.d.ts +0 -3
  899. package/dist/plugin-sdk/src/auto-reply/reply/queue/normalize.d.ts +0 -3
  900. package/dist/plugin-sdk/src/auto-reply/reply/queue/settings.d.ts +0 -2
  901. package/dist/plugin-sdk/src/auto-reply/reply/queue/state.d.ts +0 -20
  902. package/dist/plugin-sdk/src/auto-reply/reply/queue/types.d.ts +0 -85
  903. package/dist/plugin-sdk/src/auto-reply/reply/queue-policy.d.ts +0 -8
  904. package/dist/plugin-sdk/src/auto-reply/reply/queue.d.ts +0 -8
  905. package/dist/plugin-sdk/src/auto-reply/reply/reply-delivery.d.ts +0 -27
  906. package/dist/plugin-sdk/src/auto-reply/reply/reply-directives.d.ts +0 -14
  907. package/dist/plugin-sdk/src/auto-reply/reply/reply-dispatcher.d.ts +0 -54
  908. package/dist/plugin-sdk/src/auto-reply/reply/reply-elevated.d.ts +0 -16
  909. package/dist/plugin-sdk/src/auto-reply/reply/reply-inline.d.ts +0 -8
  910. package/dist/plugin-sdk/src/auto-reply/reply/reply-payloads.d.ts +0 -27
  911. package/dist/plugin-sdk/src/auto-reply/reply/reply-reference.d.ts +0 -22
  912. package/dist/plugin-sdk/src/auto-reply/reply/reply-tags.d.ts +0 -6
  913. package/dist/plugin-sdk/src/auto-reply/reply/reply-threading.d.ts +0 -9
  914. package/dist/plugin-sdk/src/auto-reply/reply/response-prefix-template.d.ts +0 -51
  915. package/dist/plugin-sdk/src/auto-reply/reply/route-reply.d.ts +0 -56
  916. package/dist/plugin-sdk/src/auto-reply/reply/session-reset-model.d.ts +0 -24
  917. package/dist/plugin-sdk/src/auto-reply/reply/session-reset-prompt.d.ts +0 -1
  918. package/dist/plugin-sdk/src/auto-reply/reply/session-run-accounting.d.ts +0 -12
  919. package/dist/plugin-sdk/src/auto-reply/reply/session-updates.d.ts +0 -34
  920. package/dist/plugin-sdk/src/auto-reply/reply/session-usage.d.ts +0 -21
  921. package/dist/plugin-sdk/src/auto-reply/reply/session.d.ts +0 -26
  922. package/dist/plugin-sdk/src/auto-reply/reply/stage-sandbox-media.d.ts +0 -9
  923. package/dist/plugin-sdk/src/auto-reply/reply/streaming-directives.d.ts +0 -10
  924. package/dist/plugin-sdk/src/auto-reply/reply/strip-inbound-meta.d.ts +0 -27
  925. package/dist/plugin-sdk/src/auto-reply/reply/subagents-utils.d.ts +0 -27
  926. package/dist/plugin-sdk/src/auto-reply/reply/typing-mode.d.ts +0 -30
  927. package/dist/plugin-sdk/src/auto-reply/reply/typing-policy.d.ts +0 -13
  928. package/dist/plugin-sdk/src/auto-reply/reply/typing.d.ts +0 -18
  929. package/dist/plugin-sdk/src/auto-reply/reply/untrusted-context.d.ts +0 -1
  930. package/dist/plugin-sdk/src/auto-reply/reply.d.ts +0 -6
  931. package/dist/plugin-sdk/src/auto-reply/send-policy.d.ts +0 -6
  932. package/dist/plugin-sdk/src/auto-reply/skill-commands.d.ts +0 -19
  933. package/dist/plugin-sdk/src/auto-reply/status.d.ts +0 -60
  934. package/dist/plugin-sdk/src/auto-reply/templating.d.ts +0 -161
  935. package/dist/plugin-sdk/src/auto-reply/thinking.d.ts +0 -16
  936. package/dist/plugin-sdk/src/auto-reply/tokens.d.ts +0 -4
  937. package/dist/plugin-sdk/src/auto-reply/tool-meta.d.ts +0 -8
  938. package/dist/plugin-sdk/src/auto-reply/types.d.ts +0 -85
  939. package/dist/plugin-sdk/src/brand.d.ts +0 -6
  940. package/dist/plugin-sdk/src/browser/bridge-auth-registry.d.ts +0 -8
  941. package/dist/plugin-sdk/src/browser/bridge-server.d.ts +0 -19
  942. package/dist/plugin-sdk/src/browser/cdp.d.ts +0 -125
  943. package/dist/plugin-sdk/src/browser/cdp.helpers.d.ts +0 -13
  944. package/dist/plugin-sdk/src/browser/chrome.d.ts +0 -20
  945. package/dist/plugin-sdk/src/browser/chrome.executables.d.ts +0 -9
  946. package/dist/plugin-sdk/src/browser/chrome.profile-decoration.d.ts +0 -10
  947. package/dist/plugin-sdk/src/browser/client-actions-core.d.ts +0 -142
  948. package/dist/plugin-sdk/src/browser/client-actions-observe.d.ts +0 -68
  949. package/dist/plugin-sdk/src/browser/client-actions-state.d.ts +0 -90
  950. package/dist/plugin-sdk/src/browser/client-actions-types.d.ts +0 -18
  951. package/dist/plugin-sdk/src/browser/client-actions-url.d.ts +0 -2
  952. package/dist/plugin-sdk/src/browser/client-actions.d.ts +0 -4
  953. package/dist/plugin-sdk/src/browser/client-fetch.d.ts +0 -20
  954. package/dist/plugin-sdk/src/browser/client.d.ts +0 -147
  955. package/dist/plugin-sdk/src/browser/config.d.ts +0 -43
  956. package/dist/plugin-sdk/src/browser/constants.d.ts +0 -8
  957. package/dist/plugin-sdk/src/browser/control-auth.d.ts +0 -13
  958. package/dist/plugin-sdk/src/browser/control-service.d.ts +0 -5
  959. package/dist/plugin-sdk/src/browser/csrf.d.ts +0 -8
  960. package/dist/plugin-sdk/src/browser/extension-relay-auth.d.ts +0 -8
  961. package/dist/plugin-sdk/src/browser/extension-relay.d.ts +0 -15
  962. package/dist/plugin-sdk/src/browser/form-fields.d.ts +0 -8
  963. package/dist/plugin-sdk/src/browser/http-auth.d.ts +0 -5
  964. package/dist/plugin-sdk/src/browser/navigation-guard.d.ts +0 -21
  965. package/dist/plugin-sdk/src/browser/paths.d.ts +0 -61
  966. package/dist/plugin-sdk/src/browser/profiles-service.d.ts +0 -25
  967. package/dist/plugin-sdk/src/browser/profiles.d.ts +0 -30
  968. package/dist/plugin-sdk/src/browser/proxy-files.d.ts +0 -7
  969. package/dist/plugin-sdk/src/browser/pw-ai-module.d.ts +0 -6
  970. package/dist/plugin-sdk/src/browser/pw-ai-state.d.ts +0 -2
  971. package/dist/plugin-sdk/src/browser/pw-ai.d.ts +0 -2
  972. package/dist/plugin-sdk/src/browser/pw-role-snapshot.d.ts +0 -35
  973. package/dist/plugin-sdk/src/browser/pw-session.d.ts +0 -162
  974. package/dist/plugin-sdk/src/browser/pw-tools-core.activity.d.ts +0 -21
  975. package/dist/plugin-sdk/src/browser/pw-tools-core.d.ts +0 -8
  976. package/dist/plugin-sdk/src/browser/pw-tools-core.downloads.d.ts +0 -34
  977. package/dist/plugin-sdk/src/browser/pw-tools-core.interactions.d.ts +0 -114
  978. package/dist/plugin-sdk/src/browser/pw-tools-core.responses.d.ts +0 -13
  979. package/dist/plugin-sdk/src/browser/pw-tools-core.shared.d.ts +0 -6
  980. package/dist/plugin-sdk/src/browser/pw-tools-core.snapshot.d.ts +0 -66
  981. package/dist/plugin-sdk/src/browser/pw-tools-core.state.d.ts +0 -46
  982. package/dist/plugin-sdk/src/browser/pw-tools-core.storage.d.ts +0 -47
  983. package/dist/plugin-sdk/src/browser/pw-tools-core.trace.d.ts +0 -12
  984. package/dist/plugin-sdk/src/browser/resolved-config-refresh.d.ts +0 -12
  985. package/dist/plugin-sdk/src/browser/routes/agent.act.d.ts +0 -3
  986. package/dist/plugin-sdk/src/browser/routes/agent.act.download.d.ts +0 -3
  987. package/dist/plugin-sdk/src/browser/routes/agent.act.hooks.d.ts +0 -3
  988. package/dist/plugin-sdk/src/browser/routes/agent.act.shared.d.ts +0 -10
  989. package/dist/plugin-sdk/src/browser/routes/agent.d.ts +0 -3
  990. package/dist/plugin-sdk/src/browser/routes/agent.debug.d.ts +0 -3
  991. package/dist/plugin-sdk/src/browser/routes/agent.shared.d.ts +0 -37
  992. package/dist/plugin-sdk/src/browser/routes/agent.snapshot.d.ts +0 -3
  993. package/dist/plugin-sdk/src/browser/routes/agent.storage.d.ts +0 -14
  994. package/dist/plugin-sdk/src/browser/routes/basic.d.ts +0 -3
  995. package/dist/plugin-sdk/src/browser/routes/dispatcher.d.ts +0 -16
  996. package/dist/plugin-sdk/src/browser/routes/index.d.ts +0 -3
  997. package/dist/plugin-sdk/src/browser/routes/output-paths.d.ts +0 -10
  998. package/dist/plugin-sdk/src/browser/routes/path-output.d.ts +0 -1
  999. package/dist/plugin-sdk/src/browser/routes/tabs.d.ts +0 -3
  1000. package/dist/plugin-sdk/src/browser/routes/types.d.ts +0 -20
  1001. package/dist/plugin-sdk/src/browser/routes/utils.d.ts +0 -15
  1002. package/dist/plugin-sdk/src/browser/runtime-dependency.d.ts +0 -3
  1003. package/dist/plugin-sdk/src/browser/screenshot.d.ts +0 -9
  1004. package/dist/plugin-sdk/src/browser/server-context.d.ts +0 -4
  1005. package/dist/plugin-sdk/src/browser/server-context.types.d.ts +0 -65
  1006. package/dist/plugin-sdk/src/browser/server-lifecycle.d.ts +0 -10
  1007. package/dist/plugin-sdk/src/browser/server-middleware.d.ts +0 -6
  1008. package/dist/plugin-sdk/src/browser/target-id.d.ts +0 -11
  1009. package/dist/plugin-sdk/src/browser/trash.d.ts +0 -1
  1010. package/dist/plugin-sdk/src/canvas-host/a2ui.d.ts +0 -6
  1011. package/dist/plugin-sdk/src/canvas-host/file-resolver.d.ts +0 -3
  1012. package/dist/plugin-sdk/src/canvas-host/server.d.ts +0 -36
  1013. package/dist/plugin-sdk/src/channel-web.d.ts +0 -6
  1014. package/dist/plugin-sdk/src/channels/account-snapshot-fields.d.ts +0 -2
  1015. package/dist/plugin-sdk/src/channels/account-summary.d.ts +0 -17
  1016. package/dist/plugin-sdk/src/channels/ack-reactions.d.ts +0 -29
  1017. package/dist/plugin-sdk/src/channels/allow-from.d.ts +0 -16
  1018. package/dist/plugin-sdk/src/channels/allowlist-match.d.ts +0 -16
  1019. package/dist/plugin-sdk/src/channels/allowlists/resolve-utils.d.ts +0 -33
  1020. package/dist/plugin-sdk/src/channels/channel-config.d.ts +0 -39
  1021. package/dist/plugin-sdk/src/channels/chat-type.d.ts +0 -2
  1022. package/dist/plugin-sdk/src/channels/command-gating.d.ts +0 -20
  1023. package/dist/plugin-sdk/src/channels/conversation-label.d.ts +0 -2
  1024. package/dist/plugin-sdk/src/channels/dock.d.ts +0 -25
  1025. package/dist/plugin-sdk/src/channels/draft-stream-controls.d.ts +0 -54
  1026. package/dist/plugin-sdk/src/channels/draft-stream-loop.d.ts +0 -13
  1027. package/dist/plugin-sdk/src/channels/ids.d.ts +0 -9
  1028. package/dist/plugin-sdk/src/channels/location.d.ts +0 -21
  1029. package/dist/plugin-sdk/src/channels/logging.d.ts +0 -20
  1030. package/dist/plugin-sdk/src/channels/mention-gating.d.ts +0 -27
  1031. package/dist/plugin-sdk/src/channels/model-overrides.d.ts +0 -18
  1032. package/dist/plugin-sdk/src/channels/plugins/account-action-gate.d.ts +0 -5
  1033. package/dist/plugin-sdk/src/channels/plugins/account-helpers.d.ts +0 -6
  1034. package/dist/plugin-sdk/src/channels/plugins/actions/discord/handle-action.d.ts +0 -3
  1035. package/dist/plugin-sdk/src/channels/plugins/actions/discord/handle-action.guild-admin.d.ts +0 -9
  1036. package/dist/plugin-sdk/src/channels/plugins/actions/discord.d.ts +0 -2
  1037. package/dist/plugin-sdk/src/channels/plugins/actions/shared.d.ts +0 -7
  1038. package/dist/plugin-sdk/src/channels/plugins/actions/signal.d.ts +0 -2
  1039. package/dist/plugin-sdk/src/channels/plugins/actions/telegram.d.ts +0 -2
  1040. package/dist/plugin-sdk/src/channels/plugins/agent-tools/whatsapp-login.d.ts +0 -2
  1041. package/dist/plugin-sdk/src/channels/plugins/allowlist-match.d.ts +0 -2
  1042. package/dist/plugin-sdk/src/channels/plugins/bluebubbles-actions.d.ts +0 -48
  1043. package/dist/plugin-sdk/src/channels/plugins/catalog.d.ts +0 -50
  1044. package/dist/plugin-sdk/src/channels/plugins/channel-config.d.ts +0 -2
  1045. package/dist/plugin-sdk/src/channels/plugins/config-helpers.d.ts +0 -14
  1046. package/dist/plugin-sdk/src/channels/plugins/config-schema.d.ts +0 -3
  1047. package/dist/plugin-sdk/src/channels/plugins/config-writes.d.ts +0 -7
  1048. package/dist/plugin-sdk/src/channels/plugins/directory-config.d.ts +0 -16
  1049. package/dist/plugin-sdk/src/channels/plugins/group-mentions.d.ts +0 -18
  1050. package/dist/plugin-sdk/src/channels/plugins/helpers.d.ts +0 -8
  1051. package/dist/plugin-sdk/src/channels/plugins/index.d.ts +0 -8
  1052. package/dist/plugin-sdk/src/channels/plugins/media-limits.d.ts +0 -9
  1053. package/dist/plugin-sdk/src/channels/plugins/media-payload.d.ts +0 -15
  1054. package/dist/plugin-sdk/src/channels/plugins/message-action-names.d.ts +0 -2
  1055. package/dist/plugin-sdk/src/channels/plugins/message-actions.d.ts +0 -15
  1056. package/dist/plugin-sdk/src/channels/plugins/normalize/discord.d.ts +0 -14
  1057. package/dist/plugin-sdk/src/channels/plugins/normalize/imessage.d.ts +0 -2
  1058. package/dist/plugin-sdk/src/channels/plugins/normalize/shared.d.ts +0 -6
  1059. package/dist/plugin-sdk/src/channels/plugins/normalize/signal.d.ts +0 -2
  1060. package/dist/plugin-sdk/src/channels/plugins/normalize/slack.d.ts +0 -2
  1061. package/dist/plugin-sdk/src/channels/plugins/normalize/telegram.d.ts +0 -2
  1062. package/dist/plugin-sdk/src/channels/plugins/normalize/whatsapp.d.ts +0 -3
  1063. package/dist/plugin-sdk/src/channels/plugins/onboarding/channel-access-configure.d.ts +0 -21
  1064. package/dist/plugin-sdk/src/channels/plugins/onboarding/channel-access.d.ts +0 -31
  1065. package/dist/plugin-sdk/src/channels/plugins/onboarding/discord.d.ts +0 -2
  1066. package/dist/plugin-sdk/src/channels/plugins/onboarding/helpers.d.ts +0 -177
  1067. package/dist/plugin-sdk/src/channels/plugins/onboarding/imessage.d.ts +0 -6
  1068. package/dist/plugin-sdk/src/channels/plugins/onboarding/signal.d.ts +0 -7
  1069. package/dist/plugin-sdk/src/channels/plugins/onboarding/slack.d.ts +0 -2
  1070. package/dist/plugin-sdk/src/channels/plugins/onboarding/telegram.d.ts +0 -4
  1071. package/dist/plugin-sdk/src/channels/plugins/onboarding/whatsapp.d.ts +0 -2
  1072. package/dist/plugin-sdk/src/channels/plugins/onboarding-types.d.ts +0 -149
  1073. package/dist/plugin-sdk/src/channels/plugins/outbound/load.d.ts +0 -2
  1074. package/dist/plugin-sdk/src/channels/plugins/pairing-message.d.ts +0 -1
  1075. package/dist/plugin-sdk/src/channels/plugins/pairing.d.ts +0 -16
  1076. package/dist/plugin-sdk/src/channels/plugins/registry-loader.d.ts +0 -5
  1077. package/dist/plugin-sdk/src/channels/plugins/setup-helpers.d.ts +0 -21
  1078. package/dist/plugin-sdk/src/channels/plugins/status-issues/bluebubbles.d.ts +0 -2
  1079. package/dist/plugin-sdk/src/channels/plugins/status-issues/discord.d.ts +0 -2
  1080. package/dist/plugin-sdk/src/channels/plugins/status-issues/shared.d.ts +0 -29
  1081. package/dist/plugin-sdk/src/channels/plugins/status-issues/telegram.d.ts +0 -2
  1082. package/dist/plugin-sdk/src/channels/plugins/status-issues/whatsapp.d.ts +0 -2
  1083. package/dist/plugin-sdk/src/channels/plugins/types.adapters.d.ts +0 -294
  1084. package/dist/plugin-sdk/src/channels/plugins/types.core.d.ts +0 -357
  1085. package/dist/plugin-sdk/src/channels/plugins/types.d.ts +0 -6
  1086. package/dist/plugin-sdk/src/channels/plugins/types.plugin.d.ts +0 -54
  1087. package/dist/plugin-sdk/src/channels/plugins/whatsapp-heartbeat.d.ts +0 -11
  1088. package/dist/plugin-sdk/src/channels/plugins/whatsapp-shared.d.ts +0 -5
  1089. package/dist/plugin-sdk/src/channels/registry.d.ts +0 -12
  1090. package/dist/plugin-sdk/src/channels/reply-prefix.d.ts +0 -24
  1091. package/dist/plugin-sdk/src/channels/sender-label.d.ts +0 -9
  1092. package/dist/plugin-sdk/src/channels/session.d.ts +0 -18
  1093. package/dist/plugin-sdk/src/channels/status-reactions.d.ts +0 -62
  1094. package/dist/plugin-sdk/src/channels/targets.d.ts +0 -42
  1095. package/dist/plugin-sdk/src/channels/telegram/allow-from.d.ts +0 -2
  1096. package/dist/plugin-sdk/src/channels/telegram/api.d.ts +0 -5
  1097. package/dist/plugin-sdk/src/channels/thread-bindings-messages.d.ts +0 -19
  1098. package/dist/plugin-sdk/src/channels/thread-bindings-policy.d.ts +0 -68
  1099. package/dist/plugin-sdk/src/channels/typing-lifecycle.d.ts +0 -12
  1100. package/dist/plugin-sdk/src/channels/typing-start-guard.d.ts +0 -13
  1101. package/dist/plugin-sdk/src/channels/typing.d.ts +0 -18
  1102. package/dist/plugin-sdk/src/channels/web/index.d.ts +0 -1
  1103. package/dist/plugin-sdk/src/cli/argv.d.ts +0 -17
  1104. package/dist/plugin-sdk/src/cli/banner.d.ts +0 -11
  1105. package/dist/plugin-sdk/src/cli/cli-name.d.ts +0 -3
  1106. package/dist/plugin-sdk/src/cli/cli-utils.d.ts +0 -19
  1107. package/dist/plugin-sdk/src/cli/command-format.d.ts +0 -1
  1108. package/dist/plugin-sdk/src/cli/deps.d.ts +0 -18
  1109. package/dist/plugin-sdk/src/cli/help-format.d.ts +0 -5
  1110. package/dist/plugin-sdk/src/cli/memory-cli.d.ts +0 -21
  1111. package/dist/plugin-sdk/src/cli/nodes-camera.d.ts +0 -38
  1112. package/dist/plugin-sdk/src/cli/nodes-canvas.d.ts +0 -10
  1113. package/dist/plugin-sdk/src/cli/nodes-media-utils.d.ts +0 -13
  1114. package/dist/plugin-sdk/src/cli/nodes-run.d.ts +0 -3
  1115. package/dist/plugin-sdk/src/cli/nodes-screen.d.ts +0 -18
  1116. package/dist/plugin-sdk/src/cli/outbound-send-deps.d.ts +0 -4
  1117. package/dist/plugin-sdk/src/cli/outbound-send-mapping.d.ts +0 -10
  1118. package/dist/plugin-sdk/src/cli/parse-bytes.d.ts +0 -4
  1119. package/dist/plugin-sdk/src/cli/parse-duration.d.ts +0 -4
  1120. package/dist/plugin-sdk/src/cli/parse-timeout.d.ts +0 -1
  1121. package/dist/plugin-sdk/src/cli/profile-utils.d.ts +0 -2
  1122. package/dist/plugin-sdk/src/cli/progress.d.ts +0 -24
  1123. package/dist/plugin-sdk/src/cli/prompt.d.ts +0 -1
  1124. package/dist/plugin-sdk/src/cli/wait.d.ts +0 -1
  1125. package/dist/plugin-sdk/src/commands/agent/attempt.d.ts +0 -39
  1126. package/dist/plugin-sdk/src/commands/agent/delivery.d.ts +0 -21
  1127. package/dist/plugin-sdk/src/commands/agent/lifecycle.d.ts +0 -17
  1128. package/dist/plugin-sdk/src/commands/agent/run-context.d.ts +0 -2
  1129. package/dist/plugin-sdk/src/commands/agent/session-store.d.ts +0 -17
  1130. package/dist/plugin-sdk/src/commands/agent/session.d.ts +0 -33
  1131. package/dist/plugin-sdk/src/commands/agent/strict-agentic-contract.d.ts +0 -44
  1132. package/dist/plugin-sdk/src/commands/agent/types.d.ts +0 -77
  1133. package/dist/plugin-sdk/src/commands/agent.d.ts +0 -7
  1134. package/dist/plugin-sdk/src/commands/agents.config.d.ts +0 -42
  1135. package/dist/plugin-sdk/src/commands/channel-account-context.d.ts +0 -10
  1136. package/dist/plugin-sdk/src/commands/cleanup-utils.d.ts +0 -37
  1137. package/dist/plugin-sdk/src/commands/daemon-runtime.d.ts +0 -8
  1138. package/dist/plugin-sdk/src/commands/gateway-presence.d.ts +0 -7
  1139. package/dist/plugin-sdk/src/commands/health.d.ts +0 -74
  1140. package/dist/plugin-sdk/src/commands/hosted-dashboard-probe.d.ts +0 -40
  1141. package/dist/plugin-sdk/src/commands/oauth-flow.d.ts +0 -21
  1142. package/dist/plugin-sdk/src/commands/onboard-helpers.d.ts +0 -84
  1143. package/dist/plugin-sdk/src/commands/onboard-types.d.ts +0 -119
  1144. package/dist/plugin-sdk/src/commands/signal-install.d.ts +0 -30
  1145. package/dist/plugin-sdk/src/commands/status-all/agents.d.ts +0 -16
  1146. package/dist/plugin-sdk/src/commands/status-all/channels.d.ts +0 -19
  1147. package/dist/plugin-sdk/src/commands/status-all/diagnosis.d.ts +0 -62
  1148. package/dist/plugin-sdk/src/commands/status-all/format.d.ts +0 -7
  1149. package/dist/plugin-sdk/src/commands/status-all/gateway.d.ts +0 -5
  1150. package/dist/plugin-sdk/src/commands/status-all/report-lines.d.ts +0 -44
  1151. package/dist/plugin-sdk/src/commands/status-all.d.ts +0 -4
  1152. package/dist/plugin-sdk/src/commands/status.acpx-bridge.d.ts +0 -19
  1153. package/dist/plugin-sdk/src/commands/status.agent-local.d.ts +0 -16
  1154. package/dist/plugin-sdk/src/commands/status.command.d.ts +0 -9
  1155. package/dist/plugin-sdk/src/commands/status.d.ts +0 -3
  1156. package/dist/plugin-sdk/src/commands/status.daemon.d.ts +0 -9
  1157. package/dist/plugin-sdk/src/commands/status.format.d.ts +0 -12
  1158. package/dist/plugin-sdk/src/commands/status.gateway-probe.d.ts +0 -6
  1159. package/dist/plugin-sdk/src/commands/status.link-channel.d.ts +0 -10
  1160. package/dist/plugin-sdk/src/commands/status.scan.d.ts +0 -46
  1161. package/dist/plugin-sdk/src/commands/status.strict-agentic.d.ts +0 -18
  1162. package/dist/plugin-sdk/src/commands/status.summary.d.ts +0 -5
  1163. package/dist/plugin-sdk/src/commands/status.types.d.ts +0 -67
  1164. package/dist/plugin-sdk/src/commands/status.update.d.ts +0 -23
  1165. package/dist/plugin-sdk/src/commands/text-format.d.ts +0 -1
  1166. package/dist/plugin-sdk/src/commands/wallet.d.ts +0 -300
  1167. package/dist/plugin-sdk/src/commands/xai-oauth.d.ts +0 -17
  1168. package/dist/plugin-sdk/src/config/agent-dirs.d.ts +0 -14
  1169. package/dist/plugin-sdk/src/config/agent-limits.d.ts +0 -6
  1170. package/dist/plugin-sdk/src/config/backup-rotation.d.ts +0 -5
  1171. package/dist/plugin-sdk/src/config/cache-utils.d.ts +0 -6
  1172. package/dist/plugin-sdk/src/config/channel-capabilities.d.ts +0 -6
  1173. package/dist/plugin-sdk/src/config/commands.d.ts +0 -25
  1174. package/dist/plugin-sdk/src/config/config-paths.d.ts +0 -10
  1175. package/dist/plugin-sdk/src/config/config.d.ts +0 -7
  1176. package/dist/plugin-sdk/src/config/dangerous-name-matching.d.ts +0 -12
  1177. package/dist/plugin-sdk/src/config/defaults.d.ts +0 -19
  1178. package/dist/plugin-sdk/src/config/discord-preview-streaming.d.ts +0 -25
  1179. package/dist/plugin-sdk/src/config/env-preserve.d.ts +0 -10
  1180. package/dist/plugin-sdk/src/config/env-substitution.d.ts +0 -36
  1181. package/dist/plugin-sdk/src/config/env-vars.d.ts +0 -6
  1182. package/dist/plugin-sdk/src/config/group-policy.d.ts +0 -49
  1183. package/dist/plugin-sdk/src/config/includes-scan.d.ts +0 -4
  1184. package/dist/plugin-sdk/src/config/includes.d.ts +0 -43
  1185. package/dist/plugin-sdk/src/config/io.d.ts +0 -63
  1186. package/dist/plugin-sdk/src/config/legacy-migrate.d.ts +0 -5
  1187. package/dist/plugin-sdk/src/config/legacy.d.ts +0 -6
  1188. package/dist/plugin-sdk/src/config/legacy.migrations.d.ts +0 -1
  1189. package/dist/plugin-sdk/src/config/legacy.migrations.part-1.d.ts +0 -2
  1190. package/dist/plugin-sdk/src/config/legacy.migrations.part-2.d.ts +0 -2
  1191. package/dist/plugin-sdk/src/config/legacy.migrations.part-3.d.ts +0 -2
  1192. package/dist/plugin-sdk/src/config/legacy.rules.d.ts +0 -2
  1193. package/dist/plugin-sdk/src/config/legacy.shared.d.ts +0 -19
  1194. package/dist/plugin-sdk/src/config/markdown-tables.d.ts +0 -7
  1195. package/dist/plugin-sdk/src/config/merge-config.d.ts +0 -7
  1196. package/dist/plugin-sdk/src/config/merge-patch.d.ts +0 -5
  1197. package/dist/plugin-sdk/src/config/model-input.d.ts +0 -11
  1198. package/dist/plugin-sdk/src/config/normalize-exec-safe-bin.d.ts +0 -2
  1199. package/dist/plugin-sdk/src/config/normalize-paths.d.ts +0 -8
  1200. package/dist/plugin-sdk/src/config/paths.d.ts +0 -57
  1201. package/dist/plugin-sdk/src/config/plugin-auto-enable.d.ts +0 -15
  1202. package/dist/plugin-sdk/src/config/plugins-allowlist.d.ts +0 -12
  1203. package/dist/plugin-sdk/src/config/port-defaults.d.ts +0 -13
  1204. package/dist/plugin-sdk/src/config/prototype-keys.d.ts +0 -1
  1205. package/dist/plugin-sdk/src/config/runtime-group-policy.d.ts +0 -56
  1206. package/dist/plugin-sdk/src/config/runtime-overrides.d.ts +0 -15
  1207. package/dist/plugin-sdk/src/config/sat-runtime-ids.d.ts +0 -23
  1208. package/dist/plugin-sdk/src/config/sessions/artifacts.d.ts +0 -6
  1209. package/dist/plugin-sdk/src/config/sessions/delivery-info.d.ts +0 -16
  1210. package/dist/plugin-sdk/src/config/sessions/disk-budget.d.ts +0 -28
  1211. package/dist/plugin-sdk/src/config/sessions/group.d.ts +0 -11
  1212. package/dist/plugin-sdk/src/config/sessions/main-session.d.ts +0 -43
  1213. package/dist/plugin-sdk/src/config/sessions/metadata.d.ts +0 -16
  1214. package/dist/plugin-sdk/src/config/sessions/paths.d.ts +0 -21
  1215. package/dist/plugin-sdk/src/config/sessions/reset.d.ts +0 -43
  1216. package/dist/plugin-sdk/src/config/sessions/session-file.d.ts +0 -15
  1217. package/dist/plugin-sdk/src/config/sessions/session-key.d.ts +0 -8
  1218. package/dist/plugin-sdk/src/config/sessions/store.d.ts +0 -124
  1219. package/dist/plugin-sdk/src/config/sessions/transcript.d.ts +0 -32
  1220. package/dist/plugin-sdk/src/config/sessions/types.d.ts +0 -273
  1221. package/dist/plugin-sdk/src/config/sessions.d.ts +0 -13
  1222. package/dist/plugin-sdk/src/config/talk.d.ts +0 -22
  1223. package/dist/plugin-sdk/src/config/telegram-custom-commands.d.ts +0 -24
  1224. package/dist/plugin-sdk/src/config/types.acp.d.ts +0 -28
  1225. package/dist/plugin-sdk/src/config/types.agent-defaults.d.ts +0 -322
  1226. package/dist/plugin-sdk/src/config/types.agents-shared.d.ts +0 -53
  1227. package/dist/plugin-sdk/src/config/types.agents.d.ts +0 -71
  1228. package/dist/plugin-sdk/src/config/types.approvals.d.ts +0 -26
  1229. package/dist/plugin-sdk/src/config/types.auth.d.ts +0 -34
  1230. package/dist/plugin-sdk/src/config/types.base.d.ts +0 -227
  1231. package/dist/plugin-sdk/src/config/types.browser.d.ts +0 -65
  1232. package/dist/plugin-sdk/src/config/types.channel-messaging-common.d.ts +0 -44
  1233. package/dist/plugin-sdk/src/config/types.channels.d.ts +0 -53
  1234. package/dist/plugin-sdk/src/config/types.cron.d.ts +0 -26
  1235. package/dist/plugin-sdk/src/config/types.d.ts +0 -35
  1236. package/dist/plugin-sdk/src/config/types.discord.d.ts +0 -283
  1237. package/dist/plugin-sdk/src/config/types.fased.d.ts +0 -134
  1238. package/dist/plugin-sdk/src/config/types.federation.d.ts +0 -319
  1239. package/dist/plugin-sdk/src/config/types.gateway.d.ts +0 -313
  1240. package/dist/plugin-sdk/src/config/types.googlechat.d.ts +0 -110
  1241. package/dist/plugin-sdk/src/config/types.hooks.d.ts +0 -141
  1242. package/dist/plugin-sdk/src/config/types.imessage.d.ts +0 -77
  1243. package/dist/plugin-sdk/src/config/types.installs.d.ts +0 -36
  1244. package/dist/plugin-sdk/src/config/types.irc.d.ts +0 -54
  1245. package/dist/plugin-sdk/src/config/types.mcp.d.ts +0 -5
  1246. package/dist/plugin-sdk/src/config/types.memory.d.ts +0 -59
  1247. package/dist/plugin-sdk/src/config/types.messages.d.ts +0 -151
  1248. package/dist/plugin-sdk/src/config/types.models.d.ts +0 -70
  1249. package/dist/plugin-sdk/src/config/types.msteams.d.ts +0 -110
  1250. package/dist/plugin-sdk/src/config/types.node-host.d.ts +0 -10
  1251. package/dist/plugin-sdk/src/config/types.plugins.d.ts +0 -48
  1252. package/dist/plugin-sdk/src/config/types.queue.d.ts +0 -14
  1253. package/dist/plugin-sdk/src/config/types.sandbox.d.ts +0 -97
  1254. package/dist/plugin-sdk/src/config/types.secrets.d.ts +0 -67
  1255. package/dist/plugin-sdk/src/config/types.signal.d.ts +0 -46
  1256. package/dist/plugin-sdk/src/config/types.skills.d.ts +0 -47
  1257. package/dist/plugin-sdk/src/config/types.slack.d.ts +0 -181
  1258. package/dist/plugin-sdk/src/config/types.telegram.d.ts +0 -199
  1259. package/dist/plugin-sdk/src/config/types.tools.d.ts +0 -637
  1260. package/dist/plugin-sdk/src/config/types.tts.d.ts +0 -78
  1261. package/dist/plugin-sdk/src/config/types.wallet.d.ts +0 -88
  1262. package/dist/plugin-sdk/src/config/types.whatsapp.d.ts +0 -101
  1263. package/dist/plugin-sdk/src/config/validation.d.ts +0 -37
  1264. package/dist/plugin-sdk/src/config/version.d.ts +0 -9
  1265. package/dist/plugin-sdk/src/config/zod-schema.agent-defaults.d.ts +0 -308
  1266. package/dist/plugin-sdk/src/config/zod-schema.agent-model.d.ts +0 -24
  1267. package/dist/plugin-sdk/src/config/zod-schema.agent-runtime.d.ts +0 -1439
  1268. package/dist/plugin-sdk/src/config/zod-schema.agents.d.ts +0 -621
  1269. package/dist/plugin-sdk/src/config/zod-schema.allowdeny.d.ts +0 -13
  1270. package/dist/plugin-sdk/src/config/zod-schema.approvals.d.ts +0 -15
  1271. package/dist/plugin-sdk/src/config/zod-schema.channels.d.ts +0 -6
  1272. package/dist/plugin-sdk/src/config/zod-schema.core.d.ts +0 -926
  1273. package/dist/plugin-sdk/src/config/zod-schema.d.ts +0 -4763
  1274. package/dist/plugin-sdk/src/config/zod-schema.hooks.d.ts +0 -83
  1275. package/dist/plugin-sdk/src/config/zod-schema.installs.d.ts +0 -38
  1276. package/dist/plugin-sdk/src/config/zod-schema.providers-core.d.ts +0 -3785
  1277. package/dist/plugin-sdk/src/config/zod-schema.providers-whatsapp.d.ts +0 -235
  1278. package/dist/plugin-sdk/src/config/zod-schema.providers.d.ts +0 -2261
  1279. package/dist/plugin-sdk/src/config/zod-schema.sensitive.d.ts +0 -2
  1280. package/dist/plugin-sdk/src/config/zod-schema.session.d.ts +0 -237
  1281. package/dist/plugin-sdk/src/context-engine/types.d.ts +0 -6
  1282. package/dist/plugin-sdk/src/cron/access-block.d.ts +0 -22
  1283. package/dist/plugin-sdk/src/cron/delivery.d.ts +0 -10
  1284. package/dist/plugin-sdk/src/cron/graph-context.d.ts +0 -45
  1285. package/dist/plugin-sdk/src/cron/legacy-delivery.d.ts +0 -3
  1286. package/dist/plugin-sdk/src/cron/normalize.d.ts +0 -9
  1287. package/dist/plugin-sdk/src/cron/parse.d.ts +0 -1
  1288. package/dist/plugin-sdk/src/cron/payload-migration.d.ts +0 -3
  1289. package/dist/plugin-sdk/src/cron/run-detail-format.d.ts +0 -28
  1290. package/dist/plugin-sdk/src/cron/run-detail.d.ts +0 -95
  1291. package/dist/plugin-sdk/src/cron/run-log.d.ts +0 -65
  1292. package/dist/plugin-sdk/src/cron/schedule.d.ts +0 -2
  1293. package/dist/plugin-sdk/src/cron/service/jobs.d.ts +0 -23
  1294. package/dist/plugin-sdk/src/cron/service/locked.d.ts +0 -2
  1295. package/dist/plugin-sdk/src/cron/service/normalize.d.ts +0 -18
  1296. package/dist/plugin-sdk/src/cron/service/ops.d.ts +0 -152
  1297. package/dist/plugin-sdk/src/cron/service/run-lease.d.ts +0 -15
  1298. package/dist/plugin-sdk/src/cron/service/state.d.ts +0 -154
  1299. package/dist/plugin-sdk/src/cron/service/store.d.ts +0 -9
  1300. package/dist/plugin-sdk/src/cron/service/timeout-policy.d.ts +0 -13
  1301. package/dist/plugin-sdk/src/cron/service/timer.d.ts +0 -80
  1302. package/dist/plugin-sdk/src/cron/service.d.ts +0 -122
  1303. package/dist/plugin-sdk/src/cron/session-reaper.d.ts +0 -35
  1304. package/dist/plugin-sdk/src/cron/stagger.d.ts +0 -8
  1305. package/dist/plugin-sdk/src/cron/store.d.ts +0 -6
  1306. package/dist/plugin-sdk/src/cron/task-adaptive-routing.d.ts +0 -21
  1307. package/dist/plugin-sdk/src/cron/task-evaluator.d.ts +0 -28
  1308. package/dist/plugin-sdk/src/cron/task-model-roles.d.ts +0 -21
  1309. package/dist/plugin-sdk/src/cron/task-planner.d.ts +0 -37
  1310. package/dist/plugin-sdk/src/cron/task-run-queue.d.ts +0 -270
  1311. package/dist/plugin-sdk/src/cron/trusted-sources.d.ts +0 -28
  1312. package/dist/plugin-sdk/src/cron/types.d.ts +0 -673
  1313. package/dist/plugin-sdk/src/cron/webhook-url.d.ts +0 -1
  1314. package/dist/plugin-sdk/src/daemon/arg-split.d.ts +0 -4
  1315. package/dist/plugin-sdk/src/daemon/cmd-argv.d.ts +0 -3
  1316. package/dist/plugin-sdk/src/daemon/cmd-set.d.ts +0 -7
  1317. package/dist/plugin-sdk/src/daemon/constants.d.ts +0 -63
  1318. package/dist/plugin-sdk/src/daemon/diagnostics.d.ts +0 -1
  1319. package/dist/plugin-sdk/src/daemon/exec-file.d.ts +0 -7
  1320. package/dist/plugin-sdk/src/daemon/launchd-plist.d.ts +0 -15
  1321. package/dist/plugin-sdk/src/daemon/launchd.d.ts +0 -49
  1322. package/dist/plugin-sdk/src/daemon/node-service.d.ts +0 -2
  1323. package/dist/plugin-sdk/src/daemon/output.d.ts +0 -8
  1324. package/dist/plugin-sdk/src/daemon/paths.d.ts +0 -3
  1325. package/dist/plugin-sdk/src/daemon/runtime-binary.d.ts +0 -2
  1326. package/dist/plugin-sdk/src/daemon/runtime-parse.d.ts +0 -1
  1327. package/dist/plugin-sdk/src/daemon/schtasks-exec.d.ts +0 -5
  1328. package/dist/plugin-sdk/src/daemon/schtasks.d.ts +0 -18
  1329. package/dist/plugin-sdk/src/daemon/service-runtime.d.ts +0 -13
  1330. package/dist/plugin-sdk/src/daemon/service-types.d.ts +0 -32
  1331. package/dist/plugin-sdk/src/daemon/service.d.ts +0 -16
  1332. package/dist/plugin-sdk/src/daemon/systemd-linger.d.ts +0 -15
  1333. package/dist/plugin-sdk/src/daemon/systemd-system.d.ts +0 -28
  1334. package/dist/plugin-sdk/src/daemon/systemd-unit.d.ts +0 -7
  1335. package/dist/plugin-sdk/src/daemon/systemd.d.ts +0 -32
  1336. package/dist/plugin-sdk/src/discord/accounts.d.ts +0 -21
  1337. package/dist/plugin-sdk/src/discord/api.d.ts +0 -11
  1338. package/dist/plugin-sdk/src/discord/audit.d.ts +0 -29
  1339. package/dist/plugin-sdk/src/discord/chunk.d.ts +0 -20
  1340. package/dist/plugin-sdk/src/discord/client.d.ts +0 -21
  1341. package/dist/plugin-sdk/src/discord/components-registry.d.ts +0 -16
  1342. package/dist/plugin-sdk/src/discord/components.d.ts +0 -196
  1343. package/dist/plugin-sdk/src/discord/directory-live.d.ts +0 -4
  1344. package/dist/plugin-sdk/src/discord/draft-chunking.d.ts +0 -6
  1345. package/dist/plugin-sdk/src/discord/draft-stream.d.ts +0 -21
  1346. package/dist/plugin-sdk/src/discord/gateway-logging.d.ts +0 -8
  1347. package/dist/plugin-sdk/src/discord/guilds.d.ts +0 -6
  1348. package/dist/plugin-sdk/src/discord/monitor/agent-components.d.ts +0 -55
  1349. package/dist/plugin-sdk/src/discord/monitor/allow-list.d.ts +0 -176
  1350. package/dist/plugin-sdk/src/discord/monitor/commands.d.ts +0 -2
  1351. package/dist/plugin-sdk/src/discord/monitor/exec-approvals.d.ts +0 -55
  1352. package/dist/plugin-sdk/src/discord/monitor/format.d.ts +0 -13
  1353. package/dist/plugin-sdk/src/discord/monitor/gateway-error-guard.d.ts +0 -6
  1354. package/dist/plugin-sdk/src/discord/monitor/gateway-plugin.d.ts +0 -8
  1355. package/dist/plugin-sdk/src/discord/monitor/gateway-registry.d.ts +0 -9
  1356. package/dist/plugin-sdk/src/discord/monitor/listeners.d.ts +0 -50
  1357. package/dist/plugin-sdk/src/discord/monitor/message-handler.d.ts +0 -5
  1358. package/dist/plugin-sdk/src/discord/monitor/message-handler.preflight.d.ts +0 -14
  1359. package/dist/plugin-sdk/src/discord/monitor/message-handler.preflight.types.d.ts +0 -96
  1360. package/dist/plugin-sdk/src/discord/monitor/message-handler.process.d.ts +0 -2
  1361. package/dist/plugin-sdk/src/discord/monitor/message-utils.d.ts +0 -44
  1362. package/dist/plugin-sdk/src/discord/monitor/model-picker-preferences.d.ts +0 -18
  1363. package/dist/plugin-sdk/src/discord/monitor/model-picker.d.ts +0 -117
  1364. package/dist/plugin-sdk/src/discord/monitor/native-command.d.ts +0 -26
  1365. package/dist/plugin-sdk/src/discord/monitor/presence-cache.d.ts +0 -9
  1366. package/dist/plugin-sdk/src/discord/monitor/presence.d.ts +0 -5
  1367. package/dist/plugin-sdk/src/discord/monitor/provider.allowlist.d.ts +0 -14
  1368. package/dist/plugin-sdk/src/discord/monitor/provider.d.ts +0 -34
  1369. package/dist/plugin-sdk/src/discord/monitor/provider.lifecycle.d.ts +0 -28
  1370. package/dist/plugin-sdk/src/discord/monitor/reply-context.d.ts +0 -17
  1371. package/dist/plugin-sdk/src/discord/monitor/reply-delivery.d.ts +0 -37
  1372. package/dist/plugin-sdk/src/discord/monitor/rest-fetch.d.ts +0 -2
  1373. package/dist/plugin-sdk/src/discord/monitor/sender-identity.d.ts +0 -31
  1374. package/dist/plugin-sdk/src/discord/monitor/system-events.d.ts +0 -2
  1375. package/dist/plugin-sdk/src/discord/monitor/thread-bindings.config.d.ts +0 -11
  1376. package/dist/plugin-sdk/src/discord/monitor/thread-bindings.d.ts +0 -8
  1377. package/dist/plugin-sdk/src/discord/monitor/thread-bindings.discord-api.d.ts +0 -36
  1378. package/dist/plugin-sdk/src/discord/monitor/thread-bindings.lifecycle.d.ts +0 -46
  1379. package/dist/plugin-sdk/src/discord/monitor/thread-bindings.manager.d.ts +0 -18
  1380. package/dist/plugin-sdk/src/discord/monitor/thread-bindings.messages.d.ts +0 -1
  1381. package/dist/plugin-sdk/src/discord/monitor/thread-bindings.persona.d.ts +0 -6
  1382. package/dist/plugin-sdk/src/discord/monitor/thread-bindings.state.d.ts +0 -80
  1383. package/dist/plugin-sdk/src/discord/monitor/thread-bindings.types.d.ts +0 -77
  1384. package/dist/plugin-sdk/src/discord/monitor/threading.d.ts +0 -106
  1385. package/dist/plugin-sdk/src/discord/monitor/typing.d.ts +0 -5
  1386. package/dist/plugin-sdk/src/discord/monitor.d.ts +0 -10
  1387. package/dist/plugin-sdk/src/discord/monitor.gateway.d.ts +0 -12
  1388. package/dist/plugin-sdk/src/discord/pluralkit.d.ts +0 -26
  1389. package/dist/plugin-sdk/src/discord/probe.d.ts +0 -28
  1390. package/dist/plugin-sdk/src/discord/resolve-channels.d.ts +0 -15
  1391. package/dist/plugin-sdk/src/discord/resolve-users.d.ts +0 -14
  1392. package/dist/plugin-sdk/src/discord/send.channels.d.ts +0 -17
  1393. package/dist/plugin-sdk/src/discord/send.components.d.ts +0 -17
  1394. package/dist/plugin-sdk/src/discord/send.d.ts +0 -10
  1395. package/dist/plugin-sdk/src/discord/send.emojis-stickers.d.ts +0 -4
  1396. package/dist/plugin-sdk/src/discord/send.guild.d.ts +0 -24
  1397. package/dist/plugin-sdk/src/discord/send.messages.d.ts +0 -20
  1398. package/dist/plugin-sdk/src/discord/send.outbound.d.ts +0 -57
  1399. package/dist/plugin-sdk/src/discord/send.permissions.d.ts +0 -20
  1400. package/dist/plugin-sdk/src/discord/send.reactions.d.ts +0 -15
  1401. package/dist/plugin-sdk/src/discord/send.shared.d.ts +0 -85
  1402. package/dist/plugin-sdk/src/discord/send.types.d.ts +0 -144
  1403. package/dist/plugin-sdk/src/discord/targets.d.ts +0 -18
  1404. package/dist/plugin-sdk/src/discord/token.d.ts +0 -11
  1405. package/dist/plugin-sdk/src/discord/ui.d.ts +0 -19
  1406. package/dist/plugin-sdk/src/discord/voice/command.d.ts +0 -15
  1407. package/dist/plugin-sdk/src/discord/voice/manager.d.ts +0 -52
  1408. package/dist/plugin-sdk/src/discord/voice-message.d.ts +0 -50
  1409. package/dist/plugin-sdk/src/federation/access-token.d.ts +0 -34
  1410. package/dist/plugin-sdk/src/federation/attestation.d.ts +0 -37
  1411. package/dist/plugin-sdk/src/federation/auto-connect.d.ts +0 -103
  1412. package/dist/plugin-sdk/src/federation/marketplace-capability-adapter.d.ts +0 -31
  1413. package/dist/plugin-sdk/src/federation/marketplace-chat-command.d.ts +0 -13
  1414. package/dist/plugin-sdk/src/federation/marketplace-delivery.d.ts +0 -61
  1415. package/dist/plugin-sdk/src/federation/marketplace-direct-payment.d.ts +0 -36
  1416. package/dist/plugin-sdk/src/federation/marketplace-escrow.d.ts +0 -58
  1417. package/dist/plugin-sdk/src/federation/marketplace-service-kinds.d.ts +0 -23
  1418. package/dist/plugin-sdk/src/federation/marketplace-task-ledger.d.ts +0 -12
  1419. package/dist/plugin-sdk/src/federation/offers.d.ts +0 -258
  1420. package/dist/plugin-sdk/src/federation/runtime.d.ts +0 -14
  1421. package/dist/plugin-sdk/src/federation/settlement-evidence.d.ts +0 -27
  1422. package/dist/plugin-sdk/src/gateway/a2a-http.d.ts +0 -25
  1423. package/dist/plugin-sdk/src/gateway/a2a-settlement.d.ts +0 -36
  1424. package/dist/plugin-sdk/src/gateway/agent-event-assistant-text.d.ts +0 -2
  1425. package/dist/plugin-sdk/src/gateway/agent-prompt.d.ts +0 -6
  1426. package/dist/plugin-sdk/src/gateway/assistant-identity.d.ts +0 -13
  1427. package/dist/plugin-sdk/src/gateway/auth-rate-limit.d.ts +0 -67
  1428. package/dist/plugin-sdk/src/gateway/auth.d.ts +0 -63
  1429. package/dist/plugin-sdk/src/gateway/call.d.ts +0 -82
  1430. package/dist/plugin-sdk/src/gateway/canvas-capability.d.ts +0 -14
  1431. package/dist/plugin-sdk/src/gateway/chat-abort.d.ts +0 -70
  1432. package/dist/plugin-sdk/src/gateway/chat-sanitize.d.ts +0 -4
  1433. package/dist/plugin-sdk/src/gateway/client.d.ts +0 -66
  1434. package/dist/plugin-sdk/src/gateway/control-plane-audit.d.ts +0 -10
  1435. package/dist/plugin-sdk/src/gateway/control-ui-boot-check.d.ts +0 -22
  1436. package/dist/plugin-sdk/src/gateway/control-ui-contract.d.ts +0 -7
  1437. package/dist/plugin-sdk/src/gateway/control-ui-csp.d.ts +0 -1
  1438. package/dist/plugin-sdk/src/gateway/control-ui-login.d.ts +0 -115
  1439. package/dist/plugin-sdk/src/gateway/control-ui-shared.d.ts +0 -9
  1440. package/dist/plugin-sdk/src/gateway/control-ui.d.ts +0 -36
  1441. package/dist/plugin-sdk/src/gateway/credentials.d.ts +0 -34
  1442. package/dist/plugin-sdk/src/gateway/device-auth.d.ts +0 -17
  1443. package/dist/plugin-sdk/src/gateway/exec-approval-manager.d.ts +0 -38
  1444. package/dist/plugin-sdk/src/gateway/federation-http.d.ts +0 -7
  1445. package/dist/plugin-sdk/src/gateway/federation-marketplace.d.ts +0 -90
  1446. package/dist/plugin-sdk/src/gateway/fedify-http.d.ts +0 -5
  1447. package/dist/plugin-sdk/src/gateway/gateway-identity.d.ts +0 -5
  1448. package/dist/plugin-sdk/src/gateway/hooks-mapping.d.ts +0 -80
  1449. package/dist/plugin-sdk/src/gateway/hooks.d.ts +0 -102
  1450. package/dist/plugin-sdk/src/gateway/http-auth-helpers.d.ts +0 -11
  1451. package/dist/plugin-sdk/src/gateway/http-common.d.ts +0 -21
  1452. package/dist/plugin-sdk/src/gateway/http-endpoint-helpers.d.ts +0 -13
  1453. package/dist/plugin-sdk/src/gateway/http-utils.d.ts +0 -15
  1454. package/dist/plugin-sdk/src/gateway/internal-call-auth.d.ts +0 -3
  1455. package/dist/plugin-sdk/src/gateway/method-scopes.d.ts +0 -22
  1456. package/dist/plugin-sdk/src/gateway/mutating-admin-rpc-rate-limit.d.ts +0 -29
  1457. package/dist/plugin-sdk/src/gateway/net.d.ts +0 -83
  1458. package/dist/plugin-sdk/src/gateway/node-command-policy.d.ts +0 -14
  1459. package/dist/plugin-sdk/src/gateway/node-registry.d.ts +0 -60
  1460. package/dist/plugin-sdk/src/gateway/open-responses.schema.d.ts +0 -765
  1461. package/dist/plugin-sdk/src/gateway/openai-http.d.ts +0 -12
  1462. package/dist/plugin-sdk/src/gateway/openresponses-http.d.ts +0 -21
  1463. package/dist/plugin-sdk/src/gateway/openresponses-prompt.d.ts +0 -5
  1464. package/dist/plugin-sdk/src/gateway/probe-auth.d.ts +0 -9
  1465. package/dist/plugin-sdk/src/gateway/probe.d.ts +0 -26
  1466. package/dist/plugin-sdk/src/gateway/protocol/client-info.d.ts +0 -58
  1467. package/dist/plugin-sdk/src/gateway/protocol/index.d.ts +0 -1048
  1468. package/dist/plugin-sdk/src/gateway/protocol/schema/agent.d.ts +0 -91
  1469. package/dist/plugin-sdk/src/gateway/protocol/schema/agents-models-skills.d.ts +0 -1400
  1470. package/dist/plugin-sdk/src/gateway/protocol/schema/channels.d.ts +0 -158
  1471. package/dist/plugin-sdk/src/gateway/protocol/schema/commands.d.ts +0 -68
  1472. package/dist/plugin-sdk/src/gateway/protocol/schema/config.d.ts +0 -115
  1473. package/dist/plugin-sdk/src/gateway/protocol/schema/cron.d.ts +0 -1551
  1474. package/dist/plugin-sdk/src/gateway/protocol/schema/devices.d.ts +0 -42
  1475. package/dist/plugin-sdk/src/gateway/protocol/schema/error-codes.d.ts +0 -15
  1476. package/dist/plugin-sdk/src/gateway/protocol/schema/exec-approvals.d.ts +0 -182
  1477. package/dist/plugin-sdk/src/gateway/protocol/schema/frames.d.ts +0 -168
  1478. package/dist/plugin-sdk/src/gateway/protocol/schema/logs-chat.d.ts +0 -45
  1479. package/dist/plugin-sdk/src/gateway/protocol/schema/nodes.d.ts +0 -85
  1480. package/dist/plugin-sdk/src/gateway/protocol/schema/primitives.d.ts +0 -4
  1481. package/dist/plugin-sdk/src/gateway/protocol/schema/protocol-schemas.d.ts +0 -3
  1482. package/dist/plugin-sdk/src/gateway/protocol/schema/push.d.ts +0 -15
  1483. package/dist/plugin-sdk/src/gateway/protocol/schema/sessions.d.ts +0 -134
  1484. package/dist/plugin-sdk/src/gateway/protocol/schema/snapshot.d.ts +0 -69
  1485. package/dist/plugin-sdk/src/gateway/protocol/schema/types.d.ts +0 -245
  1486. package/dist/plugin-sdk/src/gateway/protocol/schema/wizard.d.ts +0 -86
  1487. package/dist/plugin-sdk/src/gateway/protocol/schema.d.ts +0 -18
  1488. package/dist/plugin-sdk/src/gateway/security-path.d.ts +0 -15
  1489. package/dist/plugin-sdk/src/gateway/server/readiness.d.ts +0 -6
  1490. package/dist/plugin-sdk/src/gateway/server/ws-types.d.ts +0 -12
  1491. package/dist/plugin-sdk/src/gateway/server-broadcast.d.ts +0 -17
  1492. package/dist/plugin-sdk/src/gateway/server-channels.d.ts +0 -26
  1493. package/dist/plugin-sdk/src/gateway/server-constants.d.ts +0 -10
  1494. package/dist/plugin-sdk/src/gateway/server-http.d.ts +0 -131
  1495. package/dist/plugin-sdk/src/gateway/server-methods/commands.d.ts +0 -11
  1496. package/dist/plugin-sdk/src/gateway/server-methods/mutating-admin-rpc-audit.d.ts +0 -41
  1497. package/dist/plugin-sdk/src/gateway/server-methods/nodes.helpers.d.ts +0 -20
  1498. package/dist/plugin-sdk/src/gateway/server-methods/push.d.ts +0 -2
  1499. package/dist/plugin-sdk/src/gateway/server-methods/types.d.ts +0 -106
  1500. package/dist/plugin-sdk/src/gateway/server-model-catalog.d.ts +0 -17
  1501. package/dist/plugin-sdk/src/gateway/server-shared.d.ts +0 -7
  1502. package/dist/plugin-sdk/src/gateway/server-startup-readiness.d.ts +0 -21
  1503. package/dist/plugin-sdk/src/gateway/server-startup-trace.d.ts +0 -29
  1504. package/dist/plugin-sdk/src/gateway/session-compaction-checkpoints.d.ts +0 -24
  1505. package/dist/plugin-sdk/src/gateway/session-utils.d.ts +0 -80
  1506. package/dist/plugin-sdk/src/gateway/session-utils.fs.d.ts +0 -48
  1507. package/dist/plugin-sdk/src/gateway/session-utils.types.d.ts +0 -106
  1508. package/dist/plugin-sdk/src/gateway/tools-invoke-http.d.ts +0 -10
  1509. package/dist/plugin-sdk/src/gateway/update-status.d.ts +0 -27
  1510. package/dist/plugin-sdk/src/gateway/ws-log.d.ts +0 -5
  1511. package/dist/plugin-sdk/src/gateway/ws-logging.d.ts +0 -4
  1512. package/dist/plugin-sdk/src/globals.d.ts +0 -11
  1513. package/dist/plugin-sdk/src/hooks/config.d.ts +0 -11
  1514. package/dist/plugin-sdk/src/hooks/frontmatter.d.ts +0 -5
  1515. package/dist/plugin-sdk/src/hooks/internal-hooks.d.ts +0 -155
  1516. package/dist/plugin-sdk/src/hooks/module-loader.d.ts +0 -18
  1517. package/dist/plugin-sdk/src/hooks/types.d.ts +0 -62
  1518. package/dist/plugin-sdk/src/image-generation/types.d.ts +0 -74
  1519. package/dist/plugin-sdk/src/imessage/accounts.d.ts +0 -16
  1520. package/dist/plugin-sdk/src/imessage/client.d.ts +0 -46
  1521. package/dist/plugin-sdk/src/imessage/constants.d.ts +0 -2
  1522. package/dist/plugin-sdk/src/imessage/monitor/abort-handler.d.ts +0 -9
  1523. package/dist/plugin-sdk/src/imessage/monitor/deliver.d.ts +0 -14
  1524. package/dist/plugin-sdk/src/imessage/monitor/echo-cache.d.ts +0 -9
  1525. package/dist/plugin-sdk/src/imessage/monitor/inbound-processing.d.ts +0 -96
  1526. package/dist/plugin-sdk/src/imessage/monitor/monitor-provider.d.ts +0 -7
  1527. package/dist/plugin-sdk/src/imessage/monitor/parse-notification.d.ts +0 -2
  1528. package/dist/plugin-sdk/src/imessage/monitor/runtime.d.ts +0 -4
  1529. package/dist/plugin-sdk/src/imessage/monitor/types.d.ts +0 -37
  1530. package/dist/plugin-sdk/src/imessage/monitor.d.ts +0 -2
  1531. package/dist/plugin-sdk/src/imessage/probe.d.ts +0 -17
  1532. package/dist/plugin-sdk/src/imessage/send.d.ts +0 -34
  1533. package/dist/plugin-sdk/src/imessage/target-parsing-helpers.d.ts +0 -45
  1534. package/dist/plugin-sdk/src/imessage/targets.d.ts +0 -40
  1535. package/dist/plugin-sdk/src/infra/abort-signal.d.ts +0 -1
  1536. package/dist/plugin-sdk/src/infra/agent-events.d.ts +0 -24
  1537. package/dist/plugin-sdk/src/infra/archive-path.d.ts +0 -12
  1538. package/dist/plugin-sdk/src/infra/archive.d.ts +0 -46
  1539. package/dist/plugin-sdk/src/infra/backoff.d.ts +0 -8
  1540. package/dist/plugin-sdk/src/infra/binaries.d.ts +0 -3
  1541. package/dist/plugin-sdk/src/infra/boundary-file-read.d.ts +0 -33
  1542. package/dist/plugin-sdk/src/infra/boundary-path.d.ts +0 -38
  1543. package/dist/plugin-sdk/src/infra/brew.d.ts +0 -8
  1544. package/dist/plugin-sdk/src/infra/channel-activity.d.ts +0 -18
  1545. package/dist/plugin-sdk/src/infra/channel-summary.d.ts +0 -6
  1546. package/dist/plugin-sdk/src/infra/channels-status-issues.d.ts +0 -2
  1547. package/dist/plugin-sdk/src/infra/clawhub.d.ts +0 -1
  1548. package/dist/plugin-sdk/src/infra/control-ui-assets.d.ts +0 -32
  1549. package/dist/plugin-sdk/src/infra/dedupe.d.ts +0 -12
  1550. package/dist/plugin-sdk/src/infra/detect-package-manager.d.ts +0 -2
  1551. package/dist/plugin-sdk/src/infra/device-auth-store.d.ts +0 -19
  1552. package/dist/plugin-sdk/src/infra/device-identity.d.ts +0 -13
  1553. package/dist/plugin-sdk/src/infra/device-pairing.d.ts +0 -103
  1554. package/dist/plugin-sdk/src/infra/diagnostic-events.d.ts +0 -140
  1555. package/dist/plugin-sdk/src/infra/diagnostic-flags.d.ts +0 -4
  1556. package/dist/plugin-sdk/src/infra/dotenv.d.ts +0 -13
  1557. package/dist/plugin-sdk/src/infra/env.d.ts +0 -11
  1558. package/dist/plugin-sdk/src/infra/errors.d.ts +0 -11
  1559. package/dist/plugin-sdk/src/infra/exec-approval-reply.d.ts +0 -11
  1560. package/dist/plugin-sdk/src/infra/exec-approval-surface.d.ts +0 -38
  1561. package/dist/plugin-sdk/src/infra/exec-approvals-allowlist.d.ts +0 -69
  1562. package/dist/plugin-sdk/src/infra/exec-approvals-analysis.d.ts +0 -78
  1563. package/dist/plugin-sdk/src/infra/exec-approvals.d.ts +0 -147
  1564. package/dist/plugin-sdk/src/infra/exec-command-resolution.d.ts +0 -45
  1565. package/dist/plugin-sdk/src/infra/exec-obfuscation-detect.d.ts +0 -12
  1566. package/dist/plugin-sdk/src/infra/exec-safe-bin-policy-profiles.d.ts +0 -24
  1567. package/dist/plugin-sdk/src/infra/exec-safe-bin-policy-validator.d.ts +0 -2
  1568. package/dist/plugin-sdk/src/infra/exec-safe-bin-policy.d.ts +0 -2
  1569. package/dist/plugin-sdk/src/infra/exec-safe-bin-runtime-policy.d.ts +0 -25
  1570. package/dist/plugin-sdk/src/infra/exec-safe-bin-trust.d.ts +0 -23
  1571. package/dist/plugin-sdk/src/infra/exec-safety.d.ts +0 -1
  1572. package/dist/plugin-sdk/src/infra/exec-wrapper-resolution.d.ts +0 -48
  1573. package/dist/plugin-sdk/src/infra/fased-exec-env.d.ts +0 -1
  1574. package/dist/plugin-sdk/src/infra/fased-root.d.ts +0 -10
  1575. package/dist/plugin-sdk/src/infra/fasedhub.d.ts +0 -114
  1576. package/dist/plugin-sdk/src/infra/fetch-headers.d.ts +0 -4
  1577. package/dist/plugin-sdk/src/infra/fetch.d.ts +0 -2
  1578. package/dist/plugin-sdk/src/infra/file-identity.d.ts +0 -5
  1579. package/dist/plugin-sdk/src/infra/file-lock.d.ts +0 -2
  1580. package/dist/plugin-sdk/src/infra/format-time/format-datetime.d.ts +0 -35
  1581. package/dist/plugin-sdk/src/infra/format-time/format-duration.d.ts +0 -23
  1582. package/dist/plugin-sdk/src/infra/format-time/format-relative.d.ts +0 -39
  1583. package/dist/plugin-sdk/src/infra/fs-safe.d.ts +0 -43
  1584. package/dist/plugin-sdk/src/infra/gemini-auth.d.ts +0 -16
  1585. package/dist/plugin-sdk/src/infra/git-commit.d.ts +0 -4
  1586. package/dist/plugin-sdk/src/infra/git-root.d.ts +0 -7
  1587. package/dist/plugin-sdk/src/infra/hardlink-guards.d.ts +0 -6
  1588. package/dist/plugin-sdk/src/infra/heartbeat-active-hours.d.ts +0 -5
  1589. package/dist/plugin-sdk/src/infra/heartbeat-events-filter.d.ts +0 -8
  1590. package/dist/plugin-sdk/src/infra/heartbeat-events.d.ts +0 -21
  1591. package/dist/plugin-sdk/src/infra/heartbeat-reason.d.ts +0 -5
  1592. package/dist/plugin-sdk/src/infra/heartbeat-runner.d.ts +0 -46
  1593. package/dist/plugin-sdk/src/infra/heartbeat-visibility.d.ts +0 -17
  1594. package/dist/plugin-sdk/src/infra/heartbeat-wake.d.ts +0 -32
  1595. package/dist/plugin-sdk/src/infra/home-dir.d.ts +0 -7
  1596. package/dist/plugin-sdk/src/infra/host-env-security.d.ts +0 -26
  1597. package/dist/plugin-sdk/src/infra/http-body.d.ts +0 -46
  1598. package/dist/plugin-sdk/src/infra/install-flow.d.ts +0 -24
  1599. package/dist/plugin-sdk/src/infra/install-mode-options.d.ts +0 -20
  1600. package/dist/plugin-sdk/src/infra/install-package-dir.d.ts +0 -19
  1601. package/dist/plugin-sdk/src/infra/install-safe-path.d.ts +0 -14
  1602. package/dist/plugin-sdk/src/infra/install-source-utils.d.ts +0 -32
  1603. package/dist/plugin-sdk/src/infra/json-file.d.ts +0 -2
  1604. package/dist/plugin-sdk/src/infra/json-files.d.ts +0 -5
  1605. package/dist/plugin-sdk/src/infra/jsonl-socket.d.ts +0 -6
  1606. package/dist/plugin-sdk/src/infra/machine-name.d.ts +0 -1
  1607. package/dist/plugin-sdk/src/infra/map-size.d.ts +0 -1
  1608. package/dist/plugin-sdk/src/infra/net/fetch-guard.d.ts +0 -28
  1609. package/dist/plugin-sdk/src/infra/net/hostname.d.ts +0 -1
  1610. package/dist/plugin-sdk/src/infra/net/ssrf.d.ts +0 -35
  1611. package/dist/plugin-sdk/src/infra/node-commands.d.ts +0 -4
  1612. package/dist/plugin-sdk/src/infra/node-pairing.d.ts +0 -65
  1613. package/dist/plugin-sdk/src/infra/node-shell.d.ts +0 -1
  1614. package/dist/plugin-sdk/src/infra/npm-integrity.d.ts +0 -38
  1615. package/dist/plugin-sdk/src/infra/npm-pack-install.d.ts +0 -56
  1616. package/dist/plugin-sdk/src/infra/npm-registry-spec.d.ts +0 -1
  1617. package/dist/plugin-sdk/src/infra/optional-runtime-dependency.d.ts +0 -6
  1618. package/dist/plugin-sdk/src/infra/os-summary.d.ts +0 -7
  1619. package/dist/plugin-sdk/src/infra/outbound/abort.d.ts +0 -8
  1620. package/dist/plugin-sdk/src/infra/outbound/agent-delivery.d.ts +0 -46
  1621. package/dist/plugin-sdk/src/infra/outbound/best-effort-delivery.d.ts +0 -13
  1622. package/dist/plugin-sdk/src/infra/outbound/bound-delivery-router.d.ts +0 -16
  1623. package/dist/plugin-sdk/src/infra/outbound/channel-adapters.d.ts +0 -15
  1624. package/dist/plugin-sdk/src/infra/outbound/channel-adapters.discord.d.ts +0 -2
  1625. package/dist/plugin-sdk/src/infra/outbound/channel-resolution.d.ts +0 -8
  1626. package/dist/plugin-sdk/src/infra/outbound/channel-selection.d.ts +0 -11
  1627. package/dist/plugin-sdk/src/infra/outbound/channel-target.d.ts +0 -6
  1628. package/dist/plugin-sdk/src/infra/outbound/conversation-id.d.ts +0 -4
  1629. package/dist/plugin-sdk/src/infra/outbound/deliver.d.ts +0 -80
  1630. package/dist/plugin-sdk/src/infra/outbound/delivery-queue.d.ts +0 -85
  1631. package/dist/plugin-sdk/src/infra/outbound/directory-cache.d.ts +0 -24
  1632. package/dist/plugin-sdk/src/infra/outbound/envelope.d.ts +0 -16
  1633. package/dist/plugin-sdk/src/infra/outbound/format.d.ts +0 -41
  1634. package/dist/plugin-sdk/src/infra/outbound/identity.d.ts +0 -8
  1635. package/dist/plugin-sdk/src/infra/outbound/message-action-params.d.ts +0 -54
  1636. package/dist/plugin-sdk/src/infra/outbound/message-action-runner.d.ts +0 -81
  1637. package/dist/plugin-sdk/src/infra/outbound/message-action-spec.d.ts +0 -5
  1638. package/dist/plugin-sdk/src/infra/outbound/message.d.ts +0 -87
  1639. package/dist/plugin-sdk/src/infra/outbound/outbound-policy.d.ts +0 -32
  1640. package/dist/plugin-sdk/src/infra/outbound/outbound-send-service.d.ts +0 -74
  1641. package/dist/plugin-sdk/src/infra/outbound/outbound-session.d.ts +0 -31
  1642. package/dist/plugin-sdk/src/infra/outbound/payloads.d.ts +0 -18
  1643. package/dist/plugin-sdk/src/infra/outbound/session-binding-service.d.ts +0 -89
  1644. package/dist/plugin-sdk/src/infra/outbound/session-context.d.ts +0 -12
  1645. package/dist/plugin-sdk/src/infra/outbound/target-errors.d.ts +0 -6
  1646. package/dist/plugin-sdk/src/infra/outbound/target-normalization.d.ts +0 -4
  1647. package/dist/plugin-sdk/src/infra/outbound/target-resolver.d.ts +0 -53
  1648. package/dist/plugin-sdk/src/infra/outbound/targets.d.ts +0 -87
  1649. package/dist/plugin-sdk/src/infra/outbound/tool-payload.d.ts +0 -2
  1650. package/dist/plugin-sdk/src/infra/pairing-files.d.ts +0 -23
  1651. package/dist/plugin-sdk/src/infra/pairing-pending.d.ts +0 -13
  1652. package/dist/plugin-sdk/src/infra/pairing-token.d.ts +0 -3
  1653. package/dist/plugin-sdk/src/infra/path-alias-guards.d.ts +0 -18
  1654. package/dist/plugin-sdk/src/infra/path-guards.d.ts +0 -5
  1655. package/dist/plugin-sdk/src/infra/path-prepend.d.ts +0 -6
  1656. package/dist/plugin-sdk/src/infra/path-safety.d.ts +0 -2
  1657. package/dist/plugin-sdk/src/infra/plain-object.d.ts +0 -4
  1658. package/dist/plugin-sdk/src/infra/ports-format.d.ts +0 -5
  1659. package/dist/plugin-sdk/src/infra/ports-inspect.d.ts +0 -2
  1660. package/dist/plugin-sdk/src/infra/ports-lsof.d.ts +0 -2
  1661. package/dist/plugin-sdk/src/infra/ports-probe.d.ts +0 -5
  1662. package/dist/plugin-sdk/src/infra/ports-types.d.ts +0 -18
  1663. package/dist/plugin-sdk/src/infra/ports.d.ts +0 -14
  1664. package/dist/plugin-sdk/src/infra/prototype-keys.d.ts +0 -1
  1665. package/dist/plugin-sdk/src/infra/provider-usage.auth.d.ts +0 -11
  1666. package/dist/plugin-sdk/src/infra/provider-usage.d.ts +0 -4
  1667. package/dist/plugin-sdk/src/infra/provider-usage.fetch.claude.d.ts +0 -2
  1668. package/dist/plugin-sdk/src/infra/provider-usage.fetch.codex.d.ts +0 -2
  1669. package/dist/plugin-sdk/src/infra/provider-usage.fetch.copilot.d.ts +0 -2
  1670. package/dist/plugin-sdk/src/infra/provider-usage.fetch.d.ts +0 -6
  1671. package/dist/plugin-sdk/src/infra/provider-usage.fetch.gemini.d.ts +0 -2
  1672. package/dist/plugin-sdk/src/infra/provider-usage.fetch.minimax.d.ts +0 -2
  1673. package/dist/plugin-sdk/src/infra/provider-usage.fetch.shared.d.ts +0 -12
  1674. package/dist/plugin-sdk/src/infra/provider-usage.fetch.zai.d.ts +0 -2
  1675. package/dist/plugin-sdk/src/infra/provider-usage.format.d.ts +0 -13
  1676. package/dist/plugin-sdk/src/infra/provider-usage.load.d.ts +0 -12
  1677. package/dist/plugin-sdk/src/infra/provider-usage.shared.d.ts +0 -8
  1678. package/dist/plugin-sdk/src/infra/provider-usage.types.d.ts +0 -17
  1679. package/dist/plugin-sdk/src/infra/push-apns.d.ts +0 -83
  1680. package/dist/plugin-sdk/src/infra/restart-sentinel.d.ts +0 -50
  1681. package/dist/plugin-sdk/src/infra/restart-stale-pids.d.ts +0 -13
  1682. package/dist/plugin-sdk/src/infra/restart.d.ts +0 -72
  1683. package/dist/plugin-sdk/src/infra/retry-policy.d.ts +0 -25
  1684. package/dist/plugin-sdk/src/infra/retry.d.ts +0 -21
  1685. package/dist/plugin-sdk/src/infra/runtime-guard.d.ts +0 -21
  1686. package/dist/plugin-sdk/src/infra/runtime-status.d.ts +0 -8
  1687. package/dist/plugin-sdk/src/infra/safe-open-sync.d.ts +0 -23
  1688. package/dist/plugin-sdk/src/infra/scp-host.d.ts +0 -2
  1689. package/dist/plugin-sdk/src/infra/secure-random.d.ts +0 -2
  1690. package/dist/plugin-sdk/src/infra/session-cost-usage.d.ts +0 -45
  1691. package/dist/plugin-sdk/src/infra/session-cost-usage.types.d.ts +0 -153
  1692. package/dist/plugin-sdk/src/infra/session-maintenance-warning.d.ts +0 -10
  1693. package/dist/plugin-sdk/src/infra/shell-env.d.ts +0 -34
  1694. package/dist/plugin-sdk/src/infra/skills-remote.d.ts +0 -25
  1695. package/dist/plugin-sdk/src/infra/system-events.d.ts +0 -20
  1696. package/dist/plugin-sdk/src/infra/system-message.d.ts +0 -3
  1697. package/dist/plugin-sdk/src/infra/system-presence.d.ts +0 -45
  1698. package/dist/plugin-sdk/src/infra/system-run-command.d.ts +0 -30
  1699. package/dist/plugin-sdk/src/infra/tailnet.d.ts +0 -7
  1700. package/dist/plugin-sdk/src/infra/tailscale.d.ts +0 -34
  1701. package/dist/plugin-sdk/src/infra/tls/fingerprint.d.ts +0 -1
  1702. package/dist/plugin-sdk/src/infra/tls/gateway.d.ts +0 -16
  1703. package/dist/plugin-sdk/src/infra/tmp-fased-dir.d.ts +0 -20
  1704. package/dist/plugin-sdk/src/infra/transport-ready.d.ts +0 -16
  1705. package/dist/plugin-sdk/src/infra/unhandled-rejections.d.ts +0 -15
  1706. package/dist/plugin-sdk/src/infra/update-channels.d.ts +0 -36
  1707. package/dist/plugin-sdk/src/infra/update-check.d.ts +0 -69
  1708. package/dist/plugin-sdk/src/infra/update-global.d.ts +0 -29
  1709. package/dist/plugin-sdk/src/infra/warning-filter.d.ts +0 -7
  1710. package/dist/plugin-sdk/src/infra/ws.d.ts +0 -2
  1711. package/dist/plugin-sdk/src/infra/wsl.d.ts +0 -11
  1712. package/dist/plugin-sdk/src/line/accounts.d.ts +0 -10
  1713. package/dist/plugin-sdk/src/line/actions.d.ts +0 -22
  1714. package/dist/plugin-sdk/src/line/auto-reply-delivery.d.ts +0 -38
  1715. package/dist/plugin-sdk/src/line/bot-access.d.ts +0 -17
  1716. package/dist/plugin-sdk/src/line/bot-handlers.d.ts +0 -13
  1717. package/dist/plugin-sdk/src/line/bot-message-context.d.ts +0 -118
  1718. package/dist/plugin-sdk/src/line/bot.d.ts +0 -24
  1719. package/dist/plugin-sdk/src/line/channel-access-token.d.ts +0 -4
  1720. package/dist/plugin-sdk/src/line/config-schema.d.ts +0 -64
  1721. package/dist/plugin-sdk/src/line/download.d.ts +0 -7
  1722. package/dist/plugin-sdk/src/line/flex-templates/basic-cards.d.ts +0 -46
  1723. package/dist/plugin-sdk/src/line/flex-templates/common.d.ts +0 -2
  1724. package/dist/plugin-sdk/src/line/flex-templates/media-control-cards.d.ts +0 -73
  1725. package/dist/plugin-sdk/src/line/flex-templates/message.d.ts +0 -6
  1726. package/dist/plugin-sdk/src/line/flex-templates/schedule-cards.d.ts +0 -55
  1727. package/dist/plugin-sdk/src/line/flex-templates/types.d.ts +0 -19
  1728. package/dist/plugin-sdk/src/line/flex-templates.d.ts +0 -5
  1729. package/dist/plugin-sdk/src/line/logging.d.ts +0 -2
  1730. package/dist/plugin-sdk/src/line/markdown-to-line.d.ts +0 -72
  1731. package/dist/plugin-sdk/src/line/monitor.d.ts +0 -28
  1732. package/dist/plugin-sdk/src/line/probe.d.ts +0 -2
  1733. package/dist/plugin-sdk/src/line/reply-chunks.d.ts +0 -24
  1734. package/dist/plugin-sdk/src/line/send.d.ts +0 -91
  1735. package/dist/plugin-sdk/src/line/signature.d.ts +0 -1
  1736. package/dist/plugin-sdk/src/line/template-messages.d.ts +0 -100
  1737. package/dist/plugin-sdk/src/line/types.d.ts +0 -113
  1738. package/dist/plugin-sdk/src/line/webhook-node.d.ts +0 -15
  1739. package/dist/plugin-sdk/src/line/webhook-utils.d.ts +0 -3
  1740. package/dist/plugin-sdk/src/line/webhook.d.ts +0 -19
  1741. package/dist/plugin-sdk/src/link-understanding/apply.d.ts +0 -10
  1742. package/dist/plugin-sdk/src/link-understanding/defaults.d.ts +0 -2
  1743. package/dist/plugin-sdk/src/link-understanding/detect.d.ts +0 -3
  1744. package/dist/plugin-sdk/src/link-understanding/format.d.ts +0 -4
  1745. package/dist/plugin-sdk/src/link-understanding/runner.d.ts +0 -13
  1746. package/dist/plugin-sdk/src/logger.d.ts +0 -6
  1747. package/dist/plugin-sdk/src/logging/config.d.ts +0 -4
  1748. package/dist/plugin-sdk/src/logging/console.d.ts +0 -23
  1749. package/dist/plugin-sdk/src/logging/diagnostic-session-state.d.ts +0 -30
  1750. package/dist/plugin-sdk/src/logging/diagnostic-stability.d.ts +0 -85
  1751. package/dist/plugin-sdk/src/logging/diagnostic.d.ts +0 -65
  1752. package/dist/plugin-sdk/src/logging/env-log-level.d.ts +0 -2
  1753. package/dist/plugin-sdk/src/logging/levels.d.ts +0 -5
  1754. package/dist/plugin-sdk/src/logging/logger.d.ts +0 -44
  1755. package/dist/plugin-sdk/src/logging/node-require.d.ts +0 -1
  1756. package/dist/plugin-sdk/src/logging/redact-identifier.d.ts +0 -4
  1757. package/dist/plugin-sdk/src/logging/redact.d.ts +0 -9
  1758. package/dist/plugin-sdk/src/logging/state.d.ts +0 -19
  1759. package/dist/plugin-sdk/src/logging/subsystem.d.ts +0 -18
  1760. package/dist/plugin-sdk/src/logging/timestamps.d.ts +0 -1
  1761. package/dist/plugin-sdk/src/logging.d.ts +0 -10
  1762. package/dist/plugin-sdk/src/managed/federation.d.ts +0 -16
  1763. package/dist/plugin-sdk/src/markdown/code-spans.d.ts +0 -10
  1764. package/dist/plugin-sdk/src/markdown/fences.d.ts +0 -10
  1765. package/dist/plugin-sdk/src/markdown/frontmatter.d.ts +0 -2
  1766. package/dist/plugin-sdk/src/markdown/ir.d.ts +0 -32
  1767. package/dist/plugin-sdk/src/markdown/render.d.ts +0 -18
  1768. package/dist/plugin-sdk/src/markdown/tables.d.ts +0 -2
  1769. package/dist/plugin-sdk/src/markdown/whatsapp.d.ts +0 -14
  1770. package/dist/plugin-sdk/src/media/audio-tags.d.ts +0 -10
  1771. package/dist/plugin-sdk/src/media/audio.d.ts +0 -19
  1772. package/dist/plugin-sdk/src/media/base64.d.ts +0 -6
  1773. package/dist/plugin-sdk/src/media/constants.d.ts +0 -7
  1774. package/dist/plugin-sdk/src/media/fetch.d.ts +0 -24
  1775. package/dist/plugin-sdk/src/media/image-ops.d.ts +0 -41
  1776. package/dist/plugin-sdk/src/media/inbound-path-policy.d.ts +0 -18
  1777. package/dist/plugin-sdk/src/media/input-files.d.ts +0 -95
  1778. package/dist/plugin-sdk/src/media/local-roots.d.ts +0 -3
  1779. package/dist/plugin-sdk/src/media/mime.d.ts +0 -16
  1780. package/dist/plugin-sdk/src/media/outbound-attachment.d.ts +0 -6
  1781. package/dist/plugin-sdk/src/media/parse.d.ts +0 -8
  1782. package/dist/plugin-sdk/src/media/png-encode.d.ts +0 -8
  1783. package/dist/plugin-sdk/src/media/read-response-with-limit.d.ts +0 -7
  1784. package/dist/plugin-sdk/src/media/sniff-mime-from-base64.d.ts +0 -1
  1785. package/dist/plugin-sdk/src/media/store.d.ts +0 -33
  1786. package/dist/plugin-sdk/src/media-understanding/apply.d.ts +0 -19
  1787. package/dist/plugin-sdk/src/media-understanding/attachments.d.ts +0 -49
  1788. package/dist/plugin-sdk/src/media-understanding/audio-preflight.d.ts +0 -16
  1789. package/dist/plugin-sdk/src/media-understanding/concurrency.d.ts +0 -1
  1790. package/dist/plugin-sdk/src/media-understanding/defaults.d.ts +0 -14
  1791. package/dist/plugin-sdk/src/media-understanding/errors.d.ts +0 -6
  1792. package/dist/plugin-sdk/src/media-understanding/format.d.ts +0 -7
  1793. package/dist/plugin-sdk/src/media-understanding/fs.d.ts +0 -1
  1794. package/dist/plugin-sdk/src/media-understanding/output-extract.d.ts +0 -2
  1795. package/dist/plugin-sdk/src/media-understanding/providers/anthropic/index.d.ts +0 -2
  1796. package/dist/plugin-sdk/src/media-understanding/providers/deepgram/audio.d.ts +0 -4
  1797. package/dist/plugin-sdk/src/media-understanding/providers/deepgram/index.d.ts +0 -2
  1798. package/dist/plugin-sdk/src/media-understanding/providers/google/audio.d.ts +0 -3
  1799. package/dist/plugin-sdk/src/media-understanding/providers/google/index.d.ts +0 -2
  1800. package/dist/plugin-sdk/src/media-understanding/providers/google/inline-data.d.ts +0 -20
  1801. package/dist/plugin-sdk/src/media-understanding/providers/google/video.d.ts +0 -3
  1802. package/dist/plugin-sdk/src/media-understanding/providers/groq/index.d.ts +0 -2
  1803. package/dist/plugin-sdk/src/media-understanding/providers/image.d.ts +0 -2
  1804. package/dist/plugin-sdk/src/media-understanding/providers/index.d.ts +0 -4
  1805. package/dist/plugin-sdk/src/media-understanding/providers/minimax/index.d.ts +0 -2
  1806. package/dist/plugin-sdk/src/media-understanding/providers/mistral/index.d.ts +0 -2
  1807. package/dist/plugin-sdk/src/media-understanding/providers/moonshot/index.d.ts +0 -2
  1808. package/dist/plugin-sdk/src/media-understanding/providers/moonshot/video.d.ts +0 -3
  1809. package/dist/plugin-sdk/src/media-understanding/providers/openai/audio.d.ts +0 -3
  1810. package/dist/plugin-sdk/src/media-understanding/providers/openai/index.d.ts +0 -3
  1811. package/dist/plugin-sdk/src/media-understanding/providers/shared.d.ts +0 -20
  1812. package/dist/plugin-sdk/src/media-understanding/providers/zai/index.d.ts +0 -2
  1813. package/dist/plugin-sdk/src/media-understanding/resolve.d.ts +0 -44
  1814. package/dist/plugin-sdk/src/media-understanding/runner.d.ts +0 -39
  1815. package/dist/plugin-sdk/src/media-understanding/runner.entries.d.ts +0 -33
  1816. package/dist/plugin-sdk/src/media-understanding/scope.d.ts +0 -9
  1817. package/dist/plugin-sdk/src/media-understanding/types.d.ts +0 -93
  1818. package/dist/plugin-sdk/src/media-understanding/video.d.ts +0 -2
  1819. package/dist/plugin-sdk/src/memory/backend-config.d.ts +0 -55
  1820. package/dist/plugin-sdk/src/memory/batch-error-utils.d.ts +0 -15
  1821. package/dist/plugin-sdk/src/memory/batch-gemini.d.ts +0 -51
  1822. package/dist/plugin-sdk/src/memory/batch-http.d.ts +0 -8
  1823. package/dist/plugin-sdk/src/memory/batch-openai.d.ts +0 -20
  1824. package/dist/plugin-sdk/src/memory/batch-output.d.ts +0 -23
  1825. package/dist/plugin-sdk/src/memory/batch-provider-common.d.ts +0 -9
  1826. package/dist/plugin-sdk/src/memory/batch-runner.d.ts +0 -38
  1827. package/dist/plugin-sdk/src/memory/batch-upload.d.ts +0 -6
  1828. package/dist/plugin-sdk/src/memory/batch-utils.d.ts +0 -11
  1829. package/dist/plugin-sdk/src/memory/batch-voyage.d.ts +0 -21
  1830. package/dist/plugin-sdk/src/memory/embedding-chunk-limits.d.ts +0 -3
  1831. package/dist/plugin-sdk/src/memory/embedding-input-limits.d.ts +0 -2
  1832. package/dist/plugin-sdk/src/memory/embedding-model-limits.d.ts +0 -2
  1833. package/dist/plugin-sdk/src/memory/embeddings-debug.d.ts +0 -1
  1834. package/dist/plugin-sdk/src/memory/embeddings-gemini.d.ts +0 -16
  1835. package/dist/plugin-sdk/src/memory/embeddings-mistral.d.ts +0 -15
  1836. package/dist/plugin-sdk/src/memory/embeddings-openai.d.ts +0 -15
  1837. package/dist/plugin-sdk/src/memory/embeddings-remote-client.d.ts +0 -12
  1838. package/dist/plugin-sdk/src/memory/embeddings-remote-fetch.d.ts +0 -8
  1839. package/dist/plugin-sdk/src/memory/embeddings-remote-provider.d.ts +0 -21
  1840. package/dist/plugin-sdk/src/memory/embeddings-voyage.d.ts +0 -15
  1841. package/dist/plugin-sdk/src/memory/embeddings.d.ts +0 -48
  1842. package/dist/plugin-sdk/src/memory/filesystem-manager.d.ts +0 -38
  1843. package/dist/plugin-sdk/src/memory/fs-utils.d.ts +0 -11
  1844. package/dist/plugin-sdk/src/memory/hybrid.d.ts +0 -45
  1845. package/dist/plugin-sdk/src/memory/index.d.ts +0 -4
  1846. package/dist/plugin-sdk/src/memory/internal.d.ts +0 -38
  1847. package/dist/plugin-sdk/src/memory/inventory.d.ts +0 -150
  1848. package/dist/plugin-sdk/src/memory/manager-embedding-ops.d.ts +0 -42
  1849. package/dist/plugin-sdk/src/memory/manager-search.d.ts +0 -60
  1850. package/dist/plugin-sdk/src/memory/manager-sync-ops.d.ts +0 -137
  1851. package/dist/plugin-sdk/src/memory/manager.d.ts +0 -111
  1852. package/dist/plugin-sdk/src/memory/memory-schema.d.ts +0 -10
  1853. package/dist/plugin-sdk/src/memory/mmr.d.ts +0 -62
  1854. package/dist/plugin-sdk/src/memory/node-llama.d.ts +0 -8
  1855. package/dist/plugin-sdk/src/memory/post-json.d.ts +0 -10
  1856. package/dist/plugin-sdk/src/memory/qmd-manager.d.ts +0 -134
  1857. package/dist/plugin-sdk/src/memory/qmd-query-parser.d.ts +0 -9
  1858. package/dist/plugin-sdk/src/memory/qmd-scope.d.ts +0 -5
  1859. package/dist/plugin-sdk/src/memory/query-expansion.d.ts +0 -40
  1860. package/dist/plugin-sdk/src/memory/remote-http.d.ts +0 -9
  1861. package/dist/plugin-sdk/src/memory/repair-audit-plan.d.ts +0 -68
  1862. package/dist/plugin-sdk/src/memory/repair-cli-preview-contract.d.ts +0 -22
  1863. package/dist/plugin-sdk/src/memory/repair-contracts.d.ts +0 -80
  1864. package/dist/plugin-sdk/src/memory/repair-dashboard-preview-contract.d.ts +0 -65
  1865. package/dist/plugin-sdk/src/memory/repair-execution-policy.d.ts +0 -36
  1866. package/dist/plugin-sdk/src/memory/repair-execution-request-contract.d.ts +0 -43
  1867. package/dist/plugin-sdk/src/memory/repair-executor-fs-safety-contract.d.ts +0 -33
  1868. package/dist/plugin-sdk/src/memory/repair-executor-gate.d.ts +0 -27
  1869. package/dist/plugin-sdk/src/memory/repair-executor-lock-contract.d.ts +0 -40
  1870. package/dist/plugin-sdk/src/memory/repair-executor-result-contract.d.ts +0 -72
  1871. package/dist/plugin-sdk/src/memory/repair-executor.d.ts +0 -60
  1872. package/dist/plugin-sdk/src/memory/repair-preflight-cli-preview-contract.d.ts +0 -15
  1873. package/dist/plugin-sdk/src/memory/repair-preflight-dashboard-preview-contract.d.ts +0 -50
  1874. package/dist/plugin-sdk/src/memory/repair-preflight-pipeline-contract.d.ts +0 -35
  1875. package/dist/plugin-sdk/src/memory/search-manager.d.ts +0 -11
  1876. package/dist/plugin-sdk/src/memory/session-files.d.ts +0 -14
  1877. package/dist/plugin-sdk/src/memory/sqlite-vec.d.ts +0 -9
  1878. package/dist/plugin-sdk/src/memory/sqlite.d.ts +0 -1
  1879. package/dist/plugin-sdk/src/memory/status-format.d.ts +0 -28
  1880. package/dist/plugin-sdk/src/memory/temporal-decay.d.ts +0 -25
  1881. package/dist/plugin-sdk/src/memory/types.d.ts +0 -94
  1882. package/dist/plugin-sdk/src/mining/chat-command.d.ts +0 -19
  1883. package/dist/plugin-sdk/src/mining/mainnet-sync.d.ts +0 -32
  1884. package/dist/plugin-sdk/src/pairing/pairing-challenge.d.ts +0 -32
  1885. package/dist/plugin-sdk/src/pairing/pairing-labels.d.ts +0 -2
  1886. package/dist/plugin-sdk/src/pairing/pairing-messages.d.ts +0 -6
  1887. package/dist/plugin-sdk/src/pairing/pairing-store.d.ts +0 -50
  1888. package/dist/plugin-sdk/src/plugin-sdk/account-id.d.ts +0 -1
  1889. package/dist/plugin-sdk/src/plugin-sdk/agent-media-payload.d.ts +0 -12
  1890. package/dist/plugin-sdk/src/plugin-sdk/allow-from.d.ts +0 -32
  1891. package/dist/plugin-sdk/src/plugin-sdk/channel-core.d.ts +0 -18
  1892. package/dist/plugin-sdk/src/plugin-sdk/command-auth.d.ts +0 -27
  1893. package/dist/plugin-sdk/src/plugin-sdk/config-paths.d.ts +0 -6
  1894. package/dist/plugin-sdk/src/plugin-sdk/device-pair.d.ts +0 -5
  1895. package/dist/plugin-sdk/src/plugin-sdk/discord.d.ts +0 -10
  1896. package/dist/plugin-sdk/src/plugin-sdk/fetch-auth.d.ts +0 -13
  1897. package/dist/plugin-sdk/src/plugin-sdk/file-lock.d.ts +0 -16
  1898. package/dist/plugin-sdk/src/plugin-sdk/group-access.d.ts +0 -16
  1899. package/dist/plugin-sdk/src/plugin-sdk/image-generation.d.ts +0 -2
  1900. package/dist/plugin-sdk/src/plugin-sdk/index.d.ts +0 -163
  1901. package/dist/plugin-sdk/src/plugin-sdk/json-store.d.ts +0 -5
  1902. package/dist/plugin-sdk/src/plugin-sdk/onboarding.d.ts +0 -11
  1903. package/dist/plugin-sdk/src/plugin-sdk/pairing-access.d.ts +0 -18
  1904. package/dist/plugin-sdk/src/plugin-sdk/persistent-dedupe.d.ts +0 -20
  1905. package/dist/plugin-sdk/src/plugin-sdk/provider-auth-result.d.ts +0 -14
  1906. package/dist/plugin-sdk/src/plugin-sdk/realtime-transcription.d.ts +0 -3
  1907. package/dist/plugin-sdk/src/plugin-sdk/realtime-voice.d.ts +0 -3
  1908. package/dist/plugin-sdk/src/plugin-sdk/reply-payload.d.ts +0 -22
  1909. package/dist/plugin-sdk/src/plugin-sdk/run-command.d.ts +0 -12
  1910. package/dist/plugin-sdk/src/plugin-sdk/runtime.d.ts +0 -10
  1911. package/dist/plugin-sdk/src/plugin-sdk/sat-runtime.d.ts +0 -32
  1912. package/dist/plugin-sdk/src/plugin-sdk/slack-message-actions.d.ts +0 -11
  1913. package/dist/plugin-sdk/src/plugin-sdk/slack.d.ts +0 -9
  1914. package/dist/plugin-sdk/src/plugin-sdk/ssrf-policy.d.ts +0 -12
  1915. package/dist/plugin-sdk/src/plugin-sdk/status-helpers.d.ts +0 -88
  1916. package/dist/plugin-sdk/src/plugin-sdk/telegram.d.ts +0 -9
  1917. package/dist/plugin-sdk/src/plugin-sdk/temp-path.d.ts +0 -12
  1918. package/dist/plugin-sdk/src/plugin-sdk/text-chunking.d.ts +0 -1
  1919. package/dist/plugin-sdk/src/plugin-sdk/tool-send.d.ts +0 -4
  1920. package/dist/plugin-sdk/src/plugin-sdk/video-generation.d.ts +0 -4
  1921. package/dist/plugin-sdk/src/plugin-sdk/webhook-path.d.ts +0 -6
  1922. package/dist/plugin-sdk/src/plugin-sdk/webhook-targets.d.ts +0 -23
  1923. package/dist/plugin-sdk/src/plugin-sdk/whatsapp.d.ts +0 -11
  1924. package/dist/plugin-sdk/src/plugins/bundled-dir.d.ts +0 -7
  1925. package/dist/plugin-sdk/src/plugins/capability-provider-runtime.d.ts +0 -9
  1926. package/dist/plugin-sdk/src/plugins/commands.d.ts +0 -85
  1927. package/dist/plugin-sdk/src/plugins/config-schema.d.ts +0 -2
  1928. package/dist/plugin-sdk/src/plugins/config-state.d.ts +0 -86
  1929. package/dist/plugin-sdk/src/plugins/discovery.d.ts +0 -25
  1930. package/dist/plugin-sdk/src/plugins/hook-runner-global.d.ts +0 -37
  1931. package/dist/plugin-sdk/src/plugins/hooks.d.ts +0 -55
  1932. package/dist/plugin-sdk/src/plugins/http-path.d.ts +0 -1
  1933. package/dist/plugin-sdk/src/plugins/http-registry.d.ts +0 -13
  1934. package/dist/plugin-sdk/src/plugins/install.d.ts +0 -93
  1935. package/dist/plugin-sdk/src/plugins/loader.d.ts +0 -35
  1936. package/dist/plugin-sdk/src/plugins/logger.d.ts +0 -9
  1937. package/dist/plugin-sdk/src/plugins/manifest-registry.d.ts +0 -53
  1938. package/dist/plugin-sdk/src/plugins/manifest.d.ts +0 -136
  1939. package/dist/plugin-sdk/src/plugins/memory-embedding-providers.d.ts +0 -15
  1940. package/dist/plugin-sdk/src/plugins/min-host-version.d.ts +0 -28
  1941. package/dist/plugin-sdk/src/plugins/package-extensions.d.ts +0 -23
  1942. package/dist/plugin-sdk/src/plugins/path-safety.d.ts +0 -5
  1943. package/dist/plugin-sdk/src/plugins/provider-discovery.d.ts +0 -13
  1944. package/dist/plugin-sdk/src/plugins/provider-runtime.runtime.d.ts +0 -8
  1945. package/dist/plugin-sdk/src/plugins/providers.d.ts +0 -28
  1946. package/dist/plugin-sdk/src/plugins/registry.d.ts +0 -171
  1947. package/dist/plugin-sdk/src/plugins/runtime/admin-rpc-helper.d.ts +0 -71
  1948. package/dist/plugin-sdk/src/plugins/runtime/index.d.ts +0 -4
  1949. package/dist/plugin-sdk/src/plugins/runtime/native-deps.d.ts +0 -8
  1950. package/dist/plugin-sdk/src/plugins/runtime/scoped.d.ts +0 -6
  1951. package/dist/plugin-sdk/src/plugins/runtime/session-read-helper.d.ts +0 -115
  1952. package/dist/plugin-sdk/src/plugins/runtime/types.d.ts +0 -370
  1953. package/dist/plugin-sdk/src/plugins/runtime.d.ts +0 -6
  1954. package/dist/plugin-sdk/src/plugins/schema-validator.d.ts +0 -10
  1955. package/dist/plugin-sdk/src/plugins/slots.d.ts +0 -24
  1956. package/dist/plugin-sdk/src/plugins/tools.d.ts +0 -14
  1957. package/dist/plugin-sdk/src/plugins/types.d.ts +0 -684
  1958. package/dist/plugin-sdk/src/plugins/uninstall.d.ts +0 -45
  1959. package/dist/plugin-sdk/src/polls.d.ts +0 -31
  1960. package/dist/plugin-sdk/src/process/command-queue.d.ts +0 -63
  1961. package/dist/plugin-sdk/src/process/exec.d.ts +0 -31
  1962. package/dist/plugin-sdk/src/process/kill-tree.d.ts +0 -12
  1963. package/dist/plugin-sdk/src/process/lanes.d.ts +0 -6
  1964. package/dist/plugin-sdk/src/process/spawn-utils.d.ts +0 -26
  1965. package/dist/plugin-sdk/src/process/supervisor/adapters/child.d.ts +0 -10
  1966. package/dist/plugin-sdk/src/process/supervisor/adapters/env.d.ts +0 -1
  1967. package/dist/plugin-sdk/src/process/supervisor/adapters/pty.d.ts +0 -11
  1968. package/dist/plugin-sdk/src/process/supervisor/index.d.ts +0 -4
  1969. package/dist/plugin-sdk/src/process/supervisor/registry.d.ts +0 -21
  1970. package/dist/plugin-sdk/src/process/supervisor/supervisor.d.ts +0 -2
  1971. package/dist/plugin-sdk/src/process/supervisor/types.d.ts +0 -92
  1972. package/dist/plugin-sdk/src/project.d.ts +0 -3
  1973. package/dist/plugin-sdk/src/providers/cloudflare-ai-gateway-shared.d.ts +0 -84
  1974. package/dist/plugin-sdk/src/providers/github-copilot-models.d.ts +0 -5
  1975. package/dist/plugin-sdk/src/providers/github-copilot-token.d.ts +0 -22
  1976. package/dist/plugin-sdk/src/providers/health.d.ts +0 -15
  1977. package/dist/plugin-sdk/src/providers/huggingface-models.d.ts +0 -47
  1978. package/dist/plugin-sdk/src/providers/litellm-models.d.ts +0 -30
  1979. package/dist/plugin-sdk/src/providers/opencode-zen-shared.d.ts +0 -7
  1980. package/dist/plugin-sdk/src/providers/refreshed-model-capabilities.d.ts +0 -14
  1981. package/dist/plugin-sdk/src/providers/registry.d.ts +0 -204
  1982. package/dist/plugin-sdk/src/providers/synthetic-models.d.ts +0 -31
  1983. package/dist/plugin-sdk/src/providers/together-models.d.ts +0 -38
  1984. package/dist/plugin-sdk/src/providers/venice-models.d.ts +0 -175
  1985. package/dist/plugin-sdk/src/providers/vercel-ai-gateway-models.d.ts +0 -113
  1986. package/dist/plugin-sdk/src/providers/xiaomi-models.d.ts +0 -21
  1987. package/dist/plugin-sdk/src/realtime-transcription/provider-registry.d.ts +0 -7
  1988. package/dist/plugin-sdk/src/realtime-transcription/provider-types.d.ts +0 -26
  1989. package/dist/plugin-sdk/src/realtime-voice/provider-registry.d.ts +0 -7
  1990. package/dist/plugin-sdk/src/realtime-voice/provider-types.d.ts +0 -55
  1991. package/dist/plugin-sdk/src/routing/account-id.d.ts +0 -3
  1992. package/dist/plugin-sdk/src/routing/account-lookup.d.ts +0 -1
  1993. package/dist/plugin-sdk/src/routing/bindings.d.ts +0 -11
  1994. package/dist/plugin-sdk/src/routing/resolve-route.d.ts +0 -42
  1995. package/dist/plugin-sdk/src/routing/session-key.d.ts +0 -48
  1996. package/dist/plugin-sdk/src/runtime.d.ts +0 -7
  1997. package/dist/plugin-sdk/src/secrets/json-pointer.d.ts +0 -6
  1998. package/dist/plugin-sdk/src/secrets/ref-contract.d.ts +0 -19
  1999. package/dist/plugin-sdk/src/secrets/resolve.d.ts +0 -15
  2000. package/dist/plugin-sdk/src/secrets/runtime-web-tools.types.d.ts +0 -26
  2001. package/dist/plugin-sdk/src/secrets/shared.d.ts +0 -7
  2002. package/dist/plugin-sdk/src/security/audit-channel.d.ts +0 -7
  2003. package/dist/plugin-sdk/src/security/audit-extra.async.d.ts +0 -47
  2004. package/dist/plugin-sdk/src/security/audit-extra.d.ts +0 -10
  2005. package/dist/plugin-sdk/src/security/audit-extra.sync.d.ts +0 -25
  2006. package/dist/plugin-sdk/src/security/audit-fs.d.ts +0 -44
  2007. package/dist/plugin-sdk/src/security/audit-tool-policy.d.ts +0 -1
  2008. package/dist/plugin-sdk/src/security/audit.d.ts +0 -57
  2009. package/dist/plugin-sdk/src/security/channel-metadata.d.ts +0 -6
  2010. package/dist/plugin-sdk/src/security/dangerous-config-flags.d.ts +0 -2
  2011. package/dist/plugin-sdk/src/security/dangerous-tools.d.ts +0 -12
  2012. package/dist/plugin-sdk/src/security/dm-policy-shared.d.ts +0 -93
  2013. package/dist/plugin-sdk/src/security/external-content.d.ts +0 -58
  2014. package/dist/plugin-sdk/src/security/mutable-allowlist-detectors.d.ts +0 -6
  2015. package/dist/plugin-sdk/src/security/safe-regex.d.ts +0 -2
  2016. package/dist/plugin-sdk/src/security/scan-paths.d.ts +0 -5
  2017. package/dist/plugin-sdk/src/security/secret-equal.d.ts +0 -1
  2018. package/dist/plugin-sdk/src/security/skill-scanner.d.ts +0 -25
  2019. package/dist/plugin-sdk/src/security/windows-acl.d.ts +0 -37
  2020. package/dist/plugin-sdk/src/sessions/input-provenance.d.ts +0 -16
  2021. package/dist/plugin-sdk/src/sessions/level-overrides.d.ts +0 -10
  2022. package/dist/plugin-sdk/src/sessions/model-overrides.d.ts +0 -16
  2023. package/dist/plugin-sdk/src/sessions/send-policy.d.ts +0 -11
  2024. package/dist/plugin-sdk/src/sessions/session-key-utils.d.ts +0 -20
  2025. package/dist/plugin-sdk/src/sessions/session-label.d.ts +0 -9
  2026. package/dist/plugin-sdk/src/sessions/transcript-events.d.ts +0 -9
  2027. package/dist/plugin-sdk/src/shared/avatar-policy.d.ts +0 -16
  2028. package/dist/plugin-sdk/src/shared/chat-content.d.ts +0 -5
  2029. package/dist/plugin-sdk/src/shared/chat-envelope.d.ts +0 -2
  2030. package/dist/plugin-sdk/src/shared/config-eval.d.ts +0 -27
  2031. package/dist/plugin-sdk/src/shared/device-auth.d.ts +0 -13
  2032. package/dist/plugin-sdk/src/shared/entry-metadata.d.ts +0 -15
  2033. package/dist/plugin-sdk/src/shared/entry-status.d.ts +0 -47
  2034. package/dist/plugin-sdk/src/shared/frontmatter.d.ts +0 -24
  2035. package/dist/plugin-sdk/src/shared/gateway-bind-url.d.ts +0 -14
  2036. package/dist/plugin-sdk/src/shared/gateway-method-policy.d.ts +0 -8
  2037. package/dist/plugin-sdk/src/shared/model-param-b.d.ts +0 -1
  2038. package/dist/plugin-sdk/src/shared/model-thinking.d.ts +0 -31
  2039. package/dist/plugin-sdk/src/shared/net/ip.d.ts +0 -20
  2040. package/dist/plugin-sdk/src/shared/net/redact-sensitive-url.d.ts +0 -2
  2041. package/dist/plugin-sdk/src/shared/node-list-parse.d.ts +0 -3
  2042. package/dist/plugin-sdk/src/shared/node-list-types.d.ts +0 -48
  2043. package/dist/plugin-sdk/src/shared/node-match.d.ts +0 -9
  2044. package/dist/plugin-sdk/src/shared/operator-scope-compat.d.ts +0 -5
  2045. package/dist/plugin-sdk/src/shared/pid-alive.d.ts +0 -1
  2046. package/dist/plugin-sdk/src/shared/process-scoped-map.d.ts +0 -1
  2047. package/dist/plugin-sdk/src/shared/requirements.d.ts +0 -80
  2048. package/dist/plugin-sdk/src/shared/string-normalization.d.ts +0 -4
  2049. package/dist/plugin-sdk/src/shared/subagents-format.d.ts +0 -15
  2050. package/dist/plugin-sdk/src/shared/tailscale-status.d.ts +0 -8
  2051. package/dist/plugin-sdk/src/shared/text/code-regions.d.ts +0 -6
  2052. package/dist/plugin-sdk/src/shared/text/reasoning-tags.d.ts +0 -6
  2053. package/dist/plugin-sdk/src/shared/text-chunking.d.ts +0 -1
  2054. package/dist/plugin-sdk/src/signal/accounts.d.ts +0 -17
  2055. package/dist/plugin-sdk/src/signal/client.d.ts +0 -32
  2056. package/dist/plugin-sdk/src/signal/daemon.d.ts +0 -26
  2057. package/dist/plugin-sdk/src/signal/format.d.ts +0 -17
  2058. package/dist/plugin-sdk/src/signal/identity.d.ts +0 -24
  2059. package/dist/plugin-sdk/src/signal/index.d.ts +0 -5
  2060. package/dist/plugin-sdk/src/signal/monitor/access-policy.d.ts +0 -40
  2061. package/dist/plugin-sdk/src/signal/monitor/event-handler.d.ts +0 -5
  2062. package/dist/plugin-sdk/src/signal/monitor/event-handler.types.d.ts +0 -125
  2063. package/dist/plugin-sdk/src/signal/monitor/mentions.d.ts +0 -2
  2064. package/dist/plugin-sdk/src/signal/monitor.d.ts +0 -25
  2065. package/dist/plugin-sdk/src/signal/probe.d.ts +0 -7
  2066. package/dist/plugin-sdk/src/signal/reaction-level.d.ts +0 -17
  2067. package/dist/plugin-sdk/src/signal/rpc-context.d.ts +0 -9
  2068. package/dist/plugin-sdk/src/signal/send-reactions.d.ts +0 -32
  2069. package/dist/plugin-sdk/src/signal/send.d.ts +0 -25
  2070. package/dist/plugin-sdk/src/signal/sse-reconnect.d.ts +0 -13
  2071. package/dist/plugin-sdk/src/slack/accounts.d.ts +0 -32
  2072. package/dist/plugin-sdk/src/slack/actions.d.ts +0 -56
  2073. package/dist/plugin-sdk/src/slack/blocks-fallback.d.ts +0 -2
  2074. package/dist/plugin-sdk/src/slack/blocks-input.d.ts +0 -3
  2075. package/dist/plugin-sdk/src/slack/channel-migration.d.ts +0 -20
  2076. package/dist/plugin-sdk/src/slack/client.d.ts +0 -4
  2077. package/dist/plugin-sdk/src/slack/directory-live.d.ts +0 -4
  2078. package/dist/plugin-sdk/src/slack/draft-stream.d.ts +0 -25
  2079. package/dist/plugin-sdk/src/slack/format.d.ts +0 -7
  2080. package/dist/plugin-sdk/src/slack/http/index.d.ts +0 -1
  2081. package/dist/plugin-sdk/src/slack/http/registry.d.ts +0 -12
  2082. package/dist/plugin-sdk/src/slack/index.d.ts +0 -6
  2083. package/dist/plugin-sdk/src/slack/message-actions.d.ts +0 -4
  2084. package/dist/plugin-sdk/src/slack/modal-metadata.d.ts +0 -8
  2085. package/dist/plugin-sdk/src/slack/monitor/allow-list.d.ts +0 -23
  2086. package/dist/plugin-sdk/src/slack/monitor/auth.d.ts +0 -26
  2087. package/dist/plugin-sdk/src/slack/monitor/channel-config.d.ts +0 -43
  2088. package/dist/plugin-sdk/src/slack/monitor/commands.d.ts +0 -9
  2089. package/dist/plugin-sdk/src/slack/monitor/context.d.ts +0 -104
  2090. package/dist/plugin-sdk/src/slack/monitor/dm-auth.d.ts +0 -17
  2091. package/dist/plugin-sdk/src/slack/monitor/events/channels.d.ts +0 -4
  2092. package/dist/plugin-sdk/src/slack/monitor/events/interactions.d.ts +0 -4
  2093. package/dist/plugin-sdk/src/slack/monitor/events/members.d.ts +0 -4
  2094. package/dist/plugin-sdk/src/slack/monitor/events/messages.d.ts +0 -6
  2095. package/dist/plugin-sdk/src/slack/monitor/events/pins.d.ts +0 -4
  2096. package/dist/plugin-sdk/src/slack/monitor/events/reactions.d.ts +0 -4
  2097. package/dist/plugin-sdk/src/slack/monitor/events/system-event-context.d.ts +0 -12
  2098. package/dist/plugin-sdk/src/slack/monitor/events.d.ts +0 -8
  2099. package/dist/plugin-sdk/src/slack/monitor/external-arg-menu-store.d.ts +0 -18
  2100. package/dist/plugin-sdk/src/slack/monitor/media.d.ts +0 -66
  2101. package/dist/plugin-sdk/src/slack/monitor/message-handler/dispatch.d.ts +0 -12
  2102. package/dist/plugin-sdk/src/slack/monitor/message-handler/prepare.d.ts +0 -13
  2103. package/dist/plugin-sdk/src/slack/monitor/message-handler/types.d.ts +0 -22
  2104. package/dist/plugin-sdk/src/slack/monitor/message-handler.d.ts +0 -11
  2105. package/dist/plugin-sdk/src/slack/monitor/mrkdwn.d.ts +0 -1
  2106. package/dist/plugin-sdk/src/slack/monitor/policy.d.ts +0 -5
  2107. package/dist/plugin-sdk/src/slack/monitor/provider.d.ts +0 -7
  2108. package/dist/plugin-sdk/src/slack/monitor/replies.d.ts +0 -54
  2109. package/dist/plugin-sdk/src/slack/monitor/room-context.d.ts +0 -14
  2110. package/dist/plugin-sdk/src/slack/monitor/slash.d.ts +0 -6
  2111. package/dist/plugin-sdk/src/slack/monitor/thread-resolution.d.ts +0 -12
  2112. package/dist/plugin-sdk/src/slack/monitor/types.d.ts +0 -109
  2113. package/dist/plugin-sdk/src/slack/monitor.d.ts +0 -5
  2114. package/dist/plugin-sdk/src/slack/probe.d.ts +0 -14
  2115. package/dist/plugin-sdk/src/slack/resolve-channels.d.ts +0 -19
  2116. package/dist/plugin-sdk/src/slack/resolve-users.d.ts +0 -26
  2117. package/dist/plugin-sdk/src/slack/send.d.ts +0 -22
  2118. package/dist/plugin-sdk/src/slack/stream-mode.d.ts +0 -23
  2119. package/dist/plugin-sdk/src/slack/streaming.d.ts +0 -72
  2120. package/dist/plugin-sdk/src/slack/targets.d.ts +0 -7
  2121. package/dist/plugin-sdk/src/slack/threading-tool-context.d.ts +0 -10
  2122. package/dist/plugin-sdk/src/slack/threading.d.ts +0 -29
  2123. package/dist/plugin-sdk/src/slack/token.d.ts +0 -3
  2124. package/dist/plugin-sdk/src/slack/types.d.ts +0 -58
  2125. package/dist/plugin-sdk/src/tasks/channel-task-ledger.d.ts +0 -9
  2126. package/dist/plugin-sdk/src/tasks/task-executor.d.ts +0 -86
  2127. package/dist/plugin-sdk/src/tasks/task-owner-access.d.ts +0 -12
  2128. package/dist/plugin-sdk/src/tasks/task-registry.d.ts +0 -35
  2129. package/dist/plugin-sdk/src/tasks/task-registry.types.d.ts +0 -114
  2130. package/dist/plugin-sdk/src/tasks/task-status.d.ts +0 -11
  2131. package/dist/plugin-sdk/src/telegram/accounts.d.ts +0 -21
  2132. package/dist/plugin-sdk/src/telegram/allowed-updates.d.ts +0 -4
  2133. package/dist/plugin-sdk/src/telegram/api-logging.d.ts +0 -11
  2134. package/dist/plugin-sdk/src/telegram/audit.d.ts +0 -29
  2135. package/dist/plugin-sdk/src/telegram/bot/delivery.d.ts +0 -35
  2136. package/dist/plugin-sdk/src/telegram/bot/helpers.d.ts +0 -127
  2137. package/dist/plugin-sdk/src/telegram/bot/types.d.ts +0 -28
  2138. package/dist/plugin-sdk/src/telegram/bot-access.d.ts +0 -26
  2139. package/dist/plugin-sdk/src/telegram/bot-handlers.d.ts +0 -2
  2140. package/dist/plugin-sdk/src/telegram/bot-message-context.d.ts +0 -149
  2141. package/dist/plugin-sdk/src/telegram/bot-message-dispatch.d.ts +0 -29
  2142. package/dist/plugin-sdk/src/telegram/bot-message.d.ts +0 -20
  2143. package/dist/plugin-sdk/src/telegram/bot-native-command-menu.d.ts +0 -33
  2144. package/dist/plugin-sdk/src/telegram/bot-native-commands.d.ts +0 -58
  2145. package/dist/plugin-sdk/src/telegram/bot-updates.d.ts +0 -31
  2146. package/dist/plugin-sdk/src/telegram/bot.d.ts +0 -62
  2147. package/dist/plugin-sdk/src/telegram/button-types.d.ts +0 -7
  2148. package/dist/plugin-sdk/src/telegram/caption.d.ts +0 -5
  2149. package/dist/plugin-sdk/src/telegram/dm-access.d.ts +0 -18
  2150. package/dist/plugin-sdk/src/telegram/draft-stream.d.ts +0 -37
  2151. package/dist/plugin-sdk/src/telegram/fetch.d.ts +0 -5
  2152. package/dist/plugin-sdk/src/telegram/format.d.ts +0 -18
  2153. package/dist/plugin-sdk/src/telegram/group-access.d.ts +0 -54
  2154. package/dist/plugin-sdk/src/telegram/group-config-helpers.d.ts +0 -8
  2155. package/dist/plugin-sdk/src/telegram/group-migration.d.ts +0 -20
  2156. package/dist/plugin-sdk/src/telegram/inline-buttons.d.ts +0 -11
  2157. package/dist/plugin-sdk/src/telegram/lane-delivery.d.ts +0 -56
  2158. package/dist/plugin-sdk/src/telegram/model-buttons.d.ts +0 -63
  2159. package/dist/plugin-sdk/src/telegram/monitor.d.ts +0 -19
  2160. package/dist/plugin-sdk/src/telegram/network-config.d.ts +0 -33
  2161. package/dist/plugin-sdk/src/telegram/network-errors.d.ts +0 -5
  2162. package/dist/plugin-sdk/src/telegram/outbound-params.d.ts +0 -2
  2163. package/dist/plugin-sdk/src/telegram/probe.d.ts +0 -17
  2164. package/dist/plugin-sdk/src/telegram/proxy.d.ts +0 -1
  2165. package/dist/plugin-sdk/src/telegram/reaction-level.d.ts +0 -11
  2166. package/dist/plugin-sdk/src/telegram/reasoning-lane-coordinator.d.ts +0 -18
  2167. package/dist/plugin-sdk/src/telegram/send.d.ts +0 -153
  2168. package/dist/plugin-sdk/src/telegram/sendchataction-401-backoff.d.ts +0 -28
  2169. package/dist/plugin-sdk/src/telegram/sent-message-cache.d.ts +0 -16
  2170. package/dist/plugin-sdk/src/telegram/status-reaction-variants.d.ts +0 -21
  2171. package/dist/plugin-sdk/src/telegram/sticker-cache.d.ts +0 -46
  2172. package/dist/plugin-sdk/src/telegram/target-writeback.d.ts +0 -7
  2173. package/dist/plugin-sdk/src/telegram/targets.d.ts +0 -11
  2174. package/dist/plugin-sdk/src/telegram/token.d.ts +0 -13
  2175. package/dist/plugin-sdk/src/telegram/update-offset-store.d.ts +0 -15
  2176. package/dist/plugin-sdk/src/telegram/voice.d.ts +0 -16
  2177. package/dist/plugin-sdk/src/telegram/webhook.d.ts +0 -20
  2178. package/dist/plugin-sdk/src/terminal/ansi.d.ts +0 -2
  2179. package/dist/plugin-sdk/src/terminal/health-style.d.ts +0 -1
  2180. package/dist/plugin-sdk/src/terminal/links.d.ts +0 -6
  2181. package/dist/plugin-sdk/src/terminal/palette.d.ts +0 -10
  2182. package/dist/plugin-sdk/src/terminal/progress-line.d.ts +0 -3
  2183. package/dist/plugin-sdk/src/terminal/prompt-style.d.ts +0 -6
  2184. package/dist/plugin-sdk/src/terminal/restore.d.ts +0 -17
  2185. package/dist/plugin-sdk/src/terminal/table.d.ts +0 -18
  2186. package/dist/plugin-sdk/src/terminal/theme.d.ts +0 -18
  2187. package/dist/plugin-sdk/src/tts/tts-core.d.ts +0 -52
  2188. package/dist/plugin-sdk/src/tts/tts.d.ts +0 -194
  2189. package/dist/plugin-sdk/src/utils/account-id.d.ts +0 -1
  2190. package/dist/plugin-sdk/src/utils/boolean.d.ts +0 -5
  2191. package/dist/plugin-sdk/src/utils/chunk-items.d.ts +0 -1
  2192. package/dist/plugin-sdk/src/utils/delivery-context.d.ts +0 -29
  2193. package/dist/plugin-sdk/src/utils/directive-tags.d.ts +0 -29
  2194. package/dist/plugin-sdk/src/utils/fetch-timeout.d.ts +0 -13
  2195. package/dist/plugin-sdk/src/utils/mask-api-key.d.ts +0 -1
  2196. package/dist/plugin-sdk/src/utils/message-channel.d.ts +0 -27
  2197. package/dist/plugin-sdk/src/utils/normalize-secret-input.d.ts +0 -11
  2198. package/dist/plugin-sdk/src/utils/private-network-url.d.ts +0 -1
  2199. package/dist/plugin-sdk/src/utils/provider-utils.d.ts +0 -9
  2200. package/dist/plugin-sdk/src/utils/queue-helpers.d.ts +0 -80
  2201. package/dist/plugin-sdk/src/utils/reaction-level.d.ts +0 -15
  2202. package/dist/plugin-sdk/src/utils/run-with-concurrency.d.ts +0 -11
  2203. package/dist/plugin-sdk/src/utils/safe-json.d.ts +0 -1
  2204. package/dist/plugin-sdk/src/utils/shell-argv.d.ts +0 -1
  2205. package/dist/plugin-sdk/src/utils/transcript-tools.d.ts +0 -8
  2206. package/dist/plugin-sdk/src/utils/usage-format.d.ts +0 -26
  2207. package/dist/plugin-sdk/src/utils/with-timeout.d.ts +0 -1
  2208. package/dist/plugin-sdk/src/utils.d.ts +0 -63
  2209. package/dist/plugin-sdk/src/version.d.ts +0 -8
  2210. package/dist/plugin-sdk/src/video-generation/dashscope-compatible.d.ts +0 -45
  2211. package/dist/plugin-sdk/src/video-generation/types.d.ts +0 -79
  2212. package/dist/plugin-sdk/src/wallet/chat-command.d.ts +0 -17
  2213. package/dist/plugin-sdk/src/wallet/local-socket-signer-broker.d.ts +0 -13
  2214. package/dist/plugin-sdk/src/wallet/local-socket-signer-custody.d.ts +0 -35
  2215. package/dist/plugin-sdk/src/wallet/local-socket-signer-protocol.d.ts +0 -191
  2216. package/dist/plugin-sdk/src/wallet/providers/alchemy-adapter.d.ts +0 -29
  2217. package/dist/plugin-sdk/src/wallet/providers/embedded-keystore-adapter.d.ts +0 -37
  2218. package/dist/plugin-sdk/src/wallet/providers/local-socket-signer-adapter.d.ts +0 -44
  2219. package/dist/plugin-sdk/src/wallet/providers/privy-adapter.d.ts +0 -31
  2220. package/dist/plugin-sdk/src/wallet/providers/turnkey-adapter.d.ts +0 -33
  2221. package/dist/plugin-sdk/src/wallet/solana-address.d.ts +0 -2
  2222. package/dist/plugin-sdk/src/wallet/solana-assets.d.ts +0 -80
  2223. package/dist/plugin-sdk/src/wallet/solana-bond-signing.d.ts +0 -20
  2224. package/dist/plugin-sdk/src/wallet/solana-spl-transfer.d.ts +0 -33
  2225. package/dist/plugin-sdk/src/wallet/solana-swap.d.ts +0 -93
  2226. package/dist/plugin-sdk/src/wallet/solana-token-resolver.d.ts +0 -36
  2227. package/dist/plugin-sdk/src/wallet/solana-transaction-inspection.d.ts +0 -16
  2228. package/dist/plugin-sdk/src/wallet/solana-trigger.d.ts +0 -74
  2229. package/dist/plugin-sdk/src/wallet/trade-chat-command.d.ts +0 -18
  2230. package/dist/plugin-sdk/src/wallet/wallet-agent-selection.d.ts +0 -43
  2231. package/dist/plugin-sdk/src/wallet/wallet-approval-auth.d.ts +0 -212
  2232. package/dist/plugin-sdk/src/wallet/wallet-audit-log.d.ts +0 -18
  2233. package/dist/plugin-sdk/src/wallet/wallet-canary.d.ts +0 -47
  2234. package/dist/plugin-sdk/src/wallet/wallet-custody.d.ts +0 -313
  2235. package/dist/plugin-sdk/src/wallet/wallet-inbound-events.d.ts +0 -88
  2236. package/dist/plugin-sdk/src/wallet/wallet-observability.d.ts +0 -16
  2237. package/dist/plugin-sdk/src/wallet/wallet-policy-simulation.d.ts +0 -61
  2238. package/dist/plugin-sdk/src/wallet/wallet-policy.d.ts +0 -144
  2239. package/dist/plugin-sdk/src/wallet/wallet-provider-adapter.d.ts +0 -111
  2240. package/dist/plugin-sdk/src/wallet/wallet-provider-capabilities.d.ts +0 -51
  2241. package/dist/plugin-sdk/src/wallet/wallet-provider-registry.d.ts +0 -128
  2242. package/dist/plugin-sdk/src/wallet/wallet-provider-resolver.d.ts +0 -17
  2243. package/dist/plugin-sdk/src/wallet/wallet-redaction.d.ts +0 -3
  2244. package/dist/plugin-sdk/src/wallet/wallet-runtime-config.d.ts +0 -93
  2245. package/dist/plugin-sdk/src/wallet/wallet-secrets-store.d.ts +0 -63
  2246. package/dist/plugin-sdk/src/wallet/wallet-send-approvals.d.ts +0 -165
  2247. package/dist/plugin-sdk/src/wallet/wallet-settlement-links.d.ts +0 -57
  2248. package/dist/plugin-sdk/src/wallet/wallet-status.d.ts +0 -106
  2249. package/dist/plugin-sdk/src/wallet/wallet-task-ledger.d.ts +0 -7
  2250. package/dist/plugin-sdk/src/web/accounts.d.ts +0 -39
  2251. package/dist/plugin-sdk/src/web/active-listener.d.ts +0 -26
  2252. package/dist/plugin-sdk/src/web/auth-store.d.ts +0 -26
  2253. package/dist/plugin-sdk/src/web/auto-reply/constants.d.ts +0 -1
  2254. package/dist/plugin-sdk/src/web/auto-reply/deliver-reply.d.ts +0 -19
  2255. package/dist/plugin-sdk/src/web/auto-reply/heartbeat-runner.d.ts +0 -20
  2256. package/dist/plugin-sdk/src/web/auto-reply/loggers.d.ts +0 -4
  2257. package/dist/plugin-sdk/src/web/auto-reply/mentions.d.ts +0 -19
  2258. package/dist/plugin-sdk/src/web/auto-reply/monitor/ack-reaction.d.ts +0 -13
  2259. package/dist/plugin-sdk/src/web/auto-reply/monitor/broadcast.d.ts +0 -16
  2260. package/dist/plugin-sdk/src/web/auto-reply/monitor/commands.d.ts +0 -2
  2261. package/dist/plugin-sdk/src/web/auto-reply/monitor/echo.d.ts +0 -17
  2262. package/dist/plugin-sdk/src/web/auto-reply/monitor/group-activation.d.ts +0 -9
  2263. package/dist/plugin-sdk/src/web/auto-reply/monitor/group-gating.d.ts +0 -33
  2264. package/dist/plugin-sdk/src/web/auto-reply/monitor/group-members.d.ts +0 -6
  2265. package/dist/plugin-sdk/src/web/auto-reply/monitor/last-route.d.ts +0 -15
  2266. package/dist/plugin-sdk/src/web/auto-reply/monitor/message-line.d.ts +0 -11
  2267. package/dist/plugin-sdk/src/web/auto-reply/monitor/on-message.d.ts +0 -24
  2268. package/dist/plugin-sdk/src/web/auto-reply/monitor/peer.d.ts +0 -2
  2269. package/dist/plugin-sdk/src/web/auto-reply/monitor/process-message.d.ts +0 -40
  2270. package/dist/plugin-sdk/src/web/auto-reply/monitor.d.ts +0 -5
  2271. package/dist/plugin-sdk/src/web/auto-reply/session-snapshot.d.ts +0 -17
  2272. package/dist/plugin-sdk/src/web/auto-reply/types.d.ts +0 -30
  2273. package/dist/plugin-sdk/src/web/auto-reply/util.d.ts +0 -2
  2274. package/dist/plugin-sdk/src/web/auto-reply.d.ts +0 -1
  2275. package/dist/plugin-sdk/src/web/auto-reply.impl.d.ts +0 -6
  2276. package/dist/plugin-sdk/src/web/inbound/access-control.d.ts +0 -36
  2277. package/dist/plugin-sdk/src/web/inbound/dedupe.d.ts +0 -2
  2278. package/dist/plugin-sdk/src/web/inbound/extract.d.ts +0 -13
  2279. package/dist/plugin-sdk/src/web/inbound/media.d.ts +0 -7
  2280. package/dist/plugin-sdk/src/web/inbound/monitor.d.ts +0 -30
  2281. package/dist/plugin-sdk/src/web/inbound/send-api.d.ts +0 -22
  2282. package/dist/plugin-sdk/src/web/inbound/types.d.ts +0 -41
  2283. package/dist/plugin-sdk/src/web/inbound.d.ts +0 -4
  2284. package/dist/plugin-sdk/src/web/login-qr.d.ts +0 -19
  2285. package/dist/plugin-sdk/src/web/login.d.ts +0 -3
  2286. package/dist/plugin-sdk/src/web/media.d.ts +0 -43
  2287. package/dist/plugin-sdk/src/web/outbound.d.ts +0 -25
  2288. package/dist/plugin-sdk/src/web/qr-image.d.ts +0 -4
  2289. package/dist/plugin-sdk/src/web/reconnect.d.ts +0 -12
  2290. package/dist/plugin-sdk/src/web/session.d.ts +0 -14
  2291. package/dist/plugin-sdk/src/web/vcard.d.ts +0 -6
  2292. package/dist/plugin-sdk/src/whatsapp/normalize.d.ts +0 -6
  2293. package/dist/plugin-sdk/src/whatsapp/resolve-outbound-target.d.ts +0 -12
  2294. package/dist/plugin-sdk/src/wizard/onboarding.types.d.ts +0 -31
  2295. package/dist/plugin-sdk/src/wizard/onboarding.wallet.d.ts +0 -45
  2296. package/dist/plugin-sdk/src/wizard/prompts.d.ts +0 -45
  2297. package/dist/plugin-sdk/src/wizard/session.d.ts +0 -42
  2298. package/dist/plugin-sdk/ssrf-Cce6LubA.js +0 -421
  2299. package/dist/plugin-sdk/ssrf-Cg5wg0v3.js +0 -4
  2300. package/dist/plugin-sdk/status-B2vb7zNW.js +0 -106417
  2301. package/dist/plugin-sdk/sticker-cache-C1vOWkzA.js +0 -170
  2302. package/dist/plugin-sdk/sticker-cache-CJDzqowL.js +0 -170
  2303. package/dist/plugin-sdk/subsystem-BmpnSVOu.js +0 -358
  2304. package/dist/plugin-sdk/tables-BD7H5ug-.js +0 -55
  2305. package/dist/plugin-sdk/tables-CJE8kB35.js +0 -55
  2306. package/dist/plugin-sdk/target-errors-kz4lDpCF.js +0 -26
  2307. package/dist/plugin-sdk/targets-4QTk4tTz.js +0 -45
  2308. package/dist/plugin-sdk/targets-DmSpDM4F.js +0 -45
  2309. package/dist/plugin-sdk/targets-cA134MEE.js +0 -101
  2310. package/dist/plugin-sdk/targets-t1hbjHdJ.js +0 -101
  2311. package/dist/plugin-sdk/telegram-actions-BoiC9J7L.js +0 -307
  2312. package/dist/plugin-sdk/telegram-actions-CwAsKaNz.js +0 -307
  2313. package/dist/plugin-sdk/thread-bindings.lifecycle-Djem8FWF.js +0 -737
  2314. package/dist/plugin-sdk/thread-bindings.lifecycle-gmHv3hc7.js +0 -737
  2315. package/dist/plugin-sdk/thread-bindings.state-CNT2vxm3.js +0 -643
  2316. package/dist/plugin-sdk/thread-bindings.state-D8kN2X6H.js +0 -643
  2317. package/dist/plugin-sdk/token-BWZYO8QR.js +0 -36
  2318. package/dist/plugin-sdk/tokens-BK5rrwBB.js +0 -72
  2319. package/dist/plugin-sdk/tokens-CQRTq-NN.js +0 -72
  2320. package/dist/plugin-sdk/tool-loop-detection-Ci_YYA7P.js +0 -352
  2321. package/dist/plugin-sdk/transcript-events-BJQWUdmU.js +0 -24
  2322. package/dist/plugin-sdk/ui-7sxJ-x37.js +0 -33
  2323. package/dist/plugin-sdk/ui-BQ-Vvq_c.js +0 -33
  2324. package/dist/plugin-sdk/utils-LGKVujSU.js +0 -237
  2325. package/dist/plugin-sdk/web-BjV7ROeA.js +0 -2226
  2326. package/dist/plugin-sdk/web-DjTSgU98.js +0 -2226
  2327. package/dist/plugin-sdk/whatsapp-actions-68Mfs2dJ.js +0 -123
  2328. package/dist/plugin-sdk/whatsapp-actions-DRqtzvTO.js +0 -123
  2329. package/dist/plugin-sdk/wsl-DcM2PgSS.js +0 -1016
  2330. package/dist/plugin-sdk/wsl-PXrdWitE.js +0 -1016
  2331. /package/dist/plugin-sdk/{channel-activity-Cf5sKkfd.js → channel-activity-B7MIaDei.js} +0 -0
  2332. /package/dist/plugin-sdk/{client-DWTXscox.js → client-BTUzO_8g.js} +0 -0
  2333. /package/dist/plugin-sdk/{command-poll-backoff-C2vOB38t.js → command-poll-backoff-CBq0jVRw.js} +0 -0
  2334. /package/dist/plugin-sdk/{date-time-Bo5FVB7G.js → date-time-Bbp5JvNw.js} +0 -0
  2335. /package/dist/plugin-sdk/{diagnostic-session-state-CT36_PCE.js → diagnostic-session-state-B-9PL5r7.js} +0 -0
  2336. /package/dist/plugin-sdk/{draft-stream-loop-2KC6-8CG.js → draft-stream-loop-DZ1OAyye.js} +0 -0
  2337. /package/dist/plugin-sdk/{fetch-headers-BTcaUCW6.js → fetch-headers-DvXyXtoI.js} +0 -0
  2338. /package/dist/plugin-sdk/{fetch-timeout-Dyj5Y_Ss.js → fetch-timeout-jOIu9Xud.js} +0 -0
  2339. /package/dist/plugin-sdk/{gateway-registry-CtUjFG3Q.js → gateway-registry-C-MTEdvG.js} +0 -0
  2340. /package/dist/plugin-sdk/{inbound-context-Daf9i2Me.js → inbound-context-BNCTzgjG.js} +0 -0
  2341. /package/dist/plugin-sdk/{internal-DFhCtnuk.js → internal-CC6TMTtc.js} +0 -0
  2342. /package/dist/plugin-sdk/{media-payload-CcW51vQj.js → media-payload-DpYEcV-X.js} +0 -0
  2343. /package/dist/plugin-sdk/{polls-B4cMiwMo.js → polls-Dy1NsYKT.js} +0 -0
  2344. /package/dist/plugin-sdk/{proxy-CKQOQYAl.js → proxy-R5TjOIFS.js} +0 -0
  2345. /package/dist/plugin-sdk/{qmd-scope-ubzoBMhc.js → qmd-scope-C9tRnohc.js} +0 -0
  2346. /package/dist/plugin-sdk/{redact-identifier-BAD7jXcr.js → redact-identifier-CDvAeiFm.js} +0 -0
  2347. /package/dist/plugin-sdk/{redact-sensitive-url-DK8OUExz.js → redact-sensitive-url-B0RJQqO7.js} +0 -0
  2348. /package/dist/plugin-sdk/{render-C9LkRUhd.js → render-K7NwXvVu.js} +0 -0
  2349. /package/dist/plugin-sdk/{reply-reference-DxIu2vr0.js → reply-reference-CWEIswqw.js} +0 -0
  2350. /package/dist/plugin-sdk/{secure-random-CO1VkMEt.js → secure-random-C2EhANj2.js} +0 -0
  2351. /package/dist/plugin-sdk/{target-errors-Dn4aykSV.js → target-errors-C0yNDbGS.js} +0 -0
  2352. /package/dist/plugin-sdk/{tool-loop-detection-D6OX2-I9.js → tool-loop-detection-P5u2k0_f.js} +0 -0
  2353. /package/dist/plugin-sdk/{with-timeout-DqkblR98.js → with-timeout-Dl513q34.js} +0 -0
@@ -0,0 +1,4539 @@
1
+ import { $ as buildModelsKeyboard, $t as formatReasoningMessage, A as clearHistoryEntriesIfEnabled, Bn as resolveTelegramInlineButtonsScope, C as buildPairingReply, Cn as readJsonBodyWithLimit, E as DEFAULT_GROUP_HISTORY_LIMIT, Et as resolveChannelConfigWrites, F as removeAckReactionAfterReply, G as resolveEnvelopeFormatOptions, Gn as createDedupeCache, H as resolveInboundDebounceMs, I as shouldAckReaction, Jt as isAbortRequestText, Kt as hasControlCommand, N as recordPendingHistoryEntryIfEnabled, O as buildPendingHistoryContextFromMap, P as recordInboundSession, Pt as registerUnhandledRejectionHandler, Q as formatModelsAvailableHeader, R as dispatchReplyWithBufferedBlockDispatcher, St as formatDurationPrecise, T as sleepWithAbort, U as formatInboundEnvelope, V as createInboundDebouncer, Wn as waitForAbortSignal, X as resolveStoredModelOverride, Xt as matchesMentionWithExplicit, Yt as buildMentionRegexes, Z as buildModelsProviderData, b as logInboundDrop, bt as buildCommandsMessagePaginated, c as loadModelCatalog, er as resolveCommandAuthorizedFromAuthorizers, et as buildProviderKeyboard, f as createTypingCallbacks, it as buildCommandsPaginationKeyboard, l as modelSupportsVision, m as resolveMentionGatingWithBypass, nn as findCodeRegions, nt as getModelsPageSize, rn as isInsideCode, rt as parseModelCallbackData, s as findModelInCatalog, tn as stripReasoningTagsFromText, tr as resolveControlCommandGate, tt as calculateTotalPages, w as computeBackoff, wt as enqueueSystemEvent, x as logTypingFailure, y as logAckFailure } from "./pi-embedded-runner-DMfkIj60.js";
2
+ import { C as recordSessionMetaFromInbound, Gn as getPluginCommandSpecs, S as readSessionUpdatedAt, Wn as executePluginCommand, _n as resolveChannelGroupRequireMention, gn as resolveChannelGroupPolicy, in as resolveTelegramAccount, qn as matchPluginCommand, x as loadSessionStore } from "./runtime-BUpqjZNM.js";
3
+ import { i as defaultRuntime, r as createNonExitingRuntime, t as createSubsystemLogger } from "./subsystem-DBPNbQDQ.js";
4
+ import { i as logVerbose, l as warn, p as getChildLogger, s as shouldLogVerbose, t as danger } from "./globals-B_jjtAje.js";
5
+ import { s as resolveStateDir } from "./paths-BEmvSyOV.js";
6
+ import "./utils-CYk9EKoq.js";
7
+ import { Lt as resolveAgentMaxConcurrent, Yt as resolveDefaultModelForAgent, _ as TELEGRAM_COMMAND_NAME_PATTERN, fr as formatErrorMessage, n as loadConfig, pr as formatUncaughtError, s as writeConfigFile, v as normalizeTelegramCommandName, y as resolveTelegramCustomCommands } from "./config-DKNrb8oT.js";
8
+ import { a as resolveAgentDir, u as resolveDefaultAgentId } from "./agent-scope-BbgPlhtw.js";
9
+ import { p as normalizeAccountId$1, u as resolveThreadSessionKeys } from "./session-key-HSJ2KQTc.js";
10
+ import "./accounts-RHZyaB73.js";
11
+ import "./accounts-CuqIKU8X.js";
12
+ import "./logger-BbFvCoKk.js";
13
+ import "./exec-DQ8j4Fm3.js";
14
+ import "./accounts-Bz_2QZSt.js";
15
+ import "./allow-list-yqasgPpz.js";
16
+ import "./redact-CwCz68Mi.js";
17
+ import "./github-copilot-token-Dgug856m.js";
18
+ import { n as retryAsync } from "./retry-DycQ4ymF.js";
19
+ import { l as resolveStorePath } from "./paths-B88DQEK8.js";
20
+ import "./ip-BkeyFRJr.js";
21
+ import "./ssrf-D_4q0mKh.js";
22
+ import "./fetch-guard-CxXvFYq5.js";
23
+ import "./send-DGUAXb2b.js";
24
+ import { a as resolveOpenProviderRuntimeGroupPolicy } from "./links-D5ecKoG9.js";
25
+ import { C as isSenderAllowed, D as formatLocationText, E as resolveSenderAllowMatch, O as toLocationContext, P as firstDefined, S as resolveTelegramThreadSpec, T as normalizeDmAllowFromWithStore, _ as resolveTelegramForumThreadId, a as buildSenderLabel, b as resolveTelegramReplyId, c as buildTelegramGroupPeerId, d as buildTypingThreadParams, f as describeReplyTarget, g as normalizeForwardedContext, h as hasBotMention, i as buildGroupLabel, l as buildTelegramParentPeer, m as extractTelegramLocation, o as buildSenderName, p as expandTextLinks, s as buildTelegramGroupFrom, u as buildTelegramThreadParams, v as resolveTelegramGroupAllowFromContext, w as normalizeAllowFrom, x as resolveTelegramStreamMode, y as resolveTelegramMediaPlaceholder } from "./wsl-Cw-xOsqF.js";
26
+ import { a as upsertChannelPairingRequest, n as readChannelAllowFromStore } from "./pairing-store-BdOcH_GA.js";
27
+ import { c as resolveChunkMode, i as chunkMarkdownTextWithMode, l as resolveTextChunkLimit } from "./chunk-CuJIMshx.js";
28
+ import { a as resolveAckReaction, n as createReplyPrefixOptions } from "./reply-prefix-CbPHNXlm.js";
29
+ import "./tokens-Do_JU4Rh.js";
30
+ import "./device-pairing-J1IH1jFl.js";
31
+ import "./pairing-token-HQpaqod5.js";
32
+ import { c as logWebhookError, d as startDiagnosticHeartbeat, f as stopDiagnosticHeartbeat, l as logWebhookProcessed, m as isDiagnosticsEnabled, u as logWebhookReceived } from "./diagnostic-C16gioN6.js";
33
+ import "./diagnostic-session-state-B-9PL5r7.js";
34
+ import "./optional-runtime-dependency-Bt_3Yigu.js";
35
+ import { p as isGifMedia, v as mediaKindFromMime } from "./image-ops-BSQmb-17.js";
36
+ import "./wallet-status-CdxTkLWz.js";
37
+ import "./pi-model-discovery-DQdXL_-F.js";
38
+ import "./runtime-dependency-pUwxUAJp.js";
39
+ import "./ws-CxmRDbD9.js";
40
+ import "./path-alias-guards-BlIJ0AmG.js";
41
+ import "./fs-safe-DztQeyQe.js";
42
+ import { n as resolveMarkdownTableMode } from "./markdown-tables-DrB-IM8r.js";
43
+ import { a as fetchRemoteMedia, i as MediaFetchError, n as loadWebMedia, u as getAgentScopedMediaLocalRoots } from "./media-D8pWjqEt.js";
44
+ import "./send-DWB5HFdb.js";
45
+ import { a as saveMediaBuffer } from "./outbound-attachment-C9oadpUP.js";
46
+ import "./fetch-RV7QDF43.js";
47
+ import "./thread-bindings.state-DYYR9qeT.js";
48
+ import "./memory-search-DHSeU4pJ.js";
49
+ import "./manager-DQ1dH8OM.js";
50
+ import "./query-expansion-BM7lmqaP.js";
51
+ import "./common-C90EHP1w.js";
52
+ import { C as isNativeCommandsExplicitlyDisabled, E as resolveNativeSkillsEnabled, T as resolveNativeCommandsEnabled, c as listNativeCommandSpecsForConfig, d as parseCommandArgs, p as resolveCommandArgMenu, r as findCommandByNativeName, s as listNativeCommandSpecs, t as buildCommandTextFromArgs, u as normalizeCommandBody } from "./commands-registry-DwQIFJmL.js";
53
+ import { n as listSkillCommandsForAgents } from "./skill-commands-DCnCOVR_.js";
54
+ import { t as finalizeInboundContext } from "./inbound-context-BNCTzgjG.js";
55
+ import "./directory-live-G7AN8y8N.js";
56
+ import "./targets-BgSHco9b.js";
57
+ import "./sandbox-paths-fc-HFGJr.js";
58
+ import { n as resolveAgentRoute } from "./resolve-route-wp5xq4Ws.js";
59
+ import "./render-K7NwXvVu.js";
60
+ import "./tables-DX84FwPB.js";
61
+ import { n as recordChannelActivity } from "./channel-activity-B7MIaDei.js";
62
+ import "./retry-policy-BTH89onl.js";
63
+ import { _ as splitTelegramCaption, d as isRecoverableTelegramNetworkError, f as markdownToTelegramChunks, g as resolveTelegramFetch, h as wrapFileReferencesInHtml, i as editMessageTelegram, l as resolveTelegramVoiceSend, m as renderTelegramHtmlText, p as markdownToTelegramHtml, t as buildInlineKeyboard, u as wasSentByBot, v as withTelegramApiErrorLogging } from "./send-CRI83FPV.js";
64
+ import { t as makeProxyFetch } from "./proxy-R5TjOIFS.js";
65
+ import { i as getCachedSticker, n as describeStickerImage, t as cacheSticker } from "./sticker-cache-D4Ljzv1P.js";
66
+ import { i as createStatusReactionController, n as DEFAULT_EMOJIS, t as createFinalizableDraftLifecycle } from "./draft-stream-controls-DGYBMJYc.js";
67
+ import path from "node:path";
68
+ import os from "node:os";
69
+ import fs from "node:fs/promises";
70
+ import crypto from "node:crypto";
71
+ import { createServer } from "node:http";
72
+ import { API_CONSTANTS, Bot, GrammyError, InputFile, webhookCallback } from "grammy";
73
+ import { run, sequentialize } from "@grammyjs/runner";
74
+ import { apiThrottler } from "@grammyjs/transformer-throttler";
75
+
76
+ //#region src/telegram/allowed-updates.ts
77
+ function resolveTelegramAllowedUpdates() {
78
+ const updates = [...API_CONSTANTS.DEFAULT_UPDATE_TYPES];
79
+ if (!updates.includes("message_reaction")) updates.push("message_reaction");
80
+ if (!updates.includes("channel_post")) updates.push("channel_post");
81
+ return updates;
82
+ }
83
+
84
+ //#endregion
85
+ //#region src/telegram/bot-updates.ts
86
+ const MEDIA_GROUP_TIMEOUT_MS = 500;
87
+ const RECENT_TELEGRAM_UPDATE_TTL_MS = 5 * 6e4;
88
+ const RECENT_TELEGRAM_UPDATE_MAX = 2e3;
89
+ const resolveTelegramUpdateId = (ctx) => ctx.update?.update_id ?? ctx.update_id;
90
+ const buildTelegramUpdateKey = (ctx) => {
91
+ const updateId = resolveTelegramUpdateId(ctx);
92
+ if (typeof updateId === "number") return `update:${updateId}`;
93
+ const callbackId = ctx.callbackQuery?.id;
94
+ if (callbackId) return `callback:${callbackId}`;
95
+ const msg = ctx.message ?? ctx.channelPost ?? ctx.editedChannelPost ?? ctx.update?.message ?? ctx.update?.edited_message ?? ctx.update?.channel_post ?? ctx.update?.edited_channel_post ?? ctx.callbackQuery?.message;
96
+ const chatId = msg?.chat?.id;
97
+ const messageId = msg?.message_id;
98
+ if (typeof chatId !== "undefined" && typeof messageId === "number") return `message:${chatId}:${messageId}`;
99
+ };
100
+ const createTelegramUpdateDedupe = () => createDedupeCache({
101
+ ttlMs: RECENT_TELEGRAM_UPDATE_TTL_MS,
102
+ maxSize: RECENT_TELEGRAM_UPDATE_MAX
103
+ });
104
+
105
+ //#endregion
106
+ //#region src/telegram/bot/delivery.ts
107
+ const PARSE_ERR_RE = /can't parse entities|parse entities|find end of the entity/i;
108
+ const EMPTY_TEXT_ERR_RE = /message text is empty/i;
109
+ const VOICE_FORBIDDEN_RE = /VOICE_MESSAGES_FORBIDDEN/;
110
+ const FILE_TOO_BIG_RE = /file is too big/i;
111
+ const TELEGRAM_MEDIA_SSRF_POLICY = {
112
+ allowedHostnames: ["api.telegram.org"],
113
+ allowRfc2544BenchmarkRange: true
114
+ };
115
+ async function deliverReplies(params) {
116
+ const { replies, chatId, runtime, bot, replyToMode, textLimit, thread, linkPreview, replyQuoteText } = params;
117
+ const chunkMode = params.chunkMode ?? "length";
118
+ let hasReplied = false;
119
+ let hasDelivered = false;
120
+ const markDelivered = () => {
121
+ hasDelivered = true;
122
+ };
123
+ const chunkText = (markdown) => {
124
+ const markdownChunks = chunkMode === "newline" ? chunkMarkdownTextWithMode(markdown, textLimit, chunkMode) : [markdown];
125
+ const chunks = [];
126
+ for (const chunk of markdownChunks) {
127
+ const nested = markdownToTelegramChunks(chunk, textLimit, { tableMode: params.tableMode });
128
+ if (!nested.length && chunk) {
129
+ chunks.push({
130
+ html: wrapFileReferencesInHtml(markdownToTelegramHtml(chunk, {
131
+ tableMode: params.tableMode,
132
+ wrapFileRefs: false
133
+ })),
134
+ text: chunk
135
+ });
136
+ continue;
137
+ }
138
+ chunks.push(...nested);
139
+ }
140
+ return chunks;
141
+ };
142
+ for (const reply of replies) {
143
+ const hasMedia = Boolean(reply?.mediaUrl) || (reply?.mediaUrls?.length ?? 0) > 0;
144
+ if (!reply?.text && !hasMedia) {
145
+ if (reply?.audioAsVoice) {
146
+ logVerbose("telegram reply has audioAsVoice without media/text; skipping");
147
+ continue;
148
+ }
149
+ runtime.error?.(danger("reply missing text/media"));
150
+ continue;
151
+ }
152
+ const replyToId = replyToMode === "off" ? void 0 : resolveTelegramReplyId(reply.replyToId);
153
+ const replyToMessageIdForPayload = replyToId && (replyToMode === "all" || !hasReplied) ? replyToId : void 0;
154
+ const mediaList = reply.mediaUrls?.length ? reply.mediaUrls : reply.mediaUrl ? [reply.mediaUrl] : [];
155
+ const telegramData = reply.channelData?.telegram;
156
+ const replyMarkup = buildInlineKeyboard(telegramData?.buttons);
157
+ if (mediaList.length === 0) {
158
+ const chunks = chunkText(reply.text || "");
159
+ let sentTextChunk = false;
160
+ for (let i = 0; i < chunks.length; i += 1) {
161
+ const chunk = chunks[i];
162
+ if (!chunk) continue;
163
+ const shouldAttachButtons = i === 0 && replyMarkup;
164
+ const chunkReplyToMessageId = replyToMode === "all" || i === 0 ? replyToMessageIdForPayload : void 0;
165
+ await sendTelegramText(bot, chatId, chunk.html, runtime, {
166
+ replyToMessageId: chunkReplyToMessageId,
167
+ replyQuoteText,
168
+ thread,
169
+ textMode: "html",
170
+ plainText: chunk.text,
171
+ linkPreview,
172
+ replyMarkup: shouldAttachButtons ? replyMarkup : void 0
173
+ });
174
+ sentTextChunk = true;
175
+ markDelivered();
176
+ }
177
+ if (replyToMessageIdForPayload && !hasReplied && sentTextChunk) hasReplied = true;
178
+ continue;
179
+ }
180
+ let first = true;
181
+ let pendingFollowUpText;
182
+ for (const mediaUrl of mediaList) {
183
+ const isFirstMedia = first;
184
+ const media = await loadWebMedia(mediaUrl, { localRoots: params.mediaLocalRoots });
185
+ const kind = mediaKindFromMime(media.contentType ?? void 0);
186
+ const isGif = isGifMedia({
187
+ contentType: media.contentType,
188
+ fileName: media.fileName
189
+ });
190
+ const fileName = media.fileName ?? (isGif ? "animation.gif" : "file");
191
+ const file = new InputFile(media.buffer, fileName);
192
+ const { caption, followUpText } = splitTelegramCaption(isFirstMedia ? reply.text ?? void 0 : void 0);
193
+ const htmlCaption = caption ? renderTelegramHtmlText(caption, { tableMode: params.tableMode }) : void 0;
194
+ if (followUpText) pendingFollowUpText = followUpText;
195
+ first = false;
196
+ const replyToMessageId = replyToMode === "all" || isFirstMedia ? replyToMessageIdForPayload : void 0;
197
+ const shouldAttachButtonsToMedia = isFirstMedia && replyMarkup && !followUpText;
198
+ const mediaParams = {
199
+ caption: htmlCaption,
200
+ ...htmlCaption ? { parse_mode: "HTML" } : {},
201
+ ...shouldAttachButtonsToMedia ? { reply_markup: replyMarkup } : {},
202
+ ...buildTelegramSendParams({
203
+ replyToMessageId,
204
+ thread
205
+ })
206
+ };
207
+ if (isGif) {
208
+ await withTelegramApiErrorLogging({
209
+ operation: "sendAnimation",
210
+ runtime,
211
+ fn: () => bot.api.sendAnimation(chatId, file, { ...mediaParams })
212
+ });
213
+ markDelivered();
214
+ } else if (kind === "image") {
215
+ await withTelegramApiErrorLogging({
216
+ operation: "sendPhoto",
217
+ runtime,
218
+ fn: () => bot.api.sendPhoto(chatId, file, { ...mediaParams })
219
+ });
220
+ markDelivered();
221
+ } else if (kind === "video") {
222
+ await withTelegramApiErrorLogging({
223
+ operation: "sendVideo",
224
+ runtime,
225
+ fn: () => bot.api.sendVideo(chatId, file, { ...mediaParams })
226
+ });
227
+ markDelivered();
228
+ } else if (kind === "audio") {
229
+ const { useVoice } = resolveTelegramVoiceSend({
230
+ wantsVoice: reply.audioAsVoice === true,
231
+ contentType: media.contentType,
232
+ fileName,
233
+ logFallback: logVerbose
234
+ });
235
+ if (useVoice) {
236
+ await params.onVoiceRecording?.();
237
+ try {
238
+ await withTelegramApiErrorLogging({
239
+ operation: "sendVoice",
240
+ runtime,
241
+ shouldLog: (err) => !isVoiceMessagesForbidden(err),
242
+ fn: () => bot.api.sendVoice(chatId, file, { ...mediaParams })
243
+ });
244
+ markDelivered();
245
+ } catch (voiceErr) {
246
+ if (isVoiceMessagesForbidden(voiceErr)) {
247
+ const fallbackText = reply.text;
248
+ if (!fallbackText || !fallbackText.trim()) throw voiceErr;
249
+ logVerbose("telegram sendVoice forbidden (recipient has voice messages blocked in privacy settings); falling back to text");
250
+ await sendTelegramVoiceFallbackText({
251
+ bot,
252
+ chatId,
253
+ runtime,
254
+ text: fallbackText,
255
+ chunkText,
256
+ replyToId: replyToMessageIdForPayload,
257
+ replyToMode,
258
+ thread,
259
+ linkPreview,
260
+ replyMarkup,
261
+ replyQuoteText
262
+ });
263
+ if (replyToMessageIdForPayload && !hasReplied) hasReplied = true;
264
+ markDelivered();
265
+ continue;
266
+ }
267
+ throw voiceErr;
268
+ }
269
+ } else {
270
+ await withTelegramApiErrorLogging({
271
+ operation: "sendAudio",
272
+ runtime,
273
+ fn: () => bot.api.sendAudio(chatId, file, { ...mediaParams })
274
+ });
275
+ markDelivered();
276
+ }
277
+ } else {
278
+ await withTelegramApiErrorLogging({
279
+ operation: "sendDocument",
280
+ runtime,
281
+ fn: () => bot.api.sendDocument(chatId, file, { ...mediaParams })
282
+ });
283
+ markDelivered();
284
+ }
285
+ if (replyToMessageId && !hasReplied) hasReplied = true;
286
+ if (pendingFollowUpText && isFirstMedia) {
287
+ const chunks = chunkText(pendingFollowUpText);
288
+ for (let i = 0; i < chunks.length; i += 1) {
289
+ const chunk = chunks[i];
290
+ const followUpReplyToMessageId = replyToMode === "all" ? replyToMessageIdForPayload : void 0;
291
+ await sendTelegramText(bot, chatId, chunk.html, runtime, {
292
+ replyToMessageId: followUpReplyToMessageId,
293
+ thread,
294
+ textMode: "html",
295
+ plainText: chunk.text,
296
+ linkPreview,
297
+ replyMarkup: i === 0 ? replyMarkup : void 0
298
+ });
299
+ markDelivered();
300
+ }
301
+ pendingFollowUpText = void 0;
302
+ }
303
+ if (replyToMessageIdForPayload && !hasReplied) hasReplied = true;
304
+ }
305
+ }
306
+ return { delivered: hasDelivered };
307
+ }
308
+ async function resolveMedia(ctx, maxBytes, token, proxyFetch) {
309
+ const msg = ctx.message;
310
+ const downloadAndSaveTelegramFile = async (filePath, fetchImpl) => {
311
+ const fetched = await fetchRemoteMedia({
312
+ url: `https://api.telegram.org/file/bot${token}/${filePath}`,
313
+ fetchImpl,
314
+ filePathHint: filePath,
315
+ maxBytes,
316
+ ssrfPolicy: TELEGRAM_MEDIA_SSRF_POLICY
317
+ });
318
+ const originalName = fetched.fileName ?? filePath;
319
+ return saveMediaBuffer(fetched.buffer, fetched.contentType, "inbound", maxBytes, originalName);
320
+ };
321
+ if (msg.sticker) {
322
+ const sticker = msg.sticker;
323
+ if (sticker.is_animated || sticker.is_video) {
324
+ logVerbose("telegram: skipping animated/video sticker (only static stickers supported)");
325
+ return null;
326
+ }
327
+ if (!sticker.file_id) return null;
328
+ try {
329
+ const file = await ctx.getFile();
330
+ if (!file.file_path) {
331
+ logVerbose("telegram: getFile returned no file_path for sticker");
332
+ return null;
333
+ }
334
+ const fetchImpl = proxyFetch ?? globalThis.fetch;
335
+ if (!fetchImpl) {
336
+ logVerbose("telegram: fetch not available for sticker download");
337
+ return null;
338
+ }
339
+ const saved = await downloadAndSaveTelegramFile(file.file_path, fetchImpl);
340
+ const cached = sticker.file_unique_id ? getCachedSticker(sticker.file_unique_id) : null;
341
+ if (cached) {
342
+ logVerbose(`telegram: sticker cache hit for ${sticker.file_unique_id}`);
343
+ const fileId = sticker.file_id ?? cached.fileId;
344
+ const emoji = sticker.emoji ?? cached.emoji;
345
+ const setName = sticker.set_name ?? cached.setName;
346
+ if (fileId !== cached.fileId || emoji !== cached.emoji || setName !== cached.setName) cacheSticker({
347
+ ...cached,
348
+ fileId,
349
+ emoji,
350
+ setName
351
+ });
352
+ return {
353
+ path: saved.path,
354
+ contentType: saved.contentType,
355
+ placeholder: "<media:sticker>",
356
+ stickerMetadata: {
357
+ emoji,
358
+ setName,
359
+ fileId,
360
+ fileUniqueId: sticker.file_unique_id,
361
+ cachedDescription: cached.description
362
+ }
363
+ };
364
+ }
365
+ return {
366
+ path: saved.path,
367
+ contentType: saved.contentType,
368
+ placeholder: "<media:sticker>",
369
+ stickerMetadata: {
370
+ emoji: sticker.emoji ?? void 0,
371
+ setName: sticker.set_name ?? void 0,
372
+ fileId: sticker.file_id,
373
+ fileUniqueId: sticker.file_unique_id
374
+ }
375
+ };
376
+ } catch (err) {
377
+ logVerbose(`telegram: failed to process sticker: ${String(err)}`);
378
+ return null;
379
+ }
380
+ }
381
+ if (!(msg.photo?.[msg.photo.length - 1] ?? msg.video ?? msg.video_note ?? msg.document ?? msg.audio ?? msg.voice)?.file_id) return null;
382
+ let file;
383
+ try {
384
+ file = await retryAsync(() => ctx.getFile(), {
385
+ attempts: 3,
386
+ minDelayMs: 1e3,
387
+ maxDelayMs: 4e3,
388
+ jitter: .2,
389
+ label: "telegram:getFile",
390
+ shouldRetry: isRetryableGetFileError,
391
+ onRetry: ({ attempt, maxAttempts }) => logVerbose(`telegram: getFile retry ${attempt}/${maxAttempts}`)
392
+ });
393
+ } catch (err) {
394
+ if (isFileTooBigError(err)) {
395
+ logVerbose(warn("telegram: getFile failed - file exceeds Telegram Bot API 20MB limit; skipping attachment"));
396
+ return null;
397
+ }
398
+ logVerbose(`telegram: getFile failed after retries: ${String(err)}`);
399
+ return null;
400
+ }
401
+ if (!file.file_path) throw new Error("Telegram getFile returned no file_path");
402
+ const fetchImpl = proxyFetch ?? globalThis.fetch;
403
+ if (!fetchImpl) throw new Error("fetch is not available; set channels.telegram.proxy in config");
404
+ const saved = await downloadAndSaveTelegramFile(file.file_path, fetchImpl);
405
+ const placeholder = resolveTelegramMediaPlaceholder(msg) ?? "<media:document>";
406
+ return {
407
+ path: saved.path,
408
+ contentType: saved.contentType,
409
+ placeholder
410
+ };
411
+ }
412
+ function isVoiceMessagesForbidden(err) {
413
+ if (err instanceof GrammyError) return VOICE_FORBIDDEN_RE.test(err.description);
414
+ return VOICE_FORBIDDEN_RE.test(formatErrorMessage(err));
415
+ }
416
+ /**
417
+ * Returns true if the error is Telegram's "file is too big" error.
418
+ * This happens when trying to download files >20MB via the Bot API.
419
+ * Unlike network errors, this is a permanent error and should not be retried.
420
+ */
421
+ function isFileTooBigError(err) {
422
+ if (err instanceof GrammyError) return FILE_TOO_BIG_RE.test(err.description);
423
+ return FILE_TOO_BIG_RE.test(formatErrorMessage(err));
424
+ }
425
+ /**
426
+ * Returns true if the error is a transient network error that should be retried.
427
+ * Returns false for permanent errors like "file is too big" (400 Bad Request).
428
+ */
429
+ function isRetryableGetFileError(err) {
430
+ if (isFileTooBigError(err)) return false;
431
+ return true;
432
+ }
433
+ async function sendTelegramVoiceFallbackText(opts) {
434
+ const chunks = opts.chunkText(opts.text);
435
+ for (let i = 0; i < chunks.length; i += 1) {
436
+ const chunk = chunks[i];
437
+ const chunkReplyToId = opts.replyToMode === "all" || i === 0 ? opts.replyToId : void 0;
438
+ await sendTelegramText(opts.bot, opts.chatId, chunk.html, opts.runtime, {
439
+ replyToMessageId: chunkReplyToId,
440
+ replyQuoteText: opts.replyQuoteText,
441
+ thread: opts.thread,
442
+ textMode: "html",
443
+ plainText: chunk.text,
444
+ linkPreview: opts.linkPreview,
445
+ replyMarkup: i === 0 ? opts.replyMarkup : void 0
446
+ });
447
+ }
448
+ }
449
+ function buildTelegramSendParams(opts) {
450
+ const threadParams = buildTelegramThreadParams(opts?.thread);
451
+ const params = {};
452
+ if (opts?.replyToMessageId) params.reply_to_message_id = opts.replyToMessageId;
453
+ if (threadParams) params.message_thread_id = threadParams.message_thread_id;
454
+ return params;
455
+ }
456
+ async function sendTelegramText(bot, chatId, text, runtime, opts) {
457
+ const baseParams = buildTelegramSendParams({
458
+ replyToMessageId: opts?.replyToMessageId,
459
+ thread: opts?.thread
460
+ });
461
+ const linkPreviewOptions = opts?.linkPreview ?? true ? void 0 : { is_disabled: true };
462
+ const htmlText = (opts?.textMode ?? "markdown") === "html" ? text : markdownToTelegramHtml(text);
463
+ const fallbackText = opts?.plainText ?? text;
464
+ const hasFallbackText = fallbackText.trim().length > 0;
465
+ const sendPlainFallback = async () => {
466
+ const res = await withTelegramApiErrorLogging({
467
+ operation: "sendMessage",
468
+ runtime,
469
+ fn: () => bot.api.sendMessage(chatId, fallbackText, {
470
+ ...linkPreviewOptions ? { link_preview_options: linkPreviewOptions } : {},
471
+ ...opts?.replyMarkup ? { reply_markup: opts.replyMarkup } : {},
472
+ ...baseParams
473
+ })
474
+ });
475
+ runtime.log?.(`telegram sendMessage ok chat=${chatId} message=${res.message_id} (plain)`);
476
+ return res.message_id;
477
+ };
478
+ if (!htmlText.trim()) {
479
+ if (!hasFallbackText) throw new Error("telegram sendMessage failed: empty formatted text and empty plain fallback");
480
+ return await sendPlainFallback();
481
+ }
482
+ try {
483
+ const res = await withTelegramApiErrorLogging({
484
+ operation: "sendMessage",
485
+ runtime,
486
+ shouldLog: (err) => {
487
+ const errText = formatErrorMessage(err);
488
+ return !PARSE_ERR_RE.test(errText) && !EMPTY_TEXT_ERR_RE.test(errText);
489
+ },
490
+ fn: () => bot.api.sendMessage(chatId, htmlText, {
491
+ parse_mode: "HTML",
492
+ ...linkPreviewOptions ? { link_preview_options: linkPreviewOptions } : {},
493
+ ...opts?.replyMarkup ? { reply_markup: opts.replyMarkup } : {},
494
+ ...baseParams
495
+ })
496
+ });
497
+ runtime.log?.(`telegram sendMessage ok chat=${chatId} message=${res.message_id}`);
498
+ return res.message_id;
499
+ } catch (err) {
500
+ const errText = formatErrorMessage(err);
501
+ if (PARSE_ERR_RE.test(errText) || EMPTY_TEXT_ERR_RE.test(errText)) {
502
+ if (!hasFallbackText) throw err;
503
+ runtime.log?.(`telegram formatted send failed; retrying without formatting: ${errText}`);
504
+ return await sendPlainFallback();
505
+ }
506
+ throw err;
507
+ }
508
+ }
509
+
510
+ //#endregion
511
+ //#region src/telegram/dm-access.ts
512
+ function resolveTelegramSenderIdentity(msg, chatId) {
513
+ const from = msg.from;
514
+ const userId = from?.id != null ? String(from.id) : null;
515
+ return {
516
+ username: from?.username ?? "",
517
+ userId,
518
+ candidateId: userId ?? String(chatId),
519
+ firstName: from?.first_name,
520
+ lastName: from?.last_name
521
+ };
522
+ }
523
+ async function enforceTelegramDmAccess(params) {
524
+ const { isGroup, dmPolicy, msg, chatId, effectiveDmAllow, accountId, bot, logger } = params;
525
+ if (isGroup) return true;
526
+ if (dmPolicy === "disabled") return false;
527
+ if (dmPolicy === "open") return true;
528
+ const sender = resolveTelegramSenderIdentity(msg, chatId);
529
+ const allowMatch = resolveSenderAllowMatch({
530
+ allow: effectiveDmAllow,
531
+ senderId: sender.candidateId,
532
+ senderUsername: sender.username
533
+ });
534
+ const allowMatchMeta = `matchKey=${allowMatch.matchKey ?? "none"} matchSource=${allowMatch.matchSource ?? "none"}`;
535
+ if (effectiveDmAllow.hasWildcard || effectiveDmAllow.hasEntries && allowMatch.allowed) return true;
536
+ if (dmPolicy === "pairing") {
537
+ try {
538
+ const telegramUserId = sender.userId ?? sender.candidateId;
539
+ const { code, created } = await upsertChannelPairingRequest({
540
+ channel: "telegram",
541
+ id: telegramUserId,
542
+ accountId,
543
+ meta: {
544
+ username: sender.username || void 0,
545
+ firstName: sender.firstName,
546
+ lastName: sender.lastName
547
+ }
548
+ });
549
+ if (created) {
550
+ logger.info({
551
+ chatId: String(chatId),
552
+ senderUserId: sender.userId ?? void 0,
553
+ username: sender.username || void 0,
554
+ firstName: sender.firstName,
555
+ lastName: sender.lastName,
556
+ matchKey: allowMatch.matchKey ?? "none",
557
+ matchSource: allowMatch.matchSource ?? "none"
558
+ }, "telegram pairing request");
559
+ await withTelegramApiErrorLogging({
560
+ operation: "sendMessage",
561
+ fn: () => bot.api.sendMessage(chatId, buildPairingReply({
562
+ channel: "telegram",
563
+ idLine: `Your Telegram user id: ${telegramUserId}`,
564
+ code
565
+ }))
566
+ });
567
+ }
568
+ } catch (err) {
569
+ logVerbose(`telegram pairing reply failed for chat ${chatId}: ${String(err)}`);
570
+ }
571
+ return false;
572
+ }
573
+ logVerbose(`Blocked unauthorized telegram sender ${sender.candidateId} (dmPolicy=${dmPolicy}, ${allowMatchMeta})`);
574
+ return false;
575
+ }
576
+
577
+ //#endregion
578
+ //#region src/telegram/group-access.ts
579
+ const evaluateTelegramGroupBaseAccess = (params) => {
580
+ if (!params.isGroup) return { allowed: true };
581
+ if (params.groupConfig?.enabled === false) return {
582
+ allowed: false,
583
+ reason: "group-disabled"
584
+ };
585
+ if (params.topicConfig?.enabled === false) return {
586
+ allowed: false,
587
+ reason: "topic-disabled"
588
+ };
589
+ if (!params.enforceAllowOverride || !params.hasGroupAllowOverride) return { allowed: true };
590
+ if (!params.effectiveGroupAllow.hasEntries) return {
591
+ allowed: false,
592
+ reason: "group-override-unauthorized"
593
+ };
594
+ const senderId = params.senderId ?? "";
595
+ if (params.requireSenderForAllowOverride && !senderId) return {
596
+ allowed: false,
597
+ reason: "group-override-unauthorized"
598
+ };
599
+ if (!isSenderAllowed({
600
+ allow: params.effectiveGroupAllow,
601
+ senderId,
602
+ senderUsername: params.senderUsername ?? ""
603
+ })) return {
604
+ allowed: false,
605
+ reason: "group-override-unauthorized"
606
+ };
607
+ return { allowed: true };
608
+ };
609
+ const resolveTelegramRuntimeGroupPolicy = (params) => resolveOpenProviderRuntimeGroupPolicy({
610
+ providerConfigPresent: params.providerConfigPresent,
611
+ groupPolicy: params.groupPolicy,
612
+ defaultGroupPolicy: params.defaultGroupPolicy
613
+ });
614
+ const evaluateTelegramGroupPolicyAccess = (params) => {
615
+ const { groupPolicy: runtimeFallbackPolicy } = resolveTelegramRuntimeGroupPolicy({
616
+ providerConfigPresent: params.cfg.channels?.telegram !== void 0,
617
+ groupPolicy: params.telegramCfg.groupPolicy,
618
+ defaultGroupPolicy: params.cfg.channels?.defaults?.groupPolicy
619
+ });
620
+ const fallbackPolicy = firstDefined(params.telegramCfg.groupPolicy, params.cfg.channels?.defaults?.groupPolicy) ?? runtimeFallbackPolicy;
621
+ const groupPolicy = params.useTopicAndGroupOverrides ? firstDefined(params.topicConfig?.groupPolicy, params.groupConfig?.groupPolicy, params.telegramCfg.groupPolicy, params.cfg.channels?.defaults?.groupPolicy) ?? runtimeFallbackPolicy : fallbackPolicy;
622
+ if (!params.isGroup || !params.enforcePolicy) return {
623
+ allowed: true,
624
+ groupPolicy
625
+ };
626
+ if (groupPolicy === "disabled") return {
627
+ allowed: false,
628
+ reason: "group-policy-disabled",
629
+ groupPolicy
630
+ };
631
+ if (groupPolicy === "allowlist" && params.enforceAllowlistAuthorization) {
632
+ const senderId = params.senderId ?? "";
633
+ if (params.requireSenderForAllowlistAuthorization && !senderId) return {
634
+ allowed: false,
635
+ reason: "group-policy-allowlist-no-sender",
636
+ groupPolicy
637
+ };
638
+ if (!params.allowEmptyAllowlistEntries && !params.effectiveGroupAllow.hasEntries) return {
639
+ allowed: false,
640
+ reason: "group-policy-allowlist-empty",
641
+ groupPolicy
642
+ };
643
+ const senderUsername = params.senderUsername ?? "";
644
+ if (!isSenderAllowed({
645
+ allow: params.effectiveGroupAllow,
646
+ senderId,
647
+ senderUsername
648
+ })) return {
649
+ allowed: false,
650
+ reason: "group-policy-allowlist-unauthorized",
651
+ groupPolicy
652
+ };
653
+ }
654
+ if (params.checkChatAllowlist) {
655
+ const groupAllowlist = params.resolveGroupPolicy(params.chatId);
656
+ if (groupAllowlist.allowlistEnabled && !groupAllowlist.allowed) return {
657
+ allowed: false,
658
+ reason: "group-chat-not-allowed",
659
+ groupPolicy
660
+ };
661
+ }
662
+ return {
663
+ allowed: true,
664
+ groupPolicy
665
+ };
666
+ };
667
+
668
+ //#endregion
669
+ //#region src/telegram/group-migration.ts
670
+ function resolveAccountGroups(cfg, accountId) {
671
+ if (!accountId) return {};
672
+ const normalized = normalizeAccountId$1(accountId);
673
+ const accounts = cfg.channels?.telegram?.accounts;
674
+ if (!accounts || typeof accounts !== "object") return {};
675
+ const exact = accounts[normalized];
676
+ if (exact?.groups) return { groups: exact.groups };
677
+ const matchKey = Object.keys(accounts).find((key) => key.toLowerCase() === normalized.toLowerCase());
678
+ return { groups: matchKey ? accounts[matchKey]?.groups : void 0 };
679
+ }
680
+ function migrateTelegramGroupsInPlace(groups, oldChatId, newChatId) {
681
+ if (!groups) return {
682
+ migrated: false,
683
+ skippedExisting: false
684
+ };
685
+ if (oldChatId === newChatId) return {
686
+ migrated: false,
687
+ skippedExisting: false
688
+ };
689
+ if (!Object.hasOwn(groups, oldChatId)) return {
690
+ migrated: false,
691
+ skippedExisting: false
692
+ };
693
+ if (Object.hasOwn(groups, newChatId)) return {
694
+ migrated: false,
695
+ skippedExisting: true
696
+ };
697
+ groups[newChatId] = groups[oldChatId];
698
+ delete groups[oldChatId];
699
+ return {
700
+ migrated: true,
701
+ skippedExisting: false
702
+ };
703
+ }
704
+ function migrateTelegramGroupConfig(params) {
705
+ const scopes = [];
706
+ let migrated = false;
707
+ let skippedExisting = false;
708
+ const migrationTargets = [{
709
+ scope: "account",
710
+ groups: resolveAccountGroups(params.cfg, params.accountId).groups
711
+ }, {
712
+ scope: "global",
713
+ groups: params.cfg.channels?.telegram?.groups
714
+ }];
715
+ for (const target of migrationTargets) {
716
+ const result = migrateTelegramGroupsInPlace(target.groups, params.oldChatId, params.newChatId);
717
+ if (result.migrated) {
718
+ migrated = true;
719
+ scopes.push(target.scope);
720
+ }
721
+ if (result.skippedExisting) skippedExisting = true;
722
+ }
723
+ return {
724
+ migrated,
725
+ skippedExisting,
726
+ scopes
727
+ };
728
+ }
729
+
730
+ //#endregion
731
+ //#region src/telegram/bot-handlers.ts
732
+ function isMediaSizeLimitError(err) {
733
+ const errMsg = String(err);
734
+ return errMsg.includes("exceeds") && errMsg.includes("MB limit");
735
+ }
736
+ function isRecoverableMediaGroupError(err) {
737
+ return err instanceof MediaFetchError || isMediaSizeLimitError(err);
738
+ }
739
+ function hasInboundMedia(msg) {
740
+ return Boolean(msg.media_group_id) || Array.isArray(msg.photo) && msg.photo.length > 0 || Boolean(msg.video ?? msg.video_note ?? msg.document ?? msg.audio ?? msg.voice ?? msg.sticker);
741
+ }
742
+ function hasReplyTargetMedia(msg) {
743
+ const externalReply = msg.external_reply;
744
+ const replyTarget = msg.reply_to_message ?? externalReply;
745
+ return Boolean(replyTarget && hasInboundMedia(replyTarget));
746
+ }
747
+ function resolveInboundMediaFileId(msg) {
748
+ return msg.sticker?.file_id ?? msg.photo?.[msg.photo.length - 1]?.file_id ?? msg.video?.file_id ?? msg.video_note?.file_id ?? msg.document?.file_id ?? msg.audio?.file_id ?? msg.voice?.file_id;
749
+ }
750
+ const registerTelegramHandlers = ({ cfg, accountId, bot, opts, runtime, mediaMaxBytes, telegramCfg, allowFrom, groupAllowFrom, resolveGroupPolicy, resolveTelegramGroupConfig, shouldSkipUpdate, processMessage, logger }) => {
751
+ const DEFAULT_TEXT_FRAGMENT_MAX_GAP_MS = 1500;
752
+ const TELEGRAM_TEXT_FRAGMENT_START_THRESHOLD_CHARS = 4e3;
753
+ const TELEGRAM_TEXT_FRAGMENT_MAX_GAP_MS = typeof opts.testTimings?.textFragmentGapMs === "number" && Number.isFinite(opts.testTimings.textFragmentGapMs) ? Math.max(10, Math.floor(opts.testTimings.textFragmentGapMs)) : DEFAULT_TEXT_FRAGMENT_MAX_GAP_MS;
754
+ const TELEGRAM_TEXT_FRAGMENT_MAX_ID_GAP = 1;
755
+ const TELEGRAM_TEXT_FRAGMENT_MAX_PARTS = 12;
756
+ const TELEGRAM_TEXT_FRAGMENT_MAX_TOTAL_CHARS = 5e4;
757
+ const mediaGroupTimeoutMs = typeof opts.testTimings?.mediaGroupFlushMs === "number" && Number.isFinite(opts.testTimings.mediaGroupFlushMs) ? Math.max(10, Math.floor(opts.testTimings.mediaGroupFlushMs)) : MEDIA_GROUP_TIMEOUT_MS;
758
+ const mediaGroupBuffer = /* @__PURE__ */ new Map();
759
+ let mediaGroupProcessing = Promise.resolve();
760
+ const textFragmentBuffer = /* @__PURE__ */ new Map();
761
+ let textFragmentProcessing = Promise.resolve();
762
+ const debounceMs = resolveInboundDebounceMs({
763
+ cfg,
764
+ channel: "telegram"
765
+ });
766
+ const FORWARD_BURST_DEBOUNCE_MS = 80;
767
+ const resolveTelegramDebounceLane = (msg) => {
768
+ const forwardMeta = msg;
769
+ return forwardMeta.forward_origin ?? forwardMeta.forward_from ?? forwardMeta.forward_from_chat ?? forwardMeta.forward_sender_name ?? forwardMeta.forward_date ? "forward" : "default";
770
+ };
771
+ const buildSyntheticTextMessage = (params) => ({
772
+ ...params.base,
773
+ ...params.from ? { from: params.from } : {},
774
+ text: params.text,
775
+ caption: void 0,
776
+ caption_entities: void 0,
777
+ entities: void 0,
778
+ ...params.date != null ? { date: params.date } : {}
779
+ });
780
+ const buildSyntheticContext = (ctx, message) => {
781
+ const getFile = typeof ctx.getFile === "function" ? ctx.getFile.bind(ctx) : async () => ({});
782
+ return {
783
+ message,
784
+ me: ctx.me,
785
+ getFile
786
+ };
787
+ };
788
+ const inboundDebouncer = createInboundDebouncer({
789
+ debounceMs,
790
+ resolveDebounceMs: (entry) => entry.debounceLane === "forward" ? FORWARD_BURST_DEBOUNCE_MS : debounceMs,
791
+ buildKey: (entry) => entry.debounceKey,
792
+ shouldDebounce: (entry) => {
793
+ const text = entry.msg.text ?? entry.msg.caption ?? "";
794
+ const hasText = text.trim().length > 0;
795
+ if (hasText && hasControlCommand(text, cfg, { botUsername: entry.botUsername })) return false;
796
+ if (entry.debounceLane === "forward") return true;
797
+ return entry.allMedia.length === 0 && hasText;
798
+ },
799
+ onFlush: async (entries) => {
800
+ const last = entries.at(-1);
801
+ if (!last) return;
802
+ if (entries.length === 1) {
803
+ const replyMedia = await resolveReplyMediaForMessage(last.ctx, last.msg);
804
+ await processMessage(last.ctx, last.allMedia, last.storeAllowFrom, void 0, replyMedia);
805
+ return;
806
+ }
807
+ const combinedText = entries.map((entry) => entry.msg.text ?? entry.msg.caption ?? "").filter(Boolean).join("\n");
808
+ const combinedMedia = entries.flatMap((entry) => entry.allMedia);
809
+ if (!combinedText.trim() && combinedMedia.length === 0) return;
810
+ const first = entries[0];
811
+ const baseCtx = first.ctx;
812
+ const syntheticMessage = buildSyntheticTextMessage({
813
+ base: first.msg,
814
+ text: combinedText,
815
+ date: last.msg.date ?? first.msg.date
816
+ });
817
+ const messageIdOverride = last.msg.message_id ? String(last.msg.message_id) : void 0;
818
+ const syntheticCtx = buildSyntheticContext(baseCtx, syntheticMessage);
819
+ const replyMedia = await resolveReplyMediaForMessage(baseCtx, syntheticMessage);
820
+ await processMessage(syntheticCtx, combinedMedia, first.storeAllowFrom, messageIdOverride ? { messageIdOverride } : void 0, replyMedia);
821
+ },
822
+ onError: (err) => {
823
+ runtime.error?.(danger(`telegram debounce flush failed: ${String(err)}`));
824
+ }
825
+ });
826
+ const resolveTelegramSessionState = (params) => {
827
+ const resolvedThreadId = params.resolvedThreadId ?? resolveTelegramForumThreadId({
828
+ isForum: params.isForum,
829
+ messageThreadId: params.messageThreadId
830
+ });
831
+ const peerId = params.isGroup ? buildTelegramGroupPeerId(params.chatId, resolvedThreadId) : String(params.chatId);
832
+ const parentPeer = buildTelegramParentPeer({
833
+ isGroup: params.isGroup,
834
+ resolvedThreadId,
835
+ chatId: params.chatId
836
+ });
837
+ const route = resolveAgentRoute({
838
+ cfg,
839
+ channel: "telegram",
840
+ accountId,
841
+ peer: {
842
+ kind: params.isGroup ? "group" : "direct",
843
+ id: peerId
844
+ },
845
+ parentPeer
846
+ });
847
+ const baseSessionKey = route.sessionKey;
848
+ const dmThreadId = !params.isGroup ? params.messageThreadId : void 0;
849
+ const sessionKey = (dmThreadId != null ? resolveThreadSessionKeys({
850
+ baseSessionKey,
851
+ threadId: String(dmThreadId)
852
+ }) : null)?.sessionKey ?? baseSessionKey;
853
+ const store = loadSessionStore(resolveStorePath(cfg.session?.store, { agentId: route.agentId }));
854
+ const entry = store[sessionKey];
855
+ const storedOverride = resolveStoredModelOverride({
856
+ sessionEntry: entry,
857
+ sessionStore: store,
858
+ sessionKey
859
+ });
860
+ if (storedOverride) return {
861
+ agentId: route.agentId,
862
+ sessionEntry: entry,
863
+ model: storedOverride.provider ? `${storedOverride.provider}/${storedOverride.model}` : storedOverride.model
864
+ };
865
+ const provider = entry?.modelProvider?.trim();
866
+ const model = entry?.model?.trim();
867
+ if (provider && model) return {
868
+ agentId: route.agentId,
869
+ sessionEntry: entry,
870
+ model: `${provider}/${model}`
871
+ };
872
+ const modelCfg = cfg.agents?.defaults?.model;
873
+ return {
874
+ agentId: route.agentId,
875
+ sessionEntry: entry,
876
+ model: typeof modelCfg === "string" ? modelCfg : modelCfg?.primary
877
+ };
878
+ };
879
+ const processMediaGroup = async (entry) => {
880
+ try {
881
+ entry.messages.sort((a, b) => a.msg.message_id - b.msg.message_id);
882
+ const primaryEntry = entry.messages.find((m) => m.msg.caption || m.msg.text) ?? entry.messages[0];
883
+ const allMedia = [];
884
+ for (const { ctx } of entry.messages) {
885
+ let media;
886
+ try {
887
+ media = await resolveMedia(ctx, mediaMaxBytes, opts.token, opts.proxyFetch);
888
+ } catch (mediaErr) {
889
+ if (!isRecoverableMediaGroupError(mediaErr)) throw mediaErr;
890
+ runtime.log?.(warn(`media group: skipping photo that failed to fetch: ${String(mediaErr)}`));
891
+ continue;
892
+ }
893
+ if (media) allMedia.push({
894
+ path: media.path,
895
+ contentType: media.contentType,
896
+ stickerMetadata: media.stickerMetadata
897
+ });
898
+ }
899
+ const storeAllowFrom = await loadStoreAllowFrom();
900
+ const replyMedia = await resolveReplyMediaForMessage(primaryEntry.ctx, primaryEntry.msg);
901
+ await processMessage(primaryEntry.ctx, allMedia, storeAllowFrom, void 0, replyMedia);
902
+ } catch (err) {
903
+ runtime.error?.(danger(`media group handler failed: ${String(err)}`));
904
+ }
905
+ };
906
+ const flushTextFragments = async (entry) => {
907
+ try {
908
+ entry.messages.sort((a, b) => a.msg.message_id - b.msg.message_id);
909
+ const first = entry.messages[0];
910
+ const last = entry.messages.at(-1);
911
+ if (!first || !last) return;
912
+ const combinedText = entry.messages.map((m) => m.msg.text ?? "").join("");
913
+ if (!combinedText.trim()) return;
914
+ const syntheticMessage = buildSyntheticTextMessage({
915
+ base: first.msg,
916
+ text: combinedText,
917
+ date: last.msg.date ?? first.msg.date
918
+ });
919
+ const storeAllowFrom = await loadStoreAllowFrom();
920
+ const baseCtx = first.ctx;
921
+ await processMessage(buildSyntheticContext(baseCtx, syntheticMessage), [], storeAllowFrom, { messageIdOverride: String(last.msg.message_id) });
922
+ } catch (err) {
923
+ runtime.error?.(danger(`text fragment handler failed: ${String(err)}`));
924
+ }
925
+ };
926
+ const queueTextFragmentFlush = async (entry) => {
927
+ textFragmentProcessing = textFragmentProcessing.then(async () => {
928
+ await flushTextFragments(entry);
929
+ }).catch(() => void 0);
930
+ await textFragmentProcessing;
931
+ };
932
+ const runTextFragmentFlush = async (entry) => {
933
+ textFragmentBuffer.delete(entry.key);
934
+ await queueTextFragmentFlush(entry);
935
+ };
936
+ const scheduleTextFragmentFlush = (entry) => {
937
+ clearTimeout(entry.timer);
938
+ entry.timer = setTimeout(async () => {
939
+ await runTextFragmentFlush(entry);
940
+ }, TELEGRAM_TEXT_FRAGMENT_MAX_GAP_MS);
941
+ };
942
+ const loadStoreAllowFrom = async () => readChannelAllowFromStore("telegram", process.env, accountId).catch(() => []);
943
+ const resolveReplyMediaForMessage = async (ctx, msg) => {
944
+ const replyMessage = msg.reply_to_message;
945
+ if (!replyMessage || !hasInboundMedia(replyMessage)) return [];
946
+ const replyFileId = resolveInboundMediaFileId(replyMessage);
947
+ if (!replyFileId) return [];
948
+ try {
949
+ const media = await resolveMedia({
950
+ message: replyMessage,
951
+ me: ctx.me,
952
+ getFile: async () => await bot.api.getFile(replyFileId)
953
+ }, mediaMaxBytes, opts.token, opts.proxyFetch);
954
+ if (!media) return [];
955
+ return [{
956
+ path: media.path,
957
+ contentType: media.contentType,
958
+ stickerMetadata: media.stickerMetadata
959
+ }];
960
+ } catch (err) {
961
+ logger.warn({
962
+ chatId: msg.chat.id,
963
+ error: String(err)
964
+ }, "reply media fetch failed");
965
+ return [];
966
+ }
967
+ };
968
+ const isAllowlistAuthorized = (allow, senderId, senderUsername) => allow.hasWildcard || allow.hasEntries && isSenderAllowed({
969
+ allow,
970
+ senderId,
971
+ senderUsername
972
+ });
973
+ const shouldSkipGroupMessage = (params) => {
974
+ const { isGroup, chatId, chatTitle, resolvedThreadId, senderId, senderUsername, effectiveGroupAllow, hasGroupAllowOverride, groupConfig, topicConfig } = params;
975
+ const baseAccess = evaluateTelegramGroupBaseAccess({
976
+ isGroup,
977
+ groupConfig,
978
+ topicConfig,
979
+ hasGroupAllowOverride,
980
+ effectiveGroupAllow,
981
+ senderId,
982
+ senderUsername,
983
+ enforceAllowOverride: true,
984
+ requireSenderForAllowOverride: true
985
+ });
986
+ if (!baseAccess.allowed) {
987
+ if (baseAccess.reason === "group-disabled") {
988
+ logVerbose(`Blocked telegram group ${chatId} (group disabled)`);
989
+ return true;
990
+ }
991
+ if (baseAccess.reason === "topic-disabled") {
992
+ logVerbose(`Blocked telegram topic ${chatId} (${resolvedThreadId ?? "unknown"}) (topic disabled)`);
993
+ return true;
994
+ }
995
+ logVerbose(`Blocked telegram group sender ${senderId || "unknown"} (group allowFrom override)`);
996
+ return true;
997
+ }
998
+ if (!isGroup) return false;
999
+ const policyAccess = evaluateTelegramGroupPolicyAccess({
1000
+ isGroup,
1001
+ chatId,
1002
+ cfg,
1003
+ telegramCfg,
1004
+ topicConfig,
1005
+ groupConfig,
1006
+ effectiveGroupAllow,
1007
+ senderId,
1008
+ senderUsername,
1009
+ resolveGroupPolicy,
1010
+ enforcePolicy: true,
1011
+ useTopicAndGroupOverrides: true,
1012
+ enforceAllowlistAuthorization: true,
1013
+ allowEmptyAllowlistEntries: false,
1014
+ requireSenderForAllowlistAuthorization: true,
1015
+ checkChatAllowlist: true
1016
+ });
1017
+ if (!policyAccess.allowed) {
1018
+ if (policyAccess.reason === "group-policy-disabled") {
1019
+ logVerbose("Blocked telegram group message (groupPolicy: disabled)");
1020
+ return true;
1021
+ }
1022
+ if (policyAccess.reason === "group-policy-allowlist-no-sender") {
1023
+ logVerbose("Blocked telegram group message (no sender ID, groupPolicy: allowlist)");
1024
+ return true;
1025
+ }
1026
+ if (policyAccess.reason === "group-policy-allowlist-empty") {
1027
+ logVerbose("Blocked telegram group message (groupPolicy: allowlist, no group allowlist entries)");
1028
+ return true;
1029
+ }
1030
+ if (policyAccess.reason === "group-policy-allowlist-unauthorized") {
1031
+ logVerbose(`Blocked telegram group message from ${senderId} (groupPolicy: allowlist)`);
1032
+ return true;
1033
+ }
1034
+ logger.info({
1035
+ chatId,
1036
+ title: chatTitle,
1037
+ reason: "not-allowed"
1038
+ }, "skipping group message");
1039
+ return true;
1040
+ }
1041
+ return false;
1042
+ };
1043
+ const TELEGRAM_EVENT_AUTH_RULES = {
1044
+ reaction: {
1045
+ enforceDirectAuthorization: true,
1046
+ enforceGroupAllowlistAuthorization: false,
1047
+ deniedDmReason: "reaction unauthorized by dm policy/allowlist",
1048
+ deniedGroupReason: "reaction unauthorized by group allowlist"
1049
+ },
1050
+ "callback-scope": {
1051
+ enforceDirectAuthorization: false,
1052
+ enforceGroupAllowlistAuthorization: false,
1053
+ deniedDmReason: "callback unauthorized by inlineButtonsScope",
1054
+ deniedGroupReason: "callback unauthorized by inlineButtonsScope"
1055
+ },
1056
+ "callback-allowlist": {
1057
+ enforceDirectAuthorization: true,
1058
+ enforceGroupAllowlistAuthorization: false,
1059
+ deniedDmReason: "callback unauthorized by inlineButtonsScope allowlist",
1060
+ deniedGroupReason: "callback unauthorized by inlineButtonsScope allowlist"
1061
+ }
1062
+ };
1063
+ const resolveTelegramEventAuthorizationContext = async (params) => {
1064
+ return {
1065
+ dmPolicy: telegramCfg.dmPolicy ?? "pairing",
1066
+ ...params.groupAllowContext ?? await resolveTelegramGroupAllowFromContext({
1067
+ chatId: params.chatId,
1068
+ accountId,
1069
+ isForum: params.isForum,
1070
+ messageThreadId: params.messageThreadId,
1071
+ groupAllowFrom,
1072
+ resolveTelegramGroupConfig
1073
+ })
1074
+ };
1075
+ };
1076
+ const authorizeTelegramEventSender = (params) => {
1077
+ const { chatId, chatTitle, isGroup, senderId, senderUsername, mode, context } = params;
1078
+ const { dmPolicy, resolvedThreadId, storeAllowFrom, groupConfig, topicConfig, effectiveGroupAllow, hasGroupAllowOverride } = context;
1079
+ const { enforceDirectAuthorization, enforceGroupAllowlistAuthorization, deniedDmReason, deniedGroupReason } = TELEGRAM_EVENT_AUTH_RULES[mode];
1080
+ if (shouldSkipGroupMessage({
1081
+ isGroup,
1082
+ chatId,
1083
+ chatTitle,
1084
+ resolvedThreadId,
1085
+ senderId,
1086
+ senderUsername,
1087
+ effectiveGroupAllow,
1088
+ hasGroupAllowOverride,
1089
+ groupConfig,
1090
+ topicConfig
1091
+ })) return {
1092
+ allowed: false,
1093
+ reason: "group-policy"
1094
+ };
1095
+ if (!isGroup && enforceDirectAuthorization) {
1096
+ if (dmPolicy === "disabled") {
1097
+ logVerbose(`Blocked telegram direct event from ${senderId || "unknown"} (${deniedDmReason})`);
1098
+ return {
1099
+ allowed: false,
1100
+ reason: "direct-disabled"
1101
+ };
1102
+ }
1103
+ if (dmPolicy !== "open") {
1104
+ if (!isAllowlistAuthorized(normalizeDmAllowFromWithStore({
1105
+ allowFrom,
1106
+ storeAllowFrom,
1107
+ dmPolicy
1108
+ }), senderId, senderUsername)) {
1109
+ logVerbose(`Blocked telegram direct sender ${senderId || "unknown"} (${deniedDmReason})`);
1110
+ return {
1111
+ allowed: false,
1112
+ reason: "direct-unauthorized"
1113
+ };
1114
+ }
1115
+ }
1116
+ }
1117
+ if (isGroup && enforceGroupAllowlistAuthorization) {
1118
+ if (!isAllowlistAuthorized(effectiveGroupAllow, senderId, senderUsername)) {
1119
+ logVerbose(`Blocked telegram group sender ${senderId || "unknown"} (${deniedGroupReason})`);
1120
+ return {
1121
+ allowed: false,
1122
+ reason: "group-unauthorized"
1123
+ };
1124
+ }
1125
+ }
1126
+ return { allowed: true };
1127
+ };
1128
+ bot.on("message_reaction", async (ctx) => {
1129
+ try {
1130
+ const reaction = ctx.messageReaction;
1131
+ if (!reaction) return;
1132
+ if (shouldSkipUpdate(ctx)) return;
1133
+ const chatId = reaction.chat.id;
1134
+ const messageId = reaction.message_id;
1135
+ const user = reaction.user;
1136
+ const senderId = user?.id != null ? String(user.id) : "";
1137
+ const senderUsername = user?.username ?? "";
1138
+ const isGroup = reaction.chat.type === "group" || reaction.chat.type === "supergroup";
1139
+ const isForum = reaction.chat.is_forum === true;
1140
+ const reactionMode = telegramCfg.reactionNotifications ?? "own";
1141
+ if (reactionMode === "off") return;
1142
+ if (user?.is_bot) return;
1143
+ if (reactionMode === "own" && !wasSentByBot(chatId, messageId)) return;
1144
+ const eventAuthContext = await resolveTelegramEventAuthorizationContext({
1145
+ chatId,
1146
+ isForum
1147
+ });
1148
+ if (!authorizeTelegramEventSender({
1149
+ chatId,
1150
+ chatTitle: reaction.chat.title,
1151
+ isGroup,
1152
+ senderId,
1153
+ senderUsername,
1154
+ mode: "reaction",
1155
+ context: eventAuthContext
1156
+ }).allowed) return;
1157
+ const oldEmojis = new Set(reaction.old_reaction.filter((r) => r.type === "emoji").map((r) => r.emoji));
1158
+ const addedReactions = reaction.new_reaction.filter((r) => r.type === "emoji").filter((r) => !oldEmojis.has(r.emoji));
1159
+ if (addedReactions.length === 0) return;
1160
+ const senderName = user ? [user.first_name, user.last_name].filter(Boolean).join(" ").trim() || user.username : void 0;
1161
+ const senderUsernameLabel = user?.username ? `@${user.username}` : void 0;
1162
+ let senderLabel = senderName;
1163
+ if (senderName && senderUsernameLabel) senderLabel = `${senderName} (${senderUsernameLabel})`;
1164
+ else if (!senderName && senderUsernameLabel) senderLabel = senderUsernameLabel;
1165
+ if (!senderLabel && user?.id) senderLabel = `id:${user.id}`;
1166
+ senderLabel = senderLabel || "unknown";
1167
+ const resolvedThreadId = isForum ? resolveTelegramForumThreadId({
1168
+ isForum,
1169
+ messageThreadId: void 0
1170
+ }) : void 0;
1171
+ const peerId = isGroup ? buildTelegramGroupPeerId(chatId, resolvedThreadId) : String(chatId);
1172
+ const parentPeer = buildTelegramParentPeer({
1173
+ isGroup,
1174
+ resolvedThreadId,
1175
+ chatId
1176
+ });
1177
+ const sessionKey = resolveAgentRoute({
1178
+ cfg: loadConfig(),
1179
+ channel: "telegram",
1180
+ accountId,
1181
+ peer: {
1182
+ kind: isGroup ? "group" : "direct",
1183
+ id: peerId
1184
+ },
1185
+ parentPeer
1186
+ }).sessionKey;
1187
+ for (const r of addedReactions) {
1188
+ const emoji = r.emoji;
1189
+ const text = `Telegram reaction added: ${emoji} by ${senderLabel} on msg ${messageId}`;
1190
+ enqueueSystemEvent(text, {
1191
+ sessionKey,
1192
+ contextKey: `telegram:reaction:add:${chatId}:${messageId}:${user?.id ?? "anon"}:${emoji}`
1193
+ });
1194
+ logVerbose(`telegram: reaction event enqueued: ${text}`);
1195
+ }
1196
+ } catch (err) {
1197
+ runtime.error?.(danger(`telegram reaction handler failed: ${String(err)}`));
1198
+ }
1199
+ });
1200
+ const processInboundMessage = async (params) => {
1201
+ const { ctx, msg, chatId, resolvedThreadId, storeAllowFrom, sendOversizeWarning, oversizeLogMessage } = params;
1202
+ const text = typeof msg.text === "string" ? msg.text : void 0;
1203
+ const isCommandLike = (text ?? "").trim().startsWith("/");
1204
+ if (text && !isCommandLike) {
1205
+ const nowMs = Date.now();
1206
+ const senderId = msg.from?.id != null ? String(msg.from.id) : "unknown";
1207
+ const key = `text:${chatId}:${resolvedThreadId ?? "main"}:${senderId}`;
1208
+ const existing = textFragmentBuffer.get(key);
1209
+ if (existing) {
1210
+ const last = existing.messages.at(-1);
1211
+ const lastMsgId = last?.msg.message_id;
1212
+ const lastReceivedAtMs = last?.receivedAtMs ?? nowMs;
1213
+ const idGap = typeof lastMsgId === "number" ? msg.message_id - lastMsgId : Infinity;
1214
+ const timeGapMs = nowMs - lastReceivedAtMs;
1215
+ if (idGap > 0 && idGap <= TELEGRAM_TEXT_FRAGMENT_MAX_ID_GAP && timeGapMs >= 0 && timeGapMs <= TELEGRAM_TEXT_FRAGMENT_MAX_GAP_MS) {
1216
+ const nextTotalChars = existing.messages.reduce((sum, m) => sum + (m.msg.text?.length ?? 0), 0) + text.length;
1217
+ if (existing.messages.length + 1 <= TELEGRAM_TEXT_FRAGMENT_MAX_PARTS && nextTotalChars <= TELEGRAM_TEXT_FRAGMENT_MAX_TOTAL_CHARS) {
1218
+ existing.messages.push({
1219
+ msg,
1220
+ ctx,
1221
+ receivedAtMs: nowMs
1222
+ });
1223
+ scheduleTextFragmentFlush(existing);
1224
+ return;
1225
+ }
1226
+ }
1227
+ clearTimeout(existing.timer);
1228
+ textFragmentBuffer.delete(key);
1229
+ textFragmentProcessing = textFragmentProcessing.then(async () => {
1230
+ await flushTextFragments(existing);
1231
+ }).catch(() => void 0);
1232
+ await textFragmentProcessing;
1233
+ }
1234
+ if (text.length >= TELEGRAM_TEXT_FRAGMENT_START_THRESHOLD_CHARS) {
1235
+ const entry = {
1236
+ key,
1237
+ messages: [{
1238
+ msg,
1239
+ ctx,
1240
+ receivedAtMs: nowMs
1241
+ }],
1242
+ timer: setTimeout(() => {}, TELEGRAM_TEXT_FRAGMENT_MAX_GAP_MS)
1243
+ };
1244
+ textFragmentBuffer.set(key, entry);
1245
+ scheduleTextFragmentFlush(entry);
1246
+ return;
1247
+ }
1248
+ }
1249
+ const mediaGroupId = msg.media_group_id;
1250
+ if (mediaGroupId) {
1251
+ const existing = mediaGroupBuffer.get(mediaGroupId);
1252
+ if (existing) {
1253
+ clearTimeout(existing.timer);
1254
+ existing.messages.push({
1255
+ msg,
1256
+ ctx
1257
+ });
1258
+ existing.timer = setTimeout(async () => {
1259
+ mediaGroupBuffer.delete(mediaGroupId);
1260
+ mediaGroupProcessing = mediaGroupProcessing.then(async () => {
1261
+ await processMediaGroup(existing);
1262
+ }).catch(() => void 0);
1263
+ await mediaGroupProcessing;
1264
+ }, mediaGroupTimeoutMs);
1265
+ } else {
1266
+ const entry = {
1267
+ messages: [{
1268
+ msg,
1269
+ ctx
1270
+ }],
1271
+ timer: setTimeout(async () => {
1272
+ mediaGroupBuffer.delete(mediaGroupId);
1273
+ mediaGroupProcessing = mediaGroupProcessing.then(async () => {
1274
+ await processMediaGroup(entry);
1275
+ }).catch(() => void 0);
1276
+ await mediaGroupProcessing;
1277
+ }, mediaGroupTimeoutMs)
1278
+ };
1279
+ mediaGroupBuffer.set(mediaGroupId, entry);
1280
+ }
1281
+ return;
1282
+ }
1283
+ let media = null;
1284
+ try {
1285
+ media = await resolveMedia(ctx, mediaMaxBytes, opts.token, opts.proxyFetch);
1286
+ } catch (mediaErr) {
1287
+ if (isMediaSizeLimitError(mediaErr)) {
1288
+ if (sendOversizeWarning) {
1289
+ const limitMb = Math.round(mediaMaxBytes / (1024 * 1024));
1290
+ await withTelegramApiErrorLogging({
1291
+ operation: "sendMessage",
1292
+ runtime,
1293
+ fn: () => bot.api.sendMessage(chatId, `⚠️ File too large. Maximum size is ${limitMb}MB.`, { reply_to_message_id: msg.message_id })
1294
+ }).catch(() => {});
1295
+ }
1296
+ logger.warn({
1297
+ chatId,
1298
+ error: String(mediaErr)
1299
+ }, oversizeLogMessage);
1300
+ return;
1301
+ }
1302
+ logger.warn({
1303
+ chatId,
1304
+ error: String(mediaErr)
1305
+ }, "media fetch failed");
1306
+ await withTelegramApiErrorLogging({
1307
+ operation: "sendMessage",
1308
+ runtime,
1309
+ fn: () => bot.api.sendMessage(chatId, "⚠️ Failed to download media. Please try again.", { reply_to_message_id: msg.message_id })
1310
+ }).catch(() => {});
1311
+ return;
1312
+ }
1313
+ const hasText = Boolean((msg.text ?? msg.caption ?? "").trim());
1314
+ if (msg.sticker && !media && !hasText) {
1315
+ logVerbose("telegram: skipping sticker-only message (unsupported sticker type)");
1316
+ return;
1317
+ }
1318
+ const allMedia = media ? [{
1319
+ path: media.path,
1320
+ contentType: media.contentType,
1321
+ stickerMetadata: media.stickerMetadata
1322
+ }] : [];
1323
+ const senderId = msg.from?.id ? String(msg.from.id) : "";
1324
+ const conversationKey = resolvedThreadId != null ? `${chatId}:topic:${resolvedThreadId}` : String(chatId);
1325
+ const debounceLane = resolveTelegramDebounceLane(msg);
1326
+ const debounceKey = senderId ? `telegram:${accountId ?? "default"}:${conversationKey}:${senderId}:${debounceLane}` : null;
1327
+ await inboundDebouncer.enqueue({
1328
+ ctx,
1329
+ msg,
1330
+ allMedia,
1331
+ storeAllowFrom,
1332
+ debounceKey,
1333
+ debounceLane,
1334
+ botUsername: ctx.me?.username
1335
+ });
1336
+ };
1337
+ bot.on("callback_query", async (ctx) => {
1338
+ const callback = ctx.callbackQuery;
1339
+ if (!callback) return;
1340
+ if (shouldSkipUpdate(ctx)) return;
1341
+ await withTelegramApiErrorLogging({
1342
+ operation: "answerCallbackQuery",
1343
+ runtime,
1344
+ fn: typeof ctx.answerCallbackQuery === "function" ? () => ctx.answerCallbackQuery() : () => bot.api.answerCallbackQuery(callback.id)
1345
+ }).catch(() => {});
1346
+ try {
1347
+ const data = (callback.data ?? "").trim();
1348
+ const callbackMessage = callback.message;
1349
+ if (!data || !callbackMessage) return;
1350
+ const editCallbackMessage = async (text, params) => {
1351
+ if (typeof ctx.editMessageText === "function") return await ctx.editMessageText(text, params);
1352
+ return await bot.api.editMessageText(callbackMessage.chat.id, callbackMessage.message_id, text, params);
1353
+ };
1354
+ const deleteCallbackMessage = async () => {
1355
+ if (typeof ctx.deleteMessage === "function") return await ctx.deleteMessage();
1356
+ return await bot.api.deleteMessage(callbackMessage.chat.id, callbackMessage.message_id);
1357
+ };
1358
+ const replyToCallbackChat = async (text, params) => {
1359
+ if (typeof ctx.reply === "function") return await ctx.reply(text, params);
1360
+ return await bot.api.sendMessage(callbackMessage.chat.id, text, params);
1361
+ };
1362
+ const inlineButtonsScope = resolveTelegramInlineButtonsScope({
1363
+ cfg,
1364
+ accountId
1365
+ });
1366
+ if (inlineButtonsScope === "off") return;
1367
+ const chatId = callbackMessage.chat.id;
1368
+ const isGroup = callbackMessage.chat.type === "group" || callbackMessage.chat.type === "supergroup";
1369
+ if (inlineButtonsScope === "dm" && isGroup) return;
1370
+ if (inlineButtonsScope === "group" && !isGroup) return;
1371
+ const messageThreadId = callbackMessage.message_thread_id;
1372
+ const isForum = callbackMessage.chat.is_forum === true;
1373
+ const eventAuthContext = await resolveTelegramEventAuthorizationContext({
1374
+ chatId,
1375
+ isForum,
1376
+ messageThreadId
1377
+ });
1378
+ const { resolvedThreadId, storeAllowFrom } = eventAuthContext;
1379
+ const senderId = callback.from?.id ? String(callback.from.id) : "";
1380
+ const senderUsername = callback.from?.username ?? "";
1381
+ const authorizationMode = inlineButtonsScope === "allowlist" ? "callback-allowlist" : "callback-scope";
1382
+ if (!authorizeTelegramEventSender({
1383
+ chatId,
1384
+ chatTitle: callbackMessage.chat.title,
1385
+ isGroup,
1386
+ senderId,
1387
+ senderUsername,
1388
+ mode: authorizationMode,
1389
+ context: eventAuthContext
1390
+ }).allowed) return;
1391
+ const paginationMatch = data.match(/^commands_page_(\d+|noop)(?::(.+))?$/);
1392
+ if (paginationMatch) {
1393
+ const pageValue = paginationMatch[1];
1394
+ if (pageValue === "noop") return;
1395
+ const page = Number.parseInt(pageValue, 10);
1396
+ if (Number.isNaN(page) || page < 1) return;
1397
+ const agentId = paginationMatch[2]?.trim() || resolveDefaultAgentId(cfg) || void 0;
1398
+ const result = buildCommandsMessagePaginated(cfg, listSkillCommandsForAgents({
1399
+ cfg,
1400
+ agentIds: agentId ? [agentId] : void 0
1401
+ }), {
1402
+ page,
1403
+ surface: "telegram"
1404
+ });
1405
+ const keyboard = result.totalPages > 1 ? buildInlineKeyboard(buildCommandsPaginationKeyboard(result.currentPage, result.totalPages, agentId)) : void 0;
1406
+ try {
1407
+ await editCallbackMessage(result.text, keyboard ? { reply_markup: keyboard } : void 0);
1408
+ } catch (editErr) {
1409
+ if (!String(editErr).includes("message is not modified")) throw editErr;
1410
+ }
1411
+ return;
1412
+ }
1413
+ const modelCallback = parseModelCallbackData(data);
1414
+ if (modelCallback) {
1415
+ const { byProvider, providers } = await buildModelsProviderData(cfg);
1416
+ const editMessageWithButtons = async (text, buttons) => {
1417
+ const keyboard = buildInlineKeyboard(buttons);
1418
+ try {
1419
+ await editCallbackMessage(text, keyboard ? { reply_markup: keyboard } : void 0);
1420
+ } catch (editErr) {
1421
+ const errStr = String(editErr);
1422
+ if (errStr.includes("no text in the message")) {
1423
+ try {
1424
+ await deleteCallbackMessage();
1425
+ } catch {}
1426
+ await replyToCallbackChat(text, keyboard ? { reply_markup: keyboard } : void 0);
1427
+ } else if (!errStr.includes("message is not modified")) throw editErr;
1428
+ }
1429
+ };
1430
+ if (modelCallback.type === "providers" || modelCallback.type === "back") {
1431
+ if (providers.length === 0) {
1432
+ await editMessageWithButtons("No providers available.", []);
1433
+ return;
1434
+ }
1435
+ await editMessageWithButtons("Select a provider:", buildProviderKeyboard(providers.map((p) => ({
1436
+ id: p,
1437
+ count: byProvider.get(p)?.size ?? 0
1438
+ }))));
1439
+ return;
1440
+ }
1441
+ if (modelCallback.type === "list") {
1442
+ const { provider, page } = modelCallback;
1443
+ const modelSet = byProvider.get(provider);
1444
+ if (!modelSet || modelSet.size === 0) {
1445
+ const buttons = buildProviderKeyboard(providers.map((p) => ({
1446
+ id: p,
1447
+ count: byProvider.get(p)?.size ?? 0
1448
+ })));
1449
+ await editMessageWithButtons(`Unknown provider: ${provider}\n\nSelect a provider:`, buttons);
1450
+ return;
1451
+ }
1452
+ const models = [...modelSet].toSorted();
1453
+ const pageSize = getModelsPageSize();
1454
+ const totalPages = calculateTotalPages(models.length, pageSize);
1455
+ const safePage = Math.max(1, Math.min(page, totalPages));
1456
+ const sessionState = resolveTelegramSessionState({
1457
+ chatId,
1458
+ isGroup,
1459
+ isForum,
1460
+ messageThreadId,
1461
+ resolvedThreadId
1462
+ });
1463
+ const currentModel = sessionState.model;
1464
+ const buttons = buildModelsKeyboard({
1465
+ provider,
1466
+ models,
1467
+ currentModel,
1468
+ currentPage: safePage,
1469
+ totalPages,
1470
+ pageSize
1471
+ });
1472
+ await editMessageWithButtons(formatModelsAvailableHeader({
1473
+ provider,
1474
+ total: models.length,
1475
+ cfg,
1476
+ agentDir: resolveAgentDir(cfg, sessionState.agentId),
1477
+ sessionEntry: sessionState.sessionEntry
1478
+ }), buttons);
1479
+ return;
1480
+ }
1481
+ if (modelCallback.type === "select") {
1482
+ const { provider, model } = modelCallback;
1483
+ await processMessage(buildSyntheticContext(ctx, buildSyntheticTextMessage({
1484
+ base: callbackMessage,
1485
+ from: callback.from,
1486
+ text: `/model ${provider}/${model}`
1487
+ })), [], storeAllowFrom, {
1488
+ forceWasMentioned: true,
1489
+ messageIdOverride: callback.id
1490
+ });
1491
+ return;
1492
+ }
1493
+ return;
1494
+ }
1495
+ await processMessage(buildSyntheticContext(ctx, buildSyntheticTextMessage({
1496
+ base: callbackMessage,
1497
+ from: callback.from,
1498
+ text: data
1499
+ })), [], storeAllowFrom, {
1500
+ forceWasMentioned: true,
1501
+ messageIdOverride: callback.id
1502
+ });
1503
+ } catch (err) {
1504
+ runtime.error?.(danger(`callback handler failed: ${String(err)}`));
1505
+ }
1506
+ });
1507
+ bot.on("message:migrate_to_chat_id", async (ctx) => {
1508
+ try {
1509
+ const msg = ctx.message;
1510
+ if (!msg?.migrate_to_chat_id) return;
1511
+ if (shouldSkipUpdate(ctx)) return;
1512
+ const oldChatId = String(msg.chat.id);
1513
+ const newChatId = String(msg.migrate_to_chat_id);
1514
+ const chatTitle = msg.chat.title ?? "Unknown";
1515
+ runtime.log?.(warn(`[telegram] Group migrated: "${chatTitle}" ${oldChatId} → ${newChatId}`));
1516
+ if (!resolveChannelConfigWrites({
1517
+ cfg,
1518
+ channelId: "telegram",
1519
+ accountId
1520
+ })) {
1521
+ runtime.log?.(warn("[telegram] Config writes disabled; skipping group config migration."));
1522
+ return;
1523
+ }
1524
+ const currentConfig = loadConfig();
1525
+ const migration = migrateTelegramGroupConfig({
1526
+ cfg: currentConfig,
1527
+ accountId,
1528
+ oldChatId,
1529
+ newChatId
1530
+ });
1531
+ if (migration.migrated) {
1532
+ runtime.log?.(warn(`[telegram] Migrating group config from ${oldChatId} to ${newChatId}`));
1533
+ migrateTelegramGroupConfig({
1534
+ cfg,
1535
+ accountId,
1536
+ oldChatId,
1537
+ newChatId
1538
+ });
1539
+ await writeConfigFile(currentConfig);
1540
+ runtime.log?.(warn(`[telegram] Group config migrated and saved successfully`));
1541
+ } else if (migration.skippedExisting) runtime.log?.(warn(`[telegram] Group config already exists for ${newChatId}; leaving ${oldChatId} unchanged`));
1542
+ else runtime.log?.(warn(`[telegram] No config found for old group ID ${oldChatId}, migration logged only`));
1543
+ } catch (err) {
1544
+ runtime.error?.(danger(`[telegram] Group migration handler failed: ${String(err)}`));
1545
+ }
1546
+ });
1547
+ const handleInboundMessageLike = async (event) => {
1548
+ try {
1549
+ if (shouldSkipUpdate(event.ctxForDedupe)) return;
1550
+ const { dmPolicy, resolvedThreadId, storeAllowFrom, groupConfig, topicConfig, effectiveGroupAllow, hasGroupAllowOverride } = await resolveTelegramEventAuthorizationContext({
1551
+ chatId: event.chatId,
1552
+ isForum: event.isForum,
1553
+ messageThreadId: event.messageThreadId
1554
+ });
1555
+ const effectiveDmAllow = normalizeDmAllowFromWithStore({
1556
+ allowFrom,
1557
+ storeAllowFrom,
1558
+ dmPolicy
1559
+ });
1560
+ if (event.requireConfiguredGroup && (!groupConfig || groupConfig.enabled === false)) {
1561
+ logVerbose(`Blocked telegram channel ${event.chatId} (channel disabled)`);
1562
+ return;
1563
+ }
1564
+ if (shouldSkipGroupMessage({
1565
+ isGroup: event.isGroup,
1566
+ chatId: event.chatId,
1567
+ chatTitle: event.msg.chat.title,
1568
+ resolvedThreadId,
1569
+ senderId: event.senderId,
1570
+ senderUsername: event.senderUsername,
1571
+ effectiveGroupAllow,
1572
+ hasGroupAllowOverride,
1573
+ groupConfig,
1574
+ topicConfig
1575
+ })) return;
1576
+ if (!event.isGroup && (hasInboundMedia(event.msg) || hasReplyTargetMedia(event.msg))) {
1577
+ if (!await enforceTelegramDmAccess({
1578
+ isGroup: event.isGroup,
1579
+ dmPolicy,
1580
+ msg: event.msg,
1581
+ chatId: event.chatId,
1582
+ effectiveDmAllow,
1583
+ accountId,
1584
+ bot,
1585
+ logger
1586
+ })) return;
1587
+ }
1588
+ await processInboundMessage({
1589
+ ctx: event.ctx,
1590
+ msg: event.msg,
1591
+ chatId: event.chatId,
1592
+ resolvedThreadId,
1593
+ storeAllowFrom,
1594
+ sendOversizeWarning: event.sendOversizeWarning,
1595
+ oversizeLogMessage: event.oversizeLogMessage
1596
+ });
1597
+ } catch (err) {
1598
+ runtime.error?.(danger(`${event.errorMessage}: ${String(err)}`));
1599
+ }
1600
+ };
1601
+ bot.on("message", async (ctx) => {
1602
+ const msg = ctx.message;
1603
+ if (!msg) return;
1604
+ await handleInboundMessageLike({
1605
+ ctxForDedupe: ctx,
1606
+ ctx: buildSyntheticContext(ctx, msg),
1607
+ msg,
1608
+ chatId: msg.chat.id,
1609
+ isGroup: msg.chat.type === "group" || msg.chat.type === "supergroup",
1610
+ isForum: msg.chat.is_forum === true,
1611
+ messageThreadId: msg.message_thread_id,
1612
+ senderId: msg.from?.id != null ? String(msg.from.id) : "",
1613
+ senderUsername: msg.from?.username ?? "",
1614
+ requireConfiguredGroup: false,
1615
+ sendOversizeWarning: true,
1616
+ oversizeLogMessage: "media exceeds size limit",
1617
+ errorMessage: "handler failed"
1618
+ });
1619
+ });
1620
+ bot.on("channel_post", async (ctx) => {
1621
+ const post = ctx.channelPost;
1622
+ if (!post) return;
1623
+ const chatId = post.chat.id;
1624
+ const syntheticFrom = post.sender_chat ? {
1625
+ id: post.sender_chat.id,
1626
+ is_bot: true,
1627
+ first_name: post.sender_chat.title || "Channel",
1628
+ username: post.sender_chat.username
1629
+ } : {
1630
+ id: chatId,
1631
+ is_bot: true,
1632
+ first_name: post.chat.title || "Channel",
1633
+ username: post.chat.username
1634
+ };
1635
+ const syntheticMsg = {
1636
+ ...post,
1637
+ from: post.from ?? syntheticFrom,
1638
+ chat: {
1639
+ ...post.chat,
1640
+ type: "supergroup"
1641
+ }
1642
+ };
1643
+ await handleInboundMessageLike({
1644
+ ctxForDedupe: ctx,
1645
+ ctx: buildSyntheticContext(ctx, syntheticMsg),
1646
+ msg: syntheticMsg,
1647
+ chatId,
1648
+ isGroup: true,
1649
+ isForum: false,
1650
+ senderId: post.sender_chat?.id != null ? String(post.sender_chat.id) : post.from?.id != null ? String(post.from.id) : "",
1651
+ senderUsername: post.sender_chat?.username ?? post.from?.username ?? "",
1652
+ requireConfiguredGroup: true,
1653
+ sendOversizeWarning: false,
1654
+ oversizeLogMessage: "channel post media exceeds size limit",
1655
+ errorMessage: "channel_post handler failed"
1656
+ });
1657
+ });
1658
+ };
1659
+
1660
+ //#endregion
1661
+ //#region src/telegram/group-config-helpers.ts
1662
+ function resolveTelegramGroupPromptSettings(params) {
1663
+ const skillFilter = firstDefined(params.topicConfig?.skills, params.groupConfig?.skills);
1664
+ const systemPromptParts = [params.groupConfig?.systemPrompt?.trim() || null, params.topicConfig?.systemPrompt?.trim() || null].filter((entry) => Boolean(entry));
1665
+ return {
1666
+ skillFilter,
1667
+ groupSystemPrompt: systemPromptParts.length > 0 ? systemPromptParts.join("\n\n") : void 0
1668
+ };
1669
+ }
1670
+
1671
+ //#endregion
1672
+ //#region src/telegram/status-reaction-variants.ts
1673
+ const TELEGRAM_GENERIC_REACTION_FALLBACKS = [
1674
+ "👍",
1675
+ "👀",
1676
+ "🔥"
1677
+ ];
1678
+ const TELEGRAM_SUPPORTED_REACTION_EMOJIS = new Set([
1679
+ "❤",
1680
+ "👍",
1681
+ "👎",
1682
+ "🔥",
1683
+ "🥰",
1684
+ "👏",
1685
+ "😁",
1686
+ "🤔",
1687
+ "🤯",
1688
+ "😱",
1689
+ "🤬",
1690
+ "😢",
1691
+ "🎉",
1692
+ "🤩",
1693
+ "🤮",
1694
+ "💩",
1695
+ "🙏",
1696
+ "👌",
1697
+ "🕊",
1698
+ "🤡",
1699
+ "🥱",
1700
+ "🥴",
1701
+ "😍",
1702
+ "🐳",
1703
+ "❤‍🔥",
1704
+ "🌚",
1705
+ "🌭",
1706
+ "💯",
1707
+ "🤣",
1708
+ "⚡",
1709
+ "🍌",
1710
+ "🏆",
1711
+ "💔",
1712
+ "🤨",
1713
+ "😐",
1714
+ "🍓",
1715
+ "🍾",
1716
+ "💋",
1717
+ "🖕",
1718
+ "😈",
1719
+ "😴",
1720
+ "😭",
1721
+ "🤓",
1722
+ "👻",
1723
+ "👨‍💻",
1724
+ "👀",
1725
+ "🎃",
1726
+ "🙈",
1727
+ "😇",
1728
+ "😨",
1729
+ "🤝",
1730
+ "✍",
1731
+ "🤗",
1732
+ "🫡",
1733
+ "🎅",
1734
+ "🎄",
1735
+ "☃",
1736
+ "💅",
1737
+ "🤪",
1738
+ "🗿",
1739
+ "🆒",
1740
+ "💘",
1741
+ "🙉",
1742
+ "🦄",
1743
+ "😘",
1744
+ "💊",
1745
+ "🙊",
1746
+ "😎",
1747
+ "👾",
1748
+ "🤷‍♂",
1749
+ "🤷",
1750
+ "🤷‍♀",
1751
+ "😡"
1752
+ ]);
1753
+ const TELEGRAM_STATUS_REACTION_VARIANTS = {
1754
+ queued: [
1755
+ "👀",
1756
+ "👍",
1757
+ "🔥"
1758
+ ],
1759
+ thinking: [
1760
+ "🤔",
1761
+ "🤓",
1762
+ "👀"
1763
+ ],
1764
+ tool: [
1765
+ "🔥",
1766
+ "⚡",
1767
+ "👍"
1768
+ ],
1769
+ coding: [
1770
+ "👨‍💻",
1771
+ "🔥",
1772
+ "⚡"
1773
+ ],
1774
+ web: [
1775
+ "⚡",
1776
+ "🔥",
1777
+ "👍"
1778
+ ],
1779
+ done: [
1780
+ "👍",
1781
+ "🎉",
1782
+ "💯"
1783
+ ],
1784
+ error: [
1785
+ "😱",
1786
+ "😨",
1787
+ "🤯"
1788
+ ],
1789
+ stallSoft: [
1790
+ "🥱",
1791
+ "😴",
1792
+ "🤔"
1793
+ ],
1794
+ stallHard: [
1795
+ "😨",
1796
+ "😱",
1797
+ "⚡"
1798
+ ]
1799
+ };
1800
+ const STATUS_REACTION_EMOJI_KEYS = [
1801
+ "queued",
1802
+ "thinking",
1803
+ "tool",
1804
+ "coding",
1805
+ "web",
1806
+ "done",
1807
+ "error",
1808
+ "stallSoft",
1809
+ "stallHard"
1810
+ ];
1811
+ function normalizeEmoji(value) {
1812
+ const trimmed = value?.trim();
1813
+ return trimmed ? trimmed : void 0;
1814
+ }
1815
+ function toUniqueNonEmpty(values) {
1816
+ return Array.from(new Set(values.map((value) => value.trim()).filter(Boolean)));
1817
+ }
1818
+ function resolveTelegramStatusReactionEmojis(params) {
1819
+ const { overrides } = params;
1820
+ const queuedFallback = normalizeEmoji(params.initialEmoji) ?? DEFAULT_EMOJIS.queued;
1821
+ return {
1822
+ queued: normalizeEmoji(overrides?.queued) ?? queuedFallback,
1823
+ thinking: normalizeEmoji(overrides?.thinking) ?? DEFAULT_EMOJIS.thinking,
1824
+ tool: normalizeEmoji(overrides?.tool) ?? DEFAULT_EMOJIS.tool,
1825
+ coding: normalizeEmoji(overrides?.coding) ?? DEFAULT_EMOJIS.coding,
1826
+ web: normalizeEmoji(overrides?.web) ?? DEFAULT_EMOJIS.web,
1827
+ done: normalizeEmoji(overrides?.done) ?? DEFAULT_EMOJIS.done,
1828
+ error: normalizeEmoji(overrides?.error) ?? DEFAULT_EMOJIS.error,
1829
+ stallSoft: normalizeEmoji(overrides?.stallSoft) ?? DEFAULT_EMOJIS.stallSoft,
1830
+ stallHard: normalizeEmoji(overrides?.stallHard) ?? DEFAULT_EMOJIS.stallHard
1831
+ };
1832
+ }
1833
+ function buildTelegramStatusReactionVariants(emojis) {
1834
+ const variantsByRequested = /* @__PURE__ */ new Map();
1835
+ for (const key of STATUS_REACTION_EMOJI_KEYS) {
1836
+ const requested = normalizeEmoji(emojis[key]);
1837
+ if (!requested) continue;
1838
+ const candidates = toUniqueNonEmpty([requested, ...TELEGRAM_STATUS_REACTION_VARIANTS[key] ?? []]);
1839
+ variantsByRequested.set(requested, candidates);
1840
+ }
1841
+ return variantsByRequested;
1842
+ }
1843
+ function isTelegramSupportedReactionEmoji(emoji) {
1844
+ return TELEGRAM_SUPPORTED_REACTION_EMOJIS.has(emoji);
1845
+ }
1846
+ function extractTelegramAllowedEmojiReactions(chat) {
1847
+ if (!chat || typeof chat !== "object") return;
1848
+ if (!Object.prototype.hasOwnProperty.call(chat, "available_reactions")) return;
1849
+ const availableReactions = chat.available_reactions;
1850
+ if (availableReactions == null) return null;
1851
+ if (!Array.isArray(availableReactions)) return /* @__PURE__ */ new Set();
1852
+ const allowed = /* @__PURE__ */ new Set();
1853
+ for (const reaction of availableReactions) {
1854
+ if (!reaction || typeof reaction !== "object") continue;
1855
+ const typedReaction = reaction;
1856
+ if (typedReaction.type !== "emoji" || typeof typedReaction.emoji !== "string") continue;
1857
+ const emoji = typedReaction.emoji.trim();
1858
+ if (emoji) allowed.add(emoji);
1859
+ }
1860
+ return allowed;
1861
+ }
1862
+ async function resolveTelegramAllowedEmojiReactions(params) {
1863
+ const fromMessage = extractTelegramAllowedEmojiReactions(params.chat);
1864
+ if (fromMessage !== void 0) return fromMessage;
1865
+ if (params.getChat) try {
1866
+ const fromLookup = extractTelegramAllowedEmojiReactions(await params.getChat(params.chatId));
1867
+ if (fromLookup !== void 0) return fromLookup;
1868
+ } catch {
1869
+ return null;
1870
+ }
1871
+ return null;
1872
+ }
1873
+ function resolveTelegramReactionVariant(params) {
1874
+ const requestedEmoji = normalizeEmoji(params.requestedEmoji);
1875
+ if (!requestedEmoji) return;
1876
+ const variants = toUniqueNonEmpty([...params.variantsByRequestedEmoji.get(requestedEmoji) ?? [requestedEmoji], ...TELEGRAM_GENERIC_REACTION_FALLBACKS]);
1877
+ for (const candidate of variants) if ((params.allowedEmojiReactions == null || params.allowedEmojiReactions.has(candidate)) && isTelegramSupportedReactionEmoji(candidate)) return candidate;
1878
+ }
1879
+
1880
+ //#endregion
1881
+ //#region src/telegram/bot-message-context.ts
1882
+ async function resolveStickerVisionSupport$1(params) {
1883
+ try {
1884
+ const catalog = await loadModelCatalog({ config: params.cfg });
1885
+ const defaultModel = resolveDefaultModelForAgent({
1886
+ cfg: params.cfg,
1887
+ agentId: params.agentId
1888
+ });
1889
+ const entry = findModelInCatalog(catalog, defaultModel.provider, defaultModel.model);
1890
+ if (!entry) return false;
1891
+ return modelSupportsVision(entry);
1892
+ } catch {
1893
+ return false;
1894
+ }
1895
+ }
1896
+ const buildTelegramMessageContext = async ({ primaryCtx, allMedia, replyMedia = [], storeAllowFrom, options, bot, cfg, account, historyLimit, groupHistories, dmPolicy, allowFrom, groupAllowFrom, ackReactionScope, logger, resolveGroupActivation, resolveGroupRequireMention, resolveTelegramGroupConfig, sendChatActionHandler }) => {
1897
+ const msg = primaryCtx.message;
1898
+ const chatId = msg.chat.id;
1899
+ const isGroup = msg.chat.type === "group" || msg.chat.type === "supergroup";
1900
+ const messageThreadId = msg.message_thread_id;
1901
+ const isForum = msg.chat.is_forum === true;
1902
+ const threadSpec = resolveTelegramThreadSpec({
1903
+ isGroup,
1904
+ isForum,
1905
+ messageThreadId
1906
+ });
1907
+ const resolvedThreadId = threadSpec.scope === "forum" ? threadSpec.id : void 0;
1908
+ const replyThreadId = threadSpec.id;
1909
+ const { groupConfig, topicConfig } = resolveTelegramGroupConfig(chatId, resolvedThreadId);
1910
+ const peerId = isGroup ? buildTelegramGroupPeerId(chatId, resolvedThreadId) : String(chatId);
1911
+ const parentPeer = buildTelegramParentPeer({
1912
+ isGroup,
1913
+ resolvedThreadId,
1914
+ chatId
1915
+ });
1916
+ const route = resolveAgentRoute({
1917
+ cfg: loadConfig(),
1918
+ channel: "telegram",
1919
+ accountId: account.accountId,
1920
+ peer: {
1921
+ kind: isGroup ? "group" : "direct",
1922
+ id: peerId
1923
+ },
1924
+ parentPeer
1925
+ });
1926
+ const baseSessionKey = route.sessionKey;
1927
+ const dmThreadId = threadSpec.scope === "dm" ? threadSpec.id : void 0;
1928
+ const sessionKey = (dmThreadId != null ? resolveThreadSessionKeys({
1929
+ baseSessionKey,
1930
+ threadId: String(dmThreadId)
1931
+ }) : null)?.sessionKey ?? baseSessionKey;
1932
+ const mentionRegexes = buildMentionRegexes(cfg, route.agentId);
1933
+ const effectiveDmAllow = normalizeDmAllowFromWithStore({
1934
+ allowFrom,
1935
+ storeAllowFrom,
1936
+ dmPolicy
1937
+ });
1938
+ const groupAllowOverride = firstDefined(topicConfig?.allowFrom, groupConfig?.allowFrom);
1939
+ const effectiveGroupAllow = normalizeAllowFrom(groupAllowOverride ?? groupAllowFrom);
1940
+ const hasGroupAllowOverride = typeof groupAllowOverride !== "undefined";
1941
+ const senderId = msg.from?.id ? String(msg.from.id) : "";
1942
+ const senderUsername = msg.from?.username ?? "";
1943
+ const baseAccess = evaluateTelegramGroupBaseAccess({
1944
+ isGroup,
1945
+ groupConfig,
1946
+ topicConfig,
1947
+ hasGroupAllowOverride,
1948
+ effectiveGroupAllow,
1949
+ senderId,
1950
+ senderUsername,
1951
+ enforceAllowOverride: true,
1952
+ requireSenderForAllowOverride: false
1953
+ });
1954
+ if (!baseAccess.allowed) {
1955
+ if (baseAccess.reason === "group-disabled") {
1956
+ logVerbose(`Blocked telegram group ${chatId} (group disabled)`);
1957
+ return null;
1958
+ }
1959
+ if (baseAccess.reason === "topic-disabled") {
1960
+ logVerbose(`Blocked telegram topic ${chatId} (${resolvedThreadId ?? "unknown"}) (topic disabled)`);
1961
+ return null;
1962
+ }
1963
+ logVerbose(`Blocked telegram group sender ${senderId || "unknown"} (group allowFrom override)`);
1964
+ return null;
1965
+ }
1966
+ const activationOverride = resolveGroupActivation({
1967
+ chatId,
1968
+ messageThreadId: resolvedThreadId,
1969
+ sessionKey,
1970
+ agentId: route.agentId
1971
+ });
1972
+ const baseRequireMention = resolveGroupRequireMention(chatId);
1973
+ const requireMention = firstDefined(activationOverride, topicConfig?.requireMention, groupConfig?.requireMention, baseRequireMention);
1974
+ const sendTyping = async () => {
1975
+ await withTelegramApiErrorLogging({
1976
+ operation: "sendChatAction",
1977
+ fn: () => sendChatActionHandler.sendChatAction(chatId, "typing", buildTypingThreadParams(replyThreadId))
1978
+ });
1979
+ };
1980
+ const sendRecordVoice = async () => {
1981
+ try {
1982
+ await withTelegramApiErrorLogging({
1983
+ operation: "sendChatAction",
1984
+ fn: () => sendChatActionHandler.sendChatAction(chatId, "record_voice", buildTypingThreadParams(replyThreadId))
1985
+ });
1986
+ } catch (err) {
1987
+ logVerbose(`telegram record_voice cue failed for chat ${chatId}: ${String(err)}`);
1988
+ }
1989
+ };
1990
+ if (!await enforceTelegramDmAccess({
1991
+ isGroup,
1992
+ dmPolicy,
1993
+ msg,
1994
+ chatId,
1995
+ effectiveDmAllow,
1996
+ accountId: account.accountId,
1997
+ bot,
1998
+ logger
1999
+ })) return null;
2000
+ recordChannelActivity({
2001
+ channel: "telegram",
2002
+ accountId: account.accountId,
2003
+ direction: "inbound"
2004
+ });
2005
+ const botUsername = primaryCtx.me?.username?.toLowerCase();
2006
+ const allowForCommands = isGroup ? effectiveGroupAllow : effectiveDmAllow;
2007
+ const senderAllowedForCommands = isSenderAllowed({
2008
+ allow: allowForCommands,
2009
+ senderId,
2010
+ senderUsername
2011
+ });
2012
+ const useAccessGroups = cfg.commands?.useAccessGroups !== false;
2013
+ const hasControlCommandInMessage = hasControlCommand(msg.text ?? msg.caption ?? "", cfg, { botUsername });
2014
+ const commandGate = resolveControlCommandGate({
2015
+ useAccessGroups,
2016
+ authorizers: [{
2017
+ configured: allowForCommands.hasEntries,
2018
+ allowed: senderAllowedForCommands
2019
+ }],
2020
+ allowTextCommands: true,
2021
+ hasControlCommand: hasControlCommandInMessage
2022
+ });
2023
+ const commandAuthorized = commandGate.commandAuthorized;
2024
+ const historyKey = isGroup ? buildTelegramGroupPeerId(chatId, resolvedThreadId) : void 0;
2025
+ let placeholder = resolveTelegramMediaPlaceholder(msg) ?? "";
2026
+ const cachedStickerDescription = allMedia[0]?.stickerMetadata?.cachedDescription;
2027
+ const stickerSupportsVision = msg.sticker ? await resolveStickerVisionSupport$1({
2028
+ cfg,
2029
+ agentId: route.agentId
2030
+ }) : false;
2031
+ const stickerCacheHit = Boolean(cachedStickerDescription) && !stickerSupportsVision;
2032
+ if (stickerCacheHit) {
2033
+ const emoji = allMedia[0]?.stickerMetadata?.emoji;
2034
+ const setName = allMedia[0]?.stickerMetadata?.setName;
2035
+ const stickerContext = [emoji, setName ? `from "${setName}"` : null].filter(Boolean).join(" ");
2036
+ placeholder = `[Sticker${stickerContext ? ` ${stickerContext}` : ""}] ${cachedStickerDescription}`;
2037
+ }
2038
+ const locationData = extractTelegramLocation(msg);
2039
+ const locationText = locationData ? formatLocationText(locationData) : void 0;
2040
+ const rawText = expandTextLinks(msg.text ?? msg.caption ?? "", msg.entities ?? msg.caption_entities).trim();
2041
+ const hasUserText = Boolean(rawText || locationText);
2042
+ let rawBody = [rawText, locationText].filter(Boolean).join("\n").trim();
2043
+ if (!rawBody) rawBody = placeholder;
2044
+ if (!rawBody && allMedia.length === 0) return null;
2045
+ let bodyText = rawBody;
2046
+ const hasAudio = allMedia.some((media) => media.contentType?.startsWith("audio/"));
2047
+ let preflightTranscript;
2048
+ if (isGroup && requireMention && hasAudio && !hasUserText && mentionRegexes.length > 0) try {
2049
+ const { transcribeFirstAudio } = await import("./audio-preflight-CzG6BjAn.js");
2050
+ preflightTranscript = await transcribeFirstAudio({
2051
+ ctx: {
2052
+ MediaPaths: allMedia.length > 0 ? allMedia.map((m) => m.path) : void 0,
2053
+ MediaTypes: allMedia.length > 0 ? allMedia.map((m) => m.contentType).filter(Boolean) : void 0
2054
+ },
2055
+ cfg,
2056
+ agentDir: void 0
2057
+ });
2058
+ } catch (err) {
2059
+ logVerbose(`telegram: audio preflight transcription failed: ${String(err)}`);
2060
+ }
2061
+ if (hasAudio && bodyText === "<media:audio>" && preflightTranscript) bodyText = preflightTranscript;
2062
+ if (!bodyText && allMedia.length > 0) if (hasAudio) bodyText = preflightTranscript || "<media:audio>";
2063
+ else bodyText = `<media:image>${allMedia.length > 1 ? ` (${allMedia.length} images)` : ""}`;
2064
+ const hasAnyMention = (msg.entities ?? msg.caption_entities ?? []).some((ent) => ent.type === "mention");
2065
+ const explicitlyMentioned = botUsername ? hasBotMention(msg, botUsername) : false;
2066
+ const computedWasMentioned = matchesMentionWithExplicit({
2067
+ text: msg.text ?? msg.caption ?? "",
2068
+ mentionRegexes,
2069
+ explicit: {
2070
+ hasAnyMention,
2071
+ isExplicitlyMentioned: explicitlyMentioned,
2072
+ canResolveExplicit: Boolean(botUsername)
2073
+ },
2074
+ transcript: preflightTranscript
2075
+ });
2076
+ const wasMentioned = options?.forceWasMentioned === true ? true : computedWasMentioned;
2077
+ if (isGroup && commandGate.shouldBlock) {
2078
+ logInboundDrop({
2079
+ log: logVerbose,
2080
+ channel: "telegram",
2081
+ reason: "control command (unauthorized)",
2082
+ target: senderId ?? "unknown"
2083
+ });
2084
+ return null;
2085
+ }
2086
+ const botId = primaryCtx.me?.id;
2087
+ const replyFromId = msg.reply_to_message?.from?.id;
2088
+ const implicitMention = botId != null && replyFromId === botId;
2089
+ const canDetectMention = Boolean(botUsername) || mentionRegexes.length > 0;
2090
+ const mentionGate = resolveMentionGatingWithBypass({
2091
+ isGroup,
2092
+ requireMention: Boolean(requireMention),
2093
+ canDetectMention,
2094
+ wasMentioned,
2095
+ implicitMention: isGroup && Boolean(requireMention) && implicitMention,
2096
+ hasAnyMention,
2097
+ allowTextCommands: true,
2098
+ hasControlCommand: hasControlCommandInMessage,
2099
+ commandAuthorized
2100
+ });
2101
+ const effectiveWasMentioned = mentionGate.effectiveWasMentioned;
2102
+ if (isGroup && requireMention && canDetectMention) {
2103
+ if (mentionGate.shouldSkip) {
2104
+ logger.info({
2105
+ chatId,
2106
+ reason: "no-mention"
2107
+ }, "skipping group message");
2108
+ recordPendingHistoryEntryIfEnabled({
2109
+ historyMap: groupHistories,
2110
+ historyKey: historyKey ?? "",
2111
+ limit: historyLimit,
2112
+ entry: historyKey ? {
2113
+ sender: buildSenderLabel(msg, senderId || chatId),
2114
+ body: rawBody,
2115
+ timestamp: msg.date ? msg.date * 1e3 : void 0,
2116
+ messageId: typeof msg.message_id === "number" ? String(msg.message_id) : void 0
2117
+ } : null
2118
+ });
2119
+ return null;
2120
+ }
2121
+ }
2122
+ const ackReaction = resolveAckReaction(cfg, route.agentId, {
2123
+ channel: "telegram",
2124
+ accountId: account.accountId
2125
+ });
2126
+ const removeAckAfterReply = cfg.messages?.removeAckAfterReply ?? false;
2127
+ const shouldAckReaction$1 = () => Boolean(ackReaction && shouldAckReaction({
2128
+ scope: ackReactionScope,
2129
+ isDirect: !isGroup,
2130
+ isGroup,
2131
+ isMentionableGroup: isGroup,
2132
+ requireMention: Boolean(requireMention),
2133
+ canDetectMention,
2134
+ effectiveWasMentioned,
2135
+ shouldBypassMention: mentionGate.shouldBypassMention
2136
+ }));
2137
+ const api = bot.api;
2138
+ const reactionApi = typeof api.setMessageReaction === "function" ? api.setMessageReaction.bind(api) : null;
2139
+ const getChatApi = typeof api.getChat === "function" ? api.getChat.bind(api) : null;
2140
+ const statusReactionsConfig = cfg.messages?.statusReactions;
2141
+ const statusReactionsEnabled = statusReactionsConfig?.enabled === true && Boolean(reactionApi) && shouldAckReaction$1();
2142
+ const resolvedStatusReactionEmojis = resolveTelegramStatusReactionEmojis({
2143
+ initialEmoji: ackReaction,
2144
+ overrides: statusReactionsConfig?.emojis
2145
+ });
2146
+ const statusReactionVariantsByEmoji = buildTelegramStatusReactionVariants(resolvedStatusReactionEmojis);
2147
+ let allowedStatusReactionEmojisPromise = null;
2148
+ const statusReactionController = statusReactionsEnabled && msg.message_id ? createStatusReactionController({
2149
+ enabled: true,
2150
+ adapter: { setReaction: async (emoji) => {
2151
+ if (reactionApi) {
2152
+ if (!allowedStatusReactionEmojisPromise) allowedStatusReactionEmojisPromise = resolveTelegramAllowedEmojiReactions({
2153
+ chat: msg.chat,
2154
+ chatId,
2155
+ getChat: getChatApi ?? void 0
2156
+ }).catch((err) => {
2157
+ logVerbose(`telegram status-reaction available_reactions lookup failed for chat ${chatId}: ${String(err)}`);
2158
+ return null;
2159
+ });
2160
+ const resolvedEmoji = resolveTelegramReactionVariant({
2161
+ requestedEmoji: emoji,
2162
+ variantsByRequestedEmoji: statusReactionVariantsByEmoji,
2163
+ allowedEmojiReactions: await allowedStatusReactionEmojisPromise
2164
+ });
2165
+ if (!resolvedEmoji) return;
2166
+ await reactionApi(chatId, msg.message_id, [{
2167
+ type: "emoji",
2168
+ emoji: resolvedEmoji
2169
+ }]);
2170
+ }
2171
+ } },
2172
+ initialEmoji: ackReaction,
2173
+ emojis: resolvedStatusReactionEmojis,
2174
+ timing: statusReactionsConfig?.timing,
2175
+ onError: (err) => {
2176
+ logVerbose(`telegram status-reaction error for chat ${chatId}: ${String(err)}`);
2177
+ }
2178
+ }) : null;
2179
+ const ackReactionPromise = statusReactionController ? shouldAckReaction$1() ? Promise.resolve(statusReactionController.setQueued()).then(() => true, () => false) : null : shouldAckReaction$1() && msg.message_id && reactionApi ? withTelegramApiErrorLogging({
2180
+ operation: "setMessageReaction",
2181
+ fn: () => reactionApi(chatId, msg.message_id, [{
2182
+ type: "emoji",
2183
+ emoji: ackReaction
2184
+ }])
2185
+ }).then(() => true, (err) => {
2186
+ logVerbose(`telegram react failed for chat ${chatId}: ${String(err)}`);
2187
+ return false;
2188
+ }) : null;
2189
+ const replyTarget = describeReplyTarget(msg);
2190
+ const forwardOrigin = normalizeForwardedContext(msg);
2191
+ const replyForwardAnnotation = replyTarget?.forwardedFrom ? `[Forwarded from ${replyTarget.forwardedFrom.from}${replyTarget.forwardedFrom.date ? ` at ${(/* @__PURE__ */ new Date(replyTarget.forwardedFrom.date * 1e3)).toISOString()}` : ""}]\n` : "";
2192
+ const replySuffix = replyTarget ? replyTarget.kind === "quote" ? `\n\n[Quoting ${replyTarget.sender}${replyTarget.id ? ` id:${replyTarget.id}` : ""}]\n${replyForwardAnnotation}"${replyTarget.body}"\n[/Quoting]` : `\n\n[Replying to ${replyTarget.sender}${replyTarget.id ? ` id:${replyTarget.id}` : ""}]\n${replyForwardAnnotation}${replyTarget.body}\n[/Replying]` : "";
2193
+ const forwardPrefix = forwardOrigin ? `[Forwarded from ${forwardOrigin.from}${forwardOrigin.date ? ` at ${(/* @__PURE__ */ new Date(forwardOrigin.date * 1e3)).toISOString()}` : ""}]\n` : "";
2194
+ const groupLabel = isGroup ? buildGroupLabel(msg, chatId, resolvedThreadId) : void 0;
2195
+ const senderName = buildSenderName(msg);
2196
+ const conversationLabel = isGroup ? groupLabel ?? `group:${chatId}` : buildSenderLabel(msg, senderId || chatId);
2197
+ const storePath = resolveStorePath(cfg.session?.store, { agentId: route.agentId });
2198
+ const envelopeOptions = resolveEnvelopeFormatOptions(cfg);
2199
+ const previousTimestamp = readSessionUpdatedAt({
2200
+ storePath,
2201
+ sessionKey
2202
+ });
2203
+ const body = formatInboundEnvelope({
2204
+ channel: "Telegram",
2205
+ from: conversationLabel,
2206
+ timestamp: msg.date ? msg.date * 1e3 : void 0,
2207
+ body: `${forwardPrefix}${bodyText}${replySuffix}`,
2208
+ chatType: isGroup ? "group" : "direct",
2209
+ sender: {
2210
+ name: senderName,
2211
+ username: senderUsername || void 0,
2212
+ id: senderId || void 0
2213
+ },
2214
+ previousTimestamp,
2215
+ envelope: envelopeOptions
2216
+ });
2217
+ let combinedBody = body;
2218
+ if (isGroup && historyKey && historyLimit > 0) combinedBody = buildPendingHistoryContextFromMap({
2219
+ historyMap: groupHistories,
2220
+ historyKey,
2221
+ limit: historyLimit,
2222
+ currentMessage: combinedBody,
2223
+ formatEntry: (entry) => formatInboundEnvelope({
2224
+ channel: "Telegram",
2225
+ from: groupLabel ?? `group:${chatId}`,
2226
+ timestamp: entry.timestamp,
2227
+ body: `${entry.body} [id:${entry.messageId ?? "unknown"} chat:${chatId}]`,
2228
+ chatType: "group",
2229
+ senderLabel: entry.sender,
2230
+ envelope: envelopeOptions
2231
+ })
2232
+ });
2233
+ const { skillFilter, groupSystemPrompt } = resolveTelegramGroupPromptSettings({
2234
+ groupConfig,
2235
+ topicConfig
2236
+ });
2237
+ const commandBody = normalizeCommandBody(rawBody, { botUsername });
2238
+ const inboundHistory = isGroup && historyKey && historyLimit > 0 ? (groupHistories.get(historyKey) ?? []).map((entry) => ({
2239
+ sender: entry.sender,
2240
+ body: entry.body,
2241
+ timestamp: entry.timestamp
2242
+ })) : void 0;
2243
+ const contextMedia = [...stickerCacheHit ? [] : allMedia, ...replyMedia];
2244
+ const ctxPayload = finalizeInboundContext({
2245
+ Body: combinedBody,
2246
+ BodyForAgent: bodyText,
2247
+ InboundHistory: inboundHistory,
2248
+ RawBody: rawBody,
2249
+ CommandBody: commandBody,
2250
+ From: isGroup ? buildTelegramGroupFrom(chatId, resolvedThreadId) : `telegram:${chatId}`,
2251
+ To: `telegram:${chatId}`,
2252
+ SessionKey: sessionKey,
2253
+ AccountId: route.accountId,
2254
+ ChatType: isGroup ? "group" : "direct",
2255
+ ConversationLabel: conversationLabel,
2256
+ GroupSubject: isGroup ? msg.chat.title ?? void 0 : void 0,
2257
+ GroupSystemPrompt: isGroup ? groupSystemPrompt : void 0,
2258
+ SenderName: senderName,
2259
+ SenderId: senderId || void 0,
2260
+ SenderUsername: senderUsername || void 0,
2261
+ Provider: "telegram",
2262
+ Surface: "telegram",
2263
+ MessageSid: options?.messageIdOverride ?? String(msg.message_id),
2264
+ ReplyToId: replyTarget?.id,
2265
+ ReplyToBody: replyTarget?.body,
2266
+ ReplyToSender: replyTarget?.sender,
2267
+ ReplyToIsQuote: replyTarget?.kind === "quote" ? true : void 0,
2268
+ ReplyToForwardedFrom: replyTarget?.forwardedFrom?.from,
2269
+ ReplyToForwardedFromType: replyTarget?.forwardedFrom?.fromType,
2270
+ ReplyToForwardedFromId: replyTarget?.forwardedFrom?.fromId,
2271
+ ReplyToForwardedFromUsername: replyTarget?.forwardedFrom?.fromUsername,
2272
+ ReplyToForwardedFromTitle: replyTarget?.forwardedFrom?.fromTitle,
2273
+ ReplyToForwardedDate: replyTarget?.forwardedFrom?.date ? replyTarget.forwardedFrom.date * 1e3 : void 0,
2274
+ ForwardedFrom: forwardOrigin?.from,
2275
+ ForwardedFromType: forwardOrigin?.fromType,
2276
+ ForwardedFromId: forwardOrigin?.fromId,
2277
+ ForwardedFromUsername: forwardOrigin?.fromUsername,
2278
+ ForwardedFromTitle: forwardOrigin?.fromTitle,
2279
+ ForwardedFromSignature: forwardOrigin?.fromSignature,
2280
+ ForwardedFromChatType: forwardOrigin?.fromChatType,
2281
+ ForwardedFromMessageId: forwardOrigin?.fromMessageId,
2282
+ ForwardedDate: forwardOrigin?.date ? forwardOrigin.date * 1e3 : void 0,
2283
+ Timestamp: msg.date ? msg.date * 1e3 : void 0,
2284
+ WasMentioned: isGroup ? effectiveWasMentioned : void 0,
2285
+ MediaPath: contextMedia.length > 0 ? contextMedia[0]?.path : void 0,
2286
+ MediaType: contextMedia.length > 0 ? contextMedia[0]?.contentType : void 0,
2287
+ MediaUrl: contextMedia.length > 0 ? contextMedia[0]?.path : void 0,
2288
+ MediaPaths: contextMedia.length > 0 ? contextMedia.map((m) => m.path) : void 0,
2289
+ MediaUrls: contextMedia.length > 0 ? contextMedia.map((m) => m.path) : void 0,
2290
+ MediaTypes: contextMedia.length > 0 ? contextMedia.map((m) => m.contentType).filter(Boolean) : void 0,
2291
+ Sticker: allMedia[0]?.stickerMetadata,
2292
+ StickerMediaIncluded: allMedia[0]?.stickerMetadata ? !stickerCacheHit : void 0,
2293
+ ...locationData ? toLocationContext(locationData) : void 0,
2294
+ CommandAuthorized: commandAuthorized,
2295
+ MessageThreadId: threadSpec.id,
2296
+ IsForum: isForum,
2297
+ OriginatingChannel: "telegram",
2298
+ OriginatingTo: `telegram:${chatId}`
2299
+ });
2300
+ await recordInboundSession({
2301
+ storePath,
2302
+ sessionKey: ctxPayload.SessionKey ?? sessionKey,
2303
+ ctx: ctxPayload,
2304
+ updateLastRoute: !isGroup ? {
2305
+ sessionKey: route.mainSessionKey,
2306
+ channel: "telegram",
2307
+ to: `telegram:${chatId}`,
2308
+ accountId: route.accountId,
2309
+ threadId: dmThreadId != null ? String(dmThreadId) : void 0
2310
+ } : void 0,
2311
+ onRecordError: (err) => {
2312
+ logVerbose(`telegram: failed updating session meta: ${String(err)}`);
2313
+ }
2314
+ });
2315
+ if (replyTarget && shouldLogVerbose()) {
2316
+ const preview = replyTarget.body.replace(/\s+/g, " ").slice(0, 120);
2317
+ logVerbose(`telegram reply-context: replyToId=${replyTarget.id} replyToSender=${replyTarget.sender} replyToBody="${preview}"`);
2318
+ }
2319
+ if (forwardOrigin && shouldLogVerbose()) logVerbose(`telegram forward-context: forwardedFrom="${forwardOrigin.from}" type=${forwardOrigin.fromType}`);
2320
+ if (shouldLogVerbose()) {
2321
+ const preview = body.slice(0, 200).replace(/\n/g, "\\n");
2322
+ const mediaInfo = allMedia.length > 1 ? ` mediaCount=${allMedia.length}` : "";
2323
+ const topicInfo = resolvedThreadId != null ? ` topic=${resolvedThreadId}` : "";
2324
+ logVerbose(`telegram inbound: chatId=${chatId} from=${ctxPayload.From} len=${body.length}${mediaInfo}${topicInfo} preview="${preview}"`);
2325
+ }
2326
+ return {
2327
+ ctxPayload,
2328
+ primaryCtx,
2329
+ msg,
2330
+ chatId,
2331
+ isGroup,
2332
+ resolvedThreadId,
2333
+ threadSpec,
2334
+ replyThreadId,
2335
+ isForum,
2336
+ historyKey,
2337
+ historyLimit,
2338
+ groupHistories,
2339
+ route,
2340
+ skillFilter,
2341
+ sendTyping,
2342
+ sendRecordVoice,
2343
+ ackReactionPromise,
2344
+ reactionApi,
2345
+ removeAckAfterReply,
2346
+ statusReactionController,
2347
+ accountId: account.accountId
2348
+ };
2349
+ };
2350
+
2351
+ //#endregion
2352
+ //#region src/telegram/draft-stream.ts
2353
+ const TELEGRAM_STREAM_MAX_CHARS = 4096;
2354
+ const DEFAULT_THROTTLE_MS = 1e3;
2355
+ function createTelegramDraftStream(params) {
2356
+ const maxChars = Math.min(params.maxChars ?? TELEGRAM_STREAM_MAX_CHARS, TELEGRAM_STREAM_MAX_CHARS);
2357
+ const throttleMs = Math.max(250, params.throttleMs ?? DEFAULT_THROTTLE_MS);
2358
+ const minInitialChars = params.minInitialChars;
2359
+ const chatId = params.chatId;
2360
+ const threadParams = buildTelegramThreadParams(params.thread);
2361
+ const replyParams = params.replyToMessageId != null ? {
2362
+ ...threadParams,
2363
+ reply_to_message_id: params.replyToMessageId
2364
+ } : threadParams;
2365
+ const streamState = {
2366
+ stopped: false,
2367
+ final: false
2368
+ };
2369
+ let streamMessageId;
2370
+ let lastSentText = "";
2371
+ let lastSentParseMode;
2372
+ let generation = 0;
2373
+ const sendOrEditStreamMessage = async (text) => {
2374
+ if (streamState.stopped && !streamState.final) return false;
2375
+ const trimmed = text.trimEnd();
2376
+ if (!trimmed) return false;
2377
+ const rendered = params.renderText?.(trimmed) ?? { text: trimmed };
2378
+ const renderedText = rendered.text.trimEnd();
2379
+ const renderedParseMode = rendered.parseMode;
2380
+ if (!renderedText) return false;
2381
+ if (renderedText.length > maxChars) {
2382
+ streamState.stopped = true;
2383
+ params.warn?.(`telegram stream preview stopped (text length ${renderedText.length} > ${maxChars})`);
2384
+ return false;
2385
+ }
2386
+ if (renderedText === lastSentText && renderedParseMode === lastSentParseMode) return true;
2387
+ const sendGeneration = generation;
2388
+ if (typeof streamMessageId !== "number" && minInitialChars != null && !streamState.final) {
2389
+ if (renderedText.length < minInitialChars) return false;
2390
+ }
2391
+ lastSentText = renderedText;
2392
+ lastSentParseMode = renderedParseMode;
2393
+ try {
2394
+ if (typeof streamMessageId === "number") {
2395
+ if (renderedParseMode) await params.api.editMessageText(chatId, streamMessageId, renderedText, { parse_mode: renderedParseMode });
2396
+ else await params.api.editMessageText(chatId, streamMessageId, renderedText);
2397
+ return true;
2398
+ }
2399
+ const sendParams = renderedParseMode ? {
2400
+ ...replyParams,
2401
+ parse_mode: renderedParseMode
2402
+ } : replyParams;
2403
+ const sentMessageId = (await params.api.sendMessage(chatId, renderedText, sendParams))?.message_id;
2404
+ if (typeof sentMessageId !== "number" || !Number.isFinite(sentMessageId)) {
2405
+ streamState.stopped = true;
2406
+ params.warn?.("telegram stream preview stopped (missing message id from sendMessage)");
2407
+ return false;
2408
+ }
2409
+ const normalizedMessageId = Math.trunc(sentMessageId);
2410
+ if (sendGeneration !== generation) {
2411
+ params.onSupersededPreview?.({
2412
+ messageId: normalizedMessageId,
2413
+ textSnapshot: renderedText,
2414
+ parseMode: renderedParseMode
2415
+ });
2416
+ return true;
2417
+ }
2418
+ streamMessageId = normalizedMessageId;
2419
+ return true;
2420
+ } catch (err) {
2421
+ streamState.stopped = true;
2422
+ params.warn?.(`telegram stream preview failed: ${err instanceof Error ? err.message : String(err)}`);
2423
+ return false;
2424
+ }
2425
+ };
2426
+ const { loop, update, stop, clear } = createFinalizableDraftLifecycle({
2427
+ throttleMs,
2428
+ state: streamState,
2429
+ sendOrEditStreamMessage,
2430
+ readMessageId: () => streamMessageId,
2431
+ clearMessageId: () => {
2432
+ streamMessageId = void 0;
2433
+ },
2434
+ isValidMessageId: (value) => typeof value === "number" && Number.isFinite(value),
2435
+ deleteMessage: async (messageId) => {
2436
+ await params.api.deleteMessage(chatId, messageId);
2437
+ },
2438
+ onDeleteSuccess: (messageId) => {
2439
+ params.log?.(`telegram stream preview deleted (chat=${chatId}, message=${messageId})`);
2440
+ },
2441
+ warn: params.warn,
2442
+ warnPrefix: "telegram stream preview cleanup failed"
2443
+ });
2444
+ const forceNewMessage = () => {
2445
+ generation += 1;
2446
+ streamMessageId = void 0;
2447
+ lastSentText = "";
2448
+ lastSentParseMode = void 0;
2449
+ loop.resetPending();
2450
+ loop.resetThrottleWindow();
2451
+ };
2452
+ params.log?.(`telegram stream preview ready (maxChars=${maxChars}, throttleMs=${throttleMs})`);
2453
+ return {
2454
+ update,
2455
+ flush: loop.flush,
2456
+ messageId: () => streamMessageId,
2457
+ clear,
2458
+ stop,
2459
+ forceNewMessage
2460
+ };
2461
+ }
2462
+
2463
+ //#endregion
2464
+ //#region src/telegram/lane-delivery.ts
2465
+ function createLaneDeliveryStateTracker() {
2466
+ const state = {
2467
+ delivered: false,
2468
+ skippedNonSilent: 0,
2469
+ failedNonSilent: 0
2470
+ };
2471
+ return {
2472
+ markDelivered: () => {
2473
+ state.delivered = true;
2474
+ },
2475
+ markNonSilentSkip: () => {
2476
+ state.skippedNonSilent += 1;
2477
+ },
2478
+ markNonSilentFailure: () => {
2479
+ state.failedNonSilent += 1;
2480
+ },
2481
+ snapshot: () => ({ ...state })
2482
+ };
2483
+ }
2484
+ function createLaneTextDeliverer(params) {
2485
+ const getLanePreviewText = (lane) => lane.lastPartialText;
2486
+ const shouldSkipRegressivePreviewUpdate = (args) => {
2487
+ const currentPreviewText = args.currentPreviewText;
2488
+ if (currentPreviewText === void 0) return false;
2489
+ return currentPreviewText.startsWith(args.text) && args.text.length < currentPreviewText.length && (args.skipRegressive === "always" || args.hadPreviewMessage);
2490
+ };
2491
+ const tryEditPreviewMessage = async (args) => {
2492
+ try {
2493
+ await params.editPreview({
2494
+ laneName: args.laneName,
2495
+ messageId: args.messageId,
2496
+ text: args.text,
2497
+ previewButtons: args.previewButtons,
2498
+ context: args.context
2499
+ });
2500
+ if (args.updateLaneSnapshot) args.lane.lastPartialText = args.text;
2501
+ params.markDelivered();
2502
+ return true;
2503
+ } catch (err) {
2504
+ if (args.treatEditFailureAsDelivered) {
2505
+ params.log(`telegram: ${args.laneName} preview ${args.context} edit failed after stop-created flush; treating as delivered (${String(err)})`);
2506
+ params.markDelivered();
2507
+ return true;
2508
+ }
2509
+ params.log(`telegram: ${args.laneName} preview ${args.context} edit failed; falling back to standard send (${String(err)})`);
2510
+ return false;
2511
+ }
2512
+ };
2513
+ const tryUpdatePreviewForLane = async ({ lane, laneName, text, previewButtons, stopBeforeEdit = false, updateLaneSnapshot = false, skipRegressive, context, previewMessageId: previewMessageIdOverride, previewTextSnapshot }) => {
2514
+ if (!lane.stream) return false;
2515
+ const lanePreviewMessageId = lane.stream.messageId();
2516
+ const hadPreviewMessage = typeof previewMessageIdOverride === "number" || typeof lanePreviewMessageId === "number";
2517
+ if (stopBeforeEdit && !hadPreviewMessage && context === "final") {
2518
+ lane.stream.update(text);
2519
+ await params.stopDraftLane(lane);
2520
+ const previewMessageId = lane.stream.messageId();
2521
+ if (typeof previewMessageId !== "number") return false;
2522
+ if (shouldSkipRegressivePreviewUpdate({
2523
+ currentPreviewText: previewTextSnapshot ?? getLanePreviewText(lane),
2524
+ text,
2525
+ skipRegressive,
2526
+ hadPreviewMessage
2527
+ })) {
2528
+ params.markDelivered();
2529
+ return true;
2530
+ }
2531
+ return tryEditPreviewMessage({
2532
+ laneName,
2533
+ messageId: previewMessageId,
2534
+ text,
2535
+ context,
2536
+ previewButtons,
2537
+ updateLaneSnapshot,
2538
+ lane,
2539
+ treatEditFailureAsDelivered: true
2540
+ });
2541
+ }
2542
+ if (stopBeforeEdit) await params.stopDraftLane(lane);
2543
+ const previewMessageId = typeof previewMessageIdOverride === "number" ? previewMessageIdOverride : lane.stream.messageId();
2544
+ if (typeof previewMessageId !== "number") return false;
2545
+ if (shouldSkipRegressivePreviewUpdate({
2546
+ currentPreviewText: previewTextSnapshot ?? getLanePreviewText(lane),
2547
+ text,
2548
+ skipRegressive,
2549
+ hadPreviewMessage
2550
+ })) {
2551
+ params.markDelivered();
2552
+ return true;
2553
+ }
2554
+ return tryEditPreviewMessage({
2555
+ laneName,
2556
+ messageId: previewMessageId,
2557
+ text,
2558
+ context,
2559
+ previewButtons,
2560
+ updateLaneSnapshot,
2561
+ lane,
2562
+ treatEditFailureAsDelivered: false
2563
+ });
2564
+ };
2565
+ const consumeArchivedAnswerPreviewForFinal = async ({ lane, text, payload, previewButtons, canEditViaPreview }) => {
2566
+ const archivedPreview = params.archivedAnswerPreviews.shift();
2567
+ if (!archivedPreview) return;
2568
+ if (canEditViaPreview) {
2569
+ if (await tryUpdatePreviewForLane({
2570
+ lane,
2571
+ laneName: "answer",
2572
+ text,
2573
+ previewButtons,
2574
+ stopBeforeEdit: false,
2575
+ skipRegressive: "existingOnly",
2576
+ context: "final",
2577
+ previewMessageId: archivedPreview.messageId,
2578
+ previewTextSnapshot: archivedPreview.textSnapshot
2579
+ })) return "preview-finalized";
2580
+ }
2581
+ try {
2582
+ await params.deletePreviewMessage(archivedPreview.messageId);
2583
+ } catch (err) {
2584
+ params.log(`telegram: archived answer preview cleanup failed (${archivedPreview.messageId}): ${String(err)}`);
2585
+ }
2586
+ return await params.sendPayload(params.applyTextToPayload(payload, text)) ? "sent" : "skipped";
2587
+ };
2588
+ return async ({ laneName, text, payload, infoKind, previewButtons, allowPreviewUpdateForNonFinal = false }) => {
2589
+ const lane = params.lanes[laneName];
2590
+ const hasMedia = Boolean(payload.mediaUrl) || (payload.mediaUrls?.length ?? 0) > 0;
2591
+ const canEditViaPreview = !hasMedia && text.length > 0 && text.length <= params.draftMaxChars && !payload.isError;
2592
+ if (infoKind === "final") {
2593
+ if (laneName === "answer") {
2594
+ const archivedResult = await consumeArchivedAnswerPreviewForFinal({
2595
+ lane,
2596
+ text,
2597
+ payload,
2598
+ previewButtons,
2599
+ canEditViaPreview
2600
+ });
2601
+ if (archivedResult) return archivedResult;
2602
+ }
2603
+ if (canEditViaPreview && !params.finalizedPreviewByLane[laneName]) {
2604
+ await params.flushDraftLane(lane);
2605
+ if (laneName === "answer") {
2606
+ const archivedResultAfterFlush = await consumeArchivedAnswerPreviewForFinal({
2607
+ lane,
2608
+ text,
2609
+ payload,
2610
+ previewButtons,
2611
+ canEditViaPreview
2612
+ });
2613
+ if (archivedResultAfterFlush) return archivedResultAfterFlush;
2614
+ }
2615
+ if (await tryUpdatePreviewForLane({
2616
+ lane,
2617
+ laneName,
2618
+ text,
2619
+ previewButtons,
2620
+ stopBeforeEdit: true,
2621
+ skipRegressive: "existingOnly",
2622
+ context: "final"
2623
+ })) {
2624
+ params.finalizedPreviewByLane[laneName] = true;
2625
+ return "preview-finalized";
2626
+ }
2627
+ } else if (!hasMedia && !payload.isError && text.length > params.draftMaxChars) params.log(`telegram: preview final too long for edit (${text.length} > ${params.draftMaxChars}); falling back to standard send`);
2628
+ await params.stopDraftLane(lane);
2629
+ return await params.sendPayload(params.applyTextToPayload(payload, text)) ? "sent" : "skipped";
2630
+ }
2631
+ if (allowPreviewUpdateForNonFinal && canEditViaPreview) {
2632
+ if (await tryUpdatePreviewForLane({
2633
+ lane,
2634
+ laneName,
2635
+ text,
2636
+ previewButtons,
2637
+ stopBeforeEdit: false,
2638
+ updateLaneSnapshot: true,
2639
+ skipRegressive: "always",
2640
+ context: "update"
2641
+ })) return "preview-updated";
2642
+ }
2643
+ return await params.sendPayload(params.applyTextToPayload(payload, text)) ? "sent" : "skipped";
2644
+ };
2645
+ }
2646
+
2647
+ //#endregion
2648
+ //#region src/telegram/reasoning-lane-coordinator.ts
2649
+ const REASONING_MESSAGE_PREFIX = "Reasoning:\n";
2650
+ const REASONING_TAG_PREFIXES = [
2651
+ "<think",
2652
+ "<thinking",
2653
+ "<thought",
2654
+ "<antthinking",
2655
+ "</think",
2656
+ "</thinking",
2657
+ "</thought",
2658
+ "</antthinking"
2659
+ ];
2660
+ const THINKING_TAG_RE = /<\s*(\/?)\s*(?:think(?:ing)?|thought|antthinking)\b[^<>]*>/gi;
2661
+ function extractThinkingFromTaggedStreamOutsideCode(text) {
2662
+ if (!text) return "";
2663
+ const codeRegions = findCodeRegions(text);
2664
+ let result = "";
2665
+ let lastIndex = 0;
2666
+ let inThinking = false;
2667
+ THINKING_TAG_RE.lastIndex = 0;
2668
+ for (const match of text.matchAll(THINKING_TAG_RE)) {
2669
+ const idx = match.index ?? 0;
2670
+ if (isInsideCode(idx, codeRegions)) continue;
2671
+ if (inThinking) result += text.slice(lastIndex, idx);
2672
+ inThinking = !(match[1] === "/");
2673
+ lastIndex = idx + match[0].length;
2674
+ }
2675
+ if (inThinking) result += text.slice(lastIndex);
2676
+ return result.trim();
2677
+ }
2678
+ function isPartialReasoningTagPrefix(text) {
2679
+ const trimmed = text.trimStart().toLowerCase();
2680
+ if (!trimmed.startsWith("<")) return false;
2681
+ if (trimmed.includes(">")) return false;
2682
+ return REASONING_TAG_PREFIXES.some((prefix) => prefix.startsWith(trimmed));
2683
+ }
2684
+ function splitTelegramReasoningText(text) {
2685
+ if (typeof text !== "string") return {};
2686
+ const trimmed = text.trim();
2687
+ if (isPartialReasoningTagPrefix(trimmed)) return {};
2688
+ if (trimmed.startsWith(REASONING_MESSAGE_PREFIX) && trimmed.length > 11) return { reasoningText: trimmed };
2689
+ const taggedReasoning = extractThinkingFromTaggedStreamOutsideCode(text);
2690
+ const strippedAnswer = stripReasoningTagsFromText(text, {
2691
+ mode: "strict",
2692
+ trim: "both"
2693
+ });
2694
+ if (!taggedReasoning && strippedAnswer === text) return { answerText: text };
2695
+ return {
2696
+ reasoningText: taggedReasoning ? formatReasoningMessage(taggedReasoning) : void 0,
2697
+ answerText: strippedAnswer || void 0
2698
+ };
2699
+ }
2700
+ function createTelegramReasoningStepState() {
2701
+ let reasoningStatus = "none";
2702
+ let bufferedFinalAnswer;
2703
+ const noteReasoningHint = () => {
2704
+ if (reasoningStatus === "none") reasoningStatus = "hinted";
2705
+ };
2706
+ const noteReasoningDelivered = () => {
2707
+ reasoningStatus = "delivered";
2708
+ };
2709
+ const shouldBufferFinalAnswer = () => {
2710
+ return reasoningStatus === "hinted" && !bufferedFinalAnswer;
2711
+ };
2712
+ const bufferFinalAnswer = (value) => {
2713
+ bufferedFinalAnswer = value;
2714
+ };
2715
+ const takeBufferedFinalAnswer = () => {
2716
+ const value = bufferedFinalAnswer;
2717
+ bufferedFinalAnswer = void 0;
2718
+ return value;
2719
+ };
2720
+ const resetForNextStep = () => {
2721
+ reasoningStatus = "none";
2722
+ bufferedFinalAnswer = void 0;
2723
+ };
2724
+ return {
2725
+ noteReasoningHint,
2726
+ noteReasoningDelivered,
2727
+ shouldBufferFinalAnswer,
2728
+ bufferFinalAnswer,
2729
+ takeBufferedFinalAnswer,
2730
+ resetForNextStep
2731
+ };
2732
+ }
2733
+
2734
+ //#endregion
2735
+ //#region src/telegram/bot-message-dispatch.ts
2736
+ const EMPTY_RESPONSE_FALLBACK$1 = "No response generated. Please try again.";
2737
+ /** Minimum chars before sending first streaming message (improves push notification UX) */
2738
+ const DRAFT_MIN_INITIAL_CHARS = 30;
2739
+ const PROGRESS_DRAFT_LABEL = "Working";
2740
+ function formatTelegramProgressToolName(name) {
2741
+ const normalized = name?.trim();
2742
+ if (!normalized) return "Tool";
2743
+ return normalized.replace(/[_-]+/g, " ").split(/\s+/).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
2744
+ }
2745
+ function formatTelegramToolProgressDraft(payload) {
2746
+ return `${PROGRESS_DRAFT_LABEL}\n\`🛠️ ${formatTelegramProgressToolName(payload.name)}\``;
2747
+ }
2748
+ async function resolveStickerVisionSupport(cfg, agentId) {
2749
+ try {
2750
+ const catalog = await loadModelCatalog({ config: cfg });
2751
+ const defaultModel = resolveDefaultModelForAgent({
2752
+ cfg,
2753
+ agentId
2754
+ });
2755
+ const entry = findModelInCatalog(catalog, defaultModel.provider, defaultModel.model);
2756
+ if (!entry) return false;
2757
+ return modelSupportsVision(entry);
2758
+ } catch {
2759
+ return false;
2760
+ }
2761
+ }
2762
+ function pruneStickerMediaFromContext(ctxPayload, opts) {
2763
+ if (opts?.stickerMediaIncluded === false) return;
2764
+ const nextMediaPaths = Array.isArray(ctxPayload.MediaPaths) ? ctxPayload.MediaPaths.slice(1) : void 0;
2765
+ const nextMediaUrls = Array.isArray(ctxPayload.MediaUrls) ? ctxPayload.MediaUrls.slice(1) : void 0;
2766
+ const nextMediaTypes = Array.isArray(ctxPayload.MediaTypes) ? ctxPayload.MediaTypes.slice(1) : void 0;
2767
+ ctxPayload.MediaPaths = nextMediaPaths && nextMediaPaths.length > 0 ? nextMediaPaths : void 0;
2768
+ ctxPayload.MediaUrls = nextMediaUrls && nextMediaUrls.length > 0 ? nextMediaUrls : void 0;
2769
+ ctxPayload.MediaTypes = nextMediaTypes && nextMediaTypes.length > 0 ? nextMediaTypes : void 0;
2770
+ ctxPayload.MediaPath = ctxPayload.MediaPaths?.[0];
2771
+ ctxPayload.MediaUrl = ctxPayload.MediaUrls?.[0] ?? ctxPayload.MediaPath;
2772
+ ctxPayload.MediaType = ctxPayload.MediaTypes?.[0];
2773
+ }
2774
+ function resolveTelegramReasoningLevel(params) {
2775
+ const { cfg, sessionKey, agentId } = params;
2776
+ if (!sessionKey) return "off";
2777
+ try {
2778
+ const store = loadSessionStore(resolveStorePath(cfg.session?.store, { agentId }), { skipCache: true });
2779
+ const level = (store[sessionKey.toLowerCase()] ?? store[sessionKey])?.reasoningLevel;
2780
+ if (level === "on" || level === "stream") return level;
2781
+ } catch {}
2782
+ return "off";
2783
+ }
2784
+ const dispatchTelegramMessage = async ({ context, bot, cfg, runtime, replyToMode, streamMode, textLimit, telegramCfg, opts }) => {
2785
+ const { ctxPayload, msg, chatId, isGroup, threadSpec, historyKey, historyLimit, groupHistories, route, skillFilter, sendTyping, sendRecordVoice, ackReactionPromise, reactionApi, removeAckAfterReply, statusReactionController } = context;
2786
+ const draftMaxChars = Math.min(textLimit, 4096);
2787
+ const tableMode = resolveMarkdownTableMode({
2788
+ cfg,
2789
+ channel: "telegram",
2790
+ accountId: route.accountId
2791
+ });
2792
+ const renderDraftPreview = (text) => ({
2793
+ text: renderTelegramHtmlText(text, { tableMode }),
2794
+ parseMode: "HTML"
2795
+ });
2796
+ const accountBlockStreamingEnabled = typeof telegramCfg.blockStreaming === "boolean" ? telegramCfg.blockStreaming : cfg.agents?.defaults?.blockStreamingDefault === "on";
2797
+ const resolvedReasoningLevel = resolveTelegramReasoningLevel({
2798
+ cfg,
2799
+ sessionKey: ctxPayload.SessionKey,
2800
+ agentId: route.agentId
2801
+ });
2802
+ const forceBlockStreamingForReasoning = resolvedReasoningLevel === "on";
2803
+ const streamReasoningDraft = resolvedReasoningLevel === "stream";
2804
+ const previewStreamingEnabled = streamMode !== "off";
2805
+ const canStreamAnswerDraft = previewStreamingEnabled && !accountBlockStreamingEnabled && !forceBlockStreamingForReasoning;
2806
+ const canStreamReasoningDraft = canStreamAnswerDraft || streamReasoningDraft;
2807
+ const draftReplyToMessageId = replyToMode !== "off" && typeof msg.message_id === "number" ? msg.message_id : void 0;
2808
+ const draftMinInitialChars = DRAFT_MIN_INITIAL_CHARS;
2809
+ const mediaLocalRoots = getAgentScopedMediaLocalRoots(cfg, route.agentId);
2810
+ const archivedAnswerPreviews = [];
2811
+ const archivedReasoningPreviewIds = [];
2812
+ const createDraftLane = (laneName, enabled) => {
2813
+ return {
2814
+ stream: enabled ? createTelegramDraftStream({
2815
+ api: bot.api,
2816
+ chatId,
2817
+ maxChars: draftMaxChars,
2818
+ thread: threadSpec,
2819
+ replyToMessageId: draftReplyToMessageId,
2820
+ minInitialChars: draftMinInitialChars,
2821
+ renderText: renderDraftPreview,
2822
+ onSupersededPreview: laneName === "answer" || laneName === "reasoning" ? (preview) => {
2823
+ if (laneName === "reasoning") {
2824
+ if (!archivedReasoningPreviewIds.includes(preview.messageId)) archivedReasoningPreviewIds.push(preview.messageId);
2825
+ return;
2826
+ }
2827
+ archivedAnswerPreviews.push({
2828
+ messageId: preview.messageId,
2829
+ textSnapshot: preview.textSnapshot
2830
+ });
2831
+ } : void 0,
2832
+ log: logVerbose,
2833
+ warn: logVerbose
2834
+ }) : void 0,
2835
+ lastPartialText: "",
2836
+ hasStreamedMessage: false
2837
+ };
2838
+ };
2839
+ const lanes = {
2840
+ answer: createDraftLane("answer", canStreamAnswerDraft),
2841
+ reasoning: createDraftLane("reasoning", canStreamReasoningDraft)
2842
+ };
2843
+ const answerLane = lanes.answer;
2844
+ const reasoningLane = lanes.reasoning;
2845
+ const progressDraftsEnabled = telegramCfg.streaming === "progress" && Boolean(answerLane.stream);
2846
+ let splitReasoningOnNextStream = false;
2847
+ const reasoningStepState = createTelegramReasoningStepState();
2848
+ const splitTextIntoLaneSegments = (text) => {
2849
+ const split = splitTelegramReasoningText(text);
2850
+ const segments = [];
2851
+ const suppressReasoning = resolvedReasoningLevel === "off";
2852
+ if (split.reasoningText && !suppressReasoning) segments.push({
2853
+ lane: "reasoning",
2854
+ text: split.reasoningText
2855
+ });
2856
+ if (split.answerText) segments.push({
2857
+ lane: "answer",
2858
+ text: split.answerText
2859
+ });
2860
+ return {
2861
+ segments,
2862
+ suppressedReasoningOnly: Boolean(split.reasoningText) && suppressReasoning && !split.answerText
2863
+ };
2864
+ };
2865
+ const resetDraftLaneState = (lane) => {
2866
+ lane.lastPartialText = "";
2867
+ lane.hasStreamedMessage = false;
2868
+ };
2869
+ const updateDraftFromPartial = (lane, text) => {
2870
+ const laneStream = lane.stream;
2871
+ if (!laneStream || !text) return;
2872
+ if (text === lane.lastPartialText) return;
2873
+ lane.hasStreamedMessage = true;
2874
+ if (lane.lastPartialText && lane.lastPartialText.startsWith(text) && text.length < lane.lastPartialText.length) return;
2875
+ lane.lastPartialText = text;
2876
+ laneStream.update(text);
2877
+ };
2878
+ const pushToolProgressDraft = async (payload) => {
2879
+ if (!progressDraftsEnabled || !answerLane.stream) return;
2880
+ const text = formatTelegramToolProgressDraft(payload);
2881
+ answerLane.stream.update(text);
2882
+ answerLane.lastPartialText = text;
2883
+ answerLane.hasStreamedMessage = true;
2884
+ await answerLane.stream.flush();
2885
+ };
2886
+ const ingestDraftLaneSegments = (text) => {
2887
+ const split = splitTextIntoLaneSegments(text);
2888
+ for (const segment of split.segments) {
2889
+ if (segment.lane === "reasoning") {
2890
+ reasoningStepState.noteReasoningHint();
2891
+ reasoningStepState.noteReasoningDelivered();
2892
+ }
2893
+ updateDraftFromPartial(lanes[segment.lane], segment.text);
2894
+ }
2895
+ };
2896
+ const flushDraftLane = async (lane) => {
2897
+ if (!lane.stream) return;
2898
+ await lane.stream.flush();
2899
+ };
2900
+ const disableBlockStreaming = !previewStreamingEnabled ? true : forceBlockStreamingForReasoning ? false : typeof telegramCfg.blockStreaming === "boolean" ? !telegramCfg.blockStreaming : canStreamAnswerDraft ? true : void 0;
2901
+ const { onModelSelected, ...prefixOptions } = createReplyPrefixOptions({
2902
+ cfg,
2903
+ agentId: route.agentId,
2904
+ channel: "telegram",
2905
+ accountId: route.accountId
2906
+ });
2907
+ const chunkMode = resolveChunkMode(cfg, "telegram", route.accountId);
2908
+ const sticker = ctxPayload.Sticker;
2909
+ if (sticker?.fileId && sticker.fileUniqueId && ctxPayload.MediaPath) {
2910
+ const agentDir = resolveAgentDir(cfg, route.agentId);
2911
+ const stickerSupportsVision = await resolveStickerVisionSupport(cfg, route.agentId);
2912
+ let description = sticker.cachedDescription ?? null;
2913
+ if (!description) description = await describeStickerImage({
2914
+ imagePath: ctxPayload.MediaPath,
2915
+ cfg,
2916
+ agentDir,
2917
+ agentId: route.agentId
2918
+ });
2919
+ if (description) {
2920
+ const stickerContext = [sticker.emoji, sticker.setName ? `from "${sticker.setName}"` : null].filter(Boolean).join(" ");
2921
+ const formattedDesc = `[Sticker${stickerContext ? ` ${stickerContext}` : ""}] ${description}`;
2922
+ sticker.cachedDescription = description;
2923
+ if (!stickerSupportsVision) {
2924
+ ctxPayload.Body = formattedDesc;
2925
+ ctxPayload.BodyForAgent = formattedDesc;
2926
+ pruneStickerMediaFromContext(ctxPayload, { stickerMediaIncluded: ctxPayload.StickerMediaIncluded });
2927
+ }
2928
+ if (sticker.fileId) {
2929
+ cacheSticker({
2930
+ fileId: sticker.fileId,
2931
+ fileUniqueId: sticker.fileUniqueId,
2932
+ emoji: sticker.emoji,
2933
+ setName: sticker.setName,
2934
+ description,
2935
+ cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
2936
+ receivedFrom: ctxPayload.From
2937
+ });
2938
+ logVerbose(`telegram: cached sticker description for ${sticker.fileUniqueId}`);
2939
+ } else logVerbose(`telegram: skipped sticker cache (missing fileId)`);
2940
+ }
2941
+ }
2942
+ const replyQuoteText = ctxPayload.ReplyToIsQuote && ctxPayload.ReplyToBody ? ctxPayload.ReplyToBody.trim() || void 0 : void 0;
2943
+ const deliveryState = createLaneDeliveryStateTracker();
2944
+ const finalizedPreviewByLane = {
2945
+ answer: false,
2946
+ reasoning: false
2947
+ };
2948
+ const clearGroupHistory = () => {
2949
+ if (isGroup && historyKey) clearHistoryEntriesIfEnabled({
2950
+ historyMap: groupHistories,
2951
+ historyKey,
2952
+ limit: historyLimit
2953
+ });
2954
+ };
2955
+ const deliveryBaseOptions = {
2956
+ chatId: String(chatId),
2957
+ token: opts.token,
2958
+ runtime,
2959
+ bot,
2960
+ mediaLocalRoots,
2961
+ replyToMode,
2962
+ textLimit,
2963
+ thread: threadSpec,
2964
+ tableMode,
2965
+ chunkMode,
2966
+ linkPreview: telegramCfg.linkPreview,
2967
+ replyQuoteText
2968
+ };
2969
+ const applyTextToPayload = (payload, text) => {
2970
+ if (payload.text === text) return payload;
2971
+ return {
2972
+ ...payload,
2973
+ text
2974
+ };
2975
+ };
2976
+ const sendPayload = async (payload) => {
2977
+ const result = await deliverReplies({
2978
+ ...deliveryBaseOptions,
2979
+ replies: [payload],
2980
+ onVoiceRecording: sendRecordVoice
2981
+ });
2982
+ if (result.delivered) deliveryState.markDelivered();
2983
+ return result.delivered;
2984
+ };
2985
+ const deliverLaneText = createLaneTextDeliverer({
2986
+ lanes,
2987
+ archivedAnswerPreviews,
2988
+ finalizedPreviewByLane,
2989
+ draftMaxChars,
2990
+ applyTextToPayload,
2991
+ sendPayload,
2992
+ flushDraftLane,
2993
+ stopDraftLane: async (lane) => {
2994
+ await lane.stream?.stop();
2995
+ },
2996
+ editPreview: async ({ messageId, text, previewButtons }) => {
2997
+ await editMessageTelegram(chatId, messageId, text, {
2998
+ api: bot.api,
2999
+ cfg,
3000
+ accountId: route.accountId,
3001
+ linkPreview: telegramCfg.linkPreview,
3002
+ buttons: previewButtons
3003
+ });
3004
+ },
3005
+ deletePreviewMessage: async (messageId) => {
3006
+ await bot.api.deleteMessage(chatId, messageId);
3007
+ },
3008
+ log: logVerbose,
3009
+ markDelivered: () => {
3010
+ deliveryState.markDelivered();
3011
+ }
3012
+ });
3013
+ let queuedFinal = false;
3014
+ if (statusReactionController) statusReactionController.setThinking();
3015
+ const typingCallbacks = createTypingCallbacks({
3016
+ start: sendTyping,
3017
+ onStartError: (err) => {
3018
+ logTypingFailure({
3019
+ log: logVerbose,
3020
+ channel: "telegram",
3021
+ target: String(chatId),
3022
+ error: err
3023
+ });
3024
+ }
3025
+ });
3026
+ try {
3027
+ ({queuedFinal} = await dispatchReplyWithBufferedBlockDispatcher({
3028
+ ctx: ctxPayload,
3029
+ cfg,
3030
+ dispatcherOptions: {
3031
+ ...prefixOptions,
3032
+ typingCallbacks,
3033
+ deliver: async (payload, info) => {
3034
+ const previewButtons = (payload.channelData?.telegram)?.buttons;
3035
+ const split = splitTextIntoLaneSegments(payload.text);
3036
+ const segments = split.segments;
3037
+ const hasMedia = Boolean(payload.mediaUrl) || (payload.mediaUrls?.length ?? 0) > 0;
3038
+ const flushBufferedFinalAnswer = async () => {
3039
+ const buffered = reasoningStepState.takeBufferedFinalAnswer();
3040
+ if (!buffered) return;
3041
+ const bufferedButtons = (buffered.payload.channelData?.telegram)?.buttons;
3042
+ await deliverLaneText({
3043
+ laneName: "answer",
3044
+ text: buffered.text,
3045
+ payload: buffered.payload,
3046
+ infoKind: "final",
3047
+ previewButtons: bufferedButtons
3048
+ });
3049
+ reasoningStepState.resetForNextStep();
3050
+ };
3051
+ for (const segment of segments) {
3052
+ if (segment.lane === "answer" && info.kind === "final" && reasoningStepState.shouldBufferFinalAnswer()) {
3053
+ reasoningStepState.bufferFinalAnswer({
3054
+ payload,
3055
+ text: segment.text
3056
+ });
3057
+ continue;
3058
+ }
3059
+ if (segment.lane === "reasoning") reasoningStepState.noteReasoningHint();
3060
+ const result = await deliverLaneText({
3061
+ laneName: segment.lane,
3062
+ text: segment.text,
3063
+ payload,
3064
+ infoKind: info.kind,
3065
+ previewButtons,
3066
+ allowPreviewUpdateForNonFinal: segment.lane === "reasoning"
3067
+ });
3068
+ if (segment.lane === "reasoning") {
3069
+ if (result !== "skipped") {
3070
+ reasoningStepState.noteReasoningDelivered();
3071
+ await flushBufferedFinalAnswer();
3072
+ }
3073
+ continue;
3074
+ }
3075
+ if (info.kind === "final") {
3076
+ if (reasoningLane.hasStreamedMessage) finalizedPreviewByLane.reasoning = true;
3077
+ reasoningStepState.resetForNextStep();
3078
+ }
3079
+ }
3080
+ if (segments.length > 0) return;
3081
+ if (split.suppressedReasoningOnly) {
3082
+ if (hasMedia) await sendPayload(typeof payload.text === "string" ? {
3083
+ ...payload,
3084
+ text: ""
3085
+ } : payload);
3086
+ if (info.kind === "final") await flushBufferedFinalAnswer();
3087
+ return;
3088
+ }
3089
+ if (info.kind === "final") {
3090
+ await answerLane.stream?.stop();
3091
+ await reasoningLane.stream?.stop();
3092
+ reasoningStepState.resetForNextStep();
3093
+ }
3094
+ if (!(hasMedia || typeof payload.text !== "string" || payload.text.length > 0)) {
3095
+ if (info.kind === "final") await flushBufferedFinalAnswer();
3096
+ return;
3097
+ }
3098
+ await sendPayload(payload);
3099
+ if (info.kind === "final") await flushBufferedFinalAnswer();
3100
+ },
3101
+ onSkip: (_payload, info) => {
3102
+ if (info.reason !== "silent") deliveryState.markNonSilentSkip();
3103
+ },
3104
+ onError: (err, info) => {
3105
+ deliveryState.markNonSilentFailure();
3106
+ runtime.error?.(danger(`telegram ${info.kind} reply failed: ${String(err)}`));
3107
+ }
3108
+ },
3109
+ replyOptions: {
3110
+ skillFilter,
3111
+ disableBlockStreaming,
3112
+ allowProgressCallbacksWhenSourceDeliverySuppressed: progressDraftsEnabled ? true : void 0,
3113
+ onPartialReply: answerLane.stream || reasoningLane.stream ? (payload) => ingestDraftLaneSegments(payload.text) : void 0,
3114
+ onReasoningStream: reasoningLane.stream ? (payload) => {
3115
+ if (splitReasoningOnNextStream) {
3116
+ reasoningLane.stream?.forceNewMessage();
3117
+ resetDraftLaneState(reasoningLane);
3118
+ splitReasoningOnNextStream = false;
3119
+ }
3120
+ ingestDraftLaneSegments(payload.text);
3121
+ } : void 0,
3122
+ onAssistantMessageStart: answerLane.stream ? async () => {
3123
+ reasoningStepState.resetForNextStep();
3124
+ if (answerLane.hasStreamedMessage) {
3125
+ const previewMessageId = answerLane.stream?.messageId();
3126
+ if (typeof previewMessageId === "number" && !finalizedPreviewByLane.answer) archivedAnswerPreviews.push({
3127
+ messageId: previewMessageId,
3128
+ textSnapshot: answerLane.lastPartialText
3129
+ });
3130
+ answerLane.stream?.forceNewMessage();
3131
+ }
3132
+ resetDraftLaneState(answerLane);
3133
+ finalizedPreviewByLane.answer = false;
3134
+ } : void 0,
3135
+ onReasoningEnd: reasoningLane.stream ? () => {
3136
+ splitReasoningOnNextStream = reasoningLane.hasStreamedMessage;
3137
+ } : void 0,
3138
+ onToolStart: progressDraftsEnabled || statusReactionController ? async (payload) => {
3139
+ const progressPromise = pushToolProgressDraft(payload);
3140
+ if (statusReactionController) await statusReactionController.setTool(payload.name);
3141
+ await progressPromise;
3142
+ } : void 0,
3143
+ onModelSelected
3144
+ }
3145
+ }));
3146
+ } finally {
3147
+ const streamCleanupStates = /* @__PURE__ */ new Map();
3148
+ const lanesToCleanup = [{
3149
+ laneName: "answer",
3150
+ lane: answerLane
3151
+ }, {
3152
+ laneName: "reasoning",
3153
+ lane: reasoningLane
3154
+ }];
3155
+ for (const laneState of lanesToCleanup) {
3156
+ const stream = laneState.lane.stream;
3157
+ if (!stream) continue;
3158
+ const shouldClear = !finalizedPreviewByLane[laneState.laneName];
3159
+ const existing = streamCleanupStates.get(stream);
3160
+ if (!existing) {
3161
+ streamCleanupStates.set(stream, { shouldClear });
3162
+ continue;
3163
+ }
3164
+ existing.shouldClear = existing.shouldClear && shouldClear;
3165
+ }
3166
+ for (const [stream, cleanupState] of streamCleanupStates) {
3167
+ await stream.stop();
3168
+ if (cleanupState.shouldClear) await stream.clear();
3169
+ }
3170
+ for (const archivedPreview of archivedAnswerPreviews) try {
3171
+ await bot.api.deleteMessage(chatId, archivedPreview.messageId);
3172
+ } catch (err) {
3173
+ logVerbose(`telegram: archived answer preview cleanup failed (${archivedPreview.messageId}): ${String(err)}`);
3174
+ }
3175
+ for (const messageId of archivedReasoningPreviewIds) try {
3176
+ await bot.api.deleteMessage(chatId, messageId);
3177
+ } catch (err) {
3178
+ logVerbose(`telegram: archived reasoning preview cleanup failed (${messageId}): ${String(err)}`);
3179
+ }
3180
+ }
3181
+ let sentFallback = false;
3182
+ const deliverySummary = deliveryState.snapshot();
3183
+ if (!deliverySummary.delivered && (deliverySummary.skippedNonSilent > 0 || deliverySummary.failedNonSilent > 0)) sentFallback = (await deliverReplies({
3184
+ replies: [{ text: EMPTY_RESPONSE_FALLBACK$1 }],
3185
+ ...deliveryBaseOptions
3186
+ })).delivered;
3187
+ const hasFinalResponse = queuedFinal || sentFallback;
3188
+ if (statusReactionController && !hasFinalResponse) statusReactionController.setError().catch((err) => {
3189
+ logVerbose(`telegram: status reaction error finalize failed: ${String(err)}`);
3190
+ });
3191
+ if (!hasFinalResponse) {
3192
+ clearGroupHistory();
3193
+ return;
3194
+ }
3195
+ if (statusReactionController) statusReactionController.setDone().catch((err) => {
3196
+ logVerbose(`telegram: status reaction finalize failed: ${String(err)}`);
3197
+ });
3198
+ else removeAckReactionAfterReply({
3199
+ removeAfterReply: removeAckAfterReply,
3200
+ ackReactionPromise,
3201
+ ackReactionValue: ackReactionPromise ? "ack" : null,
3202
+ remove: () => reactionApi?.(chatId, msg.message_id ?? 0, []) ?? Promise.resolve(),
3203
+ onError: (err) => {
3204
+ if (!msg.message_id) return;
3205
+ logAckFailure({
3206
+ log: logVerbose,
3207
+ channel: "telegram",
3208
+ target: `${chatId}/${msg.message_id}`,
3209
+ error: err
3210
+ });
3211
+ }
3212
+ });
3213
+ clearGroupHistory();
3214
+ };
3215
+
3216
+ //#endregion
3217
+ //#region src/telegram/bot-message.ts
3218
+ const createTelegramMessageProcessor = (deps) => {
3219
+ const { bot, cfg, account, telegramCfg, historyLimit, groupHistories, dmPolicy, allowFrom, groupAllowFrom, ackReactionScope, logger, resolveGroupActivation, resolveGroupRequireMention, resolveTelegramGroupConfig, sendChatActionHandler, runtime, replyToMode, streamMode, textLimit, opts } = deps;
3220
+ return async (primaryCtx, allMedia, storeAllowFrom, options, replyMedia) => {
3221
+ const context = await buildTelegramMessageContext({
3222
+ primaryCtx,
3223
+ allMedia,
3224
+ replyMedia,
3225
+ storeAllowFrom,
3226
+ options,
3227
+ bot,
3228
+ cfg,
3229
+ account,
3230
+ historyLimit,
3231
+ groupHistories,
3232
+ dmPolicy,
3233
+ allowFrom,
3234
+ groupAllowFrom,
3235
+ ackReactionScope,
3236
+ logger,
3237
+ resolveGroupActivation,
3238
+ resolveGroupRequireMention,
3239
+ resolveTelegramGroupConfig,
3240
+ sendChatActionHandler
3241
+ });
3242
+ if (!context) return;
3243
+ await dispatchTelegramMessage({
3244
+ context,
3245
+ bot,
3246
+ cfg,
3247
+ runtime,
3248
+ replyToMode,
3249
+ streamMode,
3250
+ textLimit,
3251
+ telegramCfg,
3252
+ opts
3253
+ });
3254
+ };
3255
+ };
3256
+
3257
+ //#endregion
3258
+ //#region src/telegram/bot-native-command-menu.ts
3259
+ const TELEGRAM_MAX_COMMANDS = 100;
3260
+ const TELEGRAM_COMMAND_RETRY_RATIO = .8;
3261
+ function isBotCommandsTooMuchError(err) {
3262
+ if (!err) return false;
3263
+ const pattern = /\bBOT_COMMANDS_TOO_MUCH\b/i;
3264
+ if (typeof err === "string") return pattern.test(err);
3265
+ if (err instanceof Error) {
3266
+ if (pattern.test(err.message)) return true;
3267
+ }
3268
+ if (typeof err === "object") {
3269
+ const maybe = err;
3270
+ if (typeof maybe.description === "string" && pattern.test(maybe.description)) return true;
3271
+ if (typeof maybe.message === "string" && pattern.test(maybe.message)) return true;
3272
+ }
3273
+ return false;
3274
+ }
3275
+ function buildPluginTelegramMenuCommands(params) {
3276
+ const { specs, existingCommands } = params;
3277
+ const commands = [];
3278
+ const issues = [];
3279
+ const pluginCommandNames = /* @__PURE__ */ new Set();
3280
+ for (const spec of specs) {
3281
+ const normalized = normalizeTelegramCommandName(spec.name);
3282
+ if (!normalized || !TELEGRAM_COMMAND_NAME_PATTERN.test(normalized)) {
3283
+ issues.push(`Plugin command "/${spec.name}" is invalid for Telegram (use a-z, 0-9, underscore; max 32 chars).`);
3284
+ continue;
3285
+ }
3286
+ const description = spec.description.trim();
3287
+ if (!description) {
3288
+ issues.push(`Plugin command "/${normalized}" is missing a description.`);
3289
+ continue;
3290
+ }
3291
+ if (existingCommands.has(normalized)) {
3292
+ if (pluginCommandNames.has(normalized)) issues.push(`Plugin command "/${normalized}" is duplicated.`);
3293
+ else issues.push(`Plugin command "/${normalized}" conflicts with an existing Telegram command.`);
3294
+ continue;
3295
+ }
3296
+ pluginCommandNames.add(normalized);
3297
+ existingCommands.add(normalized);
3298
+ commands.push({
3299
+ command: normalized,
3300
+ description
3301
+ });
3302
+ }
3303
+ return {
3304
+ commands,
3305
+ issues
3306
+ };
3307
+ }
3308
+ function buildCappedTelegramMenuCommands(params) {
3309
+ const { allCommands } = params;
3310
+ const maxCommands = params.maxCommands ?? TELEGRAM_MAX_COMMANDS;
3311
+ const totalCommands = allCommands.length;
3312
+ const overflowCount = Math.max(0, totalCommands - maxCommands);
3313
+ return {
3314
+ commandsToRegister: allCommands.slice(0, maxCommands),
3315
+ totalCommands,
3316
+ maxCommands,
3317
+ overflowCount
3318
+ };
3319
+ }
3320
+ function syncTelegramMenuCommands(params) {
3321
+ const { bot, runtime, commandsToRegister } = params;
3322
+ const sync = async () => {
3323
+ if (typeof bot.api.deleteMyCommands === "function") await withTelegramApiErrorLogging({
3324
+ operation: "deleteMyCommands",
3325
+ runtime,
3326
+ fn: () => bot.api.deleteMyCommands()
3327
+ }).catch(() => {});
3328
+ if (commandsToRegister.length === 0) return;
3329
+ let retryCommands = commandsToRegister;
3330
+ while (retryCommands.length > 0) try {
3331
+ await withTelegramApiErrorLogging({
3332
+ operation: "setMyCommands",
3333
+ runtime,
3334
+ fn: () => bot.api.setMyCommands(retryCommands)
3335
+ });
3336
+ return;
3337
+ } catch (err) {
3338
+ if (!isBotCommandsTooMuchError(err)) throw err;
3339
+ const nextCount = Math.floor(retryCommands.length * TELEGRAM_COMMAND_RETRY_RATIO);
3340
+ const reducedCount = nextCount < retryCommands.length ? nextCount : retryCommands.length - 1;
3341
+ if (reducedCount <= 0) {
3342
+ runtime.error?.("Telegram rejected native command registration (BOT_COMMANDS_TOO_MUCH); leaving menu empty. Reduce commands or disable channels.telegram.commands.native.");
3343
+ return;
3344
+ }
3345
+ runtime.log?.(`Telegram rejected ${retryCommands.length} commands (BOT_COMMANDS_TOO_MUCH); retrying with ${reducedCount}.`);
3346
+ retryCommands = retryCommands.slice(0, reducedCount);
3347
+ }
3348
+ };
3349
+ sync().catch((err) => {
3350
+ runtime.error?.(`Telegram command sync failed: ${String(err)}`);
3351
+ });
3352
+ }
3353
+
3354
+ //#endregion
3355
+ //#region src/telegram/bot-native-commands.ts
3356
+ const EMPTY_RESPONSE_FALLBACK = "No response generated. Please try again.";
3357
+ async function resolveTelegramCommandAuth(params) {
3358
+ const { msg, bot, cfg, accountId, telegramCfg, allowFrom, groupAllowFrom, useAccessGroups, resolveGroupPolicy, resolveTelegramGroupConfig, requireAuth } = params;
3359
+ const chatId = msg.chat.id;
3360
+ const isGroup = msg.chat.type === "group" || msg.chat.type === "supergroup";
3361
+ const messageThreadId = msg.message_thread_id;
3362
+ const isForum = msg.chat.is_forum === true;
3363
+ const { resolvedThreadId, storeAllowFrom, groupConfig, topicConfig, effectiveGroupAllow, hasGroupAllowOverride } = await resolveTelegramGroupAllowFromContext({
3364
+ chatId,
3365
+ accountId,
3366
+ isForum,
3367
+ messageThreadId,
3368
+ groupAllowFrom,
3369
+ resolveTelegramGroupConfig
3370
+ });
3371
+ const senderId = msg.from?.id ? String(msg.from.id) : "";
3372
+ const senderUsername = msg.from?.username ?? "";
3373
+ const sendAuthMessage = async (text) => {
3374
+ await withTelegramApiErrorLogging({
3375
+ operation: "sendMessage",
3376
+ fn: () => bot.api.sendMessage(chatId, text)
3377
+ });
3378
+ return null;
3379
+ };
3380
+ const rejectNotAuthorized = async () => {
3381
+ return await sendAuthMessage("You are not authorized to use this command.");
3382
+ };
3383
+ const baseAccess = evaluateTelegramGroupBaseAccess({
3384
+ isGroup,
3385
+ groupConfig,
3386
+ topicConfig,
3387
+ hasGroupAllowOverride,
3388
+ effectiveGroupAllow,
3389
+ senderId,
3390
+ senderUsername,
3391
+ enforceAllowOverride: requireAuth,
3392
+ requireSenderForAllowOverride: true
3393
+ });
3394
+ if (!baseAccess.allowed) {
3395
+ if (baseAccess.reason === "group-disabled") return await sendAuthMessage("This group is disabled.");
3396
+ if (baseAccess.reason === "topic-disabled") return await sendAuthMessage("This topic is disabled.");
3397
+ return await rejectNotAuthorized();
3398
+ }
3399
+ const policyAccess = evaluateTelegramGroupPolicyAccess({
3400
+ isGroup,
3401
+ chatId,
3402
+ cfg,
3403
+ telegramCfg,
3404
+ topicConfig,
3405
+ groupConfig,
3406
+ effectiveGroupAllow,
3407
+ senderId,
3408
+ senderUsername,
3409
+ resolveGroupPolicy,
3410
+ enforcePolicy: useAccessGroups,
3411
+ useTopicAndGroupOverrides: false,
3412
+ enforceAllowlistAuthorization: requireAuth,
3413
+ allowEmptyAllowlistEntries: true,
3414
+ requireSenderForAllowlistAuthorization: true,
3415
+ checkChatAllowlist: useAccessGroups
3416
+ });
3417
+ if (!policyAccess.allowed) {
3418
+ if (policyAccess.reason === "group-policy-disabled") return await sendAuthMessage("Telegram group commands are disabled.");
3419
+ if (policyAccess.reason === "group-policy-allowlist-no-sender" || policyAccess.reason === "group-policy-allowlist-unauthorized") return await rejectNotAuthorized();
3420
+ if (policyAccess.reason === "group-chat-not-allowed") return await sendAuthMessage("This group is not allowed.");
3421
+ }
3422
+ const dmAllow = normalizeDmAllowFromWithStore({
3423
+ allowFrom,
3424
+ storeAllowFrom: isGroup ? [] : storeAllowFrom,
3425
+ dmPolicy: telegramCfg.dmPolicy ?? "pairing"
3426
+ });
3427
+ const senderAllowed = isSenderAllowed({
3428
+ allow: dmAllow,
3429
+ senderId,
3430
+ senderUsername
3431
+ });
3432
+ const commandAuthorized = resolveCommandAuthorizedFromAuthorizers({
3433
+ useAccessGroups,
3434
+ authorizers: [{
3435
+ configured: dmAllow.hasEntries,
3436
+ allowed: senderAllowed
3437
+ }],
3438
+ modeWhenAccessGroupsOff: "configured"
3439
+ });
3440
+ if (requireAuth && !commandAuthorized) return await rejectNotAuthorized();
3441
+ return {
3442
+ chatId,
3443
+ isGroup,
3444
+ isForum,
3445
+ resolvedThreadId,
3446
+ senderId,
3447
+ senderUsername,
3448
+ groupConfig,
3449
+ topicConfig,
3450
+ commandAuthorized
3451
+ };
3452
+ }
3453
+ const registerTelegramNativeCommands = ({ bot, cfg, runtime, accountId, telegramCfg, allowFrom, groupAllowFrom, replyToMode, textLimit, useAccessGroups, nativeEnabled, nativeSkillsEnabled, nativeDisabledExplicit, resolveGroupPolicy, resolveTelegramGroupConfig, shouldSkipUpdate, opts }) => {
3454
+ const boundRoute = nativeEnabled && nativeSkillsEnabled ? resolveAgentRoute({
3455
+ cfg,
3456
+ channel: "telegram",
3457
+ accountId
3458
+ }) : null;
3459
+ const boundAgentIds = boundRoute ? [boundRoute.agentId] : null;
3460
+ const skillCommands = nativeEnabled && nativeSkillsEnabled ? listSkillCommandsForAgents(boundAgentIds ? {
3461
+ cfg,
3462
+ agentIds: boundAgentIds
3463
+ } : { cfg }) : [];
3464
+ const nativeCommands = nativeEnabled ? listNativeCommandSpecsForConfig(cfg, {
3465
+ skillCommands,
3466
+ provider: "telegram"
3467
+ }) : [];
3468
+ const reservedCommands = new Set(listNativeCommandSpecs().map((command) => normalizeTelegramCommandName(command.name)));
3469
+ for (const command of skillCommands) reservedCommands.add(command.name.toLowerCase());
3470
+ const customResolution = resolveTelegramCustomCommands({
3471
+ commands: telegramCfg.customCommands,
3472
+ reservedCommands
3473
+ });
3474
+ for (const issue of customResolution.issues) runtime.error?.(danger(issue.message));
3475
+ const customCommands = customResolution.commands;
3476
+ const pluginCatalog = buildPluginTelegramMenuCommands({
3477
+ specs: getPluginCommandSpecs(),
3478
+ existingCommands: new Set([...nativeCommands.map((command) => normalizeTelegramCommandName(command.name)), ...customCommands.map((command) => command.command)].map((command) => command.toLowerCase()))
3479
+ });
3480
+ for (const issue of pluginCatalog.issues) runtime.error?.(danger(issue));
3481
+ const { commandsToRegister, totalCommands, maxCommands, overflowCount } = buildCappedTelegramMenuCommands({ allCommands: [
3482
+ ...nativeCommands.map((command) => {
3483
+ const normalized = normalizeTelegramCommandName(command.name);
3484
+ if (!TELEGRAM_COMMAND_NAME_PATTERN.test(normalized)) {
3485
+ runtime.error?.(danger(`Native command "${command.name}" is invalid for Telegram (resolved to "${normalized}"). Skipping.`));
3486
+ return null;
3487
+ }
3488
+ return {
3489
+ command: normalized,
3490
+ description: command.description
3491
+ };
3492
+ }).filter((cmd) => cmd !== null),
3493
+ ...nativeEnabled ? pluginCatalog.commands : [],
3494
+ ...customCommands
3495
+ ] });
3496
+ if (overflowCount > 0) runtime.log?.(`Telegram limits bots to ${maxCommands} commands. ${totalCommands} configured; registering first ${maxCommands}. Use channels.telegram.commands.native: false to disable, or reduce plugin/skill/custom commands.`);
3497
+ syncTelegramMenuCommands({
3498
+ bot,
3499
+ runtime,
3500
+ commandsToRegister
3501
+ });
3502
+ const resolveCommandRuntimeContext = (params) => {
3503
+ const { msg, isGroup, isForum, resolvedThreadId } = params;
3504
+ const chatId = msg.chat.id;
3505
+ const messageThreadId = msg.message_thread_id;
3506
+ const threadSpec = resolveTelegramThreadSpec({
3507
+ isGroup,
3508
+ isForum,
3509
+ messageThreadId
3510
+ });
3511
+ const parentPeer = buildTelegramParentPeer({
3512
+ isGroup,
3513
+ resolvedThreadId,
3514
+ chatId
3515
+ });
3516
+ const route = resolveAgentRoute({
3517
+ cfg,
3518
+ channel: "telegram",
3519
+ accountId,
3520
+ peer: {
3521
+ kind: isGroup ? "group" : "direct",
3522
+ id: isGroup ? buildTelegramGroupPeerId(chatId, resolvedThreadId) : String(chatId)
3523
+ },
3524
+ parentPeer
3525
+ });
3526
+ return {
3527
+ chatId,
3528
+ threadSpec,
3529
+ route,
3530
+ mediaLocalRoots: getAgentScopedMediaLocalRoots(cfg, route.agentId),
3531
+ tableMode: resolveMarkdownTableMode({
3532
+ cfg,
3533
+ channel: "telegram",
3534
+ accountId: route.accountId
3535
+ }),
3536
+ chunkMode: resolveChunkMode(cfg, "telegram", route.accountId)
3537
+ };
3538
+ };
3539
+ const buildCommandDeliveryBaseOptions = (params) => ({
3540
+ chatId: String(params.chatId),
3541
+ token: opts.token,
3542
+ runtime,
3543
+ bot,
3544
+ mediaLocalRoots: params.mediaLocalRoots,
3545
+ replyToMode,
3546
+ textLimit,
3547
+ thread: params.threadSpec,
3548
+ tableMode: params.tableMode,
3549
+ chunkMode: params.chunkMode,
3550
+ linkPreview: telegramCfg.linkPreview
3551
+ });
3552
+ if (commandsToRegister.length > 0 || pluginCatalog.commands.length > 0) if (typeof bot.command !== "function") logVerbose("telegram: bot.command unavailable; skipping native handlers");
3553
+ else {
3554
+ for (const command of nativeCommands) {
3555
+ const normalizedCommandName = normalizeTelegramCommandName(command.name);
3556
+ bot.command(normalizedCommandName, async (ctx) => {
3557
+ const msg = ctx.message;
3558
+ if (!msg) return;
3559
+ if (shouldSkipUpdate(ctx)) return;
3560
+ const auth = await resolveTelegramCommandAuth({
3561
+ msg,
3562
+ bot,
3563
+ cfg,
3564
+ accountId,
3565
+ telegramCfg,
3566
+ allowFrom,
3567
+ groupAllowFrom,
3568
+ useAccessGroups,
3569
+ resolveGroupPolicy,
3570
+ resolveTelegramGroupConfig,
3571
+ requireAuth: true
3572
+ });
3573
+ if (!auth) return;
3574
+ const { chatId, isGroup, isForum, resolvedThreadId, senderId, senderUsername, groupConfig, topicConfig, commandAuthorized } = auth;
3575
+ const { threadSpec, route, mediaLocalRoots, tableMode, chunkMode } = resolveCommandRuntimeContext({
3576
+ msg,
3577
+ isGroup,
3578
+ isForum,
3579
+ resolvedThreadId
3580
+ });
3581
+ const deliveryBaseOptions = buildCommandDeliveryBaseOptions({
3582
+ chatId,
3583
+ mediaLocalRoots,
3584
+ threadSpec,
3585
+ tableMode,
3586
+ chunkMode
3587
+ });
3588
+ const threadParams = buildTelegramThreadParams(threadSpec) ?? {};
3589
+ const commandDefinition = findCommandByNativeName(command.name, "telegram");
3590
+ const rawText = ctx.match?.trim() ?? "";
3591
+ const commandArgs = commandDefinition ? parseCommandArgs(commandDefinition, rawText) : rawText ? { raw: rawText } : void 0;
3592
+ const prompt = commandDefinition ? buildCommandTextFromArgs(commandDefinition, commandArgs) : rawText ? `/${command.name} ${rawText}` : `/${command.name}`;
3593
+ const menu = commandDefinition ? resolveCommandArgMenu({
3594
+ command: commandDefinition,
3595
+ args: commandArgs,
3596
+ cfg
3597
+ }) : null;
3598
+ if (menu && commandDefinition) {
3599
+ const title = menu.title ?? `Choose ${menu.arg.description || menu.arg.name} for /${commandDefinition.nativeName ?? commandDefinition.key}.`;
3600
+ const rows = [];
3601
+ for (let i = 0; i < menu.choices.length; i += 2) {
3602
+ const slice = menu.choices.slice(i, i + 2);
3603
+ rows.push(slice.map((choice) => {
3604
+ const args = { values: { [menu.arg.name]: choice.value } };
3605
+ return {
3606
+ text: choice.label,
3607
+ callback_data: buildCommandTextFromArgs(commandDefinition, args)
3608
+ };
3609
+ }));
3610
+ }
3611
+ const replyMarkup = buildInlineKeyboard(rows);
3612
+ await withTelegramApiErrorLogging({
3613
+ operation: "sendMessage",
3614
+ runtime,
3615
+ fn: () => bot.api.sendMessage(chatId, title, {
3616
+ ...replyMarkup ? { reply_markup: replyMarkup } : {},
3617
+ ...threadParams
3618
+ })
3619
+ });
3620
+ return;
3621
+ }
3622
+ const baseSessionKey = route.sessionKey;
3623
+ const dmThreadId = threadSpec.scope === "dm" ? threadSpec.id : void 0;
3624
+ const sessionKey = (dmThreadId != null ? resolveThreadSessionKeys({
3625
+ baseSessionKey,
3626
+ threadId: String(dmThreadId)
3627
+ }) : null)?.sessionKey ?? baseSessionKey;
3628
+ const { skillFilter, groupSystemPrompt } = resolveTelegramGroupPromptSettings({
3629
+ groupConfig,
3630
+ topicConfig
3631
+ });
3632
+ const conversationLabel = isGroup ? msg.chat.title ? `${msg.chat.title} id:${chatId}` : `group:${chatId}` : buildSenderName(msg) ?? String(senderId || chatId);
3633
+ const ctxPayload = finalizeInboundContext({
3634
+ Body: prompt,
3635
+ BodyForAgent: prompt,
3636
+ RawBody: prompt,
3637
+ CommandBody: prompt,
3638
+ CommandArgs: commandArgs,
3639
+ From: isGroup ? buildTelegramGroupFrom(chatId, resolvedThreadId) : `telegram:${chatId}`,
3640
+ To: `slash:${senderId || chatId}`,
3641
+ ChatType: isGroup ? "group" : "direct",
3642
+ ConversationLabel: conversationLabel,
3643
+ GroupSubject: isGroup ? msg.chat.title ?? void 0 : void 0,
3644
+ GroupSystemPrompt: isGroup ? groupSystemPrompt : void 0,
3645
+ SenderName: buildSenderName(msg),
3646
+ SenderId: senderId || void 0,
3647
+ SenderUsername: senderUsername || void 0,
3648
+ Surface: "telegram",
3649
+ Provider: "telegram",
3650
+ MessageSid: String(msg.message_id),
3651
+ Timestamp: msg.date ? msg.date * 1e3 : void 0,
3652
+ WasMentioned: true,
3653
+ CommandAuthorized: commandAuthorized,
3654
+ CommandSource: "native",
3655
+ SessionKey: `telegram:slash:${senderId || chatId}`,
3656
+ AccountId: route.accountId,
3657
+ CommandTargetSessionKey: sessionKey,
3658
+ MessageThreadId: threadSpec.id,
3659
+ IsForum: isForum,
3660
+ OriginatingChannel: "telegram",
3661
+ OriginatingTo: `telegram:${chatId}`
3662
+ });
3663
+ const storePath = resolveStorePath(cfg.session?.store, { agentId: route.agentId });
3664
+ try {
3665
+ await recordSessionMetaFromInbound({
3666
+ storePath,
3667
+ sessionKey: ctxPayload.SessionKey ?? route.sessionKey,
3668
+ ctx: ctxPayload
3669
+ });
3670
+ } catch (err) {
3671
+ runtime.error?.(danger(`telegram slash: failed updating session meta: ${String(err)}`));
3672
+ }
3673
+ const disableBlockStreaming = typeof telegramCfg.blockStreaming === "boolean" ? !telegramCfg.blockStreaming : void 0;
3674
+ const deliveryState = {
3675
+ delivered: false,
3676
+ skippedNonSilent: 0
3677
+ };
3678
+ const { onModelSelected, ...prefixOptions } = createReplyPrefixOptions({
3679
+ cfg,
3680
+ agentId: route.agentId,
3681
+ channel: "telegram",
3682
+ accountId: route.accountId
3683
+ });
3684
+ await dispatchReplyWithBufferedBlockDispatcher({
3685
+ ctx: ctxPayload,
3686
+ cfg,
3687
+ dispatcherOptions: {
3688
+ ...prefixOptions,
3689
+ deliver: async (payload, _info) => {
3690
+ if ((await deliverReplies({
3691
+ replies: [payload],
3692
+ ...deliveryBaseOptions
3693
+ })).delivered) deliveryState.delivered = true;
3694
+ },
3695
+ onSkip: (_payload, info) => {
3696
+ if (info.reason !== "silent") deliveryState.skippedNonSilent += 1;
3697
+ },
3698
+ onError: (err, info) => {
3699
+ runtime.error?.(danger(`telegram slash ${info.kind} reply failed: ${String(err)}`));
3700
+ }
3701
+ },
3702
+ replyOptions: {
3703
+ skillFilter,
3704
+ disableBlockStreaming,
3705
+ onModelSelected
3706
+ }
3707
+ });
3708
+ if (!deliveryState.delivered && deliveryState.skippedNonSilent > 0) await deliverReplies({
3709
+ replies: [{ text: EMPTY_RESPONSE_FALLBACK }],
3710
+ ...deliveryBaseOptions
3711
+ });
3712
+ });
3713
+ }
3714
+ for (const pluginCommand of pluginCatalog.commands) bot.command(pluginCommand.command, async (ctx) => {
3715
+ const msg = ctx.message;
3716
+ if (!msg) return;
3717
+ if (shouldSkipUpdate(ctx)) return;
3718
+ const chatId = msg.chat.id;
3719
+ const rawText = ctx.match?.trim() ?? "";
3720
+ const commandBody = `/${pluginCommand.command}${rawText ? ` ${rawText}` : ""}`;
3721
+ const match = matchPluginCommand(commandBody);
3722
+ if (!match) {
3723
+ await withTelegramApiErrorLogging({
3724
+ operation: "sendMessage",
3725
+ runtime,
3726
+ fn: () => bot.api.sendMessage(chatId, "Command not found.")
3727
+ });
3728
+ return;
3729
+ }
3730
+ const auth = await resolveTelegramCommandAuth({
3731
+ msg,
3732
+ bot,
3733
+ cfg,
3734
+ accountId,
3735
+ telegramCfg,
3736
+ allowFrom,
3737
+ groupAllowFrom,
3738
+ useAccessGroups,
3739
+ resolveGroupPolicy,
3740
+ resolveTelegramGroupConfig,
3741
+ requireAuth: match.command.requireAuth !== false
3742
+ });
3743
+ if (!auth) return;
3744
+ const { senderId, commandAuthorized, isGroup, isForum, resolvedThreadId } = auth;
3745
+ const { threadSpec, mediaLocalRoots, tableMode, chunkMode } = resolveCommandRuntimeContext({
3746
+ msg,
3747
+ isGroup,
3748
+ isForum,
3749
+ resolvedThreadId
3750
+ });
3751
+ const deliveryBaseOptions = buildCommandDeliveryBaseOptions({
3752
+ chatId,
3753
+ mediaLocalRoots,
3754
+ threadSpec,
3755
+ tableMode,
3756
+ chunkMode
3757
+ });
3758
+ const from = isGroup ? buildTelegramGroupFrom(chatId, threadSpec.id) : `telegram:${chatId}`;
3759
+ const to = `telegram:${chatId}`;
3760
+ await deliverReplies({
3761
+ replies: [await executePluginCommand({
3762
+ command: match.command,
3763
+ args: match.args,
3764
+ senderId,
3765
+ channel: "telegram",
3766
+ isAuthorizedSender: commandAuthorized,
3767
+ commandBody,
3768
+ config: cfg,
3769
+ from,
3770
+ to,
3771
+ accountId,
3772
+ messageThreadId: threadSpec.id
3773
+ })],
3774
+ ...deliveryBaseOptions
3775
+ });
3776
+ });
3777
+ }
3778
+ else if (nativeDisabledExplicit) withTelegramApiErrorLogging({
3779
+ operation: "setMyCommands",
3780
+ runtime,
3781
+ fn: () => bot.api.setMyCommands([])
3782
+ }).catch(() => {});
3783
+ };
3784
+
3785
+ //#endregion
3786
+ //#region src/telegram/sendchataction-401-backoff.ts
3787
+ const BACKOFF_POLICY = {
3788
+ initialMs: 1e3,
3789
+ maxMs: 3e5,
3790
+ factor: 2,
3791
+ jitter: .1
3792
+ };
3793
+ function is401Error(error) {
3794
+ if (!error) return false;
3795
+ const message = error instanceof Error ? error.message : JSON.stringify(error);
3796
+ return message.includes("401") || message.toLowerCase().includes("unauthorized");
3797
+ }
3798
+ /**
3799
+ * Creates a GLOBAL (per-account) handler for sendChatAction that tracks 401 errors
3800
+ * across all message contexts. This prevents the infinite loop that caused Telegram
3801
+ * to delete bots (issue #27092).
3802
+ *
3803
+ * When a 401 occurs, exponential backoff is applied (1s → 2s → 4s → ... → 5min).
3804
+ * After maxConsecutive401 failures (default 10), all sendChatAction calls are
3805
+ * suspended until reset() is called.
3806
+ */
3807
+ function createTelegramSendChatActionHandler({ sendChatActionFn, logger, maxConsecutive401 = 10 }) {
3808
+ let consecutive401Failures = 0;
3809
+ let suspended = false;
3810
+ const reset = () => {
3811
+ consecutive401Failures = 0;
3812
+ suspended = false;
3813
+ };
3814
+ const sendChatAction = async (chatId, action, threadParams) => {
3815
+ if (suspended) return;
3816
+ if (consecutive401Failures > 0) {
3817
+ const backoffMs = computeBackoff(BACKOFF_POLICY, consecutive401Failures);
3818
+ logger(`sendChatAction backoff: waiting ${backoffMs}ms before retry (failure ${consecutive401Failures}/${maxConsecutive401})`);
3819
+ await sleepWithAbort(backoffMs);
3820
+ }
3821
+ try {
3822
+ await sendChatActionFn(chatId, action, threadParams);
3823
+ if (consecutive401Failures > 0) {
3824
+ logger(`sendChatAction recovered after ${consecutive401Failures} consecutive 401 failures`);
3825
+ consecutive401Failures = 0;
3826
+ }
3827
+ } catch (error) {
3828
+ if (is401Error(error)) {
3829
+ consecutive401Failures++;
3830
+ if (consecutive401Failures >= maxConsecutive401) {
3831
+ suspended = true;
3832
+ logger(`CRITICAL: sendChatAction suspended after ${consecutive401Failures} consecutive 401 errors. Bot token is likely invalid. Telegram may DELETE the bot if requests continue. Replace the token and restart: fased channels restart telegram`);
3833
+ } else logger(`sendChatAction 401 error (${consecutive401Failures}/${maxConsecutive401}). Retrying with exponential backoff.`);
3834
+ }
3835
+ throw error;
3836
+ }
3837
+ };
3838
+ return {
3839
+ sendChatAction,
3840
+ isSuspended: () => suspended,
3841
+ reset
3842
+ };
3843
+ }
3844
+
3845
+ //#endregion
3846
+ //#region src/telegram/bot.ts
3847
+ const TELEGRAM_CONTROL_COMMANDS = new Set(["/status"]);
3848
+ function isTelegramControlRequestText(rawText, options) {
3849
+ if (!rawText) return false;
3850
+ if (isAbortRequestText(rawText, options)) return true;
3851
+ const normalized = normalizeCommandBody(rawText, options).trim().toLowerCase();
3852
+ return TELEGRAM_CONTROL_COMMANDS.has(normalized);
3853
+ }
3854
+ function getTelegramSequentialKey(ctx) {
3855
+ const reaction = ctx.update?.message_reaction;
3856
+ if (reaction?.chat?.id) return `telegram:${reaction.chat.id}`;
3857
+ const msg = ctx.message ?? ctx.channelPost ?? ctx.editedChannelPost ?? ctx.update?.message ?? ctx.update?.edited_message ?? ctx.update?.channel_post ?? ctx.update?.edited_channel_post ?? ctx.update?.callback_query?.message;
3858
+ const chatId = msg?.chat?.id ?? ctx.chat?.id;
3859
+ const rawText = msg?.text ?? msg?.caption;
3860
+ const botUsername = ctx.me?.username;
3861
+ if (isTelegramControlRequestText(rawText, botUsername ? { botUsername } : void 0)) {
3862
+ if (typeof chatId === "number") return `telegram:${chatId}:control`;
3863
+ return "telegram:control";
3864
+ }
3865
+ const isGroup = msg?.chat?.type === "group" || msg?.chat?.type === "supergroup";
3866
+ const messageThreadId = msg?.message_thread_id;
3867
+ const isForum = msg?.chat?.is_forum;
3868
+ const threadId = isGroup ? resolveTelegramForumThreadId({
3869
+ isForum,
3870
+ messageThreadId
3871
+ }) : messageThreadId;
3872
+ if (typeof chatId === "number") return threadId != null ? `telegram:${chatId}:topic:${threadId}` : `telegram:${chatId}`;
3873
+ return "telegram:unknown";
3874
+ }
3875
+ function createTelegramBot(opts) {
3876
+ const runtime = opts.runtime ?? createNonExitingRuntime();
3877
+ const cfg = opts.config ?? loadConfig();
3878
+ const account = resolveTelegramAccount({
3879
+ cfg,
3880
+ accountId: opts.accountId
3881
+ });
3882
+ const telegramCfg = account.config;
3883
+ const fetchImpl = resolveTelegramFetch(opts.proxyFetch, { network: telegramCfg.network });
3884
+ const shouldProvideFetch = Boolean(fetchImpl);
3885
+ const fetchForClient = fetchImpl;
3886
+ const timeoutSeconds = typeof telegramCfg?.timeoutSeconds === "number" && Number.isFinite(telegramCfg.timeoutSeconds) ? Math.max(1, Math.floor(telegramCfg.timeoutSeconds)) : void 0;
3887
+ const client = shouldProvideFetch || timeoutSeconds ? {
3888
+ ...shouldProvideFetch && fetchImpl ? { fetch: fetchForClient } : {},
3889
+ ...timeoutSeconds ? { timeoutSeconds } : {}
3890
+ } : void 0;
3891
+ const bot = new Bot(opts.token, client ? { client } : void 0);
3892
+ bot.api.config.use(apiThrottler());
3893
+ bot.catch((err) => {
3894
+ runtime.error?.(danger(`telegram bot error: ${formatUncaughtError(err)}`));
3895
+ });
3896
+ const recentUpdates = createTelegramUpdateDedupe();
3897
+ const initialUpdateId = typeof opts.updateOffset?.lastUpdateId === "number" ? opts.updateOffset.lastUpdateId : null;
3898
+ const pendingUpdateIds = /* @__PURE__ */ new Set();
3899
+ let highestCompletedUpdateId = initialUpdateId;
3900
+ let highestPersistedUpdateId = initialUpdateId;
3901
+ const maybePersistSafeWatermark = () => {
3902
+ if (typeof opts.updateOffset?.onUpdateId !== "function") return;
3903
+ if (highestCompletedUpdateId === null) return;
3904
+ let safe = highestCompletedUpdateId;
3905
+ if (pendingUpdateIds.size > 0) {
3906
+ let minPending = null;
3907
+ for (const id of pendingUpdateIds) if (minPending === null || id < minPending) minPending = id;
3908
+ if (minPending !== null) safe = Math.min(safe, minPending - 1);
3909
+ }
3910
+ if (highestPersistedUpdateId !== null && safe <= highestPersistedUpdateId) return;
3911
+ highestPersistedUpdateId = safe;
3912
+ opts.updateOffset.onUpdateId(safe);
3913
+ };
3914
+ const shouldSkipUpdate = (ctx) => {
3915
+ const updateId = resolveTelegramUpdateId(ctx);
3916
+ const skipCutoff = highestPersistedUpdateId ?? initialUpdateId;
3917
+ if (typeof updateId === "number" && skipCutoff !== null && updateId <= skipCutoff) return true;
3918
+ const key = buildTelegramUpdateKey(ctx);
3919
+ const skipped = recentUpdates.check(key);
3920
+ if (skipped && key && shouldLogVerbose()) logVerbose(`telegram dedupe: skipped ${key}`);
3921
+ return skipped;
3922
+ };
3923
+ bot.use(async (ctx, next) => {
3924
+ const updateId = resolveTelegramUpdateId(ctx);
3925
+ if (typeof updateId === "number") pendingUpdateIds.add(updateId);
3926
+ try {
3927
+ await next();
3928
+ } finally {
3929
+ if (typeof updateId === "number") {
3930
+ pendingUpdateIds.delete(updateId);
3931
+ if (highestCompletedUpdateId === null || updateId > highestCompletedUpdateId) highestCompletedUpdateId = updateId;
3932
+ maybePersistSafeWatermark();
3933
+ }
3934
+ }
3935
+ });
3936
+ bot.use(sequentialize(getTelegramSequentialKey));
3937
+ const rawUpdateLogger = createSubsystemLogger("gateway/channels/telegram/raw-update");
3938
+ const MAX_RAW_UPDATE_CHARS = 8e3;
3939
+ const MAX_RAW_UPDATE_STRING = 500;
3940
+ const MAX_RAW_UPDATE_ARRAY = 20;
3941
+ const stringifyUpdate = (update) => {
3942
+ const seen = /* @__PURE__ */ new WeakSet();
3943
+ return JSON.stringify(update ?? null, (key, value) => {
3944
+ if (typeof value === "string" && value.length > MAX_RAW_UPDATE_STRING) return `${value.slice(0, MAX_RAW_UPDATE_STRING)}...`;
3945
+ if (Array.isArray(value) && value.length > MAX_RAW_UPDATE_ARRAY) return [...value.slice(0, MAX_RAW_UPDATE_ARRAY), `...(${value.length - MAX_RAW_UPDATE_ARRAY} more)`];
3946
+ if (value && typeof value === "object") {
3947
+ if (seen.has(value)) return "[Circular]";
3948
+ seen.add(value);
3949
+ }
3950
+ return value;
3951
+ });
3952
+ };
3953
+ bot.use(async (ctx, next) => {
3954
+ if (shouldLogVerbose()) try {
3955
+ const raw = stringifyUpdate(ctx.update);
3956
+ const preview = raw.length > MAX_RAW_UPDATE_CHARS ? `${raw.slice(0, MAX_RAW_UPDATE_CHARS)}...` : raw;
3957
+ rawUpdateLogger.debug(`telegram update: ${preview}`);
3958
+ } catch (err) {
3959
+ rawUpdateLogger.debug(`telegram update log failed: ${String(err)}`);
3960
+ }
3961
+ await next();
3962
+ });
3963
+ const historyLimit = Math.max(0, telegramCfg.historyLimit ?? cfg.messages?.groupChat?.historyLimit ?? DEFAULT_GROUP_HISTORY_LIMIT);
3964
+ const groupHistories = /* @__PURE__ */ new Map();
3965
+ const textLimit = resolveTextChunkLimit(cfg, "telegram", account.accountId);
3966
+ const dmPolicy = telegramCfg.dmPolicy ?? "pairing";
3967
+ const allowFrom = opts.allowFrom ?? telegramCfg.allowFrom;
3968
+ const groupAllowFrom = opts.groupAllowFrom ?? telegramCfg.groupAllowFrom ?? (telegramCfg.allowFrom && telegramCfg.allowFrom.length > 0 ? telegramCfg.allowFrom : void 0) ?? (opts.allowFrom && opts.allowFrom.length > 0 ? opts.allowFrom : void 0);
3969
+ const replyToMode = opts.replyToMode ?? telegramCfg.replyToMode ?? "off";
3970
+ const nativeEnabled = resolveNativeCommandsEnabled({
3971
+ providerId: "telegram",
3972
+ providerSetting: telegramCfg.commands?.native,
3973
+ globalSetting: cfg.commands?.native
3974
+ });
3975
+ const nativeSkillsEnabled = resolveNativeSkillsEnabled({
3976
+ providerId: "telegram",
3977
+ providerSetting: telegramCfg.commands?.nativeSkills,
3978
+ globalSetting: cfg.commands?.nativeSkills
3979
+ });
3980
+ const nativeDisabledExplicit = isNativeCommandsExplicitlyDisabled({
3981
+ providerSetting: telegramCfg.commands?.native,
3982
+ globalSetting: cfg.commands?.native
3983
+ });
3984
+ const useAccessGroups = cfg.commands?.useAccessGroups !== false;
3985
+ const ackReactionScope = cfg.messages?.ackReactionScope ?? "group-mentions";
3986
+ const mediaMaxBytes = (opts.mediaMaxMb ?? telegramCfg.mediaMaxMb ?? 5) * 1024 * 1024;
3987
+ const logger = getChildLogger({ module: "telegram-auto-reply" });
3988
+ const streamMode = resolveTelegramStreamMode(telegramCfg);
3989
+ const resolveGroupPolicy = (chatId) => resolveChannelGroupPolicy({
3990
+ cfg,
3991
+ channel: "telegram",
3992
+ accountId: account.accountId,
3993
+ groupId: String(chatId)
3994
+ });
3995
+ const resolveGroupActivation = (params) => {
3996
+ const agentId = params.agentId ?? resolveDefaultAgentId(cfg);
3997
+ const sessionKey = params.sessionKey ?? `agent:${agentId}:telegram:group:${buildTelegramGroupPeerId(params.chatId, params.messageThreadId)}`;
3998
+ const storePath = resolveStorePath(cfg.session?.store, { agentId });
3999
+ try {
4000
+ const entry = loadSessionStore(storePath)[sessionKey];
4001
+ if (entry?.groupActivation === "always") return false;
4002
+ if (entry?.groupActivation === "mention") return true;
4003
+ } catch (err) {
4004
+ logVerbose(`Failed to load session for activation check: ${String(err)}`);
4005
+ }
4006
+ };
4007
+ const resolveGroupRequireMention = (chatId) => resolveChannelGroupRequireMention({
4008
+ cfg,
4009
+ channel: "telegram",
4010
+ accountId: account.accountId,
4011
+ groupId: String(chatId),
4012
+ requireMentionOverride: opts.requireMention,
4013
+ overrideOrder: "after-config"
4014
+ });
4015
+ const resolveTelegramGroupConfig = (chatId, messageThreadId) => {
4016
+ const groups = telegramCfg.groups;
4017
+ if (!groups) return {
4018
+ groupConfig: void 0,
4019
+ topicConfig: void 0
4020
+ };
4021
+ const groupConfig = groups[String(chatId)] ?? groups["*"];
4022
+ return {
4023
+ groupConfig,
4024
+ topicConfig: messageThreadId != null ? groupConfig?.topics?.[String(messageThreadId)] : void 0
4025
+ };
4026
+ };
4027
+ const processMessage = createTelegramMessageProcessor({
4028
+ bot,
4029
+ cfg,
4030
+ account,
4031
+ telegramCfg,
4032
+ historyLimit,
4033
+ groupHistories,
4034
+ dmPolicy,
4035
+ allowFrom,
4036
+ groupAllowFrom,
4037
+ ackReactionScope,
4038
+ logger,
4039
+ resolveGroupActivation,
4040
+ resolveGroupRequireMention,
4041
+ resolveTelegramGroupConfig,
4042
+ sendChatActionHandler: createTelegramSendChatActionHandler({
4043
+ sendChatActionFn: (chatId, action, threadParams) => bot.api.sendChatAction(chatId, action, threadParams),
4044
+ logger: (message) => logVerbose(`telegram: ${message}`)
4045
+ }),
4046
+ runtime,
4047
+ replyToMode,
4048
+ streamMode,
4049
+ textLimit,
4050
+ opts
4051
+ });
4052
+ registerTelegramNativeCommands({
4053
+ bot,
4054
+ cfg,
4055
+ runtime,
4056
+ accountId: account.accountId,
4057
+ telegramCfg,
4058
+ allowFrom,
4059
+ groupAllowFrom,
4060
+ replyToMode,
4061
+ textLimit,
4062
+ useAccessGroups,
4063
+ nativeEnabled,
4064
+ nativeSkillsEnabled,
4065
+ nativeDisabledExplicit,
4066
+ resolveGroupPolicy,
4067
+ resolveTelegramGroupConfig,
4068
+ shouldSkipUpdate,
4069
+ opts
4070
+ });
4071
+ registerTelegramHandlers({
4072
+ cfg,
4073
+ accountId: account.accountId,
4074
+ bot,
4075
+ opts,
4076
+ runtime,
4077
+ mediaMaxBytes,
4078
+ telegramCfg,
4079
+ allowFrom,
4080
+ groupAllowFrom,
4081
+ resolveGroupPolicy,
4082
+ resolveTelegramGroupConfig,
4083
+ shouldSkipUpdate,
4084
+ processMessage,
4085
+ logger
4086
+ });
4087
+ return bot;
4088
+ }
4089
+
4090
+ //#endregion
4091
+ //#region src/telegram/update-offset-store.ts
4092
+ const STORE_VERSION = 2;
4093
+ function normalizeAccountId(accountId) {
4094
+ const trimmed = accountId?.trim();
4095
+ if (!trimmed) return "default";
4096
+ return trimmed.replace(/[^a-z0-9._-]+/gi, "_");
4097
+ }
4098
+ function resolveTelegramUpdateOffsetPath(accountId, env = process.env) {
4099
+ const stateDir = resolveStateDir(env, os.homedir);
4100
+ const normalized = normalizeAccountId(accountId);
4101
+ return path.join(stateDir, "telegram", `update-offset-${normalized}.json`);
4102
+ }
4103
+ function extractBotIdFromToken(token) {
4104
+ const trimmed = token?.trim();
4105
+ if (!trimmed) return null;
4106
+ const [rawBotId] = trimmed.split(":", 1);
4107
+ if (!rawBotId || !/^\d+$/.test(rawBotId)) return null;
4108
+ return rawBotId;
4109
+ }
4110
+ function safeParseState(raw) {
4111
+ try {
4112
+ const parsed = JSON.parse(raw);
4113
+ if (parsed?.version !== STORE_VERSION && parsed?.version !== 1) return null;
4114
+ if (parsed.lastUpdateId !== null && typeof parsed.lastUpdateId !== "number") return null;
4115
+ if (parsed.version === STORE_VERSION && parsed.botId !== null && typeof parsed.botId !== "string") return null;
4116
+ return {
4117
+ version: STORE_VERSION,
4118
+ lastUpdateId: parsed.lastUpdateId ?? null,
4119
+ botId: parsed.version === STORE_VERSION ? parsed.botId ?? null : null
4120
+ };
4121
+ } catch {
4122
+ return null;
4123
+ }
4124
+ }
4125
+ async function readTelegramUpdateOffset(params) {
4126
+ const filePath = resolveTelegramUpdateOffsetPath(params.accountId, params.env);
4127
+ try {
4128
+ const parsed = safeParseState(await fs.readFile(filePath, "utf-8"));
4129
+ const expectedBotId = extractBotIdFromToken(params.botToken);
4130
+ if (expectedBotId && parsed?.botId && parsed.botId !== expectedBotId) return null;
4131
+ if (expectedBotId && parsed?.botId === null) return null;
4132
+ return parsed?.lastUpdateId ?? null;
4133
+ } catch (err) {
4134
+ if (err.code === "ENOENT") return null;
4135
+ return null;
4136
+ }
4137
+ }
4138
+ async function writeTelegramUpdateOffset(params) {
4139
+ const filePath = resolveTelegramUpdateOffsetPath(params.accountId, params.env);
4140
+ const dir = path.dirname(filePath);
4141
+ await fs.mkdir(dir, {
4142
+ recursive: true,
4143
+ mode: 448
4144
+ });
4145
+ const tmp = path.join(dir, `${path.basename(filePath)}.${crypto.randomUUID()}.tmp`);
4146
+ const payload = {
4147
+ version: STORE_VERSION,
4148
+ lastUpdateId: params.updateId,
4149
+ botId: extractBotIdFromToken(params.botToken)
4150
+ };
4151
+ await fs.writeFile(tmp, `${JSON.stringify(payload, null, 2)}\n`, { encoding: "utf-8" });
4152
+ await fs.chmod(tmp, 384);
4153
+ await fs.rename(tmp, filePath);
4154
+ }
4155
+
4156
+ //#endregion
4157
+ //#region src/telegram/webhook.ts
4158
+ const TELEGRAM_WEBHOOK_MAX_BODY_BYTES = 1024 * 1024;
4159
+ const TELEGRAM_WEBHOOK_BODY_TIMEOUT_MS = 3e4;
4160
+ const TELEGRAM_WEBHOOK_CALLBACK_TIMEOUT_MS = 1e4;
4161
+ async function listenHttpServer(params) {
4162
+ await new Promise((resolve, reject) => {
4163
+ const onError = (err) => {
4164
+ params.server.off("error", onError);
4165
+ reject(err);
4166
+ };
4167
+ params.server.once("error", onError);
4168
+ params.server.listen(params.port, params.host, () => {
4169
+ params.server.off("error", onError);
4170
+ resolve();
4171
+ });
4172
+ });
4173
+ }
4174
+ function resolveWebhookPublicUrl(params) {
4175
+ if (params.configuredPublicUrl) return params.configuredPublicUrl;
4176
+ const address = params.server.address();
4177
+ if (address && typeof address !== "string") return `http://${params.host === "0.0.0.0" || address.address === "0.0.0.0" || address.address === "::" ? "localhost" : address.address}:${address.port}${params.path}`;
4178
+ return `http://${params.host === "0.0.0.0" ? "localhost" : params.host}:${params.port}${params.path}`;
4179
+ }
4180
+ async function initializeTelegramWebhookBot(params) {
4181
+ const initSignal = params.abortSignal;
4182
+ await withTelegramApiErrorLogging({
4183
+ operation: "getMe",
4184
+ runtime: params.runtime,
4185
+ fn: () => params.bot.init(initSignal)
4186
+ });
4187
+ }
4188
+ async function startTelegramWebhook(opts) {
4189
+ const path = opts.path ?? "/telegram-webhook";
4190
+ const healthPath = opts.healthPath ?? "/healthz";
4191
+ const port = opts.port ?? 8787;
4192
+ const host = opts.host ?? "127.0.0.1";
4193
+ const secret = typeof opts.secret === "string" ? opts.secret.trim() : "";
4194
+ if (!secret) throw new Error("Telegram webhook mode requires a non-empty secret token. Set channels.telegram.webhookSecret in your config.");
4195
+ const runtime = opts.runtime ?? defaultRuntime;
4196
+ const diagnosticsEnabled = isDiagnosticsEnabled(opts.config);
4197
+ const bot = createTelegramBot({
4198
+ token: opts.token,
4199
+ runtime,
4200
+ proxyFetch: opts.fetch,
4201
+ config: opts.config,
4202
+ accountId: opts.accountId
4203
+ });
4204
+ await initializeTelegramWebhookBot({
4205
+ bot,
4206
+ runtime,
4207
+ abortSignal: opts.abortSignal
4208
+ });
4209
+ const handler = webhookCallback(bot, "callback", {
4210
+ secretToken: secret,
4211
+ onTimeout: "return",
4212
+ timeoutMilliseconds: TELEGRAM_WEBHOOK_CALLBACK_TIMEOUT_MS
4213
+ });
4214
+ if (diagnosticsEnabled) startDiagnosticHeartbeat();
4215
+ const server = createServer((req, res) => {
4216
+ const respondText = (statusCode, text = "") => {
4217
+ if (res.headersSent || res.writableEnded) return;
4218
+ res.writeHead(statusCode, { "Content-Type": "text/plain; charset=utf-8" });
4219
+ res.end(text);
4220
+ };
4221
+ if (req.url === healthPath) {
4222
+ res.writeHead(200);
4223
+ res.end("ok");
4224
+ return;
4225
+ }
4226
+ if (req.url !== path || req.method !== "POST") {
4227
+ res.writeHead(404);
4228
+ res.end();
4229
+ return;
4230
+ }
4231
+ const startTime = Date.now();
4232
+ if (diagnosticsEnabled) logWebhookReceived({
4233
+ channel: "telegram",
4234
+ updateType: "telegram-post"
4235
+ });
4236
+ (async () => {
4237
+ const body = await readJsonBodyWithLimit(req, {
4238
+ maxBytes: TELEGRAM_WEBHOOK_MAX_BODY_BYTES,
4239
+ timeoutMs: TELEGRAM_WEBHOOK_BODY_TIMEOUT_MS,
4240
+ emptyObjectOnEmpty: false
4241
+ });
4242
+ if (!body.ok) {
4243
+ if (body.code === "PAYLOAD_TOO_LARGE") {
4244
+ respondText(413, body.error);
4245
+ return;
4246
+ }
4247
+ if (body.code === "REQUEST_BODY_TIMEOUT") {
4248
+ respondText(408, body.error);
4249
+ return;
4250
+ }
4251
+ if (body.code === "CONNECTION_CLOSED") {
4252
+ respondText(400, body.error);
4253
+ return;
4254
+ }
4255
+ respondText(400, body.error);
4256
+ return;
4257
+ }
4258
+ let replied = false;
4259
+ const reply = async (json) => {
4260
+ if (replied) return;
4261
+ replied = true;
4262
+ if (res.headersSent || res.writableEnded) return;
4263
+ res.writeHead(200, { "Content-Type": "application/json; charset=utf-8" });
4264
+ res.end(json);
4265
+ };
4266
+ const unauthorized = async () => {
4267
+ if (replied) return;
4268
+ replied = true;
4269
+ respondText(401, "unauthorized");
4270
+ };
4271
+ const secretHeaderRaw = req.headers["x-telegram-bot-api-secret-token"];
4272
+ const secretHeader = Array.isArray(secretHeaderRaw) ? secretHeaderRaw[0] : secretHeaderRaw;
4273
+ await handler(body.value, reply, secretHeader, unauthorized);
4274
+ if (!replied) respondText(200);
4275
+ if (diagnosticsEnabled) logWebhookProcessed({
4276
+ channel: "telegram",
4277
+ updateType: "telegram-post",
4278
+ durationMs: Date.now() - startTime
4279
+ });
4280
+ })().catch((err) => {
4281
+ const errMsg = formatErrorMessage(err);
4282
+ if (diagnosticsEnabled) logWebhookError({
4283
+ channel: "telegram",
4284
+ updateType: "telegram-post",
4285
+ error: errMsg
4286
+ });
4287
+ runtime.log?.(`webhook handler failed: ${errMsg}`);
4288
+ respondText(500);
4289
+ });
4290
+ });
4291
+ await listenHttpServer({
4292
+ server,
4293
+ port,
4294
+ host
4295
+ });
4296
+ const boundAddress = server.address();
4297
+ const boundPort = boundAddress && typeof boundAddress !== "string" ? boundAddress.port : port;
4298
+ const publicUrl = resolveWebhookPublicUrl({
4299
+ configuredPublicUrl: opts.publicUrl,
4300
+ server,
4301
+ path,
4302
+ host,
4303
+ port
4304
+ });
4305
+ try {
4306
+ await withTelegramApiErrorLogging({
4307
+ operation: "setWebhook",
4308
+ runtime,
4309
+ fn: () => bot.api.setWebhook(publicUrl, {
4310
+ secret_token: secret,
4311
+ allowed_updates: resolveTelegramAllowedUpdates()
4312
+ })
4313
+ });
4314
+ } catch (err) {
4315
+ server.close();
4316
+ bot.stop();
4317
+ if (diagnosticsEnabled) stopDiagnosticHeartbeat();
4318
+ throw err;
4319
+ }
4320
+ runtime.log?.(`webhook local listener on http://${host}:${boundPort}${path}`);
4321
+ runtime.log?.(`webhook advertised to telegram on ${publicUrl}`);
4322
+ let shutDown = false;
4323
+ const shutdown = () => {
4324
+ if (shutDown) return;
4325
+ shutDown = true;
4326
+ withTelegramApiErrorLogging({
4327
+ operation: "deleteWebhook",
4328
+ runtime,
4329
+ fn: () => bot.api.deleteWebhook({ drop_pending_updates: false })
4330
+ }).catch(() => {});
4331
+ server.close();
4332
+ bot.stop();
4333
+ if (diagnosticsEnabled) stopDiagnosticHeartbeat();
4334
+ };
4335
+ if (opts.abortSignal) opts.abortSignal.addEventListener("abort", shutdown, { once: true });
4336
+ return {
4337
+ server,
4338
+ bot,
4339
+ stop: shutdown
4340
+ };
4341
+ }
4342
+
4343
+ //#endregion
4344
+ //#region src/telegram/monitor.ts
4345
+ function createTelegramRunnerOptions(cfg) {
4346
+ return {
4347
+ sink: { concurrency: resolveAgentMaxConcurrent(cfg) },
4348
+ runner: {
4349
+ fetch: {
4350
+ timeout: 30,
4351
+ allowed_updates: resolveTelegramAllowedUpdates()
4352
+ },
4353
+ silent: true,
4354
+ maxRetryTime: 3600 * 1e3,
4355
+ retryInterval: "exponential"
4356
+ }
4357
+ };
4358
+ }
4359
+ const TELEGRAM_POLL_RESTART_POLICY = {
4360
+ initialMs: 2e3,
4361
+ maxMs: 3e4,
4362
+ factor: 1.8,
4363
+ jitter: .25
4364
+ };
4365
+ const isGetUpdatesConflict = (err) => {
4366
+ if (!err || typeof err !== "object") return false;
4367
+ const typed = err;
4368
+ if ((typed.error_code ?? typed.errorCode) !== 409) return false;
4369
+ return [
4370
+ typed.method,
4371
+ typed.description,
4372
+ typed.message
4373
+ ].filter((value) => typeof value === "string").join(" ").toLowerCase().includes("getupdates");
4374
+ };
4375
+ /** Check if error is a Grammy HttpError (used to scope unhandled rejection handling) */
4376
+ const isGrammyHttpError = (err) => {
4377
+ if (!err || typeof err !== "object") return false;
4378
+ return err.name === "HttpError";
4379
+ };
4380
+ async function monitorTelegramProvider(opts = {}) {
4381
+ const log = opts.runtime?.error ?? console.error;
4382
+ let activeRunner;
4383
+ let forceRestarted = false;
4384
+ const unregisterHandler = registerUnhandledRejectionHandler((err) => {
4385
+ const isNetworkError = isRecoverableTelegramNetworkError(err, { context: "polling" });
4386
+ if (isGrammyHttpError(err) && isNetworkError) {
4387
+ log(`[telegram] Suppressed network error: ${formatErrorMessage(err)}`);
4388
+ return true;
4389
+ }
4390
+ if (isNetworkError && activeRunner && activeRunner.isRunning()) {
4391
+ forceRestarted = true;
4392
+ activeRunner.stop().catch(() => {});
4393
+ log(`[telegram] Restarting polling after unhandled network error: ${formatErrorMessage(err)}`);
4394
+ return true;
4395
+ }
4396
+ return false;
4397
+ });
4398
+ try {
4399
+ const cfg = opts.config ?? loadConfig();
4400
+ const account = resolveTelegramAccount({
4401
+ cfg,
4402
+ accountId: opts.accountId
4403
+ });
4404
+ const token = opts.token?.trim() || account.token;
4405
+ if (!token) throw new Error(`Telegram bot token missing for account "${account.accountId}" (set channels.telegram.accounts.${account.accountId}.botToken/tokenFile or TELEGRAM_BOT_TOKEN for default).`);
4406
+ const proxyFetch = opts.proxyFetch ?? (account.config.proxy ? makeProxyFetch(account.config.proxy) : void 0);
4407
+ let lastUpdateId = await readTelegramUpdateOffset({
4408
+ accountId: account.accountId,
4409
+ botToken: token
4410
+ });
4411
+ const persistUpdateId = async (updateId) => {
4412
+ if (lastUpdateId !== null && updateId <= lastUpdateId) return;
4413
+ lastUpdateId = updateId;
4414
+ try {
4415
+ await writeTelegramUpdateOffset({
4416
+ accountId: account.accountId,
4417
+ updateId,
4418
+ botToken: token
4419
+ });
4420
+ } catch (err) {
4421
+ (opts.runtime?.error ?? console.error)(`telegram: failed to persist update offset: ${String(err)}`);
4422
+ }
4423
+ };
4424
+ if (opts.useWebhook) {
4425
+ await startTelegramWebhook({
4426
+ token,
4427
+ accountId: account.accountId,
4428
+ config: cfg,
4429
+ path: opts.webhookPath,
4430
+ port: opts.webhookPort,
4431
+ secret: opts.webhookSecret ?? account.config.webhookSecret,
4432
+ host: opts.webhookHost ?? account.config.webhookHost,
4433
+ runtime: opts.runtime,
4434
+ fetch: proxyFetch,
4435
+ abortSignal: opts.abortSignal,
4436
+ publicUrl: opts.webhookUrl
4437
+ });
4438
+ await waitForAbortSignal(opts.abortSignal);
4439
+ return;
4440
+ }
4441
+ let restartAttempts = 0;
4442
+ let webhookCleared = false;
4443
+ const runnerOptions = createTelegramRunnerOptions(cfg);
4444
+ const waitBeforeRestart = async (buildLine) => {
4445
+ restartAttempts += 1;
4446
+ const delayMs = computeBackoff(TELEGRAM_POLL_RESTART_POLICY, restartAttempts);
4447
+ log(buildLine(formatDurationPrecise(delayMs)));
4448
+ try {
4449
+ await sleepWithAbort(delayMs, opts.abortSignal);
4450
+ } catch (sleepErr) {
4451
+ if (opts.abortSignal?.aborted) return false;
4452
+ throw sleepErr;
4453
+ }
4454
+ return true;
4455
+ };
4456
+ const waitBeforeRetryOnRecoverableSetupError = async (err, logPrefix) => {
4457
+ if (opts.abortSignal?.aborted) return false;
4458
+ if (!isRecoverableTelegramNetworkError(err, { context: "unknown" })) throw err;
4459
+ return waitBeforeRestart((delay) => `${logPrefix}: ${formatErrorMessage(err)}; retrying in ${delay}.`);
4460
+ };
4461
+ const createPollingBot = async () => {
4462
+ try {
4463
+ return createTelegramBot({
4464
+ token,
4465
+ runtime: opts.runtime,
4466
+ proxyFetch,
4467
+ config: cfg,
4468
+ accountId: account.accountId,
4469
+ updateOffset: {
4470
+ lastUpdateId,
4471
+ onUpdateId: persistUpdateId
4472
+ }
4473
+ });
4474
+ } catch (err) {
4475
+ if (!await waitBeforeRetryOnRecoverableSetupError(err, "Telegram setup network error")) return;
4476
+ return;
4477
+ }
4478
+ };
4479
+ const ensureWebhookCleanup = async (bot) => {
4480
+ if (webhookCleared) return "ready";
4481
+ try {
4482
+ await withTelegramApiErrorLogging({
4483
+ operation: "deleteWebhook",
4484
+ runtime: opts.runtime,
4485
+ fn: () => bot.api.deleteWebhook({ drop_pending_updates: false })
4486
+ });
4487
+ webhookCleared = true;
4488
+ return "ready";
4489
+ } catch (err) {
4490
+ return await waitBeforeRetryOnRecoverableSetupError(err, "Telegram webhook cleanup failed") ? "retry" : "exit";
4491
+ }
4492
+ };
4493
+ const runPollingCycle = async (bot) => {
4494
+ const runner = run(bot, runnerOptions);
4495
+ activeRunner = runner;
4496
+ let stopPromise;
4497
+ const stopRunner = () => {
4498
+ stopPromise ??= Promise.resolve(runner.stop()).then(() => void 0).catch(() => {});
4499
+ return stopPromise;
4500
+ };
4501
+ const stopOnAbort = () => {
4502
+ if (opts.abortSignal?.aborted) stopRunner();
4503
+ };
4504
+ opts.abortSignal?.addEventListener("abort", stopOnAbort, { once: true });
4505
+ try {
4506
+ await runner.task();
4507
+ if (opts.abortSignal?.aborted) return "exit";
4508
+ const reason = forceRestarted ? "unhandled network error" : "runner stopped (maxRetryTime exceeded or graceful stop)";
4509
+ forceRestarted = false;
4510
+ return await waitBeforeRestart((delay) => `Telegram polling runner stopped (${reason}); restarting in ${delay}.`) ? "continue" : "exit";
4511
+ } catch (err) {
4512
+ forceRestarted = false;
4513
+ if (opts.abortSignal?.aborted) throw err;
4514
+ const isConflict = isGetUpdatesConflict(err);
4515
+ const isRecoverable = isRecoverableTelegramNetworkError(err, { context: "polling" });
4516
+ if (!isConflict && !isRecoverable) throw err;
4517
+ const reason = isConflict ? "getUpdates conflict" : "network error";
4518
+ const errMsg = formatErrorMessage(err);
4519
+ return await waitBeforeRestart((delay) => `Telegram ${reason}: ${errMsg}; retrying in ${delay}.`) ? "continue" : "exit";
4520
+ } finally {
4521
+ opts.abortSignal?.removeEventListener("abort", stopOnAbort);
4522
+ await stopRunner();
4523
+ }
4524
+ };
4525
+ while (!opts.abortSignal?.aborted) {
4526
+ const bot = await createPollingBot();
4527
+ if (!bot) continue;
4528
+ const cleanupState = await ensureWebhookCleanup(bot);
4529
+ if (cleanupState === "retry") continue;
4530
+ if (cleanupState === "exit") return;
4531
+ if (await runPollingCycle(bot) === "exit") return;
4532
+ }
4533
+ } finally {
4534
+ unregisterHandler();
4535
+ }
4536
+ }
4537
+
4538
+ //#endregion
4539
+ export { monitorTelegramProvider };