@cagent/chat-embedding-core 0.0.1
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/.env.example +34 -0
- package/.eslintrc.cjs +15 -0
- package/.idea/flowise-chatbox.iml +10 -0
- package/.idea/modules.xml +8 -0
- package/.idea/workspace.xml +4 -0
- package/.prettierignore +3 -0
- package/.prettierrc +8 -0
- package/AGENTS.md +184 -0
- package/README.md +213 -0
- package/base.json +21 -0
- package/dist/api/chatRoom.d.ts +84 -0
- package/dist/assets/notificationSounds.d.ts +2 -0
- package/dist/components/Badge.d.ts +9 -0
- package/dist/components/Bot.d.ts +132 -0
- package/dist/components/FeedbackContentDialog.d.ts +12 -0
- package/dist/components/RoomReconnectAlert.d.ts +13 -0
- package/dist/components/Toast.d.ts +9 -0
- package/dist/components/TypingBubble.d.ts +1 -0
- package/dist/components/avatars/Avatar.d.ts +3 -0
- package/dist/components/avatars/DefaultAvatar.d.ts +1 -0
- package/dist/components/bubbles/AgentReasoningBubble.d.ts +15 -0
- package/dist/components/bubbles/BotBubble.d.ts +39 -0
- package/dist/components/bubbles/ChartBubble.d.ts +72 -0
- package/dist/components/bubbles/ChartLoadingPlaceholder.d.ts +7 -0
- package/dist/components/bubbles/ChartPlaceholder.d.ts +19 -0
- package/dist/components/bubbles/ChartPopupModal.d.ts +3 -0
- package/dist/components/bubbles/FollowUpPromptBubble.d.ts +7 -0
- package/dist/components/bubbles/GuestBubble.d.ts +15 -0
- package/dist/components/bubbles/LeadCaptureBubble.d.ts +19 -0
- package/dist/components/bubbles/LoadingBubble.d.ts +7 -0
- package/dist/components/bubbles/SourceBubble.d.ts +8 -0
- package/dist/components/bubbles/StableChartWrapper.d.ts +17 -0
- package/dist/components/bubbles/StarterPromptBubble.d.ts +7 -0
- package/dist/components/buttons/AttachmentUploadButton.d.ts +10 -0
- package/dist/components/buttons/CancelButton.d.ts +9 -0
- package/dist/components/buttons/CopyMessageButton.d.ts +9 -0
- package/dist/components/buttons/EditMessageButton.d.ts +7 -0
- package/dist/components/buttons/FeedbackButtons.d.ts +13 -0
- package/dist/components/buttons/ImageUploadButton.d.ts +10 -0
- package/dist/components/buttons/LeadCaptureButtons.d.ts +10 -0
- package/dist/components/buttons/PopupToast.d.ts +6 -0
- package/dist/components/buttons/RecordAudioButton.d.ts +10 -0
- package/dist/components/buttons/SendButton.d.ts +12 -0
- package/dist/components/dialogs/EditMessageDialog.d.ts +8 -0
- package/dist/components/icons/AddImageIcon.d.ts +2 -0
- package/dist/components/icons/AttachmentIcon.d.ts +2 -0
- package/dist/components/icons/CheckIcon.d.ts +2 -0
- package/dist/components/icons/CircleDotIcon.d.ts +2 -0
- package/dist/components/icons/ClipboardIcon.d.ts +2 -0
- package/dist/components/icons/CopyIcon.d.ts +4 -0
- package/dist/components/icons/DeleteIcon.d.ts +2 -0
- package/dist/components/icons/EditIcon.d.ts +4 -0
- package/dist/components/icons/FullScreenIcon.d.ts +2 -0
- package/dist/components/icons/RecordIcon.d.ts +2 -0
- package/dist/components/icons/ResetZoomIcon.d.ts +2 -0
- package/dist/components/icons/SendIcon.d.ts +2 -0
- package/dist/components/icons/SparklesIcon.d.ts +2 -0
- package/dist/components/icons/StopIcon.d.ts +2 -0
- package/dist/components/icons/ThumbsDownIcon.d.ts +4 -0
- package/dist/components/icons/ThumbsUpIcon.d.ts +4 -0
- package/dist/components/icons/TickIcon.d.ts +1 -0
- package/dist/components/icons/TrashIcon.d.ts +2 -0
- package/dist/components/icons/XIcon.d.ts +4 -0
- package/dist/components/icons/ZoomInIcon.d.ts +2 -0
- package/dist/components/icons/ZoomOutIcon.d.ts +2 -0
- package/dist/components/icons/index.d.ts +21 -0
- package/dist/components/image/PreviewImage.d.ts +4 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/inputs/textInput/components/FilePreview.d.ts +11 -0
- package/dist/components/inputs/textInput/components/ShortTextInput.d.ts +13 -0
- package/dist/components/inputs/textInput/components/TextInput.d.ts +50 -0
- package/dist/components/inputs/textInput/index.d.ts +2 -0
- package/dist/constants.d.ts +2 -0
- package/dist/features/bubble/components/Bubble.d.ts +4 -0
- package/dist/features/bubble/components/BubbleButton.d.ts +15 -0
- package/dist/features/bubble/components/Tooltip.d.ts +14 -0
- package/dist/features/bubble/components/index.d.ts +1 -0
- package/dist/features/bubble/index.d.ts +1 -0
- package/dist/features/bubble/types.d.ts +108 -0
- package/dist/features/full/components/Full.d.ts +6 -0
- package/dist/features/full/components/index.d.ts +1 -0
- package/dist/features/full/index.d.ts +1 -0
- package/dist/features/popup/components/DisclaimerPopup.d.ts +13 -0
- package/dist/features/popup/components/Popup.d.ts +8 -0
- package/dist/features/popup/components/index.d.ts +2 -0
- package/dist/features/popup/index.d.ts +1 -0
- package/dist/features/popup/types.d.ts +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/queries/sendMessageQuery.d.ts +165 -0
- package/dist/register.d.ts +1 -0
- package/dist/store/constant.d.ts +42 -0
- package/dist/types/chart.d.ts +85 -0
- package/dist/utils/audioRecording.d.ts +20 -0
- package/dist/utils/chartInstanceManager.d.ts +42 -0
- package/dist/utils/chartTagParser.d.ts +38 -0
- package/dist/utils/chatInputHistory.d.ts +21 -0
- package/dist/utils/chatStreamHelper.d.ts +18 -0
- package/dist/utils/index.d.ts +26 -0
- package/dist/utils/isMobileSignal.d.ts +1 -0
- package/dist/utils/transcriptApi.d.ts +7 -0
- package/dist/utils/ultimateJsonParser.d.ts +1 -0
- package/dist/web.d.ts +34 -0
- package/dist/web.js +1 -0
- package/dist/window.d.ts +35 -0
- package/docs/chart-rendering-implementation-plan.md +565 -0
- package/images/ChatEmbed.gif +0 -0
- package/images/proxyserver.png +0 -0
- package/package.json +87 -0
- package/public/index.html +43 -0
- package/server.js +477 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Chart } from 'chart.js';
|
|
2
|
+
/**
|
|
3
|
+
* Singleton manager for Chart.js instances.
|
|
4
|
+
* Tracks all created chart instances and handles proper cleanup to prevent memory leaks.
|
|
5
|
+
*/
|
|
6
|
+
declare class ChartInstanceManager {
|
|
7
|
+
private instances;
|
|
8
|
+
/**
|
|
9
|
+
* Register a new Chart.js instance
|
|
10
|
+
*/
|
|
11
|
+
register(id: string, chart: Chart): void;
|
|
12
|
+
/**
|
|
13
|
+
* Get a Chart.js instance by ID
|
|
14
|
+
*/
|
|
15
|
+
get(id: string): Chart | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Check if an instance exists
|
|
18
|
+
*/
|
|
19
|
+
has(id: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Destroy a Chart.js instance by ID
|
|
22
|
+
*/
|
|
23
|
+
destroy(id: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Destroy multiple Chart.js instances by their IDs
|
|
26
|
+
*/
|
|
27
|
+
destroyMany(ids: string[]): void;
|
|
28
|
+
/**
|
|
29
|
+
* Destroy all registered Chart.js instances
|
|
30
|
+
*/
|
|
31
|
+
destroyAll(): void;
|
|
32
|
+
/**
|
|
33
|
+
* Get count of registered instances
|
|
34
|
+
*/
|
|
35
|
+
get count(): number;
|
|
36
|
+
/**
|
|
37
|
+
* Get all registered instance IDs
|
|
38
|
+
*/
|
|
39
|
+
getIds(): string[];
|
|
40
|
+
}
|
|
41
|
+
export declare const chartManager: ChartInstanceManager;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ChartParseResult } from '@/types/chart';
|
|
2
|
+
/**
|
|
3
|
+
* State machine parser for extracting chart XML tags from streaming tokens.
|
|
4
|
+
* Handles partial tags split across multiple tokens.
|
|
5
|
+
*/
|
|
6
|
+
export declare class ChartTagParser {
|
|
7
|
+
private state;
|
|
8
|
+
private buffer;
|
|
9
|
+
private pendingChart;
|
|
10
|
+
private textOutput;
|
|
11
|
+
private chartPlaceholders;
|
|
12
|
+
private completedCharts;
|
|
13
|
+
/**
|
|
14
|
+
* Process a single token from the SSE stream
|
|
15
|
+
*/
|
|
16
|
+
processToken(token: string): ChartParseResult;
|
|
17
|
+
/**
|
|
18
|
+
* Process a single character through the state machine
|
|
19
|
+
*/
|
|
20
|
+
private processChar;
|
|
21
|
+
private handleIdleState;
|
|
22
|
+
private handleOpeningTagState;
|
|
23
|
+
private handleInsideTagState;
|
|
24
|
+
private handleClosingTagState;
|
|
25
|
+
private parseOpeningTag;
|
|
26
|
+
private finalizeChart;
|
|
27
|
+
private parseChartJson;
|
|
28
|
+
private getDefaultOptions;
|
|
29
|
+
/**
|
|
30
|
+
* Flush any remaining buffered content when stream ends.
|
|
31
|
+
* Incomplete chart tags are treated as plain text.
|
|
32
|
+
*/
|
|
33
|
+
flush(): ChartParseResult;
|
|
34
|
+
/**
|
|
35
|
+
* Reset parser state for a new message
|
|
36
|
+
*/
|
|
37
|
+
reset(): void;
|
|
38
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type ChatHistoryStorage = {
|
|
2
|
+
getItem(key: string): string | null;
|
|
3
|
+
setItem(key: string, value: string): void;
|
|
4
|
+
};
|
|
5
|
+
export declare class ChatInputHistory {
|
|
6
|
+
private getMaxHistory;
|
|
7
|
+
private storage;
|
|
8
|
+
private history;
|
|
9
|
+
private currentIndex;
|
|
10
|
+
private tempInput;
|
|
11
|
+
private maxHistory;
|
|
12
|
+
constructor(getMaxHistory?: () => number, storage?: ChatHistoryStorage);
|
|
13
|
+
getHistory(): string[];
|
|
14
|
+
getCurrentIndex(): number;
|
|
15
|
+
addToHistory(input: string): void;
|
|
16
|
+
getPreviousInput(currentInput: string): string;
|
|
17
|
+
getNextInput(): string;
|
|
18
|
+
private saveHistory;
|
|
19
|
+
private loadHistory;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Stream Helper
|
|
3
|
+
* Utilities for handling AI streaming responses and message buffering
|
|
4
|
+
*/
|
|
5
|
+
import { SenderType } from '@/store/constant';
|
|
6
|
+
export interface ChatMessage {
|
|
7
|
+
id: string;
|
|
8
|
+
content: string;
|
|
9
|
+
sender: SenderType;
|
|
10
|
+
timestamp: Date;
|
|
11
|
+
isStreaming?: boolean;
|
|
12
|
+
metadata?: Record<string, any>;
|
|
13
|
+
}
|
|
14
|
+
export declare const generateMessageId: () => string;
|
|
15
|
+
export declare const createChatMessage: (content: string, sender: SenderType, metadata?: Record<string, any>) => ChatMessage;
|
|
16
|
+
export declare const isHumanMessage: (sender: SenderType) => boolean;
|
|
17
|
+
export declare const isAgentMessage: (sender: SenderType) => boolean;
|
|
18
|
+
export declare const formatMessageContent: (content: string) => string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const isNotDefined: <T>(value: T | null | undefined) => value is null | undefined;
|
|
2
|
+
export declare const isDefined: <T>(value: T | null | undefined) => value is NonNullable<T>;
|
|
3
|
+
export declare const isEmpty: (value: string | undefined | null) => value is undefined;
|
|
4
|
+
export declare const isNotEmpty: (value: string | undefined | null) => value is string;
|
|
5
|
+
/**
|
|
6
|
+
* Clears authentication data from localStorage
|
|
7
|
+
* Used when 401 errors are detected or user logs out
|
|
8
|
+
*/
|
|
9
|
+
export declare const sendRequest: <ResponseData>(params: string | {
|
|
10
|
+
url: string;
|
|
11
|
+
method: string;
|
|
12
|
+
body?: Record<string, unknown> | FormData | undefined;
|
|
13
|
+
type?: string | undefined;
|
|
14
|
+
headers?: Record<string, any> | undefined;
|
|
15
|
+
formData?: FormData | undefined;
|
|
16
|
+
onRequest?: ((request: RequestInit) => Promise<void>) | undefined;
|
|
17
|
+
}) => Promise<{
|
|
18
|
+
data?: ResponseData | undefined;
|
|
19
|
+
error?: Error | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const setLocalStorageChatflow: (chatflowid: string, chatId: string, saveObj?: Record<string, any>) => void;
|
|
22
|
+
export declare const getLocalStorageChatflow: (chatflowid: string) => any;
|
|
23
|
+
export declare const removeLocalStorageChatHistory: (chatflowid: string) => void;
|
|
24
|
+
export declare const getBubbleButtonSize: (size: 'small' | 'medium' | 'large' | number | undefined) => number;
|
|
25
|
+
export declare const setCookie: (cname: string, cvalue: string, exdays: number) => void;
|
|
26
|
+
export declare const getCookie: (cname: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isMobile: import("solid-js").Accessor<boolean | undefined>, setIsMobile: import("solid-js").Setter<boolean | undefined>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload audio blob to server and get transcription
|
|
3
|
+
* @param blob - Audio blob to transcribe
|
|
4
|
+
* @param transcriptApiEndpoint - API endpoint for transcription service
|
|
5
|
+
* @returns Promise<string> - Transcribed text
|
|
6
|
+
*/
|
|
7
|
+
export declare const uploadAndTranscriptAudio: (blob: Blob, transcriptApiEndpoint?: string) => Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseJsonMarkdown(jsonString: string): any;
|
package/dist/web.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const chatbot: {
|
|
2
|
+
initFull: (props: {
|
|
3
|
+
chatflowid: string;
|
|
4
|
+
apiHost?: string | undefined;
|
|
5
|
+
onRequest?: ((request: RequestInit) => Promise<void>) | undefined;
|
|
6
|
+
chatflowConfig?: Record<string, unknown> | undefined;
|
|
7
|
+
observersConfig?: import("./components/Bot").observersConfigType | undefined;
|
|
8
|
+
theme?: import("./features/bubble/types").BubbleTheme | undefined;
|
|
9
|
+
chatwootUrl?: string | undefined;
|
|
10
|
+
roomIds?: Record<string, string> | undefined;
|
|
11
|
+
isUseFAQ?: boolean | undefined;
|
|
12
|
+
s3ExplorerUrl?: string | undefined;
|
|
13
|
+
showResponseTime?: boolean | undefined;
|
|
14
|
+
onResetChat?: (() => Promise<void>) | undefined;
|
|
15
|
+
} & {
|
|
16
|
+
id?: string | undefined;
|
|
17
|
+
}) => void;
|
|
18
|
+
init: (props: {
|
|
19
|
+
chatflowid: string;
|
|
20
|
+
apiHost?: string | undefined;
|
|
21
|
+
onRequest?: ((request: RequestInit) => Promise<void>) | undefined;
|
|
22
|
+
chatflowConfig?: Record<string, unknown> | undefined;
|
|
23
|
+
observersConfig?: import("./components/Bot").observersConfigType | undefined;
|
|
24
|
+
theme?: import("./features/bubble/types").BubbleTheme | undefined;
|
|
25
|
+
chatwootUrl?: string | undefined;
|
|
26
|
+
roomIds?: Record<string, string> | undefined;
|
|
27
|
+
isUseFAQ?: boolean | undefined;
|
|
28
|
+
s3ExplorerUrl?: string | undefined;
|
|
29
|
+
showResponseTime?: boolean | undefined;
|
|
30
|
+
onResetChat?: (() => Promise<void>) | undefined;
|
|
31
|
+
}) => void;
|
|
32
|
+
destroy: () => void;
|
|
33
|
+
};
|
|
34
|
+
export default chatbot;
|