@cometchat/chat-sdk-javascript 4.1.10 → 4.1.12

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[];
@@ -459,6 +469,11 @@ export class CometChat {
459
469
  WEBRTC_HTTPS_BIND_PORT: string;
460
470
  EXTENSION_LIST: string;
461
471
  EXTENSION_KEYS: {
472
+ /**
473
+ * This method removes data from the session storage.
474
+ * @internal
475
+ * @memberof CometChat
476
+ */
462
477
  ID: string;
463
478
  NAME: string;
464
479
  };
@@ -540,6 +555,11 @@ export class CometChat {
540
555
  };
541
556
  };
542
557
  static PresenceConstants: {
558
+ /**
559
+ * This method checks if Analytics Ping has started.
560
+ * @internal
561
+ * @returns {boolean}
562
+ */
543
563
  STATUS: {
544
564
  ONLINE: string;
545
565
  AVAILABLE: string;
@@ -629,7 +649,7 @@ export class CometChat {
629
649
  code: string;
630
650
  name: string;
631
651
  message: string;
632
- details: {};
652
+ /** @internal */ details: {};
633
653
  };
634
654
  MUST_BE_A_POSITIVE_NUMBER: {
635
655
  code: string;
@@ -755,6 +775,7 @@ export class CometChat {
755
775
  KEY_APP_ID: string;
756
776
  KEY_DEVICE_ID: string;
757
777
  KEY_SESSION_ID: string;
778
+ KEY_INTEGRATION_SOURCE: string;
758
779
  KEY_MESSAGE_LISTENER_LIST: string;
759
780
  };
760
781
  static SDKHeader: {
@@ -803,7 +824,11 @@ export class CometChat {
803
824
  details: {};
804
825
  };
805
826
  FEATURE_NOT_FOUND: {
806
- code: string;
827
+ code: string; /**
828
+ * This method triggers before a page unloads.
829
+ * @internal
830
+ * @memberof CometChat
831
+ */
807
832
  name: string;
808
833
  message: string;
809
834
  details: {};
@@ -1036,6 +1061,8 @@ export class CometChat {
1036
1061
  static InteractionReceipt: typeof InteractionReceipt;
1037
1062
  static MessageReceipt: typeof MessageReceipt;
1038
1063
  static AIAssistantMessage: typeof AIAssistantMessage;
1064
+ static AIAssistantElement: typeof AIAssistantElement;
1065
+ static CardMessage: typeof CardMessage;
1039
1066
  static AIToolCall: typeof AIToolCall;
1040
1067
  static AIToolCallFunction: typeof AIToolCallFunction;
1041
1068
  static AIAssistantMessageData: typeof AIAssistantMessageData;
@@ -1321,6 +1348,16 @@ export class CometChat {
1321
1348
  * @memberof CometChat
1322
1349
  */
1323
1350
  static init(appId: any, appSettings: AppSettings): Promise<boolean>;
1351
+ /**
1352
+ * Initialize CometChat from a cometchat-settings.json object.
1353
+ * Used by AI agent skills for file-based integration.
1354
+ * Persists integrationSource = "ai-agent" for telemetry attribution.
1355
+ * @internal
1356
+ * @param {CometChatSettings} settings - Parsed cometchat-settings.json object
1357
+ * @returns {Promise<boolean>}
1358
+ * @memberof CometChat
1359
+ */
1360
+ static initFromSettings(settings: CometChatSettings): Promise<boolean>;
1324
1361
  /**
1325
1362
  * Function to check whether CometChat class initialized before.
1326
1363
  * @returns {boolean}
@@ -2358,6 +2395,35 @@ export class CometChatNotifications {
2358
2395
  } | string>;
2359
2396
  }
2360
2397
 
2398
+ /**
2399
+ * Interface representing the shape of the `cometchat-settings.json` file.
2400
+ * Used by the file-based init overload for skills-driven integrations.
2401
+ *
2402
+ * The Chat SDK reads `appId`, `region`, and `chatSDK` fields.
2403
+ * The `credentials`, `callsSDK`, and `uiKit` fields are reserved for other layers.
2404
+ *
2405
+ * @internal
2406
+ * @module CometChatSettings
2407
+ */
2408
+ export interface CometChatSettings {
2409
+ appId: string;
2410
+ region: string;
2411
+ credentials?: {
2412
+ authKey?: string;
2413
+ };
2414
+ chatSDK?: {
2415
+ presenceSubscription?: {
2416
+ type?: string;
2417
+ roles?: string[];
2418
+ };
2419
+ autoEstablishSocketConnection?: boolean;
2420
+ adminHost?: string | null;
2421
+ clientHost?: string | null;
2422
+ };
2423
+ callsSDK?: Record<string, unknown>;
2424
+ uiKit?: Record<string, unknown>;
2425
+ }
2426
+
2361
2427
  /**
2362
2428
  *
2363
2429
  * @module CometChatException
@@ -2560,6 +2626,7 @@ export class MediaMessage extends BaseMessage implements Message {
2560
2626
  CUSTOM: string;
2561
2627
  INTERACTIVE: string;
2562
2628
  AGENTIC: string;
2629
+ CARD: string;
2563
2630
  };
2564
2631
  private url;
2565
2632
  private file;
@@ -3161,8 +3228,13 @@ export const LOCAL_STORE: {
3161
3228
  KEY_APP_ID: string;
3162
3229
  KEY_DEVICE_ID: string;
3163
3230
  KEY_SESSION_ID: string;
3231
+ KEY_INTEGRATION_SOURCE: string;
3164
3232
  KEY_MESSAGE_LISTENER_LIST: string;
3165
3233
  };
3234
+ export const INTEGRATION_SOURCE: {
3235
+ AI_AGENT: string;
3236
+ MANUAL: string;
3237
+ };
3166
3238
  export const ResponseConstants: {
3167
3239
  RESPONSE_KEYS: {
3168
3240
  KEY_DATA: string;
@@ -3250,6 +3322,7 @@ export const MessageConstatnts: {
3250
3322
  CUSTOM: string;
3251
3323
  INTERACTIVE: string;
3252
3324
  AGENTIC: string;
3325
+ CARD: string;
3253
3326
  };
3254
3327
  RECEIVER_TYPE: {
3255
3328
  USER: string;
@@ -3295,6 +3368,9 @@ export const MessageConstatnts: {
3295
3368
  TOOL_CALL_ID: string;
3296
3369
  DISPLAY_NAME: string;
3297
3370
  EXECUTION_TEXT: string;
3371
+ CARD: string;
3372
+ CARD_ID: string;
3373
+ ELEMENTS: string;
3298
3374
  };
3299
3375
  KNOWN_MEDIA_TYPE: {
3300
3376
  IMAGE: any[];
@@ -3365,7 +3441,8 @@ export enum MessageCategory {
3365
3441
  CALL = "call",
3366
3442
  CUSTOM = "custom",
3367
3443
  INTERACTIVE = "interactive",
3368
- AGENTIC = "agentic"
3444
+ AGENTIC = "agentic",
3445
+ CARD = "card"
3369
3446
  }
3370
3447
  export enum GoalType {
3371
3448
  ANY_ACTION = "anyAction",
@@ -4166,6 +4243,9 @@ export const AI_ASSISTANT_EVENTS: {
4166
4243
  TOOL_CALL_ENDED: string;
4167
4244
  TOOL_CALL_RESULT: string;
4168
4245
  TOOL_CALL_ARGUMENT: string;
4246
+ CARD_START: string;
4247
+ CARD: string;
4248
+ CARD_END: string;
4169
4249
  };
4170
4250
  export interface FlagReason {
4171
4251
  id: string;
@@ -4454,6 +4534,10 @@ export class MessageListener {
4454
4534
  * This event is triggered when an AI assistant message is received.
4455
4535
  */
4456
4536
  onAIAssistantMessageReceived?: Function;
4537
+ /**
4538
+ * This event is triggered when a card message is received.
4539
+ */
4540
+ onCardMessageReceived?: Function;
4457
4541
  constructor(...args: any[]);
4458
4542
  }
4459
4543
  export class CallListener {
@@ -4714,6 +4798,7 @@ export class Call extends BaseMessage implements Message {
4714
4798
  CUSTOM: string;
4715
4799
  INTERACTIVE: string;
4716
4800
  AGENTIC: string;
4801
+ CARD: string;
4717
4802
  };
4718
4803
  static readonly ACTION_TYPE: {
4719
4804
  TYPE_MEMBER_JOINED: string;
@@ -5011,6 +5096,7 @@ export class Action extends BaseMessage implements Message {
5011
5096
  CUSTOM: string;
5012
5097
  INTERACTIVE: string;
5013
5098
  AGENTIC: string;
5099
+ CARD: string;
5014
5100
  };
5015
5101
  static readonly ACTION_TYPE: {
5016
5102
  TYPE_MEMBER_JOINED: string;
@@ -7433,19 +7519,19 @@ export class InteractiveMessage extends BaseMessage implements Message {
7433
7519
  GROUP: string;
7434
7520
  };
7435
7521
  /** @private */ static readonly CATEGORY: {
7522
+ /**
7523
+ * Method to set interaction goal of interactive message.
7524
+ * @param {InteractionGoal} interactionGoal
7525
+ */
7436
7526
  MESSAGE: string;
7437
7527
  ACTION: string;
7438
7528
  CALL: string;
7439
7529
  CUSTOM: string;
7440
7530
  INTERACTIVE: string;
7441
7531
  AGENTIC: string;
7532
+ CARD: string;
7442
7533
  };
7443
- private interactiveData;
7444
- private interactionGoal;
7445
7534
  protected data?: Object;
7446
- private interactions?;
7447
- private tags?;
7448
- private allowSenderInteraction?;
7449
7535
  constructor(...args: any[]);
7450
7536
  /**
7451
7537
  * Method to get sender of the message.
@@ -8284,6 +8370,19 @@ export class AIAssistantMessage extends BaseMessage implements Message {
8284
8370
  * Set the tags for the message.
8285
8371
  */
8286
8372
  setTags(tags: Array<String>): void;
8373
+ /**
8374
+ * Method to get the ordered list of content blocks (`data.elements`).
8375
+ * Returns an empty array when the field is absent (e.g. older messages),
8376
+ * in which case the renderer should fall back to getText().
8377
+ * @returns {Array<AIAssistantElement>}
8378
+ */
8379
+ getElements(): Array<AIAssistantElement>;
8380
+ /**
8381
+ * Method to set the ordered list of content blocks. Called by the factory
8382
+ * to populate the field from `data.elements`.
8383
+ * @param {Array<AIAssistantElement>} elements
8384
+ */
8385
+ setElements(elements: Array<AIAssistantElement>): void;
8287
8386
  }
8288
8387
 
8289
8388
  /**
@@ -8548,6 +8647,97 @@ export class AIToolArgumentMessage extends BaseMessage implements Message {
8548
8647
  setTags(tags: Array<String>): void;
8549
8648
  }
8550
8649
 
8650
+ /**
8651
+ *
8652
+ * @module CardMessage
8653
+ */
8654
+ export class CardMessage extends BaseMessage implements Message {
8655
+ protected data?: any;
8656
+ constructor(receiverId: string, receiverType: string);
8657
+ /**
8658
+ * Method to get the raw card JSON object.
8659
+ * @returns {Object | undefined}
8660
+ */
8661
+ getCard(): Object | undefined;
8662
+ /**
8663
+ * Method to get the text content of the card message.
8664
+ * @returns {string}
8665
+ */
8666
+ getText(): string;
8667
+ /**
8668
+ * Method to get the fallback text from the card object.
8669
+ * @returns {string}
8670
+ */
8671
+ getFallbackText(): string;
8672
+ /**
8673
+ * Method to get sender of the message.
8674
+ * @returns {User}
8675
+ */
8676
+ getSender(): User;
8677
+ /**
8678
+ * Method to get receiver of the message.
8679
+ * @returns {User | Group}
8680
+ */
8681
+ getReceiver(): User | Group;
8682
+ /**
8683
+ * Method to get data of the message.
8684
+ * @returns {any}
8685
+ */
8686
+ getData(): any;
8687
+ /**
8688
+ * Get the tags of the message.
8689
+ * @returns {Array<String>}
8690
+ */
8691
+ getTags(): Array<String>;
8692
+ /**
8693
+ * @param {Array<String>} tags
8694
+ * Set the tags for the message.
8695
+ */
8696
+ setTags(tags: Array<String>): void;
8697
+ }
8698
+
8699
+ /**
8700
+ * A single ordered content block from an AIAssistantMessage's `data.elements`
8701
+ * array. Each entry is a `{ type, value }` envelope; the SDK never parses the
8702
+ * value — the caller branches on getType() to interpret what getData() returns.
8703
+ *
8704
+ * - type "text" → getData() is the block's text string
8705
+ * - type "card" → getData() is `{ card, cardId }`
8706
+ * - other types → getData() is that type's raw JSON value
8707
+ */
8708
+ export class AIAssistantElement {
8709
+ constructor(type: string, data: any);
8710
+ /**
8711
+ * Method to get the element's type string ("text" | "card" | "graph" | ...).
8712
+ * @returns {string}
8713
+ */
8714
+ getType(): string;
8715
+ /**
8716
+ * Method to set the element's type string.
8717
+ * @param {string} type
8718
+ */
8719
+ setType(type: string): void;
8720
+ /**
8721
+ * Method to get the element's body data (the entry's `value`), returned raw
8722
+ * and typed by getType(). The SDK never interprets the body.
8723
+ * @returns {any}
8724
+ */
8725
+ getData(): any;
8726
+ /**
8727
+ * Method to set the element's body data.
8728
+ * @param {any} data
8729
+ */
8730
+ setData(data: any): void;
8731
+ /**
8732
+ * Build an ordered list of AIAssistantElement from a raw `data.elements`
8733
+ * array. Returns an empty array when the field is absent (e.g. older
8734
+ * messages). The `value` of each entry is preserved raw.
8735
+ * @param {any[]} elements
8736
+ * @returns {AIAssistantElement[]}
8737
+ */
8738
+ static fromArray(elements: any[]): AIAssistantElement[];
8739
+ }
8740
+
8551
8741
  /** Push Notification Preferences Enums */
8552
8742
  export enum MessagesOptions {
8553
8743
  DONT_SUBSCRIBE,
@@ -9532,3 +9722,87 @@ export class AIAssistantToolResultEvent extends AIAssistantBaseEvent<AssistantTo
9532
9722
  setRole(role: string): void;
9533
9723
  }
9534
9724
 
9725
+ /**
9726
+ * Data interface for card started events
9727
+ */
9728
+ export interface AssistantCardStartedEventData extends AssistantBaseEventData {
9729
+ streamMessageId?: string;
9730
+ cardId?: string;
9731
+ executionText?: string;
9732
+ }
9733
+ /**
9734
+ * Event fired when AI assistant card generation starts
9735
+ */
9736
+ export class AIAssistantCardStartedEvent extends AIAssistantBaseEvent<AssistantCardStartedEventData> {
9737
+ constructor(conversationId: string, messageId: string, parentMessageId: string, data: AssistantCardStartedEventData);
9738
+ /**
9739
+ * Get the stream message ID for the card event.
9740
+ * @returns {string}
9741
+ */
9742
+ getStreamMessageId(): string;
9743
+ /**
9744
+ * Get the card ID for the card event.
9745
+ * @returns {string}
9746
+ */
9747
+ getCardId(): string;
9748
+ /**
9749
+ * Get the execution text shown while the card is being generated.
9750
+ * @returns {string}
9751
+ */
9752
+ getExecutionText(): string;
9753
+ }
9754
+
9755
+ /**
9756
+ * Data interface for card received events
9757
+ */
9758
+ export interface AssistantCardReceivedEventData extends AssistantBaseEventData {
9759
+ streamMessageId?: string;
9760
+ cardId?: string;
9761
+ card?: any;
9762
+ }
9763
+ /**
9764
+ * Event fired when AI assistant card payload is delivered
9765
+ */
9766
+ export class AIAssistantCardReceivedEvent extends AIAssistantBaseEvent<AssistantCardReceivedEventData> {
9767
+ constructor(conversationId: string, messageId: string, parentMessageId: string, data: AssistantCardReceivedEventData);
9768
+ /**
9769
+ * Get the stream message ID for the card event.
9770
+ * @returns {string}
9771
+ */
9772
+ getStreamMessageId(): string;
9773
+ /**
9774
+ * Get the card ID for the card event.
9775
+ * @returns {string}
9776
+ */
9777
+ getCardId(): string;
9778
+ /**
9779
+ * Get the raw card object from the event data.
9780
+ * @returns {any} The card object or undefined
9781
+ */
9782
+ getCard(): any;
9783
+ }
9784
+
9785
+ /**
9786
+ * Data interface for card ended events
9787
+ */
9788
+ export interface AssistantCardEndedEventData extends AssistantBaseEventData {
9789
+ streamMessageId?: string;
9790
+ cardId?: string;
9791
+ }
9792
+ /**
9793
+ * Event fired when AI assistant card generation finishes
9794
+ */
9795
+ export class AIAssistantCardEndedEvent extends AIAssistantBaseEvent<AssistantCardEndedEventData> {
9796
+ constructor(conversationId: string, messageId: string, parentMessageId: string, data: AssistantCardEndedEventData);
9797
+ /**
9798
+ * Get the stream message ID for the card event.
9799
+ * @returns {string}
9800
+ */
9801
+ getStreamMessageId(): string;
9802
+ /**
9803
+ * Get the card ID for the card event.
9804
+ * @returns {string}
9805
+ */
9806
+ getCardId(): string;
9807
+ }
9808
+