@csntgao/ai-employee-client 0.15.4 → 0.15.6

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;
@@ -165,6 +171,7 @@ declare class AiEmployeeClient {
165
171
  private socketAuthenticationFailure;
166
172
  private availabilityReconnectAttempt;
167
173
  private pendingFirstMessage;
174
+ private sessionListResolved;
168
175
  constructor(options: AiEmployeeClientOptions);
169
176
  get connectionState(): AiEmployeeConnectionState;
170
177
  get sessionId(): string | null;
@@ -193,6 +200,8 @@ declare class AiEmployeeClient {
193
200
  private handleSocketData;
194
201
  private handleServerMessage;
195
202
  private handleAiEmployeeEvent;
203
+ private applyAssistantStreamEvent;
204
+ private takeAssistantStream;
196
205
  private subscribeCurrentSession;
197
206
  private rememberPendingLocalMessage;
198
207
  /**
@@ -395,6 +404,7 @@ declare class CustomerSupportClient {
395
404
  private currentState;
396
405
  private socket;
397
406
  private heartbeatTimer;
407
+ private fallbackHistoryRefreshTimer;
398
408
  private reconnectTimer;
399
409
  private reconnectAttempt;
400
410
  private tokenReconnectAttempt;
@@ -410,6 +420,7 @@ declare class CustomerSupportClient {
410
420
  private readonly readCursorStates;
411
421
  private readLifecycleGeneration;
412
422
  private requestedSessionId;
423
+ private sessionListResolved;
413
424
  constructor(options: CustomerSupportClientOptions);
414
425
  get session(): CustomerSupportSession | null;
415
426
  get messages(): readonly CustomerSupportMessage[];
@@ -440,6 +451,8 @@ declare class CustomerSupportClient {
440
451
  private refreshSessionFromRealtime;
441
452
  private appendMessage;
442
453
  private startHeartbeat;
454
+ private startFallbackHistoryRefresh;
455
+ private stopFallbackHistoryRefresh;
443
456
  private handleSocketClose;
444
457
  private scheduleAvailabilityReconnect;
445
458
  private scheduleReconnect;
@@ -691,9 +704,22 @@ interface PingFrame {
691
704
  interface ParsedSessionMessage {
692
705
  messages: AiEmployeeMessage[];
693
706
  activities: string[];
707
+ streamEvents: ParsedAssistantStreamEvent[];
708
+ messageStreamReferences: ParsedAssistantMessageStreamReference[];
694
709
  fallbackResult?: AiEmployeeMessage;
695
710
  processing?: boolean;
696
711
  }
712
+ interface ParsedAssistantStreamEvent {
713
+ phase: 'start' | 'delta' | 'stop';
714
+ streamKey: string;
715
+ modelMessageId: string;
716
+ index: number;
717
+ delta?: string;
718
+ }
719
+ interface ParsedAssistantMessageStreamReference {
720
+ messageId: string;
721
+ modelMessageId: string;
722
+ }
697
723
  type ParsedAiEmployeeEvent = {
698
724
  kind: 'session-message';
699
725
  sessionId: string;
@@ -712,4 +738,4 @@ declare function parseJsonRecord(raw: string): JsonRecord | null;
712
738
  declare function parseAiEmployeeEvent(raw: unknown): ParsedAiEmployeeEvent;
713
739
  declare function hashText(value: string): string;
714
740
 
715
- 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 };
741
+ 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 };