@alxxsck/ai-assistant 2.22.3 → 2.23.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/README.md +23 -12
- package/dist/{Avatar-QuPBAhUu.js → Avatar-BiRx7xkN.js} +1 -1
- package/dist/ChatWidgetContent-CtUehfbL.js +8129 -0
- package/dist/api/chat-attachments.api.d.ts +36 -0
- package/dist/api/messages.api.d.ts +3 -1
- package/dist/api/messages.api.types.d.ts +14 -1
- package/dist/bridge-ai-chat-widget.es.js +1 -1
- package/dist/domain/message/chat-experience.d.ts +16 -1
- package/dist/i18n/messages.d.ts +39 -1
- package/dist/{index-BBsPIKJB.js → index-DMOAaoVj.js} +4046 -3925
- package/dist/index.types.d.ts +6 -4
- package/dist/ui/attachment-preview.d.ts +10 -0
- package/dist/ui/components/ChatAttachmentList.d.ts +3 -1
- package/dist/ui/components/ChatAttachmentPreviewDialog.d.ts +9 -0
- package/dist/ui/components/ChatMessage.d.ts +3 -0
- package/dist/ui/components/OptimisticCustomerMessage.d.ts +4 -1
- package/package.json +1 -1
- package/dist/ChatWidgetContent-CZdK6qrV.js +0 -6363
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AppApi } from "@/App";
|
|
2
|
+
import { type ChatAttachmentTransport } from "@/domain/message/chat-experience";
|
|
3
|
+
import type { WidgetConfig } from "@/index.types";
|
|
4
|
+
export declare const CHAT_ATTACHMENT_MAX_FILES = 10;
|
|
5
|
+
export declare const CHAT_ATTACHMENT_MAX_BYTES: number;
|
|
6
|
+
export declare const CHAT_ATTACHMENT_MAX_TOTAL_BYTES: number;
|
|
7
|
+
export declare const CHAT_ATTACHMENT_CONTENT_TYPES: readonly ["application/pdf", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "image/jpeg", "image/png", "image/webp", "text/csv", "text/plain"];
|
|
8
|
+
export declare const CHAT_ATTACHMENT_ACCEPT: string;
|
|
9
|
+
type AttachmentContentType = (typeof CHAT_ATTACHMENT_CONTENT_TYPES)[number];
|
|
10
|
+
export declare class ChatAttachmentApiError extends Error {
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly status?: number | undefined;
|
|
13
|
+
constructor(code: string, status?: number | undefined);
|
|
14
|
+
}
|
|
15
|
+
export declare const validAttachmentDisplayFilename: (raw: string) => boolean;
|
|
16
|
+
export declare const acceptedAttachmentContentType: (file: Pick<File, "name" | "type">) => AttachmentContentType | null;
|
|
17
|
+
declare const abortableDelay: (durationMs: number, signal?: AbortSignal) => Promise<void>;
|
|
18
|
+
export declare const sha256Hex: (file: Blob) => Promise<string>;
|
|
19
|
+
declare const uploadPresignedFile: ({ file, requiredHeaders, signal, uploadUrl, onProgress, }: {
|
|
20
|
+
file: File;
|
|
21
|
+
requiredHeaders: Record<string, string>;
|
|
22
|
+
signal?: AbortSignal;
|
|
23
|
+
uploadUrl: string;
|
|
24
|
+
onProgress?: (progress: number) => void;
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
type BackendTransportDependencies = {
|
|
27
|
+
fetchImpl?: typeof fetch;
|
|
28
|
+
uploadFile?: typeof uploadPresignedFile;
|
|
29
|
+
digest?: typeof sha256Hex;
|
|
30
|
+
wait?: typeof abortableDelay;
|
|
31
|
+
pollIntervalMs?: number;
|
|
32
|
+
maxPolls?: number;
|
|
33
|
+
createId?: () => string;
|
|
34
|
+
};
|
|
35
|
+
export declare const createBackendChatAttachmentTransport: (config: WidgetConfig, api: Pick<AppApi, "onSessionExpired">, dependencies?: BackendTransportDependencies) => ChatAttachmentTransport;
|
|
36
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AppApi } from "@/App";
|
|
2
2
|
import type { WidgetConfig } from "@/index.types";
|
|
3
3
|
import { type ConversationData, type MessageData, type RawConversationData, type RawMessageData, type SendMessageResult } from "./messages.api.types";
|
|
4
|
-
import type
|
|
4
|
+
import { type ChatAttachment } from "@/domain/message/chat-experience";
|
|
5
5
|
export declare const MAX_FETCH_MESSAGES = 100;
|
|
6
6
|
export type CursorPage<T> = {
|
|
7
7
|
items: T[];
|
|
@@ -28,6 +28,8 @@ export declare const normalizeMessageAuthorPresentation: (role: RawMessageData["
|
|
|
28
28
|
presentationVersion: number | null;
|
|
29
29
|
legacyAvatarUrl: string | null;
|
|
30
30
|
}> | null;
|
|
31
|
+
export declare const normalizeChatAttachment: (candidate: unknown) => ChatAttachment | null;
|
|
32
|
+
export declare const normalizeChatAttachments: (values: readonly unknown[] | undefined) => ChatAttachment[];
|
|
31
33
|
export declare const normalizeMessageForSession: (message: RawMessageData, interactionSessionId: string) => MessageData;
|
|
32
34
|
export declare const listConversations: (config: WidgetConfig, api: AppApi, cursor?: string, signal?: AbortSignal) => Promise<VersionedCursorPage<ConversationData>>;
|
|
33
35
|
export declare const listConversationMessages: (config: WidgetConfig, api: AppApi, conversationId: string, cursor?: string, signal?: AbortSignal) => Promise<CursorPage<MessageData>>;
|
|
@@ -108,6 +108,19 @@ export type RawConversationData = Omit<ConversationData, "responderPresentation"
|
|
|
108
108
|
responderPresentation?: unknown;
|
|
109
109
|
};
|
|
110
110
|
export type MessageRole = "USER" | "ASSISTANT" | "ADMIN" | "SCENARIO" | "SYSTEM";
|
|
111
|
+
export type RawChatAttachment = {
|
|
112
|
+
id?: unknown;
|
|
113
|
+
displayFilename?: unknown;
|
|
114
|
+
contentType?: unknown;
|
|
115
|
+
sizeBytes?: unknown;
|
|
116
|
+
/** Compatibility fields for custom transports used before durable snapshots. */
|
|
117
|
+
fileName?: unknown;
|
|
118
|
+
mediaType?: unknown;
|
|
119
|
+
size?: unknown;
|
|
120
|
+
kind?: unknown;
|
|
121
|
+
downloadUrl?: unknown;
|
|
122
|
+
previewUrl?: unknown;
|
|
123
|
+
};
|
|
111
124
|
export type RawMessageData = {
|
|
112
125
|
id: string;
|
|
113
126
|
threadId: string;
|
|
@@ -119,7 +132,7 @@ export type RawMessageData = {
|
|
|
119
132
|
ordinal?: number;
|
|
120
133
|
clientMessageId?: string | null;
|
|
121
134
|
author?: unknown;
|
|
122
|
-
attachments?:
|
|
135
|
+
attachments?: unknown[];
|
|
123
136
|
delivery?: MessageDelivery;
|
|
124
137
|
createdAt: string;
|
|
125
138
|
updatedAt: string;
|
|
@@ -5,16 +5,30 @@ export type ChatAttachment = {
|
|
|
5
5
|
mediaType: string;
|
|
6
6
|
size: number;
|
|
7
7
|
kind: ChatAttachmentKind;
|
|
8
|
-
|
|
8
|
+
/** Ephemeral local/demo URLs only. Durable backend snapshots never contain URLs. */
|
|
9
|
+
downloadUrl?: string;
|
|
9
10
|
previewUrl?: string;
|
|
10
11
|
};
|
|
12
|
+
export type ChatAttachmentUploadStage = "preparing" | "uploading" | "scanning";
|
|
11
13
|
export type ChatAttachmentUploadInput = {
|
|
12
14
|
file: File;
|
|
15
|
+
conversationId?: string;
|
|
13
16
|
signal?: AbortSignal;
|
|
14
17
|
onProgress?: (progress: number) => void;
|
|
18
|
+
onStage?: (stage: ChatAttachmentUploadStage) => void;
|
|
19
|
+
};
|
|
20
|
+
export type ChatAttachmentAccessInput = {
|
|
21
|
+
attachmentId: string;
|
|
22
|
+
conversationId?: string;
|
|
23
|
+
};
|
|
24
|
+
export type ChatAttachmentGrant = {
|
|
25
|
+
url: string;
|
|
26
|
+
expiresAt: string;
|
|
15
27
|
};
|
|
16
28
|
export interface ChatAttachmentTransport {
|
|
17
29
|
upload(input: ChatAttachmentUploadInput): Promise<ChatAttachment>;
|
|
30
|
+
grant?(input: ChatAttachmentAccessInput): Promise<ChatAttachmentGrant>;
|
|
31
|
+
revoke?(input: ChatAttachmentAccessInput): Promise<void>;
|
|
18
32
|
}
|
|
19
33
|
export type ChatTypingState = {
|
|
20
34
|
conversationId: string;
|
|
@@ -28,6 +42,7 @@ export type ChatTypingState = {
|
|
|
28
42
|
export declare const normalizeChatExperienceFrame: (frame: unknown) => {
|
|
29
43
|
typing: ChatTypingState | null;
|
|
30
44
|
};
|
|
45
|
+
export declare const attachmentKindFor: (mediaType: string) => ChatAttachmentKind;
|
|
31
46
|
/**
|
|
32
47
|
* A deterministic transport for visual QA and integration tests. Production
|
|
33
48
|
* integrators replace it with their signed-upload adapter through WidgetConfig.
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -97,14 +97,52 @@ declare const en: {
|
|
|
97
97
|
readonly confirming: "Confirming…";
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
|
+
declare const attachmentEn: {
|
|
101
|
+
readonly listLabel: "Attachments";
|
|
102
|
+
readonly oneAttachment: "One attachment";
|
|
103
|
+
readonly manyAttachments: "{{count}} attachments";
|
|
104
|
+
readonly preview: "Preview";
|
|
105
|
+
readonly download: "Download";
|
|
106
|
+
readonly closePreview: "Close file preview";
|
|
107
|
+
readonly loadingPreview: "Opening secure preview…";
|
|
108
|
+
readonly previewFailed: "This file couldn't be previewed safely.";
|
|
109
|
+
readonly retry: "Try again";
|
|
110
|
+
readonly pdfPreview: "PDF preview";
|
|
111
|
+
readonly downloadFailed: "Couldn't download the file. Try again.";
|
|
112
|
+
readonly tooMany: "You can attach up to {{count}} files.";
|
|
113
|
+
readonly emptyFile: "Empty files can't be attached.";
|
|
114
|
+
readonly unsupportedType: "This file type isn't supported.";
|
|
115
|
+
readonly invalidFileName: "Rename this file before attaching it.";
|
|
116
|
+
readonly fileTooLarge: "Each file must be {{size}} MB or smaller.";
|
|
117
|
+
readonly totalTooLarge: "Attached files must total {{size}} MB or less.";
|
|
118
|
+
readonly filesToSend: "Files to send";
|
|
119
|
+
readonly preparing: "Preparing securely";
|
|
120
|
+
readonly uploading: "Uploading";
|
|
121
|
+
readonly scanning: "Checking for threats";
|
|
122
|
+
readonly ready: "Ready";
|
|
123
|
+
readonly removing: "Removing…";
|
|
124
|
+
readonly sending: "Sending…";
|
|
125
|
+
readonly uploadFailed: "Upload failed";
|
|
126
|
+
readonly remove: "Remove";
|
|
127
|
+
readonly revokeFailed: "Couldn't remove the file. Try again.";
|
|
128
|
+
readonly messageRequired: "Add a message before sending these files.";
|
|
129
|
+
readonly dropFiles: "Drop files to attach";
|
|
130
|
+
readonly limits: "Up to {{count}} files · {{size}} MB each · {{total}} MB total";
|
|
131
|
+
readonly attachFiles: "Attach files";
|
|
132
|
+
readonly disabled: "File attachments aren't available here.";
|
|
133
|
+
};
|
|
134
|
+
type AttachmentCatalog = {
|
|
135
|
+
[Key in keyof typeof attachmentEn]: string;
|
|
136
|
+
};
|
|
100
137
|
type CatalogShape = {
|
|
101
138
|
[Group in keyof typeof en]: {
|
|
102
139
|
[Key in keyof (typeof en)[Group]]: string;
|
|
103
140
|
};
|
|
104
141
|
};
|
|
105
|
-
|
|
142
|
+
type BaseTranslationKey = {
|
|
106
143
|
[Group in keyof CatalogShape & string]: `${Group}.${keyof CatalogShape[Group] & string}`;
|
|
107
144
|
}[keyof CatalogShape & string];
|
|
145
|
+
export type TranslationKey = BaseTranslationKey | `attachment.${keyof AttachmentCatalog & string}`;
|
|
108
146
|
export type TranslationMessages = Record<TranslationKey, string>;
|
|
109
147
|
export declare const MESSAGES: Record<SupportedLocale, TranslationMessages>;
|
|
110
148
|
export {};
|