@japofc/baileys 2.1.0

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/NOTICE.md +111 -0
  2. package/README.md +1254 -0
  3. package/WAProto/index.d.ts +9 -0
  4. package/WAProto/index.js +142276 -0
  5. package/engine-requirements.js +13 -0
  6. package/lib/Builders/A2UI.d.ts +242 -0
  7. package/lib/Builders/A2UI.js +308 -0
  8. package/lib/Builders/AIRich.d.ts +105 -0
  9. package/lib/Builders/AIRich.js +2286 -0
  10. package/lib/Builders/Button.d.ts +103 -0
  11. package/lib/Builders/Button.js +883 -0
  12. package/lib/Builders/ButtonV2.d.ts +28 -0
  13. package/lib/Builders/ButtonV2.js +144 -0
  14. package/lib/Builders/ButtonV3.d.ts +25 -0
  15. package/lib/Builders/ButtonV3.js +184 -0
  16. package/lib/Builders/Carousel.d.ts +22 -0
  17. package/lib/Builders/Carousel.js +111 -0
  18. package/lib/Builders/JapBaileys.d.ts +34 -0
  19. package/lib/Builders/JapBaileys.js +108 -0
  20. package/lib/Builders/Poll.d.ts +25 -0
  21. package/lib/Builders/Poll.js +128 -0
  22. package/lib/Builders/index.d.ts +17 -0
  23. package/lib/Builders/index.js +11 -0
  24. package/lib/Builders/shared.d.ts +67 -0
  25. package/lib/Builders/shared.js +652 -0
  26. package/lib/Defaults/index.d.ts +154 -0
  27. package/lib/Defaults/index.js +178 -0
  28. package/lib/Framework/Bot.d.ts +61 -0
  29. package/lib/Framework/Bot.js +248 -0
  30. package/lib/Framework/Context.d.ts +21 -0
  31. package/lib/Framework/Context.js +89 -0
  32. package/lib/Framework/MediaManager.d.ts +17 -0
  33. package/lib/Framework/MediaManager.js +151 -0
  34. package/lib/Framework/SessionManager.d.ts +13 -0
  35. package/lib/Framework/SessionManager.js +33 -0
  36. package/lib/Framework/StatsManager.d.ts +26 -0
  37. package/lib/Framework/StatsManager.js +119 -0
  38. package/lib/Framework/Store/SQLiteStore.d.ts +11 -0
  39. package/lib/Framework/Store/SQLiteStore.js +73 -0
  40. package/lib/Framework/index.d.ts +9 -0
  41. package/lib/Framework/index.js +10 -0
  42. package/lib/Signal/Group/ciphertext-message.d.ts +9 -0
  43. package/lib/Signal/Group/ciphertext-message.js +11 -0
  44. package/lib/Signal/Group/group-session-builder.d.ts +7 -0
  45. package/lib/Signal/Group/group-session-builder.js +29 -0
  46. package/lib/Signal/Group/group_cipher.d.ts +10 -0
  47. package/lib/Signal/Group/group_cipher.js +81 -0
  48. package/lib/Signal/Group/index.d.ts +11 -0
  49. package/lib/Signal/Group/index.js +11 -0
  50. package/lib/Signal/Group/keyhelper.d.ts +6 -0
  51. package/lib/Signal/Group/keyhelper.js +17 -0
  52. package/lib/Signal/Group/sender-chain-key.d.ts +13 -0
  53. package/lib/Signal/Group/sender-chain-key.js +25 -0
  54. package/lib/Signal/Group/sender-key-distribution-message.d.ts +16 -0
  55. package/lib/Signal/Group/sender-key-distribution-message.js +62 -0
  56. package/lib/Signal/Group/sender-key-message.d.ts +18 -0
  57. package/lib/Signal/Group/sender-key-message.js +65 -0
  58. package/lib/Signal/Group/sender-key-name.d.ts +11 -0
  59. package/lib/Signal/Group/sender-key-name.js +47 -0
  60. package/lib/Signal/Group/sender-key-record.d.ts +12 -0
  61. package/lib/Signal/Group/sender-key-record.js +40 -0
  62. package/lib/Signal/Group/sender-key-state.d.ts +16 -0
  63. package/lib/Signal/Group/sender-key-state.js +83 -0
  64. package/lib/Signal/Group/sender-message-key.d.ts +11 -0
  65. package/lib/Signal/Group/sender-message-key.js +25 -0
  66. package/lib/Signal/libsignal.d.ts +54 -0
  67. package/lib/Signal/libsignal.js +430 -0
  68. package/lib/Signal/lid-mapping.d.ts +20 -0
  69. package/lib/Signal/lid-mapping.js +276 -0
  70. package/lib/Socket/Client/index.d.ts +2 -0
  71. package/lib/Socket/Client/index.js +2 -0
  72. package/lib/Socket/Client/types.d.ts +5 -0
  73. package/lib/Socket/Client/types.js +10 -0
  74. package/lib/Socket/Client/websocket.d.ts +12 -0
  75. package/lib/Socket/Client/websocket.js +53 -0
  76. package/lib/Socket/business.d.ts +395 -0
  77. package/lib/Socket/business.js +379 -0
  78. package/lib/Socket/chats.d.ts +136 -0
  79. package/lib/Socket/chats.js +1327 -0
  80. package/lib/Socket/communities.d.ts +562 -0
  81. package/lib/Socket/communities.js +439 -0
  82. package/lib/Socket/dugong.d.ts +117 -0
  83. package/lib/Socket/dugong.js +798 -0
  84. package/lib/Socket/groups.d.ts +285 -0
  85. package/lib/Socket/groups.js +354 -0
  86. package/lib/Socket/index.d.ts +585 -0
  87. package/lib/Socket/index.js +52 -0
  88. package/lib/Socket/messages-recv.d.ts +333 -0
  89. package/lib/Socket/messages-recv.js +1781 -0
  90. package/lib/Socket/messages-send.d.ts +353 -0
  91. package/lib/Socket/messages-send.js +1524 -0
  92. package/lib/Socket/mex.d.ts +1 -0
  93. package/lib/Socket/mex.js +41 -0
  94. package/lib/Socket/newsletter.d.ts +286 -0
  95. package/lib/Socket/newsletter.js +364 -0
  96. package/lib/Socket/socket.d.ts +60 -0
  97. package/lib/Socket/socket.js +1012 -0
  98. package/lib/Socket/username.d.ts +82 -0
  99. package/lib/Socket/username.js +159 -0
  100. package/lib/Store/index.d.ts +3 -0
  101. package/lib/Store/index.js +3 -0
  102. package/lib/Store/make-in-memory-store.d.ts +62 -0
  103. package/lib/Store/make-in-memory-store.js +428 -0
  104. package/lib/Store/make-ordered-dictionary.d.ts +12 -0
  105. package/lib/Store/make-ordered-dictionary.js +78 -0
  106. package/lib/Store/object-repository.d.ts +10 -0
  107. package/lib/Store/object-repository.js +23 -0
  108. package/lib/Types/Auth.d.ts +117 -0
  109. package/lib/Types/Auth.js +1 -0
  110. package/lib/Types/Bussines.d.ts +25 -0
  111. package/lib/Types/Call.d.ts +15 -0
  112. package/lib/Types/Call.js +1 -0
  113. package/lib/Types/Chat.d.ts +124 -0
  114. package/lib/Types/Chat.js +7 -0
  115. package/lib/Types/Contact.d.ts +26 -0
  116. package/lib/Types/Contact.js +1 -0
  117. package/lib/Types/Events.d.ts +256 -0
  118. package/lib/Types/Events.js +1 -0
  119. package/lib/Types/GroupMetadata.d.ts +71 -0
  120. package/lib/Types/GroupMetadata.js +1 -0
  121. package/lib/Types/Label.d.ts +5 -0
  122. package/lib/Types/Label.js +24 -0
  123. package/lib/Types/LabelAssociation.d.ts +6 -0
  124. package/lib/Types/LabelAssociation.js +6 -0
  125. package/lib/Types/Message.d.ts +62 -0
  126. package/lib/Types/Message.js +17 -0
  127. package/lib/Types/Mex.d.ts +2 -0
  128. package/lib/Types/Mex.js +38 -0
  129. package/lib/Types/Product.d.ts +79 -0
  130. package/lib/Types/Product.js +1 -0
  131. package/lib/Types/RichType.d.ts +2 -0
  132. package/lib/Types/RichType.js +22 -0
  133. package/lib/Types/Signal.d.ts +87 -0
  134. package/lib/Types/Signal.js +1 -0
  135. package/lib/Types/Socket.d.ts +138 -0
  136. package/lib/Types/Socket.js +1 -0
  137. package/lib/Types/State.d.ts +8 -0
  138. package/lib/Types/State.js +55 -0
  139. package/lib/Types/USync.d.ts +26 -0
  140. package/lib/Types/index.d.ts +68 -0
  141. package/lib/Types/index.js +27 -0
  142. package/lib/Utils/MessageBuilder.d.ts +2 -0
  143. package/lib/Utils/MessageBuilder.js +2 -0
  144. package/lib/Utils/PersistentStore.d.ts +60 -0
  145. package/lib/Utils/PersistentStore.js +592 -0
  146. package/lib/Utils/anti-delete.d.ts +74 -0
  147. package/lib/Utils/anti-delete.js +221 -0
  148. package/lib/Utils/auth-secure.d.ts +86 -0
  149. package/lib/Utils/auth-secure.js +764 -0
  150. package/lib/Utils/auth-utils.d.ts +57 -0
  151. package/lib/Utils/auth-utils.js +306 -0
  152. package/lib/Utils/auto-reply.d.ts +47 -0
  153. package/lib/Utils/auto-reply.js +157 -0
  154. package/lib/Utils/baileys-event-stream.d.ts +8 -0
  155. package/lib/Utils/baileys-event-stream.js +62 -0
  156. package/lib/Utils/browser-utils.d.ts +8 -0
  157. package/lib/Utils/browser-utils.js +27 -0
  158. package/lib/Utils/business.d.ts +49 -0
  159. package/lib/Utils/business.js +239 -0
  160. package/lib/Utils/button-helper-utils.d.ts +53 -0
  161. package/lib/Utils/button-helper-utils.js +312 -0
  162. package/lib/Utils/button-sender.d.ts +54 -0
  163. package/lib/Utils/button-sender.js +822 -0
  164. package/lib/Utils/chat-control.d.ts +159 -0
  165. package/lib/Utils/chat-control.js +230 -0
  166. package/lib/Utils/chat-history-helpers.d.ts +21 -0
  167. package/lib/Utils/chat-history-helpers.js +70 -0
  168. package/lib/Utils/chat-utils.d.ts +407 -0
  169. package/lib/Utils/chat-utils.js +885 -0
  170. package/lib/Utils/companion-reg-client-utils.d.ts +4 -0
  171. package/lib/Utils/companion-reg-client-utils.js +39 -0
  172. package/lib/Utils/crypto.d.ts +41 -0
  173. package/lib/Utils/crypto.js +147 -0
  174. package/lib/Utils/decode-wa-message.d.ts +83 -0
  175. package/lib/Utils/decode-wa-message.js +316 -0
  176. package/lib/Utils/event-buffer.d.ts +12 -0
  177. package/lib/Utils/event-buffer.js +635 -0
  178. package/lib/Utils/generics.d.ts +69 -0
  179. package/lib/Utils/generics.js +438 -0
  180. package/lib/Utils/history-share.d.ts +11 -0
  181. package/lib/Utils/history-share.js +70 -0
  182. package/lib/Utils/history.d.ts +90 -0
  183. package/lib/Utils/history.js +146 -0
  184. package/lib/Utils/humanizer.d.ts +12 -0
  185. package/lib/Utils/humanizer.js +73 -0
  186. package/lib/Utils/identity-change-handler.d.ts +13 -0
  187. package/lib/Utils/identity-change-handler.js +49 -0
  188. package/lib/Utils/index.d.ts +57 -0
  189. package/lib/Utils/index.js +56 -0
  190. package/lib/Utils/jid-tools.d.ts +6 -0
  191. package/lib/Utils/jid-tools.js +77 -0
  192. package/lib/Utils/link-preview.d.ts +12 -0
  193. package/lib/Utils/link-preview.js +84 -0
  194. package/lib/Utils/logger.d.ts +4 -0
  195. package/lib/Utils/logger.js +2 -0
  196. package/lib/Utils/lt-hash.d.ts +12 -0
  197. package/lib/Utils/lt-hash.js +26 -0
  198. package/lib/Utils/make-mutex.d.ts +6 -0
  199. package/lib/Utils/make-mutex.js +32 -0
  200. package/lib/Utils/media-messages.d.ts +18 -0
  201. package/lib/Utils/media-messages.js +70 -0
  202. package/lib/Utils/media-set.d.ts +13 -0
  203. package/lib/Utils/media-set.js +171 -0
  204. package/lib/Utils/message-kind.d.ts +32 -0
  205. package/lib/Utils/message-kind.js +136 -0
  206. package/lib/Utils/message-retry-manager.d.ts +79 -0
  207. package/lib/Utils/message-retry-manager.js +264 -0
  208. package/lib/Utils/message-search.d.ts +44 -0
  209. package/lib/Utils/message-search.js +188 -0
  210. package/lib/Utils/messages-media.d.ts +135 -0
  211. package/lib/Utils/messages-media.js +868 -0
  212. package/lib/Utils/messages.d.ts +44 -0
  213. package/lib/Utils/messages.js +2326 -0
  214. package/lib/Utils/meta-ai.d.ts +13 -0
  215. package/lib/Utils/meta-ai.js +74 -0
  216. package/lib/Utils/mini-app.d.ts +35 -0
  217. package/lib/Utils/mini-app.js +213 -0
  218. package/lib/Utils/noise-handler.d.ts +20 -0
  219. package/lib/Utils/noise-handler.js +200 -0
  220. package/lib/Utils/offline-node-processor.d.ts +9 -0
  221. package/lib/Utils/offline-node-processor.js +39 -0
  222. package/lib/Utils/past-participants.d.ts +14 -0
  223. package/lib/Utils/past-participants.js +40 -0
  224. package/lib/Utils/pre-key-manager.d.ts +25 -0
  225. package/lib/Utils/pre-key-manager.js +105 -0
  226. package/lib/Utils/process-message.d.ts +82 -0
  227. package/lib/Utils/process-message.js +808 -0
  228. package/lib/Utils/qr-render.d.ts +59 -0
  229. package/lib/Utils/qr-render.js +179 -0
  230. package/lib/Utils/qrcodegen.d.ts +79 -0
  231. package/lib/Utils/qrcodegen.js +848 -0
  232. package/lib/Utils/reporting-utils.d.ts +12 -0
  233. package/lib/Utils/reporting-utils.js +257 -0
  234. package/lib/Utils/rich-message-utils.d.ts +48 -0
  235. package/lib/Utils/rich-message-utils.js +444 -0
  236. package/lib/Utils/router.d.ts +37 -0
  237. package/lib/Utils/router.js +165 -0
  238. package/lib/Utils/scheduled-posts.d.ts +30 -0
  239. package/lib/Utils/scheduled-posts.js +110 -0
  240. package/lib/Utils/scheduling.d.ts +42 -0
  241. package/lib/Utils/scheduling.js +139 -0
  242. package/lib/Utils/signal.d.ts +82 -0
  243. package/lib/Utils/signal.js +200 -0
  244. package/lib/Utils/stanza-ack.d.ts +16 -0
  245. package/lib/Utils/stanza-ack.js +37 -0
  246. package/lib/Utils/status.d.ts +50 -0
  247. package/lib/Utils/status.js +107 -0
  248. package/lib/Utils/stickerpack.d.ts +51 -0
  249. package/lib/Utils/stickerpack.js +274 -0
  250. package/lib/Utils/sync-action-utils.d.ts +2 -0
  251. package/lib/Utils/sync-action-utils.js +48 -0
  252. package/lib/Utils/tag.d.ts +12 -0
  253. package/lib/Utils/tag.js +44 -0
  254. package/lib/Utils/tc-token-utils.d.ts +29 -0
  255. package/lib/Utils/tc-token-utils.js +162 -0
  256. package/lib/Utils/templates.d.ts +76 -0
  257. package/lib/Utils/templates.js +150 -0
  258. package/lib/Utils/transcribe.d.ts +12 -0
  259. package/lib/Utils/transcribe.js +107 -0
  260. package/lib/Utils/use-cache-manager-auth-state.d.ts +13 -0
  261. package/lib/Utils/use-cache-manager-auth-state.js +81 -0
  262. package/lib/Utils/use-multi-file-auth-state.d.ts +10 -0
  263. package/lib/Utils/use-multi-file-auth-state.js +166 -0
  264. package/lib/Utils/use-single-file-auth-state.d.ts +10 -0
  265. package/lib/Utils/use-single-file-auth-state.js +113 -0
  266. package/lib/Utils/use-sqlite-auth-state.d.ts +11 -0
  267. package/lib/Utils/use-sqlite-auth-state.js +169 -0
  268. package/lib/Utils/validate-connection.d.ts +42 -0
  269. package/lib/Utils/validate-connection.js +198 -0
  270. package/lib/Utils/vcard.d.ts +58 -0
  271. package/lib/Utils/vcard.js +104 -0
  272. package/lib/Utils/voice-note.d.ts +15 -0
  273. package/lib/Utils/voice-note.js +63 -0
  274. package/lib/VoIP/audio-feeder.d.ts +18 -0
  275. package/lib/VoIP/audio-feeder.js +160 -0
  276. package/lib/VoIP/call-recorder.d.ts +13 -0
  277. package/lib/VoIP/call-recorder.js +73 -0
  278. package/lib/VoIP/index.d.ts +86 -0
  279. package/lib/VoIP/index.js +611 -0
  280. package/lib/VoIP/relay-transport.d.ts +43 -0
  281. package/lib/VoIP/relay-transport.js +563 -0
  282. package/lib/VoIP/signaling.d.ts +26 -0
  283. package/lib/VoIP/signaling.js +662 -0
  284. package/lib/VoIP/types.d.ts +69 -0
  285. package/lib/VoIP/types.js +17 -0
  286. package/lib/VoIP/wasm-engine.d.ts +120 -0
  287. package/lib/VoIP/wasm-engine.js +1358 -0
  288. package/lib/VoIP/worker-bootstrap.d.ts +4 -0
  289. package/lib/VoIP/worker-bootstrap.js +1046 -0
  290. package/lib/WABinary/constants.d.ts +61 -0
  291. package/lib/WABinary/constants.js +1466 -0
  292. package/lib/WABinary/decode.d.ts +9 -0
  293. package/lib/WABinary/decode.js +261 -0
  294. package/lib/WABinary/encode.d.ts +2 -0
  295. package/lib/WABinary/encode.js +219 -0
  296. package/lib/WABinary/generic-utils.d.ts +74 -0
  297. package/lib/WABinary/generic-utils.js +276 -0
  298. package/lib/WABinary/index.d.ts +5 -0
  299. package/lib/WABinary/index.js +5 -0
  300. package/lib/WABinary/jid-utils.d.ts +28 -0
  301. package/lib/WABinary/jid-utils.js +95 -0
  302. package/lib/WABinary/types.d.ts +19 -0
  303. package/lib/WABinary/types.js +1 -0
  304. package/lib/WAM/BinaryInfo.d.ts +7 -0
  305. package/lib/WAM/BinaryInfo.js +9 -0
  306. package/lib/WAM/constants.d.ts +34926 -0
  307. package/lib/WAM/constants.js +22852 -0
  308. package/lib/WAM/encode.d.ts +1 -0
  309. package/lib/WAM/encode.js +149 -0
  310. package/lib/WAM/index.d.ts +3 -0
  311. package/lib/WAM/index.js +3 -0
  312. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +36 -0
  313. package/lib/WAUSync/Protocols/USyncContactProtocol.js +51 -0
  314. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +29 -0
  315. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +62 -0
  316. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
  317. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +26 -0
  318. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
  319. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +37 -0
  320. package/lib/WAUSync/Protocols/USyncUsernameProtocol.d.ts +9 -0
  321. package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +24 -0
  322. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +38 -0
  323. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +50 -0
  324. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +14 -0
  325. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +28 -0
  326. package/lib/WAUSync/Protocols/index.d.ts +7 -0
  327. package/lib/WAUSync/Protocols/index.js +7 -0
  328. package/lib/WAUSync/USyncQuery.d.ts +20 -0
  329. package/lib/WAUSync/USyncQuery.js +121 -0
  330. package/lib/WAUSync/USyncUser.d.ts +16 -0
  331. package/lib/WAUSync/USyncUser.js +30 -0
  332. package/lib/WAUSync/index.d.ts +3 -0
  333. package/lib/WAUSync/index.js +3 -0
  334. package/lib/assets/wasm/loader.d.ts +5 -0
  335. package/lib/assets/wasm/loader.js +5 -0
  336. package/lib/assets/wasm/whatsapp.wasm +0 -0
  337. package/lib/assets/wasm/worker-modules.d.ts +5 -0
  338. package/lib/assets/wasm/worker-modules.js +273 -0
  339. package/lib/index.d.ts +18 -0
  340. package/lib/index.js +23 -0
  341. package/package.json +180 -0
  342. package/postinstall-banner.js +82 -0
@@ -0,0 +1,13 @@
1
+ const major = parseInt(
2
+ process.versions.node.split('.')[0],
3
+ 10
4
+ );
5
+
6
+ if (major < 20) {
7
+ console.error(
8
+ `\n❌ This package requires Node.js 20+ to run reliably.\n` +
9
+ ` You are using Node.js ${process.versions.node}.\n` +
10
+ ` Please upgrade to Node.js 20+ to proceed.\n`
11
+ );
12
+ process.exit(1);
13
+ }
@@ -0,0 +1,242 @@
1
+ /**
2
+ * A2UI/Bloks "basic" catalog node types — confirmed from captured traffic, not a
3
+ * public spec, so treat this as best-effort autocomplete rather than an
4
+ * exhaustive guarantee. `ref` is a builder-only tag (stripped before send) so
5
+ * another node can reference this one via `BloksRef`.
6
+ */
7
+ export interface BloksRef {
8
+ $ref: string;
9
+ }
10
+ export interface BloksNodeBase {
11
+ /** Builder-only tag so another node can reference this one via `{ $ref: ref }`. Stripped before send. */
12
+ ref?: string;
13
+ }
14
+ export interface ColumnRowNode extends BloksNodeBase {
15
+ component: 'Column' | 'Row';
16
+ weight?: number;
17
+ justify?: string;
18
+ children?: BloksNode[];
19
+ }
20
+ export interface TextNode extends BloksNodeBase {
21
+ component: 'Text';
22
+ text: string;
23
+ variant?: string;
24
+ }
25
+ export interface IconNode extends BloksNodeBase {
26
+ component: 'Icon';
27
+ name: string;
28
+ }
29
+ export interface DividerNode extends BloksNodeBase {
30
+ component: 'Divider';
31
+ }
32
+ export interface ImageNode extends BloksNodeBase {
33
+ component: 'Image';
34
+ url: string;
35
+ variant?: string;
36
+ fit?: string;
37
+ }
38
+ export interface VideoNode extends BloksNodeBase {
39
+ component: 'Video';
40
+ url: string;
41
+ }
42
+ export interface ListNode extends BloksNodeBase {
43
+ component: 'List';
44
+ children?: BloksNode[];
45
+ }
46
+ export interface TextFieldNode extends BloksNodeBase {
47
+ component: 'TextField';
48
+ label?: string;
49
+ value?: string;
50
+ variant?: string;
51
+ }
52
+ export interface DateTimeInputNode extends BloksNodeBase {
53
+ component: 'DateTimeInput';
54
+ label?: string;
55
+ value?: string;
56
+ enableDate?: boolean;
57
+ enableTime?: boolean;
58
+ }
59
+ export interface SliderNode extends BloksNodeBase {
60
+ component: 'Slider';
61
+ label?: string;
62
+ min?: number;
63
+ max?: number;
64
+ value?: number;
65
+ }
66
+ export interface SwitchNode extends BloksNodeBase {
67
+ component: 'Switch';
68
+ label?: string;
69
+ value?: boolean;
70
+ }
71
+ export interface CheckBoxNode extends BloksNodeBase {
72
+ component: 'CheckBox';
73
+ label?: string;
74
+ value?: boolean;
75
+ }
76
+ export interface ChoicePickerNode extends BloksNodeBase {
77
+ component: 'ChoicePicker';
78
+ label?: string;
79
+ variant?: string;
80
+ displayStyle?: string;
81
+ options?: Array<{ label: string; value: string }>;
82
+ value?: string;
83
+ }
84
+ /**
85
+ * Unlike the CTA/native-flow `Button` class elsewhere, an A2UI Button node has no
86
+ * `label`/`type`+`name` — its label comes from a nested `child` (usually a `Text` node), and
87
+ * tapping it fires `action.call` (with `action.args`), not a native-flow button name.
88
+ */
89
+ export interface BloksButtonNode extends BloksNodeBase {
90
+ component: 'Button';
91
+ child?: BloksNode;
92
+ variant?: string;
93
+ action?: { call: string; args?: Record<string, any> };
94
+ }
95
+ export interface ModalNode extends BloksNodeBase {
96
+ component: 'Modal';
97
+ trigger: string | BloksRef;
98
+ content: BloksNode | string | BloksRef;
99
+ }
100
+ export interface TabsNode extends BloksNodeBase {
101
+ component: 'Tabs';
102
+ tabs: Array<{ title: string; child: BloksNode }>;
103
+ }
104
+ export interface CardNode extends BloksNodeBase {
105
+ component: 'Card';
106
+ child?: BloksNode;
107
+ }
108
+ export interface ProgressBarNode extends BloksNodeBase {
109
+ component: 'ProgressBar';
110
+ value?: number;
111
+ min?: number;
112
+ max?: number;
113
+ variant?: string;
114
+ }
115
+ export interface AvatarNode extends BloksNodeBase {
116
+ component: 'Avatar';
117
+ url?: string;
118
+ variant?: string;
119
+ size?: number;
120
+ }
121
+ export interface BadgeNode extends BloksNodeBase {
122
+ component: 'Badge';
123
+ child?: string | BloksNode;
124
+ label?: string;
125
+ }
126
+ export interface SpacerNode extends BloksNodeBase {
127
+ component: 'Spacer';
128
+ height?: number;
129
+ }
130
+ export interface AudioPlayerNode extends BloksNodeBase {
131
+ component: 'AudioPlayer';
132
+ url: string;
133
+ description?: string;
134
+ }
135
+ /** Fallback for components not yet confirmed on the wire — still works at runtime, just no prop-level autocomplete. */
136
+ export interface AnyBloksNode extends BloksNodeBase {
137
+ component: string;
138
+ [key: string]: any;
139
+ }
140
+ export type BloksNode =
141
+ | ColumnRowNode
142
+ | TextNode
143
+ | IconNode
144
+ | DividerNode
145
+ | ImageNode
146
+ | VideoNode
147
+ | ListNode
148
+ | TextFieldNode
149
+ | DateTimeInputNode
150
+ | SliderNode
151
+ | SwitchNode
152
+ | CheckBoxNode
153
+ | ChoicePickerNode
154
+ | BloksButtonNode
155
+ | ModalNode
156
+ | TabsNode
157
+ | CardNode
158
+ | ProgressBarNode
159
+ | AvatarNode
160
+ | BadgeNode
161
+ | SpacerNode
162
+ | AudioPlayerNode
163
+ | AnyBloksNode;
164
+
165
+ export interface A2UIBuilderOptions {
166
+ catalogId?: string;
167
+ version?: string;
168
+ }
169
+
170
+ export interface A2UIBuildOptions {
171
+ uuid?: string;
172
+ surfaceId?: string;
173
+ type?: string;
174
+ wrapped?: boolean;
175
+ }
176
+
177
+ export interface A2UIBuildResult {
178
+ uuid: string;
179
+ data: string;
180
+ type: string;
181
+ }
182
+
183
+ export interface ListCardOptions {
184
+ title?: string;
185
+ items?: any[];
186
+ fallbackText?: string;
187
+ uuid?: string;
188
+ }
189
+
190
+ export interface SendA2UIWidgetOptions {
191
+ a2ui: A2UI;
192
+ bodyText?: string;
193
+ footer?: string;
194
+ buttons?: any[];
195
+ contextInfo?: Record<string, any>;
196
+ expiration?: number;
197
+ quoted?: any;
198
+ type?: string;
199
+ wrapped?: boolean;
200
+ singleScreen?: boolean;
201
+ header?: {
202
+ title?: string;
203
+ subtitle?: string;
204
+ image?: string | Buffer | { url: string };
205
+ video?: string | Buffer | { url: string };
206
+ document?: string | Buffer | { url: string };
207
+ };
208
+ }
209
+
210
+ /** Fluent A2UI/Bloks widget builder. All widget methods return `this`; refs validated at build(). */
211
+ export class A2UI {
212
+ constructor(options?: A2UIBuilderOptions);
213
+ text(text: string, options?: { id?: string; variant?: string }): this;
214
+ image(url: string, options?: { id?: string; variant?: string; fit?: string }): this;
215
+ video(url: string, options?: { id?: string }): this;
216
+ checkbox(label: string, options?: { id?: string; value?: boolean }): this;
217
+ textField(label: string, options?: { id?: string; variant?: string }): this;
218
+ button(childId: string, options?: { id?: string; variant?: string; action?: { call: string; args?: Record<string, any> } }): this;
219
+ card(childId: string, options?: { id?: string }): this;
220
+ modal(triggerId: string, contentId: string, options?: { id?: string }): this;
221
+ raw(component: string, props?: Record<string, any>, options?: { id?: string }): this;
222
+ column(children?: string[], options?: { id?: string }): this;
223
+ row(children?: string[], options?: { id?: string }): this;
224
+ divider(options?: { id?: string }): this;
225
+ slider(options?: { id?: string; value?: number; min?: number; max?: number; step?: number; label?: string }): this;
226
+ switch(label: string, options?: { id?: string; value?: boolean }): this;
227
+ list(children?: string[], options?: { id?: string }): this;
228
+ progressBar(value: number, options?: { id?: string; min?: number; max?: number; variant?: string }): this;
229
+ avatar(url: string, options?: { id?: string; variant?: string; size?: number }): this;
230
+ badge(childId: string, options?: { id?: string; label?: string }): this;
231
+ spacer(options?: { id?: string; height?: number }): this;
232
+ tabs(children?: string[], options?: { id?: string; activeTab?: number }): this;
233
+ choicePicker(label: string, options: Array<{ label: string; value: string }>, opts?: { id?: string; variant?: string; value?: string; displayStyle?: string; filterable?: boolean }): this;
234
+ root(children: string[]): this;
235
+ listCard(options?: ListCardOptions): this;
236
+ send(client: any, jid: string, opts?: Record<string, any>): Promise<any>;
237
+ /** Validates refs, then returns the serialised widget payload. Call root() first (unless listCard()). */
238
+ build(options?: A2UIBuildOptions): A2UIBuildResult;
239
+ }
240
+
241
+ /** Build + send an A2UI/Bloks widget as an interactiveMessage. */
242
+ export declare const sendA2UIWidget: (client: any, jid: string, options?: SendA2UIWidgetOptions) => Promise<any>;
@@ -0,0 +1,308 @@
1
+ /**
2
+ * lib/Builders/A2UI.js — A2UI (Bloks) widget builder + sender
3
+ *
4
+ * Part of @japofc/baileys. Builds the flat `components` array A2UI/Bloks
5
+ * expects (id-referencing tree: Column/Row hold `children`, Card/Button hold
6
+ * `child`, Modal holds `trigger`/`content`) and sends it as an
7
+ * `interactiveMessage.bloksWidget` via the same `getBizBinaryNode()` path
8
+ * Button/ButtonV2 use, so the wire-level <biz>/<native_flow> node always
9
+ * matches the actual button names sent — no more hand-rolled duplicate of
10
+ * that logic living outside the library.
11
+ *
12
+ * See MessageBuilder.js's `Button.setBloksWidget()` for the declarative
13
+ * (nested-tree) alternative to this imperative (id-returning-factory) API;
14
+ * both produce the same wire format and can be mixed freely.
15
+ */
16
+ "use strict";
17
+
18
+ import crypto from "crypto";
19
+ import { generateWAMessageFromContent, prepareWAMessageMedia } from "../Utils/messages.js";
20
+ import { getBizBinaryNode } from "../WABinary/index.js";
21
+
22
+ class A2UI {
23
+ constructor({ catalogId = "https://a2ui.org/specification/v0_9/catalogs/basic/catalog.json", version = "v0.9" } = {}) {
24
+ this._version = version;
25
+ this._catalogId = catalogId;
26
+ this._components = new Map();
27
+ this._counter = 0;
28
+ this._rootChildren = [];
29
+ }
30
+ #nextId(prefix) {
31
+ return `${prefix}_${(this._counter++).toString(36)}`;
32
+ }
33
+ #reg(id, component, extra = {}) {
34
+ id ??= this.#nextId(component.toLowerCase());
35
+ if (id === "root") throw new Error(`Component id "root" is reserved for the implicit root wrapper`);
36
+ if (this._components.has(id)) throw new Error(`Component id "${id}" already used`);
37
+ this._components.set(id, { id, component, ...extra });
38
+ return id;
39
+ }
40
+ text(text, { id, variant = "body" } = {}) {
41
+ return this.#reg(id, "Text", { text, variant });
42
+ }
43
+ image(url, { id, variant, fit = "cover" } = {}) {
44
+ return this.#reg(id, "Image", { url, ...(variant ? { variant } : {}), fit });
45
+ }
46
+ video(url, { id } = {}) {
47
+ return this.#reg(id, "Video", { url });
48
+ }
49
+ checkbox(label, { id, value = false } = {}) {
50
+ return this.#reg(id, "CheckBox", { label, value });
51
+ }
52
+ textField(label, { id, variant = "text" } = {}) {
53
+ return this.#reg(id, "TextField", { label, variant });
54
+ }
55
+ button(childId, { id, variant = "primary", action } = {}) {
56
+ if (!childId) throw new TypeError("button(childId) requires the id of a child component (e.g. from .text())");
57
+ return this.#reg(id, "Button", { child: childId, variant, ...(action ? { action } : {}) });
58
+ }
59
+ card(childId, { id } = {}) {
60
+ return this.#reg(id, "Card", { child: childId });
61
+ }
62
+ // trigger: id of the component that opens the modal (e.g. a Button); content: id of the
63
+ // component shown inside it. Both are ids of already-registered SIBLING components, not
64
+ // nested children — that's how the wire format expects Modal to reference them.
65
+ modal(triggerId, contentId, { id } = {}) {
66
+ if (!triggerId) throw new TypeError("modal(triggerId, contentId) requires the id of the trigger component");
67
+ if (!contentId) throw new TypeError("modal(triggerId, contentId) requires the id of the content component");
68
+ return this.#reg(id, "Modal", { trigger: triggerId, content: contentId });
69
+ }
70
+ // Escape hatch for any catalog component without a dedicated method yet (Divider, Slider,
71
+ // Switch, List, etc). props is merged as-is into the registered node.
72
+ raw(component, props = {}, { id } = {}) {
73
+ if (typeof component !== "string" || !component) throw new TypeError("raw(component, props) requires a non-empty component type string");
74
+ return this.#reg(id, component, props);
75
+ }
76
+ column(children = [], { id } = {}) {
77
+ if (!children.length) throw new TypeError("column(children) requires at least one child id");
78
+ return this.#reg(id, "Column", { children });
79
+ }
80
+ row(children = [], { id } = {}) {
81
+ if (!children.length) throw new TypeError("row(children) requires at least one child id");
82
+ return this.#reg(id, "Row", { children });
83
+ }
84
+ divider({ id } = {}) {
85
+ return this.#reg(id, "Divider", {});
86
+ }
87
+ // JAP@Add --- second-wave catalog components (all register via #reg, so
88
+ // build()-time ref validation + root()/build()/send() keep working unchanged)
89
+ slider({ id, value = 0, min = 0, max = 100, step = 1, label } = {}) {
90
+ return this.#reg(id, "Slider", { value, min, max, step, ...(label !== undefined ? { label } : {}) });
91
+ }
92
+ switch(label, { id, value = false } = {}) {
93
+ return this.#reg(id, "Switch", { label, value });
94
+ }
95
+ list(children = [], { id } = {}) {
96
+ if (!children.length) throw new TypeError("list(children) requires at least one child id");
97
+ return this.#reg(id, "List", { children });
98
+ }
99
+ progressBar(value, { id, min = 0, max = 100, variant = "linear" } = {}) {
100
+ if (typeof value !== "number") throw new TypeError("progressBar(value) requires a number");
101
+ return this.#reg(id, "ProgressBar", { value, min, max, variant });
102
+ }
103
+ avatar(url, { id, variant = "circle", size = 40 } = {}) {
104
+ if (!url) throw new TypeError("avatar(url) requires an image url");
105
+ return this.#reg(id, "Avatar", { url, variant, size });
106
+ }
107
+ badge(childId, { id, label } = {}) {
108
+ if (!childId) throw new TypeError("badge(childId) requires the id of a child component");
109
+ return this.#reg(id, "Badge", { child: childId, ...(label !== undefined ? { label } : {}) });
110
+ }
111
+ spacer({ id, height = 16 } = {}) {
112
+ return this.#reg(id, "Spacer", { height });
113
+ }
114
+ tabs(children = [], { id, activeTab = 0 } = {}) {
115
+ if (!children.length) throw new TypeError("tabs(children) requires at least one child id");
116
+ return this.#reg(id, "Tabs", { children, activeTab });
117
+ }
118
+ choicePicker(label, options, { id, variant = "mutuallyExclusive", value, displayStyle = "checkbox", filterable = false } = {}) {
119
+ if (!Array.isArray(options) || !options.length) {
120
+ throw new TypeError("choicePicker(label, options) requires a non-empty options array of {label, value}");
121
+ }
122
+ return this.#reg(id, "ChoicePicker", {
123
+ label,
124
+ variant,
125
+ ...(value !== undefined ? { value } : {}),
126
+ options,
127
+ displayStyle,
128
+ filterable
129
+ });
130
+ }
131
+ root(children) {
132
+ if (!Array.isArray(children) || !children.length) {
133
+ throw new TypeError("root(children) requires a non-empty array of top-level component ids");
134
+ }
135
+ this._rootChildren = children;
136
+ return this;
137
+ }
138
+ // JAP@Add 29-08-26 --- Product/list carousel card. This is a DIFFERENT wire
139
+ // payload shape from the Column/Row component-tree the rest of this class
140
+ // builds (type: 'list_card', flat items array) — not a catalog component, so
141
+ // it doesn't go through #reg()/root(). Call this instead of root()+build();
142
+ // build() returns the list_card payload directly when this was set.
143
+ listCard({ title, items, fallbackText, uuid = crypto.randomUUID() } = {}) {
144
+ if (!title) throw new TypeError("listCard requires a title");
145
+ if (!Array.isArray(items) || !items.length) {
146
+ throw new TypeError("listCard requires a non-empty items array");
147
+ }
148
+ this._listCardPayload = {
149
+ uuid,
150
+ data: JSON.stringify({
151
+ type: "list_card",
152
+ title,
153
+ fallback_text: fallbackText ?? "",
154
+ items: items.map((it) => ({
155
+ asset_id: it.assetId ?? crypto.randomUUID().replace(/-/g, "").slice(0, 17),
156
+ asset_type: it.assetType ?? "PRODUCT_ITEM",
157
+ title: it.title,
158
+ trailing_label: it.price ?? it.trailingLabel ?? "",
159
+ trailing_emphasis: it.emphasis ?? "strong"
160
+ }))
161
+ }),
162
+ type: "im_a2ui",
163
+ fallback: fallbackText ?? ""
164
+ };
165
+ return this;
166
+ }
167
+ // JAP@Add 30-08-26 --- send(): terminal method so A2UI can be used as a one-liner like
168
+ // the other builders (Button/ButtonV2/AIRich `.send()`), instead of always needing the
169
+ // separate `sendA2UIWidget()` call. Thin wrapper only — root([...ids])/listCard() must
170
+ // still be called first, same as before build(); this doesn't change the id-returning
171
+ // factory API (child methods still return ids, not `this`, since sibling nodes need to
172
+ // reference each other by id when wiring children/trigger/content).
173
+ async send(client, jid, opts = {}) {
174
+ return sendA2UIWidget(client, jid, { ...opts, a2ui: this });
175
+ }
176
+ // JAP@Add 30-08-26 --- validates that every structural id-reference (child/children on
177
+ // Button/Card/Column/Row, trigger/content on Modal) points at a component that was
178
+ // actually registered. Without this, a typo'd id just gets written into the wire payload
179
+ // as-is and the failure only surfaces as a broken/blank widget on the WA client, with no
180
+ // error on this end. Only covers the dedicated methods' known reference keys — raw()'s
181
+ // free-form props aren't inspected, since there's no way to know which of those are id
182
+ // references vs plain data.
183
+ #validateRefs(components) {
184
+ const validIds = new Set(components.map((c) => c.id));
185
+ for (const c of components) {
186
+ for (const key of ["child", "trigger", "content"]) {
187
+ if (c[key] !== undefined && !validIds.has(c[key])) {
188
+ throw new Error(`A2UI: component "${c.id}" (${c.component}) references unknown id "${c[key]}" via "${key}"`);
189
+ }
190
+ }
191
+ if (Array.isArray(c.children)) {
192
+ for (const childId of c.children) {
193
+ if (!validIds.has(childId)) {
194
+ throw new Error(`A2UI: component "${c.id}" (${c.component}) references unknown id "${childId}" in "children"`);
195
+ }
196
+ }
197
+ }
198
+ }
199
+ }
200
+ build({ uuid = crypto.randomUUID(), surfaceId, type = "im_a2ui", wrapped = true } = {}) {
201
+ if (this._listCardPayload) return this._listCardPayload;
202
+ if (!this._rootChildren.length) throw new Error("Call root([...ids]) before build()");
203
+ const root = { id: "root", component: "Column", children: this._rootChildren };
204
+ const components = [root, ...this._components.values()];
205
+ this.#validateRefs(components);
206
+ const data = wrapped
207
+ ? {
208
+ version: this._version,
209
+ createSurface: {
210
+ surfaceId: surfaceId ?? `starcore-widget=${uuid}`,
211
+ catalogId: this._catalogId,
212
+ components
213
+ }
214
+ }
215
+ : { components };
216
+ return {
217
+ uuid,
218
+ data: JSON.stringify(data),
219
+ type
220
+ };
221
+ }
222
+ }
223
+
224
+ /**
225
+ * Build + send an A2UI/Bloks widget as an interactiveMessage.
226
+ * @param {import('../../WAProto/index.js').WASocket} client Active Baileys socket.
227
+ * @param {string} jid Destination chat/group jid.
228
+ */
229
+ async function sendA2UIWidget(client, jid, {
230
+ a2ui,
231
+ bodyText = "",
232
+ footer = "",
233
+ buttons = [],
234
+ contextInfo = {},
235
+ expiration,
236
+ quoted,
237
+ type = "im_a2ui",
238
+ wrapped = true,
239
+ singleScreen = false,
240
+ // JAP@Add 30-08-26 --- optional header media, mirroring Button/ButtonV2's toCard()
241
+ // pattern (prepareWAMessageMedia + client.waUploadToServer). { title, subtitle, image
242
+ // | video | document: path/buffer/{url} } — media is mutually exclusive, image wins if
243
+ // more than one is passed. Falls back to a title/subtitle-only header (no attachment)
244
+ // when no media is given, same shape as before this change.
245
+ header
246
+ } = {}) {
247
+ if (!client) throw new Error("Socket is required");
248
+ if (!(a2ui instanceof A2UI)) throw new TypeError("a2ui must be an A2UI instance");
249
+
250
+ const nativeFlowMessage = buttons && buttons.length
251
+ ? {
252
+ buttons: buttons.map((b) => ({
253
+ name: b.name ?? "cta_url",
254
+ buttonParamsJson: typeof b.params === "string" ? b.params : JSON.stringify(b.params ?? {}),
255
+ })),
256
+ messageParamsJson: "{}",
257
+ messageVersion: 1
258
+ }
259
+ : { messageParamsJson: "" };
260
+
261
+ const headerMediaData = header?.image
262
+ ? { image: header.image }
263
+ : header?.video
264
+ ? { video: header.video }
265
+ : header?.document
266
+ ? { document: header.document }
267
+ : null;
268
+
269
+ const headerBlock = {
270
+ ...(header?.title !== undefined ? { title: header.title } : {}),
271
+ ...(header?.subtitle !== undefined ? { subtitle: header.subtitle } : {}),
272
+ hasMediaAttachment: !!headerMediaData,
273
+ ...(headerMediaData
274
+ ? await prepareWAMessageMedia(headerMediaData, { upload: client.waUploadToServer }).catch((e) => {
275
+ if (String(e).includes("Invalid media type")) return headerMediaData;
276
+ throw e;
277
+ })
278
+ : {})
279
+ };
280
+
281
+ const interactiveMessage = singleScreen
282
+ ? {
283
+ nativeFlowMessage,
284
+ bloksWidget: a2ui.build({ type, wrapped }),
285
+ ...(expiration || Object.keys(contextInfo).length ? { contextInfo: { ...(expiration ? { expiration } : {}), ...contextInfo } } : {})
286
+ }
287
+ : {
288
+ header: headerBlock,
289
+ body: { text: bodyText },
290
+ ...(footer ? { footer: { text: footer } } : {}),
291
+ nativeFlowMessage,
292
+ bloksWidget: a2ui.build({ type, wrapped }),
293
+ ...(expiration || Object.keys(contextInfo).length ? { contextInfo: { ...(expiration ? { expiration } : {}), ...contextInfo } } : {})
294
+ };
295
+
296
+ const msg = generateWAMessageFromContent(jid, {
297
+ messageContextInfo: { messageSecret: crypto.randomBytes(32) },
298
+ interactiveMessage
299
+ }, { quoted });
300
+
301
+ await client.relayMessage(msg.key.remoteJid, msg.message, {
302
+ messageId: msg.key.id,
303
+ additionalNodes: [getBizBinaryNode(msg.message)]
304
+ });
305
+ return msg;
306
+ }
307
+
308
+ export { A2UI, sendA2UIWidget };
@@ -0,0 +1,105 @@
1
+ import type { BaseBuilder } from './shared.js';
2
+
3
+ export interface AddTextOptions {
4
+ hyperlink?: boolean;
5
+ citation?: boolean;
6
+ latex?: boolean;
7
+ }
8
+
9
+ export interface AddInlineImageOptions {
10
+ text?: string;
11
+ alignment?: string;
12
+ tapLinkUrl?: string;
13
+ resolveUrl?: boolean;
14
+ }
15
+
16
+ export interface AIRichBuildOptions {
17
+ forwarded?: boolean;
18
+ notification?: boolean;
19
+ includesUnifiedResponse?: boolean;
20
+ includesSubmessages?: boolean;
21
+ quoted?: any;
22
+ quotedParticipant?: string;
23
+ [key: string]: any;
24
+ }
25
+
26
+ export interface AIRichSendOptions extends AIRichBuildOptions {
27
+ skipImageFallback?: boolean;
28
+ messageId?: string;
29
+ }
30
+
31
+ export interface AIRichEditOptions {
32
+ msg?: any;
33
+ messageId?: string;
34
+ additionalNodes?: any[];
35
+ [key: string]: any;
36
+ }
37
+
38
+ /** AI rich-response builder (Meta AI / GenAI message primitives). */
39
+ export class AIRich extends BaseBuilder {
40
+ constructor(client: any);
41
+ addSubmessage(submessage: Record<string, any>): this;
42
+ addSection(section: Record<string, any>): this;
43
+ addText(text: string, options?: AddTextOptions): this;
44
+ addCode(language: string, code: string): this;
45
+ addTable(table: string[][], options?: AddTextOptions): this;
46
+ addLinks(links?: Record<string, any>[]): this;
47
+ addContentItems(items?: Record<string, any>[]): this;
48
+ addInlineVideo(): this;
49
+ addSource(sources?: Record<string, any>[], options?: { resolveUrl?: boolean }): this;
50
+ addReels(reelsItems?: Record<string, any>[], options?: { resolveUrl?: boolean }): this;
51
+ addImage(imageUrl: string, options?: { resolveUrl?: boolean; instant?: boolean }): this;
52
+ addInlineImage(imageUrl: string, options?: AddInlineImageOptions): this;
53
+ addVideo(videoUrl: string, options?: { autoFill?: boolean; resolveUrl?: boolean }): this;
54
+ addProduct(data?: Record<string, any>, options?: { resolveUrl?: boolean }): this;
55
+ addPost(data?: Record<string, any>, options?: { resolveUrl?: boolean }): this;
56
+ addTip(text: string): this;
57
+ addMetadata(text: string): this;
58
+ setResponseId(id: string): this;
59
+ refreshResponseId(): this;
60
+ setBotResponseId(id: string): this;
61
+ refreshBotResponseId(): this;
62
+ hasId(id: string): boolean;
63
+ getIds(): string[];
64
+ peek(id: string): { id: string; sections: any[]; submessages: any[] } | null;
65
+ delete(id: string): this;
66
+ /** FOATextPrimitive — large heading text, distinct from addText()'s paragraph text. */
67
+ addHeading(text: string): this;
68
+ /** GenAI3PExtWidgetPrimitive — experimental, reverse-engineered; see JSDoc in the .js file for caveats. */
69
+ addWidget(data: Record<string, any> | Record<string, any>[], options?: { layout?: 'Single' | 'HScroll' | 'ActionRow' | string }): this;
70
+ /** GenAIFooterActionPrimitive — footer action link chips (e.g. "Join our Group"). */
71
+ addFooterAction(actions: { text: string; url: string; type?: string } | { text: string; url: string; type?: string }[]): this;
72
+ /** GenAIDividerPrimitive — plain horizontal line, no content. */
73
+ addDivider(): this;
74
+ /** GenAISpacerPrimitive — blank vertical spacing. */
75
+ addSpacer(spacing?: number): this;
76
+ /** GenAILatexUXPrimitive — has a real AI_RICH_RESPONSE_LATEX submessage (unlike most primitives here). */
77
+ addLatex(expression: string): this;
78
+ /** GenAITaskPrimitive — task/checklist card. */
79
+ addTask(data: { task_id?: string; title: string; subtitle?: string; status?: string; textFallback?: boolean }): this;
80
+ /** GenAIBotProgressStatusPrimitive — one-shot "searching/working" status chip. */
81
+ addProgressStatus(title: string, options?: { icon?: string; is_in_progress?: boolean; target_secondary_screen_id?: string; target_secondary_screen_tab_id?: string }): this;
82
+ /** GenAIBotThinkingStatusPrimitive — one-shot "thinking" status chip. */
83
+ addThinkingStatus(title: string, options?: { icon?: string; is_in_progress?: boolean; target_secondary_screen_id?: string; target_secondary_screen_tab_id?: string; textFallback?: boolean }): this;
84
+ /** GenAIMetaSubsQuotaUpsellPrimitive — subscription-quota-limit upsell card. */
85
+ addQuotaUpsell(data: { title: string; body?: string; body_line1?: string; body_line2?: string; buttons?: { label: string; action?: string; deeplink?: string }[] }): this;
86
+ /** FOABloksPrimitive — raw Bloks payload; most experimental primitive, fields passed through as-is. */
87
+ addBloks(data: { type: string; data?: string; uuid?: string; initial_response?: any; versioning_id?: string; textFallback?: boolean }): this;
88
+ addSuggest(suggestion: Record<string, any>, options?: { scroll?: boolean; layout?: string }): this;
89
+ /** GenAIImaginePrimitive with status GENERATING — pending-generation placeholder, distinct from addImage()/addVideo()'s READY status. */
90
+ addGenerating(options?: { imagine_type?: 'IMAGE' | 'ANIMATE'; estimated_completion_time?: number; textFallback?: boolean }): this;
91
+ build(options?: AIRichBuildOptions): Promise<Record<string, any>>;
92
+ send(jid: string, options?: AIRichSendOptions): Promise<any>;
93
+ buildEdit(targetJid: string, targetId: string, options?: AIRichEditOptions): Promise<any>;
94
+ sendEdit(jid: string, id: string, options?: AIRichEditOptions): Promise<any>;
95
+ static tokenizer(code: string, lang?: string): Record<string, any>;
96
+ static toTableMetadata(arr: string[][], options?: AddTextOptions): Record<string, any>;
97
+ static newLayout(name: string, data: Record<string, any> | Record<string, any>[], extra?: Record<string, any>): Record<string, any>;
98
+ /** Send a support-ticket marker message (messageContextInfo.supportPayload). */
99
+ static sendSupportPayload(client: any, jid: string, text: string, options?: { ticketId?: string; isAiMessage?: boolean; shouldShowSystemMessage?: boolean; version?: number }): Promise<any>;
100
+ /** Send an image + video as one paired-media unit (messageAssociation). */
101
+ static sendPairedMedia(client: any, jid: string, media: { image: string | Buffer; video: string | Buffer }): Promise<any>;
102
+ }
103
+
104
+ /** `class ORich extends AIRich {}` — plain re-export alias, no additional members. */
105
+ export class ORich extends AIRich {}