@csntgao/ai-employee-client 0.15.3 → 0.15.5

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
@@ -79,6 +79,11 @@ interface AiEmployeeClientEventMap {
79
79
  sessionId: string;
80
80
  message: AiEmployeeMessage;
81
81
  source: 'local' | 'realtime';
82
+ replacesMessageId?: string;
83
+ };
84
+ 'message-stream': {
85
+ sessionId: string;
86
+ message: AiEmployeeMessage;
82
87
  };
83
88
  title: {
84
89
  sessionId: string;
@@ -145,6 +150,7 @@ declare class AiEmployeeClient {
145
150
  private readonly listeners;
146
151
  private readonly seenMessageIds;
147
152
  private readonly pendingLocalMessages;
153
+ private readonly activeAssistantStreams;
148
154
  private assistantReceivedInCurrentTurn;
149
155
  private socket;
150
156
  private reconnectTimer;
@@ -193,6 +199,8 @@ declare class AiEmployeeClient {
193
199
  private handleSocketData;
194
200
  private handleServerMessage;
195
201
  private handleAiEmployeeEvent;
202
+ private applyAssistantStreamEvent;
203
+ private takeAssistantStream;
196
204
  private subscribeCurrentSession;
197
205
  private rememberPendingLocalMessage;
198
206
  /**
@@ -395,6 +403,7 @@ declare class CustomerSupportClient {
395
403
  private currentState;
396
404
  private socket;
397
405
  private heartbeatTimer;
406
+ private fallbackHistoryRefreshTimer;
398
407
  private reconnectTimer;
399
408
  private reconnectAttempt;
400
409
  private tokenReconnectAttempt;
@@ -405,6 +414,7 @@ declare class CustomerSupportClient {
405
414
  private shouldReconnect;
406
415
  private sending;
407
416
  private historyRefresh;
417
+ private pendingRealtimeHistoryRefreshSessionId;
408
418
  private sessionsRefresh;
409
419
  private readonly readCursorStates;
410
420
  private readLifecycleGeneration;
@@ -439,6 +449,8 @@ declare class CustomerSupportClient {
439
449
  private refreshSessionFromRealtime;
440
450
  private appendMessage;
441
451
  private startHeartbeat;
452
+ private startFallbackHistoryRefresh;
453
+ private stopFallbackHistoryRefresh;
442
454
  private handleSocketClose;
443
455
  private scheduleAvailabilityReconnect;
444
456
  private scheduleReconnect;
@@ -690,9 +702,22 @@ interface PingFrame {
690
702
  interface ParsedSessionMessage {
691
703
  messages: AiEmployeeMessage[];
692
704
  activities: string[];
705
+ streamEvents: ParsedAssistantStreamEvent[];
706
+ messageStreamReferences: ParsedAssistantMessageStreamReference[];
693
707
  fallbackResult?: AiEmployeeMessage;
694
708
  processing?: boolean;
695
709
  }
710
+ interface ParsedAssistantStreamEvent {
711
+ phase: 'start' | 'delta' | 'stop';
712
+ streamKey: string;
713
+ modelMessageId: string;
714
+ index: number;
715
+ delta?: string;
716
+ }
717
+ interface ParsedAssistantMessageStreamReference {
718
+ messageId: string;
719
+ modelMessageId: string;
720
+ }
696
721
  type ParsedAiEmployeeEvent = {
697
722
  kind: 'session-message';
698
723
  sessionId: string;
@@ -711,4 +736,4 @@ declare function parseJsonRecord(raw: string): JsonRecord | null;
711
736
  declare function parseAiEmployeeEvent(raw: unknown): ParsedAiEmployeeEvent;
712
737
  declare function hashText(value: string): string;
713
738
 
714
- export { type AiEmployeeAssistantAction, type AiEmployeeAttachmentReference, AiEmployeeClient, AiEmployeeClientError, type AiEmployeeClientErrorDetail, type AiEmployeeClientEventMap, type AiEmployeeClientListener, type AiEmployeeClientOptions, type AiEmployeeClientStartResult, type AiEmployeeConnectionState, type AiEmployeeErrorCode, type AiEmployeeFirstMessageOptions, type AiEmployeeFirstMessageRequest, type AiEmployeeFirstMessageRequestState, type AiEmployeeFirstMessageRequestStore, type AiEmployeeFirstMessageResult, type AiEmployeeMessage, type AiEmployeeMessageRole, type AiEmployeeReconnectOptions, type AiEmployeeSessionSummary, type AiEmployeeTransport, AiEmployeeTransportError, type AiEmployeeTransportErrorCode, type AiEmployeeWebSocketFactory, type AuthenticateFrame, type CustomerSupportAgent, type CustomerSupportAttachment, type CustomerSupportAttachmentDownloadRequest, CustomerSupportClient, CustomerSupportClientError, type CustomerSupportClientEventMap, type CustomerSupportClientListener, type CustomerSupportClientOptions, type CustomerSupportCreateSessionRequest, type CustomerSupportCreateSessionResult, type CustomerSupportErrorCode, type CustomerSupportErrorDetail, type CustomerSupportHandoffRequest, type CustomerSupportHandoffResult, type CustomerSupportMessage, type CustomerSupportMessagePage, type CustomerSupportSenderType, type CustomerSupportSession, type CustomerSupportSessionStatus, type CustomerSupportTransport, type NotificationAttachment, NotificationCenterClient, NotificationCenterClientError, type NotificationCenterClientEventMap, type NotificationCenterClientListener, type NotificationCenterClientOptions, type NotificationCenterErrorCode, type NotificationCenterErrorDetail, type NotificationCenterTransport, type NotificationContentType, type NotificationDto, type NotificationInboxQuery, type NotificationInboxResult, type NotificationMarkAllReadResult, type NotificationMarkReadResult, type NotificationReadStatus, type NotificationRealtimeChange, type NotificationResource, type NotificationSource, type NotificationTypeSummary, type OpenCustomerSupportAssistantAction, type OpenFileAssistantAction, type ParsedAiEmployeeAssistantContent, type ParsedAiEmployeeEvent, type ParsedSessionMessage, type PingFrame, type SessionSubscriptionFrame, createAuthenticateFrame, createPingFrame, createSubscriptionFrame, hashText, isUuidV4, parseAiEmployeeAssistantContent, parseAiEmployeeEvent, parseJsonRecord };
739
+ export { type AiEmployeeAssistantAction, type AiEmployeeAttachmentReference, AiEmployeeClient, AiEmployeeClientError, type AiEmployeeClientErrorDetail, type AiEmployeeClientEventMap, type AiEmployeeClientListener, type AiEmployeeClientOptions, type AiEmployeeClientStartResult, type AiEmployeeConnectionState, type AiEmployeeErrorCode, type AiEmployeeFirstMessageOptions, type AiEmployeeFirstMessageRequest, type AiEmployeeFirstMessageRequestState, type AiEmployeeFirstMessageRequestStore, type AiEmployeeFirstMessageResult, type AiEmployeeMessage, type AiEmployeeMessageRole, type AiEmployeeReconnectOptions, type AiEmployeeSessionSummary, type AiEmployeeTransport, AiEmployeeTransportError, type AiEmployeeTransportErrorCode, type AiEmployeeWebSocketFactory, type AuthenticateFrame, type CustomerSupportAgent, type CustomerSupportAttachment, type CustomerSupportAttachmentDownloadRequest, CustomerSupportClient, CustomerSupportClientError, type CustomerSupportClientEventMap, type CustomerSupportClientListener, type CustomerSupportClientOptions, type CustomerSupportCreateSessionRequest, type CustomerSupportCreateSessionResult, type CustomerSupportErrorCode, type CustomerSupportErrorDetail, type CustomerSupportHandoffRequest, type CustomerSupportHandoffResult, type CustomerSupportMessage, type CustomerSupportMessagePage, type CustomerSupportSenderType, type CustomerSupportSession, type CustomerSupportSessionStatus, type CustomerSupportTransport, type NotificationAttachment, NotificationCenterClient, NotificationCenterClientError, type NotificationCenterClientEventMap, type NotificationCenterClientListener, type NotificationCenterClientOptions, type NotificationCenterErrorCode, type NotificationCenterErrorDetail, type NotificationCenterTransport, type NotificationContentType, type NotificationDto, type NotificationInboxQuery, type NotificationInboxResult, type NotificationMarkAllReadResult, type NotificationMarkReadResult, type NotificationReadStatus, type NotificationRealtimeChange, type NotificationResource, type NotificationSource, type NotificationTypeSummary, type OpenCustomerSupportAssistantAction, type OpenFileAssistantAction, type ParsedAiEmployeeAssistantContent, type ParsedAiEmployeeEvent, type ParsedAssistantMessageStreamReference, type ParsedAssistantStreamEvent, type ParsedSessionMessage, type PingFrame, type SessionSubscriptionFrame, createAuthenticateFrame, createPingFrame, createSubscriptionFrame, hashText, isUuidV4, parseAiEmployeeAssistantContent, parseAiEmployeeEvent, parseJsonRecord };