@alxxsck/ai-assistant 2.12.0 → 2.14.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.
@@ -1,6 +1,7 @@
1
1
  import type { AppApi } from "@/App";
2
2
  import type { WidgetConfig } from "@/index.types";
3
- import { type ConversationData, type MessageData, type RawMessageData } from "./messages.api.types";
3
+ import { type ConversationData, type MessageData, type RawMessageData, type SendMessageResult } from "./messages.api.types";
4
+ import type { ChatAttachment } from "@/domain/message/chat-experience";
4
5
  export declare const MAX_FETCH_MESSAGES = 100;
5
6
  export type CursorPage<T> = {
6
7
  items: T[];
@@ -17,5 +18,5 @@ export declare const listConversations: (config: WidgetConfig, api: AppApi, curs
17
18
  export declare const listConversationMessages: (config: WidgetConfig, api: AppApi, conversationId: string, cursor?: string, signal?: AbortSignal) => Promise<CursorPage<MessageData>>;
18
19
  export declare const createConversation: (config: WidgetConfig, api: AppApi) => Promise<ConversationData>;
19
20
  export declare const selectConversation: (config: WidgetConfig, api: AppApi, conversationId: string, signal?: AbortSignal) => Promise<ConversationData>;
20
- export declare function sendMessage(config: WidgetConfig, api: AppApi, messageText: string, conversationId?: string, clientMessageId?: `${string}-${string}-${string}-${string}-${string}`): Promise<MessageData>;
21
+ export declare function sendMessage(config: WidgetConfig, api: AppApi, messageText: string, conversationId?: string, clientMessageId?: `${string}-${string}-${string}-${string}-${string}`, attachments?: readonly ChatAttachment[]): Promise<SendMessageResult>;
21
22
  export {};
@@ -15,6 +15,16 @@ export declare enum ParticipantType {
15
15
  export type ChatParticipant = {
16
16
  id: string;
17
17
  type: ParticipantType;
18
+ displayName?: string;
19
+ avatarUrl?: string | null;
20
+ };
21
+ export type MessageDelivery = {
22
+ id: string;
23
+ channel: "SDK_REALTIME";
24
+ status: "PENDING" | "DELIVERING" | "DELIVERED" | "READ" | "FAILED" | "CANCELLED";
25
+ /** Omitted by realtime delivery claims; present in authoritative history. */
26
+ acceptedAt?: string;
27
+ interactionSessionId?: string | null;
18
28
  };
19
29
  export declare enum MessageStatus {
20
30
  Completed = "MESSAGE_STATUS_COMPLETED",
@@ -47,14 +57,36 @@ export type MessageData = {
47
57
  lastThreadMessageAt: string;
48
58
  createdAt: string;
49
59
  updatedAt: string;
50
- attachments: [];
60
+ attachments: ChatAttachment[];
51
61
  threadParticipants: ChatParticipant[];
52
62
  mentions: [];
53
63
  reactions: [];
54
64
  isPinned: boolean;
55
65
  forwardCount: number;
66
+ ordinal?: number;
67
+ delivery?: MessageDelivery;
68
+ clientMessageId?: string | null;
69
+ };
70
+ /**
71
+ * Result of accepting a customer message. `assistantMessage` is deliberately
72
+ * nullable: during a human handoff the backend can accept the message without
73
+ * admitting it to Lola's intake.
74
+ */
75
+ export type SendMessageResult = {
76
+ conversationId: string;
77
+ assistantMessage: MessageData | null;
78
+ assistantAdmitted: boolean;
79
+ aiSuspension: ConversationAISuspension | null;
56
80
  };
57
81
  export type ConversationStatus = "OPEN" | "CLOSED";
82
+ /** Authoritative per-conversation AI mode returned by Lola Backend. */
83
+ export type ConversationAISuspension = {
84
+ mode: "SUSPENDED" | "AUTOMATIC";
85
+ lifecycle: "NONE" | "ACTIVE" | "EXPIRED" | "RESUMED";
86
+ version: string;
87
+ serverTime: string;
88
+ suspendedUntil: string | null;
89
+ };
58
90
  export type ConversationData = {
59
91
  id: string;
60
92
  title: string | null;
@@ -66,6 +98,7 @@ export type ConversationData = {
66
98
  messages: number;
67
99
  };
68
100
  messages?: RawMessageData[];
101
+ aiSuspension?: ConversationAISuspension;
69
102
  };
70
103
  export type RawMessageData = {
71
104
  id: string;
@@ -75,6 +108,14 @@ export type RawMessageData = {
75
108
  text: string;
76
109
  content: JSONContent | null;
77
110
  commands: unknown[];
111
+ ordinal?: number;
112
+ clientMessageId?: string | null;
113
+ author?: {
114
+ displayName?: string;
115
+ avatarUrl?: string | null;
116
+ } | null;
117
+ attachments?: ChatAttachment[];
118
+ delivery?: MessageDelivery;
78
119
  createdAt: string;
79
120
  updatedAt: string;
80
121
  };
@@ -91,4 +132,5 @@ export type ChatMessageDeltaData = {
91
132
  text: string;
92
133
  done: boolean;
93
134
  };
135
+ import type { ChatAttachment } from "@/domain/message/chat-experience";
94
136
  export {};
@@ -3,7 +3,9 @@ import type { WidgetConfig } from "@/index.types";
3
3
  import type { VoiceSessionData } from "./voice.api.types";
4
4
  export declare class VoiceApiError extends Error {
5
5
  readonly status: number;
6
- constructor(status: number, message: string);
6
+ readonly code?: string | undefined;
7
+ readonly details?: Record<string, unknown> | undefined;
8
+ constructor(status: number, message: string, code?: string | undefined, details?: Record<string, unknown> | undefined);
7
9
  }
8
10
  export declare const parseVoiceSession: (value: unknown) => VoiceSessionData;
9
11
  export declare const startVoiceSession: (config: WidgetConfig, api: AppApi, conversationId?: string) => Promise<VoiceSessionData>;
@@ -1,7 +1,8 @@
1
- import { J as L, K as s, S as t, L as E } from "./index-CjC1YCB_.js";
1
+ import { S as A, T as e, W as s, x as n, U as r } from "./index-mn1rW9m7.js";
2
2
  export {
3
- L as ChatWidgetInstance,
4
- s as EXTERNALLY_AVAILABLE_ACTIONS,
5
- t as SUPPORTED_LOCALES,
6
- E as isExternallyAvailableAction
3
+ A as ChatWidgetInstance,
4
+ e as EXTERNALLY_AVAILABLE_ACTIONS,
5
+ s as SUPPORTED_LOCALES,
6
+ n as createMockAttachmentTransport,
7
+ r as isExternallyAvailableAction
7
8
  };
@@ -28,6 +28,10 @@ export declare class AnyCableService {
28
28
  unsubscribe(channel: Channel): this;
29
29
  acknowledgeCommand(ack: CommandAck): Promise<unknown>;
30
30
  submitScenarioChoice(input: ScenarioChoiceInput): Promise<unknown>;
31
+ acknowledgeMessageDelivery(input: {
32
+ messageId: string;
33
+ status: "delivered" | "read";
34
+ }): Promise<unknown>;
31
35
  /** Registers the cable and subscribes to the bridge channel */
32
36
  private register;
33
37
  /** Unregisters the cable and disconnects from the WebSocket server */
@@ -3,7 +3,7 @@ import type { CommandAck } from "@/domain/command/command.types";
3
3
  import type { CommandRuntime } from "@/domain/command/CommandRuntime";
4
4
  import type { MessageStoreActions } from "@/domain/message/message.store";
5
5
  type WidgetFrameDependencies = {
6
- messageActions: Pick<MessageStoreActions, "handleConversationCreated" | "handleMessageDelta" | "handleMessagesAgenticSteps" | "handleMessage">;
6
+ messageActions: Pick<MessageStoreActions, "handleConversationCreated" | "handleMessageDelta" | "handleMessagesAgenticSteps" | "handleMessage" | "handleChatTyping" | "handleSupportPresence">;
7
7
  commandRuntime: CommandRuntime;
8
8
  session: CustomerInteractionSession;
9
9
  sendAck: (ack: CommandAck) => Promise<unknown>;
@@ -0,0 +1,44 @@
1
+ export type ChatAttachmentKind = "image" | "document";
2
+ export type ChatAttachment = {
3
+ id: string;
4
+ fileName: string;
5
+ mediaType: string;
6
+ size: number;
7
+ kind: ChatAttachmentKind;
8
+ downloadUrl: string;
9
+ previewUrl?: string;
10
+ };
11
+ export type ChatAttachmentUploadInput = {
12
+ file: File;
13
+ signal?: AbortSignal;
14
+ onProgress?: (progress: number) => void;
15
+ };
16
+ export interface ChatAttachmentTransport {
17
+ upload(input: ChatAttachmentUploadInput): Promise<ChatAttachment>;
18
+ }
19
+ export type ChatTypingState = {
20
+ conversationId: string;
21
+ actor: "ASSISTANT" | "ADMIN";
22
+ active: boolean;
23
+ displayName?: string;
24
+ avatarUrl?: string | null;
25
+ };
26
+ export type SupportPresenceState = {
27
+ conversationId: string;
28
+ live: boolean;
29
+ displayName?: string;
30
+ avatarUrl?: string | null;
31
+ };
32
+ /**
33
+ * Opt-in future frame fields. Unknown frames are ignored so the SDK remains
34
+ * compatible with the currently shipped backend, which does not emit them yet.
35
+ */
36
+ export declare const normalizeChatExperienceFrame: (frame: unknown) => {
37
+ typing: ChatTypingState | null;
38
+ presence: SupportPresenceState | null;
39
+ };
40
+ /**
41
+ * A deterministic transport for visual QA and integration tests. Production
42
+ * integrators replace it with their signed-upload adapter through WidgetConfig.
43
+ */
44
+ export declare const createMockAttachmentTransport: () => ChatAttachmentTransport;
@@ -1,7 +1,8 @@
1
- import { type AgenticStepsAppendedData, type ChatMessageDeltaData, type ConversationData, type MessageData } from "@/api/messages.api.types";
1
+ import { type AgenticStepsAppendedData, type ChatMessageDeltaData, type ConversationData, type MessageData, type SendMessageResult } from "@/api/messages.api.types";
2
2
  import type { AppApi } from "@/App";
3
3
  import type { WidgetConfig } from "@/index.types";
4
4
  import { type MessageStreamState } from "./message-stream";
5
+ import type { ChatAttachment, ChatTypingState, SupportPresenceState } from "./chat-experience";
5
6
  export interface ThreadSummary {
6
7
  threadId: string;
7
8
  lastMessage: MessageData;
@@ -15,6 +16,8 @@ export type PendingCustomerMessage = {
15
16
  afterMessageId: string | null;
16
17
  acknowledged: boolean;
17
18
  canonicalMessageId: string | null;
19
+ attachments: ChatAttachment[];
20
+ readByAssistant: boolean;
18
21
  };
19
22
  export type MessageStore = {
20
23
  currentThreadId: string | undefined;
@@ -40,6 +43,9 @@ export type MessageStore = {
40
43
  pendingCustomerMessage: PendingCustomerMessage | null;
41
44
  responsePhase: AgentResponsePhase;
42
45
  sendInFlight: boolean;
46
+ typingByConversation: Map<string, ChatTypingState>;
47
+ supportPresenceByConversation: Map<string, SupportPresenceState>;
48
+ assistantSuspendedConversationIds: Set<string>;
43
49
  actions: MessageStoreActions;
44
50
  };
45
51
  export type MessageStoreActions = {
@@ -50,7 +56,7 @@ export type MessageStoreActions = {
50
56
  handleMessage: (message: MessageData) => void;
51
57
  handleMessageDelta: (delta: ChatMessageDeltaData) => void;
52
58
  settleMessageStream: (messageId: string) => void;
53
- sendMessage: (message: string) => Promise<MessageData | undefined>;
59
+ sendMessage: (message: string, attachments?: ChatAttachment[]) => Promise<SendMessageResult | undefined>;
54
60
  clearSendError: () => void;
55
61
  getThreadsSummaryData: () => ThreadSummary[];
56
62
  setLatestReadMessageDate: (readMessageDate: string) => void;
@@ -64,6 +70,8 @@ export type MessageStoreActions = {
64
70
  cancelConversationPagination: () => void;
65
71
  setCurrentThreadMessages: (conversationId: string) => void;
66
72
  sendServiceMessage: (message: string) => Promise<void>;
73
+ handleChatTyping: (typing: ChatTypingState) => void;
74
+ handleSupportPresence: (presence: SupportPresenceState) => void;
67
75
  updateConfig: (config: WidgetConfig, api: AppApi) => void;
68
76
  recoverMessages: (preserveLoadedConversations?: boolean) => Promise<void>;
69
77
  fetchMoreConversations: () => Promise<void>;
@@ -87,4 +95,8 @@ export declare const useIsResponseActive: () => boolean;
87
95
  export declare const selectCurrentThreadPendingCustomerMessage: (state: MessageStore) => PendingCustomerMessage | null;
88
96
  export declare const usePendingCustomerMessage: () => PendingCustomerMessage | null;
89
97
  export declare const useMessageStream: (messageId: string) => MessageStreamState | undefined;
98
+ export declare const useCurrentChatTyping: () => ChatTypingState | null;
99
+ export declare const useCurrentSupportPresence: () => SupportPresenceState | null;
100
+ export declare const selectIsCurrentConversationAISuspended: (state: MessageStore) => boolean;
101
+ export declare const useCurrentConversationAISuspended: () => boolean;
90
102
  export declare const useMessageStoreActions: () => MessageStoreActions;