plogme 2.0.2 → 2.0.4

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.
package/README.md CHANGED
@@ -291,29 +291,68 @@ await sock.sendMessage(jid, {
291
291
 
292
292
  ### Albums
293
293
 
294
- Use at least two image or video items. Albums are sent as a parent message followed by separately encrypted media children.
294
+ Albums now use an AIRich vertical unified-response layout. Provide at least two image or video items; the client receives one forwarded rich message with one large media item per row, matching WhatsApp's full-width stacked album presentation. The old `albumMessage` parent/child collection and compact thumbnail grid are no longer generated by `sendAlbumMessage()`.
295
295
 
296
296
  ```js
297
297
  await sock.sendAlbumMessage(jid, [
298
- { type: 'image', data: { url: './one.jpg' } },
299
- { type: 'image', data: { url: './two.jpg' } }
300
- ], {
301
- caption: 'Trip photos'
302
- })
298
+ { type: 'image', data: { url: 'https://example.com/one.jpg', width: 1200, height: 800 } },
299
+ {
300
+ image: {
301
+ sourceUrl: 'https://example.com/two-preview.jpg',
302
+ imageHighResUrl: 'https://example.com/two.jpg',
303
+ darkModePreviewUrl: 'https://example.com/two-dark-preview.jpg',
304
+ darkModeHighResUrl: 'https://example.com/two-dark.jpg',
305
+ width: 1200,
306
+ height: 800
307
+ }
308
+ },
309
+ {
310
+ type: 'video',
311
+ data: {
312
+ url: 'https://example.com/three.mp4',
313
+ mimeType: 'video/mp4',
314
+ duration: 12,
315
+ thumbnailUrl: 'https://example.com/three.jpg'
316
+ }
317
+ }
318
+ ])
303
319
  ```
304
320
 
305
- The general `sendMessage` album form is also supported:
321
+ The general `sendMessage` album form delegates to the same full-width vertical album implementation:
306
322
 
307
323
  ```js
308
324
  await sock.sendMessage(jid, {
309
325
  album: [
310
- { image: { url: './one.jpg' }, caption: 'First' },
311
- { video: { url: './clip.mp4' }, caption: 'Second' }
326
+ { image: { url: 'https://example.com/one.jpg' } },
327
+ { image: { url: 'https://example.com/two.jpg' } }
312
328
  ]
313
329
  })
314
330
  ```
315
331
 
316
- Rich-response and bot-forwarded messages cannot be nested as album children. Send them as separate messages.
332
+ `sendAlbumMessage()` accepts fetchable image and video URLs. Local `Buffer`/file inputs are not uploaded by this rich album API. The lower-level `prepareGridImageMessage()` helper remains available when a compact `GRID_IMAGE` layout is specifically required; `sendAlbumMessage()` itself uses the larger `GenAIVStackLayoutViewModel` presentation.
333
+
334
+ ### Video grids
335
+
336
+ Video grids use the supported `GenAIVideoPrimitive` inside a unified-response `GenAIGridLayoutViewModel`. They are exposed separately from `sendAlbumMessage()` because WhatsApp's protobuf does not define a `GRID_VIDEO` submessage type. Provide at least two publicly fetchable video URLs:
337
+
338
+ ```js
339
+ await sock.sendVideoGridMessage(jid, [
340
+ {
341
+ url: 'https://example.com/first.mp4',
342
+ title: 'First clip',
343
+ thumbnailUrl: 'https://example.com/first.jpg',
344
+ progressiveUrls: ['https://cdn.example.com/first-720p.mp4']
345
+ },
346
+ {
347
+ url: 'https://example.com/second.mp4',
348
+ title: 'Second clip',
349
+ thumbnailUrl: 'https://example.com/second.jpg',
350
+ progressiveUrls: ['https://cdn.example.com/second-720p.mp4']
351
+ }
352
+ ])
353
+ ```
354
+
355
+ The video-grid API is intentionally URL-based; it does not upload local buffers or files. `sendVideoGridMessage()` also uses the rich-message edit relay, so supported clients receive the unified response without an initial Download-only placeholder.
317
356
 
318
357
  ## Interactive messages
319
358
 
@@ -475,6 +514,116 @@ await sock.sendRichAIResponse(jid, {
475
514
 
476
515
  `sendRichAIResponse` also accepts `list`, `codeBlock`, and `latex` content objects. For a pre-existing Meta AI response, `captureAndResendUnifiedResponse(jid, message, quoted)` captures and resends its unified response.
477
516
 
517
+ ### One unified Plogme response
518
+
519
+ Use `sendPlogmeMessage` when a response may contain several optional sections. It combines every section that is present into one AIRich `unifiedResponse`; omitted sections are ignored, so callers do not need to construct a different payload for every result shape.
520
+
521
+ ```js
522
+ const result = await sock.sendPlogmeMessage(jid, {
523
+ headerText: 'CODY AI result',
524
+ contentText: 'The deployment completed successfully.',
525
+
526
+ // Optional highlighted code section.
527
+ code: 'const status = "online"',
528
+ language: 'javascript',
529
+
530
+ // Optional table section. The first row is treated as the heading by default.
531
+ title: 'Service status',
532
+ table: [
533
+ ['Service', 'State'],
534
+ ['API', 'Online'],
535
+ ['Worker', 'Online']
536
+ ],
537
+ noHeading: false,
538
+
539
+ // Optional carousel/content items or reels.
540
+ items: [
541
+ { title: 'API documentation', url: 'https://example.com/docs' }
542
+ ],
543
+ reels: [
544
+ {
545
+ title: 'Release notes',
546
+ url: 'https://example.com/release.mp4',
547
+ thumbnail_url: 'https://example.com/release.jpg'
548
+ }
549
+ ],
550
+
551
+ // Optional inline media and LaTeX sections.
552
+ inlineImage: 'https://example.com/status.jpg',
553
+ imageText: 'Deployment status',
554
+ alignment: 2,
555
+ latex: [
556
+ { latexExpression: 'E = mc^2', url: 'https://example.com/equation.png' }
557
+ ],
558
+
559
+ // Optional citation links.
560
+ links: [
561
+ {
562
+ text: 'Open the deployment logs',
563
+ url: 'https://example.com/logs',
564
+ title: 'Deployment logs',
565
+ displayName: 'Logs'
566
+ }
567
+ ],
568
+
569
+ // Optional AIRich product card (object = Single layout; array = HScroll).
570
+ products: {
571
+ title: 'CODY AI hosting',
572
+ brand: 'Plogme',
573
+ price: '$10',
574
+ sale_price: '$7',
575
+ url: 'https://example.com/product',
576
+ image: 'https://example.com/product.jpg'
577
+ },
578
+
579
+ // Optional social-post cards (always HScroll).
580
+ posts: [{
581
+ title: 'Release announcement',
582
+ username: 'codyai',
583
+ profile: 'https://example.com/profile.jpg',
584
+ thumbnail: 'https://example.com/post.jpg',
585
+ caption: 'Deployment completed.',
586
+ url: 'https://example.com/post',
587
+ source: 'INSTAGRAM',
588
+ verified: true
589
+ }],
590
+
591
+ // Optional source cards: [favicon URL, source URL, display text].
592
+ sources: [[
593
+ 'https://example.com/favicon.jpg',
594
+ 'https://example.com/docs',
595
+ 'Documentation'
596
+ ]],
597
+
598
+ // Optional playable video card. Metadata may be supplied manually.
599
+ inlineVideo: {
600
+ url: 'https://example.com/clip.mp4',
601
+ mimeType: 'video/mp4',
602
+ duration: 12,
603
+ fileLength: 123456
604
+ },
605
+ suggested: true,
606
+ footerText: 'Generated by CODY AI'
607
+ }, undefined, {
608
+ // The compatibility relay is enabled by default. It sends the rich
609
+ // envelope normally, then uses WhatsApp's type-14 edit protocol so
610
+ // compatible clients render it immediately instead of showing Download.
611
+ renderRichResponse: true
612
+ })
613
+
614
+ console.log('Sent message:', result.key.id)
615
+ ```
616
+
617
+ Every field in the example is optional. A minimal response is valid as well:
618
+
619
+ ```js
620
+ await sock.sendPlogmeMessage(jid, {
621
+ contentText: 'Only the text section is available right now.'
622
+ })
623
+ ```
624
+
625
+ The compatibility edit can be disabled for a specific send with `{ renderRichResponse: false }`. This sends the generated rich envelope once without the follow-up edit.
626
+
478
627
  ## Rich menus, reels, and grids
479
628
 
480
629
  ### Original Gen4 rich menu
@@ -500,6 +649,53 @@ await sock.richMenu(jid, {
500
649
  })
501
650
  ```
502
651
 
652
+ ### Large A2UI command card
653
+
654
+ Use `sendA2UICommandMenu` for the full-size card layout with an uploaded image header, a command/function table, URL buttons, and a native-flow command selector. This is an `interactiveMessage`/A2UI payload, not an AIRich `unifiedResponse`, so it is intentionally separate from `sendPlogmeMessage` and `richMenu`.
655
+
656
+ ```js
657
+ await sock.sendA2UICommandMenu(jid, {
658
+ image: 'https://example.com/cover.jpg',
659
+ title: 'CODY AI',
660
+ rows: [
661
+ ['.meid', 'Check ID'],
662
+ ['.fromid', 'Check Source'],
663
+ ['.ping', 'Check Speed']
664
+ ],
665
+ buttons: [
666
+ { text: '1st-Channel', url: 'https://example.com/first' },
667
+ { text: '2nd-Channel', url: 'https://example.com/second' }
668
+ ]
669
+ })
670
+ ```
671
+
672
+ The image URL is uploaded as the interactive header media. Rows are also available through the native-flow `single_select` menu, and button URLs are represented as A2UI `openUrl` actions.
673
+
674
+ ### Screenshot-style raw AIRich command card
675
+
676
+ Use `sendAIRichCommandMenu` when you want the manually serialized AIRich variant: an image primitive, widget CTAs, Markdown text with optional LaTeX inline metadata, a command table, and footer URL actions. Unlike A2UI, this path is an AIRich unified response and therefore uses the normal relay plus type-14 immediate-render edit.
677
+
678
+ ```js
679
+ await sock.sendAIRichCommandMenu(jid, {
680
+ image: 'https://example.com/cover.jpg',
681
+ title: 'CODY AI',
682
+ subtitle: 'Command List',
683
+ code: 'CODY AI',
684
+ rows: [
685
+ ['.meid', 'Check ID'],
686
+ ['.fromid', 'Check Source'],
687
+ ['.ping', 'Check Speed']
688
+ ],
689
+ latexImage: 'https://example.com/logo.png',
690
+ latexExpression: 'CODY',
691
+ buttons: [
692
+ { text: '1st-Channel', url: 'https://example.com/first' },
693
+ { text: '2nd-Channel', url: 'https://example.com/second' }
694
+ ],
695
+ footer: 'Developed by - CODY AI'
696
+ })
697
+ ```
698
+
503
699
  Cards and carousel layout are supported:
504
700
 
505
701
  ```js