@gaodefa/daocore 2026.5.25 → 2026.5.27

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 (1698) hide show
  1. package/dist/abort-By0wxKlI.js +277 -0
  2. package/dist/abort.runtime-C7zfjxBp.js +2 -0
  3. package/dist/abort.runtime.js +1 -1
  4. package/dist/account-inspect-DTeLlJz-.js +173 -0
  5. package/dist/accounts-B776XBaL.js +119 -0
  6. package/dist/accounts-CLyZILFF.js +107 -0
  7. package/dist/accounts-DiXgq14W.js +107 -0
  8. package/dist/accounts-iTlRLYN8.js +2 -0
  9. package/dist/acp-runtime-D9YQyGax.js +26 -0
  10. package/dist/acp-spawn-CWciV70C.js +1275 -0
  11. package/dist/acp-spawn-DjaS4O_V.js +2 -0
  12. package/dist/acp-stateful-target-driver-ByvGCj_i.js +89 -0
  13. package/dist/action-kill-DXeOA6YH.js +33 -0
  14. package/dist/action-runtime-BjQnG6qb.js +469 -0
  15. package/dist/action-runtime-api-a73ODsYk.js +2 -0
  16. package/dist/action-send-B_F3xwIu.js +39 -0
  17. package/dist/action-spawn-BFiW7gZJ.js +47 -0
  18. package/dist/actions-Bi7eE2I6.js +161 -0
  19. package/dist/actions.runtime-DmtbCLld.js +5 -0
  20. package/dist/agent-BOI4AdYK.js +3 -0
  21. package/dist/agent-DQPyDWP5.js +2 -0
  22. package/dist/agent-command-ClCxEw82.js +1367 -0
  23. package/dist/agent-components.runtime-C5wxy4D_.js +10 -0
  24. package/dist/agent-components.runtime.js +1 -1
  25. package/dist/agent-harness-CEPgjZ3p.d.ts +146 -0
  26. package/dist/agent-harness-runtime-CkdXIMHI.js +180 -0
  27. package/dist/agent-harness-runtime-DMYJ4buZ.d.ts +691 -0
  28. package/dist/agent-harness-task-runtime-CDtn5RjX.js +140 -0
  29. package/dist/agent-runner-execution-lXW8y0i2.js +1713 -0
  30. package/dist/agent-runner-utils-OdM9hLGt.js +266 -0
  31. package/dist/agent-runner.runtime-fZnfhCJI.js +3455 -0
  32. package/dist/agent-runner.runtime.js +1 -1
  33. package/dist/agent-runtime-Dp0RDnX1.js +229 -0
  34. package/dist/agent-via-gateway-vsBf3nqZ.js +463 -0
  35. package/dist/agents/pi-embedded-runner/tool-split.d.ts +1 -1
  36. package/dist/agents.commands.add-C94vGOFH.js +304 -0
  37. package/dist/agents.commands.delete-D-p2NL4v.js +128 -0
  38. package/dist/api-BZ2QC7WM.js +2 -0
  39. package/dist/api-BmYK5Dge.js +6 -0
  40. package/dist/api-C9Dmd2CA.d.ts +52 -0
  41. package/dist/api-CGdlHCIH.js +3 -0
  42. package/dist/api-CGjlsXii.js +134 -0
  43. package/dist/api-DGqp6wZo.js +2 -0
  44. package/dist/api-DKpE-zdY.js +639 -0
  45. package/dist/apply-GK4z5lYw.js +54 -0
  46. package/dist/apply-_yxsBkiR.js +41 -0
  47. package/dist/approval-handler.runtime-C7d9p3DG.js +130 -0
  48. package/dist/assistant-B-h25aRy.js +291 -0
  49. package/dist/attachment-normalize-DWZ4Nrn-.js +225 -0
  50. package/dist/attempt-execution-BY9C1EOu.js +558 -0
  51. package/dist/attempt-execution.runtime-SR7eolDa.js +3 -0
  52. package/dist/attempt-execution.runtime.js +1 -1
  53. package/dist/attempt-execution.shared-h6uYmkJz.js +38 -0
  54. package/dist/attempt.prompt-helpers-COc5m_TZ.js +475 -0
  55. package/dist/attempt.tool-run-context-CAtfgOqC.js +2094 -0
  56. package/dist/auth-BdkNYTYU.js +541 -0
  57. package/dist/banner-0TOO6XHd.js +397 -0
  58. package/dist/banner-DTHug6Ey.js +2 -0
  59. package/dist/binding-routing-BJ_A83Nl.js +113 -0
  60. package/dist/binding-targets-D5dmPh4R.js +121 -0
  61. package/dist/bot-DX1uG3P-.js +7894 -0
  62. package/dist/bot-deps-BpaYejaN.js +2 -0
  63. package/dist/bot-deps-CKFDy5y3.js +747 -0
  64. package/dist/bot-message-context.runtime-BKOeRg34.js +7 -0
  65. package/dist/bot-message-context.runtime.js +1 -1
  66. package/dist/bot-message-context.session.runtime-xgZdFv6P.js +12 -0
  67. package/dist/bot-message-context.session.runtime.js +1 -1
  68. package/dist/bot-native-commands.delivery.runtime-DDMQrRfJ.js +4 -0
  69. package/dist/bot-native-commands.delivery.runtime.js +1 -1
  70. package/dist/bot-native-commands.runtime-CVVvUz0h.js +13 -0
  71. package/dist/bot-native-commands.runtime.js +1 -1
  72. package/dist/bridge-server-37OWsDZc.js +113 -0
  73. package/dist/browser-cli-BC_6aZJV.js +2 -0
  74. package/dist/browser-cli-Dg1ipmgf.js +230 -0
  75. package/dist/browser-cli-actions-input-B0QuzzSW.js +473 -0
  76. package/dist/browser-cli-actions-observe-C246bas5.js +81 -0
  77. package/dist/browser-cli-debug-F64e_v4B.js +137 -0
  78. package/dist/browser-cli-inspect-Srn6eWjO.js +104 -0
  79. package/dist/browser-cli-manage-CaZ97-Me.js +443 -0
  80. package/dist/browser-cli-resize-CUR20fvZ.js +26 -0
  81. package/dist/browser-cli-shared-BhphnFVo.js +50 -0
  82. package/dist/browser-cli-state-CzaNXNWF.js +337 -0
  83. package/dist/browser-control-auth-DTY0Wx2B.js +2 -0
  84. package/dist/browser-profiles-BDGPPDJ7.js +2 -0
  85. package/dist/browser-runtime-aqBKI8Oi.js +384 -0
  86. package/dist/build-CG7aTzO9.js +257 -0
  87. package/dist/build-info.json +3 -3
  88. package/dist/bundled/boot-md/handler.js +2 -2
  89. package/dist/bundled/session-memory/handler.js +1 -1
  90. package/dist/call-BAWIPJo2.d.ts +43 -0
  91. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  92. package/dist/capability-cli-BhF26gVm.js +1782 -0
  93. package/dist/channel-5_XS0Mss.js +508 -0
  94. package/dist/channel-7L-vyWOO.js +362 -0
  95. package/dist/channel-B6YcNFXw.d.ts +104 -0
  96. package/dist/channel-BVxTyJ0I.js +376 -0
  97. package/dist/channel-BWIsr1r-.js +808 -0
  98. package/dist/channel-Ba0p4xM-.js +1134 -0
  99. package/dist/channel-BdhbzWTg.d.ts +427 -0
  100. package/dist/channel-Bi2nTop1.js +481 -0
  101. package/dist/channel-Bj29iFgF.js +740 -0
  102. package/dist/channel-Bkp8v6zY.d.ts +14 -0
  103. package/dist/channel-BoK62YYe.d.ts +49 -0
  104. package/dist/channel-C10lHKrC.d.ts +47 -0
  105. package/dist/channel-C6G6-tH6.js +562 -0
  106. package/dist/channel-CBhuuq-_.js +2126 -0
  107. package/dist/channel-CMmVpcnl.js +867 -0
  108. package/dist/channel-COc7idAe.js +653 -0
  109. package/dist/channel-CZrble5P.d.ts +8 -0
  110. package/dist/channel-CjfuHhSU.js +1556 -0
  111. package/dist/channel-Cquy73C-.js +1249 -0
  112. package/dist/channel-CzvuskEn.js +955 -0
  113. package/dist/channel-D6u-243v.js +1777 -0
  114. package/dist/channel-D8X4fgB9.d.ts +106 -0
  115. package/dist/channel-D9LDQOYt.d.ts +8 -0
  116. package/dist/channel-DR8PbP31.js +238 -0
  117. package/dist/channel-DUZ0s98I.js +1496 -0
  118. package/dist/channel-DVGMasO6.d.ts +7 -0
  119. package/dist/channel-Djgm5DE9.d.ts +64 -0
  120. package/dist/channel-Dl4eeuJ3.d.ts +114 -0
  121. package/dist/channel-DpQ6_cvo.d.ts +8 -0
  122. package/dist/channel-JqEqZ04S.d.ts +6 -0
  123. package/dist/channel-actions.runtime-BzEqt_Va.js +265 -0
  124. package/dist/channel-actions.runtime.js +1 -1
  125. package/dist/channel-core-CbkDdNXh.d.ts +6 -0
  126. package/dist/channel-core-DDZnTvT6.js +5 -0
  127. package/dist/channel-entry-contract-DUSF3gce.d.ts +112 -0
  128. package/dist/channel-hShoCuAc.d.ts +12 -0
  129. package/dist/channel-inbound-C2wLEE7Q.js +80 -0
  130. package/dist/channel-pIMjOo6Y.d.ts +28 -0
  131. package/dist/channel-plugin-runtime-B8AWkA0i.js +998 -0
  132. package/dist/channel-plugin-runtime-Cg67QAiE.d.ts +7 -0
  133. package/dist/channel-runtime-CciKN6E5.js +408 -0
  134. package/dist/channel-uP-mo8Q6.d.ts +7 -0
  135. package/dist/channel-whyHp4eY.d.ts +26 -0
  136. package/dist/channel.runtime-BQN8Bkb0.js +254 -0
  137. package/dist/channel.runtime-BXeGEvv7.js +21009 -0
  138. package/dist/channel.runtime-C40ILulM.js +1008 -0
  139. package/dist/channel.runtime-CJ2DSojv.js +733 -0
  140. package/dist/channel.runtime-CUaygROD.js +652 -0
  141. package/dist/channel.runtime-CcCbJhDb.js +88 -0
  142. package/dist/channel.runtime-DJbKu9D3.js +4 -0
  143. package/dist/channel.runtime-DgRuSo5T.js +109 -0
  144. package/dist/channel.runtime-tRXUD2p2.js +2528 -0
  145. package/dist/channel.setup-3aVku-g-.js +1098 -0
  146. package/dist/channel.setup-BMXb23G7.d.ts +6 -0
  147. package/dist/channel.setup-BdEXf9Ic.d.ts +8 -0
  148. package/dist/channel.setup-DT7Z9egu.js +343 -0
  149. package/dist/channel.setup-DhlkGTJV.js +10 -0
  150. package/dist/channel.setup-UZjcpncE.d.ts +7 -0
  151. package/dist/chat-D3LWYymW.js +2666 -0
  152. package/dist/chrome--ATU1T0X.js +1503 -0
  153. package/dist/cli/run-main.js +9 -9
  154. package/dist/cli-D8hIXnS1.js +1341 -0
  155. package/dist/cli-DYinYyHP.d.ts +20 -0
  156. package/dist/cli-backend-CSCGROD2.d.ts +5 -0
  157. package/dist/cli-backend-DmBwqwqy.d.ts +5 -0
  158. package/dist/cli-compaction-jmi3u2HG.js +347 -0
  159. package/dist/cli-metadata-Cy9MEdPv.js +22 -0
  160. package/dist/cli-runner-DuT8oeZF.js +540 -0
  161. package/dist/cli-runner-DvKgnkCL.js +2 -0
  162. package/dist/cli-runner.runtime-B-aD16MD.js +4 -0
  163. package/dist/cli-runner.runtime-DofcKX1U.js +3 -0
  164. package/dist/cli-runner.runtime.js +1 -1
  165. package/dist/cli-shared-CXpra3BN.d.ts +20 -0
  166. package/dist/cli-startup-metadata.json +13 -13
  167. package/dist/client-B5IcAlfB.js +650 -0
  168. package/dist/client-adapter-CXA67h2E.js +897 -0
  169. package/dist/client-factory-aY6TuKfQ.js +9 -0
  170. package/dist/command-auth-DS9XgXEG.js +135 -0
  171. package/dist/command-execution-startup-DQOLt5Sz.js +87 -0
  172. package/dist/command-handlers-DqxF-IM9.js +1609 -0
  173. package/dist/command-registry-BSVx1oOc.js +4 -0
  174. package/dist/command-registry-CsPIOiQ3.js +9 -0
  175. package/dist/command-registry-core-Bzu5ff5F.js +110 -0
  176. package/dist/command-status.runtime-MKsizBC-.js +90 -0
  177. package/dist/command-status.runtime.js +1 -1
  178. package/dist/commands-CqcnXnk-.d.ts +113 -0
  179. package/dist/commands-acp-ClJofWty.js +74 -0
  180. package/dist/commands-compact.runtime-7VqYX4tS.js +10 -0
  181. package/dist/commands-compact.runtime.js +1 -1
  182. package/dist/commands-handlers.runtime-Dfqf_Oyp.js +6154 -0
  183. package/dist/commands-handlers.runtime.js +1 -1
  184. package/dist/commands-status-CRaEj9Vf.js +16 -0
  185. package/dist/commands-status-uDaqCP2F.js +3 -0
  186. package/dist/commands-status.runtime-uDaqCP2F.js +3 -0
  187. package/dist/commands-status.runtime.js +1 -1
  188. package/dist/commands-subagents-control.runtime-BaYcGLtc.js +2 -0
  189. package/dist/commands-subagents-control.runtime-C4xMpLed.js +3 -0
  190. package/dist/commands-subagents-control.runtime.js +1 -1
  191. package/dist/commands-system-prompt-C3lzz7wW.js +162 -0
  192. package/dist/commands-system-prompt-DpiW5FkQ.js +2 -0
  193. package/dist/commands.runtime-l4fGcB5c.js +176 -0
  194. package/dist/commands.runtime.js +1 -1
  195. package/dist/commitments/runtime.js +1 -1
  196. package/dist/compact-Dq0mi-y_.js +480 -0
  197. package/dist/compact-voJdoXm-.js +1141 -0
  198. package/dist/compact.runtime-BNLPSDQQ.js +12 -0
  199. package/dist/compact.runtime.js +1 -1
  200. package/dist/completion-cli-qHUelvvd.js +315 -0
  201. package/dist/computer-use-dP3FCUtq.js +367 -0
  202. package/dist/config-BDGPPDJ7.js +2 -0
  203. package/dist/config-Dg3sgjXu.js +373 -0
  204. package/dist/config-cli-INHPnZOG.js +1633 -0
  205. package/dist/config-mutations-CAgnXnDt.js +159 -0
  206. package/dist/config-schema-Bqr7vPys.d.ts +20 -0
  207. package/dist/configure-M1VU0h9O.js +3 -0
  208. package/dist/configure.commands-CM8RXyn3.js +1251 -0
  209. package/dist/configure.commands-PvOJd4nu.js +2 -0
  210. package/dist/context-engine-host-compat-D7I7Q63Z.js +288 -0
  211. package/dist/context-engine-host-compat-DGHUiQUV.js +2 -0
  212. package/dist/context-engine-lifecycle-Zsi-S6qy.js +1274 -0
  213. package/dist/contracts-testkit-DQ4aMv6G.d.ts +145 -0
  214. package/dist/control-auth-BKUTwIvH.js +114 -0
  215. package/dist/control-service-CKUzEAa0.js +145 -0
  216. package/dist/control-ui/assets/agents-ClA7Dmdi.js +1008 -0
  217. package/dist/control-ui/assets/channel-config-extras-DbFSI8yX.js +2 -0
  218. package/dist/control-ui/assets/channels-DnbSBvPm.js +367 -0
  219. package/dist/control-ui/assets/cron-CEUF8LjD.js +1013 -0
  220. package/dist/control-ui/assets/debug-DRYELUHG.js +97 -0
  221. package/dist/control-ui/assets/index-DCsdjM46.js +7370 -0
  222. package/dist/control-ui/assets/instances-COCizU2x.js +57 -0
  223. package/dist/control-ui/assets/logs-DNECqE3y.js +74 -0
  224. package/dist/control-ui/assets/nodes-MFf2wNIy.js +436 -0
  225. package/dist/control-ui/assets/sessions-DDnQy3rE.js +399 -0
  226. package/dist/control-ui/assets/skills-8ppwfjOc.js +314 -0
  227. package/dist/control-ui/assets/skills-shared-DI8nwzCe.js +11 -0
  228. package/dist/control-ui/index.html +1 -1
  229. package/dist/control-ui/sw.js +1 -1
  230. package/dist/conversation-binding-runtime-rXAYUZyM.js +4 -0
  231. package/dist/conversation-runtime-CV0pSg81.js +31 -0
  232. package/dist/core-BV0irASW.js +282 -0
  233. package/dist/core-DIQ0fbwp.d.ts +224 -0
  234. package/dist/core-api-CyhjZVzn.js +5 -0
  235. package/dist/core-api-YdHGjff8.js +2 -0
  236. package/dist/crestodian/crestodian.js +1 -1
  237. package/dist/crestodian/rescue-message.js +1 -1
  238. package/dist/crestodian-n5FVHIW5.js +55 -0
  239. package/dist/daocore-runtime-JsdCNe3l.d.ts +151 -0
  240. package/dist/daocore-tools-CXDZ1Xhe.js +11727 -0
  241. package/dist/dashboard-CeQV6L1K.js +263 -0
  242. package/dist/delivery-D7LfafSk.js +1002 -0
  243. package/dist/dev-BSY4rs1s.js +97 -0
  244. package/dist/dialogue-DWFnjTiN.js +37 -0
  245. package/dist/dir-fetch-tool-BnlEyfZh.js +565 -0
  246. package/dist/dir-list-tool-Blhg_vTH.js +100 -0
  247. package/dist/direct-dm-DJPIaf5J.js +64 -0
  248. package/dist/directive-handling.fast-lane-DGV6PZYZ.js +68 -0
  249. package/dist/directive-handling.impl-CTDwclQa.js +818 -0
  250. package/dist/directive-handling.impl-_zI0_GsT.js +2 -0
  251. package/dist/directive-handling.model-selection-C8lG4FHQ.js +122 -0
  252. package/dist/directive-handling.persist.runtime-CmLb1evR.js +263 -0
  253. package/dist/directive-handling.persist.runtime.js +1 -1
  254. package/dist/dispatch-DvZRbIrc.js +1640 -0
  255. package/dist/dispatch-acp-transcript.runtime-PehNIsnR.js +40 -0
  256. package/dist/dispatch-acp-transcript.runtime.js +1 -1
  257. package/dist/dispatch-acp.runtime-Dg8ft-Ve.js +18 -0
  258. package/dist/dispatch-acp.runtime.js +1 -1
  259. package/dist/doctor-DJFM3lrT.js +6 -0
  260. package/dist/doctor-_ob4EiVf.js +2 -0
  261. package/dist/doctor-config-flow-D6iEk-en.js +1741 -0
  262. package/dist/doctor-core-checks-CCfWWL1-.js +573 -0
  263. package/dist/doctor-core-checks-CqkHUVcZ.js +2 -0
  264. package/dist/doctor-health-CrNPft4G.js +65 -0
  265. package/dist/doctor-health-contributions-Bwu5M_GQ.js +696 -0
  266. package/dist/doctor-lint-B2Wb_jEn.js +94 -0
  267. package/dist/doctor-prompter-cXq7RExi.js +58 -0
  268. package/dist/doctor-state-integrity-DfYyVFbQ.js +1231 -0
  269. package/dist/dynamic-tools-CbHsYkuk.js +486 -0
  270. package/dist/embedded-backend-IYuqoxzv.js +579 -0
  271. package/dist/embedded-gateway-stub.runtime-BjJ_93Pp.js +12 -0
  272. package/dist/embedded-gateway-stub.runtime.js +1 -1
  273. package/dist/embedding-provider-56qUY6a4.d.ts +16 -0
  274. package/dist/embedding-provider-CfSvDhLk.d.ts +65 -0
  275. package/dist/embedding-provider-DV9KtS1H.d.ts +21 -0
  276. package/dist/entry.d.ts +1 -1
  277. package/dist/entry.js +1 -1
  278. package/dist/exec-approvals-VjIKwFog.js +149 -0
  279. package/dist/extensionAPI.js +1 -1
  280. package/dist/extensions/active-memory/index.d.ts +1 -1
  281. package/dist/extensions/active-memory/index.js +1 -1
  282. package/dist/extensions/admin-http-rpc/index.d.ts +1 -1
  283. package/dist/extensions/admin-http-rpc/index.js +1 -1
  284. package/dist/extensions/alibaba/index.d.ts +1 -1
  285. package/dist/extensions/anthropic/api.d.ts +3 -3
  286. package/dist/extensions/anthropic/cli-backend-api.d.ts +2 -2
  287. package/dist/extensions/anthropic/cli-backend.d.ts +1 -1
  288. package/dist/extensions/anthropic/cli-migration.d.ts +1 -1
  289. package/dist/extensions/anthropic/cli-shared.d.ts +1 -1
  290. package/dist/extensions/anthropic/contract-api.d.ts +1 -1
  291. package/dist/extensions/anthropic/index.d.ts +1 -1
  292. package/dist/extensions/anthropic/provider-contract-api.d.ts +1 -1
  293. package/dist/extensions/anthropic/provider-discovery.d.ts +1 -1
  294. package/dist/extensions/anthropic/provider-policy-api.d.ts +1 -1
  295. package/dist/extensions/anthropic/register.runtime.d.ts +1 -1
  296. package/dist/extensions/anthropic/replay-policy.d.ts +1 -1
  297. package/dist/extensions/anthropic/setup-api.d.ts +1 -1
  298. package/dist/extensions/anthropic/stream-wrappers.d.ts +1 -1
  299. package/dist/extensions/anthropic/test-api.d.ts +2 -2
  300. package/dist/extensions/arcee/index.d.ts +1 -1
  301. package/dist/extensions/azure-speech/index.d.ts +1 -1
  302. package/dist/extensions/azure-speech/speech-provider.d.ts +1 -1
  303. package/dist/extensions/bonjour/index.d.ts +1 -1
  304. package/dist/extensions/browser/browser-bridge.js +1 -1
  305. package/dist/extensions/browser/browser-config.js +4 -4
  306. package/dist/extensions/browser/browser-control-auth.js +2 -2
  307. package/dist/extensions/browser/browser-doctor.js +2 -2
  308. package/dist/extensions/browser/browser-maintenance.js +1 -1
  309. package/dist/extensions/browser/browser-profiles.js +2 -2
  310. package/dist/extensions/browser/browser-runtime-api.js +11 -11
  311. package/dist/extensions/browser/cli-metadata.d.ts +1 -1
  312. package/dist/extensions/browser/cli-metadata.js +1 -1
  313. package/dist/extensions/browser/index.d.ts +1 -1
  314. package/dist/extensions/browser/index.js +1 -1
  315. package/dist/extensions/browser/plugin-registration.d.ts +1 -1
  316. package/dist/extensions/browser/plugin-registration.js +1 -1
  317. package/dist/extensions/browser/register.runtime.d.ts +2 -2
  318. package/dist/extensions/browser/register.runtime.js +4 -4
  319. package/dist/extensions/browser/runtime-api.d.ts +3 -3
  320. package/dist/extensions/browser/runtime-api.js +13 -13
  321. package/dist/extensions/browser/setup-api.d.ts +1 -1
  322. package/dist/extensions/byteplus/index.d.ts +1 -1
  323. package/dist/extensions/byteplus/provider-discovery.d.ts +1 -1
  324. package/dist/extensions/canvas/cli-metadata.d.ts +1 -1
  325. package/dist/extensions/canvas/index.d.ts +1 -1
  326. package/dist/extensions/canvas/index.js +1 -1
  327. package/dist/extensions/canvas/runtime-api.d.ts +2 -2
  328. package/dist/extensions/canvas/setup-api.d.ts +1 -1
  329. package/dist/extensions/cerebras/index.d.ts +1 -1
  330. package/dist/extensions/chutes/index.d.ts +1 -1
  331. package/dist/extensions/clickclack/api.d.ts +2 -2
  332. package/dist/extensions/clickclack/api.js +2 -2
  333. package/dist/extensions/clickclack/channel-plugin-api.d.ts +1 -1
  334. package/dist/extensions/clickclack/channel-plugin-api.js +1 -1
  335. package/dist/extensions/clickclack/index.d.ts +2 -2
  336. package/dist/extensions/clickclack/runtime-api.d.ts +2 -2
  337. package/dist/extensions/clickclack/runtime-api.js +2 -2
  338. package/dist/extensions/cloudflare-ai-gateway/index.d.ts +1 -1
  339. package/dist/extensions/cloudflare-ai-gateway/stream-wrappers.d.ts +1 -1
  340. package/dist/extensions/comfy/index.d.ts +1 -1
  341. package/dist/extensions/copilot-proxy/index.d.ts +1 -1
  342. package/dist/extensions/copilot-proxy/runtime-api.d.ts +2 -2
  343. package/dist/extensions/deepgram/index.d.ts +1 -1
  344. package/dist/extensions/deepgram/realtime-transcription-provider.d.ts +1 -1
  345. package/dist/extensions/deepgram/test-api.d.ts +1 -1
  346. package/dist/extensions/deepinfra/api.d.ts +2 -2
  347. package/dist/extensions/deepinfra/embedding-provider.d.ts +1 -1
  348. package/dist/extensions/deepinfra/index.d.ts +1 -1
  349. package/dist/extensions/deepinfra/memory-embedding-adapter.d.ts +1 -1
  350. package/dist/extensions/deepinfra/speech-provider.d.ts +1 -1
  351. package/dist/extensions/deepseek/api.d.ts +1 -1
  352. package/dist/extensions/deepseek/index.d.ts +1 -1
  353. package/dist/extensions/deepseek/provider-discovery.d.ts +1 -1
  354. package/dist/extensions/deepseek/provider-policy-api.d.ts +1 -1
  355. package/dist/extensions/deepseek/stream.d.ts +1 -1
  356. package/dist/extensions/deepseek/thinking.d.ts +1 -1
  357. package/dist/extensions/device-pair/api.d.ts +3 -3
  358. package/dist/extensions/device-pair/api.js +1 -1
  359. package/dist/extensions/device-pair/index.d.ts +1 -1
  360. package/dist/extensions/device-pair/notify.d.ts +1 -1
  361. package/dist/extensions/device-pair/pair-command-approve.js +1 -1
  362. package/dist/extensions/document-extract/index.d.ts +1 -1
  363. package/dist/extensions/duckduckgo/index.d.ts +1 -1
  364. package/dist/extensions/elevenlabs/index.d.ts +1 -1
  365. package/dist/extensions/elevenlabs/realtime-transcription-provider.d.ts +1 -1
  366. package/dist/extensions/elevenlabs/setup-api.d.ts +1 -1
  367. package/dist/extensions/elevenlabs/speech-provider.d.ts +1 -1
  368. package/dist/extensions/elevenlabs/test-api.d.ts +2 -2
  369. package/dist/extensions/exa/index.d.ts +1 -1
  370. package/dist/extensions/fal/index.d.ts +1 -1
  371. package/dist/extensions/fal/provider-contract-api.d.ts +1 -1
  372. package/dist/extensions/fal/provider-registration.d.ts +1 -1
  373. package/dist/extensions/file-transfer/index.d.ts +1 -1
  374. package/dist/extensions/file-transfer/index.js +4 -4
  375. package/dist/extensions/firecrawl/index.d.ts +1 -1
  376. package/dist/extensions/fireworks/index.d.ts +1 -1
  377. package/dist/extensions/fireworks/provider-policy-api.d.ts +1 -1
  378. package/dist/extensions/fireworks/stream.d.ts +1 -1
  379. package/dist/extensions/fireworks/thinking-policy.d.ts +1 -1
  380. package/dist/extensions/github-copilot/embeddings.d.ts +1 -1
  381. package/dist/extensions/github-copilot/index.d.ts +1 -1
  382. package/dist/extensions/github-copilot/models.d.ts +1 -1
  383. package/dist/extensions/github-copilot/register.runtime.d.ts +2 -2
  384. package/dist/extensions/github-copilot/stream.d.ts +1 -1
  385. package/dist/extensions/google/api.d.ts +5 -5
  386. package/dist/extensions/google/cli-backend.d.ts +1 -1
  387. package/dist/extensions/google/embedding-batch.d.ts +1 -1
  388. package/dist/extensions/google/embedding-provider.d.ts +1 -1
  389. package/dist/extensions/google/gemini-cli-provider.d.ts +1 -1
  390. package/dist/extensions/google/index.d.ts +1 -1
  391. package/dist/extensions/google/memory-embedding-adapter.d.ts +1 -1
  392. package/dist/extensions/google/provider-contract-api.d.ts +1 -1
  393. package/dist/extensions/google/provider-hooks.d.ts +2 -2
  394. package/dist/extensions/google/provider-models.d.ts +1 -1
  395. package/dist/extensions/google/provider-policy-api.d.ts +1 -1
  396. package/dist/extensions/google/provider-policy.d.ts +1 -1
  397. package/dist/extensions/google/provider-registration.d.ts +1 -1
  398. package/dist/extensions/google/realtime-voice-provider.d.ts +1 -1
  399. package/dist/extensions/google/runtime-api.d.ts +3 -3
  400. package/dist/extensions/google/setup-api.d.ts +1 -1
  401. package/dist/extensions/google/speech-provider.d.ts +1 -1
  402. package/dist/extensions/google/test-api.d.ts +2 -2
  403. package/dist/extensions/google/thinking-api.d.ts +1 -1
  404. package/dist/extensions/google/thinking.d.ts +1 -1
  405. package/dist/extensions/google/transport-stream.d.ts +1 -1
  406. package/dist/extensions/gradium/index.d.ts +1 -1
  407. package/dist/extensions/gradium/speech-provider.d.ts +1 -1
  408. package/dist/extensions/groq/index.d.ts +1 -1
  409. package/dist/extensions/huggingface/index.d.ts +1 -1
  410. package/dist/extensions/image-generation-core/api.d.ts +3 -3
  411. package/dist/extensions/image-generation-core/runtime-api.d.ts +1 -1
  412. package/dist/extensions/imessage/api.d.ts +2 -2
  413. package/dist/extensions/imessage/api.js +2 -2
  414. package/dist/extensions/imessage/channel-plugin-api.d.ts +1 -1
  415. package/dist/extensions/imessage/channel-plugin-api.js +1 -1
  416. package/dist/extensions/imessage/index.d.ts +2 -2
  417. package/dist/extensions/imessage/message-tool-api.d.ts +1 -1
  418. package/dist/extensions/imessage/runtime-api.d.ts +2 -2
  419. package/dist/extensions/imessage/runtime-api.js +3 -3
  420. package/dist/extensions/imessage/setup-entry.d.ts +2 -2
  421. package/dist/extensions/imessage/test-api.d.ts +1 -1
  422. package/dist/extensions/inworld/index.d.ts +1 -1
  423. package/dist/extensions/inworld/speech-provider.d.ts +1 -1
  424. package/dist/extensions/irc/api.d.ts +1 -1
  425. package/dist/extensions/irc/api.js +2 -2
  426. package/dist/extensions/irc/channel-plugin-api.d.ts +1 -1
  427. package/dist/extensions/irc/channel-plugin-api.js +1 -1
  428. package/dist/extensions/irc/index.d.ts +2 -2
  429. package/dist/extensions/irc/setup-entry.d.ts +2 -2
  430. package/dist/extensions/kilocode/index.d.ts +1 -1
  431. package/dist/extensions/kimi-coding/index.d.ts +1 -1
  432. package/dist/extensions/kimi-coding/stream.d.ts +1 -1
  433. package/dist/extensions/litellm/index.d.ts +1 -1
  434. package/dist/extensions/llm-task/api.d.ts +2 -2
  435. package/dist/extensions/llm-task/index.d.ts +1 -1
  436. package/dist/extensions/llm-task/index.js +1 -1
  437. package/dist/extensions/lmstudio/api.d.ts +1 -1
  438. package/dist/extensions/lmstudio/index.d.ts +1 -1
  439. package/dist/extensions/lmstudio/memory-embedding-adapter.d.ts +1 -1
  440. package/dist/extensions/mattermost/api.js +1 -1
  441. package/dist/extensions/mattermost/channel-plugin-api.d.ts +2 -2
  442. package/dist/extensions/mattermost/channel-plugin-api.js +1 -1
  443. package/dist/extensions/mattermost/channel-plugin-runtime.d.ts +1 -1
  444. package/dist/extensions/mattermost/channel-plugin-runtime.js +1 -1
  445. package/dist/extensions/mattermost/index.d.ts +2 -2
  446. package/dist/extensions/mattermost/policy-api.js +1 -1
  447. package/dist/extensions/mattermost/runtime-api.d.ts +3 -3
  448. package/dist/extensions/mattermost/runtime-api.js +2 -2
  449. package/dist/extensions/mattermost/setup-entry.d.ts +2 -2
  450. package/dist/extensions/mattermost/slash-route-api.d.ts +1 -1
  451. package/dist/extensions/mattermost/slash-route-api.js +1 -1
  452. package/dist/extensions/memory-core/api.d.ts +1 -1
  453. package/dist/extensions/memory-core/cli-metadata.d.ts +1 -1
  454. package/dist/extensions/memory-core/cli-metadata.js +1 -1
  455. package/dist/extensions/memory-core/index.d.ts +1 -1
  456. package/dist/extensions/memory-core/manager-runtime.d.ts +1 -1
  457. package/dist/extensions/memory-core/runtime-api.d.ts +2 -2
  458. package/dist/extensions/memory-wiki/api.d.ts +3 -3
  459. package/dist/extensions/memory-wiki/cli-metadata.d.ts +1 -1
  460. package/dist/extensions/memory-wiki/index.d.ts +1 -1
  461. package/dist/extensions/memory-wiki/setup-api.d.ts +1 -1
  462. package/dist/extensions/microsoft/index.d.ts +1 -1
  463. package/dist/extensions/microsoft/speech-provider.d.ts +1 -1
  464. package/dist/extensions/microsoft/test-api.d.ts +1 -1
  465. package/dist/extensions/microsoft-foundry/auth.d.ts +1 -1
  466. package/dist/extensions/microsoft-foundry/cli.d.ts +1 -1
  467. package/dist/extensions/microsoft-foundry/index.d.ts +1 -1
  468. package/dist/extensions/microsoft-foundry/onboard.d.ts +3 -3
  469. package/dist/extensions/microsoft-foundry/provider.d.ts +1 -1
  470. package/dist/extensions/microsoft-foundry/runtime.d.ts +1 -1
  471. package/dist/extensions/microsoft-foundry/shared-runtime.d.ts +1 -1
  472. package/dist/extensions/microsoft-foundry/shared.d.ts +1 -1
  473. package/dist/extensions/migrate-claude/apply.d.ts +1 -1
  474. package/dist/extensions/migrate-claude/apply.js +1 -1
  475. package/dist/extensions/migrate-claude/config.d.ts +1 -1
  476. package/dist/extensions/migrate-claude/helpers.d.ts +1 -1
  477. package/dist/extensions/migrate-claude/index.d.ts +1 -1
  478. package/dist/extensions/migrate-claude/index.js +1 -1
  479. package/dist/extensions/migrate-claude/memory.d.ts +2 -2
  480. package/dist/extensions/migrate-claude/plan.d.ts +1 -1
  481. package/dist/extensions/migrate-claude/plan.js +1 -1
  482. package/dist/extensions/migrate-claude/provider.d.ts +1 -1
  483. package/dist/extensions/migrate-claude/provider.js +1 -1
  484. package/dist/extensions/migrate-claude/skills.d.ts +2 -2
  485. package/dist/extensions/migrate-claude/targets.d.ts +1 -1
  486. package/dist/extensions/migrate-claude/targets.js +1 -1
  487. package/dist/extensions/migrate-hermes/apply.d.ts +1 -1
  488. package/dist/extensions/migrate-hermes/apply.js +1 -1
  489. package/dist/extensions/migrate-hermes/config.d.ts +1 -1
  490. package/dist/extensions/migrate-hermes/helpers.d.ts +1 -1
  491. package/dist/extensions/migrate-hermes/index.d.ts +1 -1
  492. package/dist/extensions/migrate-hermes/index.js +1 -1
  493. package/dist/extensions/migrate-hermes/items.d.ts +1 -1
  494. package/dist/extensions/migrate-hermes/model.d.ts +1 -1
  495. package/dist/extensions/migrate-hermes/model.js +1 -1
  496. package/dist/extensions/migrate-hermes/plan.d.ts +1 -1
  497. package/dist/extensions/migrate-hermes/plan.js +1 -1
  498. package/dist/extensions/migrate-hermes/provider.d.ts +1 -1
  499. package/dist/extensions/migrate-hermes/provider.js +1 -1
  500. package/dist/extensions/migrate-hermes/secrets.d.ts +2 -2
  501. package/dist/extensions/migrate-hermes/secrets.js +1 -1
  502. package/dist/extensions/migrate-hermes/skills.d.ts +2 -2
  503. package/dist/extensions/migrate-hermes/targets.d.ts +1 -1
  504. package/dist/extensions/migrate-hermes/targets.js +1 -1
  505. package/dist/extensions/minimax/index.d.ts +1 -1
  506. package/dist/extensions/minimax/provider-contract-api.d.ts +1 -1
  507. package/dist/extensions/minimax/provider-registration.d.ts +1 -1
  508. package/dist/extensions/minimax/speech-provider.d.ts +1 -1
  509. package/dist/extensions/mistral/embedding-provider.d.ts +1 -1
  510. package/dist/extensions/mistral/index.d.ts +1 -1
  511. package/dist/extensions/mistral/memory-embedding-adapter.d.ts +1 -1
  512. package/dist/extensions/mistral/realtime-transcription-provider.d.ts +1 -1
  513. package/dist/extensions/mistral/test-api.d.ts +1 -1
  514. package/dist/extensions/moonshot/index.d.ts +1 -1
  515. package/dist/extensions/moonshot/provider-contract-api.d.ts +1 -1
  516. package/dist/extensions/moonshot/provider-discovery.d.ts +1 -1
  517. package/dist/extensions/nvidia/index.d.ts +1 -1
  518. package/dist/extensions/oc-path/cli-metadata.d.ts +1 -1
  519. package/dist/extensions/oc-path/cli-registration.d.ts +1 -1
  520. package/dist/extensions/oc-path/index.d.ts +1 -1
  521. package/dist/extensions/ollama/api.d.ts +1 -1
  522. package/dist/extensions/ollama/index.d.ts +1 -1
  523. package/dist/extensions/ollama/provider-discovery.d.ts +1 -1
  524. package/dist/extensions/ollama/provider-policy-api.d.ts +1 -1
  525. package/dist/extensions/ollama/runtime-api.d.ts +1 -1
  526. package/dist/extensions/open-prose/index.d.ts +1 -1
  527. package/dist/extensions/open-prose/runtime-api.d.ts +2 -2
  528. package/dist/extensions/openai/api.d.ts +4 -4
  529. package/dist/extensions/openai/embedding-batch.d.ts +1 -1
  530. package/dist/extensions/openai/embedding-provider.d.ts +1 -1
  531. package/dist/extensions/openai/index.d.ts +1 -1
  532. package/dist/extensions/openai/memory-embedding-adapter.d.ts +1 -1
  533. package/dist/extensions/openai/openai-codex-oauth.runtime.d.ts +1 -1
  534. package/dist/extensions/openai/openai-codex-provider.d.ts +1 -1
  535. package/dist/extensions/openai/openai-provider.d.ts +1 -1
  536. package/dist/extensions/openai/prompt-overlay.d.ts +1 -1
  537. package/dist/extensions/openai/provider-contract-api.d.ts +1 -1
  538. package/dist/extensions/openai/provider-policy-api.d.ts +1 -1
  539. package/dist/extensions/openai/realtime-transcription-provider.d.ts +1 -1
  540. package/dist/extensions/openai/realtime-voice-provider.d.ts +1 -1
  541. package/dist/extensions/openai/register.runtime.d.ts +6 -6
  542. package/dist/extensions/openai/replay-policy.d.ts +1 -1
  543. package/dist/extensions/openai/setup-api.d.ts +1 -1
  544. package/dist/extensions/openai/shared.d.ts +3 -3
  545. package/dist/extensions/openai/speech-provider.d.ts +1 -1
  546. package/dist/extensions/openai/test-api.d.ts +3 -3
  547. package/dist/extensions/openai/thinking-policy.d.ts +1 -1
  548. package/dist/extensions/openai/transport-policy.d.ts +1 -1
  549. package/dist/extensions/opencode/index.d.ts +1 -1
  550. package/dist/extensions/opencode/provider-policy-api.d.ts +1 -1
  551. package/dist/extensions/opencode-go/index.d.ts +1 -1
  552. package/dist/extensions/opencode-go/provider-catalog.d.ts +1 -1
  553. package/dist/extensions/opencode-go/stream.d.ts +1 -1
  554. package/dist/extensions/openrouter/api.d.ts +1 -1
  555. package/dist/extensions/openrouter/index.d.ts +1 -1
  556. package/dist/extensions/openrouter/provider-contract-api.d.ts +1 -1
  557. package/dist/extensions/openrouter/provider-policy-api.d.ts +1 -1
  558. package/dist/extensions/openrouter/speech-provider.d.ts +1 -1
  559. package/dist/extensions/openrouter/stream.d.ts +1 -1
  560. package/dist/extensions/openrouter/test-api.d.ts +1 -1
  561. package/dist/extensions/openrouter/thinking-policy.d.ts +1 -1
  562. package/dist/extensions/openrouter/video-generation-provider.d.ts +1 -1
  563. package/dist/extensions/openrouter/video-model-catalog.d.ts +1 -1
  564. package/dist/extensions/perplexity/index.d.ts +1 -1
  565. package/dist/extensions/phone-control/index.d.ts +1 -1
  566. package/dist/extensions/phone-control/runtime-api.d.ts +2 -2
  567. package/dist/extensions/policy/api.js +1 -1
  568. package/dist/extensions/policy/index.d.ts +1 -1
  569. package/dist/extensions/policy/index.js +2 -2
  570. package/dist/extensions/qianfan/index.d.ts +1 -1
  571. package/dist/extensions/qwen/api.d.ts +1 -1
  572. package/dist/extensions/qwen/index.d.ts +1 -1
  573. package/dist/extensions/qwen/stream.d.ts +1 -1
  574. package/dist/extensions/runway/index.d.ts +1 -1
  575. package/dist/extensions/searxng/index.d.ts +1 -1
  576. package/dist/extensions/senseaudio/index.d.ts +1 -1
  577. package/dist/extensions/sglang/index.d.ts +1 -1
  578. package/dist/extensions/signal/api.d.ts +2 -2
  579. package/dist/extensions/signal/api.js +6 -6
  580. package/dist/extensions/signal/channel-entry.d.ts +2 -2
  581. package/dist/extensions/signal/channel-plugin-api.d.ts +1 -1
  582. package/dist/extensions/signal/channel-plugin-api.js +1 -1
  583. package/dist/extensions/signal/index.d.ts +2 -2
  584. package/dist/extensions/signal/reaction-runtime-api.js +1 -1
  585. package/dist/extensions/signal/runtime-api.d.ts +4 -4
  586. package/dist/extensions/signal/runtime-api.js +7 -7
  587. package/dist/extensions/signal/setup-entry.d.ts +2 -2
  588. package/dist/extensions/skill-workshop/api.d.ts +2 -2
  589. package/dist/extensions/skill-workshop/api.js +1 -1
  590. package/dist/extensions/skill-workshop/index.d.ts +1 -1
  591. package/dist/extensions/skill-workshop/index.js +2 -2
  592. package/dist/extensions/speech-core/api.d.ts +3 -3
  593. package/dist/extensions/speech-core/runtime-api.d.ts +2 -2
  594. package/dist/extensions/stepfun/index.d.ts +1 -1
  595. package/dist/extensions/synthetic/index.d.ts +1 -1
  596. package/dist/extensions/talk-voice/api.d.ts +2 -2
  597. package/dist/extensions/talk-voice/index.d.ts +1 -1
  598. package/dist/extensions/tavily/index.d.ts +1 -1
  599. package/dist/extensions/telegram/account-inspect-api.js +1 -1
  600. package/dist/extensions/telegram/api.d.ts +3 -3
  601. package/dist/extensions/telegram/api.js +11 -11
  602. package/dist/extensions/telegram/channel-plugin-api.d.ts +2 -2
  603. package/dist/extensions/telegram/channel-plugin-api.js +2 -2
  604. package/dist/extensions/telegram/contract-api.d.ts +1 -1
  605. package/dist/extensions/telegram/contract-api.js +3 -3
  606. package/dist/extensions/telegram/index.d.ts +2 -2
  607. package/dist/extensions/telegram/runtime-api.d.ts +3 -3
  608. package/dist/extensions/telegram/runtime-api.js +7 -7
  609. package/dist/extensions/telegram/security-audit-contract-api.js +1 -1
  610. package/dist/extensions/telegram/setup-entry.d.ts +2 -2
  611. package/dist/extensions/telegram/setup-plugin-api.d.ts +1 -1
  612. package/dist/extensions/telegram/setup-plugin-api.js +1 -1
  613. package/dist/extensions/telegram/test-api.js +2 -2
  614. package/dist/extensions/tencent/index.d.ts +1 -1
  615. package/dist/extensions/tencent/provider-discovery.d.ts +1 -1
  616. package/dist/extensions/thread-ownership/api.d.ts +2 -2
  617. package/dist/extensions/thread-ownership/index.d.ts +1 -1
  618. package/dist/extensions/together/index.d.ts +1 -1
  619. package/dist/extensions/tokenjuice/index.d.ts +1 -1
  620. package/dist/extensions/tokenjuice/tool-result-middleware.d.ts +1 -1
  621. package/dist/extensions/tts-local-cli/index.d.ts +1 -1
  622. package/dist/extensions/tts-local-cli/speech-provider.d.ts +1 -1
  623. package/dist/extensions/venice/index.d.ts +1 -1
  624. package/dist/extensions/venice/stream.d.ts +1 -1
  625. package/dist/extensions/vercel-ai-gateway/index.d.ts +1 -1
  626. package/dist/extensions/vercel-ai-gateway/thinking.d.ts +1 -1
  627. package/dist/extensions/video-generation-core/api.d.ts +2 -2
  628. package/dist/extensions/video-generation-core/runtime-api.d.ts +1 -1
  629. package/dist/extensions/vllm/api.d.ts +1 -1
  630. package/dist/extensions/vllm/index.d.ts +1 -1
  631. package/dist/extensions/vllm/stream.d.ts +1 -1
  632. package/dist/extensions/volcengine/index.d.ts +1 -1
  633. package/dist/extensions/volcengine/provider-discovery.d.ts +1 -1
  634. package/dist/extensions/volcengine/speech-provider.d.ts +1 -1
  635. package/dist/extensions/voyage/embedding-batch.d.ts +1 -1
  636. package/dist/extensions/voyage/embedding-provider.d.ts +1 -1
  637. package/dist/extensions/voyage/index.d.ts +1 -1
  638. package/dist/extensions/voyage/memory-embedding-adapter.d.ts +1 -1
  639. package/dist/extensions/vydra/index.d.ts +1 -1
  640. package/dist/extensions/vydra/speech-provider.d.ts +1 -1
  641. package/dist/extensions/web-readability/index.d.ts +1 -1
  642. package/dist/extensions/webhooks/api.d.ts +2 -2
  643. package/dist/extensions/webhooks/api.js +1 -1
  644. package/dist/extensions/webhooks/index.d.ts +1 -1
  645. package/dist/extensions/webhooks/index.js +1 -1
  646. package/dist/extensions/webhooks/runtime-api.d.ts +1 -1
  647. package/dist/extensions/xai/api.d.ts +1 -1
  648. package/dist/extensions/xai/index.d.ts +1 -1
  649. package/dist/extensions/xai/index.js +4 -4
  650. package/dist/extensions/xai/provider-contract-api.d.ts +1 -1
  651. package/dist/extensions/xai/provider-discovery.d.ts +1 -1
  652. package/dist/extensions/xai/provider-models.d.ts +1 -1
  653. package/dist/extensions/xai/provider-policy-api.d.ts +1 -1
  654. package/dist/extensions/xai/realtime-transcription-provider.d.ts +1 -1
  655. package/dist/extensions/xai/realtime-transcription-provider.js +1 -1
  656. package/dist/extensions/xai/setup-api.d.ts +1 -1
  657. package/dist/extensions/xai/speech-provider.d.ts +1 -1
  658. package/dist/extensions/xai/speech-provider.js +1 -1
  659. package/dist/extensions/xai/stream.d.ts +1 -1
  660. package/dist/extensions/xai/test-api.js +1 -1
  661. package/dist/extensions/xai/tts.js +1 -1
  662. package/dist/extensions/xai/web-search.js +1 -1
  663. package/dist/extensions/xai/xai-oauth.d.ts +1 -1
  664. package/dist/extensions/xai/xai-oauth.js +1 -1
  665. package/dist/extensions/xiaomi/index.d.ts +1 -1
  666. package/dist/extensions/xiaomi/speech-provider.d.ts +1 -1
  667. package/dist/extensions/xiaomi/stream.d.ts +1 -1
  668. package/dist/extensions/xiaomi/thinking.d.ts +1 -1
  669. package/dist/extensions/zai/index.d.ts +1 -1
  670. package/dist/file-fetch-tool-smMykVXl.js +124 -0
  671. package/dist/file-write-tool-yEYLZ2hU.js +127 -0
  672. package/dist/format-DyREJP5V.js +1145 -0
  673. package/dist/gateway/protocol/index.d.ts +1 -1
  674. package/dist/gateway-cli-D4yhwJa8.js +435 -0
  675. package/dist/gateway-method-runtime-B8AOnwqD.js +21 -0
  676. package/dist/gateway-runtime-COtKzRqi.d.ts +163 -0
  677. package/dist/gemini-cli-provider-BQgviROv.d.ts +6 -0
  678. package/dist/get-reply-Co-_Qlr-.js +4689 -0
  679. package/dist/get-reply-from-config.runtime-BcbRKxzJ.js +2 -0
  680. package/dist/get-reply-from-config.runtime.js +1 -1
  681. package/dist/graph-users-CF7Dlee2.js +1419 -0
  682. package/dist/group-access-BTU-w5S5.js +112 -0
  683. package/dist/handle-action.guild-admin-DS29y_6h.js +288 -0
  684. package/dist/harness-d9YmZWA3.js +61 -0
  685. package/dist/health-Cov1Kryj.js +4 -0
  686. package/dist/heartbeat-runner-B2wo_xDj.js +5 -0
  687. package/dist/heartbeat-runner.runtime-DrHZD-P2.js +4 -0
  688. package/dist/heartbeat-runner.runtime.js +1 -1
  689. package/dist/help-BgDd1atJ.js +136 -0
  690. package/dist/hooks-CgXKCJSD.js +534 -0
  691. package/dist/http-registry-Yo_NvKls.d.ts +23 -0
  692. package/dist/image-generation-runtime-BIAvq6jv.d.ts +21 -0
  693. package/dist/inbound-direct-dm-runtime-DjOHl6c_.js +2 -0
  694. package/dist/inbound-reply-dispatch-BCTiM2jm.js +148 -0
  695. package/dist/index-7GMgTC5k.d.ts +3971 -0
  696. package/dist/index.js +1 -1
  697. package/dist/init-CreYGHpp.js +59 -0
  698. package/dist/inline-buttons-C94TOhmL.js +40 -0
  699. package/dist/interactive-dispatch-ChuCQxzf.d.ts +56 -0
  700. package/dist/interactive-dispatch-DY_jVu-V.d.ts +143 -0
  701. package/dist/internal-events-B6D5bqsn.js +90 -0
  702. package/dist/isolated-agent-9faqxl7c.js +1118 -0
  703. package/dist/isolated-agent-CaY4uTcE.js +2 -0
  704. package/dist/lifecycle-pTz4liUn.js +571 -0
  705. package/dist/list.probe-B8pt-DOd.js +449 -0
  706. package/dist/list.status-command-Wgmt361J.js +789 -0
  707. package/dist/llm-slug-generator-Do4oXnXl.js +78 -0
  708. package/dist/llm-slug-generator.js +1 -1
  709. package/dist/loader-C-JyPvyF.d.ts +142 -0
  710. package/dist/local-dispatch.runtime-7keeuHHm.js +9 -0
  711. package/dist/local-dispatch.runtime.js +1 -1
  712. package/dist/manager-CknaUr2b.d.ts +356 -0
  713. package/dist/manager.runtime-B3nVh8Nl.js +2714 -0
  714. package/dist/manager.runtime.js +1 -1
  715. package/dist/markdown-to-line-CZLeX0SL.js +811 -0
  716. package/dist/mcp-http-LaAmzBev.js +2 -0
  717. package/dist/mcp-http-M4GjuKFd.js +555 -0
  718. package/dist/media-understanding-provider-DLA6VsQZ.js +339 -0
  719. package/dist/memory-core-host-engine-storage-izjrNFNA.d.ts +54 -0
  720. package/dist/memory-embedding-adapter-B3WLPdKc.d.ts +5 -0
  721. package/dist/message-actions-Dlv-B5yk.js +145 -0
  722. package/dist/message-handler-2HSbEoAi.js +384 -0
  723. package/dist/message-handler-XiApv_iS.js +1715 -0
  724. package/dist/message-handler.preflight-CN-g4nxs.js +1125 -0
  725. package/dist/message-handler.process-BzVq3Lq_.js +1484 -0
  726. package/dist/migration-DVKbowM8.d.ts +45 -0
  727. package/dist/model-BSBoLWjJ.d.ts +33 -0
  728. package/dist/model-Sqz99RFi.js +74 -0
  729. package/dist/model-selection-Bh9QtqlJ.js +272 -0
  730. package/dist/models-BvEw11kE.d.ts +24 -0
  731. package/dist/models-C_dD1FNN.js +2 -0
  732. package/dist/models-CtpB-fi2.js +104 -0
  733. package/dist/models-cli-I2sJE5tg.js +256 -0
  734. package/dist/monitor-B4J6Kn4-.js +60 -0
  735. package/dist/monitor-BIFxJ3Ql.js +2788 -0
  736. package/dist/monitor-BTkcXHvw.js +834 -0
  737. package/dist/monitor-BX7Encm5.js +1657 -0
  738. package/dist/monitor-CZsJ4D3J.js +4377 -0
  739. package/dist/monitor-CvKt9k7P.js +2 -0
  740. package/dist/monitor-Dy9phiVJ.js +1370 -0
  741. package/dist/monitor-auth-CjtJPc9C.js +179 -0
  742. package/dist/monitor-jQpVHEky.js +715 -0
  743. package/dist/monitor-polling.runtime-Li4-3e2G.js +883 -0
  744. package/dist/monitor-polling.runtime.js +1 -1
  745. package/dist/monitor-webhook.runtime-CQ2kN5ya.js +387 -0
  746. package/dist/monitor-webhook.runtime.js +1 -1
  747. package/dist/monitor.account-CFdazLEm.js +5233 -0
  748. package/dist/monitor.runtime-B774iFU_.js +2 -0
  749. package/dist/monitor.runtime.js +1 -1
  750. package/dist/monitor.webhook-NNrWA5P9.js +180 -0
  751. package/dist/node-cli-sessions-Ct-6bGab.js +1228 -0
  752. package/dist/onboard-DEUA1HCQ.js +733 -0
  753. package/dist/onboard-helpers-Cupkjkec.js +251 -0
  754. package/dist/onboard-helpers-D1Pvowo1.js +6 -0
  755. package/dist/onboard-remote-BN_7wNqG.js +2 -0
  756. package/dist/onboard-remote-BqYAK5dF.js +212 -0
  757. package/dist/onboard-skills-BM40qOkc.js +160 -0
  758. package/dist/onboard-skills-rSLgDOzB.js +2 -0
  759. package/dist/openai-codex-provider-C48t8ka8.d.ts +5 -0
  760. package/dist/openai-http-BRnxRJ_y.js +824 -0
  761. package/dist/openai-provider-Df75q4KM.d.ts +5 -0
  762. package/dist/openresponses-http-Dg3OL0qA.js +1173 -0
  763. package/dist/operations-jvr0A8cu.js +805 -0
  764. package/dist/outbound-adapter-BJej9JpO.js +543 -0
  765. package/dist/outbound-session-route-D3QVwFKr.js +45 -0
  766. package/dist/outbound.runtime-gdOoPtOh.js +2 -0
  767. package/dist/outbound.runtime.js +1 -1
  768. package/dist/pi-embedded-CwD_xrGP.js +3796 -0
  769. package/dist/pi-embedded-DL6l8KBl.js +4 -0
  770. package/dist/pi-embedded.runtime-DyGCj24d.js +4 -0
  771. package/dist/pi-embedded.runtime.js +1 -1
  772. package/dist/pi-tools-BzbgexEG.js +2413 -0
  773. package/dist/plan-HWBV2Rhq.js +112 -0
  774. package/dist/plan-iN77JYw-.js +81 -0
  775. package/dist/plugin-CbNvjum_.js +12396 -0
  776. package/dist/plugin-DMYsMKAW.d.ts +17 -0
  777. package/dist/plugin-app-cache-key-CHpwYM0e.js +46 -0
  778. package/dist/plugin-enabled-DjbDhNRG.js +233 -0
  779. package/dist/plugin-entry-DwVZtdM9.d.ts +47 -0
  780. package/dist/plugin-registration-BM_Iko3e.js +88 -0
  781. package/dist/plugin-runtime-Dx9WRWX8.d.ts +117 -0
  782. package/dist/plugin-sdk/.boundary-entry-shims.stamp +1 -1
  783. package/dist/plugin-sdk/acp-runtime-backend.js +1 -1
  784. package/dist/plugin-sdk/acp-runtime.js +2 -2
  785. package/dist/plugin-sdk/agent-harness-runtime.js +6 -6
  786. package/dist/plugin-sdk/agent-harness-task-runtime.js +1 -1
  787. package/dist/plugin-sdk/agent-harness.js +7 -7
  788. package/dist/plugin-sdk/agent-runtime.js +2 -2
  789. package/dist/plugin-sdk/channel-core.js +2 -2
  790. package/dist/plugin-sdk/channel-inbound.js +2 -2
  791. package/dist/plugin-sdk/channel-test-helpers.js +1 -1
  792. package/dist/plugin-sdk/command-auth.js +1 -1
  793. package/dist/plugin-sdk/command-status-runtime.js +1 -1
  794. package/dist/plugin-sdk/compat.js +1 -1
  795. package/dist/plugin-sdk/conversation-binding-runtime.js +2 -2
  796. package/dist/plugin-sdk/conversation-runtime.js +3 -3
  797. package/dist/plugin-sdk/core.js +2 -2
  798. package/dist/plugin-sdk/direct-dm.js +1 -1
  799. package/dist/plugin-sdk/gateway-method-runtime.js +1 -1
  800. package/dist/plugin-sdk/health.js +2 -2
  801. package/dist/plugin-sdk/inbound-reply-dispatch.js +1 -1
  802. package/dist/plugin-sdk/index.js +1 -1
  803. package/dist/plugin-sdk/mattermost.js +1 -1
  804. package/dist/plugin-sdk/plugin-test-contracts.js +2 -2
  805. package/dist/plugin-sdk/provider-test-contracts.js +4 -4
  806. package/dist/plugin-sdk/reply-runtime.js +4 -4
  807. package/dist/plugin-sdk/testing.js +2 -2
  808. package/dist/plugin-sdk/zalouser.js +1 -1
  809. package/dist/plugin-service-CVyMm03C.js +1229 -0
  810. package/dist/plugin-service-mHunWjlo.d.ts +24 -0
  811. package/dist/plugins/build-smoke-entry.d.ts +2 -2
  812. package/dist/plugins/loader.d.ts +1 -1
  813. package/dist/plugins/provider-discovery.runtime.d.ts +1 -1
  814. package/dist/plugins/provider-runtime.runtime.d.ts +1 -1
  815. package/dist/plugins/runtime/index.js +4 -4
  816. package/dist/policy-B2lTxn8H.js +680 -0
  817. package/dist/policy-Bp9GYcSZ.js +138 -0
  818. package/dist/prepare.runtime-CxhQeo9l.js +732 -0
  819. package/dist/prepare.runtime.js +1 -1
  820. package/dist/preview-warnings-FVRS7Mcs.js +392 -0
  821. package/dist/probe-BRLc43oX.js +47 -0
  822. package/dist/probe-C1eD9yG7.js +2204 -0
  823. package/dist/probe-C1giMJtz.js +682 -0
  824. package/dist/probe-rIUNPFef.js +2 -0
  825. package/dist/program-DfIqBXRH.js +131 -0
  826. package/dist/prompt-overlay-D0r0EA6z.d.ts +23 -0
  827. package/dist/provider-BCxvG42s.js +152 -0
  828. package/dist/provider-BHPMcHk-.js +32 -0
  829. package/dist/provider-CIAQ8D7q.js +32 -0
  830. package/dist/provider-api-key-auth-2Fp25hP8.d.ts +27 -0
  831. package/dist/provider-auth-result-mIg6RY-l.d.ts +21 -0
  832. package/dist/provider-catalog-runtime-B7e02aat.d.ts +23 -0
  833. package/dist/provider-catalog-shared-D0mIMF1C.d.ts +62 -0
  834. package/dist/provider-dispatcher-DyJDef6y.js +22 -0
  835. package/dist/provider-dispatcher.runtime.js +1 -1
  836. package/dist/provider-hook-runtime-CrtHxgL6.d.ts +61 -0
  837. package/dist/provider-j7cYms68.js +8735 -0
  838. package/dist/provider-model-shared-BESf3jvo.d.ts +143 -0
  839. package/dist/provider-models-B6wofKVD.d.ts +12 -0
  840. package/dist/provider-policy-0JjxJfxh.d.ts +30 -0
  841. package/dist/provider-registration-O7mvATZX.d.ts +6 -0
  842. package/dist/provider-registry-CtFVQxwM.d.ts +8 -0
  843. package/dist/provider-registry-DZxCJHb2.d.ts +8 -0
  844. package/dist/provider-registry-DcUASGbX.d.ts +30 -0
  845. package/dist/provider-runtime-CrrstiDP.d.ts +359 -0
  846. package/dist/provider-self-hosted-setup-DKlGE8A7.d.ts +74 -0
  847. package/dist/provider-session.runtime-CmNY15Mr.js +9 -0
  848. package/dist/provider-session.runtime.js +1 -1
  849. package/dist/provider-stream-C2vPdKh5.d.ts +140 -0
  850. package/dist/provider-stream-shared-CslVTt39.d.ts +128 -0
  851. package/dist/provider.runtime-DJO3dwrX.js +2 -0
  852. package/dist/provider.runtime.js +1 -1
  853. package/dist/providers.runtime-CHPPEG1J.d.ts +25 -0
  854. package/dist/public-surface-loader-CgBnme5n.js +114 -0
  855. package/dist/pw-ai-UeRWGzcL.js +3029 -0
  856. package/dist/pw-role-snapshot-BtlutwlO.js +333 -0
  857. package/dist/reaction-level-DWOV-qJM.js +19 -0
  858. package/dist/reaction-runtime-api-5ZiPcbGJ.js +116 -0
  859. package/dist/realtime-transcription-Brox5yj7.d.ts +43 -0
  860. package/dist/realtime-transcription-provider-B9DWwCuO.d.ts +32 -0
  861. package/dist/realtime-transcription-provider-CGhoGie3.d.ts +28 -0
  862. package/dist/realtime-transcription-provider-Dau7Zk9V.d.ts +37 -0
  863. package/dist/realtime-transcription-provider-DcsAmQEp.js +205 -0
  864. package/dist/realtime-transcription-provider-WgtPbRJc.d.ts +5 -0
  865. package/dist/realtime-voice-C5Xiylos.d.ts +333 -0
  866. package/dist/realtime-voice-provider-DUPM9wyW.d.ts +5 -0
  867. package/dist/register-Dga1nJRL.js +2178 -0
  868. package/dist/register.agent-VIgyZLKG.js +156 -0
  869. package/dist/register.configure-C21zJ4Qb.js +16 -0
  870. package/dist/register.crestodian-Bam6mUXr.js +24 -0
  871. package/dist/register.maintenance-D9E-Hh90.js +83 -0
  872. package/dist/register.onboard-BnUcaZsb.js +113 -0
  873. package/dist/register.runtime-BcgdXzLA.d.ts +6 -0
  874. package/dist/register.runtime-BdRAp4xz.js +54 -0
  875. package/dist/register.setup-Bq-9IQdV.js +40 -0
  876. package/dist/register.subclis-DubBtg8Z.js +31 -0
  877. package/dist/register.subclis-H_qmmDFx.js +3 -0
  878. package/dist/register.subclis-core-fg3DalSH.js +273 -0
  879. package/dist/registry-DnnBulh_.d.ts +91 -0
  880. package/dist/registry-types-BQ26lhRo.d.ts +392 -0
  881. package/dist/repair-sequencing-Dn0sDvBE.js +640 -0
  882. package/dist/reply-delivery-DZGfRh-W.js +196 -0
  883. package/dist/reply-runtime-BdCPL-OF.js +11 -0
  884. package/dist/reply.runtime-BcbRKxzJ.js +2 -0
  885. package/dist/reply.runtime.js +1 -1
  886. package/dist/request-Ca681Kt1.js +54 -0
  887. package/dist/resolve-allowlist-DWjCzDq1.js +220 -0
  888. package/dist/result-fallback-classifier-BWIh0wzc.js +79 -0
  889. package/dist/root-help-8a3TWleF.js +43 -0
  890. package/dist/route-BsWREv6-.js +469 -0
  891. package/dist/route-resolution-D8FyF30I.js +274 -0
  892. package/dist/routes-BxkaJuyM.js +3602 -0
  893. package/dist/routes-DdwFgSv9.js +2 -0
  894. package/dist/run-attempt-Ca7HP1Nd.js +7704 -0
  895. package/dist/run-command-JwrnqCIB.js +2 -0
  896. package/dist/run-command-wWvfXyIf.js +23 -0
  897. package/dist/run-embedded.runtime-0QIAc8PG.js +4 -0
  898. package/dist/run-embedded.runtime.js +1 -1
  899. package/dist/run-execution-cli.runtime-LhD-S0h_.js +4 -0
  900. package/dist/run-execution-cli.runtime.js +1 -1
  901. package/dist/run-executor.runtime.js +1 -1
  902. package/dist/run-prKMVvM2.js +1162 -0
  903. package/dist/run-subagent-registry.runtime-C07jSlV2.js +2 -0
  904. package/dist/run-subagent-registry.runtime.js +1 -1
  905. package/dist/runtime-7Xhj2T8S.js +6179 -0
  906. package/dist/runtime-CXUwJU3q.js +438 -0
  907. package/dist/runtime-DeQypuDs.js +1287 -0
  908. package/dist/runtime-api-0djTIsuz.js +13 -0
  909. package/dist/runtime-api-Bz1h0p3i.js +17 -0
  910. package/dist/runtime-api-CLcJZKu2.js +13 -0
  911. package/dist/runtime-api-Ce7axAAW.js +24 -0
  912. package/dist/runtime-api-CoAsju8a.js +4 -0
  913. package/dist/runtime-api-DEuynhDr.js +3 -0
  914. package/dist/runtime-api-oZFIOS9l.js +21 -0
  915. package/dist/runtime-api.actions-DWLRlSej.js +3 -0
  916. package/dist/runtime-api.monitor-DtXB3_sf.js +6 -0
  917. package/dist/runtime-api.send-BU586hbs.js +4 -0
  918. package/dist/runtime-api.threads-Djhr5AJy.js +2 -0
  919. package/dist/runtime-channel-BIgBTs_X.js +2 -0
  920. package/dist/runtime-channel-CsUTBjYU.js +150 -0
  921. package/dist/runtime-embedded-pi.runtime-Rszd_KCt.js +2 -0
  922. package/dist/runtime-embedded-pi.runtime.js +1 -1
  923. package/dist/runtime-taskflow-Co1PrqbP.d.ts +435 -0
  924. package/dist/sanitize-outbound-2umQeW_U.js +127 -0
  925. package/dist/sdk-setup-tools-TiaNam05.js +8 -0
  926. package/dist/secrets-BmyFSkt-.js +113 -0
  927. package/dist/secrets-cli-DPAwFvtH.js +149 -0
  928. package/dist/security-audit-BR9FBcLD.js +122 -0
  929. package/dist/security-audit-RKut1lWG.js +118 -0
  930. package/dist/security-audit.runtime-Pe7YbS9P.js +2 -0
  931. package/dist/security-audit.runtime.js +1 -1
  932. package/dist/selection-Cqhmjpyl.js +16157 -0
  933. package/dist/selection-xFFMaq92.js +3 -0
  934. package/dist/send-BDHagrwl.js +1631 -0
  935. package/dist/send-BV_O_Ljd.js +192 -0
  936. package/dist/send-W-DVyil6.js +2 -0
  937. package/dist/send-jUp2-szO.js +143 -0
  938. package/dist/send.components-BR_yPtKv.js +500 -0
  939. package/dist/send.components-CK7UbpRP.js +2 -0
  940. package/dist/send.runtime-DHLfdHbS.js +2 -0
  941. package/dist/send.runtime.js +1 -1
  942. package/dist/server-DRcdRu6J.js +73 -0
  943. package/dist/server-Ddv-oAKv.js +24 -0
  944. package/dist/server-close.runtime.d.ts +1 -1
  945. package/dist/server-close.runtime.js +1 -1
  946. package/dist/server-context-9rW0Cvdw.js +2 -0
  947. package/dist/server-context-uRD5N8_D.js +955 -0
  948. package/dist/server-cron-BClEPtbv.js +2 -0
  949. package/dist/server-cron-CNGar45o.js +2989 -0
  950. package/dist/server-methods-CAMhJf7g.js +16494 -0
  951. package/dist/server-node-events-DW5DoAxk.js +596 -0
  952. package/dist/server-plugin-bootstrap-CqX4dDcN.js +70 -0
  953. package/dist/server-plugins-BIhs3eCz.js +432 -0
  954. package/dist/server-reload-handlers-54HSfSr7.js +714 -0
  955. package/dist/server-restart-sentinel-C47-O08k.js +747 -0
  956. package/dist/server-restart-sentinel-Cx-3Rzl0.js +2 -0
  957. package/dist/server-runtime-services-D-SWzUww.js +267 -0
  958. package/dist/server-runtime-services-D0GOFPFq.js +2 -0
  959. package/dist/server-startup-plugins-C8pzVvkb.js +113 -0
  960. package/dist/server-startup-post-attach-2xoGJJts.js +716 -0
  961. package/dist/server-ws-runtime-Dywo6GC-.js +349 -0
  962. package/dist/server.impl-xK22fZyJ.js +2586 -0
  963. package/dist/service-Ci8roOZn.js +1446 -0
  964. package/dist/session-binding-BsdbGBhb.js +219 -0
  965. package/dist/session-binding-D42jROcb.js +2 -0
  966. package/dist/session-kill-http-kU4rUj1_.js +121 -0
  967. package/dist/session-reset-service-DkCGElAA.js +625 -0
  968. package/dist/session-route-hmQSEijy.js +93 -0
  969. package/dist/session-status.runtime-Dsz-54he.js +2 -0
  970. package/dist/session-status.runtime.js +1 -1
  971. package/dist/session-subagent-reactivation.runtime-CYJIkiW8.js +2 -0
  972. package/dist/session-subagent-reactivation.runtime.js +1 -1
  973. package/dist/session-tab-registry-YfQve--K.js +521 -0
  974. package/dist/sessions-history-http-DeuZSSGj.js +430 -0
  975. package/dist/sessions.runtime-wAccC8Lk.js +2 -0
  976. package/dist/sessions.runtime.js +1 -1
  977. package/dist/setup-B8caUFIZ.js +586 -0
  978. package/dist/setup-CgHGdMpV.js +2 -0
  979. package/dist/setup-api-Uew7qBry.js +29 -0
  980. package/dist/setup-core-BP_fjsmA.js +174 -0
  981. package/dist/setup-onboard-configure-help-fast-path-ykLp2JqU.js +64 -0
  982. package/dist/setup-surface-BgEGrdZ3.js +320 -0
  983. package/dist/setup-surface-BvSqsFEu.js +221 -0
  984. package/dist/setup-surface-CHzMJ7_T.js +405 -0
  985. package/dist/setup-surface-DYm3Xvgt.js +288 -0
  986. package/dist/setup.finalize-BgLIjblM.js +582 -0
  987. package/dist/setup.gateway-config-BBguRpIc.js +281 -0
  988. package/dist/setup.migration-import-BY06brv-.js +200 -0
  989. package/dist/setup.migration-import-Igj5NMey.js +2 -0
  990. package/dist/shared-2-FiBN51.d.ts +115 -0
  991. package/dist/shared-client-GL2KQ2Eu.js +2 -0
  992. package/dist/shared-client-Mc7bTBoQ.js +629 -0
  993. package/dist/shared-moi7PK0C.js +121 -0
  994. package/dist/side-question-BEHswpGw.js +683 -0
  995. package/dist/simple-completion-runtime-JMnVclQ6.d.ts +73 -0
  996. package/dist/skill-tool-dispatch.runtime-O5uXeees.js +143 -0
  997. package/dist/skill-tool-dispatch.runtime.js +1 -1
  998. package/dist/slash-state-BAYUTcHl.js +2166 -0
  999. package/dist/speech-CmQkc7zi.d.ts +47 -0
  1000. package/dist/speech-core-CVkLGUxG.d.ts +36 -0
  1001. package/dist/speech-provider-22oDk8Tz.js +184 -0
  1002. package/dist/speech-provider-B73iu4fH.d.ts +5 -0
  1003. package/dist/speech-provider-BEBH8vyF.d.ts +34 -0
  1004. package/dist/speech-provider-BhCRdoMK.d.ts +8 -0
  1005. package/dist/speech-provider-Cf1PVMAj.d.ts +8 -0
  1006. package/dist/speech-provider-DdEPWhuR.d.ts +5 -0
  1007. package/dist/speech-provider-ECom8JiZ.d.ts +5 -0
  1008. package/dist/src-C8wkJgE6.js +4256 -0
  1009. package/dist/startup-context-BhLJufFU.js +313 -0
  1010. package/dist/status-C20LHDLA.js +73 -0
  1011. package/dist/status-message-CmzgS8zM.js +484 -0
  1012. package/dist/status-message.runtime-iG6qi7wn.js +6 -0
  1013. package/dist/status-message.runtime.js +1 -1
  1014. package/dist/status-subagents.runtime-D49P_RIr.js +18 -0
  1015. package/dist/status-subagents.runtime.js +1 -1
  1016. package/dist/status-text-BI7Q1z4U.js +296 -0
  1017. package/dist/status.runtime-RQes0TI5.js +2 -0
  1018. package/dist/sticker-cache-Dh4joqan.js +206 -0
  1019. package/dist/sticker-vision.runtime-5SRgpo_k.js +17 -0
  1020. package/dist/sticker-vision.runtime.js +1 -1
  1021. package/dist/stream-CYHgCxMh.d.ts +5 -0
  1022. package/dist/stream-D8Ytt_tB.d.ts +120 -0
  1023. package/dist/stream-DX9I-gkW.d.ts +19 -0
  1024. package/dist/stream-DjL6Gw2C.d.ts +16 -0
  1025. package/dist/stream-m7GKt3W2.d.ts +10 -0
  1026. package/dist/stream-wrappers-UyEQes6p.d.ts +21 -0
  1027. package/dist/subagent-announce-BEPlkjCS.js +354 -0
  1028. package/dist/subagent-announce-delivery-jcxPIfNG.js +958 -0
  1029. package/dist/subagent-control-DdMWVJXs.js +508 -0
  1030. package/dist/subagent-hooks-BsTVb6ur.js +2 -0
  1031. package/dist/subagent-hooks-CBlMBrss.js +2 -0
  1032. package/dist/subagent-hooks-Ch5oDUxb.js +116 -0
  1033. package/dist/subagent-hooks-DmUeAwY3.js +146 -0
  1034. package/dist/subagent-hooks-PNuPbYEl.js +2 -0
  1035. package/dist/subagent-hooks-api-BQ051dF0.js +23 -0
  1036. package/dist/subagent-hooks-api-DcVS0aJZ.js +22 -0
  1037. package/dist/subagent-hooks-api-Dlbc5Mtd.js +23 -0
  1038. package/dist/subagent-hooks-dwsegI07.js +230 -0
  1039. package/dist/subagent-orphan-recovery-Cl_y6Poi.js +352 -0
  1040. package/dist/subagent-registry-BosUdBW6.js +2351 -0
  1041. package/dist/subagent-registry-Bxd6vaAO.js +3 -0
  1042. package/dist/subagent-registry.runtime.js +1 -1
  1043. package/dist/subagent-session-cleanup-Bd6d93qi.js +525 -0
  1044. package/dist/subagent-spawn-ViO3XAR1.js +1164 -0
  1045. package/dist/target-id-Bje_v2Ax.js +107 -0
  1046. package/dist/targets-C4byiOgQ.js +19 -0
  1047. package/dist/targets-D-0Biv4s.d.ts +10 -0
  1048. package/dist/targets-J0MVE-dD.js +44 -0
  1049. package/dist/targets-S-Pmze3w.d.ts +10 -0
  1050. package/dist/targets-ZMEvyNa8.js +19 -0
  1051. package/dist/task-registry-control.runtime.js +1 -1
  1052. package/dist/telegram/token.js +1 -1
  1053. package/dist/testing-Dk757Ggg.js +267 -0
  1054. package/dist/thinking-policy-B31-nCQk.d.ts +5 -0
  1055. package/dist/thread-bindings-CYrmTzFY.js +232 -0
  1056. package/dist/thread-bindings-Cf7fkXxk.js +571 -0
  1057. package/dist/thread-bindings-DI6LNGbW.js +8 -0
  1058. package/dist/thread-bindings-DdmuKtVD.js +228 -0
  1059. package/dist/thread-bindings.discord-api-C01V3kFk.js +187 -0
  1060. package/dist/thread-bindings.manager--WOGVrL-.js +2 -0
  1061. package/dist/thread-bindings.manager-HzjqZNiL.js +536 -0
  1062. package/dist/thread-lifecycle-CJKTxWnQ.js +1614 -0
  1063. package/dist/token-D-FQ8AQz.js +134 -0
  1064. package/dist/tool-DTCfs0DU.js +139 -0
  1065. package/dist/tool-actions.runtime-Cb3iA3Os.js +534 -0
  1066. package/dist/tool-actions.runtime.js +1 -1
  1067. package/dist/tool-plugin-B9aQw4fj.d.ts +77 -0
  1068. package/dist/tool-resolution-CbqzNutV.js +149 -0
  1069. package/dist/tool-split-zov3PauL.d.ts +19 -0
  1070. package/dist/tools-effective-inventory-BsAax-ML.js +204 -0
  1071. package/dist/tools-invoke-http-DAqZxikd.js +67 -0
  1072. package/dist/tools-invoke-shared-CsVRemTL.js +200 -0
  1073. package/dist/transport-stream-3OMu_lV2.d.ts +42 -0
  1074. package/dist/tts-Ckj6MJNr.js +66 -0
  1075. package/dist/tui-CwwCXMCq.js +2 -0
  1076. package/dist/tui-DpJn3v2D.js +4709 -0
  1077. package/dist/tui-backend-DQ9wF5es.js +256 -0
  1078. package/dist/tui-cli-k3AYPBn3.js +37 -0
  1079. package/dist/types-D3enA0Vx.d.ts +786 -0
  1080. package/dist/types-DHSQkzyq2.d.ts +3650 -0
  1081. package/dist/types.public-DHQb4Kl9.d.ts +70 -0
  1082. package/dist/update-cli-DB5Doqld.js +3664 -0
  1083. package/dist/video-generation-runtime-Dj060lga.d.ts +21 -0
  1084. package/dist/video-model-catalog-CQ-f89xh.d.ts +16 -0
  1085. package/dist/vision-tools-Dp0JrLRi.js +1409 -0
  1086. package/dist/web-search-B0yvxuiq.js +62 -0
  1087. package/dist/web-search-provider.runtime-B-cNT-5J.js +2 -0
  1088. package/dist/web-search-provider.runtime-HhmIlk_Z.js +328 -0
  1089. package/dist/web-search-provider.runtime.js +1 -1
  1090. package/dist/webhook-targets-CW4Nl_cq.d.ts +99 -0
  1091. package/dist/xai-oauth-cZGjnEjh.js +479 -0
  1092. package/dist/xai-user-agent-DA8le6vP.js +32 -0
  1093. package/package.json +1 -1
  1094. package/dist/abort-CvuLeqr1.js +0 -277
  1095. package/dist/abort.runtime-DNoavlKn.js +0 -2
  1096. package/dist/account-inspect-ByX21U_z.js +0 -173
  1097. package/dist/accounts-B0sjdn0w.js +0 -119
  1098. package/dist/accounts-BF_AfTED.js +0 -107
  1099. package/dist/accounts-DX1c8NKM.js +0 -107
  1100. package/dist/accounts-EA2GGTep.js +0 -2
  1101. package/dist/acp-runtime-BC8oA7xM.js +0 -26
  1102. package/dist/acp-spawn-CPYDCZ95.js +0 -2
  1103. package/dist/acp-spawn-Cqi47GCL.js +0 -1275
  1104. package/dist/acp-stateful-target-driver-CcWMRAQ2.js +0 -89
  1105. package/dist/action-kill-CZrPfOIS.js +0 -33
  1106. package/dist/action-runtime-DuhVKLRJ.js +0 -469
  1107. package/dist/action-runtime-api-BKaUWi7b.js +0 -2
  1108. package/dist/action-send-_NpIHMwj.js +0 -39
  1109. package/dist/action-spawn-Dymn4rUo.js +0 -47
  1110. package/dist/actions-Bk_WaEAa.js +0 -161
  1111. package/dist/actions.runtime-Hh7HYOlJ.js +0 -5
  1112. package/dist/agent-CQzGVmy1.js +0 -2
  1113. package/dist/agent-ClmYyW81.js +0 -3
  1114. package/dist/agent-command-DbU2fo-p.js +0 -1367
  1115. package/dist/agent-components.runtime-BpXJmJXk.js +0 -10
  1116. package/dist/agent-harness-D8c6PLE_.d.ts +0 -146
  1117. package/dist/agent-harness-runtime-AHXS4Jj3.d.ts +0 -691
  1118. package/dist/agent-harness-runtime-TzbK9YTz.js +0 -180
  1119. package/dist/agent-harness-task-runtime-CZWJEsKk.js +0 -140
  1120. package/dist/agent-runner-execution-CmHT78Vr.js +0 -1713
  1121. package/dist/agent-runner-utils-B0i1PW18.js +0 -266
  1122. package/dist/agent-runner.runtime-B6Ah_MlB.js +0 -3455
  1123. package/dist/agent-runtime-BOMioAX6.js +0 -229
  1124. package/dist/agent-via-gateway-DfxQCPit.js +0 -463
  1125. package/dist/agents.commands.add-CszEBxoJ.js +0 -304
  1126. package/dist/agents.commands.delete-ulnJ7RH9.js +0 -128
  1127. package/dist/api-6SmEQDkK.js +0 -134
  1128. package/dist/api-B7QdoMF5.js +0 -2
  1129. package/dist/api-BBgby6ck.js +0 -639
  1130. package/dist/api-DwKV-xfM.d.ts +0 -52
  1131. package/dist/api-RfjCqA7Y.js +0 -6
  1132. package/dist/api-VDkFlOiv.js +0 -2
  1133. package/dist/api-We4xoZFr.js +0 -3
  1134. package/dist/apply-Cgtzilem.js +0 -41
  1135. package/dist/apply-Csp3U8cA.js +0 -54
  1136. package/dist/approval-handler.runtime-aQaSBbpF.js +0 -130
  1137. package/dist/assistant-UMyirSUH.js +0 -291
  1138. package/dist/attachment-normalize-BupK-_Ox.js +0 -225
  1139. package/dist/attempt-execution-oLlyFjHk.js +0 -558
  1140. package/dist/attempt-execution.runtime-Cq8RE0x_.js +0 -3
  1141. package/dist/attempt-execution.shared-DyBzUJGB.js +0 -38
  1142. package/dist/attempt.prompt-helpers-CVBP6t5J.js +0 -475
  1143. package/dist/attempt.tool-run-context-UU1BUUC9.js +0 -2094
  1144. package/dist/auth-BDaK_y-g.js +0 -541
  1145. package/dist/banner-VbID973v.js +0 -2
  1146. package/dist/banner-W77piyz6.js +0 -397
  1147. package/dist/binding-routing-DahKvjr3.js +0 -113
  1148. package/dist/binding-targets-C3mqUdUT.js +0 -121
  1149. package/dist/bot-DonUKEuy.js +0 -7894
  1150. package/dist/bot-deps-CroXwZeM.js +0 -747
  1151. package/dist/bot-deps-DKoy3x0l.js +0 -2
  1152. package/dist/bot-message-context.runtime-BI_zyqDu.js +0 -7
  1153. package/dist/bot-message-context.session.runtime-Cpy2H9Ez.js +0 -12
  1154. package/dist/bot-native-commands.delivery.runtime-CsHg3h1O.js +0 -4
  1155. package/dist/bot-native-commands.runtime-rmoBpwZY.js +0 -13
  1156. package/dist/bridge-server-BmDNWgHD.js +0 -113
  1157. package/dist/browser-cli-BQLwmLw3.js +0 -2
  1158. package/dist/browser-cli-CHHIN-of.js +0 -230
  1159. package/dist/browser-cli-actions-input-DBZ7uwag.js +0 -473
  1160. package/dist/browser-cli-actions-observe-BdH2-WTk.js +0 -81
  1161. package/dist/browser-cli-debug-C82Apbgb.js +0 -137
  1162. package/dist/browser-cli-inspect-CrO1qca7.js +0 -104
  1163. package/dist/browser-cli-manage-Dgm1IUZT.js +0 -443
  1164. package/dist/browser-cli-resize-DqgMr3DY.js +0 -26
  1165. package/dist/browser-cli-shared-BTnXMCKA.js +0 -50
  1166. package/dist/browser-cli-state-DT3bVOtg.js +0 -337
  1167. package/dist/browser-control-auth-BRwKCt45.js +0 -2
  1168. package/dist/browser-profiles-DhGtxK9v.js +0 -2
  1169. package/dist/browser-runtime-BL6b-qtr.js +0 -384
  1170. package/dist/build-33AnG55F.js +0 -257
  1171. package/dist/call-dct8amtn.d.ts +0 -43
  1172. package/dist/capability-cli-D-KoVyyP.js +0 -1782
  1173. package/dist/channel-0tgrzPag.js +0 -867
  1174. package/dist/channel-4g20sJKJ.d.ts +0 -104
  1175. package/dist/channel-6tG8jWsw.d.ts +0 -8
  1176. package/dist/channel-7OEbQ8xS.d.ts +0 -6
  1177. package/dist/channel-7rVapSdN.d.ts +0 -8
  1178. package/dist/channel-B1fZN0iI.d.ts +0 -427
  1179. package/dist/channel-B5Q7fRiN.js +0 -1134
  1180. package/dist/channel-BEg_0h_C.d.ts +0 -12
  1181. package/dist/channel-BNp1J_eZ.js +0 -376
  1182. package/dist/channel-BP6RWm-M.d.ts +0 -47
  1183. package/dist/channel-BRjqrJfj.d.ts +0 -49
  1184. package/dist/channel-BUoyH_tP.d.ts +0 -114
  1185. package/dist/channel-BVBG4Tmn.d.ts +0 -28
  1186. package/dist/channel-Bap23sAx.js +0 -481
  1187. package/dist/channel-BhZ7x0SB.d.ts +0 -26
  1188. package/dist/channel-Bxod9CjX.js +0 -508
  1189. package/dist/channel-C6LASGjS.js +0 -808
  1190. package/dist/channel-COWZEKCw.js +0 -1249
  1191. package/dist/channel-CRAIreZ3.js +0 -238
  1192. package/dist/channel-CVY2hnJh.js +0 -1556
  1193. package/dist/channel-CgKdh_Jd.d.ts +0 -106
  1194. package/dist/channel-Cxo62btA.js +0 -1496
  1195. package/dist/channel-D5SzoyWI.js +0 -562
  1196. package/dist/channel-DE4vIsYF.d.ts +0 -64
  1197. package/dist/channel-DOdRHxJg.js +0 -1777
  1198. package/dist/channel-DZygtXdy.js +0 -362
  1199. package/dist/channel-DfhOnM71.d.ts +0 -7
  1200. package/dist/channel-DhZiptRe.d.ts +0 -8
  1201. package/dist/channel-DqPZviVV.js +0 -2126
  1202. package/dist/channel-Dssy3NQA.js +0 -740
  1203. package/dist/channel-actions.runtime-CDaMC9SV.js +0 -265
  1204. package/dist/channel-buMY8xZQ.d.ts +0 -7
  1205. package/dist/channel-core-CBhC_PNR.js +0 -5
  1206. package/dist/channel-core-x9b94azO.d.ts +0 -6
  1207. package/dist/channel-cvGHll3-.js +0 -955
  1208. package/dist/channel-entry-contract-BfZdcgTS.d.ts +0 -112
  1209. package/dist/channel-inbound-CNdyzYlz.js +0 -80
  1210. package/dist/channel-l8amaSI9.js +0 -653
  1211. package/dist/channel-plugin-runtime-CvcVGjj4.js +0 -998
  1212. package/dist/channel-plugin-runtime-D5n9A86n.d.ts +0 -7
  1213. package/dist/channel-runtime-BAbg8Dcv.js +0 -408
  1214. package/dist/channel-sWtDTVwd.d.ts +0 -14
  1215. package/dist/channel.runtime-9o-iF8zm.js +0 -2528
  1216. package/dist/channel.runtime-BotO7RD0.js +0 -21009
  1217. package/dist/channel.runtime-BrDb4cP8.js +0 -88
  1218. package/dist/channel.runtime-C1cLfrDt.js +0 -254
  1219. package/dist/channel.runtime-CTM3VO2E.js +0 -4
  1220. package/dist/channel.runtime-CnodqvCJ.js +0 -733
  1221. package/dist/channel.runtime-Dmr8503H.js +0 -1008
  1222. package/dist/channel.runtime-DqzR3Gd9.js +0 -109
  1223. package/dist/channel.runtime-LOf0PHu_.js +0 -652
  1224. package/dist/channel.setup-1leD5F5B.js +0 -343
  1225. package/dist/channel.setup-D9UyWhXM.js +0 -1098
  1226. package/dist/channel.setup-DkVld-9Z.d.ts +0 -7
  1227. package/dist/channel.setup-DxT4prSl.d.ts +0 -8
  1228. package/dist/channel.setup-IHNFkdUD.js +0 -10
  1229. package/dist/channel.setup-YwXqilBB.d.ts +0 -6
  1230. package/dist/chat-DrycI6KH.js +0 -2666
  1231. package/dist/chrome-CgGY9FsG.js +0 -1503
  1232. package/dist/cli-backend-B3aNoTD4.d.ts +0 -5
  1233. package/dist/cli-backend-BVUFOLXj.d.ts +0 -5
  1234. package/dist/cli-compaction-DPmSHZx7.js +0 -347
  1235. package/dist/cli-metadata-eFfCoGmY.js +0 -22
  1236. package/dist/cli-nmYmL8lb.js +0 -1341
  1237. package/dist/cli-runner-BTOYShgV.js +0 -2
  1238. package/dist/cli-runner-DgXAxJVr.js +0 -540
  1239. package/dist/cli-runner.runtime-BeMsKcaS.js +0 -4
  1240. package/dist/cli-runner.runtime-DMD8X8-h.js +0 -3
  1241. package/dist/cli-shared-BAuePn3e.d.ts +0 -20
  1242. package/dist/cli-v6XF4hHd.d.ts +0 -20
  1243. package/dist/client-CKLZqMCW.js +0 -650
  1244. package/dist/client-adapter-B_0W-6Fx.js +0 -897
  1245. package/dist/client-factory-CdMLQFeA.js +0 -9
  1246. package/dist/command-auth-BxYfnQzs.js +0 -135
  1247. package/dist/command-execution-startup-CiV5yFW1.js +0 -87
  1248. package/dist/command-handlers-BAWROGlt.js +0 -1609
  1249. package/dist/command-registry-BqTMebZr.js +0 -4
  1250. package/dist/command-registry-C2Y8GeJl.js +0 -9
  1251. package/dist/command-registry-core-Bi-d0-WH.js +0 -110
  1252. package/dist/command-status.runtime-BSXHZzOq.js +0 -90
  1253. package/dist/commands-Z6AfrJar.d.ts +0 -113
  1254. package/dist/commands-acp-BYWOkjAx.js +0 -74
  1255. package/dist/commands-compact.runtime-Cyb7Pu12.js +0 -10
  1256. package/dist/commands-handlers.runtime-DdJ20XTn.js +0 -6154
  1257. package/dist/commands-status-6uhiUw13.js +0 -3
  1258. package/dist/commands-status-BJ5AnkOG.js +0 -16
  1259. package/dist/commands-status.runtime-6uhiUw13.js +0 -3
  1260. package/dist/commands-subagents-control.runtime-DZrrLjSk.js +0 -2
  1261. package/dist/commands-subagents-control.runtime-_R3XgUpp.js +0 -3
  1262. package/dist/commands-system-prompt-CHGtJPnx.js +0 -162
  1263. package/dist/commands-system-prompt-CM23NlDu.js +0 -2
  1264. package/dist/commands.runtime-DUEbtHG1.js +0 -176
  1265. package/dist/compact-BA6lVtLj.js +0 -480
  1266. package/dist/compact-BfC-utPW.js +0 -1141
  1267. package/dist/compact.runtime-BRL2wCqh.js +0 -12
  1268. package/dist/completion-cli-CYKoLZLl.js +0 -315
  1269. package/dist/computer-use-BWgYktaW.js +0 -367
  1270. package/dist/config-B_HanwOV.js +0 -373
  1271. package/dist/config-DhGtxK9v.js +0 -2
  1272. package/dist/config-cli-CI5UtWr-.js +0 -1633
  1273. package/dist/config-mutations-D2GtlLMA.js +0 -159
  1274. package/dist/config-schema-BKOfHz23.d.ts +0 -20
  1275. package/dist/configure-CuPwIiwW.js +0 -3
  1276. package/dist/configure.commands-BWpwrafi.js +0 -1251
  1277. package/dist/configure.commands-qzipmoDP.js +0 -2
  1278. package/dist/context-engine-host-compat-D246ZMR2.js +0 -2
  1279. package/dist/context-engine-host-compat-KMl-oqCw.js +0 -288
  1280. package/dist/context-engine-lifecycle-DvEDHkQz.js +0 -1274
  1281. package/dist/contracts-testkit-Ym3exIK5.d.ts +0 -145
  1282. package/dist/control-auth-B_RiUaHt.js +0 -114
  1283. package/dist/control-service-DcQFx6_O.js +0 -145
  1284. package/dist/control-ui/assets/agents-Bc8cIfWF.js +0 -1008
  1285. package/dist/control-ui/assets/channel-config-extras-DQru4ECs.js +0 -2
  1286. package/dist/control-ui/assets/channels-BfncerPV.js +0 -367
  1287. package/dist/control-ui/assets/cron-DHLcga_r.js +0 -1013
  1288. package/dist/control-ui/assets/debug-DprDzDn1.js +0 -97
  1289. package/dist/control-ui/assets/index-XTZKpkBL.js +0 -7370
  1290. package/dist/control-ui/assets/instances-D1_lOT13.js +0 -57
  1291. package/dist/control-ui/assets/logs-DINx8syb.js +0 -74
  1292. package/dist/control-ui/assets/nodes-BH4XOUmD.js +0 -436
  1293. package/dist/control-ui/assets/sessions-D5Xt25SY.js +0 -399
  1294. package/dist/control-ui/assets/skills-BmayrBHY.js +0 -314
  1295. package/dist/control-ui/assets/skills-shared-CHaYSJ_s.js +0 -11
  1296. package/dist/conversation-binding-runtime-_jhzwiiC.js +0 -4
  1297. package/dist/conversation-runtime-F5kCN0Sj.js +0 -31
  1298. package/dist/core-BpeKfqbI.d.ts +0 -224
  1299. package/dist/core-DE71gncT.js +0 -282
  1300. package/dist/core-api-B4L5WkKc.js +0 -5
  1301. package/dist/core-api-Q9oM19yY.js +0 -2
  1302. package/dist/crestodian-DLpxYmzP.js +0 -55
  1303. package/dist/daocore-runtime-BnYtDbMC.d.ts +0 -151
  1304. package/dist/daocore-tools-wNTIZIO3.js +0 -11727
  1305. package/dist/dashboard-SHmcCcnT.js +0 -263
  1306. package/dist/delivery-BA4di5Tw.js +0 -1002
  1307. package/dist/dev-Cr2Dhgoc.js +0 -97
  1308. package/dist/dialogue-xI4qAuLY.js +0 -37
  1309. package/dist/dir-fetch-tool-6d4yElM4.js +0 -565
  1310. package/dist/dir-list-tool-D2k-hax6.js +0 -100
  1311. package/dist/direct-dm-eGyFHTug.js +0 -64
  1312. package/dist/directive-handling.fast-lane-Ci1l6GN_.js +0 -68
  1313. package/dist/directive-handling.impl-Co3i_YQ4.js +0 -818
  1314. package/dist/directive-handling.impl-DHKC0TrU.js +0 -2
  1315. package/dist/directive-handling.model-selection-bv5KrHOw.js +0 -122
  1316. package/dist/directive-handling.persist.runtime-CPLg-YHh.js +0 -263
  1317. package/dist/dispatch-CdvERWY-.js +0 -1640
  1318. package/dist/dispatch-acp-transcript.runtime-BhQo1XEg.js +0 -40
  1319. package/dist/dispatch-acp.runtime-Dtiu2EgE.js +0 -18
  1320. package/dist/doctor-BzsPHvLP.js +0 -2
  1321. package/dist/doctor-Cg4FWB15.js +0 -6
  1322. package/dist/doctor-config-flow-SYjHcyu4.js +0 -1741
  1323. package/dist/doctor-core-checks-75amkN-e.js +0 -2
  1324. package/dist/doctor-core-checks-B1fu7KDm.js +0 -573
  1325. package/dist/doctor-health-contributions-BMdJKStr.js +0 -696
  1326. package/dist/doctor-health-vLyDQqfq.js +0 -65
  1327. package/dist/doctor-lint-DfvFyBgL.js +0 -94
  1328. package/dist/doctor-prompter-C-dTuOnw.js +0 -58
  1329. package/dist/doctor-state-integrity-Cv-ECLuv.js +0 -1231
  1330. package/dist/dynamic-tools-BG8ijDFH.js +0 -486
  1331. package/dist/embedded-backend-bRfALCWz.js +0 -579
  1332. package/dist/embedded-gateway-stub.runtime-CAh3IhtZ.js +0 -12
  1333. package/dist/embedding-provider-B7kg9IhC.d.ts +0 -16
  1334. package/dist/embedding-provider-jB1zjkZy.d.ts +0 -65
  1335. package/dist/embedding-provider-sea2CddJ.d.ts +0 -21
  1336. package/dist/exec-approvals-BBa28Sct.js +0 -149
  1337. package/dist/file-fetch-tool-DRIsI7eQ.js +0 -124
  1338. package/dist/file-write-tool-vTMh7eW6.js +0 -127
  1339. package/dist/format-nrhTS41q.js +0 -1145
  1340. package/dist/gateway-cli-CCgw11Ik.js +0 -435
  1341. package/dist/gateway-method-runtime-BNAVGCC_.js +0 -21
  1342. package/dist/gateway-runtime-DGdJumdK.d.ts +0 -163
  1343. package/dist/gemini-cli-provider-Bbpd5lx5.d.ts +0 -6
  1344. package/dist/get-reply-DGFCqKen.js +0 -4689
  1345. package/dist/get-reply-from-config.runtime-l7NTyCh5.js +0 -2
  1346. package/dist/graph-users-CGpakgek.js +0 -1419
  1347. package/dist/group-access-D095jQ78.js +0 -112
  1348. package/dist/handle-action.guild-admin-B3pALmMq.js +0 -288
  1349. package/dist/harness-Bs-sPbOD.js +0 -61
  1350. package/dist/health-4gWMIKHu.js +0 -4
  1351. package/dist/heartbeat-runner-Sky_Rjw7.js +0 -5
  1352. package/dist/heartbeat-runner.runtime-CRZ-NbrW.js +0 -4
  1353. package/dist/help-B68Ov4LD.js +0 -136
  1354. package/dist/hooks-DWSdYas_.js +0 -534
  1355. package/dist/http-registry-CHKiFHCC.d.ts +0 -23
  1356. package/dist/image-generation-runtime-p-dfXZTf.d.ts +0 -21
  1357. package/dist/inbound-direct-dm-runtime-5z3W9Oqn.js +0 -2
  1358. package/dist/inbound-reply-dispatch-D7NeeFC1.js +0 -148
  1359. package/dist/index-CKAHTIU4.d.ts +0 -3971
  1360. package/dist/init-BXF3o80o.js +0 -59
  1361. package/dist/inline-buttons-DsHwKEVU.js +0 -40
  1362. package/dist/interactive-dispatch-BsKWomnh.d.ts +0 -143
  1363. package/dist/interactive-dispatch-CItEYOu3.d.ts +0 -56
  1364. package/dist/internal-events-TAN9dPEj.js +0 -90
  1365. package/dist/isolated-agent-CTrVGI6q.js +0 -2
  1366. package/dist/isolated-agent-DPyibJ8B.js +0 -1118
  1367. package/dist/lifecycle-BwTg0Djv.js +0 -571
  1368. package/dist/list.probe-BpM4PKu7.js +0 -449
  1369. package/dist/list.status-command-BbcloYBd.js +0 -789
  1370. package/dist/llm-slug-generator-UG7Bhj_y.js +0 -78
  1371. package/dist/loader-D6z2PEKl.d.ts +0 -142
  1372. package/dist/local-dispatch.runtime-CU6Y-BDa.js +0 -9
  1373. package/dist/manager-C3AVKMSl.d.ts +0 -356
  1374. package/dist/manager.runtime-Da5LiiaQ.js +0 -2714
  1375. package/dist/markdown-to-line-BnESmsY4.js +0 -811
  1376. package/dist/mcp-http-C38KS7On.js +0 -2
  1377. package/dist/mcp-http-CcGhAZcF.js +0 -555
  1378. package/dist/media-understanding-provider-BCz5dVl6.js +0 -339
  1379. package/dist/memory-core-host-engine-storage-sWQlfr8J.d.ts +0 -54
  1380. package/dist/memory-embedding-adapter-BrGY0ecB.d.ts +0 -5
  1381. package/dist/message-actions-CQURSOZH.js +0 -145
  1382. package/dist/message-handler-C2U3bt-X.js +0 -1715
  1383. package/dist/message-handler-CwZfuHhP.js +0 -384
  1384. package/dist/message-handler.preflight-Cosa3kg0.js +0 -1125
  1385. package/dist/message-handler.process-BlKFMYXw.js +0 -1484
  1386. package/dist/migration-hAtbc95i.d.ts +0 -45
  1387. package/dist/model-B8M2deNL.js +0 -74
  1388. package/dist/model-Ck-vNyGd.d.ts +0 -33
  1389. package/dist/model-selection-v2wQWgsT.js +0 -272
  1390. package/dist/models-B7IiQBWY.js +0 -104
  1391. package/dist/models-CnWFsPX6.d.ts +0 -24
  1392. package/dist/models-DMNzBNgt.js +0 -2
  1393. package/dist/models-cli-CQaOg02d.js +0 -256
  1394. package/dist/monitor-Bd9kOezJ.js +0 -1370
  1395. package/dist/monitor-Cy6D6MyS.js +0 -715
  1396. package/dist/monitor-DStY23C4.js +0 -834
  1397. package/dist/monitor-DnF8eltK.js +0 -1657
  1398. package/dist/monitor-DrFJ63I1.js +0 -4377
  1399. package/dist/monitor-J8jOsDaJ.js +0 -60
  1400. package/dist/monitor-auth-DKkbt_CR.js +0 -179
  1401. package/dist/monitor-jp3H9Ri_.js +0 -2
  1402. package/dist/monitor-polling.runtime-DPCAacPc.js +0 -883
  1403. package/dist/monitor-tBNmyf1s.js +0 -2788
  1404. package/dist/monitor-webhook.runtime-BnjEsLRS.js +0 -387
  1405. package/dist/monitor.account-Gh8FuMEq.js +0 -5233
  1406. package/dist/monitor.runtime-Bdh6dxyq.js +0 -2
  1407. package/dist/monitor.webhook-BosT2ylg.js +0 -180
  1408. package/dist/node-cli-sessions-B0_DtIxz.js +0 -1228
  1409. package/dist/onboard-CiTp3HuT.js +0 -733
  1410. package/dist/onboard-helpers-6NgX4RkW.js +0 -251
  1411. package/dist/onboard-helpers-BwxJT_0T.js +0 -6
  1412. package/dist/onboard-remote-CNCFouj7.js +0 -212
  1413. package/dist/onboard-remote-DXzWgH_H.js +0 -2
  1414. package/dist/onboard-skills-Dx58zrXg.js +0 -160
  1415. package/dist/onboard-skills-qaynAMqw.js +0 -2
  1416. package/dist/openai-codex-provider-Bj9cyh4I.d.ts +0 -5
  1417. package/dist/openai-http-Dp0cp01u.js +0 -824
  1418. package/dist/openai-provider-Dm3YkkWf.d.ts +0 -5
  1419. package/dist/openresponses-http-acbxr5UW.js +0 -1173
  1420. package/dist/operations-BZVuEl9E.js +0 -805
  1421. package/dist/outbound-adapter-BKGzT1Rl.js +0 -543
  1422. package/dist/outbound-session-route-mWVuRF9I.js +0 -45
  1423. package/dist/outbound.runtime-BTjY78St.js +0 -2
  1424. package/dist/pi-embedded-CFP2IrYS.js +0 -3796
  1425. package/dist/pi-embedded-D8caT0Nm.js +0 -4
  1426. package/dist/pi-embedded.runtime-eBik36nq.js +0 -4
  1427. package/dist/pi-tools-DOiFN8QJ.js +0 -2413
  1428. package/dist/plan-Cq2-YWkv.js +0 -112
  1429. package/dist/plan-DZacZ3Zv.js +0 -81
  1430. package/dist/plugin-BcNkVMQf.d.ts +0 -17
  1431. package/dist/plugin-app-cache-key-CBK84hKp.js +0 -46
  1432. package/dist/plugin-enabled-CMfz3hfi.js +0 -233
  1433. package/dist/plugin-entry-BS5QKDoz.d.ts +0 -47
  1434. package/dist/plugin-k9ChkvvX.js +0 -12396
  1435. package/dist/plugin-registration-DzPoDboh.js +0 -88
  1436. package/dist/plugin-runtime-BNGhLQ-_.d.ts +0 -117
  1437. package/dist/plugin-service-BynKHNHj.d.ts +0 -24
  1438. package/dist/plugin-service-Ckp9CgP5.js +0 -1229
  1439. package/dist/policy-CBa8yH5k.js +0 -680
  1440. package/dist/policy-Dlam-IbU.js +0 -138
  1441. package/dist/prepare.runtime-B8h04--2.js +0 -732
  1442. package/dist/preview-warnings-DPDK9HPk.js +0 -392
  1443. package/dist/probe-Bts3wK7l.js +0 -682
  1444. package/dist/probe-ByHrOECy.js +0 -47
  1445. package/dist/probe-CXqCx5yV.js +0 -2204
  1446. package/dist/probe-fhhJ0LMx.js +0 -2
  1447. package/dist/program-DfNLP_PI.js +0 -131
  1448. package/dist/prompt-overlay-qKGGXVs-.d.ts +0 -23
  1449. package/dist/provider-CeG5mirD.js +0 -8735
  1450. package/dist/provider-D_TXf9b1.js +0 -152
  1451. package/dist/provider-Fb0fhEC5.js +0 -32
  1452. package/dist/provider-api-key-auth-BIph5btg.d.ts +0 -27
  1453. package/dist/provider-auth-result-BFvMZrH6.d.ts +0 -21
  1454. package/dist/provider-catalog-runtime-Du74RUel.d.ts +0 -23
  1455. package/dist/provider-catalog-shared-B3nN3sf2.d.ts +0 -62
  1456. package/dist/provider-dispatcher-DQ0FP7Oj.js +0 -22
  1457. package/dist/provider-hook-runtime-CRpS8VJ_.d.ts +0 -61
  1458. package/dist/provider-model-shared-GrPEK3SY.d.ts +0 -143
  1459. package/dist/provider-models-iUJVn9QI.d.ts +0 -12
  1460. package/dist/provider-policy-DliVEM__.d.ts +0 -30
  1461. package/dist/provider-registration-BxzmE1yB.d.ts +0 -6
  1462. package/dist/provider-registry-B4AQXjYK.d.ts +0 -8
  1463. package/dist/provider-registry-BHyB46kI.d.ts +0 -30
  1464. package/dist/provider-registry-CnfpUSqh.d.ts +0 -8
  1465. package/dist/provider-runtime-D3j0VBbF.d.ts +0 -359
  1466. package/dist/provider-self-hosted-setup-_11XAmRH.d.ts +0 -74
  1467. package/dist/provider-session.runtime-CIMJ-7ay.js +0 -9
  1468. package/dist/provider-stream-mWxYXsAm.d.ts +0 -140
  1469. package/dist/provider-stream-shared-QayId-fm.d.ts +0 -128
  1470. package/dist/provider-xNaUQ5Lv.js +0 -32
  1471. package/dist/provider.runtime-CGsYbZGk.js +0 -2
  1472. package/dist/providers.runtime-fmZQlSRt.d.ts +0 -25
  1473. package/dist/public-surface-loader-CuVkM64A.js +0 -114
  1474. package/dist/pw-ai-BDGftH9e.js +0 -3029
  1475. package/dist/pw-role-snapshot-C_P091Iv.js +0 -333
  1476. package/dist/reaction-level-DKxiNfWB.js +0 -19
  1477. package/dist/reaction-runtime-api-TY4aPHui.js +0 -116
  1478. package/dist/realtime-transcription-CmRx7wX7.d.ts +0 -43
  1479. package/dist/realtime-transcription-provider-BNca2pAl.js +0 -205
  1480. package/dist/realtime-transcription-provider-Csl2NRiB.d.ts +0 -5
  1481. package/dist/realtime-transcription-provider-CtUTdTS4.d.ts +0 -37
  1482. package/dist/realtime-transcription-provider-DKd69ns6.d.ts +0 -28
  1483. package/dist/realtime-transcription-provider-DPj1VZIg.d.ts +0 -32
  1484. package/dist/realtime-voice-CVgV9cqF.d.ts +0 -333
  1485. package/dist/realtime-voice-provider-CmtxwZon.d.ts +0 -5
  1486. package/dist/register-DLjqO2vR.js +0 -2178
  1487. package/dist/register.agent-FV7a6yzo.js +0 -156
  1488. package/dist/register.configure-DrkSyKW3.js +0 -16
  1489. package/dist/register.crestodian-CQGAa8z2.js +0 -24
  1490. package/dist/register.maintenance-tocHfiS3.js +0 -83
  1491. package/dist/register.onboard-BomHnBGE.js +0 -113
  1492. package/dist/register.runtime-6AmV3Vgs.js +0 -54
  1493. package/dist/register.runtime-CSz0gVBB.d.ts +0 -6
  1494. package/dist/register.setup-ENYtNAA5.js +0 -40
  1495. package/dist/register.subclis-BC6TefAM.js +0 -31
  1496. package/dist/register.subclis-DZdEZgSS.js +0 -3
  1497. package/dist/register.subclis-core-C-EfowrU.js +0 -273
  1498. package/dist/registry-VitXYFE8.d.ts +0 -91
  1499. package/dist/registry-types-C4eAzEgQ.d.ts +0 -392
  1500. package/dist/repair-sequencing-l8dFaytn.js +0 -640
  1501. package/dist/reply-delivery-DdeUWVuk.js +0 -196
  1502. package/dist/reply-runtime-Bd91JEZL.js +0 -11
  1503. package/dist/reply.runtime-l7NTyCh5.js +0 -2
  1504. package/dist/request-BY_4UukN.js +0 -54
  1505. package/dist/resolve-allowlist-C4lmxl4V.js +0 -220
  1506. package/dist/result-fallback-classifier-XORMMp30.js +0 -79
  1507. package/dist/root-help-CTW0Wyrf.js +0 -43
  1508. package/dist/route-dOf1WMkJ.js +0 -469
  1509. package/dist/route-resolution-BddNYZEI.js +0 -274
  1510. package/dist/routes-D0xw72Lf.js +0 -3602
  1511. package/dist/routes-TXSPQFWS.js +0 -2
  1512. package/dist/run-DpvUuaWB.js +0 -1162
  1513. package/dist/run-attempt-Bet0PiSc.js +0 -7704
  1514. package/dist/run-command-C5vMVqMt.js +0 -23
  1515. package/dist/run-command-pNDd7NqP.js +0 -2
  1516. package/dist/run-embedded.runtime-CBZV6YWj.js +0 -4
  1517. package/dist/run-execution-cli.runtime-DTQLV8tA.js +0 -4
  1518. package/dist/run-subagent-registry.runtime-DJCvSdhY.js +0 -2
  1519. package/dist/runtime-CNXeG8vX.js +0 -1287
  1520. package/dist/runtime-DEOSWxv9.js +0 -438
  1521. package/dist/runtime-api-BCM7T4WV.js +0 -17
  1522. package/dist/runtime-api-BTnMvj8L.js +0 -13
  1523. package/dist/runtime-api-By6LEySM.js +0 -3
  1524. package/dist/runtime-api-Cd0b5LPQ.js +0 -4
  1525. package/dist/runtime-api-CtuDiikz.js +0 -21
  1526. package/dist/runtime-api-DjySILXC.js +0 -13
  1527. package/dist/runtime-api-XJTq_pyQ.js +0 -24
  1528. package/dist/runtime-api.actions-BmsSg8Ai.js +0 -3
  1529. package/dist/runtime-api.monitor-DSk7Pd5H.js +0 -6
  1530. package/dist/runtime-api.send-D3sPncy9.js +0 -4
  1531. package/dist/runtime-api.threads-BK9cB4L1.js +0 -2
  1532. package/dist/runtime-channel--Wjr2ePx.js +0 -150
  1533. package/dist/runtime-channel-WdTa9hHZ.js +0 -2
  1534. package/dist/runtime-embedded-pi.runtime-BNYBvaxo.js +0 -2
  1535. package/dist/runtime-r3jS5wSq.js +0 -6179
  1536. package/dist/runtime-taskflow-DMBY6o56.d.ts +0 -435
  1537. package/dist/sanitize-outbound-D6IBCCpn.js +0 -127
  1538. package/dist/sdk-setup-tools-DcDrd8tW.js +0 -8
  1539. package/dist/secrets-OV1uTwRt.js +0 -113
  1540. package/dist/secrets-cli-llC7t41S.js +0 -149
  1541. package/dist/security-audit-BM_fypcl.js +0 -118
  1542. package/dist/security-audit-CQ2yKgF8.js +0 -122
  1543. package/dist/security-audit.runtime-CRgJUegH.js +0 -2
  1544. package/dist/selection-DkJ7MaPC.js +0 -16157
  1545. package/dist/selection-LeUiOSn0.js +0 -3
  1546. package/dist/send-C0ZHzB6o.js +0 -1631
  1547. package/dist/send-CXL3cM-w.js +0 -192
  1548. package/dist/send-CuDA29HM.js +0 -2
  1549. package/dist/send-D7qhwK7Z.js +0 -143
  1550. package/dist/send.components-BNeg1zrc.js +0 -2
  1551. package/dist/send.components-DwRyC_Hc.js +0 -500
  1552. package/dist/send.runtime-DBIUdxpO.js +0 -2
  1553. package/dist/server-DGcm6Swr.js +0 -24
  1554. package/dist/server-DPvleC-x.js +0 -73
  1555. package/dist/server-context-BWBM4f-_.js +0 -955
  1556. package/dist/server-context-CFgwcLlu.js +0 -2
  1557. package/dist/server-cron-C1kChsjw.js +0 -2989
  1558. package/dist/server-cron-CS1EP5Li.js +0 -2
  1559. package/dist/server-methods-BcIlC8iD.js +0 -16494
  1560. package/dist/server-node-events-BAZCvZOy.js +0 -596
  1561. package/dist/server-plugin-bootstrap-cQUi21Uu.js +0 -70
  1562. package/dist/server-plugins-BRFre223.js +0 -432
  1563. package/dist/server-reload-handlers-DfcsAX-5.js +0 -714
  1564. package/dist/server-restart-sentinel-CFX5zQkM.js +0 -747
  1565. package/dist/server-restart-sentinel-DUvs77Q0.js +0 -2
  1566. package/dist/server-runtime-services-0vm5XmvV.js +0 -2
  1567. package/dist/server-runtime-services-CLz_vkLy.js +0 -267
  1568. package/dist/server-startup-plugins-CPXqqIRV.js +0 -113
  1569. package/dist/server-startup-post-attach-BkNe1Z6g.js +0 -716
  1570. package/dist/server-ws-runtime-rcJeRHFO.js +0 -349
  1571. package/dist/server.impl-a6knQ-N8.js +0 -2586
  1572. package/dist/service-H-BcELwS.js +0 -1446
  1573. package/dist/session-binding-BQliaqL7.js +0 -2
  1574. package/dist/session-binding-DPvZil_F.js +0 -219
  1575. package/dist/session-kill-http-DJMipluP.js +0 -121
  1576. package/dist/session-reset-service-Dn9FU5wA.js +0 -625
  1577. package/dist/session-route-JLWNmJxD.js +0 -93
  1578. package/dist/session-status.runtime-D0OptHcW.js +0 -2
  1579. package/dist/session-subagent-reactivation.runtime-BUmf1vNS.js +0 -2
  1580. package/dist/session-tab-registry-CoBvJVRj.js +0 -521
  1581. package/dist/sessions-history-http-B8CkLDAn.js +0 -430
  1582. package/dist/sessions.runtime-DbNqS_Gy.js +0 -2
  1583. package/dist/setup-CTZUUn1s.js +0 -586
  1584. package/dist/setup-D6fXOEjD.js +0 -2
  1585. package/dist/setup-api-DLPEXHCv.js +0 -29
  1586. package/dist/setup-core-DLXb29jm.js +0 -174
  1587. package/dist/setup-onboard-configure-help-fast-path-CrcZmKPI.js +0 -64
  1588. package/dist/setup-surface--Cct-rCt.js +0 -288
  1589. package/dist/setup-surface-CW8YN207.js +0 -320
  1590. package/dist/setup-surface-DIxcfqD0.js +0 -221
  1591. package/dist/setup-surface-IJ6kmKgi.js +0 -405
  1592. package/dist/setup.finalize-gWpWnCCk.js +0 -582
  1593. package/dist/setup.gateway-config-D_DaSfpW.js +0 -281
  1594. package/dist/setup.migration-import-CYZjCkle.js +0 -2
  1595. package/dist/setup.migration-import-CZJU4scH.js +0 -200
  1596. package/dist/shared-Bp_Fgv6B.js +0 -121
  1597. package/dist/shared-CLqPY0yv.d.ts +0 -115
  1598. package/dist/shared-client-OQdg8NGC.js +0 -629
  1599. package/dist/shared-client-dk1ICVBm.js +0 -2
  1600. package/dist/side-question-CbhRW3UI.js +0 -683
  1601. package/dist/simple-completion-runtime-XIF65b47.d.ts +0 -73
  1602. package/dist/skill-tool-dispatch.runtime-EcycYnWE.js +0 -143
  1603. package/dist/slash-state-BoX6WwB5.js +0 -2166
  1604. package/dist/speech-CvkJG5Mt.d.ts +0 -47
  1605. package/dist/speech-core-MG83lB3i.d.ts +0 -36
  1606. package/dist/speech-provider-1EN9hT-3.d.ts +0 -8
  1607. package/dist/speech-provider-67ebyEcs.js +0 -184
  1608. package/dist/speech-provider-B6tb45De.d.ts +0 -5
  1609. package/dist/speech-provider-C74wAyBX.d.ts +0 -5
  1610. package/dist/speech-provider-CYJoZZpj.d.ts +0 -8
  1611. package/dist/speech-provider-DavEMdKC.d.ts +0 -34
  1612. package/dist/speech-provider-DvFtveg6.d.ts +0 -5
  1613. package/dist/src-CbfOifft.js +0 -4256
  1614. package/dist/startup-context-YF24NARp.js +0 -313
  1615. package/dist/status-message-CcrZdfCO.js +0 -484
  1616. package/dist/status-message.runtime-Cptt1EPV.js +0 -6
  1617. package/dist/status-subagents.runtime-v2eijc4R.js +0 -18
  1618. package/dist/status-text-BWwar3Yc.js +0 -296
  1619. package/dist/status-tn3uQDY7.js +0 -73
  1620. package/dist/status.runtime-BFjTHLiQ.js +0 -2
  1621. package/dist/sticker-cache-Cs7LV_3a.js +0 -206
  1622. package/dist/sticker-vision.runtime-CyPMpoCs.js +0 -17
  1623. package/dist/stream-1rWKMSqV.d.ts +0 -16
  1624. package/dist/stream-Bk9TnoRV.d.ts +0 -10
  1625. package/dist/stream-DZeY9rhs.d.ts +0 -120
  1626. package/dist/stream-DgCoKjcL.d.ts +0 -19
  1627. package/dist/stream-exnufPSG.d.ts +0 -5
  1628. package/dist/stream-wrappers-D2EuY1tP.d.ts +0 -21
  1629. package/dist/subagent-announce-CRjGGxSB.js +0 -354
  1630. package/dist/subagent-announce-delivery-CbfRRdwt.js +0 -958
  1631. package/dist/subagent-control-VTsWynTB.js +0 -508
  1632. package/dist/subagent-hooks-BB__aHul.js +0 -2
  1633. package/dist/subagent-hooks-Cb5fJ2H0.js +0 -146
  1634. package/dist/subagent-hooks-CwVBMhp_.js +0 -2
  1635. package/dist/subagent-hooks-Cx9_GAMF.js +0 -116
  1636. package/dist/subagent-hooks-DOJhvTDx.js +0 -230
  1637. package/dist/subagent-hooks-DUMqhB3r.js +0 -2
  1638. package/dist/subagent-hooks-api-BDGmCxB2.js +0 -22
  1639. package/dist/subagent-hooks-api-CcTdPqP1.js +0 -23
  1640. package/dist/subagent-hooks-api-D18tQta6.js +0 -23
  1641. package/dist/subagent-orphan-recovery-6bNIX25Q.js +0 -352
  1642. package/dist/subagent-registry-DokIxoQ6.js +0 -2351
  1643. package/dist/subagent-registry-tlyJE0hN.js +0 -3
  1644. package/dist/subagent-session-cleanup-BWHQ6rcm.js +0 -525
  1645. package/dist/subagent-spawn-BUdUAwoc.js +0 -1164
  1646. package/dist/target-id-CI1U3MSO.js +0 -107
  1647. package/dist/targets-CbBORUXB.d.ts +0 -10
  1648. package/dist/targets-CgmlXrhv.js +0 -44
  1649. package/dist/targets-D-jSrLUN.js +0 -19
  1650. package/dist/targets-DPDu8x6v.js +0 -19
  1651. package/dist/targets-D_fXvxrg.d.ts +0 -10
  1652. package/dist/testing-D-48HuIK.js +0 -267
  1653. package/dist/thinking-policy-CY16OlCs.d.ts +0 -5
  1654. package/dist/thread-bindings-B9J0nGG7.js +0 -232
  1655. package/dist/thread-bindings-BByWvFZq.js +0 -8
  1656. package/dist/thread-bindings-Cxjm2mLg.js +0 -571
  1657. package/dist/thread-bindings-DQWmglaO.js +0 -228
  1658. package/dist/thread-bindings.discord-api-DWWDvMgL.js +0 -187
  1659. package/dist/thread-bindings.manager-CQW6bNs5.js +0 -2
  1660. package/dist/thread-bindings.manager-DpBYBs9s.js +0 -536
  1661. package/dist/thread-lifecycle-PpB8gTx1.js +0 -1614
  1662. package/dist/token-CBy6YYM_.js +0 -134
  1663. package/dist/tool-BCHcwX9p.js +0 -139
  1664. package/dist/tool-actions.runtime-Cwxr2NmB.js +0 -534
  1665. package/dist/tool-plugin-DHZYdwyJ.d.ts +0 -77
  1666. package/dist/tool-resolution-DQpf531V.js +0 -149
  1667. package/dist/tool-split-ClZW5eN5.d.ts +0 -19
  1668. package/dist/tools-effective-inventory-BHxeIAri.js +0 -204
  1669. package/dist/tools-invoke-http-Bv2LES5Q.js +0 -67
  1670. package/dist/tools-invoke-shared-Cf_ifab9.js +0 -200
  1671. package/dist/transport-stream-D_pZ9Qwv.d.ts +0 -42
  1672. package/dist/tts-CjTcF0YS.js +0 -66
  1673. package/dist/tui-D3_WpyGV.js +0 -2
  1674. package/dist/tui-Y8IezK6P.js +0 -4709
  1675. package/dist/tui-backend-BIJbrfDK.js +0 -256
  1676. package/dist/tui-cli-YVLQJGLU.js +0 -37
  1677. package/dist/types-CnKegQ41.d.ts +0 -786
  1678. package/dist/types-Dyry5PA_2.d.ts +0 -3650
  1679. package/dist/types.public-AUFnQi6j.d.ts +0 -70
  1680. package/dist/update-cli-B7MOXy4Y.js +0 -3664
  1681. package/dist/video-generation-runtime-Cc8klYNS.d.ts +0 -21
  1682. package/dist/video-model-catalog-XG42YlJS.d.ts +0 -16
  1683. package/dist/vision-tools-kEwnV2UO.js +0 -1409
  1684. package/dist/web-search-DH1W_lfx.js +0 -62
  1685. package/dist/web-search-provider.runtime-BX9TezsY.js +0 -328
  1686. package/dist/web-search-provider.runtime-BhRjYeyp.js +0 -2
  1687. package/dist/webhook-targets--wGRjxMd.d.ts +0 -99
  1688. package/dist/xai-oauth-BZQ--94U.js +0 -479
  1689. package/dist/xai-user-agent-SpZaKTGR.js +0 -32
  1690. /package/dist/{acp-runtime-backend-DU5R8SXu.js → acp-runtime-backend-DHyoMnZY.js} +0 -0
  1691. /package/dist/{channel-actions-Ce2Sna1a.js → channel-actions-B5OPAiNK.js} +0 -0
  1692. /package/dist/{command-status-runtime-Cj5vB8lc.js → command-status-runtime-BqQvv1BR.js} +0 -0
  1693. /package/dist/{delegate-BeKeQwNR.js → delegate-B1QIF1j8.js} +0 -0
  1694. /package/dist/{dispatch-acp-DXlzEM_A.js → dispatch-acp-Ch9ZmM4b.js} +0 -0
  1695. /package/dist/{heartbeat-runner-Dncw_0KS.js → heartbeat-runner-BkgH94IS.js} +0 -0
  1696. /package/dist/{library-6cU4n1-c.js → library-DP1oARlw.js} +0 -0
  1697. /package/dist/{run-executor.runtime-DjwaphFT.js → run-executor.runtime-Czk4Lxkj.js} +0 -0
  1698. /package/dist/{shared-BE5PSFeb.js → shared-SiM6kZAE.js} +0 -0
@@ -0,0 +1,4256 @@
1
+ import { a as normalizeLowercaseStringOrEmpty, c as normalizeOptionalString, f as readStringValue, s as normalizeOptionalLowercaseString } from "./string-coerce-DyL154ka.js";
2
+ import { t as appendRegularFile } from "./regular-file-DaVeNX32.js";
3
+ import { c as isRecord } from "./utils-CNnMhEDp.js";
4
+ import { t as DEFAULT_ACCOUNT_ID } from "./account-id-B32J-iNN.js";
5
+ import { p as resolveThreadSessionKeys } from "./session-key-Bte0mmcq.js";
6
+ import { n as formatAllowlistMatchMeta } from "./allowlist-match-D8Bi9YxS.js";
7
+ import { i as writeJsonFileAtomically } from "./json-store-GaAZLixM.js";
8
+ import { S as buildMediaPayload } from "./reply-payload-DMPQsrQC.js";
9
+ import { S as resolveChannelStreamingBlockEnabled, a as createChannelProgressDraftGate, c as formatChannelProgressDraftText, f as mergeChannelProgressDraftLine, i as buildChannelProgressDraftLineForEntry, k as resolveChannelStreamingPreviewToolProgress, m as resolveChannelPreviewStreamMode, p as normalizeChannelProgressDraftLineIdentity, r as buildChannelProgressDraftLine, u as isChannelProgressDraftWorkToolName, y as resolveChannelProgressDraftMaxLines } from "./channel-streaming-BubngPMB.js";
10
+ import { n as resolveInboundMentionDecision } from "./mention-gating-3P8aSD7o.js";
11
+ import { o as resolveStableChannelMessageIngress, t as channelIngressRoutes } from "./runtime-GmtZRRes.js";
12
+ import { r as resolveDefaultGroupPolicy } from "./runtime-group-policy-CmZDlIwd.js";
13
+ import { n as fetchWithSsrFGuard } from "./fetch-guard-D1q9neTt.js";
14
+ import { o as saveResponseMedia } from "./fetch-Uo7VuY97.js";
15
+ import { a as deliverWithFinalizableLivePreviewAdapter, n as createPreviewMessageReceipt, r as defineFinalizableLivePreviewAdapter, s as markLiveMessageFinalized, t as createLiveMessageState } from "./live-CF0ee90S.js";
16
+ import "./string-coerce-runtime-DcopKqDR.js";
17
+ import "./routing-tpBhvjSA.js";
18
+ import "./history-tSxfyRRl.js";
19
+ import { t as createChannelReplyPipeline } from "./reply-pipeline-Bm6cMDK_.js";
20
+ import { i as resolveChannelTurnDispatchCounts, n as hasFinalChannelTurnDispatch } from "./dispatch-result-BM3RYtx4.js";
21
+ import { n as filterSupplementalContextItems, r as shouldIncludeSupplementalContext } from "./context-visibility-C9pX_aod.js";
22
+ import { t as createChannelHistoryWindow } from "./history-window-C5iLdHGW.js";
23
+ import { r as keepHttpServerTaskAlive } from "./channel-lifecycle.core-CDt0hRZR.js";
24
+ import { f as summarizeMapping, u as mergeAllowlist } from "./allow-from-BsbZfqm-.js";
25
+ import { n as isDangerousNameMatchingEnabled } from "./dangerous-name-matching-jjAiM0PK.js";
26
+ import "./reply-history-DtXwRuqo.js";
27
+ import { t as resolveChannelContextVisibilityMode } from "./context-visibility-Si-TIKp_.js";
28
+ import { a as dispatchReplyFromConfigWithSettledDispatcher } from "./inbound-reply-dispatch-BCTiM2jm.js";
29
+ import { n as DEFAULT_WEBHOOK_MAX_BODY_BYTES } from "./http-body-DrFvDwT0.js";
30
+ import "./ssrf-runtime-CvWWmfK6.js";
31
+ import { a as resolveChannelMediaMaxBytes } from "./media-runtime-BgoHtCXx.js";
32
+ import "./security-runtime-ZkIitjef.js";
33
+ import { n as logInboundDrop, r as logTypingFailure } from "./logging-Dr3f0mtP.js";
34
+ import { a as resolveInboundSessionEnvelopeContext } from "./channel-inbound-C2wLEE7Q.js";
35
+ import { s as createDraftStreamLoop } from "./channel-lifecycle-CvrjfUlH.js";
36
+ import "./channel-ingress-runtime-DztBpKpZ.js";
37
+ import "./channel-message-BntYSBp1.js";
38
+ import { n as createChannelPairingController } from "./channel-pairing-DH0uve3l.js";
39
+ import { n as getOptionalMSTeamsRuntime, t as getMSTeamsRuntime } from "./runtime-api-oZFIOS9l.js";
40
+ import { A as GRAPH_ROOT, B as isUrlAllowed, C as buildUserAgent, D as formatUnknownError, E as formatMSTeamsSendErrorHint, F as extractHtmlFromAttachment, G as resolveRequestUrl, H as readNestedString, I as extractInlineImageCandidates, J as tryBuildGraphSharesUrlForSharedLink, K as safeFetchWithPolicy, L as inferPlaceholder, M as applyAuthorizationHeaderForUrl, N as encodeGraphShareId, P as estimateBase64DecodedBytes, R as isDownloadableAttachment, S as loadMSTeamsSdkWithAuth, T as classifyMSTeamsSendError, U as resolveAttachmentFetchPolicy, V as normalizeContentType, W as resolveMediaSsrfPolicy, _ as resolveMSTeamsStorePath, a as fetchGraphJson, b as createMSTeamsAdapter, h as resolveMSTeamsCredentials, j as IMG_SRC_RE, k as ATTACHMENT_TAG_RE, q as safeHostForUrl, w as ensureUserAgentHeader, x as createMSTeamsTokenProvider, y as createBotFrameworkJwtValidator, z as isLikelyImageAttachment } from "./graph-users-CF7Dlee2.js";
41
+ import { c as resolveMSTeamsUserAllowlist, s as resolveMSTeamsChannelAllowlist } from "./resolve-allowlist-DWjCzDq1.js";
42
+ import { i as resolveMSTeamsRouteConfig, r as resolveMSTeamsReplyPolicy, t as resolveMSTeamsAllowlistMatch } from "./policy-Bp9GYcSZ.js";
43
+ import { C as readJsonFile, S as createMSTeamsConversationStoreFs, T as writeJsonFile, _ as buildFileInfoCard, b as createMSTeamsPollStoreFs, c as renderReplyPayloadsToMessages, d as withRevokedProxyFallback, f as resolveGraphChatId, g as removePendingUploadFs, h as getPendingUploadFs, l as sendMSTeamsMessages, m as removePendingUpload, p as getPendingUpload, s as buildConversationReference, u as AI_GENERATED_ENTITY, v as parseFileConsentInvoke, w as withFileLock, x as extractMSTeamsPollVote, y as uploadToConsentUrl } from "./probe-C1eD9yG7.js";
44
+ import path from "node:path";
45
+ import fs from "node:fs/promises";
46
+ //#region extensions/msteams/src/feedback-reflection-prompt.ts
47
+ /** Max chars of the thumbed-down response to include in the reflection prompt. */
48
+ const MAX_RESPONSE_CHARS = 500;
49
+ function buildReflectionPrompt(params) {
50
+ const parts = ["A user indicated your previous response wasn't helpful."];
51
+ if (params.thumbedDownResponse) {
52
+ const truncated = params.thumbedDownResponse.length > MAX_RESPONSE_CHARS ? `${params.thumbedDownResponse.slice(0, MAX_RESPONSE_CHARS)}...` : params.thumbedDownResponse;
53
+ parts.push(`\nYour response was:\n> ${truncated}`);
54
+ }
55
+ if (params.userComment) parts.push(`\nUser's comment: "${params.userComment}"`);
56
+ parts.push("\nBriefly reflect: what could you improve? Consider tone, length, accuracy, relevance, and specificity. Reply with a single JSON object only, no markdown or prose, using this exact shape:\n{\"learning\":\"...\",\"followUp\":false,\"userMessage\":\"\"}\n- learning: a short internal adjustment note (1-2 sentences) for your future behavior in this conversation.\n- followUp: true only if the user needs a direct follow-up message.\n- userMessage: only the exact user-facing message to send; empty string when followUp is false.");
57
+ return parts.join("\n");
58
+ }
59
+ function parseBooleanLike(value) {
60
+ if (typeof value === "boolean") return value;
61
+ if (typeof value === "string") {
62
+ const normalized = normalizeOptionalLowercaseString(value);
63
+ if (normalized === "true" || normalized === "yes") return true;
64
+ if (normalized === "false" || normalized === "no") return false;
65
+ }
66
+ }
67
+ function parseStructuredReflectionValue(value) {
68
+ if (value == null || typeof value !== "object" || Array.isArray(value)) return null;
69
+ const candidate = value;
70
+ const learning = typeof candidate.learning === "string" ? candidate.learning.trim() : void 0;
71
+ if (!learning) return null;
72
+ return {
73
+ learning,
74
+ followUp: parseBooleanLike(candidate.followUp) ?? false,
75
+ userMessage: typeof candidate.userMessage === "string" && candidate.userMessage.trim() ? candidate.userMessage.trim() : void 0
76
+ };
77
+ }
78
+ function parseReflectionResponse(text) {
79
+ const trimmed = text.trim();
80
+ if (!trimmed) return null;
81
+ const candidates = [trimmed, ...trimmed.match(/```(?:json)?\s*([\s\S]*?)```/i)?.slice(1, 2) ?? []];
82
+ for (const candidateText of candidates) {
83
+ const candidate = candidateText.trim();
84
+ if (!candidate) continue;
85
+ try {
86
+ const parsed = parseStructuredReflectionValue(JSON.parse(candidate));
87
+ if (parsed) return parsed;
88
+ } catch {}
89
+ }
90
+ return {
91
+ learning: trimmed,
92
+ followUp: false
93
+ };
94
+ }
95
+ /** Tracks last reflection time per session to enforce cooldown. */
96
+ const lastReflectionBySession = /* @__PURE__ */ new Map();
97
+ /** Maximum cooldown entries before pruning expired ones. */
98
+ const MAX_COOLDOWN_ENTRIES = 500;
99
+ function legacySanitizeSessionKey(sessionKey) {
100
+ return sessionKey.replace(/[^a-zA-Z0-9_-]/g, "_");
101
+ }
102
+ function encodeSessionKey(sessionKey) {
103
+ return Buffer.from(sessionKey, "utf8").toString("base64url");
104
+ }
105
+ function resolveLearningsFilePath(storePath, sessionKey) {
106
+ return `${storePath}/${encodeSessionKey(sessionKey)}.learnings.json`;
107
+ }
108
+ function resolveLegacyLearningsFilePath(storePath, sessionKey) {
109
+ return `${storePath}/${legacySanitizeSessionKey(sessionKey)}.learnings.json`;
110
+ }
111
+ async function readLearningsFile(filePath) {
112
+ try {
113
+ const content = await fs.readFile(filePath, "utf-8");
114
+ const parsed = JSON.parse(content);
115
+ return {
116
+ exists: true,
117
+ learnings: Array.isArray(parsed) ? parsed : []
118
+ };
119
+ } catch {
120
+ return {
121
+ exists: false,
122
+ learnings: []
123
+ };
124
+ }
125
+ }
126
+ /** Prune expired cooldown entries to prevent unbounded memory growth. */
127
+ function pruneExpiredCooldowns(cooldownMs) {
128
+ if (lastReflectionBySession.size <= MAX_COOLDOWN_ENTRIES) return;
129
+ const now = Date.now();
130
+ for (const [key, time] of lastReflectionBySession) if (now - time >= cooldownMs) lastReflectionBySession.delete(key);
131
+ }
132
+ /** Check if a reflection is allowed (cooldown not active). */
133
+ function isReflectionAllowed(sessionKey, cooldownMs) {
134
+ const cooldown = cooldownMs ?? 3e5;
135
+ const lastTime = lastReflectionBySession.get(sessionKey);
136
+ if (lastTime == null) return true;
137
+ return Date.now() - lastTime >= cooldown;
138
+ }
139
+ /** Record that a reflection was run for a session. */
140
+ function recordReflectionTime(sessionKey, cooldownMs) {
141
+ lastReflectionBySession.set(sessionKey, Date.now());
142
+ pruneExpiredCooldowns(cooldownMs ?? 3e5);
143
+ }
144
+ /** Store a learning derived from feedback reflection in a session companion file. */
145
+ async function storeSessionLearning(params) {
146
+ const learningsFile = resolveLearningsFilePath(params.storePath, params.sessionKey);
147
+ const legacyLearningsFile = resolveLegacyLearningsFilePath(params.storePath, params.sessionKey);
148
+ const { exists, learnings: existingLearnings } = await readLearningsFile(learningsFile);
149
+ const { learnings: legacyLearnings } = exists || legacyLearningsFile === learningsFile ? { learnings: [] } : await readLearningsFile(legacyLearningsFile);
150
+ let learnings = exists ? existingLearnings : legacyLearnings;
151
+ learnings.push(params.learning);
152
+ if (learnings.length > 10) learnings = learnings.slice(-10);
153
+ await writeJsonFileAtomically(learningsFile, learnings);
154
+ if (!exists && legacyLearningsFile !== learningsFile) await fs.rm(legacyLearningsFile, { force: true }).catch(() => void 0);
155
+ }
156
+ //#endregion
157
+ //#region extensions/msteams/src/feedback-reflection.ts
158
+ function buildFeedbackEvent(params) {
159
+ return {
160
+ type: "custom",
161
+ event: "feedback",
162
+ ts: Date.now(),
163
+ messageId: params.messageId,
164
+ value: params.value,
165
+ comment: params.comment,
166
+ sessionKey: params.sessionKey,
167
+ agentId: params.agentId,
168
+ conversationId: params.conversationId
169
+ };
170
+ }
171
+ function buildReflectionContext(params) {
172
+ const core = getMSTeamsRuntime();
173
+ const envelopeOptions = core.channel.reply.resolveEnvelopeFormatOptions(params.cfg);
174
+ const body = core.channel.reply.formatAgentEnvelope({
175
+ channel: "Teams",
176
+ from: "system",
177
+ body: params.reflectionPrompt,
178
+ envelope: envelopeOptions
179
+ });
180
+ return { ctxPayload: core.channel.reply.finalizeInboundContext({
181
+ Body: body,
182
+ BodyForAgent: params.reflectionPrompt,
183
+ RawBody: params.reflectionPrompt,
184
+ CommandBody: params.reflectionPrompt,
185
+ From: `msteams:system:${params.conversationId}`,
186
+ To: `conversation:${params.conversationId}`,
187
+ SessionKey: params.sessionKey,
188
+ ChatType: "direct",
189
+ SenderName: "system",
190
+ SenderId: "system",
191
+ Provider: "msteams",
192
+ Surface: "msteams",
193
+ Timestamp: Date.now(),
194
+ WasMentioned: true,
195
+ CommandAuthorized: false,
196
+ OriginatingChannel: "msteams",
197
+ OriginatingTo: `conversation:${params.conversationId}`
198
+ }) };
199
+ }
200
+ function createReflectionCaptureDispatcher(params) {
201
+ const core = getMSTeamsRuntime();
202
+ let response = "";
203
+ const { dispatcher, replyOptions } = core.channel.reply.createReplyDispatcherWithTyping({
204
+ deliver: async (payload) => {
205
+ if (payload.text) response += (response ? "\n" : "") + payload.text;
206
+ },
207
+ typingCallbacks: {
208
+ onReplyStart: async () => {},
209
+ onIdle: () => {},
210
+ onCleanup: () => {}
211
+ },
212
+ humanDelay: core.channel.reply.resolveHumanDelayConfig(params.cfg, params.agentId),
213
+ onError: (err) => {
214
+ params.log.debug?.("reflection reply error", { error: formatUnknownError(err) });
215
+ }
216
+ });
217
+ return {
218
+ dispatcher,
219
+ replyOptions,
220
+ readResponse: () => response
221
+ };
222
+ }
223
+ async function sendReflectionFollowUp(params) {
224
+ const proactiveRef = {
225
+ ...buildConversationReference(params.conversationRef),
226
+ activityId: void 0
227
+ };
228
+ await params.adapter.continueConversation(params.appId, proactiveRef, async (ctx) => {
229
+ await ctx.sendActivity({
230
+ type: "message",
231
+ text: params.userMessage
232
+ });
233
+ });
234
+ }
235
+ /**
236
+ * Run a background reflection after negative feedback.
237
+ * This is designed to be called fire-and-forget (don't await in the invoke handler).
238
+ */
239
+ async function runFeedbackReflection(params) {
240
+ const { cfg, log, sessionKey } = params;
241
+ const cooldownMs = cfg.channels?.msteams?.feedbackReflectionCooldownMs ?? 3e5;
242
+ if (!isReflectionAllowed(sessionKey, cooldownMs)) {
243
+ log.debug?.("skipping reflection (cooldown active)", { sessionKey });
244
+ return;
245
+ }
246
+ const reflectionPrompt = buildReflectionPrompt({
247
+ thumbedDownResponse: params.thumbedDownResponse,
248
+ userComment: params.userComment
249
+ });
250
+ const storePath = getMSTeamsRuntime().channel.session.resolveStorePath(cfg.session?.store, { agentId: params.agentId });
251
+ const { ctxPayload } = buildReflectionContext({
252
+ cfg,
253
+ conversationId: params.conversationId,
254
+ sessionKey: params.sessionKey,
255
+ reflectionPrompt
256
+ });
257
+ const capture = createReflectionCaptureDispatcher({
258
+ cfg,
259
+ agentId: params.agentId,
260
+ log
261
+ });
262
+ try {
263
+ await dispatchReplyFromConfigWithSettledDispatcher({
264
+ ctxPayload,
265
+ cfg,
266
+ dispatcher: capture.dispatcher,
267
+ onSettled: () => {},
268
+ replyOptions: capture.replyOptions
269
+ });
270
+ } catch (err) {
271
+ log.error("reflection dispatch failed", { error: formatUnknownError(err) });
272
+ return;
273
+ }
274
+ const reflectionResponse = capture.readResponse().trim();
275
+ if (!reflectionResponse) {
276
+ log.debug?.("reflection produced no output");
277
+ return;
278
+ }
279
+ const parsedReflection = parseReflectionResponse(reflectionResponse);
280
+ if (!parsedReflection) {
281
+ log.debug?.("reflection produced no structured output");
282
+ return;
283
+ }
284
+ recordReflectionTime(sessionKey, cooldownMs);
285
+ log.info("reflection complete", {
286
+ sessionKey,
287
+ responseLength: reflectionResponse.length,
288
+ followUp: parsedReflection.followUp
289
+ });
290
+ try {
291
+ await storeSessionLearning({
292
+ storePath,
293
+ sessionKey: params.sessionKey,
294
+ learning: parsedReflection.learning
295
+ });
296
+ } catch (err) {
297
+ log.debug?.("failed to store reflection learning", { error: formatUnknownError(err) });
298
+ }
299
+ const conversationType = normalizeOptionalLowercaseString(params.conversationRef.conversation?.conversationType);
300
+ if (!(conversationType === "personal" && parsedReflection.followUp && Boolean(parsedReflection.userMessage))) {
301
+ if (parsedReflection.followUp && conversationType !== "personal") log.debug?.("skipping reflection follow-up outside direct message", {
302
+ sessionKey,
303
+ conversationType
304
+ });
305
+ return;
306
+ }
307
+ try {
308
+ await sendReflectionFollowUp({
309
+ adapter: params.adapter,
310
+ appId: params.appId,
311
+ conversationRef: params.conversationRef,
312
+ userMessage: parsedReflection.userMessage
313
+ });
314
+ log.info("sent reflection follow-up", { sessionKey });
315
+ } catch (err) {
316
+ log.debug?.("failed to send reflection follow-up", { error: formatUnknownError(err) });
317
+ }
318
+ }
319
+ //#endregion
320
+ //#region extensions/msteams/src/inbound.ts
321
+ /**
322
+ * Decode common HTML entities to plain text.
323
+ */
324
+ function decodeHtmlEntities(html) {
325
+ return html.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&#39;/g, "'").replace(/&#x27;/g, "'").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&");
326
+ }
327
+ /**
328
+ * Strip HTML tags, preserving text content.
329
+ */
330
+ function htmlToPlainText(html) {
331
+ return decodeHtmlEntities(html.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim());
332
+ }
333
+ /**
334
+ * Extract quote info from MS Teams HTML reply attachments.
335
+ * Teams wraps quoted content in a blockquote with itemtype="http://schema.skype.com/Reply".
336
+ */
337
+ function extractMSTeamsQuoteInfo(attachments) {
338
+ for (const att of attachments) {
339
+ let content = "";
340
+ if (typeof att.content === "string") content = att.content;
341
+ else if (typeof att.content === "object" && att.content !== null) {
342
+ const record = att.content;
343
+ content = typeof record.text === "string" ? record.text : typeof record.body === "string" ? record.body : "";
344
+ }
345
+ if (!content) continue;
346
+ if (!content.includes("http://schema.skype.com/Reply")) continue;
347
+ const senderMatch = /<strong[^>]*itemprop=["']mri["'][^>]*>(.*?)<\/strong>/i.exec(content);
348
+ const sender = senderMatch?.[1] ? htmlToPlainText(senderMatch[1]) : void 0;
349
+ const bodyMatch = /<p[^>]*itemprop=["']copy["'][^>]*>(.*?)<\/p>/is.exec(content);
350
+ const body = bodyMatch?.[1] ? htmlToPlainText(bodyMatch[1]) : void 0;
351
+ if (body) return {
352
+ sender: sender ?? "unknown",
353
+ body
354
+ };
355
+ }
356
+ }
357
+ function normalizeMSTeamsConversationId(raw) {
358
+ return raw.split(";")[0] ?? raw;
359
+ }
360
+ function extractMSTeamsConversationMessageId(raw) {
361
+ if (!raw) return;
362
+ return (/(?:^|;)messageid=([^;]+)/i.exec(raw)?.[1]?.trim() ?? "") || void 0;
363
+ }
364
+ function parseMSTeamsActivityTimestamp(value) {
365
+ if (!value) return;
366
+ if (value instanceof Date) return value;
367
+ if (typeof value !== "string") return;
368
+ const date = new Date(value);
369
+ return Number.isNaN(date.getTime()) ? void 0 : date;
370
+ }
371
+ function stripMSTeamsMentionTags(text) {
372
+ return text.replace(/<at[^>]*>.*?<\/at>/gi, "").trim();
373
+ }
374
+ /**
375
+ * Bot Framework uses 'a:xxx' conversation IDs for personal chats, but Graph API
376
+ * requires the '19:{userId}_{botAppId}@unq.gbl.spaces' format.
377
+ *
378
+ * This is the documented Graph API format for 1:1 chat thread IDs between a user
379
+ * and a bot/app. See Microsoft docs "Get chat between user and app":
380
+ * https://learn.microsoft.com/en-us/graph/api/userscopeteamsappinstallation-get-chat
381
+ *
382
+ * The format is only synthesized when the Bot Framework conversation ID starts with
383
+ * 'a:' (the opaque format used by BF but not recognized by Graph). If the ID already
384
+ * has the '19:...' Graph format, it is passed through unchanged.
385
+ */
386
+ function translateMSTeamsDmConversationIdForGraph(params) {
387
+ const { isDirectMessage, conversationId, aadObjectId, appId } = params;
388
+ return isDirectMessage && conversationId.startsWith("a:") && aadObjectId && appId ? `19:${aadObjectId}_${appId}@unq.gbl.spaces` : conversationId;
389
+ }
390
+ function wasMSTeamsBotMentioned(activity) {
391
+ const botId = activity.recipient?.id;
392
+ if (!botId) return false;
393
+ return (activity.entities ?? []).some((e) => e.type === "mention" && e.mentioned?.id === botId);
394
+ }
395
+ //#endregion
396
+ //#region extensions/msteams/src/file-consent-invoke.ts
397
+ /**
398
+ * Handle fileConsent/invoke activities for large file uploads.
399
+ */
400
+ async function handleMSTeamsFileConsentInvoke(context, log) {
401
+ const expiredUploadMessage = "The file upload request has expired. Please try sending the file again.";
402
+ const activity = context.activity;
403
+ if (activity.type !== "invoke" || activity.name !== "fileConsent/invoke") return false;
404
+ const consentResponse = parseFileConsentInvoke(activity);
405
+ if (!consentResponse) {
406
+ log.debug?.("invalid file consent invoke", { value: activity.value });
407
+ return false;
408
+ }
409
+ const uploadId = typeof consentResponse.context?.uploadId === "string" ? consentResponse.context.uploadId : void 0;
410
+ const inMemoryFile = getPendingUpload(uploadId);
411
+ const fsFile = inMemoryFile ? void 0 : await getPendingUploadFs(uploadId);
412
+ const pendingFile = inMemoryFile ?? fsFile;
413
+ if (pendingFile) {
414
+ const pendingConversationId = normalizeMSTeamsConversationId(pendingFile.conversationId);
415
+ const invokeConversationId = normalizeMSTeamsConversationId(activity.conversation?.id ?? "");
416
+ if (!invokeConversationId || pendingConversationId !== invokeConversationId) {
417
+ log.info("file consent conversation mismatch", {
418
+ uploadId,
419
+ expectedConversationId: pendingConversationId,
420
+ receivedConversationId: invokeConversationId || void 0
421
+ });
422
+ if (consentResponse.action === "accept") await context.sendActivity(expiredUploadMessage);
423
+ return true;
424
+ }
425
+ }
426
+ if (consentResponse.action === "accept" && consentResponse.uploadInfo) if (pendingFile) {
427
+ log.debug?.("user accepted file consent, uploading", {
428
+ uploadId,
429
+ filename: pendingFile.filename,
430
+ size: pendingFile.buffer.length
431
+ });
432
+ try {
433
+ await uploadToConsentUrl({
434
+ url: consentResponse.uploadInfo.uploadUrl,
435
+ buffer: pendingFile.buffer,
436
+ contentType: pendingFile.contentType
437
+ });
438
+ const fileInfoCard = buildFileInfoCard({
439
+ filename: consentResponse.uploadInfo.name,
440
+ contentUrl: consentResponse.uploadInfo.contentUrl,
441
+ uniqueId: consentResponse.uploadInfo.uniqueId,
442
+ fileType: consentResponse.uploadInfo.fileType
443
+ });
444
+ if (!pendingFile.consentCardActivityId) await context.sendActivity({
445
+ type: "message",
446
+ attachments: [fileInfoCard]
447
+ });
448
+ if (pendingFile.consentCardActivityId) try {
449
+ await context.updateActivity({
450
+ id: pendingFile.consentCardActivityId,
451
+ type: "message",
452
+ attachments: [fileInfoCard]
453
+ });
454
+ } catch {
455
+ await context.sendActivity({
456
+ type: "message",
457
+ attachments: [fileInfoCard]
458
+ });
459
+ }
460
+ log.info("file upload complete", {
461
+ uploadId,
462
+ filename: consentResponse.uploadInfo.name,
463
+ uniqueId: consentResponse.uploadInfo.uniqueId
464
+ });
465
+ } catch (err) {
466
+ log.error("file upload failed", {
467
+ uploadId,
468
+ error: formatUnknownError(err)
469
+ });
470
+ await context.sendActivity("File upload failed. Please try again.");
471
+ } finally {
472
+ removePendingUpload(uploadId);
473
+ await removePendingUploadFs(uploadId);
474
+ }
475
+ } else {
476
+ log.debug?.("pending file not found for consent", { uploadId });
477
+ await context.sendActivity(expiredUploadMessage);
478
+ }
479
+ else {
480
+ log.debug?.("user declined file consent", { uploadId });
481
+ removePendingUpload(uploadId);
482
+ await removePendingUploadFs(uploadId);
483
+ }
484
+ return true;
485
+ }
486
+ async function respondToMSTeamsFileConsentInvoke(context, log) {
487
+ await context.sendActivity({
488
+ type: "invokeResponse",
489
+ value: { status: 200 }
490
+ });
491
+ try {
492
+ await withRevokedProxyFallback({
493
+ run: async () => await handleMSTeamsFileConsentInvoke(context, log),
494
+ onRevoked: async () => true,
495
+ onRevokedLog: () => {
496
+ log.debug?.("turn context revoked during file consent invoke; skipping delayed response");
497
+ }
498
+ });
499
+ } catch (err) {
500
+ log.debug?.("file consent handler error", { error: formatUnknownError(err) });
501
+ }
502
+ }
503
+ //#endregion
504
+ //#region extensions/msteams/src/monitor-handler/access.ts
505
+ const msteamsIngressIdentity = {
506
+ key: "sender-id",
507
+ normalize: normalizeIngressValue,
508
+ aliases: [{
509
+ key: "sender-name",
510
+ kind: "plugin:msteams-sender-name",
511
+ normalizeEntry: normalizeIngressValue,
512
+ normalizeSubject: normalizeIngressValue,
513
+ dangerous: true
514
+ }],
515
+ isWildcardEntry: (entry) => normalizeIngressValue(entry) === "*",
516
+ resolveEntryId: ({ entryIndex, fieldKey }) => `msteams-entry-${entryIndex + 1}:${fieldKey === "sender-name" ? "name" : "id"}`
517
+ };
518
+ function normalizeIngressValue(value) {
519
+ return normalizeOptionalLowercaseString(value) ?? null;
520
+ }
521
+ async function resolveMSTeamsSenderAccess(params) {
522
+ const activity = params.activity;
523
+ const msteamsCfg = params.cfg.channels?.msteams;
524
+ const conversationId = normalizeMSTeamsConversationId(activity.conversation?.id ?? "unknown");
525
+ const convType = normalizeOptionalLowercaseString(activity.conversation?.conversationType);
526
+ const isDirectMessage = convType === "personal" || !convType && !activity.conversation?.isGroup;
527
+ const senderId = activity.from?.aadObjectId ?? activity.from?.id ?? "unknown";
528
+ const senderName = activity.from?.name ?? activity.from?.id ?? senderId;
529
+ const pairing = createChannelPairingController({
530
+ core: getMSTeamsRuntime(),
531
+ channel: "msteams",
532
+ accountId: DEFAULT_ACCOUNT_ID
533
+ });
534
+ const dmPolicy = msteamsCfg?.dmPolicy ?? "pairing";
535
+ const configuredDmAllowFrom = msteamsCfg?.allowFrom ?? [];
536
+ const groupAllowFrom = msteamsCfg?.groupAllowFrom;
537
+ const defaultGroupPolicy = resolveDefaultGroupPolicy(params.cfg);
538
+ const groupPolicy = !isDirectMessage && msteamsCfg ? msteamsCfg.groupPolicy ?? defaultGroupPolicy ?? "allowlist" : "disabled";
539
+ const allowNameMatching = isDangerousNameMatchingEnabled(msteamsCfg);
540
+ const channelGate = resolveMSTeamsRouteConfig({
541
+ cfg: msteamsCfg,
542
+ teamId: activity.channelData?.team?.id,
543
+ teamName: activity.channelData?.team?.name,
544
+ conversationId,
545
+ channelName: activity.channelData?.channel?.name,
546
+ allowNameMatching
547
+ });
548
+ return {
549
+ ...await resolveStableChannelMessageIngress({
550
+ channelId: "msteams",
551
+ accountId: pairing.accountId,
552
+ identity: msteamsIngressIdentity,
553
+ cfg: params.cfg,
554
+ readStoreAllowFrom: pairing.readAllowFromStore,
555
+ subject: {
556
+ stableId: senderId,
557
+ aliases: { "sender-name": senderName }
558
+ },
559
+ conversation: {
560
+ kind: isDirectMessage ? "direct" : convType === "channel" ? "channel" : "group",
561
+ id: conversationId,
562
+ parentId: activity.channelData?.team?.id
563
+ },
564
+ route: channelIngressRoutes(!isDirectMessage && channelGate.allowlistConfigured && {
565
+ id: "msteams:team-channel",
566
+ kind: "nestedAllowlist",
567
+ allowed: channelGate.allowed,
568
+ precedence: 0,
569
+ matchId: "msteams-route",
570
+ ...channelGate.allowed && groupPolicy === "allowlist" ? {
571
+ senderPolicy: "deny-when-empty",
572
+ senderAllowFromSource: "effective-group"
573
+ } : {}
574
+ }),
575
+ dmPolicy,
576
+ groupPolicy,
577
+ policy: {
578
+ groupAllowFromFallbackToAllowFrom: true,
579
+ mutableIdentifierMatching: allowNameMatching ? "enabled" : "disabled"
580
+ },
581
+ allowFrom: configuredDmAllowFrom,
582
+ groupAllowFrom,
583
+ command: {
584
+ allowTextCommands: true,
585
+ hasControlCommand: params.hasControlCommand === true,
586
+ directGroupAllowFrom: isDirectMessage ? "effective" : "none"
587
+ }
588
+ }),
589
+ pairing,
590
+ isDirectMessage,
591
+ conversationId,
592
+ senderId,
593
+ senderName,
594
+ msteamsCfg,
595
+ dmPolicy,
596
+ channelGate,
597
+ allowNameMatching,
598
+ groupPolicy
599
+ };
600
+ }
601
+ //#endregion
602
+ //#region extensions/msteams/src/attachments/bot-framework.ts
603
+ /**
604
+ * Bot Framework Service token scope for requesting a token used against
605
+ * the Bot Connector (v3) REST endpoints such as `/v3/attachments/{id}`.
606
+ */
607
+ const BOT_FRAMEWORK_SCOPE = "https://api.botframework.com";
608
+ /**
609
+ * Detect Bot Framework personal chat ("a:") and MSA orgid ("8:orgid:") conversation
610
+ * IDs. These identifiers are not recognized by Graph's `/chats/{id}` endpoint, so we
611
+ * must fetch media via the Bot Framework v3 attachments endpoint instead.
612
+ *
613
+ * Graph-compatible IDs start with `19:` and are left untouched by this detector.
614
+ */
615
+ function isBotFrameworkPersonalChatId(conversationId) {
616
+ if (typeof conversationId !== "string") return false;
617
+ const trimmed = conversationId.trim();
618
+ return trimmed.startsWith("a:") || trimmed.startsWith("8:orgid:");
619
+ }
620
+ function normalizeServiceUrl(serviceUrl) {
621
+ return serviceUrl.replace(/\/+$/, "");
622
+ }
623
+ async function fetchBotFrameworkAttachmentInfo(params) {
624
+ const url = `${normalizeServiceUrl(params.serviceUrl)}/v3/attachments/${encodeURIComponent(params.attachmentId)}`;
625
+ let response;
626
+ try {
627
+ response = await safeFetchWithPolicy({
628
+ url,
629
+ policy: params.policy,
630
+ fetchFn: params.fetchFn,
631
+ resolveFn: params.resolveFn,
632
+ requestInit: { headers: ensureUserAgentHeader({ Authorization: `Bearer ${params.accessToken}` }) }
633
+ });
634
+ } catch (err) {
635
+ params.logger?.warn?.("msteams botFramework attachmentInfo fetch failed", { error: err instanceof Error ? err.message : String(err) });
636
+ return;
637
+ }
638
+ if (!response.ok) {
639
+ params.logger?.warn?.("msteams botFramework attachmentInfo non-ok", { status: response.status });
640
+ return;
641
+ }
642
+ try {
643
+ return await response.json();
644
+ } catch (err) {
645
+ params.logger?.warn?.("msteams botFramework attachmentInfo parse failed", { error: err instanceof Error ? err.message : String(err) });
646
+ return;
647
+ }
648
+ }
649
+ async function saveBotFrameworkAttachmentView(params) {
650
+ const url = `${normalizeServiceUrl(params.serviceUrl)}/v3/attachments/${encodeURIComponent(params.attachmentId)}/views/${encodeURIComponent(params.viewId)}`;
651
+ let response;
652
+ try {
653
+ response = await safeFetchWithPolicy({
654
+ url,
655
+ policy: params.policy,
656
+ fetchFn: params.fetchFn,
657
+ resolveFn: params.resolveFn,
658
+ requestInit: { headers: ensureUserAgentHeader({ Authorization: `Bearer ${params.accessToken}` }) }
659
+ });
660
+ } catch (err) {
661
+ params.logger?.warn?.("msteams botFramework attachmentView fetch failed", { error: err instanceof Error ? err.message : String(err) });
662
+ return;
663
+ }
664
+ if (!response.ok) {
665
+ params.logger?.warn?.("msteams botFramework attachmentView non-ok", { status: response.status });
666
+ return;
667
+ }
668
+ const contentLength = response.headers.get("content-length");
669
+ if (contentLength && Number(contentLength) > params.maxBytes) return;
670
+ try {
671
+ return await getMSTeamsRuntime().channel.media.saveResponseMedia(response, {
672
+ sourceUrl: url,
673
+ filePathHint: params.fileNameHint,
674
+ maxBytes: params.maxBytes,
675
+ fallbackContentType: params.contentTypeHint,
676
+ subdir: "inbound",
677
+ originalFilename: params.preserveFilenames ? params.fileNameHint : void 0
678
+ });
679
+ } catch (err) {
680
+ params.logger?.warn?.("msteams botFramework attachmentView save failed", { error: err instanceof Error ? err.message : String(err) });
681
+ return;
682
+ }
683
+ }
684
+ /**
685
+ * Download media for a single attachment via the Bot Framework v3 attachments
686
+ * endpoint. Used for personal DM conversations where the Graph `/chats/{id}`
687
+ * path is not usable because the Bot Framework conversation ID (`a:...`) is
688
+ * not a valid Graph chat identifier.
689
+ */
690
+ async function downloadMSTeamsBotFrameworkAttachment(params) {
691
+ if (!params.serviceUrl || !params.attachmentId || !params.tokenProvider) return;
692
+ const policy = resolveAttachmentFetchPolicy({
693
+ allowHosts: params.allowHosts,
694
+ authAllowHosts: params.authAllowHosts
695
+ });
696
+ if (!isUrlAllowed(`${normalizeServiceUrl(params.serviceUrl)}/v3/attachments/${encodeURIComponent(params.attachmentId)}`, policy.allowHosts)) return;
697
+ let accessToken;
698
+ try {
699
+ accessToken = await params.tokenProvider.getAccessToken(BOT_FRAMEWORK_SCOPE);
700
+ } catch (err) {
701
+ params.logger?.warn?.("msteams botFramework token acquisition failed", { error: err instanceof Error ? err.message : String(err) });
702
+ return;
703
+ }
704
+ if (!accessToken) return;
705
+ const info = await fetchBotFrameworkAttachmentInfo({
706
+ serviceUrl: params.serviceUrl,
707
+ attachmentId: params.attachmentId,
708
+ accessToken,
709
+ policy,
710
+ fetchFn: params.fetchFn,
711
+ resolveFn: params.resolveFn,
712
+ logger: params.logger
713
+ });
714
+ if (!info) return;
715
+ const views = Array.isArray(info.views) ? info.views : [];
716
+ const candidateView = views.find((view) => view?.viewId === "original") ?? views.find((view) => typeof view?.viewId === "string");
717
+ const viewId = typeof candidateView?.viewId === "string" && candidateView.viewId ? candidateView.viewId : void 0;
718
+ if (!viewId) return;
719
+ if (typeof candidateView?.size === "number" && candidateView.size > 0 && candidateView.size > params.maxBytes) return;
720
+ const fileNameHint = typeof params.fileNameHint === "string" && params.fileNameHint || typeof info.name === "string" && info.name || void 0;
721
+ const contentTypeHint = typeof params.contentTypeHint === "string" && params.contentTypeHint || typeof info.type === "string" && info.type || void 0;
722
+ const saved = await saveBotFrameworkAttachmentView({
723
+ serviceUrl: params.serviceUrl,
724
+ attachmentId: params.attachmentId,
725
+ viewId,
726
+ accessToken,
727
+ maxBytes: params.maxBytes,
728
+ fileNameHint,
729
+ contentTypeHint,
730
+ preserveFilenames: params.preserveFilenames,
731
+ policy,
732
+ fetchFn: params.fetchFn,
733
+ resolveFn: params.resolveFn,
734
+ logger: params.logger
735
+ });
736
+ if (!saved) return;
737
+ return {
738
+ path: saved.path,
739
+ contentType: saved.contentType,
740
+ placeholder: inferPlaceholder({
741
+ contentType: saved.contentType,
742
+ fileName: fileNameHint
743
+ })
744
+ };
745
+ }
746
+ /**
747
+ * Download media for every attachment referenced by a Bot Framework personal
748
+ * chat activity. Returns all successfully fetched media along with diagnostics
749
+ * compatible with `downloadMSTeamsGraphMedia`'s result shape so callers can
750
+ * reuse the existing logging path.
751
+ */
752
+ async function downloadMSTeamsBotFrameworkAttachments(params) {
753
+ const seen = /* @__PURE__ */ new Set();
754
+ const unique = [];
755
+ for (const id of params.attachmentIds ?? []) {
756
+ if (typeof id !== "string") continue;
757
+ const trimmed = id.trim();
758
+ if (!trimmed || seen.has(trimmed)) continue;
759
+ seen.add(trimmed);
760
+ unique.push(trimmed);
761
+ }
762
+ if (unique.length === 0 || !params.serviceUrl || !params.tokenProvider) return {
763
+ media: [],
764
+ attachmentCount: unique.length
765
+ };
766
+ const media = [];
767
+ for (const attachmentId of unique) try {
768
+ const item = await downloadMSTeamsBotFrameworkAttachment({
769
+ serviceUrl: params.serviceUrl,
770
+ attachmentId,
771
+ tokenProvider: params.tokenProvider,
772
+ maxBytes: params.maxBytes,
773
+ allowHosts: params.allowHosts,
774
+ authAllowHosts: params.authAllowHosts,
775
+ fetchFn: params.fetchFn,
776
+ resolveFn: params.resolveFn,
777
+ fileNameHint: params.fileNameHint,
778
+ contentTypeHint: params.contentTypeHint,
779
+ preserveFilenames: params.preserveFilenames,
780
+ logger: params.logger
781
+ });
782
+ if (item) media.push(item);
783
+ } catch (err) {
784
+ params.logger?.warn?.("msteams botFramework attachment download failed", {
785
+ error: err instanceof Error ? err.message : String(err),
786
+ attachmentId
787
+ });
788
+ }
789
+ return {
790
+ media,
791
+ attachmentCount: unique.length
792
+ };
793
+ }
794
+ //#endregion
795
+ //#region extensions/msteams/src/attachments/remote-media.ts
796
+ /**
797
+ * Direct fetch path used when the caller's `fetchImpl` has already validated
798
+ * the URL against a hostname allowlist (for example `safeFetchWithPolicy`).
799
+ *
800
+ * Bypasses the strict SSRF dispatcher on `readRemoteMediaBuffer` because:
801
+ * 1. The pinned undici dispatcher used by `readRemoteMediaBuffer` is incompatible
802
+ * with Node 24+'s built-in undici v7 (fails with "invalid onRequestStart
803
+ * method"), which silently breaks SharePoint/OneDrive downloads. See
804
+ * issue #63396.
805
+ * 2. SSRF protection is already enforced by the caller's `fetchImpl`
806
+ * (`safeFetch` validates every redirect hop against the hostname
807
+ * allowlist before following).
808
+ */
809
+ async function saveRemoteMediaDirect(params) {
810
+ return await saveResponseMedia(await params.fetchImpl(params.url, { redirect: "follow" }), {
811
+ sourceUrl: params.url,
812
+ filePathHint: params.filePathHint,
813
+ maxBytes: params.maxBytes,
814
+ fallbackContentType: params.contentTypeHint,
815
+ originalFilename: params.originalFilename
816
+ });
817
+ }
818
+ async function downloadAndStoreMSTeamsRemoteMedia(params) {
819
+ const originalFilename = params.preserveFilenames ? params.filePathHint : void 0;
820
+ let saved;
821
+ if (params.useDirectFetch && params.fetchImpl) saved = await saveRemoteMediaDirect({
822
+ url: params.url,
823
+ filePathHint: params.filePathHint,
824
+ fetchImpl: params.fetchImpl,
825
+ maxBytes: params.maxBytes,
826
+ contentTypeHint: params.contentTypeHint,
827
+ originalFilename
828
+ });
829
+ else saved = await getMSTeamsRuntime().channel.media.saveRemoteMedia({
830
+ url: params.url,
831
+ fetchImpl: params.fetchImpl,
832
+ filePathHint: params.filePathHint,
833
+ maxBytes: params.maxBytes,
834
+ ssrfPolicy: params.ssrfPolicy,
835
+ fallbackContentType: params.contentTypeHint,
836
+ originalFilename
837
+ });
838
+ return {
839
+ path: saved.path,
840
+ contentType: saved.contentType,
841
+ placeholder: params.placeholder ?? inferPlaceholder({
842
+ contentType: saved.contentType,
843
+ fileName: params.filePathHint
844
+ })
845
+ };
846
+ }
847
+ //#endregion
848
+ //#region extensions/msteams/src/attachments/download.ts
849
+ function resolveDownloadCandidate(att) {
850
+ const contentType = normalizeContentType(att.contentType);
851
+ const name = normalizeOptionalString(att.name) ?? "";
852
+ if (contentType === "application/vnd.microsoft.teams.file.download.info") {
853
+ if (!isRecord(att.content)) return null;
854
+ const downloadUrl = normalizeOptionalString(att.content.downloadUrl) ?? "";
855
+ if (!downloadUrl) return null;
856
+ const fileType = normalizeOptionalString(att.content.fileType) ?? "";
857
+ const uniqueId = normalizeOptionalString(att.content.uniqueId) ?? "";
858
+ const fileName = normalizeOptionalString(att.content.fileName) ?? "";
859
+ const fileHint = name || fileName || (uniqueId && fileType ? `${uniqueId}.${fileType}` : "");
860
+ return {
861
+ url: downloadUrl,
862
+ fileHint: fileHint || void 0,
863
+ contentTypeHint: void 0,
864
+ placeholder: inferPlaceholder({
865
+ contentType,
866
+ fileName: fileHint,
867
+ fileType
868
+ })
869
+ };
870
+ }
871
+ const contentUrl = normalizeOptionalString(att.contentUrl) ?? "";
872
+ if (!contentUrl) return null;
873
+ const sharesUrl = tryBuildGraphSharesUrlForSharedLink(contentUrl);
874
+ return {
875
+ url: sharesUrl ?? contentUrl,
876
+ fileHint: name || void 0,
877
+ contentTypeHint: sharesUrl ? void 0 : contentType,
878
+ placeholder: inferPlaceholder({
879
+ contentType,
880
+ fileName: name
881
+ })
882
+ };
883
+ }
884
+ function scopeCandidatesForUrl(url) {
885
+ try {
886
+ const host = normalizeLowercaseStringOrEmpty(new URL(url).hostname);
887
+ return host.endsWith("graph.microsoft.com") || host.endsWith("sharepoint.com") || host.endsWith("1drv.ms") || host.includes("sharepoint") ? ["https://graph.microsoft.com", "https://api.botframework.com"] : ["https://api.botframework.com", "https://graph.microsoft.com"];
888
+ } catch {
889
+ return ["https://api.botframework.com", "https://graph.microsoft.com"];
890
+ }
891
+ }
892
+ function isRedirectStatus(status) {
893
+ return status === 301 || status === 302 || status === 303 || status === 307 || status === 308;
894
+ }
895
+ async function resolveInlineDataImageMime(inline) {
896
+ const mime = normalizeOptionalLowercaseString(await getMSTeamsRuntime().media.detectMime({
897
+ buffer: inline.data,
898
+ headerMime: inline.contentType
899
+ }) ?? inline.contentType);
900
+ return mime?.startsWith("image/") ? mime : void 0;
901
+ }
902
+ async function fetchWithAuthFallback(params) {
903
+ const firstAttempt = await safeFetchWithPolicy({
904
+ url: params.url,
905
+ policy: params.policy,
906
+ fetchFn: params.fetchFn,
907
+ requestInit: params.requestInit,
908
+ resolveFn: params.resolveFn
909
+ });
910
+ if (firstAttempt.ok) return firstAttempt;
911
+ if (!params.tokenProvider) return firstAttempt;
912
+ if (firstAttempt.status !== 401 && firstAttempt.status !== 403) return firstAttempt;
913
+ if (!isUrlAllowed(params.url, params.policy.authAllowHosts)) return firstAttempt;
914
+ const scopes = scopeCandidatesForUrl(params.url);
915
+ const fetchFn = params.fetchFn ?? fetch;
916
+ for (const scope of scopes) try {
917
+ const token = await params.tokenProvider.getAccessToken(scope);
918
+ const authHeaders = new Headers(params.requestInit?.headers);
919
+ authHeaders.set("Authorization", `Bearer ${token}`);
920
+ const authAttempt = await safeFetchWithPolicy({
921
+ url: params.url,
922
+ policy: params.policy,
923
+ fetchFn,
924
+ requestInit: {
925
+ ...params.requestInit,
926
+ headers: authHeaders
927
+ },
928
+ resolveFn: params.resolveFn
929
+ });
930
+ if (authAttempt.ok) return authAttempt;
931
+ if (isRedirectStatus(authAttempt.status)) return authAttempt;
932
+ if (authAttempt.status !== 401 && authAttempt.status !== 403) continue;
933
+ } catch {}
934
+ return firstAttempt;
935
+ }
936
+ /**
937
+ * Download all file attachments from a Teams message (images, documents, etc.).
938
+ * Renamed from downloadMSTeamsImageAttachments to support all file types.
939
+ */
940
+ async function downloadMSTeamsAttachments(params) {
941
+ const list = Array.isArray(params.attachments) ? params.attachments : [];
942
+ if (list.length === 0) return [];
943
+ const policy = resolveAttachmentFetchPolicy({
944
+ allowHosts: params.allowHosts,
945
+ authAllowHosts: params.authAllowHosts
946
+ });
947
+ const allowHosts = policy.allowHosts;
948
+ const ssrfPolicy = resolveMediaSsrfPolicy(allowHosts);
949
+ const candidates = list.filter(isDownloadableAttachment).map(resolveDownloadCandidate).filter(Boolean);
950
+ const inlineCandidates = extractInlineImageCandidates(list, {
951
+ maxInlineBytes: params.maxBytes,
952
+ maxInlineTotalBytes: params.maxBytes
953
+ });
954
+ const seenUrls = /* @__PURE__ */ new Set();
955
+ for (const inline of inlineCandidates) if (inline.kind === "url") {
956
+ if (!isUrlAllowed(inline.url, allowHosts)) continue;
957
+ if (seenUrls.has(inline.url)) continue;
958
+ seenUrls.add(inline.url);
959
+ candidates.push({
960
+ url: inline.url,
961
+ fileHint: inline.fileHint,
962
+ contentTypeHint: inline.contentType,
963
+ placeholder: inline.placeholder
964
+ });
965
+ }
966
+ if (candidates.length === 0 && inlineCandidates.length === 0) return [];
967
+ const out = [];
968
+ for (const inline of inlineCandidates) {
969
+ if (inline.kind !== "data") continue;
970
+ if (inline.data.byteLength > params.maxBytes) continue;
971
+ try {
972
+ const contentType = await resolveInlineDataImageMime(inline);
973
+ if (!contentType) continue;
974
+ const saved = await getMSTeamsRuntime().channel.media.saveMediaBuffer(inline.data, contentType, "inbound", params.maxBytes);
975
+ out.push({
976
+ path: saved.path,
977
+ contentType: saved.contentType,
978
+ placeholder: inferPlaceholder({ contentType: saved.contentType ?? contentType })
979
+ });
980
+ } catch (err) {
981
+ params.logger?.warn?.("msteams inline attachment decode failed", { error: err instanceof Error ? err.message : String(err) });
982
+ }
983
+ }
984
+ for (const candidate of candidates) {
985
+ if (!isUrlAllowed(candidate.url, allowHosts)) continue;
986
+ try {
987
+ const media = await downloadAndStoreMSTeamsRemoteMedia({
988
+ url: candidate.url,
989
+ filePathHint: candidate.fileHint ?? candidate.url,
990
+ maxBytes: params.maxBytes,
991
+ contentTypeHint: candidate.contentTypeHint,
992
+ placeholder: candidate.placeholder,
993
+ preserveFilenames: params.preserveFilenames,
994
+ ssrfPolicy,
995
+ useDirectFetch: true,
996
+ fetchImpl: (input, init) => fetchWithAuthFallback({
997
+ url: resolveRequestUrl(input),
998
+ tokenProvider: params.tokenProvider,
999
+ fetchFn: params.fetchFn,
1000
+ requestInit: init,
1001
+ resolveFn: params.resolveFn,
1002
+ policy
1003
+ })
1004
+ });
1005
+ out.push(media);
1006
+ } catch (err) {
1007
+ params.logger?.warn?.("msteams attachment download failed", {
1008
+ error: err instanceof Error ? err.message : String(err),
1009
+ host: safeHostForLog(candidate.url)
1010
+ });
1011
+ }
1012
+ }
1013
+ return out;
1014
+ }
1015
+ function safeHostForLog(url) {
1016
+ try {
1017
+ return new URL(url).host;
1018
+ } catch {
1019
+ return "invalid-url";
1020
+ }
1021
+ }
1022
+ //#endregion
1023
+ //#region extensions/msteams/src/attachments/graph.ts
1024
+ function buildMSTeamsGraphMessageUrls(params) {
1025
+ const conversationType = normalizeLowercaseStringOrEmpty(params.conversationType ?? "");
1026
+ const messageIdCandidates = /* @__PURE__ */ new Set();
1027
+ const pushCandidate = (value) => {
1028
+ const trimmed = normalizeOptionalString(value) ?? "";
1029
+ if (trimmed) messageIdCandidates.add(trimmed);
1030
+ };
1031
+ pushCandidate(params.messageId);
1032
+ pushCandidate(params.conversationMessageId);
1033
+ pushCandidate(readNestedString(params.channelData, ["messageId"]));
1034
+ pushCandidate(readNestedString(params.channelData, ["teamsMessageId"]));
1035
+ const replyToId = normalizeOptionalString(params.replyToId) ?? "";
1036
+ if (conversationType === "channel") {
1037
+ const teamId = readNestedString(params.channelData, ["team", "id"]) ?? readNestedString(params.channelData, ["teamId"]);
1038
+ const channelId = readNestedString(params.channelData, ["channel", "id"]) ?? readNestedString(params.channelData, ["channelId"]) ?? readNestedString(params.channelData, ["teamsChannelId"]);
1039
+ if (!teamId || !channelId) return [];
1040
+ const urls = [];
1041
+ if (replyToId) for (const candidate of messageIdCandidates) {
1042
+ if (candidate === replyToId) continue;
1043
+ urls.push(`${GRAPH_ROOT}/teams/${encodeURIComponent(teamId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(replyToId)}/replies/${encodeURIComponent(candidate)}`);
1044
+ }
1045
+ if (messageIdCandidates.size === 0 && replyToId) messageIdCandidates.add(replyToId);
1046
+ for (const candidate of messageIdCandidates) urls.push(`${GRAPH_ROOT}/teams/${encodeURIComponent(teamId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(candidate)}`);
1047
+ return Array.from(new Set(urls));
1048
+ }
1049
+ const chatId = params.conversationId?.trim() || readNestedString(params.channelData, ["chatId"]);
1050
+ if (!chatId) return [];
1051
+ if (messageIdCandidates.size === 0 && replyToId) messageIdCandidates.add(replyToId);
1052
+ const urls = Array.from(messageIdCandidates).map((candidate) => `${GRAPH_ROOT}/chats/${encodeURIComponent(chatId)}/messages/${encodeURIComponent(candidate)}`);
1053
+ return Array.from(new Set(urls));
1054
+ }
1055
+ async function fetchGraphCollection(params) {
1056
+ const fetchFn = params.fetchFn ?? fetch;
1057
+ const { response, release } = await fetchWithSsrFGuard({
1058
+ url: params.url,
1059
+ fetchImpl: fetchFn,
1060
+ init: { headers: ensureUserAgentHeader({ Authorization: `Bearer ${params.accessToken}` }) },
1061
+ policy: params.ssrfPolicy,
1062
+ auditContext: "msteams.graph.collection"
1063
+ });
1064
+ try {
1065
+ const status = response.status;
1066
+ if (!response.ok) return {
1067
+ status,
1068
+ items: []
1069
+ };
1070
+ try {
1071
+ const data = await response.json();
1072
+ return {
1073
+ status,
1074
+ items: Array.isArray(data.value) ? data.value : []
1075
+ };
1076
+ } catch {
1077
+ return {
1078
+ status,
1079
+ items: []
1080
+ };
1081
+ }
1082
+ } finally {
1083
+ await release();
1084
+ }
1085
+ }
1086
+ function normalizeGraphAttachment(att) {
1087
+ let content = att.content;
1088
+ if (typeof content === "string") try {
1089
+ content = JSON.parse(content);
1090
+ } catch {}
1091
+ return {
1092
+ contentType: normalizeContentType(att.contentType) ?? void 0,
1093
+ contentUrl: att.contentUrl ?? void 0,
1094
+ name: att.name ?? void 0,
1095
+ thumbnailUrl: att.thumbnailUrl ?? void 0,
1096
+ content
1097
+ };
1098
+ }
1099
+ /**
1100
+ * Download all hosted content from a Teams message (images, documents, etc.).
1101
+ * Renamed from downloadGraphHostedImages to support all file types.
1102
+ */
1103
+ async function downloadGraphHostedContent(params) {
1104
+ const hosted = await fetchGraphCollection({
1105
+ url: `${params.messageUrl}/hostedContents`,
1106
+ accessToken: params.accessToken,
1107
+ fetchFn: params.fetchFn,
1108
+ ssrfPolicy: params.ssrfPolicy
1109
+ });
1110
+ if (hosted.items.length === 0) return {
1111
+ media: [],
1112
+ status: hosted.status,
1113
+ count: 0
1114
+ };
1115
+ const out = [];
1116
+ for (const item of hosted.items) {
1117
+ const contentBytes = typeof item.contentBytes === "string" ? item.contentBytes : "";
1118
+ let buffer;
1119
+ if (contentBytes) {
1120
+ if (estimateBase64DecodedBytes(contentBytes) > params.maxBytes) continue;
1121
+ try {
1122
+ buffer = Buffer.from(contentBytes, "base64");
1123
+ } catch (err) {
1124
+ params.logger?.warn?.("msteams graph hostedContent base64 decode failed", { error: err instanceof Error ? err.message : String(err) });
1125
+ continue;
1126
+ }
1127
+ } else if (item.id) {
1128
+ try {
1129
+ const valueUrl = `${params.messageUrl}/hostedContents/${encodeURIComponent(item.id)}/$value`;
1130
+ const { response: valRes, release } = await fetchWithSsrFGuard({
1131
+ url: valueUrl,
1132
+ fetchImpl: params.fetchFn ?? fetch,
1133
+ init: { headers: ensureUserAgentHeader({ Authorization: `Bearer ${params.accessToken}` }) },
1134
+ policy: params.ssrfPolicy,
1135
+ auditContext: "msteams.graph.hostedContent.value"
1136
+ });
1137
+ try {
1138
+ if (!valRes.ok) continue;
1139
+ const saved = await getMSTeamsRuntime().channel.media.saveResponseMedia(valRes, {
1140
+ sourceUrl: valueUrl,
1141
+ maxBytes: params.maxBytes,
1142
+ fallbackContentType: item.contentType ?? void 0,
1143
+ subdir: "inbound"
1144
+ });
1145
+ out.push({
1146
+ path: saved.path,
1147
+ contentType: saved.contentType,
1148
+ placeholder: inferPlaceholder({ contentType: saved.contentType })
1149
+ });
1150
+ } finally {
1151
+ await release();
1152
+ }
1153
+ } catch (err) {
1154
+ params.logger?.warn?.("msteams graph hostedContent value fetch failed", { error: err instanceof Error ? err.message : String(err) });
1155
+ continue;
1156
+ }
1157
+ continue;
1158
+ } else continue;
1159
+ if (buffer.byteLength > params.maxBytes) continue;
1160
+ const mime = await getMSTeamsRuntime().media.detectMime({
1161
+ buffer,
1162
+ headerMime: item.contentType ?? void 0
1163
+ });
1164
+ try {
1165
+ const saved = await getMSTeamsRuntime().channel.media.saveMediaBuffer(buffer, mime ?? item.contentType ?? void 0, "inbound", params.maxBytes);
1166
+ out.push({
1167
+ path: saved.path,
1168
+ contentType: saved.contentType,
1169
+ placeholder: inferPlaceholder({ contentType: saved.contentType })
1170
+ });
1171
+ } catch (err) {
1172
+ params.logger?.warn?.("msteams graph hostedContent save failed", { error: err instanceof Error ? err.message : String(err) });
1173
+ }
1174
+ }
1175
+ return {
1176
+ media: out,
1177
+ status: hosted.status,
1178
+ count: hosted.items.length
1179
+ };
1180
+ }
1181
+ async function downloadMSTeamsGraphMedia(params) {
1182
+ if (!params.messageUrl || !params.tokenProvider) return { media: [] };
1183
+ const policy = resolveAttachmentFetchPolicy({
1184
+ allowHosts: params.allowHosts,
1185
+ authAllowHosts: params.authAllowHosts
1186
+ });
1187
+ const ssrfPolicy = resolveMediaSsrfPolicy(policy.allowHosts);
1188
+ const messageUrl = params.messageUrl;
1189
+ const debugLog = params.log ?? params.logger ?? void 0;
1190
+ let accessToken;
1191
+ try {
1192
+ accessToken = await params.tokenProvider.getAccessToken("https://graph.microsoft.com");
1193
+ } catch (err) {
1194
+ debugLog?.debug?.("graph media token acquisition failed", {
1195
+ messageUrl,
1196
+ error: err instanceof Error ? err.message : String(err)
1197
+ });
1198
+ params.logger?.warn?.("msteams graph token acquisition failed", { error: err instanceof Error ? err.message : String(err) });
1199
+ return {
1200
+ media: [],
1201
+ messageUrl,
1202
+ tokenError: true
1203
+ };
1204
+ }
1205
+ const fetchFn = params.fetchFn ?? fetch;
1206
+ const sharePointMedia = [];
1207
+ const downloadedReferenceUrls = /* @__PURE__ */ new Set();
1208
+ let messageAttachments = [];
1209
+ let messageStatus;
1210
+ try {
1211
+ const { response: msgRes, release } = await fetchWithSsrFGuard({
1212
+ url: messageUrl,
1213
+ fetchImpl: fetchFn,
1214
+ init: { headers: ensureUserAgentHeader({ Authorization: `Bearer ${accessToken}` }) },
1215
+ policy: ssrfPolicy,
1216
+ auditContext: "msteams.graph.message"
1217
+ });
1218
+ try {
1219
+ messageStatus = msgRes.status;
1220
+ if (msgRes.ok) {
1221
+ let msgData;
1222
+ try {
1223
+ msgData = await msgRes.json();
1224
+ } catch (err) {
1225
+ debugLog?.debug?.("graph media message parse failed", {
1226
+ messageUrl,
1227
+ error: err instanceof Error ? err.message : String(err)
1228
+ });
1229
+ params.logger?.warn?.("msteams graph message parse failed", {
1230
+ error: err instanceof Error ? err.message : String(err),
1231
+ messageUrl
1232
+ });
1233
+ msgData = {};
1234
+ }
1235
+ messageAttachments = Array.isArray(msgData.attachments) ? msgData.attachments : [];
1236
+ const spAttachments = messageAttachments.filter((a) => a.contentType === "reference" && a.contentUrl && a.name);
1237
+ for (const att of spAttachments) {
1238
+ const name = att.name ?? "file";
1239
+ const shareUrl = att.contentUrl ?? "";
1240
+ if (!shareUrl) continue;
1241
+ try {
1242
+ const sharesUrl = `${GRAPH_ROOT}/shares/${encodeGraphShareId(shareUrl)}/driveItem/content`;
1243
+ if (!isUrlAllowed(sharesUrl, policy.allowHosts)) {
1244
+ debugLog?.debug?.("graph media sharepoint url not in allowHosts", {
1245
+ messageUrl,
1246
+ sharesUrl
1247
+ });
1248
+ continue;
1249
+ }
1250
+ const media = await downloadAndStoreMSTeamsRemoteMedia({
1251
+ url: sharesUrl,
1252
+ filePathHint: name,
1253
+ maxBytes: params.maxBytes,
1254
+ contentTypeHint: "application/octet-stream",
1255
+ preserveFilenames: params.preserveFilenames,
1256
+ ssrfPolicy,
1257
+ useDirectFetch: true,
1258
+ fetchImpl: async (input, init) => {
1259
+ const requestUrl = resolveRequestUrl(input);
1260
+ const headers = ensureUserAgentHeader(init?.headers);
1261
+ applyAuthorizationHeaderForUrl({
1262
+ headers,
1263
+ url: requestUrl,
1264
+ authAllowHosts: policy.authAllowHosts,
1265
+ bearerToken: accessToken
1266
+ });
1267
+ return await safeFetchWithPolicy({
1268
+ url: requestUrl,
1269
+ policy,
1270
+ fetchFn,
1271
+ requestInit: {
1272
+ ...init,
1273
+ headers
1274
+ },
1275
+ resolveFn: params.resolveFn
1276
+ });
1277
+ }
1278
+ });
1279
+ sharePointMedia.push(media);
1280
+ downloadedReferenceUrls.add(shareUrl);
1281
+ } catch (err) {
1282
+ params.logger?.warn?.("msteams SharePoint reference download failed", {
1283
+ error: err instanceof Error ? err.message : String(err),
1284
+ name
1285
+ });
1286
+ }
1287
+ }
1288
+ } else debugLog?.debug?.("graph media message fetch not ok", {
1289
+ messageUrl,
1290
+ status: messageStatus
1291
+ });
1292
+ } finally {
1293
+ await release();
1294
+ }
1295
+ } catch (err) {
1296
+ debugLog?.debug?.("graph media message fetch failed", {
1297
+ messageUrl,
1298
+ error: err instanceof Error ? err.message : String(err)
1299
+ });
1300
+ params.logger?.warn?.("msteams graph message fetch failed", { error: err instanceof Error ? err.message : String(err) });
1301
+ }
1302
+ const hosted = await downloadGraphHostedContent({
1303
+ accessToken,
1304
+ messageUrl,
1305
+ maxBytes: params.maxBytes,
1306
+ fetchFn: params.fetchFn,
1307
+ preserveFilenames: params.preserveFilenames,
1308
+ ssrfPolicy,
1309
+ logger: params.logger
1310
+ });
1311
+ const normalizedAttachments = messageAttachments.map(normalizeGraphAttachment);
1312
+ const filteredAttachments = sharePointMedia.length > 0 ? normalizedAttachments.filter((att) => {
1313
+ if (normalizeOptionalLowercaseString(att.contentType) !== "reference") return true;
1314
+ const url = typeof att.contentUrl === "string" ? att.contentUrl : "";
1315
+ if (!url) return true;
1316
+ return !downloadedReferenceUrls.has(url);
1317
+ }) : normalizedAttachments;
1318
+ let attachmentMedia = [];
1319
+ try {
1320
+ attachmentMedia = await downloadMSTeamsAttachments({
1321
+ attachments: filteredAttachments,
1322
+ maxBytes: params.maxBytes,
1323
+ tokenProvider: params.tokenProvider,
1324
+ allowHosts: policy.allowHosts,
1325
+ authAllowHosts: policy.authAllowHosts,
1326
+ fetchFn: params.fetchFn,
1327
+ resolveFn: params.resolveFn,
1328
+ preserveFilenames: params.preserveFilenames,
1329
+ logger: params.logger
1330
+ });
1331
+ } catch (err) {
1332
+ params.logger?.warn?.("msteams graph attachment download failed", {
1333
+ error: err instanceof Error ? err.message : String(err),
1334
+ messageUrl
1335
+ });
1336
+ }
1337
+ return {
1338
+ media: [
1339
+ ...sharePointMedia,
1340
+ ...hosted.media,
1341
+ ...attachmentMedia
1342
+ ],
1343
+ hostedCount: hosted.count,
1344
+ attachmentCount: filteredAttachments.length + sharePointMedia.length,
1345
+ hostedStatus: hosted.status,
1346
+ attachmentStatus: messageStatus,
1347
+ messageUrl
1348
+ };
1349
+ }
1350
+ //#endregion
1351
+ //#region extensions/msteams/src/attachments/html.ts
1352
+ /**
1353
+ * Extract every `<attachment id="...">` reference from the HTML attachments in
1354
+ * the inbound activity. Returns the complete (non-sliced) list; callers that
1355
+ * need a capped diagnostic summary can truncate after calling this helper.
1356
+ */
1357
+ function extractMSTeamsHtmlAttachmentIds(attachments) {
1358
+ const list = Array.isArray(attachments) ? attachments : [];
1359
+ if (list.length === 0) return [];
1360
+ const ids = /* @__PURE__ */ new Set();
1361
+ for (const att of list) {
1362
+ const html = extractHtmlFromAttachment(att);
1363
+ if (!html) continue;
1364
+ ATTACHMENT_TAG_RE.lastIndex = 0;
1365
+ let match = ATTACHMENT_TAG_RE.exec(html);
1366
+ while (match) {
1367
+ const id = match[1]?.trim();
1368
+ if (id) ids.add(id);
1369
+ match = ATTACHMENT_TAG_RE.exec(html);
1370
+ }
1371
+ }
1372
+ return Array.from(ids);
1373
+ }
1374
+ function summarizeMSTeamsHtmlAttachments(attachments) {
1375
+ const list = Array.isArray(attachments) ? attachments : [];
1376
+ if (list.length === 0) return;
1377
+ let htmlAttachments = 0;
1378
+ let imgTags = 0;
1379
+ let dataImages = 0;
1380
+ let cidImages = 0;
1381
+ const srcHosts = /* @__PURE__ */ new Set();
1382
+ let attachmentTags = 0;
1383
+ const attachmentIds = /* @__PURE__ */ new Set();
1384
+ for (const att of list) {
1385
+ const html = extractHtmlFromAttachment(att);
1386
+ if (!html) continue;
1387
+ htmlAttachments += 1;
1388
+ IMG_SRC_RE.lastIndex = 0;
1389
+ let match = IMG_SRC_RE.exec(html);
1390
+ while (match) {
1391
+ imgTags += 1;
1392
+ const src = match[1]?.trim();
1393
+ if (src) if (src.startsWith("data:")) dataImages += 1;
1394
+ else if (src.startsWith("cid:")) cidImages += 1;
1395
+ else srcHosts.add(safeHostForUrl(src));
1396
+ match = IMG_SRC_RE.exec(html);
1397
+ }
1398
+ ATTACHMENT_TAG_RE.lastIndex = 0;
1399
+ let attachmentMatch = ATTACHMENT_TAG_RE.exec(html);
1400
+ while (attachmentMatch) {
1401
+ attachmentTags += 1;
1402
+ const id = attachmentMatch[1]?.trim();
1403
+ if (id) attachmentIds.add(id);
1404
+ attachmentMatch = ATTACHMENT_TAG_RE.exec(html);
1405
+ }
1406
+ }
1407
+ if (htmlAttachments === 0) return;
1408
+ return {
1409
+ htmlAttachments,
1410
+ imgTags,
1411
+ dataImages,
1412
+ cidImages,
1413
+ srcHosts: Array.from(srcHosts).slice(0, 5),
1414
+ attachmentTags,
1415
+ attachmentIds: Array.from(attachmentIds).slice(0, 5)
1416
+ };
1417
+ }
1418
+ function buildMSTeamsAttachmentPlaceholder(attachments, limits) {
1419
+ const list = Array.isArray(attachments) ? attachments : [];
1420
+ if (list.length === 0) return "";
1421
+ const totalImages = list.filter(isLikelyImageAttachment).length + extractInlineImageCandidates(list, limits).length;
1422
+ if (totalImages > 0) return `<media:image>${totalImages > 1 ? ` (${totalImages} images)` : ""}`;
1423
+ const count = list.length;
1424
+ return `<media:document>${count > 1 ? ` (${count} files)` : ""}`;
1425
+ }
1426
+ //#endregion
1427
+ //#region extensions/msteams/src/attachments/payload.ts
1428
+ function buildMSTeamsMediaPayload(mediaList) {
1429
+ return buildMediaPayload(mediaList, { preserveMediaTypeCardinality: true });
1430
+ }
1431
+ //#endregion
1432
+ //#region extensions/msteams/src/graph-thread.ts
1433
+ const teamGroupIdCache = /* @__PURE__ */ new Map();
1434
+ const CACHE_TTL_MS = 600 * 1e3;
1435
+ /**
1436
+ * Strip HTML tags from Teams message content, preserving @mention display names.
1437
+ * Teams wraps mentions in <at>Name</at> tags.
1438
+ */
1439
+ function stripHtmlFromTeamsMessage(html) {
1440
+ let text = html.replace(/<at[^>]*>(.*?)<\/at>/gi, "@$1");
1441
+ text = text.replace(/<[^>]*>/g, " ");
1442
+ text = text.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&#39;/g, "'").replace(/&nbsp;/g, " ");
1443
+ return text.replace(/\s+/g, " ").trim();
1444
+ }
1445
+ /**
1446
+ * Resolve the Azure AD group GUID for a Teams conversation team ID.
1447
+ * Results are cached with a TTL to avoid repeated Graph API calls.
1448
+ */
1449
+ async function resolveTeamGroupId(token, conversationTeamId) {
1450
+ const cached = teamGroupIdCache.get(conversationTeamId);
1451
+ if (cached && cached.expiresAt > Date.now()) return cached.groupId;
1452
+ try {
1453
+ const groupId = (await fetchGraphJson({
1454
+ token,
1455
+ path: `/teams/${encodeURIComponent(conversationTeamId)}?$select=id`
1456
+ })).id ?? conversationTeamId;
1457
+ teamGroupIdCache.set(conversationTeamId, {
1458
+ groupId,
1459
+ expiresAt: Date.now() + CACHE_TTL_MS
1460
+ });
1461
+ return groupId;
1462
+ } catch {
1463
+ return conversationTeamId;
1464
+ }
1465
+ }
1466
+ /**
1467
+ * Fetch a single channel message (the parent/root of a thread).
1468
+ * Returns undefined on error so callers can degrade gracefully.
1469
+ */
1470
+ async function fetchChannelMessage(token, groupId, channelId, messageId) {
1471
+ const path = `/teams/${encodeURIComponent(groupId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(messageId)}?$select=id,from,body,createdDateTime`;
1472
+ try {
1473
+ return await fetchGraphJson({
1474
+ token,
1475
+ path
1476
+ });
1477
+ } catch {
1478
+ return;
1479
+ }
1480
+ }
1481
+ /**
1482
+ * Fetch thread replies for a channel message, ordered chronologically.
1483
+ *
1484
+ * **Limitation:** The Graph API replies endpoint (`/messages/{id}/replies`) does not
1485
+ * support `$orderby`, so results are always returned in ascending (oldest-first) order.
1486
+ * Combined with the `$top` cap of 50, this means only the **oldest 50 replies** are
1487
+ * returned for long threads — newer replies are silently omitted. There is currently no
1488
+ * Graph API workaround for this; pagination via `@odata.nextLink` can retrieve more
1489
+ * replies but still in ascending order only.
1490
+ */
1491
+ async function fetchThreadReplies(token, groupId, channelId, messageId, limit = 50) {
1492
+ return (await fetchGraphJson({
1493
+ token,
1494
+ path: `/teams/${encodeURIComponent(groupId)}/channels/${encodeURIComponent(channelId)}/messages/${encodeURIComponent(messageId)}/replies?$top=${Math.min(Math.max(limit, 1), 50)}&$select=id,from,body,createdDateTime`
1495
+ })).value ?? [];
1496
+ }
1497
+ /**
1498
+ * Format thread messages into a context string for the agent.
1499
+ * Skips the current message (by id) and blank messages.
1500
+ */
1501
+ function formatThreadContext(messages, currentMessageId) {
1502
+ const lines = [];
1503
+ for (const msg of messages) {
1504
+ if (msg.id && msg.id === currentMessageId) continue;
1505
+ const sender = msg.from?.user?.displayName ?? msg.from?.application?.displayName ?? "unknown";
1506
+ const contentType = msg.body?.contentType ?? "text";
1507
+ const rawContent = msg.body?.content ?? "";
1508
+ const content = contentType === "html" ? stripHtmlFromTeamsMessage(rawContent) : rawContent.trim();
1509
+ if (!content) continue;
1510
+ lines.push(`${sender}: ${content}`);
1511
+ }
1512
+ return lines.join("\n");
1513
+ }
1514
+ //#endregion
1515
+ //#region extensions/msteams/src/thread-parent-context.ts
1516
+ const PARENT_CACHE_TTL_MS = 300 * 1e3;
1517
+ const PARENT_CACHE_MAX = 100;
1518
+ const parentCache = /* @__PURE__ */ new Map();
1519
+ const INJECTED_MAX = 200;
1520
+ const injectedParents = /* @__PURE__ */ new Map();
1521
+ function touchLru(map, key, value, max) {
1522
+ if (map.has(key)) map.delete(key);
1523
+ else if (map.size >= max) {
1524
+ const firstKey = map.keys().next().value;
1525
+ if (firstKey !== void 0) map.delete(firstKey);
1526
+ }
1527
+ map.set(key, value);
1528
+ }
1529
+ function buildParentCacheKey(groupId, channelId, parentId) {
1530
+ return `${groupId}\u0000${channelId}\u0000${parentId}`;
1531
+ }
1532
+ /**
1533
+ * Fetch a channel parent message with an LRU+TTL cache.
1534
+ *
1535
+ * Uses the injected `fetchParent` (defaults to `fetchChannelMessage`) so
1536
+ * tests can swap in a stub without mocking the Graph transport.
1537
+ */
1538
+ async function fetchParentMessageCached(token, groupId, channelId, parentId, fetchParent = fetchChannelMessage) {
1539
+ const key = buildParentCacheKey(groupId, channelId, parentId);
1540
+ const now = Date.now();
1541
+ const cached = parentCache.get(key);
1542
+ if (cached && cached.expiresAt > now) {
1543
+ parentCache.delete(key);
1544
+ parentCache.set(key, cached);
1545
+ return cached.message;
1546
+ }
1547
+ const message = await fetchParent(token, groupId, channelId, parentId);
1548
+ touchLru(parentCache, key, {
1549
+ message,
1550
+ expiresAt: now + PARENT_CACHE_TTL_MS
1551
+ }, PARENT_CACHE_MAX);
1552
+ return message;
1553
+ }
1554
+ const PARENT_TEXT_MAX_CHARS = 400;
1555
+ /**
1556
+ * Extract a compact summary (sender + plain-text body) from a Graph parent
1557
+ * message. Returns undefined when the parent cannot be summarized (missing
1558
+ * or blank body).
1559
+ */
1560
+ function summarizeParentMessage(message) {
1561
+ if (!message) return;
1562
+ const sender = message.from?.user?.displayName ?? message.from?.application?.displayName ?? "unknown";
1563
+ const contentType = message.body?.contentType ?? "text";
1564
+ const raw = message.body?.content ?? "";
1565
+ const text = contentType === "html" ? stripHtmlFromTeamsMessage(raw) : raw.replace(/\s+/g, " ").trim();
1566
+ if (!text) return;
1567
+ return {
1568
+ sender,
1569
+ text: text.length > PARENT_TEXT_MAX_CHARS ? `${text.slice(0, PARENT_TEXT_MAX_CHARS - 1)}…` : text
1570
+ };
1571
+ }
1572
+ /**
1573
+ * Build the single-line `Replying to @sender: body` system event text.
1574
+ * Callers should pass this text to `enqueueSystemEvent` together with a
1575
+ * stable contextKey derived from the parent id.
1576
+ */
1577
+ function formatParentContextEvent(summary) {
1578
+ return `Replying to @${summary.sender}: ${summary.text}`;
1579
+ }
1580
+ /**
1581
+ * Decide whether a parent context event should be enqueued for the current
1582
+ * session. Returns `false` when we already injected the same parent for this
1583
+ * session recently (prevents re-prepending identical context on every reply
1584
+ * in the thread).
1585
+ */
1586
+ function shouldInjectParentContext(sessionKey, parentId) {
1587
+ const key = sessionKey;
1588
+ return injectedParents.get(key) !== parentId;
1589
+ }
1590
+ /**
1591
+ * Record that `parentId` was just injected for `sessionKey` so subsequent
1592
+ * replies with the same parent can short-circuit via `shouldInjectParentContext`.
1593
+ */
1594
+ function markParentContextInjected(sessionKey, parentId) {
1595
+ touchLru(injectedParents, sessionKey, parentId, INJECTED_MAX);
1596
+ }
1597
+ //#endregion
1598
+ //#region extensions/msteams/src/streaming-message.ts
1599
+ /**
1600
+ * Teams streaming message using the streaminfo entity protocol.
1601
+ *
1602
+ * Follows the official Teams SDK pattern:
1603
+ * 1. First chunk → POST a typing activity with streaminfo entity (streamType: "streaming")
1604
+ * 2. Subsequent chunks → POST typing activities with streaminfo + incrementing streamSequence
1605
+ * 3. Finalize → POST a message activity with streaminfo (streamType: "final")
1606
+ *
1607
+ * Uses the shared draft-stream-loop for throttling (avoids rate limits).
1608
+ */
1609
+ /** Default throttle interval between stream updates (ms).
1610
+ * Teams docs recommend buffering tokens for 1.5-2s; limit is 1 req/s. */
1611
+ const DEFAULT_THROTTLE_MS = 1500;
1612
+ /** Minimum chars before sending the first streaming message. */
1613
+ const MIN_INITIAL_CHARS = 20;
1614
+ /** Teams message text limit. */
1615
+ const TEAMS_MAX_CHARS = 4e3;
1616
+ /**
1617
+ * Stop streaming before Teams expires the content stream server-side.
1618
+ * The exact service limit is opaque, so stay comfortably under it.
1619
+ */
1620
+ const MAX_STREAM_AGE_MS = 45e3;
1621
+ function extractId(response) {
1622
+ if (response && typeof response === "object" && "id" in response) return readStringValue(response.id);
1623
+ }
1624
+ function buildStreamInfoEntity(streamId, streamType, streamSequence) {
1625
+ const entity = {
1626
+ type: "streaminfo",
1627
+ streamType
1628
+ };
1629
+ if (streamId) entity.streamId = streamId;
1630
+ if (streamSequence != null) entity.streamSequence = streamSequence;
1631
+ return entity;
1632
+ }
1633
+ var TeamsHttpStream = class {
1634
+ constructor(options) {
1635
+ this.accumulatedText = "";
1636
+ this.streamId = void 0;
1637
+ this.sequenceNumber = 0;
1638
+ this.stopped = false;
1639
+ this.finalized = false;
1640
+ this.streamFailed = false;
1641
+ this.lastStreamedText = "";
1642
+ this.finalMessageId = void 0;
1643
+ this.streamStartedAt = void 0;
1644
+ this.sendActivity = options.sendActivity;
1645
+ this.feedbackLoopEnabled = options.feedbackLoopEnabled ?? false;
1646
+ this.onError = options.onError;
1647
+ this.loop = createDraftStreamLoop({
1648
+ throttleMs: options.throttleMs ?? DEFAULT_THROTTLE_MS,
1649
+ isStopped: () => this.stopped,
1650
+ sendOrEditStreamMessage: (text) => this.pushStreamChunk(text)
1651
+ });
1652
+ }
1653
+ /**
1654
+ * Send an informative status update (blue progress bar in Teams).
1655
+ * Call this immediately when a message is received, before LLM starts generating.
1656
+ * Establishes the stream so subsequent chunks continue from this stream ID.
1657
+ */
1658
+ async sendInformativeUpdate(text) {
1659
+ if (this.stopped || this.finalized) return;
1660
+ this.sequenceNumber++;
1661
+ const activity = {
1662
+ type: "typing",
1663
+ text,
1664
+ entities: [buildStreamInfoEntity(this.streamId, "informative", this.sequenceNumber)]
1665
+ };
1666
+ try {
1667
+ const response = await this.sendActivity(activity);
1668
+ if (!this.streamId) this.streamId = extractId(response);
1669
+ } catch (err) {
1670
+ this.onError?.(err);
1671
+ }
1672
+ }
1673
+ /**
1674
+ * Ingest partial text from the LLM token stream.
1675
+ * Called by onPartialReply — accumulates text and throttles updates.
1676
+ */
1677
+ update(text) {
1678
+ if (this.stopped || this.finalized) return;
1679
+ this.accumulatedText = text;
1680
+ if (!this.streamId && this.accumulatedText.length < MIN_INITIAL_CHARS) return;
1681
+ if (this.accumulatedText.length > TEAMS_MAX_CHARS) {
1682
+ this.streamFailed = true;
1683
+ this.finalize();
1684
+ return;
1685
+ }
1686
+ if (this.streamStartedAt && Date.now() - this.streamStartedAt >= MAX_STREAM_AGE_MS) {
1687
+ this.streamFailed = true;
1688
+ this.finalize();
1689
+ return;
1690
+ }
1691
+ this.loop.update(this.accumulatedText);
1692
+ }
1693
+ /**
1694
+ * Replace an informative progress update with final answer text.
1695
+ * Returns false when the stream could not safely carry the final text, so
1696
+ * callers can deliver the answer through the normal Teams message path.
1697
+ */
1698
+ async replaceInformativeWithFinal(text) {
1699
+ if (this.stopped || this.finalized) return false;
1700
+ this.update(text);
1701
+ await this.loop.flush();
1702
+ await this.finalize();
1703
+ return !this.streamFailed && this.hasContent;
1704
+ }
1705
+ /**
1706
+ * Finalize the stream — send the final message activity.
1707
+ */
1708
+ async finalize() {
1709
+ if (this.finalized) return this.finalMessageId;
1710
+ this.finalized = true;
1711
+ this.stopped = true;
1712
+ this.loop.stop();
1713
+ await this.loop.waitForInFlight();
1714
+ if (!this.accumulatedText.trim()) return this.finalMessageId;
1715
+ if (this.streamFailed) {
1716
+ if (this.streamId) try {
1717
+ const response = await this.sendActivity({
1718
+ type: "message",
1719
+ text: this.lastStreamedText || "",
1720
+ channelData: { feedbackLoopEnabled: this.feedbackLoopEnabled },
1721
+ entities: [AI_GENERATED_ENTITY, buildStreamInfoEntity(this.streamId, "final")]
1722
+ });
1723
+ this.finalMessageId = extractId(response);
1724
+ } catch {}
1725
+ return this.finalMessageId;
1726
+ }
1727
+ try {
1728
+ const entities = [AI_GENERATED_ENTITY];
1729
+ if (this.streamId) entities.push(buildStreamInfoEntity(this.streamId, "final"));
1730
+ const finalActivity = {
1731
+ type: "message",
1732
+ text: this.accumulatedText,
1733
+ channelData: { feedbackLoopEnabled: this.feedbackLoopEnabled },
1734
+ entities
1735
+ };
1736
+ const response = await this.sendActivity(finalActivity);
1737
+ this.finalMessageId = extractId(response);
1738
+ } catch (err) {
1739
+ this.streamFailed = true;
1740
+ this.onError?.(err);
1741
+ }
1742
+ return this.finalMessageId;
1743
+ }
1744
+ /** Whether streaming successfully delivered content (at least one chunk sent, not failed). */
1745
+ get hasContent() {
1746
+ return this.accumulatedText.length > 0 && !this.streamFailed;
1747
+ }
1748
+ /** Whether streaming failed and fallback delivery is needed. */
1749
+ get isFailed() {
1750
+ return this.streamFailed;
1751
+ }
1752
+ /** Number of characters successfully streamed before failure. */
1753
+ get streamedLength() {
1754
+ return this.lastStreamedText.length;
1755
+ }
1756
+ /** Whether the stream has been finalized. */
1757
+ get isFinalized() {
1758
+ return this.finalized;
1759
+ }
1760
+ /** Platform id returned by the final message activity, when available. */
1761
+ get messageId() {
1762
+ return this.finalMessageId;
1763
+ }
1764
+ /** Stream id returned by the first streaminfo activity, when available. */
1765
+ get previewStreamId() {
1766
+ return this.streamId;
1767
+ }
1768
+ /** Whether streaming fell back (not used in this implementation). */
1769
+ get isFallback() {
1770
+ return false;
1771
+ }
1772
+ /**
1773
+ * Send a single streaming chunk as a typing activity with streaminfo.
1774
+ * Per the Teams REST API spec:
1775
+ * - First chunk: no streamId, streamSequence=1 → returns 201 with { id: streamId }
1776
+ * - Subsequent chunks: include streamId, increment streamSequence → returns 202
1777
+ */
1778
+ async pushStreamChunk(text) {
1779
+ if (this.stopped && !this.finalized) return false;
1780
+ this.sequenceNumber++;
1781
+ const activity = {
1782
+ type: "typing",
1783
+ text,
1784
+ entities: [buildStreamInfoEntity(this.streamId, "streaming", this.sequenceNumber)]
1785
+ };
1786
+ try {
1787
+ const response = await this.sendActivity(activity);
1788
+ if (!this.streamStartedAt) this.streamStartedAt = Date.now();
1789
+ if (!this.streamId) this.streamId = extractId(response);
1790
+ this.lastStreamedText = text;
1791
+ return true;
1792
+ } catch (err) {
1793
+ const axiosData = err?.response;
1794
+ const statusCode = axiosData?.status ?? err?.statusCode;
1795
+ const responseBody = axiosData?.data ? JSON.stringify(axiosData.data).slice(0, 300) : "";
1796
+ const msg = formatUnknownError(err);
1797
+ this.onError?.(/* @__PURE__ */ new Error(`stream POST failed (HTTP ${statusCode ?? "?"}): ${msg}${responseBody ? ` body=${responseBody}` : ""}`));
1798
+ this.streamFailed = true;
1799
+ return false;
1800
+ }
1801
+ }
1802
+ };
1803
+ //#endregion
1804
+ //#region extensions/msteams/src/reply-stream-controller.ts
1805
+ function createTeamsReplyStreamController(params) {
1806
+ const isPersonal = normalizeOptionalLowercaseString(params.conversationType) === "personal";
1807
+ const streamMode = resolveChannelPreviewStreamMode(params.msteamsConfig, "partial");
1808
+ const shouldUseNativeStream = isPersonal && (streamMode === "partial" || streamMode === "progress");
1809
+ const shouldSuppressDefaultToolProgressMessages = shouldUseNativeStream && streamMode === "progress";
1810
+ const shouldStreamPreviewToolProgress = shouldSuppressDefaultToolProgressMessages && resolveChannelStreamingPreviewToolProgress(params.msteamsConfig);
1811
+ const stream = shouldUseNativeStream ? new TeamsHttpStream({
1812
+ sendActivity: (activity) => params.context.sendActivity(activity),
1813
+ feedbackLoopEnabled: params.feedbackLoopEnabled,
1814
+ onError: (err) => {
1815
+ params.log.debug?.(`stream error: ${formatUnknownError(err)}`);
1816
+ }
1817
+ }) : void 0;
1818
+ let streamReceivedTokens = false;
1819
+ let informativeUpdateSent = false;
1820
+ let progressLines = [];
1821
+ let lastInformativeText = "";
1822
+ let pendingFinalize;
1823
+ let liveState = createLiveMessageState({ canFinalizeInPlace: Boolean(stream) });
1824
+ const markStreamFinalized = () => {
1825
+ if (!stream || stream.isFailed) return;
1826
+ const messageId = stream.messageId ?? stream.previewStreamId;
1827
+ if (!messageId) return;
1828
+ liveState = markLiveMessageFinalized(liveState, createPreviewMessageReceipt({ id: messageId }));
1829
+ };
1830
+ const renderInformativeUpdate = async () => {
1831
+ if (!stream) return;
1832
+ const informativeText = formatChannelProgressDraftText({
1833
+ entry: params.msteamsConfig,
1834
+ lines: shouldStreamPreviewToolProgress ? progressLines : [],
1835
+ seed: params.progressSeed,
1836
+ bullet: "-"
1837
+ });
1838
+ if (!informativeText || informativeText === lastInformativeText) return;
1839
+ lastInformativeText = informativeText;
1840
+ informativeUpdateSent = true;
1841
+ await stream.sendInformativeUpdate(informativeText);
1842
+ };
1843
+ const progressDraftGate = createChannelProgressDraftGate({ onStart: renderInformativeUpdate });
1844
+ const noteProgressWork = async (options) => {
1845
+ if (!stream || streamMode !== "progress") return;
1846
+ if (options?.toolName !== void 0 && !isChannelProgressDraftWorkToolName(options.toolName)) return;
1847
+ const hadStarted = progressDraftGate.hasStarted;
1848
+ await progressDraftGate.noteWork();
1849
+ if (hadStarted && progressDraftGate.hasStarted) await renderInformativeUpdate();
1850
+ };
1851
+ const pushProgressLine = async (line, options) => {
1852
+ if (!stream || streamMode !== "progress") return;
1853
+ if (options?.toolName !== void 0 && !isChannelProgressDraftWorkToolName(options.toolName)) return;
1854
+ if (shouldStreamPreviewToolProgress) {
1855
+ const normalized = normalizeChannelProgressDraftLineIdentity(line);
1856
+ if (normalized) progressLines = mergeChannelProgressDraftLine(progressLines, typeof line === "object" && line !== void 0 ? line : normalized, { maxLines: resolveChannelProgressDraftMaxLines(params.msteamsConfig) });
1857
+ }
1858
+ await noteProgressWork();
1859
+ };
1860
+ const fallbackAfterStreamFailure = (payload, hasMedia) => {
1861
+ if (!payload.text) return payload;
1862
+ const streamedLength = stream?.streamedLength ?? 0;
1863
+ if (streamedLength <= 0) return payload;
1864
+ const remainingText = payload.text.slice(streamedLength);
1865
+ if (!remainingText) return hasMedia ? {
1866
+ ...payload,
1867
+ text: void 0
1868
+ } : void 0;
1869
+ return {
1870
+ ...payload,
1871
+ text: remainingText
1872
+ };
1873
+ };
1874
+ const finalizeProgressPayload = async (payload, hasMedia) => {
1875
+ if (!stream || !payload.text) return payload;
1876
+ return (await deliverWithFinalizableLivePreviewAdapter({
1877
+ kind: "final",
1878
+ payload,
1879
+ liveState,
1880
+ adapter: defineFinalizableLivePreviewAdapter({
1881
+ draft: {
1882
+ flush: async () => {},
1883
+ clear: async () => {},
1884
+ id: () => stream.previewStreamId
1885
+ },
1886
+ buildFinalEdit: (candidate) => candidate.text ? { text: candidate.text } : void 0,
1887
+ editFinal: async (_previewId, edit) => {
1888
+ const finalized = await stream.replaceInformativeWithFinal(edit.text);
1889
+ informativeUpdateSent = false;
1890
+ if (!finalized || stream.isFailed) throw new Error("Teams progress stream finalization failed");
1891
+ },
1892
+ resolveFinalizedId: (previewId) => stream.messageId ?? stream.previewStreamId ?? previewId,
1893
+ createPreviewReceipt: (id) => createPreviewMessageReceipt({ id }),
1894
+ onPreviewFinalized: (_id, _receipt, state) => {
1895
+ liveState = state;
1896
+ },
1897
+ logPreviewEditFailure: (err) => {
1898
+ params.log.debug?.(`stream finalization failed: ${formatUnknownError(err)}`);
1899
+ }
1900
+ }),
1901
+ deliverNormally: async () => false
1902
+ })).kind === "preview-finalized" ? hasMedia ? {
1903
+ ...payload,
1904
+ text: void 0
1905
+ } : void 0 : payload;
1906
+ };
1907
+ return {
1908
+ async onReplyStart() {},
1909
+ async noteProgressWork(options) {
1910
+ await noteProgressWork(options);
1911
+ },
1912
+ onPartialReply(payload) {
1913
+ if (!stream || !payload.text) return;
1914
+ if (streamMode === "progress") return;
1915
+ streamReceivedTokens = true;
1916
+ stream.update(payload.text);
1917
+ },
1918
+ async pushProgressLine(line, options) {
1919
+ await pushProgressLine(line, options);
1920
+ },
1921
+ shouldSuppressDefaultToolProgressMessages() {
1922
+ return shouldSuppressDefaultToolProgressMessages;
1923
+ },
1924
+ shouldStreamPreviewToolProgress() {
1925
+ return shouldStreamPreviewToolProgress;
1926
+ },
1927
+ async preparePayload(payload) {
1928
+ const hasMedia = Boolean(payload.mediaUrl || payload.mediaUrls?.length);
1929
+ if (stream && streamMode === "progress" && informativeUpdateSent && !stream.isFinalized) {
1930
+ if (!payload.text) return payload;
1931
+ return await finalizeProgressPayload(payload, hasMedia);
1932
+ }
1933
+ if (!stream || !streamReceivedTokens) return payload;
1934
+ if (stream.isFailed) {
1935
+ streamReceivedTokens = false;
1936
+ return fallbackAfterStreamFailure(payload, hasMedia);
1937
+ }
1938
+ if (!stream.hasContent || stream.isFinalized) return payload;
1939
+ streamReceivedTokens = false;
1940
+ pendingFinalize = stream.finalize().then(() => {
1941
+ markStreamFinalized();
1942
+ });
1943
+ if (!hasMedia) return;
1944
+ return {
1945
+ ...payload,
1946
+ text: void 0
1947
+ };
1948
+ },
1949
+ async finalize() {
1950
+ progressDraftGate.cancel();
1951
+ await pendingFinalize;
1952
+ if (!pendingFinalize) {
1953
+ await stream?.finalize();
1954
+ markStreamFinalized();
1955
+ }
1956
+ },
1957
+ hasStream() {
1958
+ return Boolean(stream);
1959
+ },
1960
+ liveState() {
1961
+ return liveState;
1962
+ },
1963
+ /**
1964
+ * Whether the Teams streaming card is currently receiving LLM tokens.
1965
+ * Used to gate side-channel keepalive activity so we don't overlay plain
1966
+ * "typing" indicators on top of a live streaming card.
1967
+ *
1968
+ * Returns true only while the stream is actively chunking text into the
1969
+ * streaming card. The informative update (blue progress bar) is short
1970
+ * lived so we intentionally do not count it as "active"; this way the
1971
+ * typing keepalive can still fire during the informative window and
1972
+ * during tool chains between text segments.
1973
+ *
1974
+ * Returns false when:
1975
+ * - No stream exists (non-personal conversation).
1976
+ * - Stream has not yet received any text tokens.
1977
+ * - Stream has been finalized (e.g. after the first text segment, while
1978
+ * tools run before the next segment).
1979
+ */
1980
+ isStreamActive() {
1981
+ if (!stream) return false;
1982
+ if (stream.isFinalized || stream.isFailed) return false;
1983
+ return streamReceivedTokens;
1984
+ }
1985
+ };
1986
+ }
1987
+ //#endregion
1988
+ //#region extensions/msteams/src/reply-dispatcher.ts
1989
+ function createMSTeamsReplyDispatcher(params) {
1990
+ const core = getMSTeamsRuntime();
1991
+ const msteamsCfg = params.cfg.channels?.msteams;
1992
+ const conversationType = normalizeOptionalLowercaseString(params.conversationRef.conversation?.conversationType);
1993
+ const isTypingSupported = conversationType === "personal" || conversationType === "groupchat";
1994
+ /**
1995
+ * Keepalive cadence for the typing indicator while the bot is running
1996
+ * (including long tool chains). Bot Framework 1:1 TurnContext proxies
1997
+ * expire after ~30s of inactivity; sending a typing activity every 8s
1998
+ * keeps the proxy alive so the post-tool reply can still land via the
1999
+ * turn context. Sits in the middle of the 5-10s range recommended in
2000
+ * #59731.
2001
+ */
2002
+ const TYPING_KEEPALIVE_INTERVAL_MS = 8e3;
2003
+ /**
2004
+ * TTL ceiling for the typing keepalive loop. The default in
2005
+ * createTypingCallbacks is 60s, which is too short for the Teams long tool
2006
+ * chains described in #59731 (60s+ total runs are common). Give tool
2007
+ * chains up to 10 minutes before auto-stopping the keepalive.
2008
+ */
2009
+ const TYPING_KEEPALIVE_MAX_DURATION_MS = 10 * 6e4;
2010
+ const streamActiveRef = { current: () => false };
2011
+ const rawSendTypingIndicator = async () => {
2012
+ await withRevokedProxyFallback({
2013
+ run: async () => {
2014
+ await params.context.sendActivity({ type: "typing" });
2015
+ },
2016
+ onRevoked: async () => {
2017
+ const baseRef = buildConversationReference(params.conversationRef);
2018
+ await params.adapter.continueConversation(params.appId, {
2019
+ ...baseRef,
2020
+ activityId: void 0
2021
+ }, async (ctx) => {
2022
+ await ctx.sendActivity({ type: "typing" });
2023
+ });
2024
+ },
2025
+ onRevokedLog: () => {
2026
+ params.log.debug?.("turn context revoked, sending typing via proactive messaging");
2027
+ }
2028
+ });
2029
+ };
2030
+ const sendTypingIndicator = isTypingSupported ? async () => {
2031
+ if (streamActiveRef.current()) return;
2032
+ await rawSendTypingIndicator();
2033
+ } : async () => {};
2034
+ const { onModelSelected, typingCallbacks, ...replyPipeline } = createChannelReplyPipeline({
2035
+ cfg: params.cfg,
2036
+ agentId: params.agentId,
2037
+ channel: "msteams",
2038
+ accountId: params.accountId,
2039
+ typing: {
2040
+ start: sendTypingIndicator,
2041
+ keepaliveIntervalMs: TYPING_KEEPALIVE_INTERVAL_MS,
2042
+ maxDurationMs: TYPING_KEEPALIVE_MAX_DURATION_MS,
2043
+ onStartError: (err) => {
2044
+ logTypingFailure({
2045
+ log: (message) => params.log.debug?.(message),
2046
+ channel: "msteams",
2047
+ action: "start",
2048
+ error: err
2049
+ });
2050
+ }
2051
+ }
2052
+ });
2053
+ const chunkMode = core.channel.text.resolveChunkMode(params.cfg, "msteams");
2054
+ const tableMode = core.channel.text.resolveMarkdownTableMode({
2055
+ cfg: params.cfg,
2056
+ channel: "msteams"
2057
+ });
2058
+ const mediaMaxBytes = resolveChannelMediaMaxBytes({
2059
+ cfg: params.cfg,
2060
+ resolveChannelLimitMb: ({ cfg }) => cfg.channels?.msteams?.mediaMaxMb
2061
+ });
2062
+ const feedbackLoopEnabled = params.cfg.channels?.msteams?.feedbackEnabled !== false;
2063
+ const streamController = createTeamsReplyStreamController({
2064
+ conversationType,
2065
+ context: params.context,
2066
+ feedbackLoopEnabled,
2067
+ log: params.log,
2068
+ msteamsConfig: msteamsCfg,
2069
+ progressSeed: `${params.accountId ?? "default"}:${params.conversationRef.conversation?.id ?? ""}`
2070
+ });
2071
+ streamActiveRef.current = () => streamController.isStreamActive();
2072
+ const resolvedBlockStreamingEnabled = resolveChannelPreviewStreamMode(msteamsCfg, "partial") === "block" ? true : resolveChannelStreamingBlockEnabled(msteamsCfg);
2073
+ const blockStreamingEnabled = resolvedBlockStreamingEnabled ?? false;
2074
+ const typingIndicatorEnabled = typeof msteamsCfg?.typingIndicator === "boolean" ? msteamsCfg.typingIndicator : true;
2075
+ const pendingMessages = [];
2076
+ const sendMessages = async (messages) => {
2077
+ return sendMSTeamsMessages({
2078
+ replyStyle: params.replyStyle,
2079
+ adapter: params.adapter,
2080
+ appId: params.appId,
2081
+ conversationRef: params.conversationRef,
2082
+ context: params.context,
2083
+ messages,
2084
+ retry: {},
2085
+ onRetry: (event) => {
2086
+ params.log.debug?.("retrying send", {
2087
+ replyStyle: params.replyStyle,
2088
+ ...event
2089
+ });
2090
+ },
2091
+ tokenProvider: params.tokenProvider,
2092
+ sharePointSiteId: params.sharePointSiteId,
2093
+ mediaMaxBytes,
2094
+ feedbackLoopEnabled
2095
+ });
2096
+ };
2097
+ const queueDeliveryFailureSystemEvent = (failure) => {
2098
+ const classification = classifyMSTeamsSendError(failure.error);
2099
+ const errorText = formatUnknownError(failure.error);
2100
+ const failedAll = failure.failed >= failure.total;
2101
+ const sentences = [
2102
+ `Microsoft Teams delivery failed: ${failedAll ? "the previous reply was not delivered" : `${failure.failed} of ${failure.total} message blocks were not delivered`}.`,
2103
+ `The user may not have received ${failedAll ? "that reply" : "the full reply"}.`,
2104
+ `Error: ${errorText}.`,
2105
+ classification.statusCode != null ? `Status: ${classification.statusCode}.` : void 0,
2106
+ classification.kind === "transient" || classification.kind === "throttled" ? "Retrying later may succeed." : void 0
2107
+ ].filter(Boolean);
2108
+ core.system.enqueueSystemEvent(sentences.join(" "), {
2109
+ sessionKey: params.sessionKey,
2110
+ contextKey: `msteams:delivery-failure:${params.conversationRef.conversation?.id ?? "unknown"}`
2111
+ });
2112
+ };
2113
+ const flushPendingMessages = async () => {
2114
+ if (pendingMessages.length === 0) return;
2115
+ const toSend = pendingMessages.splice(0);
2116
+ const total = toSend.length;
2117
+ let ids;
2118
+ try {
2119
+ ids = await sendMessages(toSend);
2120
+ } catch (batchError) {
2121
+ ids = [];
2122
+ let failed = 0;
2123
+ let lastFailedError = batchError;
2124
+ for (const msg of toSend) try {
2125
+ const msgIds = await sendMessages([msg]);
2126
+ ids.push(...msgIds);
2127
+ } catch (msgError) {
2128
+ failed += 1;
2129
+ lastFailedError = msgError;
2130
+ params.log.debug?.("individual message send failed, continuing with remaining blocks");
2131
+ }
2132
+ if (failed > 0) {
2133
+ params.log.warn?.(`failed to deliver ${failed} of ${total} message blocks`, {
2134
+ failed,
2135
+ total
2136
+ });
2137
+ queueDeliveryFailureSystemEvent({
2138
+ failed,
2139
+ total,
2140
+ error: lastFailedError
2141
+ });
2142
+ }
2143
+ }
2144
+ if (ids.length > 0) params.onSentMessageIds?.(ids);
2145
+ };
2146
+ const { dispatcher, replyOptions, markDispatchIdle: baseMarkDispatchIdle } = core.channel.reply.createReplyDispatcherWithTyping({
2147
+ ...replyPipeline,
2148
+ humanDelay: core.channel.reply.resolveHumanDelayConfig(params.cfg, params.agentId),
2149
+ onReplyStart: async () => {
2150
+ await streamController.onReplyStart();
2151
+ if (typingIndicatorEnabled) await typingCallbacks?.onReplyStart?.();
2152
+ },
2153
+ typingCallbacks,
2154
+ deliver: async (payload) => {
2155
+ const preparedPayload = await streamController.preparePayload(payload);
2156
+ if (!preparedPayload) return;
2157
+ const messages = renderReplyPayloadsToMessages([preparedPayload], {
2158
+ textChunkLimit: params.textLimit,
2159
+ chunkText: true,
2160
+ mediaMode: "split",
2161
+ tableMode,
2162
+ chunkMode
2163
+ });
2164
+ pendingMessages.push(...messages);
2165
+ if (blockStreamingEnabled) await flushPendingMessages();
2166
+ },
2167
+ onError: (err, info) => {
2168
+ const errMsg = formatUnknownError(err);
2169
+ const classification = classifyMSTeamsSendError(err);
2170
+ const hint = formatMSTeamsSendErrorHint(classification);
2171
+ params.runtime.error?.(`msteams ${info.kind} reply failed: ${errMsg}${hint ? ` (${hint})` : ""}`);
2172
+ params.log.error("reply failed", {
2173
+ kind: info.kind,
2174
+ error: errMsg,
2175
+ classification,
2176
+ hint
2177
+ });
2178
+ }
2179
+ });
2180
+ const markDispatchIdle = () => {
2181
+ return flushPendingMessages().catch((err) => {
2182
+ const errMsg = formatUnknownError(err);
2183
+ const classification = classifyMSTeamsSendError(err);
2184
+ const hint = formatMSTeamsSendErrorHint(classification);
2185
+ params.runtime.error?.(`msteams flush reply failed: ${errMsg}${hint ? ` (${hint})` : ""}`);
2186
+ params.log.error("flush reply failed", {
2187
+ error: errMsg,
2188
+ classification,
2189
+ hint
2190
+ });
2191
+ }).then(() => {
2192
+ return streamController.finalize().catch((err) => {
2193
+ params.log.debug?.("stream finalize failed", { error: formatUnknownError(err) });
2194
+ });
2195
+ }).finally(() => {
2196
+ baseMarkDispatchIdle();
2197
+ });
2198
+ };
2199
+ return {
2200
+ dispatcher,
2201
+ replyOptions: {
2202
+ ...replyOptions,
2203
+ ...streamController.hasStream() ? {
2204
+ onPartialReply: (payload) => streamController.onPartialReply(payload),
2205
+ onToolStart: async (payload) => {
2206
+ await streamController.noteProgressWork({ toolName: payload.name });
2207
+ },
2208
+ onItemEvent: async () => {
2209
+ await streamController.noteProgressWork();
2210
+ },
2211
+ onPlanUpdate: async (payload) => {
2212
+ if (payload.phase === "update") await streamController.noteProgressWork();
2213
+ },
2214
+ onApprovalEvent: async (payload) => {
2215
+ if (payload.phase === "requested") await streamController.noteProgressWork();
2216
+ },
2217
+ onCommandOutput: async (payload) => {
2218
+ if (payload.phase === "end") await streamController.noteProgressWork();
2219
+ },
2220
+ onPatchSummary: async (payload) => {
2221
+ if (payload.phase === "end") await streamController.noteProgressWork();
2222
+ }
2223
+ } : {},
2224
+ ...streamController.shouldSuppressDefaultToolProgressMessages() ? { suppressDefaultToolProgressMessages: true } : {},
2225
+ ...streamController.shouldStreamPreviewToolProgress() ? {
2226
+ onToolStart: async (payload) => {
2227
+ await streamController.pushProgressLine(buildChannelProgressDraftLineForEntry(msteamsCfg, {
2228
+ event: "tool",
2229
+ name: payload.name,
2230
+ phase: payload.phase,
2231
+ args: payload.args
2232
+ }, payload.detailMode ? { detailMode: payload.detailMode } : void 0), { toolName: payload.name });
2233
+ },
2234
+ onItemEvent: async (payload) => {
2235
+ await streamController.pushProgressLine(buildChannelProgressDraftLineForEntry(msteamsCfg, {
2236
+ event: "item",
2237
+ itemId: payload.itemId,
2238
+ itemKind: payload.kind,
2239
+ title: payload.title,
2240
+ name: payload.name,
2241
+ phase: payload.phase,
2242
+ status: payload.status,
2243
+ summary: payload.summary,
2244
+ progressText: payload.progressText,
2245
+ meta: payload.meta
2246
+ }));
2247
+ },
2248
+ onPlanUpdate: async (payload) => {
2249
+ if (payload.phase !== "update") return;
2250
+ await streamController.pushProgressLine(buildChannelProgressDraftLine({
2251
+ event: "plan",
2252
+ phase: payload.phase,
2253
+ title: payload.title,
2254
+ explanation: payload.explanation,
2255
+ steps: payload.steps
2256
+ }));
2257
+ },
2258
+ onApprovalEvent: async (payload) => {
2259
+ if (payload.phase !== "requested") return;
2260
+ await streamController.pushProgressLine(buildChannelProgressDraftLine({
2261
+ event: "approval",
2262
+ phase: payload.phase,
2263
+ title: payload.title,
2264
+ command: payload.command,
2265
+ reason: payload.reason,
2266
+ message: payload.message
2267
+ }));
2268
+ },
2269
+ onCommandOutput: async (payload) => {
2270
+ if (payload.phase !== "end") return;
2271
+ await streamController.pushProgressLine(buildChannelProgressDraftLine({
2272
+ event: "command-output",
2273
+ phase: payload.phase,
2274
+ title: payload.title,
2275
+ name: payload.name,
2276
+ status: payload.status,
2277
+ exitCode: payload.exitCode
2278
+ }));
2279
+ },
2280
+ onPatchSummary: async (payload) => {
2281
+ if (payload.phase !== "end") return;
2282
+ await streamController.pushProgressLine(buildChannelProgressDraftLine({
2283
+ event: "patch",
2284
+ phase: payload.phase,
2285
+ title: payload.title,
2286
+ name: payload.name,
2287
+ added: payload.added,
2288
+ modified: payload.modified,
2289
+ deleted: payload.deleted,
2290
+ summary: payload.summary
2291
+ }));
2292
+ }
2293
+ } : {},
2294
+ disableBlockStreaming: typeof resolvedBlockStreamingEnabled === "boolean" ? !resolvedBlockStreamingEnabled : void 0,
2295
+ onModelSelected
2296
+ },
2297
+ markDispatchIdle
2298
+ };
2299
+ }
2300
+ //#endregion
2301
+ //#region extensions/msteams/src/sent-message-cache.ts
2302
+ const TTL_MS = 1440 * 60 * 1e3;
2303
+ const PERSISTENT_MAX_ENTRIES = 1e3;
2304
+ const PERSISTENT_NAMESPACE = "msteams.sent-messages";
2305
+ const MSTEAMS_SENT_MESSAGES_KEY = Symbol.for("daocore.msteamsSentMessages");
2306
+ let sentMessageCache;
2307
+ let persistentStore;
2308
+ let persistentStoreDisabled = false;
2309
+ function getSentMessageCache() {
2310
+ if (!sentMessageCache) {
2311
+ const globalStore = globalThis;
2312
+ sentMessageCache = globalStore[MSTEAMS_SENT_MESSAGES_KEY] ?? /* @__PURE__ */ new Map();
2313
+ globalStore[MSTEAMS_SENT_MESSAGES_KEY] = sentMessageCache;
2314
+ }
2315
+ return sentMessageCache;
2316
+ }
2317
+ function makePersistentKey(conversationId, messageId) {
2318
+ return `${conversationId}:${messageId}`;
2319
+ }
2320
+ function reportPersistentSentMessageError(error) {
2321
+ try {
2322
+ getOptionalMSTeamsRuntime()?.logging.getChildLogger({
2323
+ plugin: "msteams",
2324
+ feature: "sent-message-state"
2325
+ }).warn("Microsoft Teams persistent sent-message state failed", { error: String(error) });
2326
+ } catch {}
2327
+ }
2328
+ function disablePersistentSentMessageStore(error) {
2329
+ persistentStoreDisabled = true;
2330
+ persistentStore = void 0;
2331
+ reportPersistentSentMessageError(error);
2332
+ }
2333
+ function getPersistentSentMessageStore() {
2334
+ if (persistentStoreDisabled) return;
2335
+ if (persistentStore) return persistentStore;
2336
+ const runtime = getOptionalMSTeamsRuntime();
2337
+ if (!runtime) return;
2338
+ try {
2339
+ persistentStore = runtime.state.openKeyedStore({
2340
+ namespace: PERSISTENT_NAMESPACE,
2341
+ maxEntries: PERSISTENT_MAX_ENTRIES,
2342
+ defaultTtlMs: TTL_MS
2343
+ });
2344
+ return persistentStore;
2345
+ } catch (error) {
2346
+ disablePersistentSentMessageStore(error);
2347
+ return;
2348
+ }
2349
+ }
2350
+ function cleanupExpired(scopeKey, entry, now) {
2351
+ for (const [id, timestamp] of entry) if (now - timestamp > TTL_MS) entry.delete(id);
2352
+ if (entry.size === 0) getSentMessageCache().delete(scopeKey);
2353
+ }
2354
+ function rememberSentMessageInMemory(conversationId, messageId, sentAt) {
2355
+ const store = getSentMessageCache();
2356
+ let entry = store.get(conversationId);
2357
+ if (!entry) {
2358
+ entry = /* @__PURE__ */ new Map();
2359
+ store.set(conversationId, entry);
2360
+ }
2361
+ entry.set(messageId, sentAt);
2362
+ if (entry.size > 200) cleanupExpired(conversationId, entry, sentAt);
2363
+ }
2364
+ function rememberPersistentSentMessage(params) {
2365
+ const store = getPersistentSentMessageStore();
2366
+ if (!store) return;
2367
+ store.register(makePersistentKey(params.conversationId, params.messageId), { sentAt: params.sentAt }).catch(disablePersistentSentMessageStore);
2368
+ }
2369
+ async function lookupPersistentSentMessage(params) {
2370
+ const store = getPersistentSentMessageStore();
2371
+ if (!store) return;
2372
+ try {
2373
+ return (await store.lookup(makePersistentKey(params.conversationId, params.messageId)))?.sentAt;
2374
+ } catch (error) {
2375
+ disablePersistentSentMessageStore(error);
2376
+ return;
2377
+ }
2378
+ }
2379
+ function recordMSTeamsSentMessage(conversationId, messageId) {
2380
+ if (!conversationId || !messageId) return;
2381
+ const now = Date.now();
2382
+ rememberSentMessageInMemory(conversationId, messageId, now);
2383
+ rememberPersistentSentMessage({
2384
+ conversationId,
2385
+ messageId,
2386
+ sentAt: now
2387
+ });
2388
+ }
2389
+ function wasMSTeamsMessageSent(conversationId, messageId) {
2390
+ const entry = getSentMessageCache().get(conversationId);
2391
+ if (!entry) return false;
2392
+ cleanupExpired(conversationId, entry, Date.now());
2393
+ return entry.has(messageId);
2394
+ }
2395
+ async function wasMSTeamsMessageSentWithPersistence(params) {
2396
+ if (!params.conversationId || !params.messageId) return false;
2397
+ if (wasMSTeamsMessageSent(params.conversationId, params.messageId)) return true;
2398
+ const sentAt = await lookupPersistentSentMessage(params);
2399
+ if (sentAt == null) return false;
2400
+ rememberSentMessageInMemory(params.conversationId, params.messageId, sentAt);
2401
+ return wasMSTeamsMessageSent(params.conversationId, params.messageId);
2402
+ }
2403
+ //#endregion
2404
+ //#region extensions/msteams/src/monitor-handler/inbound-media.ts
2405
+ async function resolveMSTeamsInboundMedia(params) {
2406
+ const { attachments, htmlSummary, maxBytes, tokenProvider, allowHosts, conversationType, conversationId, conversationMessageId, serviceUrl, activity, log, preserveFilenames } = params;
2407
+ let mediaList = await downloadMSTeamsAttachments({
2408
+ attachments,
2409
+ maxBytes,
2410
+ tokenProvider,
2411
+ allowHosts,
2412
+ authAllowHosts: params.authAllowHosts,
2413
+ preserveFilenames,
2414
+ logger: log
2415
+ });
2416
+ if (mediaList.length === 0) {
2417
+ const attachmentIds = extractMSTeamsHtmlAttachmentIds(attachments);
2418
+ const hasHtmlFileAttachment = attachmentIds.length > 0;
2419
+ if (hasHtmlFileAttachment && isBotFrameworkPersonalChatId(conversationId)) if (!serviceUrl) log.debug?.("bot framework attachment skipped (missing serviceUrl)", {
2420
+ conversationType,
2421
+ conversationId
2422
+ });
2423
+ else {
2424
+ const bfMedia = await downloadMSTeamsBotFrameworkAttachments({
2425
+ serviceUrl,
2426
+ attachmentIds,
2427
+ tokenProvider,
2428
+ maxBytes,
2429
+ allowHosts,
2430
+ authAllowHosts: params.authAllowHosts,
2431
+ preserveFilenames
2432
+ });
2433
+ if (bfMedia.media.length > 0) mediaList = bfMedia.media;
2434
+ else log.debug?.("bot framework attachments fetch empty", {
2435
+ conversationType,
2436
+ attachmentCount: bfMedia.attachmentCount ?? attachmentIds.length
2437
+ });
2438
+ }
2439
+ if (hasHtmlFileAttachment && mediaList.length === 0 && !isBotFrameworkPersonalChatId(conversationId)) {
2440
+ const messageUrls = buildMSTeamsGraphMessageUrls({
2441
+ conversationType,
2442
+ conversationId,
2443
+ messageId: activity.id ?? void 0,
2444
+ replyToId: activity.replyToId ?? void 0,
2445
+ conversationMessageId,
2446
+ channelData: activity.channelData
2447
+ });
2448
+ if (messageUrls.length === 0) log.debug?.("graph message url unavailable", {
2449
+ conversationType,
2450
+ hasChannelData: Boolean(activity.channelData),
2451
+ messageId: activity.id ?? void 0,
2452
+ replyToId: activity.replyToId ?? void 0
2453
+ });
2454
+ else {
2455
+ const attempts = [];
2456
+ for (const messageUrl of messageUrls) {
2457
+ const graphMedia = await downloadMSTeamsGraphMedia({
2458
+ messageUrl,
2459
+ tokenProvider,
2460
+ maxBytes,
2461
+ allowHosts,
2462
+ authAllowHosts: params.authAllowHosts,
2463
+ preserveFilenames,
2464
+ log,
2465
+ logger: log
2466
+ });
2467
+ attempts.push({
2468
+ url: messageUrl,
2469
+ hostedStatus: graphMedia.hostedStatus,
2470
+ attachmentStatus: graphMedia.attachmentStatus,
2471
+ hostedCount: graphMedia.hostedCount,
2472
+ attachmentCount: graphMedia.attachmentCount,
2473
+ tokenError: graphMedia.tokenError
2474
+ });
2475
+ if (graphMedia.media.length > 0) {
2476
+ mediaList = graphMedia.media;
2477
+ break;
2478
+ }
2479
+ if (graphMedia.tokenError) break;
2480
+ }
2481
+ if (mediaList.length === 0) log.debug?.("graph media fetch empty", {
2482
+ attempts,
2483
+ attachmentIdCount: attachmentIds.length
2484
+ });
2485
+ }
2486
+ }
2487
+ }
2488
+ if (mediaList.length > 0) log.debug?.("downloaded attachments", { count: mediaList.length });
2489
+ else if (htmlSummary?.imgTags) log.debug?.("inline images detected but none downloaded", {
2490
+ imgTags: htmlSummary.imgTags,
2491
+ srcHosts: htmlSummary.srcHosts,
2492
+ dataImages: htmlSummary.dataImages,
2493
+ cidImages: htmlSummary.cidImages
2494
+ });
2495
+ return mediaList;
2496
+ }
2497
+ //#endregion
2498
+ //#region extensions/msteams/src/monitor-handler/thread-session.ts
2499
+ const TRAILING_THREAD_SUFFIX = /(?::thread:[^:]+)+$/;
2500
+ function resolveMSTeamsRouteSessionKey(params) {
2501
+ const channelThreadId = params.isChannel ? params.conversationMessageId ?? params.replyToId ?? void 0 : void 0;
2502
+ const cleanBase = params.baseSessionKey.replace(TRAILING_THREAD_SUFFIX, "");
2503
+ return resolveThreadSessionKeys({
2504
+ baseSessionKey: cleanBase,
2505
+ threadId: channelThreadId,
2506
+ parentSessionKey: channelThreadId ? cleanBase : void 0
2507
+ }).sessionKey;
2508
+ }
2509
+ //#endregion
2510
+ //#region extensions/msteams/src/monitor-handler/message-handler.ts
2511
+ function extractTextFromHtmlAttachments(attachments) {
2512
+ for (const attachment of attachments) {
2513
+ if (attachment.contentType !== "text/html") continue;
2514
+ const content = attachment.content;
2515
+ const raw = typeof content === "string" ? content : isRecord(content) && typeof content.text === "string" ? content.text : isRecord(content) && typeof content.body === "string" ? content.body : "";
2516
+ if (!raw) continue;
2517
+ const text = raw.replace(/<at[^>]*>.*?<\/at>/gis, " ").replace(/<a\b[^>]*href=["']([^"']+)["'][^>]*>(.*?)<\/a>/gis, "$2 $1").replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<[^>]+>/g, " ").replace(/&nbsp;/gi, " ").replace(/&amp;/gi, "&").replace(/\s+/g, " ").trim();
2518
+ if (text) return text;
2519
+ }
2520
+ return "";
2521
+ }
2522
+ function formatMSTeamsSenderReason(params) {
2523
+ switch (params.reasonCode) {
2524
+ case "dm_policy_open": return "dmPolicy=open";
2525
+ case "dm_policy_disabled": return "dmPolicy=disabled";
2526
+ case "dm_policy_pairing_required": return "dmPolicy=pairing (not allowlisted)";
2527
+ case "dm_policy_allowlisted": return `dmPolicy=${params.dmPolicy ?? "allowlist"} (allowlisted)`;
2528
+ case "dm_policy_not_allowlisted": return `dmPolicy=${params.dmPolicy ?? "allowlist"} (not allowlisted)`;
2529
+ case "group_policy_disabled": return "groupPolicy=disabled";
2530
+ case "group_policy_empty_allowlist":
2531
+ case "route_sender_empty": return "groupPolicy=allowlist (empty allowlist)";
2532
+ case "group_policy_not_allowlisted": return "groupPolicy=allowlist (not allowlisted)";
2533
+ case "group_policy_open": return "groupPolicy=open";
2534
+ case "group_policy_allowed": return `groupPolicy=${params.groupPolicy ?? "allowlist"}`;
2535
+ default: return params.reasonCode;
2536
+ }
2537
+ }
2538
+ function buildStoredConversationReference(params) {
2539
+ const { activity, conversationId, conversationType, teamId, threadId } = params;
2540
+ const from = activity.from;
2541
+ const conversation = activity.conversation;
2542
+ const agent = activity.recipient;
2543
+ const clientInfo = activity.entities?.find((e) => e.type === "clientInfo");
2544
+ const tenantId = activity.channelData?.tenant?.id ?? conversation?.tenantId;
2545
+ const aadObjectId = from?.aadObjectId;
2546
+ return {
2547
+ activityId: activity.id,
2548
+ user: from ? {
2549
+ id: from.id,
2550
+ name: from.name,
2551
+ aadObjectId: from.aadObjectId
2552
+ } : void 0,
2553
+ agent,
2554
+ bot: agent ? {
2555
+ id: agent.id,
2556
+ name: agent.name
2557
+ } : void 0,
2558
+ conversation: {
2559
+ id: conversationId,
2560
+ conversationType,
2561
+ tenantId
2562
+ },
2563
+ ...tenantId ? { tenantId } : {},
2564
+ ...aadObjectId ? { aadObjectId } : {},
2565
+ teamId,
2566
+ channelId: activity.channelId,
2567
+ serviceUrl: activity.serviceUrl,
2568
+ locale: activity.locale,
2569
+ ...clientInfo?.timezone ? { timezone: clientInfo.timezone } : {},
2570
+ ...threadId ? { threadId } : {}
2571
+ };
2572
+ }
2573
+ function createMSTeamsMessageHandler(deps) {
2574
+ const { cfg, runtime, appId, adapter, tokenProvider, textLimit, mediaMaxBytes, conversationStore, pollStore, log } = deps;
2575
+ const core = getMSTeamsRuntime();
2576
+ const logVerboseMessage = (message) => {
2577
+ if (core.logging.shouldLogVerbose()) log.debug?.(message);
2578
+ };
2579
+ const msteamsCfg = cfg.channels?.msteams;
2580
+ const contextVisibilityMode = resolveChannelContextVisibilityMode({
2581
+ cfg,
2582
+ channel: "msteams"
2583
+ });
2584
+ const historyLimit = Math.max(0, msteamsCfg?.historyLimit ?? cfg.messages?.groupChat?.historyLimit ?? 50);
2585
+ const conversationHistories = /* @__PURE__ */ new Map();
2586
+ const inboundDebounceMs = core.channel.debounce.resolveInboundDebounceMs({
2587
+ cfg,
2588
+ channel: "msteams"
2589
+ });
2590
+ const handleTeamsMessageNow = async (params) => {
2591
+ const context = params.context;
2592
+ const activity = context.activity;
2593
+ const rawText = params.rawText;
2594
+ const text = params.text;
2595
+ const attachments = params.attachments;
2596
+ const attachmentPlaceholder = buildMSTeamsAttachmentPlaceholder(attachments, {
2597
+ maxInlineBytes: mediaMaxBytes,
2598
+ maxInlineTotalBytes: mediaMaxBytes
2599
+ });
2600
+ const rawBody = text || attachmentPlaceholder;
2601
+ const quoteInfo = extractMSTeamsQuoteInfo(attachments);
2602
+ let quoteSenderId;
2603
+ let quoteSenderName;
2604
+ const from = activity.from;
2605
+ const conversation = activity.conversation;
2606
+ const attachmentTypes = attachments.map((att) => typeof att.contentType === "string" ? att.contentType : void 0).filter(Boolean).slice(0, 3);
2607
+ const htmlSummary = summarizeMSTeamsHtmlAttachments(attachments);
2608
+ log.info("received message", {
2609
+ rawText: rawText.slice(0, 50),
2610
+ text: text.slice(0, 50),
2611
+ attachments: attachments.length,
2612
+ attachmentTypes,
2613
+ from: from?.id,
2614
+ conversation: conversation?.id
2615
+ });
2616
+ if (htmlSummary) log.debug?.("html attachment summary", htmlSummary);
2617
+ if (!from?.id) {
2618
+ log.debug?.("skipping message without from.id");
2619
+ return;
2620
+ }
2621
+ const rawConversationId = conversation?.id ?? "";
2622
+ const conversationId = normalizeMSTeamsConversationId(rawConversationId);
2623
+ const conversationMessageId = extractMSTeamsConversationMessageId(rawConversationId);
2624
+ const conversationType = conversation?.conversationType ?? "personal";
2625
+ const teamId = activity.channelData?.team?.id;
2626
+ const conversationRef = buildStoredConversationReference({
2627
+ activity,
2628
+ conversationId,
2629
+ conversationType,
2630
+ teamId,
2631
+ threadId: conversationType === "channel" ? conversationMessageId ?? activity.replyToId ?? void 0 : void 0
2632
+ });
2633
+ const allowTextCommands = core.channel.commands.shouldHandleTextCommands({
2634
+ cfg,
2635
+ surface: "msteams"
2636
+ });
2637
+ const isControlCommand = allowTextCommands && core.channel.commands.isControlCommandMessage(text, cfg);
2638
+ const { dmPolicy, senderId, senderName, pairing, isDirectMessage, channelGate, senderAccess, commandAccess, allowNameMatching, groupPolicy } = await resolveMSTeamsSenderAccess({
2639
+ cfg,
2640
+ activity,
2641
+ hasControlCommand: isControlCommand
2642
+ });
2643
+ const commandAuthorized = commandAccess.requested ? commandAccess.authorized : void 0;
2644
+ const effectiveDmAllowFrom = senderAccess.effectiveAllowFrom;
2645
+ const effectiveGroupAllowFrom = senderAccess.effectiveGroupAllowFrom;
2646
+ const isChannel = conversationType === "channel";
2647
+ if (isDirectMessage && msteamsCfg && senderAccess.decision !== "allow") {
2648
+ if (senderAccess.reasonCode === "dm_policy_disabled") {
2649
+ log.info("dropping dm (dms disabled)", {
2650
+ sender: senderId,
2651
+ label: senderName
2652
+ });
2653
+ log.debug?.("dropping dm (dms disabled)");
2654
+ return;
2655
+ }
2656
+ const allowMatch = resolveMSTeamsAllowlistMatch({
2657
+ allowFrom: effectiveDmAllowFrom,
2658
+ senderId,
2659
+ senderName,
2660
+ allowNameMatching
2661
+ });
2662
+ if (senderAccess.decision === "pairing") {
2663
+ conversationStore.upsert(conversationId, conversationRef).catch((err) => {
2664
+ log.debug?.("failed to save conversation reference", { error: formatUnknownError(err) });
2665
+ });
2666
+ if (await pairing.upsertPairingRequest({
2667
+ id: senderId,
2668
+ meta: { name: senderName }
2669
+ })) log.info("msteams pairing request created", {
2670
+ sender: senderId,
2671
+ label: senderName
2672
+ });
2673
+ }
2674
+ log.debug?.("dropping dm (not allowlisted)", {
2675
+ sender: senderId,
2676
+ label: senderName,
2677
+ allowlistMatch: formatAllowlistMatchMeta(allowMatch)
2678
+ });
2679
+ log.info("dropping dm (not allowlisted)", {
2680
+ sender: senderId,
2681
+ label: senderName,
2682
+ dmPolicy,
2683
+ reason: formatMSTeamsSenderReason({
2684
+ reasonCode: senderAccess.reasonCode,
2685
+ dmPolicy,
2686
+ groupPolicy
2687
+ }),
2688
+ allowlistMatch: formatAllowlistMatchMeta(allowMatch)
2689
+ });
2690
+ return;
2691
+ }
2692
+ if (!isDirectMessage && msteamsCfg) {
2693
+ if (channelGate.allowlistConfigured && !channelGate.allowed) {
2694
+ log.info("dropping group message (not in team/channel allowlist)", {
2695
+ conversationId,
2696
+ teamKey: channelGate.teamKey ?? "none",
2697
+ channelKey: channelGate.channelKey ?? "none",
2698
+ channelMatchKey: channelGate.channelMatchKey ?? "none",
2699
+ channelMatchSource: channelGate.channelMatchSource ?? "none"
2700
+ });
2701
+ log.debug?.("dropping group message (not in team/channel allowlist)", {
2702
+ conversationId,
2703
+ teamKey: channelGate.teamKey ?? "none",
2704
+ channelKey: channelGate.channelKey ?? "none",
2705
+ channelMatchKey: channelGate.channelMatchKey ?? "none",
2706
+ channelMatchSource: channelGate.channelMatchSource ?? "none"
2707
+ });
2708
+ return;
2709
+ }
2710
+ if (!senderAccess.allowed && senderAccess.reasonCode === "group_policy_disabled") {
2711
+ log.info("dropping group message (groupPolicy: disabled)", { conversationId });
2712
+ log.debug?.("dropping group message (groupPolicy: disabled)", { conversationId });
2713
+ return;
2714
+ }
2715
+ if (!senderAccess.allowed && (senderAccess.reasonCode === "group_policy_empty_allowlist" || senderAccess.reasonCode === "route_sender_empty")) {
2716
+ log.info("dropping group message (groupPolicy: allowlist, no allowlist)", { conversationId });
2717
+ log.debug?.("dropping group message (groupPolicy: allowlist, no allowlist)", { conversationId });
2718
+ return;
2719
+ }
2720
+ if (!senderAccess.allowed && senderAccess.reasonCode === "group_policy_not_allowlisted") {
2721
+ const allowMatch = resolveMSTeamsAllowlistMatch({
2722
+ allowFrom: effectiveGroupAllowFrom,
2723
+ senderId,
2724
+ senderName,
2725
+ allowNameMatching
2726
+ });
2727
+ log.debug?.("dropping group message (not in groupAllowFrom)", {
2728
+ sender: senderId,
2729
+ label: senderName,
2730
+ allowlistMatch: formatAllowlistMatchMeta(allowMatch)
2731
+ });
2732
+ log.info("dropping group message (not in groupAllowFrom)", {
2733
+ sender: senderId,
2734
+ label: senderName,
2735
+ allowlistMatch: formatAllowlistMatchMeta(allowMatch)
2736
+ });
2737
+ return;
2738
+ }
2739
+ }
2740
+ if (commandAccess.shouldBlockControlCommand) {
2741
+ logInboundDrop({
2742
+ log: logVerboseMessage,
2743
+ channel: "msteams",
2744
+ reason: "control command (unauthorized)",
2745
+ target: senderId
2746
+ });
2747
+ return;
2748
+ }
2749
+ conversationStore.upsert(conversationId, conversationRef).catch((err) => {
2750
+ log.debug?.("failed to save conversation reference", { error: formatUnknownError(err) });
2751
+ });
2752
+ const pollVote = extractMSTeamsPollVote(activity);
2753
+ if (pollVote) {
2754
+ try {
2755
+ if (!await pollStore.recordVote({
2756
+ pollId: pollVote.pollId,
2757
+ voterId: senderId,
2758
+ selections: pollVote.selections
2759
+ })) log.debug?.("poll vote ignored (poll not found)", { pollId: pollVote.pollId });
2760
+ else log.info("recorded poll vote", {
2761
+ pollId: pollVote.pollId,
2762
+ voter: senderId,
2763
+ selections: pollVote.selections
2764
+ });
2765
+ } catch (err) {
2766
+ log.error("failed to record poll vote", {
2767
+ pollId: pollVote.pollId,
2768
+ error: formatUnknownError(err)
2769
+ });
2770
+ }
2771
+ return;
2772
+ }
2773
+ if (!rawBody) {
2774
+ log.debug?.("skipping empty message after stripping mentions");
2775
+ return;
2776
+ }
2777
+ const teamsFrom = isDirectMessage ? `msteams:${senderId}` : isChannel ? `msteams:channel:${conversationId}` : `msteams:group:${conversationId}`;
2778
+ const teamsTo = isDirectMessage ? `user:${senderId}` : `conversation:${conversationId}`;
2779
+ const route = core.channel.routing.resolveAgentRoute({
2780
+ cfg,
2781
+ channel: "msteams",
2782
+ teamId,
2783
+ peer: {
2784
+ kind: isDirectMessage ? "direct" : isChannel ? "channel" : "group",
2785
+ id: isDirectMessage ? senderId : conversationId
2786
+ }
2787
+ });
2788
+ route.sessionKey = resolveMSTeamsRouteSessionKey({
2789
+ baseSessionKey: route.sessionKey,
2790
+ isChannel,
2791
+ conversationMessageId,
2792
+ replyToId: activity.replyToId
2793
+ });
2794
+ const preview = rawBody.replace(/\s+/g, " ").slice(0, 160);
2795
+ const inboundLabel = isDirectMessage ? `Teams DM from ${senderName}` : `Teams message in ${conversationType} from ${senderName}`;
2796
+ const enqueuePrimaryMessageSystemEvent = () => core.system.enqueueSystemEvent(`${inboundLabel}: ${preview}`, {
2797
+ sessionKey: route.sessionKey,
2798
+ contextKey: `msteams:message:${conversationId}:${activity.id ?? "unknown"}`
2799
+ });
2800
+ const channelId = conversationId;
2801
+ const { teamConfig, channelConfig } = channelGate;
2802
+ const { requireMention, replyStyle } = resolveMSTeamsReplyPolicy({
2803
+ isDirectMessage,
2804
+ globalConfig: msteamsCfg,
2805
+ teamConfig,
2806
+ channelConfig
2807
+ });
2808
+ const timestamp = parseMSTeamsActivityTimestamp(activity.timestamp);
2809
+ const mentionDecision = resolveInboundMentionDecision({
2810
+ facts: {
2811
+ canDetectMention: true,
2812
+ wasMentioned: params.wasMentioned,
2813
+ implicitMentionKinds: params.implicitMentionKinds
2814
+ },
2815
+ policy: {
2816
+ isGroup: !isDirectMessage,
2817
+ requireMention,
2818
+ allowTextCommands,
2819
+ hasControlCommand: isControlCommand,
2820
+ commandAuthorized: commandAuthorized === true
2821
+ }
2822
+ });
2823
+ if (!isDirectMessage) {
2824
+ const mentioned = mentionDecision.effectiveWasMentioned;
2825
+ if (requireMention && mentionDecision.shouldSkip) {
2826
+ log.debug?.("skipping message (mention required)", {
2827
+ teamId,
2828
+ channelId,
2829
+ requireMention,
2830
+ mentioned
2831
+ });
2832
+ enqueuePrimaryMessageSystemEvent();
2833
+ createChannelHistoryWindow({ historyMap: conversationHistories }).record({
2834
+ historyKey: conversationId,
2835
+ limit: historyLimit,
2836
+ entry: {
2837
+ sender: senderName,
2838
+ body: rawBody,
2839
+ timestamp: timestamp?.getTime(),
2840
+ messageId: activity.id ?? void 0
2841
+ }
2842
+ });
2843
+ return;
2844
+ }
2845
+ }
2846
+ enqueuePrimaryMessageSystemEvent();
2847
+ let graphConversationId = translateMSTeamsDmConversationIdForGraph({
2848
+ isDirectMessage,
2849
+ conversationId,
2850
+ aadObjectId: from.aadObjectId,
2851
+ appId
2852
+ });
2853
+ if (isDirectMessage && conversationId.startsWith("a:")) {
2854
+ const cached = await conversationStore.get(conversationId);
2855
+ if (cached?.graphChatId) graphConversationId = cached.graphChatId;
2856
+ else try {
2857
+ const resolved = await resolveGraphChatId({
2858
+ botFrameworkConversationId: conversationId,
2859
+ userAadObjectId: from.aadObjectId ?? void 0,
2860
+ tokenProvider
2861
+ });
2862
+ if (resolved) {
2863
+ graphConversationId = resolved;
2864
+ conversationStore.upsert(conversationId, {
2865
+ ...conversationRef,
2866
+ graphChatId: resolved
2867
+ }).catch(() => {});
2868
+ }
2869
+ } catch {
2870
+ log.debug?.("failed to resolve Graph chat ID for inbound media", { conversationId });
2871
+ }
2872
+ }
2873
+ const mediaPayload = buildMSTeamsMediaPayload(await resolveMSTeamsInboundMedia({
2874
+ attachments,
2875
+ htmlSummary: htmlSummary ?? void 0,
2876
+ maxBytes: mediaMaxBytes,
2877
+ tokenProvider,
2878
+ allowHosts: msteamsCfg?.mediaAllowHosts,
2879
+ authAllowHosts: msteamsCfg?.mediaAuthAllowHosts,
2880
+ conversationType,
2881
+ conversationId: graphConversationId,
2882
+ conversationMessageId: conversationMessageId ?? void 0,
2883
+ serviceUrl: activity.serviceUrl,
2884
+ activity: {
2885
+ id: activity.id,
2886
+ replyToId: activity.replyToId,
2887
+ channelData: activity.channelData
2888
+ },
2889
+ log,
2890
+ preserveFilenames: cfg.media?.preserveFilenames
2891
+ }));
2892
+ let threadContext;
2893
+ if (activity.replyToId && isChannel && teamId) try {
2894
+ const graphToken = await tokenProvider.getAccessToken("https://graph.microsoft.com");
2895
+ const groupId = await resolveTeamGroupId(graphToken, teamId);
2896
+ const [parentResult, repliesResult] = await Promise.allSettled([fetchParentMessageCached(graphToken, groupId, conversationId, activity.replyToId), fetchThreadReplies(graphToken, groupId, conversationId, activity.replyToId)]);
2897
+ const parentMsg = parentResult.status === "fulfilled" ? parentResult.value : void 0;
2898
+ const replies = repliesResult.status === "fulfilled" ? repliesResult.value : [];
2899
+ if (parentResult.status === "rejected") log.debug?.("failed to fetch parent message", { error: formatUnknownError(parentResult.reason) });
2900
+ if (repliesResult.status === "rejected") log.debug?.("failed to fetch thread replies", { error: formatUnknownError(repliesResult.reason) });
2901
+ const isThreadSenderAllowed = (msg) => groupPolicy === "allowlist" ? resolveMSTeamsAllowlistMatch({
2902
+ allowFrom: effectiveGroupAllowFrom,
2903
+ senderId: msg.from?.user?.id ?? "",
2904
+ senderName: msg.from?.user?.displayName,
2905
+ allowNameMatching
2906
+ }).allowed : true;
2907
+ const parentSummary = summarizeParentMessage(parentMsg);
2908
+ const visibleParentMessages = parentMsg ? filterSupplementalContextItems({
2909
+ items: [parentMsg],
2910
+ mode: contextVisibilityMode,
2911
+ kind: "thread",
2912
+ isSenderAllowed: isThreadSenderAllowed
2913
+ }).items : [];
2914
+ if (parentSummary && visibleParentMessages.length > 0 && shouldInjectParentContext(route.sessionKey, activity.replyToId)) {
2915
+ core.system.enqueueSystemEvent(formatParentContextEvent(parentSummary), {
2916
+ sessionKey: route.sessionKey,
2917
+ contextKey: `msteams:thread-parent:${conversationId}:${activity.replyToId}`
2918
+ });
2919
+ markParentContextInjected(route.sessionKey, activity.replyToId);
2920
+ }
2921
+ const allMessages = parentMsg ? [parentMsg, ...replies] : replies;
2922
+ quoteSenderId = parentMsg?.from?.user?.id ?? parentMsg?.from?.application?.id ?? void 0;
2923
+ quoteSenderName = parentMsg?.from?.user?.displayName ?? parentMsg?.from?.application?.displayName ?? quoteInfo?.sender;
2924
+ const { items: threadMessages } = filterSupplementalContextItems({
2925
+ items: allMessages,
2926
+ mode: contextVisibilityMode,
2927
+ kind: "thread",
2928
+ isSenderAllowed: isThreadSenderAllowed
2929
+ });
2930
+ const formatted = formatThreadContext(threadMessages, activity.id);
2931
+ if (formatted) threadContext = formatted;
2932
+ } catch (err) {
2933
+ log.debug?.("failed to fetch thread history", { error: formatUnknownError(err) });
2934
+ }
2935
+ quoteSenderName ??= quoteInfo?.sender;
2936
+ const envelopeFrom = isDirectMessage ? senderName : conversationType;
2937
+ const { storePath, envelopeOptions, previousTimestamp } = resolveInboundSessionEnvelopeContext({
2938
+ cfg,
2939
+ agentId: route.agentId,
2940
+ sessionKey: route.sessionKey
2941
+ });
2942
+ let combinedBody = core.channel.reply.formatAgentEnvelope({
2943
+ channel: "Teams",
2944
+ from: envelopeFrom,
2945
+ timestamp,
2946
+ previousTimestamp,
2947
+ envelope: envelopeOptions,
2948
+ body: rawBody
2949
+ });
2950
+ const isRoomish = !isDirectMessage;
2951
+ const historyKey = isRoomish ? conversationId : void 0;
2952
+ if (isRoomish && historyKey) combinedBody = createChannelHistoryWindow({ historyMap: conversationHistories }).buildPendingContext({
2953
+ historyKey,
2954
+ limit: historyLimit,
2955
+ currentMessage: combinedBody,
2956
+ formatEntry: (entry) => core.channel.reply.formatAgentEnvelope({
2957
+ channel: "Teams",
2958
+ from: conversationType,
2959
+ timestamp: entry.timestamp,
2960
+ body: `${entry.sender}: ${entry.body}${entry.messageId ? ` [id:${entry.messageId}]` : ""}`,
2961
+ envelope: envelopeOptions
2962
+ })
2963
+ });
2964
+ const inboundHistory = isRoomish && historyKey && historyLimit > 0 ? createChannelHistoryWindow({ historyMap: conversationHistories }).buildInboundHistory({
2965
+ historyKey,
2966
+ limit: historyLimit
2967
+ }) : void 0;
2968
+ const commandBody = text.trim();
2969
+ const quoteSenderAllowed = quoteInfo && quoteInfo.sender ? !isChannel || groupPolicy !== "allowlist" ? true : resolveMSTeamsAllowlistMatch({
2970
+ allowFrom: effectiveGroupAllowFrom,
2971
+ senderId: quoteSenderId ?? "",
2972
+ senderName: quoteSenderName,
2973
+ allowNameMatching
2974
+ }).allowed : true;
2975
+ const includeQuoteContext = quoteInfo && shouldIncludeSupplementalContext({
2976
+ mode: contextVisibilityMode,
2977
+ kind: "quote",
2978
+ senderAllowed: quoteSenderAllowed
2979
+ });
2980
+ const bodyForAgent = threadContext ? `[Thread history]\n${threadContext}\n[/Thread history]\n\n${rawBody}` : rawBody;
2981
+ const nativeChannelId = isChannel && teamId ? `${teamId}/${conversationId}` : void 0;
2982
+ const ctxPayload = core.channel.reply.finalizeInboundContext({
2983
+ Body: combinedBody,
2984
+ BodyForAgent: bodyForAgent,
2985
+ InboundHistory: inboundHistory,
2986
+ RawBody: rawBody,
2987
+ CommandBody: commandBody,
2988
+ BodyForCommands: commandBody,
2989
+ From: teamsFrom,
2990
+ To: teamsTo,
2991
+ SessionKey: route.sessionKey,
2992
+ AccountId: route.accountId,
2993
+ ChatType: isDirectMessage ? "direct" : isChannel ? "channel" : "group",
2994
+ ConversationLabel: envelopeFrom,
2995
+ GroupSubject: !isDirectMessage ? conversationType : void 0,
2996
+ GroupSpace: teamId,
2997
+ SenderName: senderName,
2998
+ SenderId: senderId,
2999
+ Provider: "msteams",
3000
+ Surface: "msteams",
3001
+ MessageSid: activity.id,
3002
+ Timestamp: timestamp?.getTime() ?? Date.now(),
3003
+ WasMentioned: isDirectMessage || mentionDecision.effectiveWasMentioned,
3004
+ CommandAuthorized: commandAuthorized,
3005
+ OriginatingChannel: "msteams",
3006
+ OriginatingTo: teamsTo,
3007
+ NativeChannelId: nativeChannelId,
3008
+ ReplyToId: activity.replyToId ?? void 0,
3009
+ ReplyToBody: includeQuoteContext ? quoteInfo?.body : void 0,
3010
+ ReplyToSender: includeQuoteContext ? quoteInfo?.sender : void 0,
3011
+ ReplyToIsQuote: quoteInfo ? true : void 0,
3012
+ ...mediaPayload
3013
+ });
3014
+ logVerboseMessage(`msteams inbound: from=${ctxPayload.From} preview="${preview}"`);
3015
+ const sharePointSiteId = msteamsCfg?.sharePointSiteId;
3016
+ const { dispatcher, replyOptions, markDispatchIdle } = createMSTeamsReplyDispatcher({
3017
+ cfg,
3018
+ agentId: route.agentId,
3019
+ sessionKey: route.sessionKey,
3020
+ accountId: route.accountId,
3021
+ runtime,
3022
+ log,
3023
+ adapter,
3024
+ appId,
3025
+ conversationRef,
3026
+ context,
3027
+ replyStyle,
3028
+ textLimit,
3029
+ onSentMessageIds: (ids) => {
3030
+ for (const id of ids) recordMSTeamsSentMessage(conversationId, id);
3031
+ },
3032
+ tokenProvider,
3033
+ sharePointSiteId
3034
+ });
3035
+ const senderTimezone = (activity.entities?.find((e) => e.type === "clientInfo"))?.timezone || conversationRef.timezone;
3036
+ const configOverride = senderTimezone && !cfg.agents?.defaults?.userTimezone ? { agents: { defaults: {
3037
+ ...cfg.agents?.defaults,
3038
+ userTimezone: senderTimezone
3039
+ } } } : void 0;
3040
+ log.info("dispatching to agent", { sessionKey: route.sessionKey });
3041
+ try {
3042
+ const turnResult = await core.channel.turn.run({
3043
+ channel: "msteams",
3044
+ accountId: route.accountId,
3045
+ raw: context,
3046
+ adapter: {
3047
+ ingest: () => ({
3048
+ id: activity.id ?? `${teamsFrom}:${Date.now()}`,
3049
+ timestamp: timestamp?.getTime(),
3050
+ rawText: rawBody,
3051
+ textForAgent: bodyForAgent,
3052
+ textForCommands: commandBody,
3053
+ raw: activity
3054
+ }),
3055
+ resolveTurn: () => ({
3056
+ channel: "msteams",
3057
+ accountId: route.accountId,
3058
+ routeSessionKey: route.sessionKey,
3059
+ storePath,
3060
+ ctxPayload,
3061
+ recordInboundSession: core.channel.session.recordInboundSession,
3062
+ record: { onRecordError: (err) => {
3063
+ logVerboseMessage(`msteams: failed updating session meta: ${formatUnknownError(err)}`);
3064
+ } },
3065
+ history: {
3066
+ isGroup: isRoomish,
3067
+ historyKey,
3068
+ historyMap: conversationHistories,
3069
+ limit: historyLimit
3070
+ },
3071
+ onPreDispatchFailure: () => core.channel.reply.settleReplyDispatcher({
3072
+ dispatcher,
3073
+ onSettled: () => markDispatchIdle()
3074
+ }),
3075
+ runDispatch: () => dispatchReplyFromConfigWithSettledDispatcher({
3076
+ cfg,
3077
+ ctxPayload,
3078
+ dispatcher,
3079
+ onSettled: () => markDispatchIdle(),
3080
+ replyOptions,
3081
+ configOverride
3082
+ })
3083
+ })
3084
+ }
3085
+ });
3086
+ const dispatchResult = turnResult.dispatched ? turnResult.dispatchResult : void 0;
3087
+ const queuedFinal = dispatchResult?.queuedFinal ?? false;
3088
+ const counts = resolveChannelTurnDispatchCounts(dispatchResult);
3089
+ const hasFinalResponse = hasFinalChannelTurnDispatch(dispatchResult);
3090
+ log.info("dispatch complete", {
3091
+ queuedFinal,
3092
+ counts
3093
+ });
3094
+ if (!hasFinalResponse) return;
3095
+ const finalCount = counts.final;
3096
+ logVerboseMessage(`msteams: delivered ${finalCount} reply${finalCount === 1 ? "" : "ies"} to ${teamsTo}`);
3097
+ } catch (err) {
3098
+ log.error("dispatch failed", { error: formatUnknownError(err) });
3099
+ runtime.error(`msteams dispatch failed: ${formatUnknownError(err)}`);
3100
+ try {
3101
+ await context.sendActivity("⚠️ Something went wrong. Please try again.");
3102
+ } catch {}
3103
+ }
3104
+ };
3105
+ const inboundDebouncer = core.channel.debounce.createInboundDebouncer({
3106
+ debounceMs: inboundDebounceMs,
3107
+ buildKey: (entry) => {
3108
+ const conversationId = normalizeMSTeamsConversationId(entry.context.activity.conversation?.id ?? "");
3109
+ const senderId = entry.context.activity.from?.aadObjectId ?? entry.context.activity.from?.id ?? "";
3110
+ if (!senderId || !conversationId) return null;
3111
+ return `msteams:${appId}:${conversationId}:${senderId}`;
3112
+ },
3113
+ shouldDebounce: (entry) => {
3114
+ if (!entry.text.trim()) return false;
3115
+ if (entry.attachments.length > 0) return false;
3116
+ return !core.channel.commands.isControlCommandMessage(entry.text, cfg);
3117
+ },
3118
+ onFlush: async (entries) => {
3119
+ const last = entries.at(-1);
3120
+ if (!last) return;
3121
+ if (entries.length === 1) {
3122
+ await handleTeamsMessageNow(last);
3123
+ return;
3124
+ }
3125
+ const combinedText = entries.map((entry) => entry.text).filter(Boolean).join("\n");
3126
+ if (!combinedText.trim()) return;
3127
+ const combinedRawText = entries.map((entry) => entry.rawText).filter(Boolean).join("\n");
3128
+ const wasMentioned = entries.some((entry) => entry.wasMentioned);
3129
+ const implicitMentionKinds = entries.flatMap((entry) => entry.implicitMentionKinds);
3130
+ await handleTeamsMessageNow({
3131
+ context: last.context,
3132
+ rawText: combinedRawText,
3133
+ text: combinedText,
3134
+ attachments: [],
3135
+ wasMentioned,
3136
+ implicitMentionKinds
3137
+ });
3138
+ },
3139
+ onError: (err) => {
3140
+ runtime.error(`msteams debounce flush failed: ${formatUnknownError(err)}`);
3141
+ }
3142
+ });
3143
+ return async function handleTeamsMessage(context) {
3144
+ const activity = context.activity;
3145
+ const attachments = Array.isArray(activity.attachments) ? activity.attachments : [];
3146
+ const rawText = activity.text?.trim() ?? "";
3147
+ const htmlText = extractTextFromHtmlAttachments(attachments);
3148
+ const text = stripMSTeamsMentionTags(rawText || htmlText);
3149
+ const wasMentioned = wasMSTeamsBotMentioned(activity);
3150
+ const conversationId = normalizeMSTeamsConversationId(activity.conversation?.id ?? "");
3151
+ const replyToId = activity.replyToId ?? void 0;
3152
+ const implicitMentionKinds = conversationId && replyToId && await wasMSTeamsMessageSentWithPersistence({
3153
+ conversationId,
3154
+ messageId: replyToId
3155
+ }) ? ["reply_to_bot"] : [];
3156
+ await inboundDebouncer.enqueue({
3157
+ context,
3158
+ rawText,
3159
+ text,
3160
+ attachments,
3161
+ wasMentioned,
3162
+ implicitMentionKinds
3163
+ });
3164
+ };
3165
+ }
3166
+ //#endregion
3167
+ //#region extensions/msteams/src/monitor-handler/reaction-handler.ts
3168
+ /** Teams reaction type names → Unicode emoji. */
3169
+ const TEAMS_REACTION_EMOJI = {
3170
+ like: "👍",
3171
+ heart: "❤️",
3172
+ laugh: "😆",
3173
+ surprised: "😮",
3174
+ sad: "😢",
3175
+ angry: "😡"
3176
+ };
3177
+ /**
3178
+ * Map a Teams reaction type string to a Unicode emoji.
3179
+ * Falls back to the raw type if not recognized.
3180
+ */
3181
+ function mapReactionEmoji(reactionType) {
3182
+ return TEAMS_REACTION_EMOJI[reactionType] ?? reactionType;
3183
+ }
3184
+ /**
3185
+ * Create a handler for MS Teams reaction activities (reactionsAdded / reactionsRemoved).
3186
+ * The returned function accepts a turn context and a direction string.
3187
+ */
3188
+ function createMSTeamsReactionHandler(deps) {
3189
+ const { cfg, log } = deps;
3190
+ const core = getMSTeamsRuntime();
3191
+ const msteamsCfg = cfg.channels?.msteams;
3192
+ return async function handleReaction(context, direction) {
3193
+ const activity = context.activity;
3194
+ const reactions = direction === "added" ? activity.reactionsAdded ?? [] : activity.reactionsRemoved ?? [];
3195
+ if (reactions.length === 0) {
3196
+ log.debug?.("reaction activity has no reactions; skipping");
3197
+ return;
3198
+ }
3199
+ const from = activity.from;
3200
+ if (!from?.id) {
3201
+ log.debug?.("reaction activity missing from.id; skipping");
3202
+ return;
3203
+ }
3204
+ const conversationId = normalizeMSTeamsConversationId(activity.conversation?.id ?? "");
3205
+ const conversationType = activity.conversation?.conversationType ?? "personal";
3206
+ const isGroupChat = conversationType === "groupChat" || activity.conversation?.isGroup === true;
3207
+ const isChannel = conversationType === "channel";
3208
+ const isDirectMessage = !isGroupChat && !isChannel;
3209
+ const senderId = from.aadObjectId ?? from.id;
3210
+ const senderName = from.name ?? from.id;
3211
+ if (msteamsCfg) {
3212
+ const senderAccess = await resolveMSTeamsSenderAccess({
3213
+ cfg,
3214
+ activity
3215
+ });
3216
+ if (senderAccess.senderAccess.decision !== "allow") {
3217
+ log.debug?.("dropping reaction (access denied)", {
3218
+ sender: senderId,
3219
+ reason: senderAccess.senderAccess.reasonCode
3220
+ });
3221
+ return;
3222
+ }
3223
+ }
3224
+ const teamId = isDirectMessage ? void 0 : activity.channelData?.team?.id;
3225
+ const route = core.channel.routing.resolveAgentRoute({
3226
+ cfg,
3227
+ channel: "msteams",
3228
+ peer: {
3229
+ kind: isDirectMessage ? "direct" : isChannel ? "channel" : "group",
3230
+ id: isDirectMessage ? senderId : conversationId
3231
+ },
3232
+ ...teamId ? { teamId } : {}
3233
+ });
3234
+ const targetMessageId = activity.replyToId ?? "unknown";
3235
+ for (const reaction of reactions) {
3236
+ const reactionType = reaction.type ?? "unknown";
3237
+ const emoji = mapReactionEmoji(reactionType);
3238
+ const label = direction === "added" ? `Teams reaction ${emoji} added by ${senderName} on message ${targetMessageId}` : `Teams reaction ${emoji} removed by ${senderName} from message ${targetMessageId}`;
3239
+ log.info(`reaction ${direction}`, {
3240
+ sender: senderId,
3241
+ reactionType,
3242
+ emoji,
3243
+ targetMessageId,
3244
+ conversationId
3245
+ });
3246
+ core.system.enqueueSystemEvent(label, {
3247
+ sessionKey: route.sessionKey,
3248
+ contextKey: `msteams:reaction:${conversationId}:${targetMessageId}:${senderId}:${reactionType}:${direction}`
3249
+ });
3250
+ }
3251
+ };
3252
+ }
3253
+ //#endregion
3254
+ //#region extensions/msteams/src/sso.ts
3255
+ /** Scope used to obtain a Bot Framework service token. */
3256
+ const BOT_FRAMEWORK_TOKEN_SCOPE = "https://api.botframework.com/.default";
3257
+ /** Bot Framework User Token service base URL. */
3258
+ const BOT_FRAMEWORK_USER_TOKEN_BASE_URL = "https://token.botframework.com";
3259
+ /**
3260
+ * Extract and validate the `signin/tokenExchange` activity value. Teams
3261
+ * delivers `{ id, connectionName, token }`; any field may be missing on
3262
+ * malformed invocations, so callers should check the parsed result.
3263
+ */
3264
+ function parseSigninTokenExchangeValue(value) {
3265
+ if (!value || typeof value !== "object") return null;
3266
+ const obj = value;
3267
+ return {
3268
+ id: typeof obj.id === "string" ? obj.id : void 0,
3269
+ connectionName: typeof obj.connectionName === "string" ? obj.connectionName : void 0,
3270
+ token: typeof obj.token === "string" ? obj.token : void 0
3271
+ };
3272
+ }
3273
+ /** Extract the `signin/verifyState` activity value `{ state }`. */
3274
+ function parseSigninVerifyStateValue(value) {
3275
+ if (!value || typeof value !== "object") return null;
3276
+ const obj = value;
3277
+ return { state: typeof obj.state === "string" ? obj.state : void 0 };
3278
+ }
3279
+ async function callUserTokenService(params) {
3280
+ const qs = new URLSearchParams(params.query).toString();
3281
+ const url = `${params.baseUrl.replace(/\/+$/, "")}${params.path}?${qs}`;
3282
+ const headers = {
3283
+ Accept: "application/json",
3284
+ Authorization: `Bearer ${params.bearerToken}`,
3285
+ "User-Agent": buildUserAgent()
3286
+ };
3287
+ if (params.body !== void 0) headers["Content-Type"] = "application/json";
3288
+ const response = await params.fetchImpl(url, {
3289
+ method: params.method,
3290
+ headers,
3291
+ body: params.body === void 0 ? void 0 : JSON.stringify(params.body)
3292
+ });
3293
+ if (!response.ok) return {
3294
+ error: await response.text().catch(() => "") || `HTTP ${response.status}`,
3295
+ status: response.status
3296
+ };
3297
+ let parsed;
3298
+ try {
3299
+ parsed = await response.json();
3300
+ } catch {
3301
+ return {
3302
+ error: "invalid JSON from User Token service",
3303
+ status: response.status
3304
+ };
3305
+ }
3306
+ if (!parsed || typeof parsed !== "object") return {
3307
+ error: "empty response from User Token service",
3308
+ status: response.status
3309
+ };
3310
+ const obj = parsed;
3311
+ const token = typeof obj.token === "string" ? obj.token : void 0;
3312
+ const connectionName = typeof obj.connectionName === "string" ? obj.connectionName : void 0;
3313
+ const channelId = typeof obj.channelId === "string" ? obj.channelId : void 0;
3314
+ const expiration = typeof obj.expiration === "string" ? obj.expiration : void 0;
3315
+ if (!token || !connectionName) return {
3316
+ error: "User Token service response missing token/connectionName",
3317
+ status: 502
3318
+ };
3319
+ return {
3320
+ channelId,
3321
+ connectionName,
3322
+ token,
3323
+ expiration
3324
+ };
3325
+ }
3326
+ /**
3327
+ * Exchange a Teams SSO token for a delegated user token via Bot
3328
+ * Framework's User Token service, then persist the result.
3329
+ */
3330
+ async function handleSigninTokenExchangeInvoke(params) {
3331
+ const { value, user, deps } = params;
3332
+ if (!user.userId) return {
3333
+ ok: false,
3334
+ code: "missing_user",
3335
+ message: "no user id on invoke activity"
3336
+ };
3337
+ const connectionName = value.connectionName?.trim() || deps.connectionName;
3338
+ if (!connectionName) return {
3339
+ ok: false,
3340
+ code: "missing_connection",
3341
+ message: "no OAuth connection name"
3342
+ };
3343
+ if (!value.token) return {
3344
+ ok: false,
3345
+ code: "missing_token",
3346
+ message: "no exchangeable token on invoke"
3347
+ };
3348
+ const bearer = await deps.tokenProvider.getAccessToken(BOT_FRAMEWORK_TOKEN_SCOPE);
3349
+ const fetchImpl = deps.fetchImpl ?? globalThis.fetch;
3350
+ const result = await callUserTokenService({
3351
+ baseUrl: deps.userTokenBaseUrl ?? BOT_FRAMEWORK_USER_TOKEN_BASE_URL,
3352
+ path: "/api/usertoken/exchange",
3353
+ query: {
3354
+ userId: user.userId,
3355
+ connectionName,
3356
+ channelId: user.channelId ?? "msteams"
3357
+ },
3358
+ method: "POST",
3359
+ body: { token: value.token },
3360
+ bearerToken: bearer,
3361
+ fetchImpl
3362
+ });
3363
+ if ("error" in result) return {
3364
+ ok: false,
3365
+ code: result.status >= 500 ? "service_error" : "unexpected_response",
3366
+ message: result.error,
3367
+ status: result.status
3368
+ };
3369
+ await deps.tokenStore.save({
3370
+ connectionName,
3371
+ userId: user.userId,
3372
+ token: result.token,
3373
+ expiresAt: result.expiration,
3374
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
3375
+ });
3376
+ return {
3377
+ ok: true,
3378
+ token: result.token,
3379
+ expiresAt: result.expiration
3380
+ };
3381
+ }
3382
+ /**
3383
+ * Finish a magic-code sign-in: look up the user token for the state
3384
+ * code via Bot Framework's User Token service, then persist it.
3385
+ */
3386
+ async function handleSigninVerifyStateInvoke(params) {
3387
+ const { value, user, deps } = params;
3388
+ if (!user.userId) return {
3389
+ ok: false,
3390
+ code: "missing_user",
3391
+ message: "no user id on invoke activity"
3392
+ };
3393
+ if (!deps.connectionName) return {
3394
+ ok: false,
3395
+ code: "missing_connection",
3396
+ message: "no OAuth connection name"
3397
+ };
3398
+ const state = value.state?.trim();
3399
+ if (!state) return {
3400
+ ok: false,
3401
+ code: "missing_state",
3402
+ message: "no state code on invoke"
3403
+ };
3404
+ const bearer = await deps.tokenProvider.getAccessToken(BOT_FRAMEWORK_TOKEN_SCOPE);
3405
+ const fetchImpl = deps.fetchImpl ?? globalThis.fetch;
3406
+ const result = await callUserTokenService({
3407
+ baseUrl: deps.userTokenBaseUrl ?? BOT_FRAMEWORK_USER_TOKEN_BASE_URL,
3408
+ path: "/api/usertoken/GetToken",
3409
+ query: {
3410
+ userId: user.userId,
3411
+ connectionName: deps.connectionName,
3412
+ channelId: user.channelId ?? "msteams",
3413
+ code: state
3414
+ },
3415
+ method: "GET",
3416
+ bearerToken: bearer,
3417
+ fetchImpl
3418
+ });
3419
+ if ("error" in result) return {
3420
+ ok: false,
3421
+ code: result.status >= 500 ? "service_error" : "unexpected_response",
3422
+ message: result.error,
3423
+ status: result.status
3424
+ };
3425
+ await deps.tokenStore.save({
3426
+ connectionName: deps.connectionName,
3427
+ userId: user.userId,
3428
+ token: result.token,
3429
+ expiresAt: result.expiration,
3430
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
3431
+ });
3432
+ return {
3433
+ ok: true,
3434
+ token: result.token,
3435
+ expiresAt: result.expiration
3436
+ };
3437
+ }
3438
+ //#endregion
3439
+ //#region extensions/msteams/src/welcome-card.ts
3440
+ /**
3441
+ * Builds an Adaptive Card for welcoming users when the bot is added to a conversation.
3442
+ */
3443
+ const DEFAULT_PROMPT_STARTERS = [
3444
+ "What can you do?",
3445
+ "Summarize my last meeting",
3446
+ "Help me draft an email"
3447
+ ];
3448
+ /**
3449
+ * Build a welcome Adaptive Card for 1:1 personal chats.
3450
+ */
3451
+ function buildWelcomeCard(options) {
3452
+ const botName = options?.botName || "DaoCore";
3453
+ const starters = options?.promptStarters?.length ? options.promptStarters : DEFAULT_PROMPT_STARTERS;
3454
+ return {
3455
+ type: "AdaptiveCard",
3456
+ version: "1.5",
3457
+ body: [{
3458
+ type: "TextBlock",
3459
+ text: `Hi! I'm ${botName}.`,
3460
+ weight: "bolder",
3461
+ size: "medium"
3462
+ }, {
3463
+ type: "TextBlock",
3464
+ text: "I can help you with questions, tasks, and more. Here are some things to try:",
3465
+ wrap: true
3466
+ }],
3467
+ actions: starters.map((label) => ({
3468
+ type: "Action.Submit",
3469
+ title: label,
3470
+ data: { msteams: {
3471
+ type: "imBack",
3472
+ value: label
3473
+ } }
3474
+ }))
3475
+ };
3476
+ }
3477
+ /**
3478
+ * Build a brief welcome message for group chats (when the bot is @mentioned).
3479
+ */
3480
+ function buildGroupWelcomeText(botName) {
3481
+ const name = botName || "DaoCore";
3482
+ return `Hi! I'm ${name}. Mention me with @${name} to get started.`;
3483
+ }
3484
+ //#endregion
3485
+ //#region extensions/msteams/src/monitor-handler.ts
3486
+ function serializeAdaptiveCardActionValue(value) {
3487
+ if (typeof value === "string") {
3488
+ const trimmed = value.trim();
3489
+ return trimmed ? trimmed : null;
3490
+ }
3491
+ if (value === void 0) return null;
3492
+ try {
3493
+ return JSON.stringify(value);
3494
+ } catch {
3495
+ return null;
3496
+ }
3497
+ }
3498
+ async function isInvokeAuthorized(params) {
3499
+ const { context, deps, deniedLogs, includeInvokeName = false } = params;
3500
+ const resolved = await resolveMSTeamsSenderAccess({
3501
+ cfg: deps.cfg,
3502
+ activity: context.activity
3503
+ });
3504
+ const { msteamsCfg, isDirectMessage, conversationId, senderId } = resolved;
3505
+ if (!msteamsCfg) return true;
3506
+ const maybeInvokeName = includeInvokeName ? { name: context.activity.name } : void 0;
3507
+ if (isDirectMessage && resolved.senderAccess.decision !== "allow") {
3508
+ deps.log.debug?.(deniedLogs.dm, {
3509
+ sender: senderId,
3510
+ conversationId,
3511
+ ...maybeInvokeName
3512
+ });
3513
+ return false;
3514
+ }
3515
+ if (!isDirectMessage && resolved.channelGate.allowlistConfigured && !resolved.channelGate.allowed) {
3516
+ deps.log.debug?.(deniedLogs.channel, {
3517
+ conversationId,
3518
+ teamKey: resolved.channelGate.teamKey ?? "none",
3519
+ channelKey: resolved.channelGate.channelKey ?? "none",
3520
+ ...maybeInvokeName
3521
+ });
3522
+ return false;
3523
+ }
3524
+ if (!isDirectMessage && !resolved.senderAccess.allowed) {
3525
+ deps.log.debug?.(deniedLogs.group, {
3526
+ sender: senderId,
3527
+ conversationId,
3528
+ ...maybeInvokeName
3529
+ });
3530
+ return false;
3531
+ }
3532
+ return true;
3533
+ }
3534
+ async function isFeedbackInvokeAuthorized(context, deps) {
3535
+ return isInvokeAuthorized({
3536
+ context,
3537
+ deps,
3538
+ deniedLogs: {
3539
+ dm: "dropping feedback invoke (dm sender not allowlisted)",
3540
+ channel: "dropping feedback invoke (not in team/channel allowlist)",
3541
+ group: "dropping feedback invoke (group sender not allowlisted)"
3542
+ }
3543
+ });
3544
+ }
3545
+ async function isSigninInvokeAuthorized(context, deps) {
3546
+ return isInvokeAuthorized({
3547
+ context,
3548
+ deps,
3549
+ deniedLogs: {
3550
+ dm: "dropping signin invoke (dm sender not allowlisted)",
3551
+ channel: "dropping signin invoke (not in team/channel allowlist)",
3552
+ group: "dropping signin invoke (group sender not allowlisted)"
3553
+ },
3554
+ includeInvokeName: true
3555
+ });
3556
+ }
3557
+ /**
3558
+ * Parse and handle feedback invoke activities (thumbs up/down).
3559
+ * Returns true if the activity was a feedback invoke, false otherwise.
3560
+ */
3561
+ async function handleFeedbackInvoke(context, deps) {
3562
+ const activity = context.activity;
3563
+ const value = activity.value;
3564
+ if (!value) return false;
3565
+ if (value.actionName !== "feedback") return false;
3566
+ const reaction = value.actionValue?.reaction;
3567
+ if (reaction !== "like" && reaction !== "dislike") {
3568
+ deps.log.debug?.("ignoring feedback with unknown reaction", { reaction });
3569
+ return false;
3570
+ }
3571
+ const msteamsCfg = deps.cfg.channels?.msteams;
3572
+ if (msteamsCfg?.feedbackEnabled === false) {
3573
+ deps.log.debug?.("feedback handling disabled");
3574
+ return true;
3575
+ }
3576
+ if (!await isFeedbackInvokeAuthorized(context, deps)) return true;
3577
+ let userComment;
3578
+ if (value.actionValue?.feedback) try {
3579
+ userComment = JSON.parse(value.actionValue.feedback).feedbackText || void 0;
3580
+ } catch {}
3581
+ const rawConversationId = activity.conversation?.id ?? "unknown";
3582
+ const conversationId = normalizeMSTeamsConversationId(rawConversationId);
3583
+ const senderId = activity.from?.aadObjectId ?? activity.from?.id ?? "unknown";
3584
+ const messageId = value.replyToId ?? activity.replyToId ?? "unknown";
3585
+ const isNegative = reaction === "dislike";
3586
+ const convType = normalizeOptionalLowercaseString(activity.conversation?.conversationType);
3587
+ const isDirectMessage = convType === "personal" || !convType && !activity.conversation?.isGroup;
3588
+ const isChannel = convType === "channel";
3589
+ const core = getMSTeamsRuntime();
3590
+ const route = core.channel.routing.resolveAgentRoute({
3591
+ cfg: deps.cfg,
3592
+ channel: "msteams",
3593
+ peer: {
3594
+ kind: isDirectMessage ? "direct" : isChannel ? "channel" : "group",
3595
+ id: isDirectMessage ? senderId : conversationId
3596
+ }
3597
+ });
3598
+ const feedbackThreadId = isChannel ? extractMSTeamsConversationMessageId(rawConversationId) ?? activity.replyToId ?? void 0 : void 0;
3599
+ if (feedbackThreadId) route.sessionKey = resolveThreadSessionKeys({
3600
+ baseSessionKey: route.sessionKey,
3601
+ threadId: feedbackThreadId,
3602
+ parentSessionKey: route.sessionKey
3603
+ }).sessionKey;
3604
+ const feedbackEvent = buildFeedbackEvent({
3605
+ messageId,
3606
+ value: isNegative ? "negative" : "positive",
3607
+ comment: userComment,
3608
+ sessionKey: route.sessionKey,
3609
+ agentId: route.agentId,
3610
+ conversationId
3611
+ });
3612
+ deps.log.info("received feedback", {
3613
+ value: feedbackEvent.value,
3614
+ messageId,
3615
+ conversationId,
3616
+ hasComment: Boolean(userComment)
3617
+ });
3618
+ try {
3619
+ const storePath = core.channel.session.resolveStorePath(deps.cfg.session?.store, { agentId: route.agentId });
3620
+ const safeKey = route.sessionKey.replace(/[^a-zA-Z0-9_-]/g, "_");
3621
+ await appendRegularFile({
3622
+ filePath: path.join(storePath, `${safeKey}.jsonl`),
3623
+ content: `${JSON.stringify(feedbackEvent)}\n`,
3624
+ rejectSymlinkParents: true
3625
+ }).catch(() => {});
3626
+ } catch {}
3627
+ const conversationRef = {
3628
+ activityId: activity.id,
3629
+ user: {
3630
+ id: activity.from?.id,
3631
+ name: activity.from?.name,
3632
+ aadObjectId: activity.from?.aadObjectId
3633
+ },
3634
+ agent: activity.recipient ? {
3635
+ id: activity.recipient.id,
3636
+ name: activity.recipient.name
3637
+ } : void 0,
3638
+ bot: activity.recipient ? {
3639
+ id: activity.recipient.id,
3640
+ name: activity.recipient.name
3641
+ } : void 0,
3642
+ conversation: {
3643
+ id: conversationId,
3644
+ conversationType: activity.conversation?.conversationType,
3645
+ tenantId: activity.conversation?.tenantId
3646
+ },
3647
+ channelId: activity.channelId ?? "msteams",
3648
+ serviceUrl: activity.serviceUrl,
3649
+ locale: activity.locale
3650
+ };
3651
+ if (isNegative && msteamsCfg?.feedbackReflection !== false) runFeedbackReflection({
3652
+ cfg: deps.cfg,
3653
+ adapter: deps.adapter,
3654
+ appId: deps.appId,
3655
+ conversationRef,
3656
+ sessionKey: route.sessionKey,
3657
+ agentId: route.agentId,
3658
+ conversationId,
3659
+ feedbackMessageId: messageId,
3660
+ userComment,
3661
+ log: deps.log
3662
+ }).catch((err) => {
3663
+ deps.log.error("feedback reflection failed", { error: formatUnknownError(err) });
3664
+ });
3665
+ return true;
3666
+ }
3667
+ function registerMSTeamsHandlers(handler, deps) {
3668
+ const handleTeamsMessage = createMSTeamsMessageHandler(deps);
3669
+ const handleReaction = createMSTeamsReactionHandler(deps);
3670
+ const originalRun = handler.run;
3671
+ if (originalRun) handler.run = async (context) => {
3672
+ const ctx = context;
3673
+ if (ctx.activity?.type === "invoke" && ctx.activity?.name === "fileConsent/invoke") {
3674
+ await respondToMSTeamsFileConsentInvoke(ctx, deps.log);
3675
+ return;
3676
+ }
3677
+ if (ctx.activity?.type === "invoke" && ctx.activity?.name === "message/submitAction") {
3678
+ if (await handleFeedbackInvoke(ctx, deps)) return;
3679
+ }
3680
+ if (ctx.activity?.type === "invoke" && ctx.activity?.name === "adaptiveCard/action") {
3681
+ const text = serializeAdaptiveCardActionValue(ctx.activity?.value);
3682
+ if (text) {
3683
+ await handleTeamsMessage({
3684
+ ...ctx,
3685
+ activity: {
3686
+ ...ctx.activity,
3687
+ type: "message",
3688
+ text
3689
+ }
3690
+ });
3691
+ return;
3692
+ }
3693
+ deps.log.debug?.("skipping adaptive card action invoke without value payload");
3694
+ }
3695
+ if (ctx.activity?.type === "invoke" && (ctx.activity?.name === "signin/tokenExchange" || ctx.activity?.name === "signin/verifyState")) {
3696
+ await ctx.sendActivity({
3697
+ type: "invokeResponse",
3698
+ value: {
3699
+ status: 200,
3700
+ body: {}
3701
+ }
3702
+ });
3703
+ if (!await isSigninInvokeAuthorized(ctx, deps)) return;
3704
+ if (!deps.sso) {
3705
+ deps.log.debug?.("signin invoke received but msteams.sso is not configured", { name: ctx.activity.name });
3706
+ return;
3707
+ }
3708
+ const user = {
3709
+ userId: ctx.activity.from?.aadObjectId ?? ctx.activity.from?.id ?? "",
3710
+ channelId: ctx.activity.channelId ?? "msteams"
3711
+ };
3712
+ try {
3713
+ if (ctx.activity.name === "signin/tokenExchange") {
3714
+ const parsed = parseSigninTokenExchangeValue(ctx.activity.value);
3715
+ if (!parsed) {
3716
+ deps.log.debug?.("invalid signin/tokenExchange invoke value");
3717
+ return;
3718
+ }
3719
+ const result = await handleSigninTokenExchangeInvoke({
3720
+ value: parsed,
3721
+ user,
3722
+ deps: deps.sso
3723
+ });
3724
+ if (result.ok) deps.log.info("msteams sso token exchanged", {
3725
+ userId: user.userId,
3726
+ hasExpiry: Boolean(result.expiresAt)
3727
+ });
3728
+ else deps.log.error("msteams sso token exchange failed", {
3729
+ code: result.code,
3730
+ status: result.status,
3731
+ message: result.message
3732
+ });
3733
+ return;
3734
+ }
3735
+ const parsed = parseSigninVerifyStateValue(ctx.activity.value);
3736
+ if (!parsed) {
3737
+ deps.log.debug?.("invalid signin/verifyState invoke value");
3738
+ return;
3739
+ }
3740
+ const result = await handleSigninVerifyStateInvoke({
3741
+ value: parsed,
3742
+ user,
3743
+ deps: deps.sso
3744
+ });
3745
+ if (result.ok) deps.log.info("msteams sso verifyState succeeded", {
3746
+ userId: user.userId,
3747
+ hasExpiry: Boolean(result.expiresAt)
3748
+ });
3749
+ else deps.log.error("msteams sso verifyState failed", {
3750
+ code: result.code,
3751
+ status: result.status,
3752
+ message: result.message
3753
+ });
3754
+ } catch (err) {
3755
+ deps.log.error("msteams sso invoke handler error", { error: formatUnknownError(err) });
3756
+ }
3757
+ return;
3758
+ }
3759
+ return originalRun.call(handler, context);
3760
+ };
3761
+ handler.onMessage(async (context, next) => {
3762
+ try {
3763
+ await handleTeamsMessage(context);
3764
+ } catch (err) {
3765
+ deps.runtime.error(`msteams handler failed: ${formatUnknownError(err)}`);
3766
+ }
3767
+ await next();
3768
+ });
3769
+ handler.onMembersAdded(async (context, next) => {
3770
+ const ctx = context;
3771
+ const membersAdded = ctx.activity?.membersAdded ?? [];
3772
+ const botId = ctx.activity?.recipient?.id;
3773
+ const msteamsCfg = deps.cfg.channels?.msteams;
3774
+ for (const member of membersAdded) if (member.id === botId) {
3775
+ const isPersonal = (normalizeOptionalLowercaseString(ctx.activity?.conversation?.conversationType) ?? "personal") === "personal";
3776
+ if (isPersonal && msteamsCfg?.welcomeCard !== false) {
3777
+ const card = buildWelcomeCard({
3778
+ botName: ctx.activity?.recipient?.name ?? void 0,
3779
+ promptStarters: msteamsCfg?.promptStarters
3780
+ });
3781
+ try {
3782
+ await ctx.sendActivity({
3783
+ type: "message",
3784
+ attachments: [{
3785
+ contentType: "application/vnd.microsoft.card.adaptive",
3786
+ content: card
3787
+ }]
3788
+ });
3789
+ deps.log.info("sent welcome card");
3790
+ } catch (err) {
3791
+ deps.log.debug?.("failed to send welcome card", { error: formatUnknownError(err) });
3792
+ }
3793
+ } else if (!isPersonal && msteamsCfg?.groupWelcomeCard === true) {
3794
+ const botName = ctx.activity?.recipient?.name ?? void 0;
3795
+ try {
3796
+ await ctx.sendActivity(buildGroupWelcomeText(botName));
3797
+ deps.log.info("sent group welcome message");
3798
+ } catch (err) {
3799
+ deps.log.debug?.("failed to send group welcome", { error: formatUnknownError(err) });
3800
+ }
3801
+ } else deps.log.debug?.("skipping welcome (disabled by config or conversation type)");
3802
+ } else deps.log.debug?.("member added", { member: member.id });
3803
+ await next();
3804
+ });
3805
+ handler.onReactionsAdded(async (context, next) => {
3806
+ try {
3807
+ await handleReaction(context, "added");
3808
+ } catch (err) {
3809
+ deps.runtime.error(`msteams reaction handler failed: ${String(err)}`);
3810
+ }
3811
+ await next();
3812
+ });
3813
+ handler.onReactionsRemoved(async (context, next) => {
3814
+ try {
3815
+ await handleReaction(context, "removed");
3816
+ } catch (err) {
3817
+ deps.runtime.error(`msteams reaction handler failed: ${String(err)}`);
3818
+ }
3819
+ await next();
3820
+ });
3821
+ return handler;
3822
+ }
3823
+ //#endregion
3824
+ //#region extensions/msteams/src/sso-token-store.ts
3825
+ /**
3826
+ * File-backed store for Bot Framework OAuth SSO tokens.
3827
+ *
3828
+ * Tokens are keyed by (connectionName, userId). `userId` should be the
3829
+ * stable AAD object ID (`activity.from.aadObjectId`) when available,
3830
+ * falling back to the Bot Framework `activity.from.id`.
3831
+ *
3832
+ * The store is intentionally minimal: it persists the exchanged user
3833
+ * token plus its expiration so consumers (for example tool handlers
3834
+ * that call Microsoft Graph with delegated permissions) can fetch a
3835
+ * valid token without reaching back into Bot Framework every turn.
3836
+ */
3837
+ const STORE_FILENAME = "msteams-sso-tokens.json";
3838
+ const STORE_KEY_VERSION_PREFIX = "v2:";
3839
+ function makeKey(connectionName, userId) {
3840
+ return `${STORE_KEY_VERSION_PREFIX}${Buffer.from(JSON.stringify([connectionName, userId]), "utf8").toString("base64url")}`;
3841
+ }
3842
+ function normalizeStoredToken(value) {
3843
+ if (!value || typeof value !== "object") return null;
3844
+ const token = value;
3845
+ if (typeof token.connectionName !== "string" || !token.connectionName || typeof token.userId !== "string" || !token.userId || typeof token.token !== "string" || !token.token || typeof token.updatedAt !== "string" || !token.updatedAt) return null;
3846
+ return {
3847
+ connectionName: token.connectionName,
3848
+ userId: token.userId,
3849
+ token: token.token,
3850
+ ...typeof token.expiresAt === "string" ? { expiresAt: token.expiresAt } : {},
3851
+ updatedAt: token.updatedAt
3852
+ };
3853
+ }
3854
+ function isSsoStoreData(value) {
3855
+ if (!value || typeof value !== "object") return false;
3856
+ const obj = value;
3857
+ return obj.version === 1 && typeof obj.tokens === "object" && obj.tokens !== null;
3858
+ }
3859
+ function createMSTeamsSsoTokenStoreFs(params) {
3860
+ const filePath = resolveMSTeamsStorePath({
3861
+ filename: STORE_FILENAME,
3862
+ env: params?.env,
3863
+ homedir: params?.homedir,
3864
+ stateDir: params?.stateDir,
3865
+ storePath: params?.storePath
3866
+ });
3867
+ const empty = {
3868
+ version: 1,
3869
+ tokens: {}
3870
+ };
3871
+ const readStore = async () => {
3872
+ const { value } = await readJsonFile(filePath, empty);
3873
+ if (!isSsoStoreData(value)) return {
3874
+ version: 1,
3875
+ tokens: {}
3876
+ };
3877
+ const tokens = {};
3878
+ for (const stored of Object.values(value.tokens)) {
3879
+ const normalized = normalizeStoredToken(stored);
3880
+ if (!normalized) continue;
3881
+ tokens[makeKey(normalized.connectionName, normalized.userId)] = normalized;
3882
+ }
3883
+ return {
3884
+ version: 1,
3885
+ tokens
3886
+ };
3887
+ };
3888
+ return {
3889
+ async get({ connectionName, userId }) {
3890
+ return (await readStore()).tokens[makeKey(connectionName, userId)] ?? null;
3891
+ },
3892
+ async save(token) {
3893
+ await withFileLock(filePath, empty, async () => {
3894
+ const store = await readStore();
3895
+ const key = makeKey(token.connectionName, token.userId);
3896
+ store.tokens[key] = { ...token };
3897
+ await writeJsonFile(filePath, store);
3898
+ });
3899
+ },
3900
+ async remove({ connectionName, userId }) {
3901
+ let removed = false;
3902
+ await withFileLock(filePath, empty, async () => {
3903
+ const store = await readStore();
3904
+ const key = makeKey(connectionName, userId);
3905
+ if (store.tokens[key]) {
3906
+ delete store.tokens[key];
3907
+ removed = true;
3908
+ await writeJsonFile(filePath, store);
3909
+ }
3910
+ });
3911
+ return removed;
3912
+ }
3913
+ };
3914
+ }
3915
+ //#endregion
3916
+ //#region extensions/msteams/src/webhook-timeouts.ts
3917
+ const MSTEAMS_WEBHOOK_INACTIVITY_TIMEOUT_MS = 3e4;
3918
+ const MSTEAMS_WEBHOOK_REQUEST_TIMEOUT_MS = 3e4;
3919
+ const MSTEAMS_WEBHOOK_HEADERS_TIMEOUT_MS = 15e3;
3920
+ function applyMSTeamsWebhookTimeouts(httpServer, opts) {
3921
+ const inactivityTimeoutMs = opts?.inactivityTimeoutMs ?? MSTEAMS_WEBHOOK_INACTIVITY_TIMEOUT_MS;
3922
+ const requestTimeoutMs = opts?.requestTimeoutMs ?? MSTEAMS_WEBHOOK_REQUEST_TIMEOUT_MS;
3923
+ const headersTimeoutMs = Math.min(opts?.headersTimeoutMs ?? MSTEAMS_WEBHOOK_HEADERS_TIMEOUT_MS, requestTimeoutMs);
3924
+ httpServer.setTimeout(inactivityTimeoutMs);
3925
+ httpServer.requestTimeout = requestTimeoutMs;
3926
+ httpServer.headersTimeout = headersTimeoutMs;
3927
+ }
3928
+ //#endregion
3929
+ //#region extensions/msteams/src/monitor.ts
3930
+ const MSTEAMS_WEBHOOK_MAX_BODY_BYTES = DEFAULT_WEBHOOK_MAX_BODY_BYTES;
3931
+ async function monitorMSTeamsProvider(opts) {
3932
+ const core = getMSTeamsRuntime();
3933
+ const log = core.logging.getChildLogger({ name: "msteams" });
3934
+ let cfg = opts.cfg;
3935
+ let msteamsCfg = cfg.channels?.msteams;
3936
+ if (!msteamsCfg?.enabled) {
3937
+ log.debug?.("msteams provider disabled");
3938
+ return {
3939
+ app: null,
3940
+ shutdown: async () => {}
3941
+ };
3942
+ }
3943
+ const creds = resolveMSTeamsCredentials(msteamsCfg);
3944
+ if (!creds) {
3945
+ log.error("msteams credentials not configured");
3946
+ return {
3947
+ app: null,
3948
+ shutdown: async () => {}
3949
+ };
3950
+ }
3951
+ const appId = creds.appId;
3952
+ const runtime = opts.runtime ?? {
3953
+ log: console.log,
3954
+ error: console.error,
3955
+ exit: (code) => {
3956
+ throw new Error(`exit ${code}`);
3957
+ }
3958
+ };
3959
+ let allowFrom = msteamsCfg.allowFrom;
3960
+ let groupAllowFrom = msteamsCfg.groupAllowFrom;
3961
+ let teamsConfig = msteamsCfg.teams;
3962
+ const allowNameMatching = isDangerousNameMatchingEnabled(msteamsCfg);
3963
+ const cleanAllowEntry = (entry) => entry.replace(/^(msteams|teams):/i, "").replace(/^user:/i, "").trim();
3964
+ const isStableUserId = (entry) => /^[0-9a-fA-F-]{16,}$/.test(entry);
3965
+ const cleanAllowEntries = (entries) => entries?.map((entry) => cleanAllowEntry(entry)).filter((entry) => entry && entry !== "*") ?? [];
3966
+ const mergeStableUserIds = (entries) => {
3967
+ const additions = cleanAllowEntries(entries).filter((entry) => isStableUserId(entry));
3968
+ return additions.length > 0 ? mergeAllowlist({
3969
+ existing: entries,
3970
+ additions
3971
+ }) : entries;
3972
+ };
3973
+ const resolveAllowlistUsers = async (label, entries) => {
3974
+ if (entries.length === 0) return {
3975
+ additions: [],
3976
+ unresolved: []
3977
+ };
3978
+ const resolved = await resolveMSTeamsUserAllowlist({
3979
+ cfg,
3980
+ entries
3981
+ });
3982
+ const additions = [];
3983
+ const unresolved = [];
3984
+ for (const entry of resolved) if (entry.resolved && entry.id) additions.push(entry.id);
3985
+ else unresolved.push(entry.input);
3986
+ summarizeMapping(label, resolved.filter((entry) => entry.resolved && entry.id).map((entry) => `${entry.input}→${entry.id}`), unresolved, runtime);
3987
+ return {
3988
+ additions,
3989
+ unresolved
3990
+ };
3991
+ };
3992
+ try {
3993
+ allowFrom = mergeStableUserIds(allowFrom);
3994
+ if (Array.isArray(groupAllowFrom) && groupAllowFrom.length > 0) groupAllowFrom = mergeStableUserIds(groupAllowFrom);
3995
+ if (allowNameMatching) {
3996
+ const allowEntries = cleanAllowEntries(allowFrom).filter((entry) => !isStableUserId(entry));
3997
+ if (allowEntries.length > 0) {
3998
+ const { additions } = await resolveAllowlistUsers("msteams users", allowEntries);
3999
+ allowFrom = mergeAllowlist({
4000
+ existing: allowFrom,
4001
+ additions
4002
+ });
4003
+ }
4004
+ if (Array.isArray(groupAllowFrom) && groupAllowFrom.length > 0) {
4005
+ const groupEntries = cleanAllowEntries(groupAllowFrom).filter((entry) => !isStableUserId(entry));
4006
+ if (groupEntries.length > 0) {
4007
+ const { additions } = await resolveAllowlistUsers("msteams group users", groupEntries);
4008
+ groupAllowFrom = mergeAllowlist({
4009
+ existing: groupAllowFrom,
4010
+ additions
4011
+ });
4012
+ }
4013
+ }
4014
+ }
4015
+ if (teamsConfig && Object.keys(teamsConfig).length > 0) {
4016
+ const entries = [];
4017
+ for (const [teamKey, teamCfg] of Object.entries(teamsConfig)) {
4018
+ if (teamKey === "*") continue;
4019
+ const channels = teamCfg?.channels ?? {};
4020
+ const channelKeys = Object.keys(channels).filter((key) => key !== "*");
4021
+ if (channelKeys.length === 0) {
4022
+ entries.push({
4023
+ input: teamKey,
4024
+ teamKey
4025
+ });
4026
+ continue;
4027
+ }
4028
+ for (const channelKey of channelKeys) entries.push({
4029
+ input: `${teamKey}/${channelKey}`,
4030
+ teamKey,
4031
+ channelKey
4032
+ });
4033
+ }
4034
+ if (entries.length > 0) {
4035
+ const resolved = await resolveMSTeamsChannelAllowlist({
4036
+ cfg,
4037
+ entries: entries.map((entry) => entry.input)
4038
+ });
4039
+ const mapping = [];
4040
+ const unresolved = [];
4041
+ const nextTeams = { ...teamsConfig };
4042
+ resolved.forEach((entry, idx) => {
4043
+ const source = entries[idx];
4044
+ if (!source) return;
4045
+ const sourceTeam = teamsConfig?.[source.teamKey] ?? {};
4046
+ if (!entry.resolved || !entry.teamId) {
4047
+ unresolved.push(entry.input);
4048
+ return;
4049
+ }
4050
+ mapping.push(entry.channelId ? `${entry.input}→${entry.teamId}/${entry.channelId}` : `${entry.input}→${entry.teamId}`);
4051
+ const existing = nextTeams[entry.teamId] ?? {};
4052
+ const mergedChannels = {
4053
+ ...sourceTeam.channels,
4054
+ ...existing.channels
4055
+ };
4056
+ const mergedTeam = {
4057
+ ...sourceTeam,
4058
+ ...existing,
4059
+ channels: mergedChannels
4060
+ };
4061
+ nextTeams[entry.teamId] = mergedTeam;
4062
+ if (source.channelKey && entry.channelId) {
4063
+ const sourceChannel = sourceTeam.channels?.[source.channelKey];
4064
+ if (sourceChannel) nextTeams[entry.teamId] = {
4065
+ ...mergedTeam,
4066
+ channels: {
4067
+ ...mergedChannels,
4068
+ [entry.channelId]: {
4069
+ ...sourceChannel,
4070
+ ...mergedChannels?.[entry.channelId]
4071
+ }
4072
+ }
4073
+ };
4074
+ }
4075
+ });
4076
+ teamsConfig = nextTeams;
4077
+ summarizeMapping("msteams channels", mapping, unresolved, runtime);
4078
+ }
4079
+ }
4080
+ } catch (err) {
4081
+ runtime?.error(`msteams resolve failed; falling back to raw config entries — allowlist members resolved via Graph may be missing. ${formatUnknownError(err)}`);
4082
+ }
4083
+ msteamsCfg = {
4084
+ ...msteamsCfg,
4085
+ allowFrom,
4086
+ groupAllowFrom,
4087
+ teams: teamsConfig
4088
+ };
4089
+ cfg = {
4090
+ ...cfg,
4091
+ channels: {
4092
+ ...cfg.channels,
4093
+ msteams: msteamsCfg
4094
+ }
4095
+ };
4096
+ const port = msteamsCfg.webhook?.port ?? 3978;
4097
+ const textLimit = core.channel.text.resolveTextChunkLimit(cfg, "msteams");
4098
+ const MB = 1024 * 1024;
4099
+ const agentDefaults = cfg.agents?.defaults;
4100
+ const mediaMaxBytes = typeof agentDefaults?.mediaMaxMb === "number" && agentDefaults.mediaMaxMb > 0 ? Math.floor(agentDefaults.mediaMaxMb * MB) : 8 * MB;
4101
+ const conversationStore = opts.conversationStore ?? createMSTeamsConversationStoreFs();
4102
+ const pollStore = opts.pollStore ?? createMSTeamsPollStoreFs();
4103
+ log.info(`starting provider (port ${port})`);
4104
+ const express = await import("express");
4105
+ const { sdk, app } = await loadMSTeamsSdkWithAuth(creds);
4106
+ const tokenProvider = createMSTeamsTokenProvider(app);
4107
+ const adapter = createMSTeamsAdapter(app, sdk);
4108
+ let ssoDeps;
4109
+ if (msteamsCfg.sso?.enabled && msteamsCfg.sso.connectionName) {
4110
+ ssoDeps = {
4111
+ tokenProvider,
4112
+ tokenStore: createMSTeamsSsoTokenStoreFs(),
4113
+ connectionName: msteamsCfg.sso.connectionName
4114
+ };
4115
+ log.debug?.("msteams sso enabled", { connectionName: msteamsCfg.sso.connectionName });
4116
+ }
4117
+ const handler = buildActivityHandler();
4118
+ registerMSTeamsHandlers(handler, {
4119
+ cfg,
4120
+ runtime,
4121
+ appId,
4122
+ adapter,
4123
+ tokenProvider,
4124
+ textLimit,
4125
+ mediaMaxBytes,
4126
+ conversationStore,
4127
+ pollStore,
4128
+ log,
4129
+ sso: ssoDeps
4130
+ });
4131
+ const expressApp = express.default();
4132
+ expressApp.use((req, res, next) => {
4133
+ const auth = req.headers.authorization;
4134
+ if (!auth || !auth.startsWith("Bearer ")) {
4135
+ res.status(401).json({ error: "Unauthorized" });
4136
+ return;
4137
+ }
4138
+ next();
4139
+ });
4140
+ const jwtValidator = await createBotFrameworkJwtValidator(creds);
4141
+ expressApp.use((req, res, next) => {
4142
+ const authHeader = req.headers.authorization;
4143
+ jwtValidator.validate(authHeader).then((valid) => {
4144
+ if (!valid) {
4145
+ log.debug?.("JWT validation failed");
4146
+ res.status(401).json({ error: "Unauthorized" });
4147
+ return;
4148
+ }
4149
+ next();
4150
+ }).catch((err) => {
4151
+ if (err instanceof Error && /ECONNREFUSED|ENOTFOUND|EHOSTUNREACH|ETIMEDOUT|ECONNRESET/i.test(err.code ?? err.message)) runtime?.error(`msteams: JWKS key fetch failed — check egress to login.botframework.com:443 (firewall or DNS may be blocking it). Bot will 401 all inbound requests until this is resolved. Error: ${formatUnknownError(err)}`);
4152
+ else log.debug?.(`JWT validation error: ${formatUnknownError(err)}`);
4153
+ res.status(401).json({ error: "Unauthorized" });
4154
+ });
4155
+ });
4156
+ expressApp.use(express.json({ limit: MSTEAMS_WEBHOOK_MAX_BODY_BYTES }));
4157
+ expressApp.use((err, _req, res, next) => {
4158
+ if (err && typeof err === "object" && "status" in err && err.status === 413) {
4159
+ res.status(413).json({ error: "Payload too large" });
4160
+ return;
4161
+ }
4162
+ next(err);
4163
+ });
4164
+ const configuredPath = msteamsCfg.webhook?.path ?? "/api/messages";
4165
+ const messageHandler = (req, res) => {
4166
+ adapter.process(req, res, (context) => handler.run(context)).catch((err) => {
4167
+ log.error("msteams webhook failed", { error: formatUnknownError(err) });
4168
+ });
4169
+ };
4170
+ expressApp.post(configuredPath, messageHandler);
4171
+ if (configuredPath !== "/api/messages") expressApp.post("/api/messages", messageHandler);
4172
+ log.debug?.("listening on paths", {
4173
+ primary: configuredPath,
4174
+ fallback: "/api/messages"
4175
+ });
4176
+ const httpServer = expressApp.listen(port);
4177
+ await new Promise((resolve, reject) => {
4178
+ const onListening = () => {
4179
+ httpServer.off("error", onError);
4180
+ log.info(`msteams provider started on port ${port}`);
4181
+ resolve();
4182
+ };
4183
+ const onError = (err) => {
4184
+ httpServer.off("listening", onListening);
4185
+ log.error("msteams server error", { error: formatUnknownError(err) });
4186
+ reject(err);
4187
+ };
4188
+ httpServer.once("listening", onListening);
4189
+ httpServer.once("error", onError);
4190
+ });
4191
+ applyMSTeamsWebhookTimeouts(httpServer);
4192
+ httpServer.on("error", (err) => {
4193
+ log.error("msteams server error", { error: formatUnknownError(err) });
4194
+ });
4195
+ const shutdown = async () => {
4196
+ log.info("shutting down msteams provider");
4197
+ return new Promise((resolve) => {
4198
+ httpServer.close((err) => {
4199
+ if (err) log.debug?.("msteams server close error", { error: formatUnknownError(err) });
4200
+ resolve();
4201
+ });
4202
+ });
4203
+ };
4204
+ await keepHttpServerTaskAlive({
4205
+ server: httpServer,
4206
+ abortSignal: opts.abortSignal,
4207
+ onAbort: shutdown
4208
+ });
4209
+ return {
4210
+ app: expressApp,
4211
+ shutdown
4212
+ };
4213
+ }
4214
+ /**
4215
+ * Build a minimal ActivityHandler-compatible object that supports
4216
+ * onMessage / onMembersAdded registration and a run() method.
4217
+ */
4218
+ function buildActivityHandler() {
4219
+ const messageHandlers = [];
4220
+ const membersAddedHandlers = [];
4221
+ const reactionsAddedHandlers = [];
4222
+ const reactionsRemovedHandlers = [];
4223
+ const handler = {
4224
+ onMessage(cb) {
4225
+ messageHandlers.push(cb);
4226
+ return handler;
4227
+ },
4228
+ onMembersAdded(cb) {
4229
+ membersAddedHandlers.push(cb);
4230
+ return handler;
4231
+ },
4232
+ onReactionsAdded(cb) {
4233
+ reactionsAddedHandlers.push(cb);
4234
+ return handler;
4235
+ },
4236
+ onReactionsRemoved(cb) {
4237
+ reactionsRemovedHandlers.push(cb);
4238
+ return handler;
4239
+ },
4240
+ async run(context) {
4241
+ const ctx = context;
4242
+ const activityType = ctx?.activity?.type;
4243
+ const noop = async () => {};
4244
+ if (activityType === "message") for (const h of messageHandlers) await h(context, noop);
4245
+ else if (activityType === "conversationUpdate") for (const h of membersAddedHandlers) await h(context, noop);
4246
+ else if (activityType === "messageReaction") {
4247
+ const activity = ctx?.activity;
4248
+ if (activity?.reactionsAdded?.length) for (const h of reactionsAddedHandlers) await h(context, noop);
4249
+ if (activity?.reactionsRemoved?.length) for (const h of reactionsRemovedHandlers) await h(context, noop);
4250
+ }
4251
+ }
4252
+ };
4253
+ return handler;
4254
+ }
4255
+ //#endregion
4256
+ export { monitorMSTeamsProvider };