@ujet/websdk-headless 6.33.0 → 6.35.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
@@ -172,6 +172,8 @@ interface ChatResponse {
172
172
  post_session_opt_in_required?: boolean;
173
173
  post_session_transfer_status?: string;
174
174
  check_in_status?: CheckInStatus;
175
+ /** Whether a task virtual agent is active on the chat; only on the single-chat read, and absent on older servers. */
176
+ task_virtual_agent_active?: boolean | undefined;
175
177
  }
176
178
  interface CallApiResponse {
177
179
  created_at: string;
@@ -661,6 +663,38 @@ interface CobrowseOption {
661
663
  hideSessionControls?: () => void;
662
664
  }
663
665
 
666
+ type SendStatus = 'sending' | 'sent' | 'failed' | 'discarded';
667
+ type SendFailureReason = 'timeout' | 'disconnected' | 'chat_ended' | 'rejected' | 'upload_failed';
668
+ interface SendFailure {
669
+ readonly reason: SendFailureReason;
670
+ /**
671
+ * Whether the SDK resends on its own; always false once the message is `failed`. A manual retry is allowed
672
+ * for every reason but chat_ended.
673
+ */
674
+ readonly retryable: boolean;
675
+ }
676
+ interface OutgoingMessageStatusBase {
677
+ readonly client_message_id: string;
678
+ readonly status: SendStatus;
679
+ /** When the user pressed send, or Retry. */
680
+ readonly $timestamp: Date;
681
+ /** 1 for the first send, +1 for every automatic or manual resend. */
682
+ readonly attempt: number;
683
+ readonly error?: SendFailure | undefined;
684
+ }
685
+ interface OutgoingTextStatus extends OutgoingMessageStatusBase {
686
+ readonly type: 'text';
687
+ readonly content: string;
688
+ }
689
+ interface OutgoingFileStatus extends OutgoingMessageStatusBase {
690
+ readonly type: 'photo' | 'video' | 'document' | 'file';
691
+ /** The File passed to sendFileMessage; pairs the status with the preview shown for it. */
692
+ readonly file: File;
693
+ /** Set once the upload is done; an automatic resend publishes it again without uploading. */
694
+ readonly media_id?: number | undefined;
695
+ }
696
+ type OutgoingMessageStatus = OutgoingTextStatus | OutgoingFileStatus;
697
+
664
698
  declare class EventManager {
665
699
  private handlers;
666
700
  addEventListener(eventName: string, handler: EventHandler): void;
@@ -743,6 +777,18 @@ declare abstract class BaseProvider {
743
777
  protected cleanupAudio(): void;
744
778
  on(eventName: string, handler: EventHandler): void;
745
779
  off(eventName: string, handler: EventHandler): void;
780
+ /**
781
+ * Whether sends can go through the outbox: the echo carries the sent `client_message_id` back, and
782
+ * publishTracked() rejects with errors classifySendError() can tell apart. A provider that has it also
783
+ * emits SEND_READY_EVENT whenever the transport comes back.
784
+ */
785
+ get tracksSends(): boolean;
786
+ /** Whether a publish can go out right now; only read when tracksSends. */
787
+ get canPublish(): boolean;
788
+ /** One publish attempt for the outbox, rejecting when the message does not go out; only called when tracksSends. */
789
+ publishTracked(_message: MessageRequest): Promise<void>;
790
+ /** The key a file send's echo carries as `$index`, for pairing its File; '' when there is none. */
791
+ attachmentKeyOf(_message: MessageRequest): AttachmentKey;
746
792
  trackInTask(message: MessageResponse): void;
747
793
  abstract create(): Promise<void>;
748
794
  abstract destroy(): Promise<void>;
@@ -764,6 +810,8 @@ interface ChatHooks {
764
810
  isRiskFlagEnabled?: (flagName: string) => boolean;
765
811
  /** Ownership-checked lookup of a redacted message's original; rejects with `{ status }` on HTTP errors. */
766
812
  fetchMessageOriginal?: (redactionRef: number) => Promise<ChatMessageOriginalResponse>;
813
+ /** The server's current task-VA state for this chat; undefined when the server does not report it. */
814
+ fetchTaskVaActive?: (() => Promise<boolean | undefined>) | undefined;
767
815
  }
768
816
  declare class Chat {
769
817
  private provider;
@@ -785,6 +833,15 @@ declare class Chat {
785
833
  private beaconAttempted;
786
834
  private connecting;
787
835
  private connectEnd;
836
+ private outbox;
837
+ private sendTrackingReleased;
838
+ private newestSid;
839
+ private sendFloors;
840
+ private sentAwaitingEcho;
841
+ private pairedEchoIds;
842
+ private sentFiles;
843
+ private taskStateResync;
844
+ private readonly onTaskStateSignal;
788
845
  constructor(state: ChatResponse, issueChatToken: IssueChatTokenMethod, hooks?: ChatHooks, providerContext?: ProviderContext);
789
846
  private handleConnectionEnded;
790
847
  private endConnection;
@@ -841,6 +898,34 @@ declare class Chat {
841
898
  * `chat` is public too. Pairing still uses the provider's wide key.
842
899
  */
843
900
  sendMessage(message: MessageRequest, file?: File): Promise<number>;
901
+ /** Messages sent through the outbox and not confirmed yet, oldest first; empty when nothing is tracked. */
902
+ get outgoingMessages(): readonly OutgoingMessageStatus[];
903
+ private saveSentFile;
904
+ private statusOf;
905
+ /**
906
+ * The File of the tracked send an own media echo answers — by client_message_id, or by media_id for an echo
907
+ * without it — saved under the echo's key, so the live path and a later history page show the same preview.
908
+ */
909
+ private pairSentFile;
910
+ private sentFileByMediaId;
911
+ /**
912
+ * Confirms the tracked send an echo answers. An own text or media echo that matches a held message but
913
+ * carries no client_message_id means echoes cannot be paired on this chat: the oldest match that was handed
914
+ * to the transport is confirmed, and tracking stops instead of failing a message the agent may already have.
915
+ * The echo is given that send's client_message_id, so listeners pair it by id as the SDK did.
916
+ */
917
+ private settleOwnEcho;
918
+ /**
919
+ * An own echo without the id that comes after its send was reported `sent` (the ack came first, or release()
920
+ * ended it) gets that send's id too, by the same checks, so listeners still pair it by id.
921
+ */
922
+ private pairLateEcho;
923
+ private givePairedId;
924
+ private awaitEcho;
925
+ private forgetSent;
926
+ /** Whether the message was published after this send was queued. With nothing seen before the send, any is. */
927
+ private isAfterSend;
928
+ private noteSid;
844
929
  preview(text: string | undefined): Promise<void>;
845
930
  fetchMessages(): Promise<MessageResponse[]>;
846
931
  /**
@@ -859,6 +944,7 @@ declare class Chat {
859
944
  private surfacesSubscriptionEnd;
860
945
  private settleEndedConnect;
861
946
  private localOriginalCacheEnabled;
947
+ private sanitizesInboundPaths;
862
948
  /**
863
949
  * Joins the original onto `message.unredacted` for the end user's own
864
950
  * redacted text: local cache → in-band `unredacted` → (returns true) a
@@ -881,6 +967,7 @@ declare class Chat {
881
967
  stopTyping(): void;
882
968
  saveMedia(index: AttachmentKey, file: File): void;
883
969
  destroy(): Promise<void>;
970
+ private startTaskStateResync;
884
971
  clearMediaStore(): Promise<void>;
885
972
  private triggerEvent;
886
973
  private registerProviderEvents;
@@ -1217,6 +1304,7 @@ declare class Client {
1217
1304
  private _voiceTabLock;
1218
1305
  private redactionSendQueue;
1219
1306
  private fileSendQueue;
1307
+ private noCryptoLogged;
1220
1308
  private _rehydratePromise;
1221
1309
  private onPageHide?;
1222
1310
  private onPageShow?;
@@ -1385,8 +1473,23 @@ declare class Client {
1385
1473
  trackChatEndUserEvent(data: ChatEndUserEventRequest): Promise<void>;
1386
1474
  getChatHistory(page?: number): Promise<ChatHistoryResponse | null>;
1387
1475
  fetchMessages(): Promise<MessageResponse[]>;
1476
+ private sanitizeFetchedMessages;
1477
+ /**
1478
+ * On a chat that tracks sends, the upload is done once and its response goes through the outbox: status
1479
+ * events follow, carrying this `file`, and a resend or retry publishes the same response without uploading
1480
+ * again. An upload failure is unchanged.
1481
+ */
1388
1482
  sendFileMessage(file: File): Promise<number>;
1389
- sendTextMessage(rawContent: string): Promise<void>;
1483
+ /**
1484
+ * Resolves with the message's client_message_id when the SDK tracks it: status events follow for that id.
1485
+ * `undefined` means the SDK isn't tracking the message; it is not a failure.
1486
+ */
1487
+ sendTextMessage(rawContent: string): Promise<string | undefined>;
1488
+ private warnNoCrypto;
1489
+ /** Sends a `failed` message again with the same id. False for an unknown id, a message not `failed`, or an ended chat. */
1490
+ retryMessage(clientMessageId: string): boolean;
1491
+ /** Removes a `failed` message; its last status is `discarded`. False when there is no such message. */
1492
+ discardMessage(clientMessageId: string): boolean;
1390
1493
  sendPreviewMessage(content: string): Promise<void>;
1391
1494
  private isRedactionAgentEnabled;
1392
1495
  createCobrowseCode(lang?: string, customData?: Record<string, string>): Promise<string>;
@@ -1542,4 +1645,4 @@ declare const COBROWSE_EVENTS: {
1542
1645
  };
1543
1646
  type CobrowseEvent = (typeof COBROWSE_EVENTS)[keyof typeof COBROWSE_EVENTS];
1544
1647
 
1545
- export { AnotherTabVoiceCallError, type AttachmentKey, BaseProvider, BaseVoiceProvider, COBROWSE_EVENTS, type CallApiResponse, CallInProgressError, type CallRequest, type CallResponse, ChannelType, Chat, type ChatDeflectionResponse, type ChatDocumentItem, type ChatEndUserEventRequest, ChatEndedError, type ChatHistoryItem, type ChatHistoryResponse, type ChatMessageOriginalResponse, type ChatMessageRequest, type ChatMessageResponse, type ChatRequest, type ChatResponse, type ChatSurveyResponse, type ChatTaskMessageResponse, type CheckInModalStateRequest, type CheckInResponse, CheckInStatus, type CheckInVisibilityStateRequest, Client, type ClientEvent, type ClientOption, type CobrowseEvent, type CobrowseMessages, type CobrowseOption, type CobrowseRequest, type CompanyResponse, type ConnectCallback, type ConnectOption, type ConnectRequest, type ConnectResult, type ConnectionQualityLevel, type ConnectionQualityWarning, type CustomFormPayload, ENVIRONMENT, type EmailRequest, type EmailResponse, type EscalateRequest, type EventHandler, EventManager, type FeatureFlagsResponse, FeatureNotEnabledError, type FileTypeItem, type FormData, type GenerateTranscriptResponse, type GetServerMessage, type GetTimeSlotsRequest, type HumanAgent, InboundDisabledError, type IssueChatTokenMethod, type IssueVoiceTokenMethod, type LanguageOption, type LogData, type LogHistoryData, Logger, type LoggerHandler, type MediaIndex, type MediaRef, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MenusRoutingInputs, type MessageRequest, type MessageResponse, MessageType, MicPermissionDeniedError, type MicPermissionState, NoActiveVoiceCallError, NotiEvent, OPTIONS, OperationHoursError, type PdfStatusResponse, PostSessionStatus, type ProviderContext, ProviderError, ProviderType, type QuestionItem, RISK_FLAG_EVENTS, type RateRequest, type RecordingOption, type RecordingPermission, type RefusedBy, type RequestMethod, type RequestReturn, type ServerAuthResponse, type ServerVoiceCallStatus, SmartActionError, type SmartActionMediaType, type SmartActionResponse, type SmartActionType, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, type UjetConversationHistoryQuery, type UjetConversationHistoryResponse, type UjetConversationMessageItem, UnauthorizedError, UnknownVoiceError, type UserProfile, UserType, VERSION, VOICE_EVENTS, type VirtualAgent, VoiceCall, VoiceCallError, type VoiceCallRequest, type VoiceCallResponse, type VoiceCallStatus, type VoiceCobrowseRequestedEvent, type VoiceCobrowseResolvedEvent, type VoiceConnectionQualityEvent, type VoiceErrorCode, type VoiceErrorEvent, type VoiceFeedbackType, type VoiceProviderConstructor, type VoiceProviderMessage, type VoiceProviderMessageType, type VoiceRecordingPermissionRequiredEvent, type VoiceSmartActionRequestedEvent, type VoiceSmartActionResolvedEvent, type VoiceStatusChangedEvent, type WaitTimeResponse, addProviderType, addVoiceProviderType, getErrorMessage, getErrorStatus, getVoiceProviderType, hasErrorCode, isAfterHoursError, isMobilePlatform, toIdentity };
1648
+ export { AnotherTabVoiceCallError, type AttachmentKey, BaseProvider, BaseVoiceProvider, COBROWSE_EVENTS, type CallApiResponse, CallInProgressError, type CallRequest, type CallResponse, ChannelType, Chat, type ChatDeflectionResponse, type ChatDocumentItem, type ChatEndUserEventRequest, ChatEndedError, type ChatHistoryItem, type ChatHistoryResponse, type ChatMessageOriginalResponse, type ChatMessageRequest, type ChatMessageResponse, type ChatRequest, type ChatResponse, type ChatSurveyResponse, type ChatTaskMessageResponse, type CheckInModalStateRequest, type CheckInResponse, CheckInStatus, type CheckInVisibilityStateRequest, Client, type ClientEvent, type ClientOption, type CobrowseEvent, type CobrowseMessages, type CobrowseOption, type CobrowseRequest, type CompanyResponse, type ConnectCallback, type ConnectOption, type ConnectRequest, type ConnectResult, type ConnectionQualityLevel, type ConnectionQualityWarning, type CustomFormPayload, ENVIRONMENT, type EmailRequest, type EmailResponse, type EscalateRequest, type EventHandler, EventManager, type FeatureFlagsResponse, FeatureNotEnabledError, type FileTypeItem, type FormData, type GenerateTranscriptResponse, type GetServerMessage, type GetTimeSlotsRequest, type HumanAgent, InboundDisabledError, type IssueChatTokenMethod, type IssueVoiceTokenMethod, type LanguageOption, type LogData, type LogHistoryData, Logger, type LoggerHandler, type MediaIndex, type MediaRef, MediaStore, type MenuChannel, type MenuItem, type MenuResponse, type MenusRoutingInputs, type MessageRequest, type MessageResponse, MessageType, MicPermissionDeniedError, type MicPermissionState, NoActiveVoiceCallError, NotiEvent, OPTIONS, OperationHoursError, type OutgoingFileStatus, type OutgoingMessageStatus, type OutgoingTextStatus, type PdfStatusResponse, PostSessionStatus, type ProviderContext, ProviderError, ProviderType, type QuestionItem, RISK_FLAG_EVENTS, type RateRequest, type RecordingOption, type RecordingPermission, type RefusedBy, type RequestMethod, type RequestReturn, type SendFailure, type SendFailureReason, type SendStatus, type ServerAuthResponse, type ServerVoiceCallStatus, SmartActionError, type SmartActionMediaType, type SmartActionResponse, type SmartActionType, type SurveyAnswers, type TokenResponse, type TriggerItem, type TriggerMessage, type UjetConversationHistoryQuery, type UjetConversationHistoryResponse, type UjetConversationMessageItem, UnauthorizedError, UnknownVoiceError, type UserProfile, UserType, VERSION, VOICE_EVENTS, type VirtualAgent, VoiceCall, VoiceCallError, type VoiceCallRequest, type VoiceCallResponse, type VoiceCallStatus, type VoiceCobrowseRequestedEvent, type VoiceCobrowseResolvedEvent, type VoiceConnectionQualityEvent, type VoiceErrorCode, type VoiceErrorEvent, type VoiceFeedbackType, type VoiceProviderConstructor, type VoiceProviderMessage, type VoiceProviderMessageType, type VoiceRecordingPermissionRequiredEvent, type VoiceSmartActionRequestedEvent, type VoiceSmartActionResolvedEvent, type VoiceStatusChangedEvent, type WaitTimeResponse, addProviderType, addVoiceProviderType, getErrorMessage, getErrorStatus, getVoiceProviderType, hasErrorCode, isAfterHoursError, isMobilePlatform, toIdentity };