@5ss/ai-tools 2.11.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 (342) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/LICENSE +21 -0
  3. package/README.md +221 -0
  4. package/dist/ai-sdk/index.d.ts +15 -0
  5. package/dist/ai-sdk/index.d.ts.map +1 -0
  6. package/dist/ai-sdk/index.js +24 -0
  7. package/dist/ai-sdk/index.js.map +1 -0
  8. package/dist/artifact-D064mHfK.js +44 -0
  9. package/dist/artifact-D064mHfK.js.map +1 -0
  10. package/dist/artifacts-O8g-40Pw.js +404 -0
  11. package/dist/artifacts-O8g-40Pw.js.map +1 -0
  12. package/dist/aws-json-CecFqzqX.js +23 -0
  13. package/dist/aws-json-CecFqzqX.js.map +1 -0
  14. package/dist/aws-service-msttbPrz.js +58 -0
  15. package/dist/aws-service-msttbPrz.js.map +1 -0
  16. package/dist/batch-BMM5dXqL.d.ts +22 -0
  17. package/dist/batch-BMM5dXqL.d.ts.map +1 -0
  18. package/dist/batch-Co1ujeAW.js +67 -0
  19. package/dist/batch-Co1ujeAW.js.map +1 -0
  20. package/dist/bedrock-agentcore-browser-a_qOs-NR.js +182 -0
  21. package/dist/bedrock-agentcore-browser-a_qOs-NR.js.map +1 -0
  22. package/dist/bedrock-agentcore-code-interpreter-MWK-8RhA.js +357 -0
  23. package/dist/bedrock-agentcore-code-interpreter-MWK-8RhA.js.map +1 -0
  24. package/dist/bytes-BxpimpQx.js +45 -0
  25. package/dist/bytes-BxpimpQx.js.map +1 -0
  26. package/dist/client-CCKGsTeI.js +743 -0
  27. package/dist/client-CCKGsTeI.js.map +1 -0
  28. package/dist/cloudflare/index.d.ts +37 -0
  29. package/dist/cloudflare/index.d.ts.map +1 -0
  30. package/dist/cloudflare/index.js +41 -0
  31. package/dist/cloudflare/index.js.map +1 -0
  32. package/dist/cloudflare-browser-B6Yolpin.js +428 -0
  33. package/dist/cloudflare-browser-B6Yolpin.js.map +1 -0
  34. package/dist/cloudflare-email-Dy0KHeDf.js +197 -0
  35. package/dist/cloudflare-email-Dy0KHeDf.js.map +1 -0
  36. package/dist/cloudflare-sandbox-Dp_uNaqW.js +982 -0
  37. package/dist/cloudflare-sandbox-Dp_uNaqW.js.map +1 -0
  38. package/dist/content-type-CORxaxcv.js +49 -0
  39. package/dist/content-type-CORxaxcv.js.map +1 -0
  40. package/dist/core/index.d.ts +4 -0
  41. package/dist/core/index.js +204 -0
  42. package/dist/core/index.js.map +1 -0
  43. package/dist/define-CvpJ_pNP.js +115 -0
  44. package/dist/define-CvpJ_pNP.js.map +1 -0
  45. package/dist/errors-DoSpNHvs.js +20 -0
  46. package/dist/errors-DoSpNHvs.js.map +1 -0
  47. package/dist/errors-aKhko9T1.d.ts +18 -0
  48. package/dist/errors-aKhko9T1.d.ts.map +1 -0
  49. package/dist/eventbridge-scheduler-Bh6GqZY2.js +349 -0
  50. package/dist/eventbridge-scheduler-Bh6GqZY2.js.map +1 -0
  51. package/dist/framework-context-DVIIY8ZO.js +24 -0
  52. package/dist/framework-context-DVIIY8ZO.js.map +1 -0
  53. package/dist/gotenberg-NuJjxyln.js +291 -0
  54. package/dist/gotenberg-NuJjxyln.js.map +1 -0
  55. package/dist/http/index.d.ts +47 -0
  56. package/dist/http/index.d.ts.map +1 -0
  57. package/dist/http/index.js +3 -0
  58. package/dist/http-service-DDNCO1s4.js +254 -0
  59. package/dist/http-service-DDNCO1s4.js.map +1 -0
  60. package/dist/http-service-T7E5UjP8.d.ts +80 -0
  61. package/dist/http-service-T7E5UjP8.d.ts.map +1 -0
  62. package/dist/imessage-BSAFOI8Z.js +154 -0
  63. package/dist/imessage-BSAFOI8Z.js.map +1 -0
  64. package/dist/index-BU4gmYO8.d.ts +254 -0
  65. package/dist/index-BU4gmYO8.d.ts.map +1 -0
  66. package/dist/index-CCivzmxO.d.ts +188 -0
  67. package/dist/index-CCivzmxO.d.ts.map +1 -0
  68. package/dist/index-CLmTrcu5.d.ts +22 -0
  69. package/dist/index-CLmTrcu5.d.ts.map +1 -0
  70. package/dist/index-CZX5OeOF.d.ts +235 -0
  71. package/dist/index-CZX5OeOF.d.ts.map +1 -0
  72. package/dist/index-CdFmEfZO.d.ts +359 -0
  73. package/dist/index-CdFmEfZO.d.ts.map +1 -0
  74. package/dist/index-Cuh6eMWc.d.ts +285 -0
  75. package/dist/index-Cuh6eMWc.d.ts.map +1 -0
  76. package/dist/index-DuOGj7vc.d.ts +107 -0
  77. package/dist/index-DuOGj7vc.d.ts.map +1 -0
  78. package/dist/index-ccZ1XOHw.d.ts +69 -0
  79. package/dist/index-ccZ1XOHw.d.ts.map +1 -0
  80. package/dist/index-n8JTpNf1.d.ts +247 -0
  81. package/dist/index-n8JTpNf1.d.ts.map +1 -0
  82. package/dist/index-pwW1OsOx.d.ts +134 -0
  83. package/dist/index-pwW1OsOx.d.ts.map +1 -0
  84. package/dist/index-zK1ZwS4m.d.ts +347 -0
  85. package/dist/index-zK1ZwS4m.d.ts.map +1 -0
  86. package/dist/limits-hjrO8zUG.js +80 -0
  87. package/dist/limits-hjrO8zUG.js.map +1 -0
  88. package/dist/mastra/index.d.ts +14 -0
  89. package/dist/mastra/index.d.ts.map +1 -0
  90. package/dist/mastra/index.js +26 -0
  91. package/dist/mastra/index.js.map +1 -0
  92. package/dist/mastra-vector-Dhc6XZ8l.js +234 -0
  93. package/dist/mastra-vector-Dhc6XZ8l.js.map +1 -0
  94. package/dist/mcp/index.d.ts +80 -0
  95. package/dist/mcp/index.d.ts.map +1 -0
  96. package/dist/mcp/index.js +97 -0
  97. package/dist/mcp/index.js.map +1 -0
  98. package/dist/modules/artifacts/index.d.ts +337 -0
  99. package/dist/modules/artifacts/index.d.ts.map +1 -0
  100. package/dist/modules/artifacts/index.js +348 -0
  101. package/dist/modules/artifacts/index.js.map +1 -0
  102. package/dist/modules/browser/index.d.ts +516 -0
  103. package/dist/modules/browser/index.d.ts.map +1 -0
  104. package/dist/modules/browser/index.js +475 -0
  105. package/dist/modules/browser/index.js.map +1 -0
  106. package/dist/modules/calendar/index.d.ts +93 -0
  107. package/dist/modules/calendar/index.d.ts.map +1 -0
  108. package/dist/modules/calendar/index.js +131 -0
  109. package/dist/modules/calendar/index.js.map +1 -0
  110. package/dist/modules/code-sandbox/index.d.ts +317 -0
  111. package/dist/modules/code-sandbox/index.d.ts.map +1 -0
  112. package/dist/modules/code-sandbox/index.js +537 -0
  113. package/dist/modules/code-sandbox/index.js.map +1 -0
  114. package/dist/modules/content-type/index.d.ts +22 -0
  115. package/dist/modules/content-type/index.d.ts.map +1 -0
  116. package/dist/modules/content-type/index.js +66 -0
  117. package/dist/modules/content-type/index.js.map +1 -0
  118. package/dist/modules/crypto/index.d.ts +115 -0
  119. package/dist/modules/crypto/index.d.ts.map +1 -0
  120. package/dist/modules/crypto/index.js +139 -0
  121. package/dist/modules/crypto/index.js.map +1 -0
  122. package/dist/modules/document/index.d.ts +575 -0
  123. package/dist/modules/document/index.d.ts.map +1 -0
  124. package/dist/modules/document/index.js +444 -0
  125. package/dist/modules/document/index.js.map +1 -0
  126. package/dist/modules/document-extract/index.d.ts +438 -0
  127. package/dist/modules/document-extract/index.d.ts.map +1 -0
  128. package/dist/modules/document-extract/index.js +127 -0
  129. package/dist/modules/document-extract/index.js.map +1 -0
  130. package/dist/modules/document-render/index.d.ts +336 -0
  131. package/dist/modules/document-render/index.d.ts.map +1 -0
  132. package/dist/modules/document-render/index.js +155 -0
  133. package/dist/modules/document-render/index.js.map +1 -0
  134. package/dist/modules/email/index.d.ts +311 -0
  135. package/dist/modules/email/index.d.ts.map +1 -0
  136. package/dist/modules/email/index.js +167 -0
  137. package/dist/modules/email/index.js.map +1 -0
  138. package/dist/modules/email-message/index.d.ts +95 -0
  139. package/dist/modules/email-message/index.d.ts.map +1 -0
  140. package/dist/modules/email-message/index.js +264 -0
  141. package/dist/modules/email-message/index.js.map +1 -0
  142. package/dist/modules/file-convert/index.d.ts +273 -0
  143. package/dist/modules/file-convert/index.d.ts.map +1 -0
  144. package/dist/modules/file-convert/index.js +103 -0
  145. package/dist/modules/file-convert/index.js.map +1 -0
  146. package/dist/modules/files/index.d.ts +452 -0
  147. package/dist/modules/files/index.d.ts.map +1 -0
  148. package/dist/modules/files/index.js +733 -0
  149. package/dist/modules/files/index.js.map +1 -0
  150. package/dist/modules/image/index.d.ts +342 -0
  151. package/dist/modules/image/index.d.ts.map +1 -0
  152. package/dist/modules/image/index.js +281 -0
  153. package/dist/modules/image/index.js.map +1 -0
  154. package/dist/modules/messaging/index.d.ts +608 -0
  155. package/dist/modules/messaging/index.d.ts.map +1 -0
  156. package/dist/modules/messaging/index.js +1067 -0
  157. package/dist/modules/messaging/index.js.map +1 -0
  158. package/dist/modules/pdf/index.d.ts +287 -0
  159. package/dist/modules/pdf/index.d.ts.map +1 -0
  160. package/dist/modules/pdf/index.js +259 -0
  161. package/dist/modules/pdf/index.js.map +1 -0
  162. package/dist/modules/presentation/index.d.ts +247 -0
  163. package/dist/modules/presentation/index.d.ts.map +1 -0
  164. package/dist/modules/presentation/index.js +12657 -0
  165. package/dist/modules/presentation/index.js.map +1 -0
  166. package/dist/modules/queue/index.d.ts +129 -0
  167. package/dist/modules/queue/index.d.ts.map +1 -0
  168. package/dist/modules/queue/index.js +131 -0
  169. package/dist/modules/queue/index.js.map +1 -0
  170. package/dist/modules/rag/index.d.ts +250 -0
  171. package/dist/modules/rag/index.d.ts.map +1 -0
  172. package/dist/modules/rag/index.js +366 -0
  173. package/dist/modules/rag/index.js.map +1 -0
  174. package/dist/modules/scheduler/index.d.ts +216 -0
  175. package/dist/modules/scheduler/index.d.ts.map +1 -0
  176. package/dist/modules/scheduler/index.js +153 -0
  177. package/dist/modules/scheduler/index.js.map +1 -0
  178. package/dist/modules/skills/index.d.ts +205 -0
  179. package/dist/modules/skills/index.d.ts.map +1 -0
  180. package/dist/modules/skills/index.js +203 -0
  181. package/dist/modules/skills/index.js.map +1 -0
  182. package/dist/modules/tasks/index.d.ts +287 -0
  183. package/dist/modules/tasks/index.d.ts.map +1 -0
  184. package/dist/modules/tasks/index.js +207 -0
  185. package/dist/modules/tasks/index.js.map +1 -0
  186. package/dist/modules/vector-store/index.d.ts +3 -0
  187. package/dist/modules/vector-store/index.js +3 -0
  188. package/dist/modules/web-fetch/index.d.ts +99 -0
  189. package/dist/modules/web-fetch/index.d.ts.map +1 -0
  190. package/dist/modules/web-fetch/index.js +242 -0
  191. package/dist/modules/web-fetch/index.js.map +1 -0
  192. package/dist/object-artifact-store-CMTzCm_G.d.ts +7 -0
  193. package/dist/object-artifact-store-CMTzCm_G.d.ts.map +1 -0
  194. package/dist/object-artifact-store-wZ2j9cto.js +28 -0
  195. package/dist/object-artifact-store-wZ2j9cto.js.map +1 -0
  196. package/dist/pinecone-umY4t6OF.js +190 -0
  197. package/dist/pinecone-umY4t6OF.js.map +1 -0
  198. package/dist/provider-CgDAlg6K.js +34 -0
  199. package/dist/provider-CgDAlg6K.js.map +1 -0
  200. package/dist/qdrant-DMp4NhKR.js +253 -0
  201. package/dist/qdrant-DMp4NhKR.js.map +1 -0
  202. package/dist/resend-BAC38_dA.js +155 -0
  203. package/dist/resend-BAC38_dA.js.map +1 -0
  204. package/dist/s3-CsOaPWMP.js +955 -0
  205. package/dist/s3-CsOaPWMP.js.map +1 -0
  206. package/dist/schemas-ChOAhdo9.js +192 -0
  207. package/dist/schemas-ChOAhdo9.js.map +1 -0
  208. package/dist/slack-Di5BBNpt.js +1455 -0
  209. package/dist/slack-Di5BBNpt.js.map +1 -0
  210. package/dist/sqs-DCwS1i2N.js +225 -0
  211. package/dist/sqs-DCwS1i2N.js.map +1 -0
  212. package/dist/supabase-vector-Dpp9mmJR.js +218 -0
  213. package/dist/supabase-vector-Dpp9mmJR.js.map +1 -0
  214. package/dist/tanstack/index.d.ts +15 -0
  215. package/dist/tanstack/index.d.ts.map +1 -0
  216. package/dist/tanstack/index.js +28 -0
  217. package/dist/tanstack/index.js.map +1 -0
  218. package/dist/teams-DYAHNb39.js +835 -0
  219. package/dist/teams-DYAHNb39.js.map +1 -0
  220. package/dist/telegram-DDXWzkfL.js +734 -0
  221. package/dist/telegram-DDXWzkfL.js.map +1 -0
  222. package/dist/textract-CPLiB22H.js +554 -0
  223. package/dist/textract-CPLiB22H.js.map +1 -0
  224. package/dist/transport-B4vn-XiQ.js +157 -0
  225. package/dist/transport-B4vn-XiQ.js.map +1 -0
  226. package/dist/transport-i96ACAI_.d.ts +46 -0
  227. package/dist/transport-i96ACAI_.d.ts.map +1 -0
  228. package/dist/types-Ccb0DXY9.d.ts +150 -0
  229. package/dist/types-Ccb0DXY9.d.ts.map +1 -0
  230. package/dist/unique-EwBH1JPB.js +19 -0
  231. package/dist/unique-EwBH1JPB.js.map +1 -0
  232. package/dist/vector-store-C3nEO80e.js +193 -0
  233. package/dist/vector-store-C3nEO80e.js.map +1 -0
  234. package/dist/vendors/amazon-sp-api/index.d.ts +526 -0
  235. package/dist/vendors/amazon-sp-api/index.d.ts.map +1 -0
  236. package/dist/vendors/amazon-sp-api/index.js +975 -0
  237. package/dist/vendors/amazon-sp-api/index.js.map +1 -0
  238. package/dist/vendors/bedrock-agentcore-browser/index.d.ts +2 -0
  239. package/dist/vendors/bedrock-agentcore-browser/index.js +2 -0
  240. package/dist/vendors/bedrock-agentcore-code-interpreter/index.d.ts +228 -0
  241. package/dist/vendors/bedrock-agentcore-code-interpreter/index.d.ts.map +1 -0
  242. package/dist/vendors/bedrock-agentcore-code-interpreter/index.js +2 -0
  243. package/dist/vendors/cloudflare-browser/index.d.ts +2 -0
  244. package/dist/vendors/cloudflare-browser/index.js +2 -0
  245. package/dist/vendors/cloudflare-email/index.d.ts +260 -0
  246. package/dist/vendors/cloudflare-email/index.d.ts.map +1 -0
  247. package/dist/vendors/cloudflare-email/index.js +3 -0
  248. package/dist/vendors/cloudflare-sandbox/index.d.ts +565 -0
  249. package/dist/vendors/cloudflare-sandbox/index.d.ts.map +1 -0
  250. package/dist/vendors/cloudflare-sandbox/index.js +2 -0
  251. package/dist/vendors/eventbridge-scheduler/index.d.ts +2 -0
  252. package/dist/vendors/eventbridge-scheduler/index.js +2 -0
  253. package/dist/vendors/gotenberg/index.d.ts +306 -0
  254. package/dist/vendors/gotenberg/index.d.ts.map +1 -0
  255. package/dist/vendors/gotenberg/index.js +2 -0
  256. package/dist/vendors/imessage/index.d.ts +420 -0
  257. package/dist/vendors/imessage/index.d.ts.map +1 -0
  258. package/dist/vendors/imessage/index.js +4 -0
  259. package/dist/vendors/katana/index.d.ts +1570 -0
  260. package/dist/vendors/katana/index.d.ts.map +1 -0
  261. package/dist/vendors/katana/index.js +1639 -0
  262. package/dist/vendors/katana/index.js.map +1 -0
  263. package/dist/vendors/mastra-vector/index.d.ts +120 -0
  264. package/dist/vendors/mastra-vector/index.d.ts.map +1 -0
  265. package/dist/vendors/mastra-vector/index.js +3 -0
  266. package/dist/vendors/pinecone/index.d.ts +75 -0
  267. package/dist/vendors/pinecone/index.d.ts.map +1 -0
  268. package/dist/vendors/pinecone/index.js +3 -0
  269. package/dist/vendors/qdrant/index.d.ts +75 -0
  270. package/dist/vendors/qdrant/index.d.ts.map +1 -0
  271. package/dist/vendors/qdrant/index.js +3 -0
  272. package/dist/vendors/resend/index.d.ts +3 -0
  273. package/dist/vendors/resend/index.js +3 -0
  274. package/dist/vendors/s3/index.d.ts +2 -0
  275. package/dist/vendors/s3/index.js +2 -0
  276. package/dist/vendors/slack/index.d.ts +576 -0
  277. package/dist/vendors/slack/index.d.ts.map +1 -0
  278. package/dist/vendors/slack/index.js +3 -0
  279. package/dist/vendors/sqs/index.d.ts +2 -0
  280. package/dist/vendors/sqs/index.js +2 -0
  281. package/dist/vendors/supabase-vector/index.d.ts +89 -0
  282. package/dist/vendors/supabase-vector/index.d.ts.map +1 -0
  283. package/dist/vendors/supabase-vector/index.js +3 -0
  284. package/dist/vendors/teams/index.d.ts +303 -0
  285. package/dist/vendors/teams/index.d.ts.map +1 -0
  286. package/dist/vendors/teams/index.js +3 -0
  287. package/dist/vendors/telegram/index.d.ts +319 -0
  288. package/dist/vendors/telegram/index.d.ts.map +1 -0
  289. package/dist/vendors/telegram/index.js +3 -0
  290. package/dist/vendors/textract/index.d.ts +2 -0
  291. package/dist/vendors/textract/index.js +2 -0
  292. package/dist/vendors/woocommerce/index.d.ts +1700 -0
  293. package/dist/vendors/woocommerce/index.d.ts.map +1 -0
  294. package/dist/vendors/woocommerce/index.js +1427 -0
  295. package/dist/vendors/woocommerce/index.js.map +1 -0
  296. package/dist/with-auth-CpKqTrGK.js +240 -0
  297. package/dist/with-auth-CpKqTrGK.js.map +1 -0
  298. package/logos/LUCIDE-ATTRIBUTION.txt +4 -0
  299. package/logos/README.md +89 -0
  300. package/logos/amazon.svg +6 -0
  301. package/logos/artifacts.svg +9 -0
  302. package/logos/browser.svg +9 -0
  303. package/logos/calendar.svg +15 -0
  304. package/logos/cloudflare-browser.svg +5 -0
  305. package/logos/cloudflare-email.svg +5 -0
  306. package/logos/cloudflare.svg +4 -0
  307. package/logos/code-sandbox.svg +8 -0
  308. package/logos/content-type.svg +10 -0
  309. package/logos/crypto.svg +7 -0
  310. package/logos/document-extract.svg +12 -0
  311. package/logos/document-render.svg +8 -0
  312. package/logos/document.svg +10 -0
  313. package/logos/email-message.svg +8 -0
  314. package/logos/email.svg +7 -0
  315. package/logos/file-convert.svg +9 -0
  316. package/logos/files.svg +6 -0
  317. package/logos/gotenberg.svg +340 -0
  318. package/logos/image.svg +8 -0
  319. package/logos/imessage.svg +7 -0
  320. package/logos/katana.svg +13 -0
  321. package/logos/mastra.svg +7 -0
  322. package/logos/messaging.svg +7 -0
  323. package/logos/pack-logos.json +48 -0
  324. package/logos/pdf.svg +10 -0
  325. package/logos/pinecone.svg +25 -0
  326. package/logos/presentation.svg +8 -0
  327. package/logos/qdrant.svg +4 -0
  328. package/logos/queue.svg +11 -0
  329. package/logos/rag.svg +18 -0
  330. package/logos/resend.svg +5 -0
  331. package/logos/scheduler.svg +7 -0
  332. package/logos/skills.svg +10 -0
  333. package/logos/slack.svg +14 -0
  334. package/logos/supabase.svg +4 -0
  335. package/logos/tasks.svg +10 -0
  336. package/logos/teams.svg +6 -0
  337. package/logos/telegram.svg +10 -0
  338. package/logos/textract.svg +5 -0
  339. package/logos/vector-store.svg +8 -0
  340. package/logos/web-fetch.svg +8 -0
  341. package/logos/woocommerce.svg +4 -0
  342. package/package.json +373 -0
@@ -0,0 +1,1067 @@
1
+ import { d as isImessageDefiniteRejection, f as isImessageOutcomeUnknown, h as imessageAuthSchema, m as MAX_MEDIA_BYTES } from "../../client-CCKGsTeI.js";
2
+ import { t as ToolError } from "../../errors-DoSpNHvs.js";
3
+ import { n as defineModule, r as defineTool } from "../../define-CvpJ_pNP.js";
4
+ import { n as requireAuth } from "../../provider-CgDAlg6K.js";
5
+ import { n as bytesToBase64, t as base64ToBytes } from "../../bytes-BxpimpQx.js";
6
+ import { m as s3AuthSchema, p as S3Client } from "../../s3-CsOaPWMP.js";
7
+ import { n as runBatchItems, t as batchResultSchema } from "../../batch-Co1ujeAW.js";
8
+ import { n as createTypingPulse, t as createLiveMessage } from "../../transport-B4vn-XiQ.js";
9
+ import { A as slackAuthSchema, C as isSlackOutcomeUnknown, S as isSlackDefiniteRejection, b as SlackClient, w as MAX_MEDIA_BYTES$1 } from "../../slack-Di5BBNpt.js";
10
+ import { _ as isTeamsOutcomeUnknown, b as teamsAuthSchema, g as isTeamsDefiniteRejection, m as TeamsClient, v as MAX_MEDIA_BYTES$2 } from "../../teams-DYAHNb39.js";
11
+ import { _ as isTelegramOutcomeUnknown, b as telegramAuthSchema, g as isTelegramDefiniteRejection, m as TelegramClient, v as MAX_MEDIA_BYTES$3 } from "../../telegram-DDXWzkfL.js";
12
+ import { isError } from "es-toolkit";
13
+ import { z } from "zod";
14
+ //#region src/modules/messaging/contracts.ts
15
+ /**
16
+ * Messaging seam contracts — shared I/O + provider auth union.
17
+ */
18
+ const MAX_MESSAGING_MEDIA_BATCH = 10;
19
+ const messagingChatActionSchema = z.enum([
20
+ "typing",
21
+ "upload_photo",
22
+ "record_video",
23
+ "upload_video",
24
+ "record_voice",
25
+ "upload_voice",
26
+ "upload_document",
27
+ "choose_sticker",
28
+ "find_location",
29
+ "record_video_note",
30
+ "upload_video_note"
31
+ ]);
32
+ /** Optional object storage for ArtifactRef media IO (send source / download destination). */
33
+ const messagingStorageAuth = s3AuthSchema.optional().describe("S3-compatible object storage for ArtifactRef media (source on send, destination_key on download)");
34
+ /** Host auth: channel credentials + provider discriminator. */
35
+ const telegramMessagingAuthSchema = telegramAuthSchema.extend({
36
+ provider: z.literal("telegram"),
37
+ storage: messagingStorageAuth
38
+ });
39
+ const slackMessagingAuthSchema = slackAuthSchema.extend({
40
+ provider: z.literal("slack"),
41
+ storage: messagingStorageAuth
42
+ });
43
+ const teamsMessagingAuthSchema = teamsAuthSchema.extend({
44
+ provider: z.literal("teams"),
45
+ storage: messagingStorageAuth
46
+ });
47
+ const imessageMessagingAuthSchema = imessageAuthSchema.extend({
48
+ provider: z.literal("imessage"),
49
+ storage: messagingStorageAuth
50
+ });
51
+ const messagingAuthSchema = z.discriminatedUnion("provider", [
52
+ telegramMessagingAuthSchema,
53
+ slackMessagingAuthSchema,
54
+ teamsMessagingAuthSchema,
55
+ imessageMessagingAuthSchema
56
+ ]);
57
+ const serviceUrlOptional = z.string().min(1).optional().describe("Activity service base URL when the bound channel requires it for this call");
58
+ const messagingSendTextInputSchema = z.object({
59
+ chat_id: z.string().min(1).describe("Channel conversation / chat id"),
60
+ text: z.string().min(1).describe("Message text"),
61
+ reply_to_message_id: z.string().min(1).optional().describe("Optional message id to reply to (thread/reply)"),
62
+ reply_markup: z.unknown().optional().describe("Optional channel-native markup (blocks, attachments, …)"),
63
+ service_url: serviceUrlOptional
64
+ });
65
+ /** Common send/edit/media result shell for journaling. */
66
+ const messagingMessageOutputSchema = z.object({
67
+ message_id: z.string().describe("Provider message id as string"),
68
+ file_id: z.string().optional().describe("File id when the send created a downloadable attachment"),
69
+ attachment_message_ids: z.array(z.string()).optional().describe("Additional attachment message ids when a single call produced more than one message")
70
+ });
71
+ const messagingEditTextInputSchema = z.object({
72
+ chat_id: z.string().min(1).describe("Channel conversation / chat id"),
73
+ message_id: z.string().min(1).describe("Message id to edit"),
74
+ text: z.string().min(1).describe("Replacement text"),
75
+ reply_markup: z.unknown().optional().describe("Optional channel-native markup"),
76
+ service_url: serviceUrlOptional
77
+ });
78
+ const messagingSendChatActionInputSchema = z.object({
79
+ chat_id: z.string().min(1).describe("Channel conversation / chat id"),
80
+ action: messagingChatActionSchema.describe("Chat action (typing, upload_document, …)"),
81
+ reply_to_message_id: z.string().min(1).optional().describe("Optional thread or reply anchor when the channel uses thread-scoped status"),
82
+ service_url: serviceUrlOptional
83
+ });
84
+ const messagingStopTypingInputSchema = z.object({
85
+ chat_id: z.string().min(1).describe("Channel conversation / chat id"),
86
+ reply_to_message_id: z.string().min(1).optional().describe("Optional thread or reply anchor when the channel uses thread-scoped status"),
87
+ service_url: serviceUrlOptional
88
+ });
89
+ const messagingSetReactionInputSchema = z.object({
90
+ chat_id: z.string().min(1).describe("Channel conversation / chat id"),
91
+ message_id: z.string().min(1).describe("Message id to react to"),
92
+ emoji: z.string().min(1).max(64).describe("Any emoji the bound channel accepts")
93
+ });
94
+ /** Reaction result — store message_id when present for clearReaction. */
95
+ const messagingReactionOutputSchema = z.object({ message_id: z.string().optional().describe("Reaction message id when the channel creates a separate reaction message; pass to clearReaction") });
96
+ const messagingClearReactionInputSchema = z.object({
97
+ chat_id: z.string().min(1).describe("Channel conversation / chat id"),
98
+ message_id: z.string().min(1).describe("Message id to clear; use reaction message_id from setReaction when that was returned"),
99
+ emoji: z.string().min(1).max(64).optional().describe("Emoji to clear when the channel requires a reaction name")
100
+ });
101
+ /** Messaging only resolves object-store artifacts (not host-mapped keys). */
102
+ const messagingObjectArtifactRefSchema = z.object({
103
+ store: z.literal("object").describe("Object storage owned by bound messaging storage auth"),
104
+ key: z.string().min(1).describe("Object key"),
105
+ media_type: z.string().min(1).optional().describe("MIME or format hint when known"),
106
+ filename: z.string().min(1).optional().describe("Original or display file name"),
107
+ byte_length: z.int().min(0).optional().describe("Size in bytes when known")
108
+ });
109
+ const messagingMediaBodyFields = {
110
+ kind: z.enum(["photo", "document"]).describe("Media kind"),
111
+ body_base64: z.string().min(1).optional().describe("File body as base64. Omit when source is set. Prefer source for large files."),
112
+ source: messagingObjectArtifactRefSchema.optional().describe("Object-store ArtifactRef for the media file. Prefer this over body_base64 for large files"),
113
+ file_name: z.string().min(1).optional().describe("File name including extension. Required with body_base64; defaults to source.filename when source is set"),
114
+ caption: z.string().optional().describe("Optional caption"),
115
+ content_type: z.string().optional().describe("Optional content type; defaults to source.media_type when source is set")
116
+ };
117
+ function refineMediaBody(val, ctx) {
118
+ const hasB64 = val.body_base64 !== void 0;
119
+ const hasSource = val.source !== void 0;
120
+ if (hasB64 === hasSource) ctx.addIssue({
121
+ code: "custom",
122
+ message: "Provide exactly one of body_base64 or source"
123
+ });
124
+ if (hasB64 && !val.file_name) ctx.addIssue({
125
+ code: "custom",
126
+ path: ["file_name"],
127
+ message: "file_name is required when body_base64 is set"
128
+ });
129
+ if (hasSource && !val.file_name && !val.source?.filename) ctx.addIssue({
130
+ code: "custom",
131
+ path: ["file_name"],
132
+ message: "file_name or source.filename is required when source is set"
133
+ });
134
+ }
135
+ const messagingSendMediaInputSchema = z.object({
136
+ chat_id: z.string().min(1).describe("Channel conversation / chat id"),
137
+ ...messagingMediaBodyFields,
138
+ reply_to_message_id: z.string().min(1).optional().describe("Optional reply / thread anchor"),
139
+ service_url: serviceUrlOptional
140
+ }).superRefine(refineMediaBody);
141
+ const messagingSendMediaBatchItemSchema = z.object({ ...messagingMediaBodyFields }).superRefine(refineMediaBody);
142
+ const messagingSendMediaBatchInputSchema = z.object({
143
+ chat_id: z.string().min(1).describe("Channel conversation / chat id"),
144
+ items: z.array(messagingSendMediaBatchItemSchema).min(1).max(10).describe(`1–10 media items in send order`),
145
+ reply_to_message_id: z.string().min(1).optional().describe("Optional reply / thread anchor for the batch"),
146
+ service_url: serviceUrlOptional
147
+ });
148
+ const messagingSendMediaBatchOutputSchema = z.object({
149
+ message_ids: z.array(z.string()).describe("Successfully sent message ids in order"),
150
+ results: batchResultSchema(messagingMessageOutputSchema).describe("Per-item outcomes (partial failure allowed)")
151
+ });
152
+ const messagingDownloadFileInputSchema = z.object({
153
+ file_id: z.string().min(1).describe("Provider file id, content URL, or attachment message id"),
154
+ chat_id: z.string().min(1).optional().describe("Conversation id when the channel requires it for download"),
155
+ file_name: z.string().min(1).optional().describe("Preferred file name"),
156
+ destination_key: z.string().min(1).optional().describe("When set, persist downloaded bytes at this object key and return an ArtifactRef instead of body_base64"),
157
+ service_url: serviceUrlOptional
158
+ });
159
+ const messagingDownloadFileOutputSchema = z.object({
160
+ file_name: z.string(),
161
+ file_size: z.number().optional(),
162
+ body_base64: z.string().optional().describe("Downloaded file body as base64 when destination_key is omitted"),
163
+ artifact: messagingObjectArtifactRefSchema.optional().describe("Object-store ArtifactRef when destination_key is set")
164
+ });
165
+ const messagingAnswerCallbackInputSchema = z.object({
166
+ callback_query_id: z.string().min(1).describe("Callback / response id from an inbound interaction"),
167
+ text: z.string().max(3e3).optional().describe("Optional notification text"),
168
+ show_alert: z.boolean().optional().describe("When supported, show an alert instead of a toast"),
169
+ service_url: serviceUrlOptional
170
+ });
171
+ const messagingReadInputSchema = z.object({
172
+ chat_id: z.string().min(1).describe("Channel conversation / chat id"),
173
+ message_id: z.string().min(1).describe("Message id to mark read up to"),
174
+ service_url: serviceUrlOptional
175
+ });
176
+ const messagingOkOutputSchema = z.object({ ok: z.boolean() });
177
+ //#endregion
178
+ //#region src/modules/messaging/domain.ts
179
+ /**
180
+ * Messaging seam helpers (no HTTP).
181
+ */
182
+ /**
183
+ * Intentional lifecycle no-op (e.g. read when the channel has no mark-as-read API).
184
+ * Succeeds so multi-channel hosts can call one surface without branching.
185
+ * Destructive gaps (unsend) must not live on the seam — use the vendor pack.
186
+ */
187
+ function warnUnsupportedMessagingOp(provider, op) {
188
+ console.warn(`[messaging] ${provider}: ${op} is a successful no-op (not needed / not applicable on this channel)`);
189
+ }
190
+ /** Provider-neutral definite rejection (do not treat as possible delivery). */
191
+ function isMessagingDefiniteRejection(error) {
192
+ return isTelegramDefiniteRejection(error) || isSlackDefiniteRejection(error) || isTeamsDefiniteRejection(error) || isImessageDefiniteRejection(error);
193
+ }
194
+ /**
195
+ * Provider-neutral outcome-unknown (retry may duplicate).
196
+ * Includes transport network/abort failures rethrown as vendor client errors.
197
+ */
198
+ function isMessagingOutcomeUnknown(error) {
199
+ return isTelegramOutcomeUnknown(error) || isSlackOutcomeUnknown(error) || isTeamsOutcomeUnknown(error) || isImessageOutcomeUnknown(error);
200
+ }
201
+ /** Media byte ceiling for the bound channel (align object reads before channel decode). */
202
+ function mediaMaxBytesForProvider(provider) {
203
+ switch (provider) {
204
+ case "teams": return MAX_MEDIA_BYTES$2;
205
+ case "slack": return MAX_MEDIA_BYTES$1;
206
+ case "telegram": return MAX_MEDIA_BYTES$3;
207
+ case "imessage": return MAX_MEDIA_BYTES;
208
+ default: return MAX_MEDIA_BYTES$3;
209
+ }
210
+ }
211
+ function toBatchError(error) {
212
+ if (error instanceof ToolError) return {
213
+ code: error.code,
214
+ message: error.message,
215
+ retryable: error.retryable
216
+ };
217
+ return {
218
+ code: "internal",
219
+ message: isError(error) ? error.message : "Batch item failed"
220
+ };
221
+ }
222
+ async function bodyFromSource(source, storage, maxBytes) {
223
+ if (!storage) throw new ToolError("ArtifactRef media requires storage credentials on messaging auth", { code: "bad_auth" });
224
+ return {
225
+ body_base64: bytesToBase64(await storage.getBytes(source.key, { maxBytes })),
226
+ file_name: source.filename,
227
+ content_type: source.media_type
228
+ };
229
+ }
230
+ async function resolveMediaBody(input, storage, maxBytes) {
231
+ if (input.body_base64 !== void 0) {
232
+ if (!input.file_name) throw new ToolError("file_name is required when body_base64 is set", { code: "bad_input" });
233
+ const raw = base64ToBytes(input.body_base64);
234
+ if (raw.byteLength > maxBytes) throw new ToolError("Media body exceeds channel size limit", {
235
+ code: "too_large",
236
+ details: {
237
+ max_bytes: maxBytes,
238
+ content_length: raw.byteLength
239
+ }
240
+ });
241
+ return {
242
+ body_base64: input.body_base64,
243
+ file_name: input.file_name,
244
+ content_type: input.content_type
245
+ };
246
+ }
247
+ if (!input.source) throw new ToolError("Provide exactly one of body_base64 or source", { code: "bad_input" });
248
+ const fromStore = await bodyFromSource(input.source, storage, maxBytes);
249
+ const file_name = input.file_name ?? fromStore.file_name;
250
+ if (!file_name) throw new ToolError("file_name or source.filename is required when source is set", { code: "bad_input" });
251
+ return {
252
+ body_base64: fromStore.body_base64,
253
+ file_name,
254
+ content_type: input.content_type ?? fromStore.content_type
255
+ };
256
+ }
257
+ /** Resolve public send-media input to channel-facing body_base64 payload. */
258
+ async function resolveSendMediaInput(input, storage, maxBytes) {
259
+ const body = await resolveMediaBody(input, storage, maxBytes);
260
+ return {
261
+ chat_id: input.chat_id,
262
+ kind: input.kind,
263
+ body_base64: body.body_base64,
264
+ file_name: body.file_name,
265
+ content_type: body.content_type,
266
+ caption: input.caption,
267
+ reply_to_message_id: input.reply_to_message_id,
268
+ service_url: input.service_url
269
+ };
270
+ }
271
+ /**
272
+ * Resolve each batch item independently, send only successes, merge failures by original index.
273
+ * Preserves partial-failure contract when ArtifactRef resolution fails mid-batch.
274
+ */
275
+ async function resolveAndSendMediaBatch(input, storage, maxBytes, sendBatch) {
276
+ const slots = [];
277
+ for (let index = 0; index < input.items.length; index++) {
278
+ const item = input.items[index];
279
+ if (!item) continue;
280
+ try {
281
+ const body = await resolveMediaBody(item, storage, maxBytes);
282
+ slots.push({
283
+ index,
284
+ ok: true,
285
+ item: {
286
+ kind: item.kind,
287
+ body_base64: body.body_base64,
288
+ file_name: body.file_name,
289
+ content_type: body.content_type,
290
+ caption: item.caption
291
+ }
292
+ });
293
+ } catch (error) {
294
+ slots.push({
295
+ index,
296
+ ok: false,
297
+ error: toBatchError(error)
298
+ });
299
+ }
300
+ }
301
+ const successes = slots.filter((s) => s.ok);
302
+ const results = [];
303
+ const message_ids = [];
304
+ if (successes.length === 0) {
305
+ for (const slot of slots) if (!slot.ok) results.push({
306
+ index: slot.index,
307
+ ok: false,
308
+ error: slot.error
309
+ });
310
+ return {
311
+ message_ids,
312
+ results: {
313
+ results,
314
+ succeeded: 0,
315
+ failed: results.length
316
+ }
317
+ };
318
+ }
319
+ const providerOut = await sendBatch({
320
+ chat_id: input.chat_id,
321
+ items: successes.map((s) => s.item),
322
+ reply_to_message_id: input.reply_to_message_id,
323
+ service_url: input.service_url
324
+ });
325
+ const providerByLocal = new Map(providerOut.results.results.map((row) => [row.index, row]));
326
+ let successCursor = 0;
327
+ for (const slot of slots) {
328
+ if (!slot.ok) {
329
+ results.push({
330
+ index: slot.index,
331
+ ok: false,
332
+ error: slot.error
333
+ });
334
+ continue;
335
+ }
336
+ const pr = providerByLocal.get(successCursor);
337
+ successCursor += 1;
338
+ if (!pr) {
339
+ results.push({
340
+ index: slot.index,
341
+ ok: false,
342
+ error: {
343
+ code: "internal",
344
+ message: "Missing provider batch result"
345
+ }
346
+ });
347
+ continue;
348
+ }
349
+ if (pr.ok && pr.value) {
350
+ results.push({
351
+ index: slot.index,
352
+ ok: true,
353
+ value: pr.value
354
+ });
355
+ if (pr.value.message_id) message_ids.push(pr.value.message_id);
356
+ } else results.push({
357
+ index: slot.index,
358
+ ok: false,
359
+ error: pr.error ?? {
360
+ code: "internal",
361
+ message: "Provider batch item failed"
362
+ }
363
+ });
364
+ }
365
+ const succeeded = results.filter((r) => r.ok).length;
366
+ return {
367
+ message_ids,
368
+ results: {
369
+ results,
370
+ succeeded,
371
+ failed: results.length - succeeded
372
+ }
373
+ };
374
+ }
375
+ /** After channel download, optionally land bytes in object storage. */
376
+ async function finalizeDownloadOutput(got, destination_key, storage) {
377
+ if (!destination_key) return {
378
+ file_name: got.file_name,
379
+ file_size: got.file_size,
380
+ body_base64: got.body_base64
381
+ };
382
+ if (!storage) throw new ToolError("destination_key requires storage credentials on messaging auth", { code: "bad_auth" });
383
+ const bytes = base64ToBytes(got.body_base64);
384
+ await storage.putBytes(destination_key, bytes);
385
+ const file_size = got.file_size ?? bytes.byteLength;
386
+ return {
387
+ file_name: got.file_name,
388
+ file_size,
389
+ artifact: {
390
+ store: "object",
391
+ key: destination_key,
392
+ filename: got.file_name,
393
+ byte_length: file_size
394
+ }
395
+ };
396
+ }
397
+ /** Sequential sendMedia for channels without a native multi-file API. */
398
+ async function sendMediaBatchSequential(sendOne, input) {
399
+ const batch = await runBatchItems(input.items, (item) => sendOne({
400
+ chat_id: input.chat_id,
401
+ kind: item.kind,
402
+ body_base64: item.body_base64,
403
+ file_name: item.file_name,
404
+ caption: item.caption,
405
+ content_type: item.content_type,
406
+ reply_to_message_id: input.reply_to_message_id,
407
+ service_url: input.service_url
408
+ }), { concurrency: 1 });
409
+ const message_ids = [];
410
+ for (const row of batch.results) if (row.ok && row.value?.message_id) message_ids.push(row.value.message_id);
411
+ return {
412
+ message_ids,
413
+ results: batch
414
+ };
415
+ }
416
+ //#endregion
417
+ //#region src/modules/messaging/providers/imessage.ts
418
+ /**
419
+ * iMessage provider for the messaging seam.
420
+ * Wraps `ImessageClient` (Photon Spectrum Cloud + Advanced iMessage gRPC).
421
+ *
422
+ * Vendor client is loaded via dynamic import so edge/browser packaging of the
423
+ * messaging seam does not pull Node-only gRPC peers until iMessage is used.
424
+ */
425
+ var ImessageMessagingProvider = class {
426
+ #auth;
427
+ #options;
428
+ #client;
429
+ #ready;
430
+ constructor(auth, options = {}) {
431
+ this.#auth = auth;
432
+ this.#options = options;
433
+ }
434
+ async #sdk() {
435
+ if (this.#client) return this.#client;
436
+ this.#ready ??= (async () => {
437
+ const { ImessageClient } = await import("../../client-CCKGsTeI.js").then((n) => n.n);
438
+ const { provider: _p, storage: _s, ...vendorAuth } = this.#auth;
439
+ const client = new ImessageClient(vendorAuth, this.#options);
440
+ this.#client = client;
441
+ return client;
442
+ })();
443
+ return this.#ready;
444
+ }
445
+ async sendText(input) {
446
+ return { message_id: (await (await this.#sdk()).sendText({
447
+ chat_id: input.chat_id,
448
+ text: input.text
449
+ })).message_id };
450
+ }
451
+ async editText(input) {
452
+ return { message_id: (await (await this.#sdk()).editText({
453
+ chat_id: input.chat_id,
454
+ message_id: input.message_id,
455
+ text: input.text
456
+ })).message_id ?? input.message_id };
457
+ }
458
+ async sendChatAction(input) {
459
+ await (await this.#sdk()).sendChatAction({
460
+ chat_id: input.chat_id,
461
+ action: input.action
462
+ });
463
+ }
464
+ async stopTyping(input) {
465
+ await (await this.#sdk()).stopTyping({ chat_id: input.chat_id });
466
+ }
467
+ async setReaction(input) {
468
+ return { message_id: (await (await this.#sdk()).setReaction({
469
+ chat_id: input.chat_id,
470
+ message_id: input.message_id,
471
+ emoji: input.emoji
472
+ })).message_id };
473
+ }
474
+ /**
475
+ * Clears via setReaction(isSet=false). Requires emoji matching setReaction.
476
+ * `message_id` is the **target** message guid.
477
+ */
478
+ async clearReaction(input) {
479
+ if (!input.emoji) throw new ToolError("iMessage clearReaction requires emoji (same tapback/emoji used when setting)", { code: "bad_input" });
480
+ await (await this.#sdk()).clearReaction({
481
+ chat_id: input.chat_id,
482
+ message_id: input.message_id,
483
+ emoji: input.emoji
484
+ });
485
+ }
486
+ async sendMedia(input) {
487
+ return { message_id: (await (await this.#sdk()).sendMedia({
488
+ chat_id: input.chat_id,
489
+ kind: input.kind,
490
+ body_base64: input.body_base64,
491
+ file_name: input.file_name,
492
+ ...input.caption && { caption: input.caption },
493
+ ...input.content_type && { content_type: input.content_type }
494
+ })).message_id };
495
+ }
496
+ sendMediaBatch(input) {
497
+ return sendMediaBatchSequential((item) => this.sendMedia(item), input);
498
+ }
499
+ async downloadFile(input) {
500
+ const fileId = input.chat_id ? input.file_id : splitImessageFileRef(input.file_id).file_id ?? input.file_id;
501
+ return (await this.#sdk()).downloadFile({
502
+ file_id: fileId,
503
+ ...input.chat_id && { chat_id: input.chat_id },
504
+ ...input.file_name && { file_name: input.file_name }
505
+ });
506
+ }
507
+ async answerCallback(_input) {
508
+ await (await this.#sdk()).answerCallback({});
509
+ }
510
+ async read(input) {
511
+ await (await this.#sdk()).read({
512
+ chat_id: input.chat_id,
513
+ ...input.message_id && { message_id: input.message_id }
514
+ });
515
+ }
516
+ };
517
+ /** Legacy composite: `space_id::message_id` when chat_id is omitted (message_id is attachment guid). */
518
+ function splitImessageFileRef(fileId) {
519
+ const idx = fileId.indexOf("::");
520
+ if (idx <= 0) return { file_id: fileId };
521
+ const chat_id = fileId.slice(0, idx);
522
+ const rest = fileId.slice(idx + 2);
523
+ if (chat_id.length === 0 || rest.length === 0) return { file_id: fileId };
524
+ return {
525
+ chat_id,
526
+ file_id: rest
527
+ };
528
+ }
529
+ //#endregion
530
+ //#region src/modules/messaging/providers/slack.ts
531
+ /**
532
+ * Slack provider for the messaging seam. Wraps `SlackClient`.
533
+ */
534
+ var SlackMessagingProvider = class {
535
+ #client;
536
+ constructor(auth, options = {}) {
537
+ const { provider: _p, storage: _s, ...vendorAuth } = auth;
538
+ this.#client = new SlackClient(vendorAuth, options);
539
+ }
540
+ sendText(input) {
541
+ return this.#client.sendText({
542
+ chat_id: input.chat_id,
543
+ text: input.text,
544
+ ...input.reply_to_message_id && { reply_to_message_id: input.reply_to_message_id },
545
+ ...input.reply_markup !== void 0 && { reply_markup: input.reply_markup }
546
+ });
547
+ }
548
+ editText(input) {
549
+ return this.#client.editText({
550
+ chat_id: input.chat_id,
551
+ message_id: input.message_id,
552
+ text: input.text,
553
+ ...input.reply_markup !== void 0 && { reply_markup: input.reply_markup }
554
+ });
555
+ }
556
+ sendChatAction(input) {
557
+ const body = {
558
+ chat_id: input.chat_id,
559
+ action: input.action
560
+ };
561
+ if (input.reply_to_message_id) body.reply_to_message_id = input.reply_to_message_id;
562
+ return this.#client.sendChatAction(body);
563
+ }
564
+ /** Clear assistant.threads.setStatus when reply_to_message_id (thread_ts) is set. */
565
+ stopTyping(input) {
566
+ const body = { chat_id: input.chat_id };
567
+ if (input.reply_to_message_id) body.reply_to_message_id = input.reply_to_message_id;
568
+ return this.#client.stopTyping(body);
569
+ }
570
+ async setReaction(input) {
571
+ await this.#client.setReaction({
572
+ chat_id: input.chat_id,
573
+ message_id: input.message_id,
574
+ emoji: input.emoji
575
+ });
576
+ return {};
577
+ }
578
+ clearReaction(input) {
579
+ if (!input.emoji) throw new ToolError("Slack clear reaction requires emoji", { code: "bad_input" });
580
+ return this.#client.clearReaction({
581
+ chat_id: input.chat_id,
582
+ message_id: input.message_id,
583
+ emoji: input.emoji
584
+ });
585
+ }
586
+ async sendMedia(input) {
587
+ const out = await this.#client.sendMedia({
588
+ chat_id: input.chat_id,
589
+ kind: input.kind,
590
+ body_base64: input.body_base64,
591
+ file_name: input.file_name,
592
+ ...input.caption && { caption: input.caption },
593
+ ...input.reply_to_message_id && { reply_to_message_id: input.reply_to_message_id },
594
+ ...input.content_type && { content_type: input.content_type }
595
+ });
596
+ return {
597
+ message_id: out.message_id,
598
+ ...out.file_id && { file_id: out.file_id }
599
+ };
600
+ }
601
+ sendMediaBatch(input) {
602
+ return sendMediaBatchSequential((item) => this.sendMedia(item), input);
603
+ }
604
+ downloadFile(input) {
605
+ return this.#client.downloadFile({
606
+ file_id: input.file_id,
607
+ ...input.file_name && { file_name: input.file_name }
608
+ });
609
+ }
610
+ answerCallback(input) {
611
+ return this.#client.answerCallback({
612
+ callback_query_id: input.callback_query_id,
613
+ ...input.text && { text: input.text },
614
+ ...input.show_alert !== void 0 && { show_alert: input.show_alert }
615
+ });
616
+ }
617
+ async read(_input) {
618
+ warnUnsupportedMessagingOp("slack", "read");
619
+ }
620
+ };
621
+ //#endregion
622
+ //#region src/modules/messaging/providers/teams.ts
623
+ /**
624
+ * Teams provider for the messaging seam. Wraps `TeamsClient`.
625
+ */
626
+ function requireServiceUrl(serviceUrl, method) {
627
+ if (!serviceUrl) throw new ToolError(`${method} requires service_url when provider is teams`, { code: "bad_input" });
628
+ return serviceUrl;
629
+ }
630
+ var TeamsMessagingProvider = class {
631
+ #client;
632
+ constructor(auth, options = {}) {
633
+ const { provider: _p, storage: _s, ...vendorAuth } = auth;
634
+ this.#client = new TeamsClient(vendorAuth, options);
635
+ }
636
+ sendText(input) {
637
+ const service_url = requireServiceUrl(input.service_url, "messaging sendText");
638
+ return this.#client.sendText({
639
+ chat_id: input.chat_id,
640
+ text: input.text,
641
+ service_url,
642
+ ...input.reply_to_message_id && { reply_to_message_id: input.reply_to_message_id },
643
+ ...input.reply_markup !== void 0 && { reply_markup: input.reply_markup }
644
+ });
645
+ }
646
+ editText(input) {
647
+ const service_url = requireServiceUrl(input.service_url, "messaging editText");
648
+ return this.#client.editText({
649
+ chat_id: input.chat_id,
650
+ message_id: input.message_id,
651
+ text: input.text,
652
+ service_url,
653
+ ...input.reply_markup !== void 0 && { reply_markup: input.reply_markup }
654
+ });
655
+ }
656
+ sendChatAction(input) {
657
+ const service_url = requireServiceUrl(input.service_url, "messaging sendChatAction");
658
+ return this.#client.sendChatAction({
659
+ chat_id: input.chat_id,
660
+ action: input.action,
661
+ service_url
662
+ });
663
+ }
664
+ /** Teams typing is one-shot; stop is a successful no-op. */
665
+ async stopTyping(_input) {}
666
+ /**
667
+ * Graph reactions when Teams auth has tenant_id; otherwise client no-op.
668
+ */
669
+ async setReaction(input) {
670
+ await this.#client.setReaction({
671
+ chat_id: input.chat_id,
672
+ message_id: input.message_id,
673
+ emoji: input.emoji
674
+ });
675
+ return {};
676
+ }
677
+ /**
678
+ * Graph unsetReaction when tenant_id bound; requires emoji for Graph.
679
+ * Without tenant_id, client no-ops.
680
+ */
681
+ clearReaction(input) {
682
+ return this.#client.clearReaction({
683
+ chat_id: input.chat_id,
684
+ message_id: input.message_id,
685
+ ...input.emoji && { emoji: input.emoji }
686
+ });
687
+ }
688
+ sendMedia(input) {
689
+ const service_url = requireServiceUrl(input.service_url, "messaging sendMedia");
690
+ return this.#client.sendMedia({
691
+ chat_id: input.chat_id,
692
+ kind: input.kind,
693
+ body_base64: input.body_base64,
694
+ file_name: input.file_name,
695
+ service_url,
696
+ ...input.caption && { caption: input.caption },
697
+ ...input.reply_to_message_id && { reply_to_message_id: input.reply_to_message_id },
698
+ ...input.content_type && { content_type: input.content_type }
699
+ });
700
+ }
701
+ sendMediaBatch(input) {
702
+ return sendMediaBatchSequential((item) => this.sendMedia(item), input);
703
+ }
704
+ downloadFile(input) {
705
+ return this.#client.downloadFile({
706
+ file_id: input.file_id,
707
+ ...input.file_name && { file_name: input.file_name },
708
+ ...input.service_url && { service_url: input.service_url }
709
+ });
710
+ }
711
+ answerCallback(input) {
712
+ return this.#client.answerCallback({
713
+ callback_query_id: input.callback_query_id,
714
+ ...input.text && { text: input.text },
715
+ ...input.show_alert !== void 0 && { show_alert: input.show_alert },
716
+ ...input.service_url && { service_url: input.service_url }
717
+ });
718
+ }
719
+ async read(_input) {
720
+ warnUnsupportedMessagingOp("teams", "read");
721
+ }
722
+ };
723
+ //#endregion
724
+ //#region src/modules/messaging/providers/telegram.ts
725
+ var TelegramMessagingProvider = class {
726
+ #client;
727
+ constructor(auth, options = {}) {
728
+ const { provider: _p, storage: _s, ...vendorAuth } = auth;
729
+ this.#client = new TelegramClient(vendorAuth, options);
730
+ }
731
+ async sendText(input) {
732
+ const out = await this.#client.sendText({
733
+ chat_id: input.chat_id,
734
+ text: input.text,
735
+ ...input.reply_to_message_id && { reply_to_message_id: input.reply_to_message_id },
736
+ ...input.reply_markup !== void 0 && { reply_markup: input.reply_markup }
737
+ });
738
+ return {
739
+ message_id: out.message_id,
740
+ ...out.file_id && { file_id: out.file_id }
741
+ };
742
+ }
743
+ async editText(input) {
744
+ return { message_id: (await this.#client.editText({
745
+ chat_id: input.chat_id,
746
+ message_id: input.message_id,
747
+ text: input.text,
748
+ ...input.reply_markup !== void 0 && { reply_markup: input.reply_markup }
749
+ })).message_id };
750
+ }
751
+ sendChatAction(input) {
752
+ return this.#client.sendChatAction({
753
+ chat_id: input.chat_id,
754
+ action: input.action
755
+ });
756
+ }
757
+ /** Telegram typing auto-expires; stop is a successful no-op. */
758
+ async stopTyping(_input) {}
759
+ async setReaction(input) {
760
+ await this.#client.setReaction({
761
+ chat_id: input.chat_id,
762
+ message_id: input.message_id,
763
+ emoji: input.emoji
764
+ });
765
+ return {};
766
+ }
767
+ clearReaction(input) {
768
+ return this.#client.clearReaction({
769
+ chat_id: input.chat_id,
770
+ message_id: input.message_id
771
+ });
772
+ }
773
+ async sendMedia(input) {
774
+ const out = await this.#client.sendMedia({
775
+ chat_id: input.chat_id,
776
+ kind: input.kind,
777
+ body_base64: input.body_base64,
778
+ file_name: input.file_name,
779
+ ...input.caption && { caption: input.caption },
780
+ ...input.reply_to_message_id && { reply_to_message_id: input.reply_to_message_id },
781
+ ...input.content_type && { content_type: input.content_type }
782
+ });
783
+ return {
784
+ message_id: out.message_id,
785
+ ...out.file_id && { file_id: out.file_id }
786
+ };
787
+ }
788
+ async sendMediaBatch(input) {
789
+ const homogeneous = new Set(input.items.map((i) => i.kind)).size === 1;
790
+ const kind = input.items[0]?.kind;
791
+ if (homogeneous && kind && input.items.length >= 2 && input.items.length <= 10) {
792
+ const group = await this.#client.sendMediaGroup({
793
+ chat_id: input.chat_id,
794
+ items: input.items.map((item) => ({
795
+ kind: item.kind,
796
+ body_base64: item.body_base64,
797
+ file_name: item.file_name,
798
+ ...item.caption && { caption: item.caption },
799
+ ...item.content_type && { content_type: item.content_type }
800
+ })),
801
+ ...input.reply_to_message_id && { reply_to_message_id: input.reply_to_message_id }
802
+ });
803
+ return {
804
+ message_ids: group.message_ids,
805
+ results: {
806
+ results: group.message_ids.map((message_id, index) => ({
807
+ index,
808
+ ok: true,
809
+ value: { message_id }
810
+ })),
811
+ succeeded: group.message_ids.length,
812
+ failed: 0
813
+ }
814
+ };
815
+ }
816
+ return sendMediaBatchSequential((item) => this.sendMedia(item), input);
817
+ }
818
+ downloadFile(input) {
819
+ return this.#client.downloadFile({
820
+ file_id: input.file_id,
821
+ ...input.file_name && { file_name: input.file_name }
822
+ });
823
+ }
824
+ answerCallback(input) {
825
+ return this.#client.answerCallback({
826
+ callback_query_id: input.callback_query_id,
827
+ ...input.text && { text: input.text },
828
+ ...input.show_alert !== void 0 && { show_alert: input.show_alert }
829
+ });
830
+ }
831
+ async read(_input) {
832
+ warnUnsupportedMessagingOp("telegram", "read");
833
+ }
834
+ };
835
+ //#endregion
836
+ //#region src/modules/messaging/client.ts
837
+ /**
838
+ * Messaging seam client — picks telegram / slack / teams / imessage from host auth.
839
+ * Resolves ArtifactRef media via optional nested S3 storage before channel calls.
840
+ */
841
+ function transportOptions(ctx) {
842
+ return {
843
+ ...ctx.fetch && { fetch: ctx.fetch },
844
+ ...ctx.signal && { signal: ctx.signal }
845
+ };
846
+ }
847
+ function providerFor(auth, ctx) {
848
+ const options = transportOptions(ctx);
849
+ switch (auth.provider) {
850
+ case "telegram": return new TelegramMessagingProvider(auth, options);
851
+ case "slack": return new SlackMessagingProvider(auth, options);
852
+ case "teams": return new TeamsMessagingProvider(auth, options);
853
+ case "imessage": return new ImessageMessagingProvider(auth, options);
854
+ }
855
+ }
856
+ function storageFor(auth, ctx) {
857
+ if (!auth.storage) return void 0;
858
+ return new S3Client(auth.storage, transportOptions(ctx));
859
+ }
860
+ var MessagingClient = class MessagingClient {
861
+ #ops;
862
+ #storage;
863
+ #maxMediaBytes;
864
+ constructor(ops, storage, maxMediaBytes) {
865
+ this.#ops = ops;
866
+ this.#storage = storage;
867
+ this.#maxMediaBytes = maxMediaBytes;
868
+ }
869
+ static fromContext(ctx) {
870
+ const auth = requireAuth(ctx, messagingAuthSchema);
871
+ return new MessagingClient(providerFor(auth, ctx), storageFor(auth, ctx), mediaMaxBytesForProvider(auth.provider));
872
+ }
873
+ static fromAuth(auth, ctx = {}) {
874
+ return new MessagingClient(providerFor(auth, ctx), storageFor(auth, ctx), mediaMaxBytesForProvider(auth.provider));
875
+ }
876
+ sendText(input) {
877
+ return this.#ops.sendText(input);
878
+ }
879
+ editText(input) {
880
+ return this.#ops.editText(input);
881
+ }
882
+ sendChatAction(input) {
883
+ return this.#ops.sendChatAction(input);
884
+ }
885
+ stopTyping(input) {
886
+ return this.#ops.stopTyping(input);
887
+ }
888
+ setReaction(input) {
889
+ return this.#ops.setReaction(input);
890
+ }
891
+ clearReaction(input) {
892
+ return this.#ops.clearReaction(input);
893
+ }
894
+ async sendMedia(input) {
895
+ const resolved = await resolveSendMediaInput(input, this.#storage, this.#maxMediaBytes);
896
+ return this.#ops.sendMedia(resolved);
897
+ }
898
+ async sendMediaBatch(input) {
899
+ return resolveAndSendMediaBatch(input, this.#storage, this.#maxMediaBytes, (resolved) => this.#ops.sendMediaBatch(resolved));
900
+ }
901
+ async downloadFile(input) {
902
+ return finalizeDownloadOutput(await this.#ops.downloadFile(input), input.destination_key, this.#storage);
903
+ }
904
+ answerCallback(input) {
905
+ return this.#ops.answerCallback(input);
906
+ }
907
+ read(input) {
908
+ return this.#ops.read(input);
909
+ }
910
+ };
911
+ //#endregion
912
+ //#region src/modules/messaging/module.ts
913
+ const messagingSendTextTool = defineTool({
914
+ id: "messaging-send-text",
915
+ name: "messagingSendText",
916
+ description: "Send a text message on the bound messaging channel. Optional reply_to_message_id anchors a reply or thread. Returns message_id.",
917
+ inputSchema: messagingSendTextInputSchema,
918
+ outputSchema: messagingMessageOutputSchema,
919
+ sideEffect: "send",
920
+ runtime: "both",
921
+ execute: async (input, ctx) => MessagingClient.fromContext(ctx).sendText(input)
922
+ });
923
+ const messagingEditTextTool = defineTool({
924
+ id: "messaging-edit-text",
925
+ name: "messagingEditText",
926
+ description: "Edit the text of an existing message on the bound messaging channel.",
927
+ inputSchema: messagingEditTextInputSchema,
928
+ outputSchema: messagingMessageOutputSchema,
929
+ sideEffect: "write",
930
+ runtime: "both",
931
+ execute: async (input, ctx) => MessagingClient.fromContext(ctx).editText(input)
932
+ });
933
+ const messagingSendChatActionTool = defineTool({
934
+ id: "messaging-send-chat-action",
935
+ name: "messagingSendChatAction",
936
+ description: "Show a chat action on the conversation when supported (typing, upload_photo, upload_document, …). Optional reply_to_message_id anchors a thread when the channel uses thread-scoped status.",
937
+ inputSchema: messagingSendChatActionInputSchema,
938
+ outputSchema: messagingOkOutputSchema,
939
+ sideEffect: "none",
940
+ runtime: "both",
941
+ execute: async (input, ctx) => {
942
+ await MessagingClient.fromContext(ctx).sendChatAction(input);
943
+ return { ok: true };
944
+ }
945
+ });
946
+ const messagingStopTypingTool = defineTool({
947
+ id: "messaging-stop-typing",
948
+ name: "messagingStopTyping",
949
+ description: "Stop a typing or busy indicator on the conversation when supported. Optional reply_to_message_id clears thread-scoped status when the channel uses it.",
950
+ inputSchema: messagingStopTypingInputSchema,
951
+ outputSchema: messagingOkOutputSchema,
952
+ sideEffect: "none",
953
+ runtime: "both",
954
+ execute: async (input, ctx) => {
955
+ await MessagingClient.fromContext(ctx).stopTyping(input);
956
+ return { ok: true };
957
+ }
958
+ });
959
+ const messagingSetReactionTool = defineTool({
960
+ id: "messaging-set-reaction",
961
+ name: "messagingSetReaction",
962
+ description: "Set an emoji reaction on a message when supported. Returns optional message_id when the channel creates a separate reaction message — store it for clearReaction.",
963
+ inputSchema: messagingSetReactionInputSchema,
964
+ outputSchema: messagingReactionOutputSchema,
965
+ sideEffect: "write",
966
+ runtime: "both",
967
+ execute: async (input, ctx) => MessagingClient.fromContext(ctx).setReaction(input)
968
+ });
969
+ const messagingClearReactionTool = defineTool({
970
+ id: "messaging-clear-reaction",
971
+ name: "messagingClearReaction",
972
+ description: "Clear a reaction on a message when supported. Pass emoji when required. When setReaction returned a message_id, pass that id instead of the target message id.",
973
+ inputSchema: messagingClearReactionInputSchema,
974
+ outputSchema: messagingOkOutputSchema,
975
+ sideEffect: "write",
976
+ runtime: "both",
977
+ execute: async (input, ctx) => {
978
+ await MessagingClient.fromContext(ctx).clearReaction(input);
979
+ return { ok: true };
980
+ }
981
+ });
982
+ const messagingSendMediaTool = defineTool({
983
+ id: "messaging-send-media",
984
+ name: "messagingSendMedia",
985
+ description: "Send one photo or document on the bound messaging channel. Provide body_base64 for small payloads or source ArtifactRef (object store) for large files.",
986
+ inputSchema: messagingSendMediaInputSchema,
987
+ outputSchema: messagingMessageOutputSchema,
988
+ sideEffect: "send",
989
+ runtime: "both",
990
+ execute: async (input, ctx) => MessagingClient.fromContext(ctx).sendMedia(input)
991
+ });
992
+ const messagingSendMediaBatchTool = defineTool({
993
+ id: "messaging-send-media-batch",
994
+ name: "messagingSendMediaBatch",
995
+ description: "Send 1–10 media items in order (body_base64 or source ArtifactRef per item). May use a native album when all items share the same kind (2–10); otherwise sequential. Partial failures are reported per item.",
996
+ inputSchema: messagingSendMediaBatchInputSchema,
997
+ outputSchema: messagingSendMediaBatchOutputSchema,
998
+ sideEffect: "send",
999
+ runtime: "both",
1000
+ execute: async (input, ctx) => MessagingClient.fromContext(ctx).sendMediaBatch(input)
1001
+ });
1002
+ const messagingDownloadFileTool = defineTool({
1003
+ id: "messaging-download-file",
1004
+ name: "messagingDownloadFile",
1005
+ description: "Download a file by file_id (and optional chat_id / file_name). Returns body_base64 by default, or an ArtifactRef when destination_key is set (writes to bound object storage).",
1006
+ inputSchema: messagingDownloadFileInputSchema,
1007
+ outputSchema: messagingDownloadFileOutputSchema,
1008
+ sideEffect: "read",
1009
+ runtime: "both",
1010
+ execute: async (input, ctx) => MessagingClient.fromContext(ctx).downloadFile(input)
1011
+ });
1012
+ const messagingAnswerCallbackTool = defineTool({
1013
+ id: "messaging-answer-callback",
1014
+ name: "messagingAnswerCallback",
1015
+ description: "Acknowledge an inbound interactive callback when supported (toast, alert, or response URL).",
1016
+ inputSchema: messagingAnswerCallbackInputSchema,
1017
+ outputSchema: messagingOkOutputSchema,
1018
+ sideEffect: "write",
1019
+ runtime: "both",
1020
+ execute: async (input, ctx) => {
1021
+ await MessagingClient.fromContext(ctx).answerCallback(input);
1022
+ return { ok: true };
1023
+ }
1024
+ });
1025
+ const messagingReadTool = defineTool({
1026
+ id: "messaging-read",
1027
+ name: "messagingRead",
1028
+ description: "Mark conversation messages as read up to message_id when supported.",
1029
+ inputSchema: messagingReadInputSchema,
1030
+ outputSchema: messagingOkOutputSchema,
1031
+ sideEffect: "write",
1032
+ runtime: "both",
1033
+ execute: async (input, ctx) => {
1034
+ await MessagingClient.fromContext(ctx).read(input);
1035
+ return { ok: true };
1036
+ }
1037
+ });
1038
+ const messagingModule = defineModule({
1039
+ id: "messaging",
1040
+ title: "Messaging",
1041
+ description: "Send and edit text, media (single and batch), chat actions, reactions, file download, callback answers, and read on the bound messaging channel.",
1042
+ runtime: "both",
1043
+ auth: {
1044
+ type: "custom",
1045
+ schema: messagingAuthSchema
1046
+ },
1047
+ categories: ["messaging", "chat"],
1048
+ classification: "pii",
1049
+ tags: ["multi-provider"],
1050
+ tools: [
1051
+ messagingSendTextTool,
1052
+ messagingEditTextTool,
1053
+ messagingSendChatActionTool,
1054
+ messagingStopTypingTool,
1055
+ messagingSetReactionTool,
1056
+ messagingClearReactionTool,
1057
+ messagingSendMediaTool,
1058
+ messagingSendMediaBatchTool,
1059
+ messagingDownloadFileTool,
1060
+ messagingAnswerCallbackTool,
1061
+ messagingReadTool
1062
+ ]
1063
+ });
1064
+ //#endregion
1065
+ export { MAX_MESSAGING_MEDIA_BATCH, MessagingClient, createLiveMessage, createTypingPulse, isMessagingDefiniteRejection, isMessagingOutcomeUnknown, messagingAnswerCallbackInputSchema, messagingAnswerCallbackTool, messagingAuthSchema, messagingChatActionSchema, messagingClearReactionInputSchema, messagingClearReactionTool, messagingDownloadFileInputSchema, messagingDownloadFileOutputSchema, messagingDownloadFileTool, messagingEditTextInputSchema, messagingEditTextTool, messagingMessageOutputSchema, messagingModule, messagingOkOutputSchema, messagingReactionOutputSchema, messagingReadInputSchema, messagingReadTool, messagingSendChatActionInputSchema, messagingSendChatActionTool, messagingSendMediaBatchInputSchema, messagingSendMediaBatchItemSchema, messagingSendMediaBatchOutputSchema, messagingSendMediaBatchTool, messagingSendMediaInputSchema, messagingSendMediaTool, messagingSendTextInputSchema, messagingSendTextTool, messagingSetReactionInputSchema, messagingSetReactionTool, messagingStopTypingInputSchema, messagingStopTypingTool };
1066
+
1067
+ //# sourceMappingURL=index.js.map