cmcts-c-agent-embedding 1.0.16 → 1.0.17-kyocera
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/.idea/{Flowise-share-chatbox.iml → flowise-chatbox.iml} +0 -1
- package/.idea/modules.xml +1 -2
- package/.idea/vcs.xml +5 -6
- package/CLAUDE.md +115 -0
- package/README.md +349 -349
- package/auggie_shell_conversation.txt +162 -0
- package/auggie_shell_user_request.txt +81 -0
- package/dist/BubbleChat.d.ts +9 -12
- package/dist/BubbleChat.d.ts.map +1 -1
- package/dist/FullPageChat.d.ts +17 -17
- package/dist/components/Bot.d.ts +14 -0
- package/dist/components/Bot.d.ts.map +1 -1
- package/dist/components/FeedbackContentDialog.d.ts +6 -0
- package/dist/components/FeedbackContentDialog.d.ts.map +1 -1
- package/dist/components/Toast.d.ts +10 -0
- package/dist/components/Toast.d.ts.map +1 -0
- package/dist/components/bubbles/BotBubble.d.ts +11 -0
- package/dist/components/bubbles/BotBubble.d.ts.map +1 -1
- package/dist/components/bubbles/ChartBubble.d.ts +73 -0
- package/dist/components/bubbles/ChartBubble.d.ts.map +1 -0
- package/dist/components/bubbles/ChartLoadingPlaceholder.d.ts +8 -0
- package/dist/components/bubbles/ChartLoadingPlaceholder.d.ts.map +1 -0
- package/dist/components/bubbles/ChartPlaceholder.d.ts +20 -0
- package/dist/components/bubbles/ChartPlaceholder.d.ts.map +1 -0
- package/dist/components/bubbles/ChartPopupModal.d.ts +4 -0
- package/dist/components/bubbles/ChartPopupModal.d.ts.map +1 -0
- package/dist/components/bubbles/ChartPortalContainer.d.ts +12 -0
- package/dist/components/bubbles/ChartPortalContainer.d.ts.map +1 -0
- package/dist/components/bubbles/LoadingBubble.d.ts +7 -1
- package/dist/components/bubbles/LoadingBubble.d.ts.map +1 -1
- package/dist/components/bubbles/SourceBubble.d.ts.map +1 -1
- package/dist/components/bubbles/StableChartWrapper.d.ts +18 -0
- package/dist/components/bubbles/StableChartWrapper.d.ts.map +1 -0
- package/dist/components/bubbles/StarterPromptBubble.d.ts.map +1 -1
- package/dist/components/buttons/ConsultationButton.d.ts +14 -0
- package/dist/components/buttons/ConsultationButton.d.ts.map +1 -0
- package/dist/components/buttons/CopyMessageButton.d.ts +10 -0
- package/dist/components/buttons/CopyMessageButton.d.ts.map +1 -0
- package/dist/components/buttons/EditMessageButton.d.ts +10 -0
- package/dist/components/buttons/EditMessageButton.d.ts.map +1 -0
- package/dist/components/buttons/FeedbackButtons.d.ts +1 -0
- package/dist/components/buttons/FeedbackButtons.d.ts.map +1 -1
- package/dist/components/buttons/PopupToast.d.ts +7 -0
- package/dist/components/buttons/PopupToast.d.ts.map +1 -0
- package/dist/components/buttons/SendButton.d.ts +1 -0
- package/dist/components/buttons/SendButton.d.ts.map +1 -1
- package/dist/components/dialogs/EditMessageDialog.d.ts +14 -0
- package/dist/components/dialogs/EditMessageDialog.d.ts.map +1 -0
- package/dist/components/icons/AddImageIcon.d.ts.map +1 -1
- package/dist/components/icons/CheckIcon.d.ts +2 -0
- package/dist/components/icons/CheckIcon.d.ts.map +1 -0
- package/dist/components/icons/CmcIcon.d.ts +3 -0
- package/dist/components/icons/CmcIcon.d.ts.map +1 -0
- package/dist/components/icons/CopyIcon.d.ts +2 -0
- package/dist/components/icons/CopyIcon.d.ts.map +1 -0
- package/dist/components/icons/EditIcon.d.ts +2 -0
- package/dist/components/icons/EditIcon.d.ts.map +1 -0
- package/dist/components/icons/FullScreenIcon.d.ts +3 -0
- package/dist/components/icons/FullScreenIcon.d.ts.map +1 -0
- package/dist/components/icons/ResetBtn.d.ts +3 -0
- package/dist/components/icons/ResetBtn.d.ts.map +1 -0
- package/dist/components/icons/ResetZoomIcon.d.ts +3 -0
- package/dist/components/icons/ResetZoomIcon.d.ts.map +1 -0
- package/dist/components/icons/SendIconOff.d.ts +3 -0
- package/dist/components/icons/SendIconOff.d.ts.map +1 -0
- package/dist/components/icons/SendIconOn.d.ts +3 -0
- package/dist/components/icons/SendIconOn.d.ts.map +1 -0
- package/dist/components/icons/SupportIcon.d.ts +3 -0
- package/dist/components/icons/SupportIcon.d.ts.map +1 -0
- package/dist/components/icons/ThumbsDownIcon.d.ts +3 -1
- package/dist/components/icons/ThumbsDownIcon.d.ts.map +1 -1
- package/dist/components/icons/ThumbsUpIcon.d.ts +3 -1
- package/dist/components/icons/ThumbsUpIcon.d.ts.map +1 -1
- package/dist/components/icons/ZoomInIcon.d.ts +3 -0
- package/dist/components/icons/ZoomInIcon.d.ts.map +1 -0
- package/dist/components/icons/ZoomOutIcon.d.ts +3 -0
- package/dist/components/icons/ZoomOutIcon.d.ts.map +1 -0
- package/dist/components/icons/index.d.ts +7 -0
- package/dist/components/icons/index.d.ts.map +1 -1
- package/dist/components/image/PreviewImage.d.ts +5 -0
- package/dist/components/image/PreviewImage.d.ts.map +1 -0
- package/dist/components/inputs/textInput/components/ShortTextInput.d.ts +3 -0
- package/dist/components/inputs/textInput/components/ShortTextInput.d.ts.map +1 -1
- package/dist/components/inputs/textInput/components/TextInput.d.ts +11 -3
- package/dist/components/inputs/textInput/components/TextInput.d.ts.map +1 -1
- package/dist/components/modals/ZaloQRModal.d.ts +8 -0
- package/dist/components/modals/ZaloQRModal.d.ts.map +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/features/bubble/components/Bubble.d.ts.map +1 -1
- package/dist/features/bubble/types.d.ts +6 -0
- package/dist/features/bubble/types.d.ts.map +1 -1
- package/dist/features/full/components/Full.d.ts.map +1 -1
- package/dist/features/popup/components/Popup.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/queries/sendMessageQuery.d.ts +52 -1
- package/dist/queries/sendMessageQuery.d.ts.map +1 -1
- package/dist/types/chart.d.ts +86 -0
- package/dist/types/chart.d.ts.map +1 -0
- package/dist/utils/chartConfigManager.d.ts +54 -0
- package/dist/utils/chartConfigManager.d.ts.map +1 -0
- package/dist/utils/chartInstanceManager.d.ts +43 -0
- package/dist/utils/chartInstanceManager.d.ts.map +1 -0
- package/dist/utils/chartPopupManager.d.ts +43 -0
- package/dist/utils/chartPopupManager.d.ts.map +1 -0
- package/dist/utils/chartPortalManager.d.ts +76 -0
- package/dist/utils/chartPortalManager.d.ts.map +1 -0
- package/dist/utils/chartTagParser.d.ts +39 -0
- package/dist/utils/chartTagParser.d.ts.map +1 -0
- package/dist/utils/index.d.ts +77 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/security.d.ts +50 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/textStreamSmoother.d.ts +40 -0
- package/dist/utils/textStreamSmoother.d.ts.map +1 -0
- package/dist/utils/transcriptApi.d.ts +17 -0
- package/dist/utils/transcriptApi.d.ts.map +1 -0
- package/dist/utils/ultimateJsonParser.d.ts +2 -0
- package/dist/utils/ultimateJsonParser.d.ts.map +1 -0
- package/dist/web.d.ts +2 -0
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +1 -1
- package/dist/window.d.ts +1 -0
- package/dist/window.d.ts.map +1 -1
- package/docs/chart-rendering-implementation-plan.md +565 -0
- package/{.env → flowise-chatbox/.env.example} +3 -5
- package/flowise-chatbox/.eslintrc.cjs +15 -0
- package/flowise-chatbox/.prettierignore +3 -0
- package/flowise-chatbox/.prettierrc +8 -0
- package/flowise-chatbox/AGENTS.md +166 -0
- package/flowise-chatbox/README.md +349 -0
- package/flowise-chatbox/auggie_shell.ps1 +10 -0
- package/flowise-chatbox/auggie_shell_user_request.txt +75 -0
- package/flowise-chatbox/base.json +21 -0
- package/flowise-chatbox/docs/chart-rendering-implementation-plan.md +565 -0
- package/flowise-chatbox/images/ChatEmbed.gif +0 -0
- package/flowise-chatbox/images/proxyserver.png +0 -0
- package/flowise-chatbox/package-lock.json +11914 -0
- package/flowise-chatbox/package.json +86 -0
- package/flowise-chatbox/public/index.html +43 -0
- package/flowise-chatbox/server.js +401 -0
- package/flowise-chatbox/yarn.lock +6294 -0
- package/package.json +13 -8
- package/public/index.html +33 -142
- package/server.js +401 -401
- package/.husky/pre-commit +0 -18
- package/.idea/codeStyles/Project.xml +0 -60
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -16
- package/.idea/prettier.xml +0 -6
- package/a.json +0 -57
- package/bun.lockb +0 -0
- package/dist/components/ImageUploadButton.d.ts +0 -11
- package/dist/components/ImageUploadButton.d.ts.map +0 -1
- package/dist/components/RecordAudioButton.d.ts +0 -11
- package/dist/components/RecordAudioButton.d.ts.map +0 -1
- package/dist/components/SendButton.d.ts +0 -12
- package/dist/components/SendButton.d.ts.map +0 -1
- package/test.html +0 -17
package/.idea/modules.xml
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
<project version="4">
|
|
3
3
|
<component name="ProjectModuleManager">
|
|
4
4
|
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/
|
|
6
|
-
<module fileurl="file://$PROJECT_DIR$/../Flowise-share-chatbox-main/.idea/Flowise-share-chatbox-main.iml" filepath="$PROJECT_DIR$/../Flowise-share-chatbox-main/.idea/Flowise-share-chatbox-main.iml" />
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/flowise-chatbox.iml" filepath="$PROJECT_DIR$/.idea/flowise-chatbox.iml" />
|
|
7
6
|
</modules>
|
|
8
7
|
</component>
|
|
9
8
|
</project>
|
package/.idea/vcs.xml
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="VcsDirectoryMappings">
|
|
4
|
-
<mapping directory="" vcs="Git" />
|
|
5
|
-
|
|
6
|
-
</component>
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="VcsDirectoryMappings">
|
|
4
|
+
<mapping directory="" vcs="Git" />
|
|
5
|
+
</component>
|
|
7
6
|
</project>
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
Flowise Chat Embed is a JavaScript library (npm: `cmcts-c-agent-embedding`) that displays Flowise AI chatbots on websites. It provides two modes: popup (bubble chat) and full-page chat. The library is built with SolidJS and compiled as web components using Rollup.
|
|
8
|
+
|
|
9
|
+
## Common Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Install dependencies
|
|
13
|
+
yarn install --frozen-lockfile
|
|
14
|
+
|
|
15
|
+
# Development (starts dev server at http://localhost:5678)
|
|
16
|
+
yarn dev
|
|
17
|
+
|
|
18
|
+
# Build for production
|
|
19
|
+
yarn build
|
|
20
|
+
|
|
21
|
+
# Type checking
|
|
22
|
+
yarn type-check
|
|
23
|
+
|
|
24
|
+
# Lint
|
|
25
|
+
yarn lint
|
|
26
|
+
yarn lint-fix
|
|
27
|
+
|
|
28
|
+
# Format
|
|
29
|
+
yarn format
|
|
30
|
+
yarn format:check
|
|
31
|
+
|
|
32
|
+
# Start proxy server (port 3001)
|
|
33
|
+
yarn start
|
|
34
|
+
|
|
35
|
+
# Build and publish to npm
|
|
36
|
+
yarn build-and-publish
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Architecture
|
|
40
|
+
|
|
41
|
+
### Entry Points
|
|
42
|
+
- `src/web.ts` - Main browser entry point. Registers web components and exports `Chatbot` API with `init()`, `initFull()`, `destroy()` methods
|
|
43
|
+
- `src/window.ts` - Manages chatbot lifecycle, element creation/destruction, and window injection
|
|
44
|
+
- `src/register.tsx` - Registers `<flowise-chatbot>` and `<flowise-fullchatbot>` custom elements using `solid-element`
|
|
45
|
+
|
|
46
|
+
### Component Hierarchy
|
|
47
|
+
```
|
|
48
|
+
web.ts → register.tsx → Bubble/Full → Bot.tsx (main chat logic)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
- **Bubble** (`src/features/bubble/`) - Popup chat widget with draggable button, tooltip, resize, and scale controls
|
|
52
|
+
- **Full** (`src/features/full/`) - Full-page chat using IntersectionObserver for lazy loading
|
|
53
|
+
- **Bot.tsx** (`src/components/Bot.tsx`) - Core chat component (~2400 lines) handling messages, streaming, file uploads, lead capture, feedback, and human advisor connection
|
|
54
|
+
|
|
55
|
+
### Proxy Server
|
|
56
|
+
`server.js` provides a secure proxy server that:
|
|
57
|
+
- Hides Flowise API host and chatflow IDs from client-side
|
|
58
|
+
- Uses domain-based whitelisting (no wildcards allowed)
|
|
59
|
+
- Parses chatflow configs from environment variables: `IDENTIFIER=chatflowId,domain1,domain2`
|
|
60
|
+
- Required env vars: `API_HOST`, `FLOWISE_API_KEY`
|
|
61
|
+
- Validates requests using browser headers and Authorization Bearer tokens
|
|
62
|
+
|
|
63
|
+
### Key Files
|
|
64
|
+
- `src/queries/sendMessageQuery.ts` - API layer for predictions, feedback, file uploads, FAQ search
|
|
65
|
+
- `src/utils/index.ts` - Request helpers, localStorage management, authentication utilities
|
|
66
|
+
- `src/utils/ultimateJsonParser.ts` - Robust JSON parser for malformed/partial JSON from AI responses
|
|
67
|
+
- `src/features/bubble/types.ts` - Theme configuration types for all customization options
|
|
68
|
+
|
|
69
|
+
## Special Patterns and Workarounds
|
|
70
|
+
|
|
71
|
+
### Streaming Bug Fix (Critical)
|
|
72
|
+
In `Bot.tsx` around line 1074-1082, there's a workaround for a streaming bug when sending images:
|
|
73
|
+
```typescript
|
|
74
|
+
// TODO: Đoạn JSON.stringify(faqId) để fix Lỗi streaming khi chọn ảnh xong gửi luôn
|
|
75
|
+
if (
|
|
76
|
+
isChatFlowAvailableToStream() &&
|
|
77
|
+
(!faqId ||
|
|
78
|
+
JSON.stringify(faqId) === JSON.stringify({ isTrusted: true }))
|
|
79
|
+
)
|
|
80
|
+
```
|
|
81
|
+
When an image is selected and sent immediately, `faqId` may incorrectly contain `{ isTrusted: true }` from the event. This check prevents incorrect fallback to non-streaming mode.
|
|
82
|
+
|
|
83
|
+
### Popup Mode Default Behavior
|
|
84
|
+
In `src/window.ts`, popup mode (`init()`) sets `isUseFAQ: true` by default, while full page mode does not. This affects FAQ functionality.
|
|
85
|
+
|
|
86
|
+
### Authentication Flow
|
|
87
|
+
- `dataLogin` localStorage stores user auth data (parsed for `accessToken`)
|
|
88
|
+
- `cmcts:userInfo` localStorage stores mapped user profile
|
|
89
|
+
- `validateAndMapUserInfo()` maps `dataLogin.user` to `cmcts:userInfo`
|
|
90
|
+
- 401 responses automatically clear auth data via `clearAuthenticationData()`
|
|
91
|
+
- VIB-specific auth: `checkAndInitializeAuth()` only runs on `.vib` domains
|
|
92
|
+
|
|
93
|
+
### Chat State Persistence
|
|
94
|
+
- Chat history stored in `{chatflowId}_EXTERNAL` localStorage key
|
|
95
|
+
- Lead data preserved across chat clears
|
|
96
|
+
- Human advisor connection state in `{chatflowId}_HUMAN_ADVISOR_CONNECTED`
|
|
97
|
+
- Scale/width preferences: `cmcts:chatScale`, `cmcts:chatWindowWidth`
|
|
98
|
+
|
|
99
|
+
### File Upload Constraints
|
|
100
|
+
- Images: 3MB max
|
|
101
|
+
- Other files: 10MB max
|
|
102
|
+
- RAG file uploads handled via `upsertVectorStoreWithFormData()`
|
|
103
|
+
- Attachments via `createAttachmentWithFormData()`
|
|
104
|
+
|
|
105
|
+
## TypeScript Configuration
|
|
106
|
+
|
|
107
|
+
Uses `@/*` path alias for `src/*`. JSX uses SolidJS with `preserve` mode.
|
|
108
|
+
|
|
109
|
+
## Development Notes
|
|
110
|
+
|
|
111
|
+
- Dev server serves from `dist` and `public` directories
|
|
112
|
+
- `public/index.html` is optional demo page, not required for production
|
|
113
|
+
- Rollup outputs single `dist/web.js` bundle (ES module format)
|
|
114
|
+
- Custom CSS injection supported via `theme.customCSS`
|
|
115
|
+
|