@desplega.ai/agent-swarm 2.9.0 → 2.9.1

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 (305) hide show
  1. package/dist/acp-adapter-g909b5hw.js +16 -0
  2. package/dist/{acp-targets-swxq55dr.js → acp-targets-ny75x1qy.js} +7 -7
  3. package/dist/{actions-pb678g3e.js → actions-b9qgrmeq.js} +81 -21
  4. package/dist/{agent-fs-provision-dmhnc38q.js → agent-fs-provision-b5dhdsbd.js} +4 -4
  5. package/dist/{amp-adapter-3pa66q27.js → amp-adapter-vtax2c9s.js} +2 -2
  6. package/dist/{anthropic-messages-x2cp5fvf.js → anthropic-messages-r5xf5hqw.js} +10 -10
  7. package/dist/{app-17d12ev4.js → app-g2z15hax.js} +6 -3
  8. package/dist/{approval-notifications-h7vd9pmg.js → approval-notifications-yt13wp8r.js} +8 -5
  9. package/dist/{assistant-t7k39ree.js → assistant-2cgfxsgk.js} +23 -21
  10. package/dist/{boot-args-schema-0gqmkfbe.js → boot-args-schema-3gwy0f60.js} +1 -1
  11. package/dist/{boot-reembed-n6anc01d.js → boot-reembed-92g7s5zp.js} +1 -1
  12. package/dist/{boot-reembed-f064w382.js → boot-reembed-mywmyp4s.js} +1 -1
  13. package/dist/{boot-scrub-sweep-ejd5dnrz.js → boot-scrub-sweep-7dkdzqxx.js} +3 -3
  14. package/dist/{boot-seeds-f99fjs5q.js → boot-seeds-ce7rvgq1.js} +4 -4
  15. package/dist/{claude-adapter-gvznwxgc.js → claude-adapter-3m4q7735.js} +7 -7
  16. package/dist/{claude-managed-adapter-pbrbvc64.js → claude-managed-adapter-t8nfgcgz.js} +2 -2
  17. package/dist/{claude-managed-setup-kdxttvc3.js → claude-managed-setup-c217draw.js} +3 -3
  18. package/dist/{claude-sdk-session-0t2teq6n.js → claude-sdk-session-7fbqm51z.js} +7 -7
  19. package/dist/{cli-9a2rtd77.js → cli-1jykg0py.js} +6 -4
  20. package/dist/{cli-5ntc4we6.js → cli-2czxfnvj.js} +235 -2003
  21. package/dist/{cli-dd37e0cm.js → cli-2dq9yv8p.js} +1 -1
  22. package/dist/{cli-c07v0qfa.js → cli-2xs8tsf7.js} +69 -66
  23. package/dist/{cli-7fx9jyfs.js → cli-2yjj3e31.js} +64 -10
  24. package/dist/{cli-4ghh072d.js → cli-32djehja.js} +36 -36
  25. package/dist/{cli-cw7mc1je.js → cli-3j873zxq.js} +3 -3
  26. package/dist/cli-43ms35q9.js +270 -0
  27. package/dist/cli-47hz21se.js +25584 -0
  28. package/dist/{cli-n515ex5z.js → cli-4ymxrwg5.js} +16 -16
  29. package/dist/{cli-5gygrr67.js → cli-67mwzr35.js} +1 -1
  30. package/dist/{cli-5kcmxwxv.js → cli-6945ywhr.js} +1 -1
  31. package/dist/{cli-812paz57.js → cli-6ehs4mta.js} +18 -2
  32. package/dist/{cli-95930z69.js → cli-6ym4jhzp.js} +2 -2
  33. package/dist/{cli-zg3z63x3.js → cli-7mv4h3sn.js} +1 -1
  34. package/dist/{cli-eg437b5p.js → cli-7sf9sb0w.js} +2 -1
  35. package/dist/{cli-nr46j5pw.js → cli-8zh9nrew.js} +1 -1
  36. package/dist/{cli-wr1h0k28.js → cli-9w8712tq.js} +617 -278
  37. package/dist/{cli-ssvdrk4y.js → cli-b6px1k1q.js} +1 -1
  38. package/dist/{cli-7831nhaw.js → cli-b91nz213.js} +3 -3
  39. package/dist/{cli-7cgf614g.js → cli-bg63qmsx.js} +2 -2
  40. package/dist/{cli-me4maa4j.js → cli-bkjdknnp.js} +9 -5
  41. package/dist/{cli-rts1qvb4.js → cli-bnqncekd.js} +2 -2
  42. package/dist/{cli-25nstr34.js → cli-br0924pw.js} +1 -1
  43. package/dist/{cli-ymct0ycy.js → cli-ctx0b85j.js} +5222 -4978
  44. package/dist/{cli-kqh27v2y.js → cli-dgs10ttj.js} +1 -1
  45. package/dist/{cli-kmvcm34h.js → cli-f3jyzq4g.js} +2 -2
  46. package/dist/cli-f8x9drqr.js +84 -0
  47. package/dist/{cli-8axx8vnw.js → cli-f9gz2vyj.js} +5 -5
  48. package/dist/{cli-vvgaz8t6.js → cli-fh97xn30.js} +2 -2
  49. package/dist/{cli-8x8y70av.js → cli-fkef327x.js} +2 -2
  50. package/dist/{cli-js8zrfyg.js → cli-gfy38pvt.js} +2 -2
  51. package/dist/{cli-kaa4bd7x.js → cli-h9yqfzx9.js} +7 -6
  52. package/dist/{cli-svc803vq.js → cli-j7svy295.js} +11 -11
  53. package/dist/{cli-nhq5js1b.js → cli-jaw5v1sy.js} +3 -3
  54. package/dist/{cli-w7dxb2fj.js → cli-jkw6ptfw.js} +6 -6
  55. package/dist/{cli-1tvdx9t5.js → cli-jm0hvmz2.js} +1 -1
  56. package/dist/{cli-e9973bf0.js → cli-jwampxxq.js} +2 -2
  57. package/dist/{cli-dx439zpg.js → cli-kpgcm7xy.js} +13 -1
  58. package/dist/{cli-pz1c00aa.js → cli-kxx4k2jw.js} +2 -2
  59. package/dist/{cli-aa8s22gn.js → cli-m7c2380k.js} +191 -182
  60. package/dist/{cli-2kg31ted.js → cli-m7zvgt57.js} +11 -11
  61. package/dist/{cli-57pvhnyt.js → cli-mhapr559.js} +1 -1
  62. package/dist/{cli-gddgcnav.js → cli-mjw0yf82.js} +1 -1
  63. package/dist/{cli-h474mvp5.js → cli-mkwkwq81.js} +7 -4
  64. package/dist/{cli-jd3kxppb.js → cli-mw620q3n.js} +1 -1
  65. package/dist/{cli-spzkdgtg.js → cli-n3qe7tyr.js} +172 -168
  66. package/dist/{cli-3zxdz9r7.js → cli-nafvvsp8.js} +3 -3
  67. package/dist/{cli-fnh4b12r.js → cli-nbt14he0.js} +6 -6
  68. package/dist/{cli-7akn6ze9.js → cli-nh7x3133.js} +7 -28
  69. package/dist/{cli-faf46gdq.js → cli-p4kckx1z.js} +10 -10
  70. package/dist/{cli-k7pt28ad.js → cli-pb2ay3sh.js} +2 -2
  71. package/dist/{cli-pn1v1pb0.js → cli-psffsanb.js} +3 -2
  72. package/dist/{cli-2tnbc3gw.js → cli-pyjn0qhk.js} +2257 -61
  73. package/dist/{cli-fgphc007.js → cli-rq5rpv6k.js} +1 -1
  74. package/dist/{cli-vw5x18yj.js → cli-sn650d7x.js} +9 -9
  75. package/dist/{cli-mc1fx4xd.js → cli-td9tb872.js} +10 -10
  76. package/dist/{cli-6dp0jkfj.js → cli-tvc4jag9.js} +3 -3
  77. package/dist/{cli-a9hfzg2r.js → cli-ty3gha1p.js} +6 -6
  78. package/dist/{cli-pwsax0vp.js → cli-v57d7fmm.js} +1 -1
  79. package/dist/{cli-nmcpzbty.js → cli-vt89089n.js} +4 -4
  80. package/dist/{cli-sn4pc4qx.js → cli-vyff45ve.js} +2 -2
  81. package/dist/{cli-m1fbz2wj.js → cli-w4n323t3.js} +175 -16
  82. package/dist/{cli-g3zzby8t.js → cli-wn13hhdt.js} +5 -5
  83. package/dist/{cli-q8cfh1t9.js → cli-xag7btpe.js} +1 -1
  84. package/dist/{cli-c5cspahx.js → cli-y2ewxhth.js} +38 -13
  85. package/dist/{cli-k09cxm6m.js → cli-ysvspf5e.js} +2 -2
  86. package/dist/{cli-eepnpee7.js → cli-zh0e5x7p.js} +4 -4
  87. package/dist/{cli-bk9v1xrv.js → cli-zr6qy15y.js} +11 -11
  88. package/dist/cli.js +21 -20
  89. package/dist/{codex-adapter-44yq2fkn.js → codex-adapter-n656pvb8.js} +6 -6
  90. package/dist/{codex-hook-h1zb7cfk.js → codex-hook-59atdwd8.js} +1 -1
  91. package/dist/{codex-login-cdyrr5y1.js → codex-login-a239g1ah.js} +1 -1
  92. package/dist/{codex-session-runner-zbh26gbw.js → codex-session-runner-p0fbv5y9.js} +6 -6
  93. package/dist/{commands-54f02v5b.js → commands-gwea8z5p.js} +3 -3
  94. package/dist/{controller-9gpwcdek.js → controller-t67c3grh.js} +6 -3
  95. package/dist/{controllers-connect-61re6k1n.js → controllers-connect-ks155r0h.js} +22 -20
  96. package/dist/{cursor-adapter-7e4g81vd.js → cursor-adapter-ygwrtmkv.js} +1 -1
  97. package/dist/{db-dg2gc7fd.js → db-kpmx06s9.js} +8 -2
  98. package/dist/{db-wnh0qjy1.js → db-rb2xqdb1.js} +3 -3
  99. package/dist/{dispatcher-jrm24r43.js → dispatcher-31sm0ej2.js} +20 -18
  100. package/dist/{docker-9aq30pp2.js → docker-09tkkg0n.js} +42 -3
  101. package/dist/{dsh-adapter-1yqk267c.js → dsh-adapter-qyxh0w31.js} +1 -1
  102. package/dist/{easter-egg-3d-r4h9cs9m.js → easter-egg-3d-00wjscn6.js} +1 -1
  103. package/dist/{embedding-space-bafjr5f7.js → embedding-space-qhw4g68n.js} +6 -6
  104. package/dist/{embeddings-7xmgqe0e.js → embeddings-zdv9ke6x.js} +1 -1
  105. package/dist/{execute-d6jg5ns0.js → execute-zna8wwr7.js} +1 -1
  106. package/dist/{external-channel-frq1xvq2.js → external-channel-1ac6t56s.js} +2 -2
  107. package/dist/fx-adapter-sk7n0fzc.js +19 -0
  108. package/dist/{google-generative-ai-hh7strj3.js → google-generative-ai-maq6c9bf.js} +1 -1
  109. package/dist/{google-vertex-fy5bw2pm.js → google-vertex-2jgsw2nb.js} +1 -1
  110. package/dist/grok-adapter-sjbcm5ew.js +19 -0
  111. package/dist/handlers-yzy0c87x.js +35 -0
  112. package/dist/{heartbeat-6bpa611t.js → heartbeat-2f6z4kdx.js} +23 -21
  113. package/dist/{hook-w12k146y.js → hook-8y0gvtp1.js} +6 -6
  114. package/dist/{hook-hvm5nf46.js → hook-w1skzaqc.js} +5 -5
  115. package/dist/{http-43tthdvs.js → http-wghxvpef.js} +714 -145
  116. package/dist/{index-1f0vypbg.js → index-0h6qd4p1.js} +34 -24
  117. package/dist/index-25pvya7q.js +40 -0
  118. package/dist/index-2t4859r5.js +35 -0
  119. package/dist/{index-4b1q8kan.js → index-4k7m5dgj.js} +629 -354
  120. package/dist/index-620y7jzq.js +15 -0
  121. package/dist/{index-cret47a5.js → index-8p0j4h4j.js} +506 -43
  122. package/dist/{index-mhq4sh5w.js → index-8zn8nxn5.js} +1 -1
  123. package/dist/{index-m5gx1xd6.js → index-9myfj74s.js} +40 -40
  124. package/dist/{index-ftywhyr0.js → index-9zkchs9t.js} +221 -65
  125. package/dist/{index-bs7gw5fd.js → index-b5wgnm78.js} +44 -44
  126. package/dist/index-cxca2t8y.js +36 -0
  127. package/dist/{index-585gyczt.js → index-pe3d8jfy.js} +3 -3
  128. package/dist/{index-tx9mc2ap.js → index-rv89fvzf.js} +24 -22
  129. package/dist/{index-fn054vsf.js → index-s71ez27v.js} +1 -1
  130. package/dist/{keepalive-rk0j0jvh.js → keepalive-sh02349h.js} +3 -3
  131. package/dist/lead-gk4h5eg7.js +74 -0
  132. package/dist/{maintenance-g6z6kaxw.js → maintenance-yj0dcjja.js} +1 -1
  133. package/dist/{node-jftbyawr.js → node-dqm4xgxw.js} +1 -1
  134. package/dist/{oauth-refresh-sweep-2k3g2q4w.js → oauth-refresh-sweep-d9xedk66.js} +2 -2
  135. package/dist/{onboard-6fdbvh3v.js → onboard-dpgjn03r.js} +2 -2
  136. package/dist/{opencode-adapter-fdbsvts7.js → opencode-adapter-2d31cpjc.js} +6 -6
  137. package/dist/{otel-impl-rvwtc09q.js → otel-impl-1skarpfq.js} +1 -1
  138. package/dist/{pending-sqkrb836.js → pending-bfmxtx0g.js} +21 -19
  139. package/dist/{pi-mono-adapter-asqayqcg.js → pi-mono-adapter-gvppnasy.js} +40 -13
  140. package/dist/{pricing-refresh-f5tkgmw2.js → pricing-refresh-c6b325mk.js} +2 -2
  141. package/dist/{rbac-roles-06s555fa.js → rbac-roles-h80qbdbs.js} +3 -3
  142. package/dist/{rbac-roles-szxsg8t1.js → rbac-roles-zfcx68tx.js} +2 -2
  143. package/dist/{render-v2-103p266q.js → render-v2-nx20t3rb.js} +6 -3
  144. package/dist/{resume-v7kjewt9.js → resume-5ep8agan.js} +10 -7
  145. package/dist/{runtime-f1gmk0b7.js → runtime-r3pj4mce.js} +1 -1
  146. package/dist/{session-access-6shev8ts.js → session-access-n7p3m15b.js} +4 -4
  147. package/dist/{session-source-backfill-bd7spzjd.js → session-source-backfill-v8mt0zwn.js} +3 -3
  148. package/dist/{setup-kmxmztdb.js → setup-z1psaqhe.js} +1 -1
  149. package/dist/thread-buffer-a1re2r9r.js +38 -0
  150. package/dist/{virtual-modules-57eje5wy.js → virtual-modules-rrbjdpxn.js} +3 -3
  151. package/dist/{work-objects-zr47ygmf.js → work-objects-4aghh73z.js} +29 -23
  152. package/dist/worker-3dyyb8ev.js +74 -0
  153. package/dist/{worker-follow-up-grrr3fda.js → worker-follow-up-166zmex1.js} +20 -18
  154. package/openapi.json +1387 -13
  155. package/package.json +7 -6
  156. package/src/apps/catalog.generated.json +43 -3
  157. package/src/apps/page-validator.ts +27 -0
  158. package/src/be/db/model-profiles.ts +4 -1
  159. package/src/be/db/session-costs.ts +219 -0
  160. package/src/be/db/session-log-reasoning.ts +36 -0
  161. package/src/be/db/tasks/read.ts +7 -3
  162. package/src/be/db/tasks/write.ts +33 -1
  163. package/src/be/db.ts +200 -304
  164. package/src/be/key-window-usage.ts +385 -0
  165. package/src/be/migrations/303_task_ui_specs.sql +28 -0
  166. package/src/be/migrations/306_provider_account_telemetry.sql +1 -0
  167. package/src/be/migrations/307_session_cost_credential_attribution.sql +23 -0
  168. package/src/be/migrations/310_session_logs_reasoning.sql +12 -0
  169. package/src/be/runtime-pools/db.ts +3 -0
  170. package/src/be/seed-scripts/catalog/boot-triage.inline.ts +1 -0
  171. package/src/be/seed-scripts/catalog/boot-triage.ts +1 -0
  172. package/src/be/seed-scripts/catalog/wait-for-task.ts +5 -1
  173. package/src/be/seed-skills/index.ts +3 -0
  174. package/src/be/swarm-config-guard.ts +24 -1
  175. package/src/be/task-ui-spec.ts +158 -0
  176. package/src/commands/controller.ts +3 -0
  177. package/src/commands/credential-outcome-report.ts +13 -3
  178. package/src/commands/rate-limit-outcome.ts +6 -0
  179. package/src/commands/runner.ts +34 -53
  180. package/src/extensions/catalog.generated.json +3 -3
  181. package/src/extensions/contract-types.generated.ts +1 -1
  182. package/src/http/api-keys.ts +258 -30
  183. package/src/http/session-data.ts +74 -23
  184. package/src/http/sessions.ts +6 -2
  185. package/src/http/tasks.ts +105 -5
  186. package/src/integrations/chat-sdk/relay.ts +87 -0
  187. package/src/jira/outbound.ts +5 -3
  188. package/src/linear/outbound.ts +5 -1
  189. package/src/prompts/base-prompt.ts +8 -0
  190. package/src/prompts/session-templates.ts +19 -2
  191. package/src/providers/acp-targets.ts +1 -1
  192. package/src/providers/amp-adapter.ts +1 -1
  193. package/src/providers/claude-adapter.ts +27 -4
  194. package/src/providers/claude-flag-settings.ts +39 -1
  195. package/src/providers/codex-adapter.ts +85 -3
  196. package/src/providers/codex-app-server.ts +9 -5
  197. package/src/providers/codex-oauth/auth-json.ts +1 -0
  198. package/src/providers/pi-mono-adapter.ts +35 -2
  199. package/src/providers/pricing-sources.md +32 -0
  200. package/src/providers/types.ts +11 -0
  201. package/src/runtime-providers/docker.ts +65 -1
  202. package/src/scheduler/deferred-task-waits.ts +18 -5
  203. package/src/scripts-runtime/types/swarm-extension.d.ts +8 -8
  204. package/src/slack/actions.ts +56 -0
  205. package/src/slack/app.ts +22 -15
  206. package/src/slack/inbound-files.ts +2 -0
  207. package/src/slack/render-v2.ts +107 -23
  208. package/src/slack/responses.ts +3 -2
  209. package/src/slack/work-objects.ts +4 -1
  210. package/src/tasks/errors.ts +5 -0
  211. package/src/tests/acp-adapter.test.ts +4 -6
  212. package/src/tests/api-key-tracking.test.ts +0 -72
  213. package/src/tests/api-keys-status-model-limits.test.ts +93 -1
  214. package/src/tests/api-keys-validation.test.ts +42 -0
  215. package/src/tests/approval-card-resolution.test.ts +7 -1
  216. package/src/tests/approval-requests-notifications.test.ts +11 -1
  217. package/src/tests/apps-catalog-page-frame.test.ts +49 -0
  218. package/src/tests/apps-session-thread.test.ts +79 -0
  219. package/src/tests/base-prompt.test.ts +111 -5
  220. package/src/tests/chat-sdk-relay.test.ts +149 -1
  221. package/src/tests/claude-adapter-binary.test.ts +67 -6
  222. package/src/tests/claude-flag-settings.test.ts +29 -0
  223. package/src/tests/claude-sdk-lifecycle.test.ts +5 -0
  224. package/src/tests/codex-adapter.test.ts +340 -2
  225. package/src/tests/codex-app-server.test.ts +16 -0
  226. package/src/tests/codex-oauth.test.ts +3 -1
  227. package/src/tests/codex-rate-limits.test.ts +384 -0
  228. package/src/tests/credential-outcome-report.test.ts +20 -0
  229. package/src/tests/db-task-read-contract.test.ts +3 -0
  230. package/src/tests/db-task-write-contract.test.ts +4 -0
  231. package/src/tests/deferred-task-wake.test.ts +63 -1
  232. package/src/tests/docker-isolation-config-guard.test.ts +29 -0
  233. package/src/tests/docs-index-footprint.test.js +11 -3
  234. package/src/tests/e2e-visuals-comment.test.ts +82 -0
  235. package/src/tests/e2e-visuals-verify-pr.test.ts +138 -0
  236. package/src/tests/extensions-example-sql-admin-only.test.ts +7 -4
  237. package/src/tests/fixtures/ui-spec-slack/deploys.json +121 -0
  238. package/src/tests/fixtures/ui-spec-slack/incident.json +183 -0
  239. package/src/tests/fixtures/ui-spec-slack/three-charts-stale.json +196 -0
  240. package/src/tests/fixtures/ui-spec-slack/video-rejected-by-slack.json +183 -0
  241. package/src/tests/fixtures/ui-spec-slack/video.json +446 -0
  242. package/src/tests/gitleaks-download-retry.test.ts +85 -0
  243. package/src/tests/human-thread-routing.test.ts +187 -0
  244. package/src/tests/jira-outbound-sync.test.ts +33 -1
  245. package/src/tests/key-window-usage.test.ts +831 -0
  246. package/src/tests/linear-outbound-sync.test.ts +30 -1
  247. package/src/tests/pi-mono-adapter.test.ts +79 -0
  248. package/src/tests/preload-env.test.ts +2 -0
  249. package/src/tests/preload.ts +3 -1
  250. package/src/tests/prompt-template-session.test.ts +4 -3
  251. package/src/tests/provider-quota-persistence.test.ts +362 -0
  252. package/src/tests/rate-limit-event.test.ts +22 -0
  253. package/src/tests/reasoning-events.test.ts +164 -0
  254. package/src/tests/routing-affinity-inventory.test.ts +22 -0
  255. package/src/tests/runtime-providers-docker.test.ts +91 -0
  256. package/src/tests/script-connections.test.ts +5 -0
  257. package/src/tests/secret-canary-sweep.test.ts +41 -5
  258. package/src/tests/seed-scripts.test.ts +23 -0
  259. package/src/tests/session-cost-attribution.test.ts +748 -0
  260. package/src/tests/session-costs.test.ts +14 -15
  261. package/src/tests/session-logs.test.ts +83 -0
  262. package/src/tests/sessions-detail-batch.test.ts +7 -0
  263. package/src/tests/slack-render-v2.test.ts +357 -0
  264. package/src/tests/slack-start-reload-race.test.ts +67 -0
  265. package/src/tests/subscription-plans.test.ts +20 -1
  266. package/src/tests/task-ui-action-route.test.ts +191 -0
  267. package/src/tests/task-ui-actions.test.ts +195 -0
  268. package/src/tests/task-ui-spec-fallback.test.ts +65 -0
  269. package/src/tests/task-ui-spec.test.ts +368 -0
  270. package/src/tests/workflow-agent-task-retry.test.ts +34 -1
  271. package/src/tools/defer-task.ts +1 -1
  272. package/src/tools/store-progress.ts +69 -3
  273. package/src/types.ts +7 -2
  274. package/src/ui-spec/actions.ts +86 -0
  275. package/src/ui-spec/fallback.ts +19 -0
  276. package/src/ui-spec/slack.ts +17 -0
  277. package/src/ui-spec/validate.ts +169 -0
  278. package/src/utils/codex-rate-limits.ts +159 -0
  279. package/src/utils/credentials.ts +2 -0
  280. package/src/utils/error-tracker.ts +19 -0
  281. package/src/utils/provider-account-telemetry.ts +331 -0
  282. package/src/utils/reasoning-events.ts +107 -0
  283. package/src/utils/subscription-plans.ts +11 -59
  284. package/src/utils/task-ui-spec.ts +67 -0
  285. package/src/workflows/task-step-routing.ts +8 -3
  286. package/templates/extensions/sql-admin-only/README.md +2 -1
  287. package/templates/extensions/sql-admin-only/hooks.ts +7 -3
  288. package/templates/extensions/sql-admin-only/manifest.json +1 -1
  289. package/templates/skills/apps/SKILL.md +32 -5
  290. package/templates/skills/apps/content.md +32 -5
  291. package/templates/skills/ui-spec/config.json +14 -0
  292. package/templates/skills/ui-spec/content.md +127 -0
  293. package/dist/acp-adapter-jqn86aam.js +0 -16
  294. package/dist/cli-srtkr1h2.js +0 -12078
  295. package/dist/fx-adapter-0zrkfbkd.js +0 -19
  296. package/dist/grok-adapter-3db1c538.js +0 -19
  297. package/dist/handlers-k22n8mnn.js +0 -33
  298. package/dist/index-8xcyd3mc.js +0 -33
  299. package/dist/index-9sy2bh6n.js +0 -38
  300. package/dist/index-b24j7t2m.js +0 -12797
  301. package/dist/index-wjd56k1v.js +0 -34
  302. package/dist/lead-atxf3q6e.js +0 -72
  303. package/dist/thread-buffer-4yz236d0.js +0 -36
  304. package/dist/worker-p4hbtcy3.js +0 -72
  305. package/dist/{cli-j49yqpvh.js → cli-7evph51z.js} +3 -3
@@ -19,16 +19,26 @@ import {
19
19
  defaultEmojiResolver2,
20
20
  convertEmojiPlaceholders2,
21
21
  cardChildToFallbackText2,
22
- init_dist4
23
- } from "./cli-wr1h0k28.js";
22
+ init_dist8
23
+ } from "./cli-9w8712tq.js";
24
24
  import {
25
25
  require_index_min
26
26
  } from "./cli-t9wbrgm4.js";
27
+ import {
28
+ require_jsonwebtoken,
29
+ require_lib,
30
+ require_vary,
31
+ require_express
32
+ } from "./cli-1jx0srjt.js";
33
+ import {
34
+ require_form_data,
35
+ require_follow_redirects
36
+ } from "./cli-meydjstb.js";
27
37
  import {
28
38
  extractCard,
29
39
  extractFiles,
30
40
  AdapterRateLimitError,
31
- AuthenticationError2,
41
+ AuthenticationError3,
32
42
  PermissionError,
33
43
  ValidationError,
34
44
  NetworkError,
@@ -38,18 +48,8 @@ import {
38
48
  mapButtonStyle,
39
49
  escapeTableCell,
40
50
  downloadAttachment,
41
- init_dist
42
- } from "./cli-spzkdgtg.js";
43
- import {
44
- require_jsonwebtoken,
45
- require_lib,
46
- require_vary,
47
- require_express
48
- } from "./cli-1jx0srjt.js";
49
- import {
50
- require_form_data,
51
- require_follow_redirects
52
- } from "./cli-meydjstb.js";
51
+ init_dist7
52
+ } from "./cli-n3qe7tyr.js";
53
53
  import {
54
54
  require_src3
55
55
  } from "./cli-qe909n63.js";
@@ -43316,21 +43316,46 @@ var init_chats = __esm(() => {
43316
43316
  init_messages();
43317
43317
  });
43318
43318
 
43319
+ // node_modules/@microsoft/teams.graph-endpoints/dist/shares/driveItem/index.mjs
43320
+ var exports_driveItem = {};
43321
+ __export(exports_driveItem, {
43322
+ content: () => d3,
43323
+ get: () => s
43324
+ });
43325
+ function s(t) {
43326
+ return { method: "get", path: "/shares/{sharedDriveItem-id}/driveItem", paramDefs: { path: ["sharedDriveItem-id"], query: ["$select", "$expand"] }, params: t };
43327
+ }
43328
+ var d3;
43329
+ var init_driveItem = __esm(() => {
43330
+ d3 = { get: function(e) {
43331
+ return { method: "get", path: "/shares/{sharedDriveItem-id}/driveItem/content", paramDefs: { query: ["$format"], path: ["sharedDriveItem-id"] }, params: e };
43332
+ }, set: function(e, r) {
43333
+ return { method: "put", path: "/shares/{sharedDriveItem-id}/driveItem/content", paramDefs: { path: ["sharedDriveItem-id"] }, params: r, body: e };
43334
+ }, del: function(e) {
43335
+ return { method: "delete", path: "/shares/{sharedDriveItem-id}/driveItem/content", paramDefs: { header: ["If-Match"], path: ["sharedDriveItem-id"] }, params: e };
43336
+ } };
43337
+ });
43338
+
43339
+ // node_modules/@microsoft/teams.graph-endpoints/dist/shares/index.mjs
43340
+ var init_shares = __esm(() => {
43341
+ init_driveItem();
43342
+ });
43343
+
43319
43344
  // node_modules/@microsoft/teams.graph-endpoints/dist/teams/channels/allMembers/index.mjs
43320
43345
  var exports_allMembers = {};
43321
43346
  __export(exports_allMembers, {
43322
43347
  add: () => l,
43323
- create: () => d3,
43348
+ create: () => d4,
43324
43349
  del: () => t,
43325
43350
  get: () => i3,
43326
- list: () => s,
43351
+ list: () => s2,
43327
43352
  remove: () => r3,
43328
43353
  update: () => m
43329
43354
  });
43330
43355
  function t(e) {
43331
43356
  return { method: "delete", path: "/teams/{team-id}/channels/{channel-id}/allMembers/{conversationMember-id}", paramDefs: { header: ["If-Match"], path: ["team-id", "channel-id", "conversationMember-id"] }, params: e };
43332
43357
  }
43333
- function s(e) {
43358
+ function s2(e) {
43334
43359
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/allMembers", paramDefs: { path: ["team-id", "channel-id"], query: ["$top", "$skip", "$search", "$filter", "$count", "$orderby", "$select", "$expand"] }, params: e };
43335
43360
  }
43336
43361
  function i3(e) {
@@ -43339,7 +43364,7 @@ function i3(e) {
43339
43364
  function m(e, n) {
43340
43365
  return { method: "patch", path: "/teams/{team-id}/channels/{channel-id}/allMembers/{conversationMember-id}", paramDefs: { path: ["team-id", "channel-id", "conversationMember-id"] }, params: n, body: e };
43341
43366
  }
43342
- function d3(e, n) {
43367
+ function d4(e, n) {
43343
43368
  return { method: "post", path: "/teams/{team-id}/channels/{channel-id}/allMembers", paramDefs: { path: ["team-id", "channel-id"] }, params: n, body: e };
43344
43369
  }
43345
43370
  var l, r3;
@@ -43355,15 +43380,15 @@ var init_allMembers = __esm(() => {
43355
43380
  // node_modules/@microsoft/teams.graph-endpoints/dist/teams/channels/filesFolder/index.mjs
43356
43381
  var exports_filesFolder = {};
43357
43382
  __export(exports_filesFolder, {
43358
- content: () => s2,
43383
+ content: () => s3,
43359
43384
  get: () => a3
43360
43385
  });
43361
43386
  function a3(n) {
43362
43387
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/filesFolder", paramDefs: { path: ["team-id", "channel-id"], query: ["$select", "$expand"] }, params: n };
43363
43388
  }
43364
- var s2;
43389
+ var s3;
43365
43390
  var init_filesFolder = __esm(() => {
43366
- s2 = { get: function(e) {
43391
+ s3 = { get: function(e) {
43367
43392
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/filesFolder/content", paramDefs: { query: ["$format"], path: ["team-id", "channel-id"] }, params: e };
43368
43393
  }, set: function(e, t) {
43369
43394
  return { method: "put", path: "/teams/{team-id}/channels/{channel-id}/filesFolder/content", paramDefs: { path: ["team-id", "channel-id"] }, params: t, body: e };
@@ -43376,9 +43401,9 @@ var init_filesFolder = __esm(() => {
43376
43401
  var exports_members = {};
43377
43402
  __export(exports_members, {
43378
43403
  add: () => r4,
43379
- create: () => d4,
43404
+ create: () => d5,
43380
43405
  del: () => t2,
43381
- get: () => s3,
43406
+ get: () => s4,
43382
43407
  list: () => m2,
43383
43408
  remove: () => o3,
43384
43409
  update: () => i4
@@ -43389,13 +43414,13 @@ function t2(e) {
43389
43414
  function m2(e) {
43390
43415
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/members", paramDefs: { path: ["team-id", "channel-id"], query: ["$top", "$skip", "$search", "$filter", "$count", "$orderby", "$select", "$expand"] }, params: e };
43391
43416
  }
43392
- function s3(e) {
43417
+ function s4(e) {
43393
43418
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/members/{conversationMember-id}", paramDefs: { path: ["team-id", "channel-id", "conversationMember-id"], query: ["$select", "$expand"] }, params: e };
43394
43419
  }
43395
43420
  function i4(e, n) {
43396
43421
  return { method: "patch", path: "/teams/{team-id}/channels/{channel-id}/members/{conversationMember-id}", paramDefs: { path: ["team-id", "channel-id", "conversationMember-id"] }, params: n, body: e };
43397
43422
  }
43398
- function d4(e, n) {
43423
+ function d5(e, n) {
43399
43424
  return { method: "post", path: "/teams/{team-id}/channels/{channel-id}/members", paramDefs: { path: ["team-id", "channel-id"] }, params: n, body: e };
43400
43425
  }
43401
43426
  var r4, o3;
@@ -43420,7 +43445,7 @@ __export(exports_replies2, {
43420
43445
  softDelete: () => o4,
43421
43446
  undoSoftDelete: () => g3,
43422
43447
  unsetReaction: () => l2,
43423
- update: () => d5
43448
+ update: () => d6
43424
43449
  });
43425
43450
  function t3(s) {
43426
43451
  return { method: "delete", path: "/teams/{team-id}/channels/{channel-id}/messages/{chatMessage-id}/replies/{chatMessage-id1}", paramDefs: { header: ["If-Match"], path: ["team-id", "channel-id", "chatMessage-id", "chatMessage-id1"] }, params: s };
@@ -43431,7 +43456,7 @@ function n3(s) {
43431
43456
  function i5(s) {
43432
43457
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/messages/{chatMessage-id}/replies/{chatMessage-id1}", paramDefs: { path: ["team-id", "channel-id", "chatMessage-id", "chatMessage-id1"], query: ["$select", "$expand"] }, params: s };
43433
43458
  }
43434
- function d5(s, e) {
43459
+ function d6(s, e) {
43435
43460
  return { method: "patch", path: "/teams/{team-id}/channels/{channel-id}/messages/{chatMessage-id}/replies/{chatMessage-id1}", paramDefs: { path: ["team-id", "channel-id", "chatMessage-id", "chatMessage-id1"] }, params: e, body: s };
43436
43461
  }
43437
43462
  function h3(s, e) {
@@ -43469,7 +43494,7 @@ var exports_messages2 = {};
43469
43494
  __export(exports_messages2, {
43470
43495
  create: () => h4,
43471
43496
  del: () => t4,
43472
- get: () => d6,
43497
+ get: () => d7,
43473
43498
  hostedContents: () => c4,
43474
43499
  list: () => n4,
43475
43500
  replies: () => exports_replies2,
@@ -43485,7 +43510,7 @@ function t4(s) {
43485
43510
  function n4(s) {
43486
43511
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/messages", paramDefs: { path: ["team-id", "channel-id"], query: ["$top", "$skip", "$search", "$filter", "$count", "$orderby", "$select", "$expand"] }, params: s };
43487
43512
  }
43488
- function d6(s) {
43513
+ function d7(s) {
43489
43514
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/messages/{chatMessage-id}", paramDefs: { path: ["team-id", "channel-id", "chatMessage-id"], query: ["$select", "$expand"] }, params: s };
43490
43515
  }
43491
43516
  function i6(s, e) {
@@ -43526,12 +43551,12 @@ var init_messages2 = __esm(() => {
43526
43551
  var exports_sharedWithTeams = {};
43527
43552
  __export(exports_sharedWithTeams, {
43528
43553
  allowedMembers: () => i7,
43529
- create: () => d7,
43554
+ create: () => d8,
43530
43555
  del: () => n5,
43531
43556
  get: () => h5,
43532
43557
  list: () => t5,
43533
43558
  team: () => m5,
43534
- update: () => s4
43559
+ update: () => s5
43535
43560
  });
43536
43561
  function n5(e) {
43537
43562
  return { method: "delete", path: "/teams/{team-id}/channels/{channel-id}/sharedWithTeams/{sharedWithChannelTeamInfo-id}", paramDefs: { header: ["If-Match"], path: ["team-id", "channel-id", "sharedWithChannelTeamInfo-id"] }, params: e };
@@ -43542,10 +43567,10 @@ function t5(e) {
43542
43567
  function h5(e) {
43543
43568
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/sharedWithTeams/{sharedWithChannelTeamInfo-id}", paramDefs: { path: ["team-id", "channel-id", "sharedWithChannelTeamInfo-id"], query: ["$select", "$expand"] }, params: e };
43544
43569
  }
43545
- function s4(e, a) {
43570
+ function s5(e, a) {
43546
43571
  return { method: "patch", path: "/teams/{team-id}/channels/{channel-id}/sharedWithTeams/{sharedWithChannelTeamInfo-id}", paramDefs: { path: ["team-id", "channel-id", "sharedWithChannelTeamInfo-id"] }, params: a, body: e };
43547
43572
  }
43548
- function d7(e, a) {
43573
+ function d8(e, a) {
43549
43574
  return { method: "post", path: "/teams/{team-id}/channels/{channel-id}/sharedWithTeams", paramDefs: { path: ["team-id", "channel-id"] }, params: a, body: e };
43550
43575
  }
43551
43576
  var i7, m5;
@@ -43563,9 +43588,9 @@ var init_sharedWithTeams = __esm(() => {
43563
43588
  // node_modules/@microsoft/teams.graph-endpoints/dist/teams/channels/tabs/index.mjs
43564
43589
  var exports_tabs = {};
43565
43590
  __export(exports_tabs, {
43566
- create: () => d8,
43591
+ create: () => d9,
43567
43592
  del: () => t6,
43568
- get: () => s5,
43593
+ get: () => s6,
43569
43594
  list: () => n6,
43570
43595
  teamsApp: () => m6,
43571
43596
  update: () => i8
@@ -43576,13 +43601,13 @@ function t6(a) {
43576
43601
  function n6(a) {
43577
43602
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/tabs", paramDefs: { path: ["team-id", "channel-id"], query: ["$top", "$skip", "$search", "$filter", "$count", "$orderby", "$select", "$expand"] }, params: a };
43578
43603
  }
43579
- function s5(a) {
43604
+ function s6(a) {
43580
43605
  return { method: "get", path: "/teams/{team-id}/channels/{channel-id}/tabs/{teamsTab-id}", paramDefs: { path: ["team-id", "channel-id", "teamsTab-id"], query: ["$select", "$expand"] }, params: a };
43581
43606
  }
43582
43607
  function i8(a, e) {
43583
43608
  return { method: "patch", path: "/teams/{team-id}/channels/{channel-id}/tabs/{teamsTab-id}", paramDefs: { path: ["team-id", "channel-id", "teamsTab-id"] }, params: e, body: a };
43584
43609
  }
43585
- function d8(a, e) {
43610
+ function d9(a, e) {
43586
43611
  return { method: "post", path: "/teams/{team-id}/channels/{channel-id}/tabs", paramDefs: { path: ["team-id", "channel-id"] }, params: e, body: a };
43587
43612
  }
43588
43613
  var m6;
@@ -43598,11 +43623,11 @@ __export(exports_channels, {
43598
43623
  allMembers: () => exports_allMembers,
43599
43624
  archive: () => c5,
43600
43625
  completeMigration: () => o6,
43601
- create: () => d9,
43626
+ create: () => d10,
43602
43627
  del: () => t7,
43603
43628
  filesFolder: () => exports_filesFolder,
43604
43629
  get: () => i9,
43605
- list: () => s6,
43630
+ list: () => s7,
43606
43631
  members: () => exports_members,
43607
43632
  messages: () => exports_messages2,
43608
43633
  provisionEmail: () => h6,
@@ -43615,7 +43640,7 @@ __export(exports_channels, {
43615
43640
  function t7(e) {
43616
43641
  return { method: "delete", path: "/teams/{team-id}/channels/{channel-id}", paramDefs: { header: ["If-Match"], path: ["team-id", "channel-id"] }, params: e };
43617
43642
  }
43618
- function s6(e) {
43643
+ function s7(e) {
43619
43644
  return { method: "get", path: "/teams/{team-id}/channels", paramDefs: { path: ["team-id"], query: ["$top", "$skip", "$search", "$filter", "$count", "$orderby", "$select", "$expand"] }, params: e };
43620
43645
  }
43621
43646
  function i9(e) {
@@ -43624,7 +43649,7 @@ function i9(e) {
43624
43649
  function m7(e, n) {
43625
43650
  return { method: "patch", path: "/teams/{team-id}/channels/{channel-id}", paramDefs: { path: ["team-id", "channel-id"] }, params: n, body: e };
43626
43651
  }
43627
- function d9(e, n) {
43652
+ function d10(e, n) {
43628
43653
  return { method: "post", path: "/teams/{team-id}/channels", paramDefs: { path: ["team-id"] }, params: n, body: e };
43629
43654
  }
43630
43655
  var c5, o6, h6, r5, p3;
@@ -43664,13 +43689,19 @@ function n7(s) {
43664
43689
  var init_users = () => {};
43665
43690
 
43666
43691
  // node_modules/@microsoft/teams.graph-endpoints/dist/index.mjs
43667
- var init_dist2 = __esm(() => {
43692
+ var init_dist = __esm(() => {
43668
43693
  init_chats();
43694
+ init_shares();
43669
43695
  init_teams();
43670
43696
  init_users();
43671
43697
  });
43672
43698
 
43673
43699
  // node_modules/@chat-adapter/teams/dist/index.js
43700
+ function applyAiGeneratedLabel(activity, message) {
43701
+ if (typeof message === "object" && message.aiGenerated === true) {
43702
+ activity.addAiGenerated();
43703
+ }
43704
+ }
43674
43705
  function normalizeServiceUrl(serviceUrl) {
43675
43706
  let end = serviceUrl.length;
43676
43707
  while (end > 0 && serviceUrl[end - 1] === "/") {
@@ -43706,6 +43737,9 @@ function createFetchDataFn(retrieval, fetchers) {
43706
43737
  if (retrieval.mode === "anonymous") {
43707
43738
  return fetchers.createAnonymousFetchData(retrieval.url);
43708
43739
  }
43740
+ if (retrieval.mode === "graph") {
43741
+ return () => fetchers.fetchGraphFile(retrieval.url);
43742
+ }
43709
43743
  return async () => {
43710
43744
  if (retrieval.mode === "rejected" || !isTrustedBotAttachmentUrl(retrieval.url, retrieval.connectorOrigin)) {
43711
43745
  throw new NetworkError("teams", "Refusing to send a bot token to an untrusted attachment URL");
@@ -43769,6 +43803,28 @@ function createTeamsAttachment(att, serviceUrl, fetchers) {
43769
43803
  fetchData: retrieval ? createFetchDataFn(retrieval, fetchers) : undefined
43770
43804
  };
43771
43805
  }
43806
+ function createTeamsGraphAttachment(att, fetchers) {
43807
+ const name = att.name ?? undefined;
43808
+ const url = att.contentUrl ?? undefined;
43809
+ if (att.contentType !== GRAPH_FILE_REFERENCE_CONTENT_TYPE) {
43810
+ return {
43811
+ type: att.contentType?.includes("image") ? "image" : "file",
43812
+ name,
43813
+ url,
43814
+ mimeType: att.contentType ?? undefined
43815
+ };
43816
+ }
43817
+ const mimeType = inferFileMimeType(name);
43818
+ const retrieval = url ? { mode: "graph", url } : undefined;
43819
+ return {
43820
+ type: classifyAttachmentType(mimeType),
43821
+ name,
43822
+ url,
43823
+ mimeType,
43824
+ fetchMetadata: url ? { url, auth: "graph" } : undefined,
43825
+ fetchData: retrieval ? createFetchDataFn(retrieval, fetchers) : undefined
43826
+ };
43827
+ }
43772
43828
  function rehydrateTeamsAttachment(attachment, fetchers) {
43773
43829
  const url = attachment.fetchMetadata?.url ?? attachment.url;
43774
43830
  if (!url) {
@@ -43778,37 +43834,64 @@ function rehydrateTeamsAttachment(attachment, fetchers) {
43778
43834
  let retrieval = { mode: "anonymous", url };
43779
43835
  if (attachment.fetchMetadata?.auth === "bot") {
43780
43836
  retrieval = connectorOrigin ? { mode: "bot", url, connectorOrigin } : { mode: "rejected", url };
43837
+ } else if (attachment.fetchMetadata?.auth === "graph") {
43838
+ retrieval = { mode: "graph", url };
43781
43839
  }
43782
43840
  return {
43783
43841
  ...attachment,
43784
43842
  fetchData: createFetchDataFn(retrieval, fetchers)
43785
43843
  };
43786
43844
  }
43845
+ function cardInputValues(data, reservedKeys) {
43846
+ if (!data) {
43847
+ return;
43848
+ }
43849
+ const values = {};
43850
+ for (const [key, value] of Object.entries(data)) {
43851
+ if (reservedKeys.has(key)) {
43852
+ continue;
43853
+ }
43854
+ const text = submitValueToString(value);
43855
+ if (text !== undefined) {
43856
+ values[key] = text;
43857
+ }
43858
+ }
43859
+ return Object.keys(values).length > 0 ? values : undefined;
43860
+ }
43861
+ function submitValueToString(value) {
43862
+ if (typeof value === "string") {
43863
+ return value;
43864
+ }
43865
+ if (typeof value === "number") {
43866
+ return String(value);
43867
+ }
43868
+ return;
43869
+ }
43787
43870
  function cardToAdaptiveCard(card) {
43788
43871
  const body = [];
43789
43872
  const actions = [];
43790
43873
  if (card.title) {
43791
- body.push(new import_teams6.TextBlock(convertEmoji(card.title), {
43874
+ body.push(new import_teams7.TextBlock(convertEmoji(card.title), {
43792
43875
  weight: "Bolder",
43793
43876
  size: "Large",
43794
43877
  wrap: true
43795
43878
  }));
43796
43879
  }
43797
43880
  if (card.subtitle) {
43798
- body.push(new import_teams6.TextBlock(convertEmoji(card.subtitle), {
43881
+ body.push(new import_teams7.TextBlock(convertEmoji(card.subtitle), {
43799
43882
  isSubtle: true,
43800
43883
  wrap: true
43801
43884
  }));
43802
43885
  }
43803
43886
  if (card.imageUrl) {
43804
- body.push(new import_teams6.Image(card.imageUrl, { size: "Stretch" }));
43887
+ body.push(new import_teams7.Image(card.imageUrl, { size: "Stretch" }));
43805
43888
  }
43806
43889
  for (const child of card.children) {
43807
43890
  const result = convertChildToAdaptive(child);
43808
43891
  body.push(...result.elements);
43809
43892
  actions.push(...result.actions);
43810
43893
  }
43811
- const adaptiveCard = new import_teams6.AdaptiveCard(...body).withOptions({
43894
+ const adaptiveCard = new import_teams7.AdaptiveCard(...body).withOptions({
43812
43895
  $schema: ADAPTIVE_CARD_SCHEMA,
43813
43896
  version: ADAPTIVE_CARD_VERSION,
43814
43897
  ...card.width === "full" ? { msteams: { width: "full" } } : {}
@@ -43835,7 +43918,7 @@ function convertChildToAdaptive(child) {
43835
43918
  case "link":
43836
43919
  return {
43837
43920
  elements: [
43838
- new import_teams6.TextBlock(`[${convertEmoji(child.label)}](${child.url})`, {
43921
+ new import_teams7.TextBlock(`[${convertEmoji(child.label)}](${child.url})`, {
43839
43922
  wrap: true
43840
43923
  })
43841
43924
  ],
@@ -43843,11 +43926,16 @@ function convertChildToAdaptive(child) {
43843
43926
  };
43844
43927
  case "table":
43845
43928
  return { elements: convertTableToElements(child), actions: [] };
43929
+ case "text_input":
43930
+ if (BUTTON_SUBMIT_KEYS.has(child.id)) {
43931
+ throw new ValidationError("teams", `A card TextInput can't use the ID "${child.id}", which the adapter reserves for the button's own submit data`);
43932
+ }
43933
+ return { elements: [textInputToAdaptive(child)], actions: [] };
43846
43934
  default: {
43847
43935
  const text = cardChildToFallbackText2(child);
43848
43936
  if (text) {
43849
43937
  return {
43850
- elements: [new import_teams6.TextBlock(text, { wrap: true })],
43938
+ elements: [new import_teams7.TextBlock(text, { wrap: true })],
43851
43939
  actions: []
43852
43940
  };
43853
43941
  }
@@ -43864,16 +43952,28 @@ function convertTextToElement(element) {
43864
43952
  } else if (element.style === "muted") {
43865
43953
  options.isSubtle = true;
43866
43954
  }
43867
- return new import_teams6.TextBlock(convertEmoji(element.content), options);
43955
+ return new import_teams7.TextBlock(convertEmoji(element.content), options);
43956
+ }
43957
+ function textInputToAdaptive(element) {
43958
+ const options = {
43959
+ id: element.id,
43960
+ label: convertEmoji(element.label),
43961
+ isMultiline: element.multiline ?? false,
43962
+ isRequired: !(element.optional ?? false),
43963
+ placeholder: element.placeholder,
43964
+ value: element.initialValue,
43965
+ maxLength: element.maxLength
43966
+ };
43967
+ return new import_teams7.TextInput(options);
43868
43968
  }
43869
43969
  function convertImageToElement(element) {
43870
- return new import_teams6.Image(element.url, {
43970
+ return new import_teams7.Image(element.url, {
43871
43971
  altText: element.alt || "Image",
43872
43972
  size: "Auto"
43873
43973
  });
43874
43974
  }
43875
43975
  function convertDividerToElement(_element) {
43876
- return new import_teams6.Container().withSeparator(true);
43976
+ return new import_teams7.Container().withSeparator(true);
43877
43977
  }
43878
43978
  function convertActionsToElements(element) {
43879
43979
  const actions = [];
@@ -43902,7 +44002,7 @@ function convertActionsToElements(element) {
43902
44002
  }
43903
44003
  }
43904
44004
  if (hasInputs && !hasButtons) {
43905
- actions.push(new import_teams6.SubmitAction({
44005
+ actions.push(new import_teams7.SubmitAction({
43906
44006
  title: "Submit",
43907
44007
  data: { actionId: AUTO_SUBMIT_ACTION_ID }
43908
44008
  }));
@@ -43910,7 +44010,7 @@ function convertActionsToElements(element) {
43910
44010
  return { elements, actions };
43911
44011
  }
43912
44012
  function convertSelectToElement(select) {
43913
- const choices = select.options.map((opt) => new import_teams6.Choice({ title: convertEmoji(opt.label), value: opt.value }));
44013
+ const choices = select.options.map((opt) => new import_teams7.Choice({ title: convertEmoji(opt.label), value: opt.value }));
43914
44014
  const options = {
43915
44015
  id: select.id,
43916
44016
  label: convertEmoji(select.label),
@@ -43919,10 +44019,10 @@ function convertSelectToElement(select) {
43919
44019
  placeholder: select.placeholder,
43920
44020
  value: select.initialOption
43921
44021
  };
43922
- return new import_teams6.ChoiceSetInput(...choices).withOptions(options);
44022
+ return new import_teams7.ChoiceSetInput(...choices).withOptions(options);
43923
44023
  }
43924
44024
  function convertRadioSelectToElement(radioSelect) {
43925
- const choices = radioSelect.options.map((opt) => new import_teams6.Choice({ title: convertEmoji(opt.label), value: opt.value }));
44025
+ const choices = radioSelect.options.map((opt) => new import_teams7.Choice({ title: convertEmoji(opt.label), value: opt.value }));
43926
44026
  const options = {
43927
44027
  id: radioSelect.id,
43928
44028
  label: convertEmoji(radioSelect.label),
@@ -43930,7 +44030,7 @@ function convertRadioSelectToElement(radioSelect) {
43930
44030
  isRequired: !(radioSelect.optional ?? false),
43931
44031
  value: radioSelect.initialOption
43932
44032
  };
43933
- return new import_teams6.ChoiceSetInput(...choices).withOptions(options);
44033
+ return new import_teams7.ChoiceSetInput(...choices).withOptions(options);
43934
44034
  }
43935
44035
  function actionOptions(button) {
43936
44036
  const options = {
@@ -43954,11 +44054,14 @@ function convertButtonToAction(button) {
43954
44054
  data.msteams = { type: "task/fetch" };
43955
44055
  }
43956
44056
  const options = { ...actionOptions(button), data };
43957
- return new import_teams6.SubmitAction(options);
44057
+ if (button.actionType === "modal") {
44058
+ options.associatedInputs = "none";
44059
+ }
44060
+ return new import_teams7.SubmitAction(options);
43958
44061
  }
43959
44062
  function convertLinkButtonToAction(button) {
43960
44063
  const options = actionOptions(button);
43961
- return new import_teams6.OpenUrlAction(button.url, options);
44064
+ return new import_teams7.OpenUrlAction(button.url, options);
43962
44065
  }
43963
44066
  function convertSectionToElements(element) {
43964
44067
  const elements = [];
@@ -43970,7 +44073,7 @@ function convertSectionToElements(element) {
43970
44073
  actions.push(...result.actions);
43971
44074
  }
43972
44075
  if (containerItems.length > 0) {
43973
- elements.push(new import_teams6.Container(...containerItems));
44076
+ elements.push(new import_teams7.Container(...containerItems));
43974
44077
  }
43975
44078
  return { elements, actions };
43976
44079
  }
@@ -43993,13 +44096,13 @@ function convertTableToElements(element) {
43993
44096
  }
43994
44097
  const columns = Array.from({ length: columnCount }, (_, index) => {
43995
44098
  const align = element.align?.[index];
43996
- return new import_teams6.ColumnDefinition({
44099
+ return new import_teams7.ColumnDefinition({
43997
44100
  width: columnWeight(element.widths?.[index]),
43998
44101
  horizontalCellContentAlignment: align ? TABLE_HORIZONTAL_ALIGNMENT[align] : undefined
43999
44102
  });
44000
44103
  });
44001
- const toRow = (cells, textOptions = {}) => new import_teams6.TableRow({
44002
- cells: Array.from({ length: columnCount }, (_, index) => new import_teams6.TableCell(new import_teams6.TextBlock(convertEmoji(cells[index] ?? ""), {
44104
+ const toRow = (cells, textOptions = {}) => new import_teams7.TableRow({
44105
+ cells: Array.from({ length: columnCount }, (_, index) => new import_teams7.TableCell(new import_teams7.TextBlock(convertEmoji(cells[index] ?? ""), {
44003
44106
  wrap: true,
44004
44107
  ...textOptions
44005
44108
  })))
@@ -44010,7 +44113,7 @@ function convertTableToElements(element) {
44010
44113
  rows.unshift(toRow(element.headers, { weight: "Bolder" }));
44011
44114
  }
44012
44115
  return [
44013
- new import_teams6.Table({
44116
+ new import_teams7.Table({
44014
44117
  columns,
44015
44118
  firstRowAsHeaders: hasHeader,
44016
44119
  rows,
@@ -44021,8 +44124,8 @@ function convertTableToElements(element) {
44021
44124
  ];
44022
44125
  }
44023
44126
  function convertFieldsToElement(element) {
44024
- const facts = element.children.map((field) => new import_teams6.Fact(convertEmoji(field.label), convertEmoji(field.value)));
44025
- return new import_teams6.FactSet(...facts);
44127
+ const facts = element.children.map((field) => new import_teams7.Fact(convertEmoji(field.label), convertEmoji(field.value)));
44128
+ return new import_teams7.FactSet(...facts);
44026
44129
  }
44027
44130
  function toAppOptions(config) {
44028
44131
  if (config.certificate) {
@@ -44052,7 +44155,7 @@ function handleTeamsError(error, operation) {
44052
44155
  const innerError = err.innerHttpError;
44053
44156
  const statusCode = innerError?.statusCode || err.statusCode || err.status || err.code;
44054
44157
  if (statusCode === 401) {
44055
- throw new AuthenticationError2("teams", `Authentication failed for ${operation}: ${err.message || "unauthorized"}`);
44158
+ throw new AuthenticationError3("teams", `Authentication failed for ${operation}: ${err.message || "unauthorized"}`);
44056
44159
  }
44057
44160
  if (statusCode === 403 || err.message && typeof err.message === "string" && err.message.toLowerCase().includes("permission")) {
44058
44161
  throw new PermissionError("teams", operation);
@@ -44097,8 +44200,9 @@ function encodeThreadId(platformData) {
44097
44200
  const encodedServiceUrl = Buffer.from(platformData.serviceUrl).toString("base64url");
44098
44201
  const conversationType = platformData.conversationType;
44099
44202
  const legacyIsDM = !platformData.conversationId.startsWith("19:");
44203
+ const legacyIsChannel = platformData.conversationId.split(";")[0]?.endsWith("@thread.tacv2");
44100
44204
  const explicitIsDM = conversationType === "personal";
44101
- const needsConversationType = conversationType !== undefined && explicitIsDM !== legacyIsDM;
44205
+ const needsConversationType = conversationType !== undefined && (explicitIsDM !== legacyIsDM || !explicitIsDM && conversationType === "channel" !== legacyIsChannel);
44102
44206
  return needsConversationType ? `teams:${encodedConversationId}:${encodedServiceUrl}:${conversationType}` : `teams:${encodedConversationId}:${encodedServiceUrl}`;
44103
44207
  }
44104
44208
  function decodeThreadId(threadId) {
@@ -44132,6 +44236,127 @@ function parseInstallationAction(value) {
44132
44236
  function isInstallAction(action) {
44133
44237
  return action === "add" || action === "add-upgrade";
44134
44238
  }
44239
+ function forwardFinder(value, char) {
44240
+ let lastFrom = Number.POSITIVE_INFINITY;
44241
+ let lastIndex = -1;
44242
+ return (from) => {
44243
+ if (from < lastFrom || lastIndex !== -1 && from > lastIndex) {
44244
+ lastFrom = from;
44245
+ lastIndex = value.indexOf(char, from);
44246
+ }
44247
+ return lastIndex;
44248
+ };
44249
+ }
44250
+ function closedHrefs(html) {
44251
+ const nextQuote = forwardFinder(html, '"');
44252
+ const nextTagEnd = forwardFinder(html, ">");
44253
+ const nextTagStart = forwardFinder(html, "<");
44254
+ const hrefs = [];
44255
+ for (const match of html.matchAll(HREF_PATTERN)) {
44256
+ const valueStart = match.index + HREF_PREFIX_LENGTH;
44257
+ const quote = nextQuote(valueStart);
44258
+ if (quote <= valueStart) {
44259
+ continue;
44260
+ }
44261
+ const tagEnd = nextTagEnd(quote + 1);
44262
+ if (tagEnd === -1) {
44263
+ continue;
44264
+ }
44265
+ const textEnd = nextTagStart(tagEnd + 1);
44266
+ if (textEnd <= tagEnd + 1) {
44267
+ continue;
44268
+ }
44269
+ LINK_END_PATTERN.lastIndex = textEnd;
44270
+ if (LINK_END_PATTERN.test(html)) {
44271
+ hrefs.push({ start: match.index, quote, tagEnd, textEnd });
44272
+ }
44273
+ }
44274
+ return hrefs;
44275
+ }
44276
+ function replaceLinks(html) {
44277
+ const hrefs = closedHrefs(html);
44278
+ if (hrefs.length === 0) {
44279
+ return html;
44280
+ }
44281
+ const nextTagEnd = forwardFinder(html, ">");
44282
+ let result = "";
44283
+ let copied = 0;
44284
+ let candidates = 0;
44285
+ for (const match of html.matchAll(LINK_START_PATTERN)) {
44286
+ const start = match.index;
44287
+ if (start < copied) {
44288
+ continue;
44289
+ }
44290
+ const tagEnd = nextTagEnd(start + 2);
44291
+ if (tagEnd === -1) {
44292
+ break;
44293
+ }
44294
+ while (candidates < hrefs.length && hrefs[candidates].start + HREF_PREFIX_LENGTH <= tagEnd) {
44295
+ candidates++;
44296
+ }
44297
+ const href = hrefs[candidates - 1];
44298
+ if (!href || href.start < start + 3) {
44299
+ continue;
44300
+ }
44301
+ const text = html.slice(href.tagEnd + 1, href.textEnd);
44302
+ const url = html.slice(href.start + HREF_PREFIX_LENGTH, href.quote);
44303
+ result += `${html.slice(copied, start)}[${text}](${url})`;
44304
+ copied = href.textEnd + LINK_END_LENGTH;
44305
+ }
44306
+ return result + html.slice(copied);
44307
+ }
44308
+ function replaceTags(html, replace) {
44309
+ let result = "";
44310
+ let copied = 0;
44311
+ let start = html.indexOf("<");
44312
+ while (start !== -1) {
44313
+ if (html[start + 1] === ">") {
44314
+ start = html.indexOf("<", start + 2);
44315
+ continue;
44316
+ }
44317
+ const end = html.indexOf(">", start + 2);
44318
+ if (end === -1) {
44319
+ break;
44320
+ }
44321
+ result += html.slice(copied, start) + replace(html.slice(start, end + 1));
44322
+ copied = end + 1;
44323
+ start = html.indexOf("<", copied);
44324
+ }
44325
+ return result + html.slice(copied);
44326
+ }
44327
+ function trimNewlines(value) {
44328
+ let start = 0;
44329
+ let end = value.length;
44330
+ while (start < end && value[start] === `
44331
+ `) {
44332
+ start++;
44333
+ }
44334
+ while (end > start && value[end - 1] === `
44335
+ `) {
44336
+ end--;
44337
+ }
44338
+ return value.slice(start, end);
44339
+ }
44340
+ function teamsHtmlToMarkdown(teamsText) {
44341
+ let markdown = teamsText.replace(MENTION_PATTERN, "@$1");
44342
+ markdown = markdown.replace(BOLD_PATTERN, "**$2**");
44343
+ markdown = markdown.replace(ITALIC_PATTERN, "_$2_");
44344
+ markdown = markdown.replace(STRIKE_PATTERN, "~~$2~~");
44345
+ markdown = replaceLinks(markdown);
44346
+ markdown = markdown.replace(CODE_PATTERN, "`$1`");
44347
+ markdown = markdown.replace(PRE_PATTERN, "```\n$1\n```");
44348
+ markdown = replaceTags(markdown, () => "");
44349
+ return markdown.replace(ENTITY_PATTERN, (match) => ENTITIES[match] ?? match);
44350
+ }
44351
+ function teamsHtmlToPlainText(teamsText) {
44352
+ const withMentions = teamsText.replace(MENTION_PATTERN, "@$1");
44353
+ const stripped = replaceTags(withMentions, (tag) => BLOCK_TAG_PATTERN.test(tag) ? `
44354
+ ` : "");
44355
+ const decoded = stripped.replace(PLAIN_TEXT_ENTITY_PATTERN, (match) => ENTITIES[match] ?? match);
44356
+ return trimNewlines(decoded.replace(EXTRA_NEWLINES_PATTERN, `
44357
+
44358
+ `));
44359
+ }
44135
44360
  function modalToAdaptiveCard(modal, contextId, callbackId) {
44136
44361
  const body = [];
44137
44362
  for (const child of modal.children) {
@@ -44149,8 +44374,8 @@ function modalToAdaptiveCard(modal, contextId, callbackId) {
44149
44374
  if (style) {
44150
44375
  submitOptions.style = style;
44151
44376
  }
44152
- const submitAction = new import_teams8.SubmitAction(submitOptions);
44153
- return new import_teams8.AdaptiveCard(...body).withOptions({
44377
+ const submitAction = new import_teams9.SubmitAction(submitOptions);
44378
+ return new import_teams9.AdaptiveCard(...body).withOptions({
44154
44379
  $schema: ADAPTIVE_CARD_SCHEMA2,
44155
44380
  version: ADAPTIVE_CARD_VERSION2
44156
44381
  }).withActions(submitAction);
@@ -44177,18 +44402,6 @@ function modalChildToAdaptiveElements(child) {
44177
44402
  return [];
44178
44403
  }
44179
44404
  }
44180
- function textInputToAdaptive(input) {
44181
- const options = {
44182
- id: input.id,
44183
- label: convertEmoji2(input.label),
44184
- isMultiline: input.multiline ?? false,
44185
- isRequired: !(input.optional ?? false),
44186
- placeholder: input.placeholder,
44187
- value: input.initialValue,
44188
- maxLength: input.maxLength
44189
- };
44190
- return new import_teams8.TextInput(options);
44191
- }
44192
44405
  function dateInputToAdaptive(input) {
44193
44406
  const options = {
44194
44407
  id: input.id,
@@ -44197,7 +44410,7 @@ function dateInputToAdaptive(input) {
44197
44410
  placeholder: input.placeholder,
44198
44411
  value: input.initialValue
44199
44412
  };
44200
- return new import_teams8.DateInput(options);
44413
+ return new import_teams9.DateInput(options);
44201
44414
  }
44202
44415
  function numberInputToAdaptive(input) {
44203
44416
  const options = {
@@ -44209,10 +44422,10 @@ function numberInputToAdaptive(input) {
44209
44422
  min: input.min,
44210
44423
  max: input.max
44211
44424
  };
44212
- return new import_teams8.NumberInput(options);
44425
+ return new import_teams9.NumberInput(options);
44213
44426
  }
44214
44427
  function selectToAdaptive(select) {
44215
- const choices = select.options.map((opt) => new import_teams8.Choice({ title: convertEmoji2(opt.label), value: opt.value }));
44428
+ const choices = select.options.map((opt) => new import_teams9.Choice({ title: convertEmoji2(opt.label), value: opt.value }));
44216
44429
  const options = {
44217
44430
  id: select.id,
44218
44431
  label: convertEmoji2(select.label),
@@ -44221,10 +44434,10 @@ function selectToAdaptive(select) {
44221
44434
  placeholder: select.placeholder,
44222
44435
  value: select.initialOption
44223
44436
  };
44224
- return new import_teams8.ChoiceSetInput(...choices).withOptions(options);
44437
+ return new import_teams9.ChoiceSetInput(...choices).withOptions(options);
44225
44438
  }
44226
44439
  function radioSelectToAdaptive(radioSelect) {
44227
- const choices = radioSelect.options.map((opt) => new import_teams8.Choice({ title: convertEmoji2(opt.label), value: opt.value }));
44440
+ const choices = radioSelect.options.map((opt) => new import_teams9.Choice({ title: convertEmoji2(opt.label), value: opt.value }));
44228
44441
  const options = {
44229
44442
  id: radioSelect.id,
44230
44443
  label: convertEmoji2(radioSelect.label),
@@ -44232,7 +44445,7 @@ function radioSelectToAdaptive(radioSelect) {
44232
44445
  isRequired: !(radioSelect.optional ?? false),
44233
44446
  value: radioSelect.initialOption
44234
44447
  };
44235
- return new import_teams8.ChoiceSetInput(...choices).withOptions(options);
44448
+ return new import_teams9.ChoiceSetInput(...choices).withOptions(options);
44236
44449
  }
44237
44450
  function textToAdaptive(text) {
44238
44451
  const options = {
@@ -44243,11 +44456,11 @@ function textToAdaptive(text) {
44243
44456
  } else if (text.style === "muted") {
44244
44457
  options.isSubtle = true;
44245
44458
  }
44246
- return new import_teams8.TextBlock(convertEmoji2(text.content), options);
44459
+ return new import_teams9.TextBlock(convertEmoji2(text.content), options);
44247
44460
  }
44248
44461
  function fieldsToAdaptive(fields) {
44249
- const facts = fields.children.map((field) => new import_teams8.Fact(convertEmoji2(field.label), convertEmoji2(field.value)));
44250
- return new import_teams8.FactSet(...facts);
44462
+ const facts = fields.children.map((field) => new import_teams9.Fact(convertEmoji2(field.label), convertEmoji2(field.value)));
44463
+ return new import_teams9.FactSet(...facts);
44251
44464
  }
44252
44465
  function parseDialogSubmitValues(data) {
44253
44466
  if (!data) {
@@ -44296,11 +44509,11 @@ function modalResponseToTaskModuleResponse(response, logger, contextId) {
44296
44509
  logger?.warn("Teams does not support dialog stacking (push). Falling back to update.", { callbackId: response.modal.callbackId });
44297
44510
  return buildContinueResponse(response.modal, contextId);
44298
44511
  case "errors": {
44299
- const errorBlocks = Object.entries(response.errors).map(([field, msg]) => new import_teams8.TextBlock(`**${field}**: ${msg}`, {
44512
+ const errorBlocks = Object.entries(response.errors).map(([field, msg]) => new import_teams9.TextBlock(`**${field}**: ${msg}`, {
44300
44513
  wrap: true,
44301
44514
  color: "Attention"
44302
44515
  }));
44303
- const errorCard = new import_teams8.AdaptiveCard(new import_teams8.TextBlock("Please fix the following errors:", {
44516
+ const errorCard = new import_teams9.AdaptiveCard(new import_teams9.TextBlock("Please fix the following errors:", {
44304
44517
  weight: "Bolder",
44305
44518
  wrap: true
44306
44519
  }), ...errorBlocks).withOptions({
@@ -44331,7 +44544,7 @@ function resolveTeamsReactionType(emoji) {
44331
44544
  function createTeamsAdapter(config) {
44332
44545
  return new TeamsAdapter(config ?? {});
44333
44546
  }
44334
- var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, import_teams8, TeamsApp, FILE_DOWNLOAD_INFO_CONTENT_TYPE = "application/vnd.microsoft.teams.file.download.info", FILE_TYPE_PREFIX_PATTERN, LOOPBACK_HOST_PATTERN, FILE_MIME_TYPES, BridgeHttpAdapter = class {
44547
+ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, import_teams7, import_teams9, TeamsApp, FILE_DOWNLOAD_INFO_CONTENT_TYPE = "application/vnd.microsoft.teams.file.download.info", GRAPH_FILE_REFERENCE_CONTENT_TYPE = "reference", FILE_TYPE_PREFIX_PATTERN, LOOPBACK_HOST_PATTERN, FILE_MIME_TYPES, BridgeHttpAdapter = class {
44335
44548
  handler = null;
44336
44549
  webhookOptionsMap = /* @__PURE__ */ new Map;
44337
44550
  logger;
@@ -44403,7 +44616,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44403
44616
  }
44404
44617
  return this.webhookOptionsMap.get(activityId);
44405
44618
  }
44406
- }, convertEmoji, ADAPTIVE_CARD_SCHEMA = "http://adaptivecards.io/schemas/adaptive-card.json", ADAPTIVE_CARD_VERSION = "1.5", AUTO_SUBMIT_ACTION_ID = "__auto_submit", TABLE_HORIZONTAL_ALIGNMENT, TABLE_VERTICAL_ALIGNMENT, MESSAGEID_STRIP_PATTERN, SEMICOLON_MESSAGEID_CAPTURE_PATTERN, TeamsGraphReader = class {
44619
+ }, convertEmoji, ADAPTIVE_CARD_SCHEMA = "http://adaptivecards.io/schemas/adaptive-card.json", ADAPTIVE_CARD_VERSION = "1.5", AUTO_SUBMIT_ACTION_ID = "__auto_submit", BUTTON_SUBMIT_KEYS, AUTO_SUBMIT_KEYS, TABLE_HORIZONTAL_ALIGNMENT, TABLE_VERTICAL_ALIGNMENT, MESSAGEID_STRIP_PATTERN, SEMICOLON_MESSAGEID_CAPTURE_PATTERN, TRUSTED_GRAPH_HOSTS, TeamsGraphReader = class {
44407
44620
  deps;
44408
44621
  constructor(deps) {
44409
44622
  this.deps = deps;
@@ -44520,65 +44733,29 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44520
44733
  let graphMessages;
44521
44734
  let hasMoreMessages = false;
44522
44735
  if (graphContext && graphContext.type !== "dm") {
44523
- const channelParams = {
44524
- "team-id": graphContext.teamId,
44525
- "channel-id": graphContext.channelId
44526
- };
44527
- if (direction === "forward") {
44528
- const allMessages = [];
44529
- const firstPage = await this.deps.graph.call(exports_channels.messages.list, {
44530
- ...channelParams,
44531
- $top: 50
44532
- });
44533
- allMessages.push(...firstPage.value || []);
44534
- let nextLink = firstPage["@odata.nextLink"] ?? undefined;
44535
- while (nextLink) {
44536
- const page = await this.graphGetNextLink(nextLink);
44537
- allMessages.push(...page.value || []);
44538
- nextLink = page["@odata.nextLink"] ?? undefined;
44539
- }
44540
- allMessages.reverse();
44541
- let startIndex = 0;
44542
- if (options.cursor) {
44543
- const cursorVal = options.cursor;
44544
- startIndex = allMessages.findIndex((msg) => msg.createdDateTime && msg.createdDateTime > cursorVal);
44545
- if (startIndex === -1) {
44546
- startIndex = allMessages.length;
44547
- }
44548
- }
44549
- hasMoreMessages = startIndex + limit < allMessages.length;
44550
- graphMessages = allMessages.slice(startIndex, startIndex + limit);
44551
- } else {
44552
- const response = await this.deps.graph.call(exports_channels.messages.list, {
44553
- ...channelParams,
44554
- $top: limit
44555
- });
44556
- graphMessages = response.value || [];
44557
- graphMessages.reverse();
44558
- hasMoreMessages = graphMessages.length >= limit;
44559
- }
44736
+ const allMessages = await this.fetchAllChannelRoots(graphContext);
44737
+ return this.pageChannelMessages(allMessages, channelId, options);
44738
+ }
44739
+ const chatId = this.chatIdFromContext(graphContext, baseConversationId);
44740
+ if (direction === "forward") {
44741
+ const response = await this.deps.graph.call(exports_messages.list, {
44742
+ "chat-id": chatId,
44743
+ $top: limit,
44744
+ $orderby: ["createdDateTime asc"],
44745
+ $filter: options.cursor ? `createdDateTime gt ${options.cursor}` : undefined
44746
+ });
44747
+ graphMessages = response.value || [];
44748
+ hasMoreMessages = graphMessages.length >= limit;
44560
44749
  } else {
44561
- const chatId = this.chatIdFromContext(graphContext, baseConversationId);
44562
- if (direction === "forward") {
44563
- const response = await this.deps.graph.call(exports_messages.list, {
44564
- "chat-id": chatId,
44565
- $top: limit,
44566
- $orderby: ["createdDateTime asc"],
44567
- $filter: options.cursor ? `createdDateTime gt ${options.cursor}` : undefined
44568
- });
44569
- graphMessages = response.value || [];
44570
- hasMoreMessages = graphMessages.length >= limit;
44571
- } else {
44572
- const response = await this.deps.graph.call(exports_messages.list, {
44573
- "chat-id": chatId,
44574
- $top: limit,
44575
- $orderby: ["createdDateTime desc"],
44576
- $filter: options.cursor ? `createdDateTime lt ${options.cursor}` : undefined
44577
- });
44578
- graphMessages = response.value || [];
44579
- graphMessages.reverse();
44580
- hasMoreMessages = graphMessages.length >= limit;
44581
- }
44750
+ const response = await this.deps.graph.call(exports_messages.list, {
44751
+ "chat-id": chatId,
44752
+ $top: limit,
44753
+ $orderby: ["createdDateTime desc"],
44754
+ $filter: options.cursor ? `createdDateTime lt ${options.cursor}` : undefined
44755
+ });
44756
+ graphMessages = response.value || [];
44757
+ graphMessages.reverse();
44758
+ hasMoreMessages = graphMessages.length >= limit;
44582
44759
  }
44583
44760
  const messages = this.mapGraphMessages(graphMessages, channelId);
44584
44761
  let nextCursor;
@@ -44662,12 +44839,17 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44662
44839
  limit
44663
44840
  });
44664
44841
  const threads = [];
44842
+ let nextCursor;
44665
44843
  if (graphContext && graphContext.type !== "dm") {
44666
- const response = await this.deps.graph.call(exports_channels.messages.list, {
44844
+ let response = options.cursor ? await this.fetchChannelRootContinuation(options.cursor, graphContext) : await this.deps.graph.call(exports_channels.messages.list, {
44667
44845
  "team-id": graphContext.teamId,
44668
44846
  "channel-id": graphContext.channelId,
44669
- $top: limit
44847
+ $top: Math.min(limit, 50)
44670
44848
  });
44849
+ while (!(response.value ?? []).some((msg) => !!msg.id) && response["@odata.nextLink"]) {
44850
+ response = await this.graphGetNextLink(response["@odata.nextLink"]);
44851
+ }
44852
+ nextCursor = response["@odata.nextLink"] ?? undefined;
44671
44853
  const messages = response.value || [];
44672
44854
  for (const msg of messages) {
44673
44855
  if (!msg.id) {
@@ -44685,7 +44867,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44685
44867
  id: msg.id,
44686
44868
  threadId,
44687
44869
  text: this.extractTextFromGraphMessage(msg),
44688
- formatted: this.deps.formatConverter.toAst(this.extractTextFromGraphMessage(msg)),
44870
+ formatted: this.deps.formatConverter.parseIncoming(this.extractTextFromGraphMessage(msg)).formatted,
44689
44871
  raw: msg,
44690
44872
  author: {
44691
44873
  userId: msg.from?.user?.id || msg.from?.application?.id || "unknown",
@@ -44696,7 +44878,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44696
44878
  },
44697
44879
  metadata: {
44698
44880
  dateSent: msg.createdDateTime ? new Date(msg.createdDateTime) : /* @__PURE__ */ new Date,
44699
- edited: !!msg.lastModifiedDateTime
44881
+ edited: !!msg.lastEditedDateTime
44700
44882
  },
44701
44883
  attachments: this.extractAttachmentsFromGraphMessage(msg)
44702
44884
  }),
@@ -44728,7 +44910,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44728
44910
  id: msg.id,
44729
44911
  threadId,
44730
44912
  text: this.extractTextFromGraphMessage(msg),
44731
- formatted: this.deps.formatConverter.toAst(this.extractTextFromGraphMessage(msg)),
44913
+ formatted: this.deps.formatConverter.parseIncoming(this.extractTextFromGraphMessage(msg)).formatted,
44732
44914
  raw: msg,
44733
44915
  author: {
44734
44916
  userId: msg.from?.user?.id || msg.from?.application?.id || "unknown",
@@ -44739,7 +44921,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44739
44921
  },
44740
44922
  metadata: {
44741
44923
  dateSent: msg.createdDateTime ? new Date(msg.createdDateTime) : /* @__PURE__ */ new Date,
44742
- edited: !!msg.lastModifiedDateTime
44924
+ edited: !!msg.lastEditedDateTime
44743
44925
  },
44744
44926
  attachments: this.extractAttachmentsFromGraphMessage(msg)
44745
44927
  })
@@ -44749,7 +44931,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44749
44931
  this.deps.logger.debug("Teams Graph API: listThreads result", {
44750
44932
  threadCount: threads.length
44751
44933
  });
44752
- return { threads };
44934
+ return { threads, nextCursor };
44753
44935
  } catch (error) {
44754
44936
  this.deps.logger.error("Teams Graph API: listThreads error", { error });
44755
44937
  throw error;
@@ -44772,70 +44954,95 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44772
44954
  "channel-id": context.channelId,
44773
44955
  "chatMessage-id": threadMessageId
44774
44956
  };
44775
- let parentMessage = null;
44776
- try {
44777
- parentMessage = await this.deps.graph.call(exports_channels.messages.get, channelMsgParams);
44778
- } catch (err) {
44779
- this.deps.logger.warn("Failed to fetch parent message", {
44780
- threadMessageId,
44781
- err
44782
- });
44957
+ const [parentMessage, allReplies] = await Promise.all([
44958
+ this.deps.graph.call(exports_channels.messages.get, channelMsgParams).catch((err) => {
44959
+ this.deps.logger.warn("Failed to fetch parent message", {
44960
+ threadMessageId,
44961
+ err
44962
+ });
44963
+ return null;
44964
+ }),
44965
+ this.fetchAllChannelReplies(channelMsgParams)
44966
+ ]);
44967
+ const allMessages = parentMessage ? [parentMessage, ...allReplies] : allReplies;
44968
+ return this.pageChannelMessages(allMessages, threadId, options);
44969
+ }
44970
+ channelMessagePosition(msg) {
44971
+ return {
44972
+ timestamp: Date.parse(msg.createdDateTime ?? "") || 0,
44973
+ id: msg.id ?? ""
44974
+ };
44975
+ }
44976
+ compareChannelMessagePositions(left, right) {
44977
+ const timestampDifference = left.timestamp - right.timestamp;
44978
+ if (timestampDifference || right.id === undefined) {
44979
+ return timestampDifference;
44783
44980
  }
44784
- let graphMessages;
44785
- let hasMoreMessages = false;
44786
- if (direction === "forward") {
44787
- const allReplies = await this.fetchAllChannelReplies(channelMsgParams);
44788
- allReplies.reverse();
44789
- const allMessages = parentMessage ? [parentMessage, ...allReplies] : allReplies;
44790
- let startIndex = 0;
44791
- if (cursor) {
44792
- startIndex = allMessages.findIndex((msg) => msg.createdDateTime && msg.createdDateTime > cursor);
44793
- if (startIndex === -1) {
44794
- startIndex = allMessages.length;
44795
- }
44796
- }
44797
- hasMoreMessages = startIndex + limit < allMessages.length;
44798
- graphMessages = allMessages.slice(startIndex, startIndex + limit);
44799
- } else {
44800
- const allReplies = await this.fetchAllChannelReplies(channelMsgParams);
44801
- allReplies.reverse();
44802
- const allMessages = parentMessage ? [parentMessage, ...allReplies] : allReplies;
44803
- if (cursor) {
44804
- const cursorIndex = allMessages.findIndex((msg) => msg.createdDateTime && msg.createdDateTime >= cursor);
44805
- if (cursorIndex > 0) {
44806
- const sliceStart = Math.max(0, cursorIndex - limit);
44807
- graphMessages = allMessages.slice(sliceStart, cursorIndex);
44808
- hasMoreMessages = sliceStart > 0;
44809
- } else {
44810
- graphMessages = allMessages.slice(-limit);
44811
- hasMoreMessages = allMessages.length > limit;
44812
- }
44813
- } else {
44814
- graphMessages = allMessages.slice(-limit);
44815
- hasMoreMessages = allMessages.length > limit;
44981
+ if (left.id === right.id) {
44982
+ return 0;
44983
+ }
44984
+ return left.id < right.id ? -1 : 1;
44985
+ }
44986
+ parseChannelHistoryCursor(cursor) {
44987
+ if (!cursor.startsWith("teams-channel-history:")) {
44988
+ const timestamp = Date.parse(cursor);
44989
+ if (Number.isFinite(timestamp)) {
44990
+ return { timestamp };
44816
44991
  }
44992
+ throw new ValidationError("teams", "Invalid channel history cursor");
44817
44993
  }
44818
- this.deps.logger.debug("Teams Graph API: fetched channel thread messages", {
44819
- count: graphMessages.length,
44820
- direction,
44821
- hasMoreMessages
44822
- });
44823
- const messages = this.mapGraphMessages(graphMessages, threadId);
44824
- let nextCursor;
44825
- if (hasMoreMessages && graphMessages.length > 0) {
44826
- if (direction === "forward") {
44827
- const lastMsg = graphMessages.at(-1);
44828
- if (lastMsg?.createdDateTime) {
44829
- nextCursor = lastMsg.createdDateTime;
44830
- }
44831
- } else {
44832
- const oldestMsg = graphMessages[0];
44833
- if (oldestMsg?.createdDateTime) {
44834
- nextCursor = oldestMsg.createdDateTime;
44835
- }
44994
+ try {
44995
+ const value = JSON.parse(Buffer.from(cursor.slice("teams-channel-history:".length), "base64url").toString("utf8"));
44996
+ if (typeof value === "object" && value !== null && "timestamp" in value && typeof value.timestamp === "number" && Number.isFinite(value.timestamp) && "id" in value && typeof value.id === "string" && value.id.length > 0) {
44997
+ return { timestamp: value.timestamp, id: value.id };
44836
44998
  }
44999
+ } catch {}
45000
+ throw new ValidationError("teams", "Invalid channel history cursor");
45001
+ }
45002
+ pageChannelMessages(graphMessages, channelId, options) {
45003
+ const direction = options.direction ?? "backward";
45004
+ const limit = options.limit || 50;
45005
+ const boundary = options.cursor ? this.parseChannelHistoryCursor(options.cursor) : undefined;
45006
+ const sorted = graphMessages.filter((msg) => !!msg.id).map((msg) => ({ msg, position: this.channelMessagePosition(msg) })).sort((left, right) => this.compareChannelMessagePositions(left.position, right.position));
45007
+ const remaining = boundary ? sorted.filter(({ position }) => {
45008
+ const comparison = this.compareChannelMessagePositions(position, boundary);
45009
+ return direction === "forward" ? comparison > 0 : comparison < 0;
45010
+ }) : sorted;
45011
+ const page = direction === "forward" ? remaining.slice(0, limit) : remaining.slice(-limit);
45012
+ const edge = direction === "forward" ? page.at(-1) : page[0];
45013
+ const nextCursor = remaining.length > limit && edge ? `teams-channel-history:${Buffer.from(JSON.stringify(edge.position)).toString("base64url")}` : undefined;
45014
+ return {
45015
+ messages: this.mapGraphMessages(page.map(({ msg }) => msg), channelId),
45016
+ nextCursor
45017
+ };
45018
+ }
45019
+ async fetchAllChannelRoots(context) {
45020
+ let page = await this.deps.graph.call(exports_channels.messages.list, {
45021
+ "team-id": context.teamId,
45022
+ "channel-id": context.channelId,
45023
+ $top: 50
45024
+ });
45025
+ const messages = [...page.value ?? []];
45026
+ while (page["@odata.nextLink"]) {
45027
+ page = await this.graphGetNextLink(page["@odata.nextLink"]);
45028
+ messages.push(...page.value ?? []);
44837
45029
  }
44838
- return { messages, nextCursor };
45030
+ return messages;
45031
+ }
45032
+ async fetchChannelRootContinuation(cursor, context) {
45033
+ let url;
45034
+ let pathname;
45035
+ try {
45036
+ url = new URL(cursor);
45037
+ pathname = decodeURIComponent(url.pathname);
45038
+ } catch {
45039
+ throw new ValidationError("teams", "Invalid channel thread continuation cursor");
45040
+ }
45041
+ const expectedPath = `/v1.0/teams/${context.teamId}/channels/${context.channelId}/messages`;
45042
+ if (url.protocol !== "https:" || !TRUSTED_GRAPH_HOSTS.has(url.hostname.toLowerCase()) || url.username || url.password || url.port || pathname.toLowerCase() !== expectedPath.toLowerCase()) {
45043
+ throw new ValidationError("teams", "Invalid channel thread continuation cursor");
45044
+ }
45045
+ return this.graphGetNextLink(cursor);
44839
45046
  }
44840
45047
  async fetchAllChannelReplies(params) {
44841
45048
  const allReplies = [];
@@ -44853,6 +45060,17 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44853
45060
  const res = await this.deps.graph.http.get(nextLinkUrl);
44854
45061
  return res.data;
44855
45062
  }
45063
+ async resolveFileDownloadUrl(fileUrl) {
45064
+ const shareId = `u!${Buffer.from(fileUrl).toString("base64url")}`;
45065
+ const item = await this.deps.graph.call(exports_driveItem.get, {
45066
+ "sharedDriveItem-id": shareId
45067
+ });
45068
+ const downloadUrl = item["@microsoft.graph.downloadUrl"];
45069
+ if (typeof downloadUrl !== "string" || !downloadUrl) {
45070
+ throw new Error("Microsoft Graph did not return a download URL for the shared file");
45071
+ }
45072
+ return downloadUrl;
45073
+ }
44856
45074
  extractTextFromGraphMessage(msg) {
44857
45075
  if (msg.body?.contentType === "text") {
44858
45076
  return msg.body.content || "";
@@ -44922,12 +45140,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44922
45140
  if (!msg.attachments?.length) {
44923
45141
  return [];
44924
45142
  }
44925
- return msg.attachments.map((att) => ({
44926
- type: att.contentType?.includes("image") ? "image" : "file",
44927
- name: att.name ?? undefined,
44928
- url: att.contentUrl ?? undefined,
44929
- mimeType: att.contentType ?? undefined
44930
- }));
45143
+ return msg.attachments.map((att) => createTeamsGraphAttachment(att, this.deps.attachmentFetchers));
44931
45144
  }
44932
45145
  mapGraphMessages(graphMessages, threadId) {
44933
45146
  return graphMessages.filter((msg) => msg.id).map((msg) => {
@@ -44936,7 +45149,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44936
45149
  id: msg.id,
44937
45150
  threadId,
44938
45151
  text: this.extractTextFromGraphMessage(msg),
44939
- formatted: this.deps.formatConverter.toAst(this.extractTextFromGraphMessage(msg)),
45152
+ formatted: this.deps.formatConverter.parseIncoming(this.extractTextFromGraphMessage(msg)).formatted,
44940
45153
  raw: msg,
44941
45154
  author: {
44942
45155
  userId: msg.from?.user?.id || msg.from?.application?.id || "unknown",
@@ -44947,13 +45160,13 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
44947
45160
  },
44948
45161
  metadata: {
44949
45162
  dateSent: msg.createdDateTime ? new Date(msg.createdDateTime) : /* @__PURE__ */ new Date,
44950
- edited: !!msg.lastModifiedDateTime
45163
+ edited: !!msg.lastEditedDateTime
44951
45164
  },
44952
45165
  attachments: this.extractAttachmentsFromGraphMessage(msg)
44953
45166
  });
44954
45167
  });
44955
45168
  }
44956
- }, INSTALLATION_ACTIONS, TeamsFormatConverter, convertEmoji2, ADAPTIVE_CARD_SCHEMA2 = "http://adaptivecards.io/schemas/adaptive-card.json", ADAPTIVE_CARD_VERSION2 = "1.5", MESSAGEID_CAPTURE_PATTERN, MESSAGEID_STRIP_PATTERN2, CACHE_TTL_MS, USER_INFO_CACHE_TTL_MS, USER_INFO_NEGATIVE_CACHE_TTL_MS, TARGETED_ACTIVITY_TTL_MS, USER_INFO_NEGATIVE_SENTINEL = "unresolvable", DEFAULT_DIALOG_OPEN_TIMEOUT_MS = 5000, TEAMS_REACTION_ALIASES, TeamsAdapter = class {
45169
+ }, INSTALLATION_ACTIONS, MENTION_PATTERN, BOLD_PATTERN, ITALIC_PATTERN, STRIKE_PATTERN, CODE_PATTERN, PRE_PATTERN, LINK_START_PATTERN, HREF_PATTERN, LINK_END_PATTERN, ENTITY_PATTERN, PLAIN_TEXT_ENTITY_PATTERN, BLOCK_TAG_PATTERN, EXTRA_NEWLINES_PATTERN, HREF_PREFIX_LENGTH, LINK_END_LENGTH, ENTITIES, TeamsFormatConverter, convertEmoji2, ADAPTIVE_CARD_SCHEMA2 = "http://adaptivecards.io/schemas/adaptive-card.json", ADAPTIVE_CARD_VERSION2 = "1.5", CARD_ACTION_INVOKE_ACK, MESSAGEID_CAPTURE_PATTERN, MESSAGEID_STRIP_PATTERN2, BOT_USER_ID_PREFIX = "28:", CACHE_TTL_MS, USER_INFO_CACHE_TTL_MS, USER_INFO_NEGATIVE_CACHE_TTL_MS, TARGETED_ACTIVITY_TTL_MS, USER_INFO_NEGATIVE_SENTINEL = "unresolvable", DEFAULT_DIALOG_OPEN_TIMEOUT_MS = 5000, TEAMS_REACTION_ALIASES, TeamsAdapter = class {
44957
45170
  name = "teams";
44958
45171
  userName;
44959
45172
  appInstance;
@@ -45000,6 +45213,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45000
45213
  skipAuth: Boolean(this.config.webhookVerifier)
45001
45214
  });
45002
45215
  const graphReader = new TeamsGraphReader({
45216
+ attachmentFetchers: this.attachmentFetchers,
45003
45217
  botId: app.id ?? "",
45004
45218
  graph: app.graph,
45005
45219
  logger: this.logger,
@@ -45021,11 +45235,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45021
45235
  this.app.on("card.action", async (ctx) => {
45022
45236
  this.cacheUserContext(ctx.activity);
45023
45237
  await this.handleAdaptiveCardAction(ctx);
45024
- return {
45025
- statusCode: 200,
45026
- type: "application/vnd.microsoft.activity.message",
45027
- value: ""
45028
- };
45238
+ return CARD_ACTION_INVOKE_ACK;
45029
45239
  });
45030
45240
  this.app.on("dialog.open", async (ctx) => {
45031
45241
  this.cacheUserContext(ctx.activity);
@@ -45216,15 +45426,18 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45216
45426
  }
45217
45427
  const threadId = this.threadIdFromActivity(activity);
45218
45428
  const message = this.parseTeamsMessage(activity, threadId);
45219
- const user = activity.from?.aadObjectId ? await this.getIncomingUser(ctx, message.author.userId, activity.from.aadObjectId) : await this.getUser(message.author.userId);
45429
+ let user = null;
45430
+ if (activity.from?.aadObjectId) {
45431
+ user = await this.getIncomingUser(ctx, message.author.userId, activity.from.aadObjectId);
45432
+ } else if (!message.author.isBot) {
45433
+ user = await this.getUser(message.author.userId);
45434
+ }
45220
45435
  if (user?.email) {
45221
45436
  message.author.email = user.email;
45222
45437
  }
45223
45438
  const entities = activity.entities || [];
45224
- const isMention = entities.some((e) => e.type === "mention" && e.mentioned?.id && (e.mentioned.id === this.app.id || e.mentioned.id.endsWith(`:${this.app.id}`)));
45225
- if (isMention) {
45226
- message.isMention = true;
45227
- }
45439
+ const isMention = entities.some((e) => e.type === "mention" && !!e.mentioned?.id && this.isBotAccountId(e.mentioned.id));
45440
+ message.isMention = isMention;
45228
45441
  if (this.isDM(threadId)) {
45229
45442
  this.activeStreams.set(threadId, ctx.stream);
45230
45443
  let resolveProcessing;
@@ -45260,13 +45473,8 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45260
45473
  const actionEvent = {
45261
45474
  actionId: actionValue.actionId,
45262
45475
  value: actionValue.value,
45263
- user: {
45264
- userId: activity.from?.id || "unknown",
45265
- userName: activity.from?.name || "unknown",
45266
- fullName: activity.from?.name || "unknown",
45267
- isBot: false,
45268
- isMe: false
45269
- },
45476
+ values: cardInputValues(actionValue, BUTTON_SUBMIT_KEYS),
45477
+ user: this.authorFromActivity(activity),
45270
45478
  messageId: activity.replyToId || activity.id || "",
45271
45479
  threadId,
45272
45480
  adapter: this,
@@ -45294,20 +45502,14 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45294
45502
  }
45295
45503
  const threadId = this.threadIdFromActivity(activity);
45296
45504
  if (actionData.actionId === AUTO_SUBMIT_ACTION_ID) {
45297
- const rawPayload = activity.value.action.data;
45298
- this.fanOutAutoSubmit(rawPayload, activity, threadId);
45505
+ this.fanOutAutoSubmit(actionData, activity, threadId);
45299
45506
  return;
45300
45507
  }
45301
45508
  const actionEvent = {
45302
45509
  actionId: actionData.actionId,
45303
45510
  value: actionData.value,
45304
- user: {
45305
- userId: activity.from?.id || "unknown",
45306
- userName: activity.from?.name || "unknown",
45307
- fullName: activity.from?.name || "unknown",
45308
- isBot: false,
45309
- isMe: false
45310
- },
45511
+ values: cardInputValues(actionData, BUTTON_SUBMIT_KEYS),
45512
+ user: this.authorFromActivity(activity),
45311
45513
  messageId: activity.replyToId || activity.id || "",
45312
45514
  threadId,
45313
45515
  adapter: this,
@@ -45326,29 +45528,24 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45326
45528
  return;
45327
45529
  }
45328
45530
  const webhookOptions = this.bridgeAdapter.getWebhookOptions(activity.id);
45329
- const entries = Object.entries(payload).filter(([key]) => key !== "actionId" && key !== "msteams");
45531
+ const entries = Object.entries(payload).filter(([key]) => !AUTO_SUBMIT_KEYS.has(key));
45330
45532
  this.logger.debug("Auto-submit fan-out", {
45331
45533
  inputCount: entries.length,
45332
45534
  keys: entries.map(([k]) => k)
45333
45535
  });
45334
45536
  const baseEvent = {
45335
- user: {
45336
- userId: activity.from?.id || "unknown",
45337
- userName: activity.from?.name || "unknown",
45338
- fullName: activity.from?.name || "unknown",
45339
- isBot: false,
45340
- isMe: false
45341
- },
45537
+ user: this.authorFromActivity(activity),
45342
45538
  messageId: activity.replyToId || activity.id || "",
45343
45539
  threadId,
45344
45540
  adapter: this,
45345
- raw: activity
45541
+ raw: activity,
45542
+ values: cardInputValues(payload, AUTO_SUBMIT_KEYS)
45346
45543
  };
45347
45544
  for (const [key, val] of entries) {
45348
45545
  this.chat.processAction({
45349
45546
  ...baseEvent,
45350
45547
  actionId: key,
45351
- value: typeof val === "string" ? val : undefined
45548
+ value: submitValueToString(val)
45352
45549
  }, webhookOptions);
45353
45550
  }
45354
45551
  }
@@ -45366,13 +45563,8 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45366
45563
  const actionEvent = {
45367
45564
  actionId: actionData.actionId || "dialog.open",
45368
45565
  value: actionData.value,
45369
- user: {
45370
- userId: activity.from?.id || "unknown",
45371
- userName: activity.from?.name || "unknown",
45372
- fullName: activity.from?.name || "unknown",
45373
- isBot: false,
45374
- isMe: false
45375
- },
45566
+ values: cardInputValues(actionData, BUTTON_SUBMIT_KEYS),
45567
+ user: this.authorFromActivity(activity),
45376
45568
  messageId: activity.replyToId || activity.id || "",
45377
45569
  threadId,
45378
45570
  adapter: this,
@@ -45432,13 +45624,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45432
45624
  viewId: activity.id || "",
45433
45625
  values,
45434
45626
  privateMetadata: undefined,
45435
- user: {
45436
- userId: activity.from?.id || "unknown",
45437
- userName: activity.from?.name || "unknown",
45438
- fullName: activity.from?.name || "unknown",
45439
- isBot: false,
45440
- isMe: false
45441
- },
45627
+ user: this.authorFromActivity(activity),
45442
45628
  adapter: this,
45443
45629
  raw: activity
45444
45630
  };
@@ -45458,13 +45644,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45458
45644
  const messageIdMatch = conversationId.match(MESSAGEID_CAPTURE_PATTERN);
45459
45645
  const messageId = messageIdMatch?.[1] || activity.replyToId || "";
45460
45646
  const threadId = this.threadIdFromActivity(activity);
45461
- const user = {
45462
- userId: activity.from?.id || "unknown",
45463
- userName: activity.from?.name || "unknown",
45464
- fullName: activity.from?.name || "unknown",
45465
- isBot: false,
45466
- isMe: this.isMessageFromSelf(activity)
45467
- };
45647
+ const user = this.authorFromActivity(activity);
45468
45648
  const reactionsAdded = activity.reactionsAdded || [];
45469
45649
  for (const reaction of reactionsAdded) {
45470
45650
  const rawEmoji = reaction.type || "";
@@ -45509,20 +45689,12 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45509
45689
  parseTeamsMessage(activity, threadId) {
45510
45690
  const text = activity.text || "";
45511
45691
  const normalizedText = this.normalizeMentions(text);
45512
- const isMe = this.isMessageFromSelf(activity);
45513
45692
  return new Message3({
45514
45693
  id: activity.id || "",
45515
45694
  threadId,
45516
- text: this.formatConverter.extractPlainText(normalizedText),
45517
- formatted: this.formatConverter.toAst(normalizedText),
45695
+ ...this.formatConverter.parseIncoming(normalizedText),
45518
45696
  raw: activity,
45519
- author: {
45520
- userId: activity.from?.id || "unknown",
45521
- userName: activity.from?.name || "unknown",
45522
- fullName: activity.from?.name || "unknown",
45523
- isBot: false,
45524
- isMe
45525
- },
45697
+ author: this.authorFromActivity(activity),
45526
45698
  metadata: {
45527
45699
  dateSent: activity.timestamp ? new Date(activity.timestamp) : /* @__PURE__ */ new Date,
45528
45700
  edited: false
@@ -45531,14 +45703,25 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45531
45703
  });
45532
45704
  }
45533
45705
  createAttachment(att, serviceUrl) {
45534
- return createTeamsAttachment(att, serviceUrl, {
45535
- createAnonymousFetchData: (url) => this.createFetchDataFn(url),
45536
- fetchAuthenticated: (url) => this.fetchAuthenticatedAttachment(url)
45537
- });
45706
+ return createTeamsAttachment(att, serviceUrl, this.attachmentFetchers);
45538
45707
  }
45708
+ attachmentFetchers = {
45709
+ createAnonymousFetchData: (url) => this.createFetchDataFn(url),
45710
+ fetchAuthenticated: (url) => this.fetchAuthenticatedAttachment(url),
45711
+ fetchGraphFile: (url) => this.fetchGraphFile(url)
45712
+ };
45539
45713
  createFetchDataFn(url) {
45540
45714
  return createAnonymousAttachmentFetchData(url);
45541
45715
  }
45716
+ async fetchGraphFile(url) {
45717
+ let downloadUrl;
45718
+ try {
45719
+ downloadUrl = await this.graphReader.resolveFileDownloadUrl(url);
45720
+ } catch (error) {
45721
+ handleTeamsError(error, "fetchGraphFile");
45722
+ }
45723
+ return this.createFetchDataFn(downloadUrl)();
45724
+ }
45542
45725
  async fetchAuthenticatedAttachment(url) {
45543
45726
  try {
45544
45727
  const response = await this.app.api.http.get(url, {
@@ -45552,10 +45735,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45552
45735
  }
45553
45736
  }
45554
45737
  rehydrateAttachment(attachment) {
45555
- return rehydrateTeamsAttachment(attachment, {
45556
- createAnonymousFetchData: (url) => this.createFetchDataFn(url),
45557
- fetchAuthenticated: (url) => this.fetchAuthenticatedAttachment(url)
45558
- });
45738
+ return rehydrateTeamsAttachment(attachment, this.attachmentFetchers);
45559
45739
  }
45560
45740
  normalizeMentions(text) {
45561
45741
  return text.trim();
@@ -45592,12 +45772,16 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45592
45772
  return null;
45593
45773
  }
45594
45774
  try {
45595
- const aadObjectId = await this.chat.getState().get(`teams:aadObjectId:${userId}`);
45775
+ const state = this.chat.getState();
45776
+ const [aadObjectId, tenantId] = await Promise.all([
45777
+ state.get(`teams:aadObjectId:${userId}`),
45778
+ state.get(`teams:tenantId:${userId}`)
45779
+ ]);
45596
45780
  if (!aadObjectId) {
45597
45781
  this.logger.debug("No cached aadObjectId for user", { userId });
45598
45782
  return null;
45599
45783
  }
45600
- return await this.getUserByAadObjectId(userId, aadObjectId);
45784
+ return await this.getUserByAadObjectId(userId, aadObjectId, tenantId ?? undefined);
45601
45785
  } catch (error) {
45602
45786
  this.logger.warn("Failed to read cached aadObjectId from state", {
45603
45787
  userId,
@@ -45608,9 +45792,10 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45608
45792
  }
45609
45793
  async getIncomingUser(ctx, userId, aadObjectId) {
45610
45794
  const cacheKey = `teams:userInfo:${aadObjectId}`;
45795
+ const isBot = this.isBotSender(ctx.activity);
45611
45796
  const cached = await this.readCachedUserInfo(cacheKey);
45612
45797
  if (cached && cached !== USER_INFO_NEGATIVE_SENTINEL) {
45613
- return { ...cached, userId };
45798
+ return { ...cached, isBot, userId };
45614
45799
  }
45615
45800
  try {
45616
45801
  const member = await ctx.api.conversations.getMemberById(ctx.activity.conversation.id, userId);
@@ -45618,7 +45803,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45618
45803
  avatarUrl: undefined,
45619
45804
  email: member.email ?? member.userPrincipalName ?? undefined,
45620
45805
  fullName: member.name ?? aadObjectId,
45621
- isBot: false,
45806
+ isBot,
45622
45807
  userId,
45623
45808
  userName: member.userPrincipalName ?? member.email ?? member.name ?? userId
45624
45809
  };
@@ -45629,24 +45814,25 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45629
45814
  return null;
45630
45815
  }
45631
45816
  }
45632
- async getUserByAadObjectId(userId, aadObjectId) {
45817
+ async getUserByAadObjectId(userId, aadObjectId, tenantId) {
45633
45818
  const cacheKey = `teams:userInfo:${aadObjectId}`;
45819
+ const isBot = this.isBotUserId(userId);
45634
45820
  const cached = await this.readCachedUserInfo(cacheKey);
45635
45821
  if (cached === USER_INFO_NEGATIVE_SENTINEL) {
45636
45822
  return null;
45637
45823
  }
45638
45824
  if (cached) {
45639
- return { ...cached, userId };
45825
+ return { ...cached, isBot, userId };
45640
45826
  }
45641
45827
  try {
45642
- const graphUser = await this.app.graph.call(n7, {
45828
+ const graphUser = await this.app.graphFor(tenantId).call(n7, {
45643
45829
  "user-id": aadObjectId
45644
45830
  });
45645
45831
  const userInfo = {
45646
45832
  avatarUrl: undefined,
45647
45833
  email: graphUser.mail ?? graphUser.userPrincipalName ?? undefined,
45648
45834
  fullName: graphUser.displayName ?? aadObjectId,
45649
- isBot: false,
45835
+ isBot,
45650
45836
  userId,
45651
45837
  userName: graphUser.userPrincipalName ?? graphUser.displayName ?? userId
45652
45838
  };
@@ -45694,6 +45880,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45694
45880
  },
45695
45881
  ...fileAttachments
45696
45882
  ];
45883
+ applyAiGeneratedLabel(activity2, message);
45697
45884
  this.logger.debug("Teams API: send (adaptive card)", {
45698
45885
  conversationId,
45699
45886
  fileCount: fileAttachments.length
@@ -45716,6 +45903,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45716
45903
  if (fileAttachments.length > 0) {
45717
45904
  activity.attachments = fileAttachments;
45718
45905
  }
45906
+ applyAiGeneratedLabel(activity, message);
45719
45907
  this.logger.debug("Teams API: send (message)", {
45720
45908
  conversationId,
45721
45909
  textLength: text.length,
@@ -45760,6 +45948,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45760
45948
  },
45761
45949
  ...fileAttachments
45762
45950
  ];
45951
+ applyAiGeneratedLabel(activity2, message);
45763
45952
  this.logger.debug("Teams API: send (targeted adaptive card)", {
45764
45953
  conversationId,
45765
45954
  userId,
@@ -45789,6 +45978,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45789
45978
  if (fileAttachments.length > 0) {
45790
45979
  activity.attachments = fileAttachments;
45791
45980
  }
45981
+ applyAiGeneratedLabel(activity, message);
45792
45982
  this.logger.debug("Teams API: send (targeted message)", {
45793
45983
  conversationId,
45794
45984
  userId,
@@ -45886,6 +46076,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45886
46076
  content: adaptiveCard
45887
46077
  }
45888
46078
  ];
46079
+ applyAiGeneratedLabel(activity2, message);
45889
46080
  const targeted2 = await this.isTargetedActivity(conversationId, messageId);
45890
46081
  this.logger.debug("Teams API: updateActivity (adaptive card)", {
45891
46082
  conversationId,
@@ -45908,6 +46099,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
45908
46099
  const text = convertEmojiPlaceholders2(this.formatConverter.renderPostable(message), "teams");
45909
46100
  const activity = new import_teams.MessageActivity(text);
45910
46101
  activity.textFormat = "markdown";
46102
+ applyAiGeneratedLabel(activity, message);
45911
46103
  const targeted = await this.isTargetedActivity(conversationId, messageId);
45912
46104
  this.logger.debug("Teams API: updateActivity", {
45913
46105
  conversationId,
@@ -46014,7 +46206,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
46014
46206
  async stream(threadId, textStream, options) {
46015
46207
  const activeStream = this.activeStreams.get(threadId);
46016
46208
  if (activeStream && !activeStream.canceled) {
46017
- return this.streamViaEmit(threadId, textStream, activeStream, options?.fallbackStreamingPlaceholderText);
46209
+ return this.streamViaEmit(threadId, textStream, activeStream, options?.fallbackStreamingPlaceholderText, options?.aiGenerated);
46018
46210
  }
46019
46211
  if (!activeStream && typeof options?.fallbackStreamingPlaceholderText === "string") {
46020
46212
  return null;
@@ -46030,9 +46222,12 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
46030
46222
  if (!accumulated) {
46031
46223
  return { id: "", threadId, raw: { text: "" } };
46032
46224
  }
46033
- return this.postMessage(threadId, { markdown: accumulated });
46225
+ return this.postMessage(threadId, {
46226
+ markdown: accumulated,
46227
+ aiGenerated: options?.aiGenerated
46228
+ });
46034
46229
  }
46035
- async streamViaEmit(threadId, textStream, stream, placeholderText) {
46230
+ async streamViaEmit(threadId, textStream, stream, placeholderText, aiGenerated) {
46036
46231
  let accumulated = "";
46037
46232
  let messageId = "";
46038
46233
  const idCaptured = new Promise((resolve) => {
@@ -46058,7 +46253,7 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
46058
46253
  if (!text) {
46059
46254
  continue;
46060
46255
  }
46061
- stream.emit(text);
46256
+ stream.emit(aiGenerated ? new import_teams.MessageActivityInput(text).addAiGenerated() : text);
46062
46257
  accumulated += text;
46063
46258
  }
46064
46259
  } catch (error) {
@@ -46143,6 +46338,11 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
46143
46338
  const target = this.decodeThreadId(channelId);
46144
46339
  const { conversationId } = target;
46145
46340
  const baseConversationId = conversationId.replace(MESSAGEID_STRIP_PATTERN2, "");
46341
+ const isChannel = target.conversationType === "channel" || target.conversationType === undefined && baseConversationId.endsWith("@thread.tacv2");
46342
+ const getThreadId = (messageId) => messageId && isChannel ? this.encodeThreadId({
46343
+ ...target,
46344
+ conversationId: `${baseConversationId};messageid=${messageId}`
46345
+ }) : channelId;
46146
46346
  const files = extractFiles(message);
46147
46347
  const fileAttachments = files.length > 0 ? await this.filesToAttachments(files) : [];
46148
46348
  const card = extractCard(message);
@@ -46156,9 +46356,14 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
46156
46356
  },
46157
46357
  ...fileAttachments
46158
46358
  ];
46359
+ applyAiGeneratedLabel(activity2, message);
46159
46360
  try {
46160
46361
  const sent = await this.app.sendTo({ ...target, conversationId: baseConversationId }, activity2);
46161
- return { id: sent.id || "", threadId: channelId, raw: activity2 };
46362
+ return {
46363
+ id: sent.id || "",
46364
+ threadId: getThreadId(sent.id),
46365
+ raw: activity2
46366
+ };
46162
46367
  } catch (error) {
46163
46368
  this.logger.error("Teams API: postChannelMessage failed", {
46164
46369
  conversationId: baseConversationId,
@@ -46173,12 +46378,17 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
46173
46378
  if (fileAttachments.length > 0) {
46174
46379
  activity.attachments = fileAttachments;
46175
46380
  }
46381
+ applyAiGeneratedLabel(activity, message);
46176
46382
  try {
46177
46383
  const sent = await this.app.sendTo({ ...target, conversationId: baseConversationId }, activity);
46178
46384
  this.logger.debug("Teams API: postChannelMessage response", {
46179
46385
  messageId: sent.id
46180
46386
  });
46181
- return { id: sent.id || "", threadId: channelId, raw: activity };
46387
+ return {
46388
+ id: sent.id || "",
46389
+ threadId: getThreadId(sent.id),
46390
+ raw: activity
46391
+ };
46182
46392
  } catch (error) {
46183
46393
  this.logger.error("Teams API: postChannelMessage failed", {
46184
46394
  conversationId: baseConversationId,
@@ -46212,6 +46422,22 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
46212
46422
  const fromId = activity.from?.id;
46213
46423
  return fromId ? this.isBotAccountId(fromId) : false;
46214
46424
  }
46425
+ isBotSender(activity) {
46426
+ const fromId = activity.from?.id;
46427
+ return activity.from?.role?.toLowerCase() === "bot" || (fromId ? this.isBotUserId(fromId) : false);
46428
+ }
46429
+ isBotUserId(userId) {
46430
+ return userId.startsWith(BOT_USER_ID_PREFIX) || this.isBotAccountId(userId);
46431
+ }
46432
+ authorFromActivity(activity) {
46433
+ return {
46434
+ userId: activity.from?.id || "unknown",
46435
+ userName: activity.from?.name || "unknown",
46436
+ fullName: activity.from?.name || "unknown",
46437
+ isBot: this.isBotSender(activity),
46438
+ isMe: this.isMessageFromSelf(activity)
46439
+ };
46440
+ }
46215
46441
  isBotAccountId(accountId) {
46216
46442
  const appId = this.appInstance?.id?.toLowerCase();
46217
46443
  if (!appId) {
@@ -46224,27 +46450,30 @@ var import_teams, import_teams2, import_teams4, import_teams5, import_teams6, im
46224
46450
  return this.formatConverter.fromAst(content);
46225
46451
  }
46226
46452
  };
46227
- var init_dist3 = __esm(() => {
46228
- init_dist();
46229
- init_dist2();
46230
- init_dist4();
46231
- init_dist();
46232
- init_dist();
46233
- init_dist4();
46234
- init_dist();
46235
- init_dist2();
46236
- init_dist4();
46237
- init_dist();
46453
+ var init_dist2 = __esm(() => {
46454
+ init_dist7();
46238
46455
  init_dist();
46239
- init_dist4();
46456
+ init_dist8();
46457
+ init_dist7();
46458
+ init_dist7();
46459
+ init_dist8();
46460
+ init_dist7();
46461
+ init_dist7();
46240
46462
  init_dist();
46463
+ init_dist8();
46464
+ init_dist7();
46465
+ init_dist7();
46466
+ init_dist8();
46467
+ init_dist7();
46241
46468
  import_teams = __toESM(require_dist4(), 1);
46242
46469
  import_teams2 = __toESM(require_dist7(), 1);
46243
46470
  import_teams4 = __toESM(require_dist4(), 1);
46244
46471
  import_teams5 = __toESM(require_dist7(), 1);
46245
- import_teams6 = __toESM(require_dist3(), 1);
46246
- import_teams8 = __toESM(require_dist3(), 1);
46472
+ import_teams6 = __toESM(require_dist6(), 1);
46473
+ import_teams7 = __toESM(require_dist3(), 1);
46474
+ import_teams9 = __toESM(require_dist3(), 1);
46247
46475
  TeamsApp = class extends import_teams5.App {
46476
+ tenantGraphClients = /* @__PURE__ */ new Map;
46248
46477
  get hasServiceUrlOverride() {
46249
46478
  return Boolean(this.options.serviceUrl);
46250
46479
  }
@@ -46255,6 +46484,17 @@ var init_dist3 = __esm(() => {
46255
46484
  }
46256
46485
  return new import_teams4.Client(target, this.client.clone({ token: () => this.getBotToken() }));
46257
46486
  }
46487
+ graphFor(tenantId) {
46488
+ if (!tenantId || tenantId === this.options.tenantId) {
46489
+ return this.graph;
46490
+ }
46491
+ let client = this.tenantGraphClients.get(tenantId);
46492
+ if (!client) {
46493
+ client = new import_teams6.Client(this.client.clone({ token: () => this.getAppGraphToken(tenantId) }), { baseUrlRoot: this.graphBaseUrl });
46494
+ this.tenantGraphClients.set(tenantId, client);
46495
+ }
46496
+ return client;
46497
+ }
46258
46498
  async sendTo(target, activity) {
46259
46499
  if (!this.id) {
46260
46500
  throw new Error("Teams app has no credentials configured");
@@ -46278,11 +46518,16 @@ var init_dist3 = __esm(() => {
46278
46518
  FILE_MIME_TYPES = {
46279
46519
  apng: "image/apng",
46280
46520
  avif: "image/avif",
46521
+ csv: "text/csv",
46522
+ doc: "application/msword",
46523
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
46281
46524
  gif: "image/gif",
46282
46525
  jpeg: "image/jpeg",
46283
46526
  jpg: "image/jpeg",
46284
46527
  pdf: "application/pdf",
46285
46528
  png: "image/png",
46529
+ ppt: "application/vnd.ms-powerpoint",
46530
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
46286
46531
  svg: "image/svg+xml",
46287
46532
  txt: "text/plain",
46288
46533
  webp: "image/webp",
@@ -46290,6 +46535,15 @@ var init_dist3 = __esm(() => {
46290
46535
  xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
46291
46536
  };
46292
46537
  convertEmoji = createEmojiConverter("teams");
46538
+ BUTTON_SUBMIT_KEYS = /* @__PURE__ */ new Set([
46539
+ "actionId",
46540
+ "msteams",
46541
+ "value"
46542
+ ]);
46543
+ AUTO_SUBMIT_KEYS = /* @__PURE__ */ new Set([
46544
+ "actionId",
46545
+ "msteams"
46546
+ ]);
46293
46547
  TABLE_HORIZONTAL_ALIGNMENT = {
46294
46548
  left: "Left",
46295
46549
  center: "Center",
@@ -46302,13 +46556,44 @@ var init_dist3 = __esm(() => {
46302
46556
  };
46303
46557
  MESSAGEID_STRIP_PATTERN = /;messageid=\d+/;
46304
46558
  SEMICOLON_MESSAGEID_CAPTURE_PATTERN = /;messageid=(\d+)/;
46559
+ TRUSTED_GRAPH_HOSTS = /* @__PURE__ */ new Set([
46560
+ "dod-graph.microsoft.us",
46561
+ "graph.microsoft.com",
46562
+ "graph.microsoft.de",
46563
+ "graph.microsoft.us",
46564
+ "microsoftgraph.chinacloudapi.cn"
46565
+ ]);
46305
46566
  INSTALLATION_ACTIONS = [
46306
46567
  "add",
46307
46568
  "add-upgrade",
46308
46569
  "remove",
46309
46570
  "remove-upgrade"
46310
46571
  ];
46572
+ MENTION_PATTERN = /<at>([^<]+)<\/at>/gi;
46573
+ BOLD_PATTERN = /<(b|strong)>([^<]+)<\/(b|strong)>/gi;
46574
+ ITALIC_PATTERN = /<(i|em)>([^<]+)<\/(i|em)>/gi;
46575
+ STRIKE_PATTERN = /<(s|strike)>([^<]+)<\/(s|strike)>/gi;
46576
+ CODE_PATTERN = /<code>([^<]+)<\/code>/gi;
46577
+ PRE_PATTERN = /<pre>([^<]+)<\/pre>/gi;
46578
+ LINK_START_PATTERN = /<a/gi;
46579
+ HREF_PATTERN = /href="/gi;
46580
+ LINK_END_PATTERN = /<\/a>/iy;
46581
+ ENTITY_PATTERN = /&(?:lt|gt|amp|quot|#39);/g;
46582
+ PLAIN_TEXT_ENTITY_PATTERN = /&(?:lt|gt|amp|quot|#39|nbsp);/g;
46583
+ BLOCK_TAG_PATTERN = /^<(?:br\b|\/(?:p|div|li|tr|h[1-6]|blockquote|pre|table|ul|ol)\b)/i;
46584
+ EXTRA_NEWLINES_PATTERN = /\n{3,}/g;
46585
+ HREF_PREFIX_LENGTH = 'href="'.length;
46586
+ LINK_END_LENGTH = "</a>".length;
46587
+ ENTITIES = {
46588
+ "&lt;": "<",
46589
+ "&gt;": ">",
46590
+ "&amp;": "&",
46591
+ "&quot;": '"',
46592
+ "&#39;": "'",
46593
+ "&nbsp;": " "
46594
+ };
46311
46595
  TeamsFormatConverter = class extends BaseFormatConverter2 {
46596
+ indentListContinuationLines = true;
46312
46597
  renderPostable(message) {
46313
46598
  if (typeof message === "string") {
46314
46599
  return message;
@@ -46328,28 +46613,13 @@ var init_dist3 = __esm(() => {
46328
46613
  return this.fromAstWithNodeConverter(ast, (node) => this.nodeToTeams(node));
46329
46614
  }
46330
46615
  toAst(teamsText) {
46331
- let markdown = teamsText;
46332
- markdown = markdown.replace(/<at>([^<]+)<\/at>/gi, "@$1");
46333
- markdown = markdown.replace(/<(b|strong)>([^<]+)<\/(b|strong)>/gi, "**$2**");
46334
- markdown = markdown.replace(/<(i|em)>([^<]+)<\/(i|em)>/gi, "_$2_");
46335
- markdown = markdown.replace(/<(s|strike)>([^<]+)<\/(s|strike)>/gi, "~~$2~~");
46336
- markdown = markdown.replace(/<a[^>]+href="([^"]+)"[^>]*>([^<]+)<\/a>/gi, "[$2]($1)");
46337
- markdown = markdown.replace(/<code>([^<]+)<\/code>/gi, "`$1`");
46338
- markdown = markdown.replace(/<pre>([^<]+)<\/pre>/gi, "```\n$1\n```");
46339
- let prev;
46340
- do {
46341
- prev = markdown;
46342
- markdown = markdown.replace(/<[^>]+>/g, "");
46343
- } while (markdown !== prev);
46344
- const entityMap = {
46345
- "&lt;": "<",
46346
- "&gt;": ">",
46347
- "&amp;": "&",
46348
- "&quot;": '"',
46349
- "&#39;": "'"
46350
- };
46351
- markdown = markdown.replace(/&(?:lt|gt|amp|quot|#39);/g, (match) => entityMap[match] ?? match);
46352
- return parseMarkdown2(markdown);
46616
+ return parseMarkdown2(teamsHtmlToMarkdown(teamsText));
46617
+ }
46618
+ exceedsIncomingBudget(teamsText) {
46619
+ return teamsText.length > this.maxIncomingParseLength || super.exceedsIncomingBudget(teamsHtmlToMarkdown(teamsText));
46620
+ }
46621
+ incomingFallbackText(teamsText) {
46622
+ return teamsHtmlToPlainText(teamsText);
46353
46623
  }
46354
46624
  nodeToTeams(node) {
46355
46625
  if (isParagraphNode2(node)) {
@@ -46426,6 +46696,11 @@ ${node.value}
46426
46696
  }
46427
46697
  };
46428
46698
  convertEmoji2 = createEmojiConverter("teams");
46699
+ CARD_ACTION_INVOKE_ACK = {
46700
+ statusCode: 200,
46701
+ type: "application/vnd.microsoft.activity.message",
46702
+ value: "OK"
46703
+ };
46429
46704
  MESSAGEID_CAPTURE_PATTERN = /messageid=(\d+)/;
46430
46705
  MESSAGEID_STRIP_PATTERN2 = /;messageid=\d+/;
46431
46706
  CACHE_TTL_MS = 30 * 24 * 60 * 60 * 1000;
@@ -46442,7 +46717,7 @@ ${node.value}
46442
46717
  x: "274c_crossmark"
46443
46718
  };
46444
46719
  });
46445
- init_dist3();
46720
+ init_dist2();
46446
46721
 
46447
46722
  export {
46448
46723
  createTeamsAdapter