@cometchat/chat-sdk-javascript 4.1.11 → 4.1.13

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/CometChat.d.ts CHANGED
@@ -23,6 +23,9 @@ export class CometChat {
23
23
  static AIAssistantToolEndedEvent: typeof AIAssistantToolEndedEvent;
24
24
  static AIAssistantToolArgumentEvent: typeof AIAssistantToolArgumentEvent;
25
25
  static AIAssistantToolResultEvent: typeof AIAssistantToolResultEvent;
26
+ static AIAssistantCardStartedEvent: typeof AIAssistantCardStartedEvent;
27
+ static AIAssistantCardReceivedEvent: typeof AIAssistantCardReceivedEvent;
28
+ static AIAssistantCardEndedEvent: typeof AIAssistantCardEndedEvent;
26
29
  static AI_ASSISTANT_EVENTS: {
27
30
  RUN_STARTED: string;
28
31
  RUN_FINISHED: string;
@@ -33,6 +36,9 @@ export class CometChat {
33
36
  TOOL_CALL_ENDED: string;
34
37
  TOOL_CALL_RESULT: string;
35
38
  TOOL_CALL_ARGUMENT: string;
39
+ CARD_START: string;
40
+ CARD: string;
41
+ CARD_END: string;
36
42
  };
37
43
  static GroupType: typeof GroupType;
38
44
  static GroupMemberScope: typeof GroupMemberScope;
@@ -338,6 +344,7 @@ export class CometChat {
338
344
  CUSTOM: string;
339
345
  INTERACTIVE: string;
340
346
  AGENTIC: string;
347
+ CARD: string;
341
348
  };
342
349
  RECEIVER_TYPE: {
343
350
  USER: string;
@@ -383,6 +390,9 @@ export class CometChat {
383
390
  TOOL_CALL_ID: string;
384
391
  DISPLAY_NAME: string;
385
392
  EXECUTION_TEXT: string;
393
+ CARD: string;
394
+ CARD_ID: string;
395
+ ELEMENTS: string;
386
396
  };
387
397
  KNOWN_MEDIA_TYPE: {
388
398
  IMAGE: any[];
@@ -495,6 +505,8 @@ export class CometChat {
495
505
  CORE_CONVERSATIONS_UPDATE_ON_CUSTOM_MESSAGES: string;
496
506
  CORE_CONVERSATIONS_UPDATE_ON_REPLIES: string;
497
507
  FLAG_REASONS: string;
508
+ FILE_SIZE_MAX: string;
509
+ FILE_COUNT_MAX: string;
498
510
  };
499
511
  };
500
512
  static GroupConstants: {
@@ -1037,6 +1049,8 @@ export class CometChat {
1037
1049
  static InteractionReceipt: typeof InteractionReceipt;
1038
1050
  static MessageReceipt: typeof MessageReceipt;
1039
1051
  static AIAssistantMessage: typeof AIAssistantMessage;
1052
+ static AIAssistantElement: typeof AIAssistantElement;
1053
+ static CardMessage: typeof CardMessage;
1040
1054
  static AIToolCall: typeof AIToolCall;
1041
1055
  static AIToolCallFunction: typeof AIToolCallFunction;
1042
1056
  static AIAssistantMessageData: typeof AIAssistantMessageData;
@@ -1135,6 +1149,9 @@ export class CometChat {
1135
1149
  static CallListener: typeof CallListener;
1136
1150
  static ConnectionListener: typeof ConnectionListener;
1137
1151
  static LoginListener: typeof LoginListener;
1152
+ static UploadFileListener: typeof UploadFileListener;
1153
+ static UploadFileRequest: typeof UploadFileRequest;
1154
+ static UploadStatus: typeof UploadStatus;
1138
1155
  static AIAssistantListener: typeof AIAssistantListener;
1139
1156
  static CallController: typeof CallController;
1140
1157
  static CometChatHelper: typeof CometChatHelper;
@@ -1396,6 +1413,46 @@ export class CometChat {
1396
1413
  * @memberof CometChat
1397
1414
  */
1398
1415
  static sendMediaMessage(message: Object): Promise<TextMessage | BaseMessage | MediaMessage | CustomMessage>;
1416
+ /**
1417
+ * Creates an {@link UploadFileRequest} scoped to one destination and one upload batch. This is
1418
+ * the entry point for the multi-attachment upload flow: configure the request
1419
+ * (`setParentMessageId`/`setBatchId`/`setConcurrency`), upload files through it
1420
+ * (`uploadAttachment`/`uploadAttachments`), read the batch (`getAttachments`/`getStatus`/…),
1421
+ * then build a `MediaMessage` from its attachments and call {@link CometChat.sendMediaMessage}.
1422
+ *
1423
+ * @param {string} receiverId Intended recipient id (uid or guid). Sent in the presign call for role-based access control.
1424
+ * @param {string} receiverType Recipient type (`user` or `group`). Sent in the presign call for role-based access control.
1425
+ * @returns {UploadFileRequest} A request object scoped to this destination + one batch.
1426
+ * @memberof CometChat
1427
+ *
1428
+ * @example
1429
+ * // 1) Upload files through the request.
1430
+ * const request = CometChat.createUploadFileRequest(receiverId, receiverType);
1431
+ * request.uploadAttachments(files.map(f => ({ fileId: f.id, file: f })), new CometChat.UploadFileListener({
1432
+ * onFileUploaded: (fileId, attachment) => { ... },
1433
+ * onComplete: (result) => { ... }, // fires when the batch settles
1434
+ * }));
1435
+ *
1436
+ * // 2) When ready, build the MediaMessage and send it.
1437
+ * // IMPORTANT: pass `null` as the file argument and attach the uploaded attachments with
1438
+ * // setAttachments(). Do NOT pass request.getAttachments() as the constructor's file argument —
1439
+ * // that sets the raw-file field and the message silently falls back to the legacy upload path.
1440
+ * const message = new CometChat.MediaMessage(receiverId, null, CometChat.MESSAGE_TYPE.IMAGE, receiverType);
1441
+ * message.setAttachments(request.getAttachments()); // pre-uploaded attachments
1442
+ * message.setCaption("Optional caption");
1443
+ * CometChat.sendMediaMessage(message).then(sent => { ... });
1444
+ * request.clearAll(); // release the batch after sending
1445
+ */
1446
+ static createUploadFileRequest(receiverId: string, receiverType: string): UploadFileRequest;
1447
+ /**
1448
+ * Returns the maximum number of attachments allowed per message, as configured
1449
+ * in app settings (`file.count.max`). Falls back to `UPLOAD_CONSTANTS.DEFAULT_FILE_COUNT_MAX`
1450
+ * if the setting is not available.
1451
+ *
1452
+ * @returns {Promise<number>}
1453
+ * @memberof CometChat
1454
+ */
1455
+ static getMaxAttachmentCount(): Promise<number>;
1399
1456
  /**
1400
1457
  *
1401
1458
  * Function to send a custom message.
@@ -2398,6 +2455,286 @@ export interface CometChatSettings {
2398
2455
  uiKit?: Record<string, unknown>;
2399
2456
  }
2400
2457
 
2458
+ /**
2459
+ *
2460
+ * @module UploadFileListener
2461
+ */
2462
+ /**
2463
+ * Callback bundle for an upload batch. Passed per call to
2464
+ * {@link UploadFileRequest.uploadAttachment}/{@link UploadFileRequest.uploadAttachments}, and also
2465
+ * registered as the batch-wide global listener via {@link UploadFileRequest.addUploadListener}.
2466
+ * Every callback is optional; override only the ones you need. Unlike `MessageListener`/
2467
+ * `CallListener`, this is not registered globally with a string id — it lives for the duration of
2468
+ * the upload batch.
2469
+ *
2470
+ * @example
2471
+ * const request = CometChat.createUploadFileRequest(receiverId, receiverType);
2472
+ * // Each item pairs a file with a required, caller-supplied fileId (echoed back on every event).
2473
+ * request.uploadAttachments(files.map(f => ({ fileId: f.id, file: f })), new CometChat.UploadFileListener({
2474
+ * onFileProgress: (fileId, loaded, total, percent) => {},
2475
+ * onFileUploaded: (fileId, attachment) => {},
2476
+ * onFileError: (fileId, error) => {},
2477
+ * onFileFailure: (fileId, error) => {},
2478
+ * onComplete: (result) => {}
2479
+ * }));
2480
+ */
2481
+ export class UploadFileListener {
2482
+ /** Per-file upload progress. */
2483
+ onFileProgress?: (fileId: string, loaded: number, total: number, percent: number) => void;
2484
+ /** Per-file success. */
2485
+ onFileUploaded?: (fileId: string, attachment: Attachment) => void;
2486
+ /** Per-file rejected — not retryable (fix input / permission). */
2487
+ onFileError?: (fileId: string, error: CometChatException) => void;
2488
+ /** Per-file transfer failure — retryable via `retryAttachment`. */
2489
+ onFileFailure?: (fileId: string, error: CometChatException) => void;
2490
+ /** Fires once each time the batch drains (no files in-flight). */
2491
+ onComplete?: (result: UploadResult) => void;
2492
+ constructor(callbacks?: {
2493
+ onFileProgress?: (fileId: string, loaded: number, total: number, percent: number) => void;
2494
+ onFileUploaded?: (fileId: string, attachment: Attachment) => void;
2495
+ onFileError?: (fileId: string, error: CometChatException) => void;
2496
+ onFileFailure?: (fileId: string, error: CometChatException) => void;
2497
+ onComplete?: (result: UploadResult) => void;
2498
+ });
2499
+ }
2500
+
2501
+ /**
2502
+ *
2503
+ * @module UploadFileRequest
2504
+ */
2505
+ /**
2506
+ * A request object scoped to one destination (`receiverId`/`receiverType`) and one upload **batch**.
2507
+ * The request owns the batch id (auto-generated as a UUID unless the app sets one) and forwards all
2508
+ * operations to the {@link UploadManager}. Obtain one via {@link CometChat.createUploadFileRequest}.
2509
+ *
2510
+ * Upload is decoupled from sending: upload files through the request, then build a `MediaMessage`
2511
+ * with the request's attachments (`getAttachments()` / `getAttachmentsByType()`) and call
2512
+ * {@link CometChat.sendMediaMessage}.
2513
+ */
2514
+ export class UploadFileRequest {
2515
+ /**
2516
+ * @param {string} receiverId Recipient id (uid/guid). Sent in the presign call for RBAC/SBAC.
2517
+ * @param {string} receiverType Recipient type (`user`/`group`). Sent in the presign call.
2518
+ */
2519
+ constructor(receiverId: string, receiverType: string);
2520
+ /**
2521
+ * Mark this batch as belonging to a thread. The id is sent with `receiverId`/`receiverType` in
2522
+ * the presign call. Omit for a top-level (non-thread) message.
2523
+ * @param {string | number} messageId
2524
+ * @returns {UploadFileRequest}
2525
+ */
2526
+ setParentMessageId(messageId: string | number): UploadFileRequest;
2527
+ /**
2528
+ * Set the batch id all files in this request share. If never called, the SDK keeps the
2529
+ * auto-generated UUID. Has no effect once files have been uploaded through the request.
2530
+ * @param {string} batchId
2531
+ * @returns {UploadFileRequest}
2532
+ */
2533
+ setBatchId(batchId: string): UploadFileRequest;
2534
+ /**
2535
+ * @returns {string} The effective batch id (app-set or auto-generated UUID).
2536
+ */
2537
+ getBatchId(): string;
2538
+ /**
2539
+ * Set how many files upload concurrently for this batch. Default 1 (sequential). Applies from
2540
+ * the next drain onward.
2541
+ * @param {number} count
2542
+ * @returns {UploadFileRequest}
2543
+ */
2544
+ setConcurrency(count: number): UploadFileRequest;
2545
+ /**
2546
+ * Upload multiple files into this batch. Each entry pairs the file with a **required**
2547
+ * caller-supplied `fileId` (echoed back on every event). A `fileId` already present in the batch
2548
+ * is skipped (deduped).
2549
+ * @param {UploadItem[]} files `{ fileId, file }[]`
2550
+ * @param {UploadFileListener} [listener] Per-call events for these files.
2551
+ */
2552
+ uploadAttachments(files: UploadItem[], listener?: UploadFileListener): void;
2553
+ /**
2554
+ * Upload a single file into this batch under a **required** caller-supplied `fileId`.
2555
+ * @param {string} fileId Caller-supplied id (required; echoed back on every event).
2556
+ * @param {UploadFileInput} file Platform-native file (`File`/`Blob`).
2557
+ * @param {UploadFileListener} [listener] Per-call events for this file.
2558
+ */
2559
+ uploadAttachment(fileId: string, file: UploadFileInput, listener?: UploadFileListener): void;
2560
+ /**
2561
+ * @param {string} fileId
2562
+ * @returns {Attachment | null} The uploaded attachment for `fileId`, or null if unknown / not yet uploaded.
2563
+ */
2564
+ getAttachment(fileId: string): Attachment | null;
2565
+ /**
2566
+ * @returns {Attachment[]} All uploaded attachments in the batch.
2567
+ */
2568
+ getAttachments(): Attachment[];
2569
+ /**
2570
+ * @param {string} type One of `image`/`video`/`audio`/`file`.
2571
+ * @returns {Attachment[]} Uploaded attachments of that kind — always an array (empty when none).
2572
+ */
2573
+ getAttachmentsByType(type: string): Attachment[];
2574
+ /**
2575
+ * @returns {number} Total files in the batch, any state (in-progress/failed/succeeded).
2576
+ */
2577
+ getAttachmentCount(): number;
2578
+ /**
2579
+ * @returns {UploadStatus} `IN_PROGRESS` while any upload is running, else `IDLE`.
2580
+ */
2581
+ getStatus(): UploadStatus;
2582
+ /**
2583
+ * Add a batch-wide global listener that fires for every file across all upload calls on this
2584
+ * request. A later call overrides the previous global listener (single slot).
2585
+ * @param {UploadFileListener} listener
2586
+ */
2587
+ addUploadListener(listener: UploadFileListener): void;
2588
+ /**
2589
+ * Remove the batch-wide global listener.
2590
+ */
2591
+ removeUploadListener(): void;
2592
+ /**
2593
+ * Re-upload one FAILED file (`onFileFailure`) using its retained bytes, re-presigning if the
2594
+ * prior presign expired. No-op for rejected/uploaded files.
2595
+ * @param {string} fileId
2596
+ */
2597
+ retryAttachment(fileId: string): void;
2598
+ /**
2599
+ * Remove one file from the batch. Aborts its in-flight upload (silently) if still uploading, or
2600
+ * drops it from the set if already uploaded.
2601
+ * @param {string} fileId
2602
+ */
2603
+ removeAttachment(fileId: string): void;
2604
+ /**
2605
+ * Clear all files and release this batch from SDK memory, aborting any in-flight uploads. Call
2606
+ * after a successful send, or to abandon a composer.
2607
+ */
2608
+ clearAll(): void;
2609
+ }
2610
+
2611
+ /**
2612
+ *
2613
+ * @module UploadTypes
2614
+ */
2615
+ /**
2616
+ * Per-file upload lifecycle status (internal).
2617
+ * @private
2618
+ */
2619
+ export enum UploadFileStatus {
2620
+ QUEUED = "queued",
2621
+ REQUESTING_URL = "requesting_url",
2622
+ UPLOADING = "uploading",
2623
+ UPLOADED = "uploaded",
2624
+ FAILED = "failed",
2625
+ REJECTED = "rejected",
2626
+ CANCELLED = "cancelled"
2627
+ }
2628
+ /**
2629
+ * Public batch-level status returned by {@link UploadFileRequest.getStatus}.
2630
+ * `IN_PROGRESS` while any file is still non-terminal; `IDLE` when nothing is in flight — i.e. the
2631
+ * batch is empty or every file has settled.
2632
+ */
2633
+ export enum UploadStatus {
2634
+ IN_PROGRESS = "in_progress",
2635
+ IDLE = "idle"
2636
+ }
2637
+ /**
2638
+ * Platform-native file input accepted by the upload pipeline. The pipeline needs a numeric
2639
+ * `size`, so inputs must be web `File`/`Blob` objects.
2640
+ */
2641
+ export type UploadFileInput = File | Blob;
2642
+ /**
2643
+ * A single file to upload. `fileId` is **caller-supplied and required** — the SDK does not generate
2644
+ * one; it is echoed back unchanged on every per-file event and used to dedupe within the batch.
2645
+ */
2646
+ export interface UploadItem {
2647
+ file: UploadFileInput;
2648
+ fileId: string;
2649
+ }
2650
+ /**
2651
+ * Options accepted internally by the upload manager, supplied by {@link UploadFileRequest}.
2652
+ * @private
2653
+ */
2654
+ export interface UploadOptions {
2655
+ /** Number of simultaneous uploads. Defaults to 1 (sequential). */
2656
+ concurrency?: number;
2657
+ /** The batch id all files share (request-owned; auto-generated when the app omits one). */
2658
+ batchId?: string;
2659
+ /** Recipient id, forwarded to the presign endpoint. */
2660
+ receiverId?: string;
2661
+ /** Recipient type (`user`/`group`), forwarded to the presign endpoint. */
2662
+ receiverType?: string;
2663
+ /** Thread parent message id, forwarded to the presign endpoint for thread batches. */
2664
+ parentMessageId?: string | number;
2665
+ }
2666
+ /**
2667
+ * Recipient context forwarded to the presign endpoint so it can apply role-based access control.
2668
+ * @private
2669
+ */
2670
+ export interface PresignContext {
2671
+ receiverId?: string;
2672
+ receiverType?: string;
2673
+ parentMessageId?: string | number;
2674
+ }
2675
+ /** A successfully uploaded file entry in {@link UploadResult}. */
2676
+ export interface UploadResultSuccessItem {
2677
+ fileId: string;
2678
+ attachment: Attachment;
2679
+ }
2680
+ /** A non-successful file entry in {@link UploadResult}. */
2681
+ export interface UploadResultErrorItem {
2682
+ fileId: string;
2683
+ error: CometChatException;
2684
+ }
2685
+ /**
2686
+ * Aggregate result for an upload group, delivered through `onComplete`.
2687
+ * Reflects the whole group's current settled state.
2688
+ */
2689
+ export interface UploadResult {
2690
+ batchId: string;
2691
+ successful: UploadResultSuccessItem[];
2692
+ /** Files reported via `onFileError` — not retryable. */
2693
+ rejected: UploadResultErrorItem[];
2694
+ /** Files reported via `onFileFailure` — retryable. */
2695
+ failed: UploadResultErrorItem[];
2696
+ }
2697
+ /**
2698
+ * Pre-signed upload form for a single file, returned by the presign endpoint.
2699
+ */
2700
+ export interface PresignForm {
2701
+ request: {
2702
+ url: string;
2703
+ method: string;
2704
+ body: {
2705
+ [key: string]: any;
2706
+ };
2707
+ };
2708
+ attachment: {
2709
+ [key: string]: any;
2710
+ };
2711
+ expiresAt?: number;
2712
+ }
2713
+ /**
2714
+ * Internal per-file state tracked by the upload manager.
2715
+ * @private
2716
+ */
2717
+ export interface UploadFileState {
2718
+ fileId: string;
2719
+ file: any;
2720
+ name: string;
2721
+ size: number;
2722
+ mimeType: string;
2723
+ status: UploadFileStatus;
2724
+ attachment?: Attachment;
2725
+ error?: CometChatException;
2726
+ presign?: PresignForm;
2727
+ presignedAt?: number;
2728
+ lastPercent?: number;
2729
+ request?: {
2730
+ abort: () => void;
2731
+ } | null;
2732
+ stallTimer?: any;
2733
+ settled?: boolean;
2734
+ /** Per-call listener supplied for the upload call that added this file (may be undefined). */
2735
+ listener?: any;
2736
+ }
2737
+
2401
2738
  /**
2402
2739
  *
2403
2740
  * @module CometChatException
@@ -2600,6 +2937,7 @@ export class MediaMessage extends BaseMessage implements Message {
2600
2937
  CUSTOM: string;
2601
2938
  INTERACTIVE: string;
2602
2939
  AGENTIC: string;
2940
+ CARD: string;
2603
2941
  };
2604
2942
  private url;
2605
2943
  private file;
@@ -3295,6 +3633,7 @@ export const MessageConstatnts: {
3295
3633
  CUSTOM: string;
3296
3634
  INTERACTIVE: string;
3297
3635
  AGENTIC: string;
3636
+ CARD: string;
3298
3637
  };
3299
3638
  RECEIVER_TYPE: {
3300
3639
  USER: string;
@@ -3340,6 +3679,9 @@ export const MessageConstatnts: {
3340
3679
  TOOL_CALL_ID: string;
3341
3680
  DISPLAY_NAME: string;
3342
3681
  EXECUTION_TEXT: string;
3682
+ CARD: string;
3683
+ CARD_ID: string;
3684
+ ELEMENTS: string;
3343
3685
  };
3344
3686
  KNOWN_MEDIA_TYPE: {
3345
3687
  IMAGE: any[];
@@ -3410,7 +3752,8 @@ export enum MessageCategory {
3410
3752
  CALL = "call",
3411
3753
  CUSTOM = "custom",
3412
3754
  INTERACTIVE = "interactive",
3413
- AGENTIC = "agentic"
3755
+ AGENTIC = "agentic",
3756
+ CARD = "card"
3414
3757
  }
3415
3758
  export enum GoalType {
3416
3759
  ANY_ACTION = "anyAction",
@@ -4104,8 +4447,18 @@ export const APP_SETTINGS: {
4104
4447
  CORE_CONVERSATIONS_UPDATE_ON_CUSTOM_MESSAGES: string;
4105
4448
  CORE_CONVERSATIONS_UPDATE_ON_REPLIES: string;
4106
4449
  FLAG_REASONS: string;
4450
+ FILE_SIZE_MAX: string;
4451
+ FILE_COUNT_MAX: string;
4107
4452
  };
4108
4453
  };
4454
+ export const UPLOAD_CONSTANTS: {
4455
+ DEFAULT_FILE_SIZE_MAX: number;
4456
+ DEFAULT_FILE_COUNT_MAX: number;
4457
+ DEFAULT_CONCURRENCY: number;
4458
+ STALL_TIMEOUT_MS: number;
4459
+ PROGRESS_THROTTLE_PERCENT: number;
4460
+ PRESIGN_TTL_MS: number;
4461
+ };
4109
4462
  export const COMMON_UTILITY_CONSTANTS: {
4110
4463
  TYPE_CONSTANTS: {
4111
4464
  BOOLEAN: string;
@@ -4211,6 +4564,9 @@ export const AI_ASSISTANT_EVENTS: {
4211
4564
  TOOL_CALL_ENDED: string;
4212
4565
  TOOL_CALL_RESULT: string;
4213
4566
  TOOL_CALL_ARGUMENT: string;
4567
+ CARD_START: string;
4568
+ CARD: string;
4569
+ CARD_END: string;
4214
4570
  };
4215
4571
  export interface FlagReason {
4216
4572
  id: string;
@@ -4499,6 +4855,10 @@ export class MessageListener {
4499
4855
  * This event is triggered when an AI assistant message is received.
4500
4856
  */
4501
4857
  onAIAssistantMessageReceived?: Function;
4858
+ /**
4859
+ * This event is triggered when a card message is received.
4860
+ */
4861
+ onCardMessageReceived?: Function;
4502
4862
  constructor(...args: any[]);
4503
4863
  }
4504
4864
  export class CallListener {
@@ -4759,6 +5119,7 @@ export class Call extends BaseMessage implements Message {
4759
5119
  CUSTOM: string;
4760
5120
  INTERACTIVE: string;
4761
5121
  AGENTIC: string;
5122
+ CARD: string;
4762
5123
  };
4763
5124
  static readonly ACTION_TYPE: {
4764
5125
  TYPE_MEMBER_JOINED: string;
@@ -5056,6 +5417,7 @@ export class Action extends BaseMessage implements Message {
5056
5417
  CUSTOM: string;
5057
5418
  INTERACTIVE: string;
5058
5419
  AGENTIC: string;
5420
+ CARD: string;
5059
5421
  };
5060
5422
  static readonly ACTION_TYPE: {
5061
5423
  TYPE_MEMBER_JOINED: string;
@@ -7488,6 +7850,7 @@ export class InteractiveMessage extends BaseMessage implements Message {
7488
7850
  CUSTOM: string;
7489
7851
  INTERACTIVE: string;
7490
7852
  AGENTIC: string;
7853
+ CARD: string;
7491
7854
  };
7492
7855
  protected data?: Object;
7493
7856
  constructor(...args: any[]);
@@ -8328,6 +8691,19 @@ export class AIAssistantMessage extends BaseMessage implements Message {
8328
8691
  * Set the tags for the message.
8329
8692
  */
8330
8693
  setTags(tags: Array<String>): void;
8694
+ /**
8695
+ * Method to get the ordered list of content blocks (`data.elements`).
8696
+ * Returns an empty array when the field is absent (e.g. older messages),
8697
+ * in which case the renderer should fall back to getText().
8698
+ * @returns {Array<AIAssistantElement>}
8699
+ */
8700
+ getElements(): Array<AIAssistantElement>;
8701
+ /**
8702
+ * Method to set the ordered list of content blocks. Called by the factory
8703
+ * to populate the field from `data.elements`.
8704
+ * @param {Array<AIAssistantElement>} elements
8705
+ */
8706
+ setElements(elements: Array<AIAssistantElement>): void;
8331
8707
  }
8332
8708
 
8333
8709
  /**
@@ -8592,6 +8968,97 @@ export class AIToolArgumentMessage extends BaseMessage implements Message {
8592
8968
  setTags(tags: Array<String>): void;
8593
8969
  }
8594
8970
 
8971
+ /**
8972
+ *
8973
+ * @module CardMessage
8974
+ */
8975
+ export class CardMessage extends BaseMessage implements Message {
8976
+ protected data?: any;
8977
+ constructor(receiverId: string, receiverType: string);
8978
+ /**
8979
+ * Method to get the raw card JSON object.
8980
+ * @returns {Object | undefined}
8981
+ */
8982
+ getCard(): Object | undefined;
8983
+ /**
8984
+ * Method to get the text content of the card message.
8985
+ * @returns {string}
8986
+ */
8987
+ getText(): string;
8988
+ /**
8989
+ * Method to get the fallback text from the card object.
8990
+ * @returns {string}
8991
+ */
8992
+ getFallbackText(): string;
8993
+ /**
8994
+ * Method to get sender of the message.
8995
+ * @returns {User}
8996
+ */
8997
+ getSender(): User;
8998
+ /**
8999
+ * Method to get receiver of the message.
9000
+ * @returns {User | Group}
9001
+ */
9002
+ getReceiver(): User | Group;
9003
+ /**
9004
+ * Method to get data of the message.
9005
+ * @returns {any}
9006
+ */
9007
+ getData(): any;
9008
+ /**
9009
+ * Get the tags of the message.
9010
+ * @returns {Array<String>}
9011
+ */
9012
+ getTags(): Array<String>;
9013
+ /**
9014
+ * @param {Array<String>} tags
9015
+ * Set the tags for the message.
9016
+ */
9017
+ setTags(tags: Array<String>): void;
9018
+ }
9019
+
9020
+ /**
9021
+ * A single ordered content block from an AIAssistantMessage's `data.elements`
9022
+ * array. Each entry is a `{ type, value }` envelope; the SDK never parses the
9023
+ * value — the caller branches on getType() to interpret what getData() returns.
9024
+ *
9025
+ * - type "text" → getData() is the block's text string
9026
+ * - type "card" → getData() is `{ card, cardId }`
9027
+ * - other types → getData() is that type's raw JSON value
9028
+ */
9029
+ export class AIAssistantElement {
9030
+ constructor(type: string, data: any);
9031
+ /**
9032
+ * Method to get the element's type string ("text" | "card" | "graph" | ...).
9033
+ * @returns {string}
9034
+ */
9035
+ getType(): string;
9036
+ /**
9037
+ * Method to set the element's type string.
9038
+ * @param {string} type
9039
+ */
9040
+ setType(type: string): void;
9041
+ /**
9042
+ * Method to get the element's body data (the entry's `value`), returned raw
9043
+ * and typed by getType(). The SDK never interprets the body.
9044
+ * @returns {any}
9045
+ */
9046
+ getData(): any;
9047
+ /**
9048
+ * Method to set the element's body data.
9049
+ * @param {any} data
9050
+ */
9051
+ setData(data: any): void;
9052
+ /**
9053
+ * Build an ordered list of AIAssistantElement from a raw `data.elements`
9054
+ * array. Returns an empty array when the field is absent (e.g. older
9055
+ * messages). The `value` of each entry is preserved raw.
9056
+ * @param {any[]} elements
9057
+ * @returns {AIAssistantElement[]}
9058
+ */
9059
+ static fromArray(elements: any[]): AIAssistantElement[];
9060
+ }
9061
+
8595
9062
  /** Push Notification Preferences Enums */
8596
9063
  export enum MessagesOptions {
8597
9064
  DONT_SUBSCRIBE,
@@ -9576,3 +10043,87 @@ export class AIAssistantToolResultEvent extends AIAssistantBaseEvent<AssistantTo
9576
10043
  setRole(role: string): void;
9577
10044
  }
9578
10045
 
10046
+ /**
10047
+ * Data interface for card started events
10048
+ */
10049
+ export interface AssistantCardStartedEventData extends AssistantBaseEventData {
10050
+ streamMessageId?: string;
10051
+ cardId?: string;
10052
+ executionText?: string;
10053
+ }
10054
+ /**
10055
+ * Event fired when AI assistant card generation starts
10056
+ */
10057
+ export class AIAssistantCardStartedEvent extends AIAssistantBaseEvent<AssistantCardStartedEventData> {
10058
+ constructor(conversationId: string, messageId: string, parentMessageId: string, data: AssistantCardStartedEventData);
10059
+ /**
10060
+ * Get the stream message ID for the card event.
10061
+ * @returns {string}
10062
+ */
10063
+ getStreamMessageId(): string;
10064
+ /**
10065
+ * Get the card ID for the card event.
10066
+ * @returns {string}
10067
+ */
10068
+ getCardId(): string;
10069
+ /**
10070
+ * Get the execution text shown while the card is being generated.
10071
+ * @returns {string}
10072
+ */
10073
+ getExecutionText(): string;
10074
+ }
10075
+
10076
+ /**
10077
+ * Data interface for card received events
10078
+ */
10079
+ export interface AssistantCardReceivedEventData extends AssistantBaseEventData {
10080
+ streamMessageId?: string;
10081
+ cardId?: string;
10082
+ card?: any;
10083
+ }
10084
+ /**
10085
+ * Event fired when AI assistant card payload is delivered
10086
+ */
10087
+ export class AIAssistantCardReceivedEvent extends AIAssistantBaseEvent<AssistantCardReceivedEventData> {
10088
+ constructor(conversationId: string, messageId: string, parentMessageId: string, data: AssistantCardReceivedEventData);
10089
+ /**
10090
+ * Get the stream message ID for the card event.
10091
+ * @returns {string}
10092
+ */
10093
+ getStreamMessageId(): string;
10094
+ /**
10095
+ * Get the card ID for the card event.
10096
+ * @returns {string}
10097
+ */
10098
+ getCardId(): string;
10099
+ /**
10100
+ * Get the raw card object from the event data.
10101
+ * @returns {any} The card object or undefined
10102
+ */
10103
+ getCard(): any;
10104
+ }
10105
+
10106
+ /**
10107
+ * Data interface for card ended events
10108
+ */
10109
+ export interface AssistantCardEndedEventData extends AssistantBaseEventData {
10110
+ streamMessageId?: string;
10111
+ cardId?: string;
10112
+ }
10113
+ /**
10114
+ * Event fired when AI assistant card generation finishes
10115
+ */
10116
+ export class AIAssistantCardEndedEvent extends AIAssistantBaseEvent<AssistantCardEndedEventData> {
10117
+ constructor(conversationId: string, messageId: string, parentMessageId: string, data: AssistantCardEndedEventData);
10118
+ /**
10119
+ * Get the stream message ID for the card event.
10120
+ * @returns {string}
10121
+ */
10122
+ getStreamMessageId(): string;
10123
+ /**
10124
+ * Get the card ID for the card event.
10125
+ * @returns {string}
10126
+ */
10127
+ getCardId(): string;
10128
+ }
10129
+