@sendbird/ai-agent-messenger-react 1.37.0 → 1.38.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.
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ import { ComponentType } from 'react';
8
8
  import { Context } from 'react';
9
9
  import type { Conversation as Conversation_2 } from '@sendbird/chat/aiAgent';
10
10
  import type { ConversationStatus } from '@sendbird/chat/aiAgent';
11
+ import type { CPAAuthorizationErrorCode } from '@sendbird/chat/aiAgent';
11
12
  import { CSSProperties } from 'react';
12
13
  import type { DeskChannelFilter } from '@sendbird/chat/aiAgent';
13
14
  import type { FileMessage } from '@sendbird/chat/message';
@@ -226,6 +227,11 @@ countryCode?: string;
226
227
  context?: Record<string, string>;
227
228
  /**
228
229
  * @public
230
+ * @description Customer-provided authorization codes to submit after the messenger session connects.
231
+ * */
232
+ cpaAuthorizationCodes?: CPAAuthorizationCode[];
233
+ /**
234
+ * @public
229
235
  * @description AIAgent global default query parameters.
230
236
  * */
231
237
  queryParams?: AIAgentQueryParams;
@@ -579,6 +585,7 @@ declare interface AIAgentContextValue {
579
585
  language: string;
580
586
  countryCode?: string;
581
587
  context?: Record<string, string>;
588
+ cpaAuthorizationCodes?: CPAAuthorizationCode[];
582
589
 
583
590
  logger: Loggable;
584
591
  dispatcher: Dispatcher;
@@ -623,11 +630,7 @@ declare interface AIAgentConversationContextValue {
623
630
  };
624
631
 
625
632
  state: {
626
- streamAnimation: {
627
- isAnimating: boolean;
628
- start: (id: string | number) => void;
629
- stop: (id: string | number) => void;
630
- };
633
+ streamAnimation: StreamAnimation;
631
634
  input: InputState;
632
635
  };
633
636
 
@@ -745,6 +748,8 @@ declare interface AIAgentInterface {
745
748
  countryCode?: string;
746
749
  /** The context object for AI Agent */
747
750
  context?: Record<string, string>;
751
+ /** Customer-provided authorization codes to submit after authentication connects */
752
+ cpaAuthorizationCodes?: CPAAuthorizationCode[];
748
753
 
749
754
  /** @internal Agent version for conversation initialization */
750
755
  agentVersion?: number;
@@ -778,6 +783,8 @@ declare interface AIAgentInterface {
778
783
  getContextObject: (channelUrl: string) => Promise<ContextObject>;
779
784
  /** Requests a nudge message to be shown above the launcher. Fire-and-forget: the result is only broadcast to onNudgeMessageReceived subscribers */
780
785
  requestNudgeMessage: (params: RequestNudgeMessageParams) => Promise<void>;
786
+ /** Submits customer-provided authorization codes for the current user */
787
+ submitCPAAuthorizationCodes: (authCodes: CPAAuthorizationCode[]) => Promise<SubmitCPAAuthorizationCodesResponse>;
781
788
  /** Clears memories saved for the current user */
782
789
  clearUserMemories: (params?: ClearUserMemoriesParams) => Promise<void>;
783
790
 
@@ -836,6 +843,7 @@ declare interface AIAgentMessengerSessionContextValue {
836
843
  createConversation: (params: ConversationCreateParams) => Promise<string>;
837
844
  searchConversation: (params: SearchConversationParams) => Promise<string[]>;
838
845
  refreshActiveChannel: () => Promise<string>;
846
+ submitCPAAuthorizationCodes: (authCodes: CPAAuthorizationCode[]) => Promise<SubmitCPAAuthorizationCodesResponse>;
839
847
 
840
848
  authenticate: () => Promise<MessengerSettingsResponse>;
841
849
  deauthenticate: () => Promise<void>;
@@ -848,6 +856,7 @@ declare interface AIAgentMessengerSessionRef {
848
856
  chatSDK: AIAgentContextValue['chatSDK'];
849
857
  authenticate: () => Promise<MessengerSettingsResponse>;
850
858
  deauthenticate: () => Promise<void>;
859
+ submitCPAAuthorizationCodes: (authCodes: CPAAuthorizationCode[]) => Promise<SubmitCPAAuthorizationCodesResponse>;
851
860
  getContextObject: () => Promise<ContextObject>;
852
861
  updateContext: {
853
862
  /** Updates the context of the active conversation initialized at session start. */
@@ -963,6 +972,11 @@ export declare type AIAgentProps = PropsWithChildren<{
963
972
  * @description Context object for the AI agent client. This is injected when the messenger is first loaded and can provide additional context that may influence how the AI responds to user conversations.
964
973
  * */
965
974
  context?: Record<string, string>;
975
+ /**
976
+ * @public
977
+ * @description Customer-provided authorization codes to submit after the messenger session connects.
978
+ * */
979
+ cpaAuthorizationCodes?: CPAAuthorizationCode[];
966
980
  /**
967
981
  * @public
968
982
  * @description AIAgent global default query parameters.
@@ -1469,6 +1483,8 @@ declare type ChatSDKConversation = Conversation_2;
1469
1483
 
1470
1484
  declare type ChatSDKConversationStatus = ConversationStatus;
1471
1485
 
1486
+ declare type ChatSDKCPAAuthorizationErrorCode = CPAAuthorizationErrorCode;
1487
+
1472
1488
  declare type ChatSDKDeskChannelFilter = DeskChannelFilter;
1473
1489
 
1474
1490
  declare type ChatSDKFileMessage = FileMessage;
@@ -2794,6 +2810,19 @@ declare interface ConversationScrollContextValue {
2794
2810
 
2795
2811
  declare type ConversationScrollMode = 'auto' | 'fixed';
2796
2812
 
2813
+ declare interface CPAAuthorizationCode {
2814
+ key: string;
2815
+ code: string;
2816
+ redirectURI?: string;
2817
+ }
2818
+
2819
+ declare interface CPAAuthorizationResult {
2820
+ key: string;
2821
+ status: 'ok' | 'error';
2822
+ errorCode?: ChatSDKCPAAuthorizationErrorCode;
2823
+ errorMessage?: string;
2824
+ }
2825
+
2797
2826
  declare type CSATSubmitParams = {
2798
2827
  csatType: string;
2799
2828
  csat?: number;
@@ -3035,6 +3064,7 @@ export declare interface ExtendedMessagePayload {
3035
3064
  declare type ExternalAuthTokenExpiredData = {
3036
3065
  channelUrl: string;
3037
3066
  aiAgentId: string;
3067
+ cpaKey: string;
3038
3068
  };
3039
3069
 
3040
3070
  export declare interface FeedbackInfo {
@@ -3185,6 +3215,12 @@ BaseMessageProps<{
3185
3215
  onStreamAnimationStart?: () => void;
3186
3216
  onStreamAnimationProgress?: () => void;
3187
3217
  onStreamAnimationComplete?: () => void;
3218
+ /**
3219
+ * Fired (layout effect) when this row starts/stops holding its text — the stream animation is
3220
+ * running but nothing is visible yet. The row renders nothing while holding, so the list draws its
3221
+ * single typing row on the row's behalf and keeps the held row out of the accessibility tree.
3222
+ */
3223
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
3188
3224
 
3189
3225
  // fallbacks
3190
3226
  messageTemplateErrorFallback?: ReactNode;
@@ -3275,6 +3311,7 @@ export declare const IncomingMessageLayout: {
3275
3311
  onStreamAnimationStart?: () => void;
3276
3312
  onStreamAnimationProgress?: () => void;
3277
3313
  onStreamAnimationComplete?: () => void;
3314
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
3278
3315
  messageTemplateErrorFallback?: ReactNode;
3279
3316
  messageTemplateLoadingFallback?: ReactNode;
3280
3317
  } & {
@@ -3353,6 +3390,7 @@ export declare const IncomingMessageLayout: {
3353
3390
  onStreamAnimationStart?: () => void;
3354
3391
  onStreamAnimationProgress?: () => void;
3355
3392
  onStreamAnimationComplete?: () => void;
3393
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
3356
3394
  messageTemplateErrorFallback?: ReactNode;
3357
3395
  messageTemplateLoadingFallback?: ReactNode;
3358
3396
  } & {
@@ -3431,6 +3469,7 @@ export declare const IncomingMessageLayout: {
3431
3469
  onStreamAnimationStart?: () => void;
3432
3470
  onStreamAnimationProgress?: () => void;
3433
3471
  onStreamAnimationComplete?: () => void;
3472
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
3434
3473
  messageTemplateErrorFallback?: ReactNode;
3435
3474
  messageTemplateLoadingFallback?: ReactNode;
3436
3475
  } & {
@@ -3505,6 +3544,7 @@ export declare const IncomingMessageLayout: {
3505
3544
  onStreamAnimationStart?: () => void;
3506
3545
  onStreamAnimationProgress?: () => void;
3507
3546
  onStreamAnimationComplete?: () => void;
3547
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
3508
3548
  messageTemplateErrorFallback?: ReactNode;
3509
3549
  messageTemplateLoadingFallback?: ReactNode;
3510
3550
  } & {
@@ -3583,6 +3623,7 @@ export declare const IncomingMessageLayout: {
3583
3623
  onStreamAnimationStart?: () => void;
3584
3624
  onStreamAnimationProgress?: () => void;
3585
3625
  onStreamAnimationComplete?: () => void;
3626
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
3586
3627
  messageTemplateErrorFallback?: ReactNode;
3587
3628
  messageTemplateLoadingFallback?: ReactNode;
3588
3629
  } & {
@@ -3661,6 +3702,7 @@ export declare const IncomingMessageLayout: {
3661
3702
  onStreamAnimationStart?: () => void;
3662
3703
  onStreamAnimationProgress?: () => void;
3663
3704
  onStreamAnimationComplete?: () => void;
3705
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
3664
3706
  messageTemplateErrorFallback?: ReactNode;
3665
3707
  messageTemplateLoadingFallback?: ReactNode;
3666
3708
  } & {
@@ -3767,6 +3809,7 @@ export declare const IncomingMessageLayout: {
3767
3809
  onStreamAnimationStart?: () => void;
3768
3810
  onStreamAnimationProgress?: () => void;
3769
3811
  onStreamAnimationComplete?: () => void;
3812
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
3770
3813
  messageTemplateErrorFallback?: ReactNode;
3771
3814
  messageTemplateLoadingFallback?: ReactNode;
3772
3815
  } & {
@@ -3845,6 +3888,7 @@ export declare const IncomingMessageLayout: {
3845
3888
  onStreamAnimationStart?: () => void;
3846
3889
  onStreamAnimationProgress?: () => void;
3847
3890
  onStreamAnimationComplete?: () => void;
3891
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
3848
3892
  messageTemplateErrorFallback?: ReactNode;
3849
3893
  messageTemplateLoadingFallback?: ReactNode;
3850
3894
  } & {
@@ -3923,6 +3967,7 @@ export declare const IncomingMessageLayout: {
3923
3967
  onStreamAnimationStart?: () => void;
3924
3968
  onStreamAnimationProgress?: () => void;
3925
3969
  onStreamAnimationComplete?: () => void;
3970
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
3926
3971
  messageTemplateErrorFallback?: ReactNode;
3927
3972
  messageTemplateLoadingFallback?: ReactNode;
3928
3973
  } & {
@@ -3997,6 +4042,7 @@ export declare const IncomingMessageLayout: {
3997
4042
  onStreamAnimationStart?: () => void;
3998
4043
  onStreamAnimationProgress?: () => void;
3999
4044
  onStreamAnimationComplete?: () => void;
4045
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4000
4046
  messageTemplateErrorFallback?: ReactNode;
4001
4047
  messageTemplateLoadingFallback?: ReactNode;
4002
4048
  } & {
@@ -4075,6 +4121,7 @@ export declare const IncomingMessageLayout: {
4075
4121
  onStreamAnimationStart?: () => void;
4076
4122
  onStreamAnimationProgress?: () => void;
4077
4123
  onStreamAnimationComplete?: () => void;
4124
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4078
4125
  messageTemplateErrorFallback?: ReactNode;
4079
4126
  messageTemplateLoadingFallback?: ReactNode;
4080
4127
  } & {
@@ -4153,6 +4200,7 @@ export declare const IncomingMessageLayout: {
4153
4200
  onStreamAnimationStart?: () => void;
4154
4201
  onStreamAnimationProgress?: () => void;
4155
4202
  onStreamAnimationComplete?: () => void;
4203
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4156
4204
  messageTemplateErrorFallback?: ReactNode;
4157
4205
  messageTemplateLoadingFallback?: ReactNode;
4158
4206
  } & {
@@ -4254,6 +4302,7 @@ export declare const IncomingMessageLayout: {
4254
4302
  onStreamAnimationStart?: () => void;
4255
4303
  onStreamAnimationProgress?: () => void;
4256
4304
  onStreamAnimationComplete?: () => void;
4305
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4257
4306
  messageTemplateErrorFallback?: ReactNode;
4258
4307
  messageTemplateLoadingFallback?: ReactNode;
4259
4308
  } & {
@@ -4332,6 +4381,7 @@ export declare const IncomingMessageLayout: {
4332
4381
  onStreamAnimationStart?: () => void;
4333
4382
  onStreamAnimationProgress?: () => void;
4334
4383
  onStreamAnimationComplete?: () => void;
4384
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4335
4385
  messageTemplateErrorFallback?: ReactNode;
4336
4386
  messageTemplateLoadingFallback?: ReactNode;
4337
4387
  } & {
@@ -4410,6 +4460,7 @@ export declare const IncomingMessageLayout: {
4410
4460
  onStreamAnimationStart?: () => void;
4411
4461
  onStreamAnimationProgress?: () => void;
4412
4462
  onStreamAnimationComplete?: () => void;
4463
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4413
4464
  messageTemplateErrorFallback?: ReactNode;
4414
4465
  messageTemplateLoadingFallback?: ReactNode;
4415
4466
  } & {
@@ -4484,6 +4535,7 @@ export declare const IncomingMessageLayout: {
4484
4535
  onStreamAnimationStart?: () => void;
4485
4536
  onStreamAnimationProgress?: () => void;
4486
4537
  onStreamAnimationComplete?: () => void;
4538
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4487
4539
  messageTemplateErrorFallback?: ReactNode;
4488
4540
  messageTemplateLoadingFallback?: ReactNode;
4489
4541
  } & {
@@ -4562,6 +4614,7 @@ export declare const IncomingMessageLayout: {
4562
4614
  onStreamAnimationStart?: () => void;
4563
4615
  onStreamAnimationProgress?: () => void;
4564
4616
  onStreamAnimationComplete?: () => void;
4617
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4565
4618
  messageTemplateErrorFallback?: ReactNode;
4566
4619
  messageTemplateLoadingFallback?: ReactNode;
4567
4620
  } & {
@@ -4640,6 +4693,7 @@ export declare const IncomingMessageLayout: {
4640
4693
  onStreamAnimationStart?: () => void;
4641
4694
  onStreamAnimationProgress?: () => void;
4642
4695
  onStreamAnimationComplete?: () => void;
4696
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4643
4697
  messageTemplateErrorFallback?: ReactNode;
4644
4698
  messageTemplateLoadingFallback?: ReactNode;
4645
4699
  } & {
@@ -4764,6 +4818,7 @@ export declare const IncomingMessageLayout: {
4764
4818
  onStreamAnimationStart?: () => void;
4765
4819
  onStreamAnimationProgress?: () => void;
4766
4820
  onStreamAnimationComplete?: () => void;
4821
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4767
4822
  messageTemplateErrorFallback?: ReactNode;
4768
4823
  messageTemplateLoadingFallback?: ReactNode;
4769
4824
  } & {
@@ -4842,6 +4897,7 @@ export declare const IncomingMessageLayout: {
4842
4897
  onStreamAnimationStart?: () => void;
4843
4898
  onStreamAnimationProgress?: () => void;
4844
4899
  onStreamAnimationComplete?: () => void;
4900
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4845
4901
  messageTemplateErrorFallback?: ReactNode;
4846
4902
  messageTemplateLoadingFallback?: ReactNode;
4847
4903
  } & {
@@ -4920,6 +4976,7 @@ export declare const IncomingMessageLayout: {
4920
4976
  onStreamAnimationStart?: () => void;
4921
4977
  onStreamAnimationProgress?: () => void;
4922
4978
  onStreamAnimationComplete?: () => void;
4979
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4923
4980
  messageTemplateErrorFallback?: ReactNode;
4924
4981
  messageTemplateLoadingFallback?: ReactNode;
4925
4982
  } & {
@@ -4996,6 +5053,7 @@ export declare const IncomingMessageLayout: {
4996
5053
  onStreamAnimationStart?: () => void;
4997
5054
  onStreamAnimationProgress?: () => void;
4998
5055
  onStreamAnimationComplete?: () => void;
5056
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
4999
5057
  messageTemplateErrorFallback?: ReactNode;
5000
5058
  messageTemplateLoadingFallback?: ReactNode;
5001
5059
  } & {
@@ -5074,6 +5132,7 @@ export declare const IncomingMessageLayout: {
5074
5132
  onStreamAnimationStart?: () => void;
5075
5133
  onStreamAnimationProgress?: () => void;
5076
5134
  onStreamAnimationComplete?: () => void;
5135
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
5077
5136
  messageTemplateErrorFallback?: ReactNode;
5078
5137
  messageTemplateLoadingFallback?: ReactNode;
5079
5138
  } & {
@@ -5152,6 +5211,7 @@ export declare const IncomingMessageLayout: {
5152
5211
  onStreamAnimationStart?: () => void;
5153
5212
  onStreamAnimationProgress?: () => void;
5154
5213
  onStreamAnimationComplete?: () => void;
5214
+ onStreamAnimationHoldChange?: (holding: boolean) => void;
5155
5215
  messageTemplateErrorFallback?: ReactNode;
5156
5216
  messageTemplateLoadingFallback?: ReactNode;
5157
5217
  } & {
@@ -5633,6 +5693,9 @@ declare class MessagePendingStuckStatsTracker extends MultiStatsTrackerBase<Mess
5633
5693
  }
5634
5694
  }
5635
5695
 
5696
+ /** How a message's sender is drawn: the typing row's user and every message row's sender share this. */
5697
+ declare type MessageSenderInfo = { userId: string; nickname: string; profileUrl?: string };
5698
+
5636
5699
  declare interface MessageTemplateCache {
5637
5700
  set(key: string, value: string): void;
5638
5701
  get(key: string): string | null;
@@ -6636,6 +6699,25 @@ declare enum StewardTaskStatus {
6636
6699
  CANCELED = 'CANCELED',
6637
6700
  }
6638
6701
 
6702
+ declare type StreamAnimation = {
6703
+ isAnimating: boolean;
6704
+ start: (id: string | number) => void;
6705
+ stop: (id: string | number) => void;
6706
+ isHolding: (id: string | number) => boolean;
6707
+ /**
6708
+ * Set while a row holds its streamed text. The list draws a single typing row, so it falls back to
6709
+ * this when nobody is typing — a live typing signal always wins.
6710
+ *
6711
+ * Never carries a thinking message, deliberately: a row enters the hold only after its reply started
6712
+ * streaming, so the agent's thinking phase is over by then — the frame is held back by our own start
6713
+ * gate, not by the agent still thinking. Relaying the last thinking text here would report a state it
6714
+ * has already left, so the typing row falls back to dots for this window.
6715
+ */
6716
+ heldTypingInfo?: TypingRowInfo;
6717
+ holdStart: (id: string | number, info: TypingRowInfo) => void;
6718
+ holdStop: (id: string | number) => void;
6719
+ };
6720
+
6639
6721
  declare type StreamMeasure = {
6640
6722
  channelUrl?: string;
6641
6723
  deliveryTimer: TimeoutId | null;
@@ -7166,6 +7248,10 @@ export declare type StringSet = {
7166
7248
  CHANNEL_FROZEN: string;
7167
7249
  };
7168
7250
 
7251
+ declare interface SubmitCPAAuthorizationCodesResponse {
7252
+ cpaAuthorizations: CPAAuthorizationResult[];
7253
+ }
7254
+
7169
7255
  declare type SystemBaseMessageProps<T> = T & BaseMessageProps<{}>;
7170
7256
 
7171
7257
  declare type SystemCSATMessageProps = SystemMessageProps & {
@@ -7513,6 +7599,16 @@ declare type TypingMeasure = {
7513
7599
  userMessageId?: number;
7514
7600
  };
7515
7601
 
7602
+ /**
7603
+ * What the list's single typing row renders, whoever it is drawn for. `user.userId` identifies the row
7604
+ * it stands in for, which is how the typing bridge tells the awaited reply from anyone else's.
7605
+ */
7606
+ declare type TypingRowInfo = {
7607
+ user: MessageSenderInfo;
7608
+ isBot: boolean;
7609
+ thinkingMessage?: string;
7610
+ };
7611
+
7516
7612
  declare type TypingTurnEntry = {
7517
7613
  requestId: string;
7518
7614
  record: StatsRecord<TypingIndicatorAbsentTimeoutStats, TypingMeasure>;