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.
Files changed (158) hide show
  1. package/.idea/{Flowise-share-chatbox.iml → flowise-chatbox.iml} +0 -1
  2. package/.idea/modules.xml +1 -2
  3. package/.idea/vcs.xml +5 -6
  4. package/CLAUDE.md +115 -0
  5. package/README.md +349 -349
  6. package/auggie_shell_conversation.txt +162 -0
  7. package/auggie_shell_user_request.txt +81 -0
  8. package/dist/BubbleChat.d.ts +9 -12
  9. package/dist/BubbleChat.d.ts.map +1 -1
  10. package/dist/FullPageChat.d.ts +17 -17
  11. package/dist/components/Bot.d.ts +14 -0
  12. package/dist/components/Bot.d.ts.map +1 -1
  13. package/dist/components/FeedbackContentDialog.d.ts +6 -0
  14. package/dist/components/FeedbackContentDialog.d.ts.map +1 -1
  15. package/dist/components/Toast.d.ts +10 -0
  16. package/dist/components/Toast.d.ts.map +1 -0
  17. package/dist/components/bubbles/BotBubble.d.ts +11 -0
  18. package/dist/components/bubbles/BotBubble.d.ts.map +1 -1
  19. package/dist/components/bubbles/ChartBubble.d.ts +73 -0
  20. package/dist/components/bubbles/ChartBubble.d.ts.map +1 -0
  21. package/dist/components/bubbles/ChartLoadingPlaceholder.d.ts +8 -0
  22. package/dist/components/bubbles/ChartLoadingPlaceholder.d.ts.map +1 -0
  23. package/dist/components/bubbles/ChartPlaceholder.d.ts +20 -0
  24. package/dist/components/bubbles/ChartPlaceholder.d.ts.map +1 -0
  25. package/dist/components/bubbles/ChartPopupModal.d.ts +4 -0
  26. package/dist/components/bubbles/ChartPopupModal.d.ts.map +1 -0
  27. package/dist/components/bubbles/ChartPortalContainer.d.ts +12 -0
  28. package/dist/components/bubbles/ChartPortalContainer.d.ts.map +1 -0
  29. package/dist/components/bubbles/LoadingBubble.d.ts +7 -1
  30. package/dist/components/bubbles/LoadingBubble.d.ts.map +1 -1
  31. package/dist/components/bubbles/SourceBubble.d.ts.map +1 -1
  32. package/dist/components/bubbles/StableChartWrapper.d.ts +18 -0
  33. package/dist/components/bubbles/StableChartWrapper.d.ts.map +1 -0
  34. package/dist/components/bubbles/StarterPromptBubble.d.ts.map +1 -1
  35. package/dist/components/buttons/ConsultationButton.d.ts +14 -0
  36. package/dist/components/buttons/ConsultationButton.d.ts.map +1 -0
  37. package/dist/components/buttons/CopyMessageButton.d.ts +10 -0
  38. package/dist/components/buttons/CopyMessageButton.d.ts.map +1 -0
  39. package/dist/components/buttons/EditMessageButton.d.ts +10 -0
  40. package/dist/components/buttons/EditMessageButton.d.ts.map +1 -0
  41. package/dist/components/buttons/FeedbackButtons.d.ts +1 -0
  42. package/dist/components/buttons/FeedbackButtons.d.ts.map +1 -1
  43. package/dist/components/buttons/PopupToast.d.ts +7 -0
  44. package/dist/components/buttons/PopupToast.d.ts.map +1 -0
  45. package/dist/components/buttons/SendButton.d.ts +1 -0
  46. package/dist/components/buttons/SendButton.d.ts.map +1 -1
  47. package/dist/components/dialogs/EditMessageDialog.d.ts +14 -0
  48. package/dist/components/dialogs/EditMessageDialog.d.ts.map +1 -0
  49. package/dist/components/icons/AddImageIcon.d.ts.map +1 -1
  50. package/dist/components/icons/CheckIcon.d.ts +2 -0
  51. package/dist/components/icons/CheckIcon.d.ts.map +1 -0
  52. package/dist/components/icons/CmcIcon.d.ts +3 -0
  53. package/dist/components/icons/CmcIcon.d.ts.map +1 -0
  54. package/dist/components/icons/CopyIcon.d.ts +2 -0
  55. package/dist/components/icons/CopyIcon.d.ts.map +1 -0
  56. package/dist/components/icons/EditIcon.d.ts +2 -0
  57. package/dist/components/icons/EditIcon.d.ts.map +1 -0
  58. package/dist/components/icons/FullScreenIcon.d.ts +3 -0
  59. package/dist/components/icons/FullScreenIcon.d.ts.map +1 -0
  60. package/dist/components/icons/ResetBtn.d.ts +3 -0
  61. package/dist/components/icons/ResetBtn.d.ts.map +1 -0
  62. package/dist/components/icons/ResetZoomIcon.d.ts +3 -0
  63. package/dist/components/icons/ResetZoomIcon.d.ts.map +1 -0
  64. package/dist/components/icons/SendIconOff.d.ts +3 -0
  65. package/dist/components/icons/SendIconOff.d.ts.map +1 -0
  66. package/dist/components/icons/SendIconOn.d.ts +3 -0
  67. package/dist/components/icons/SendIconOn.d.ts.map +1 -0
  68. package/dist/components/icons/SupportIcon.d.ts +3 -0
  69. package/dist/components/icons/SupportIcon.d.ts.map +1 -0
  70. package/dist/components/icons/ThumbsDownIcon.d.ts +3 -1
  71. package/dist/components/icons/ThumbsDownIcon.d.ts.map +1 -1
  72. package/dist/components/icons/ThumbsUpIcon.d.ts +3 -1
  73. package/dist/components/icons/ThumbsUpIcon.d.ts.map +1 -1
  74. package/dist/components/icons/ZoomInIcon.d.ts +3 -0
  75. package/dist/components/icons/ZoomInIcon.d.ts.map +1 -0
  76. package/dist/components/icons/ZoomOutIcon.d.ts +3 -0
  77. package/dist/components/icons/ZoomOutIcon.d.ts.map +1 -0
  78. package/dist/components/icons/index.d.ts +7 -0
  79. package/dist/components/icons/index.d.ts.map +1 -1
  80. package/dist/components/image/PreviewImage.d.ts +5 -0
  81. package/dist/components/image/PreviewImage.d.ts.map +1 -0
  82. package/dist/components/inputs/textInput/components/ShortTextInput.d.ts +3 -0
  83. package/dist/components/inputs/textInput/components/ShortTextInput.d.ts.map +1 -1
  84. package/dist/components/inputs/textInput/components/TextInput.d.ts +11 -3
  85. package/dist/components/inputs/textInput/components/TextInput.d.ts.map +1 -1
  86. package/dist/components/modals/ZaloQRModal.d.ts +8 -0
  87. package/dist/components/modals/ZaloQRModal.d.ts.map +1 -0
  88. package/dist/constants.d.ts.map +1 -1
  89. package/dist/features/bubble/components/Bubble.d.ts.map +1 -1
  90. package/dist/features/bubble/types.d.ts +6 -0
  91. package/dist/features/bubble/types.d.ts.map +1 -1
  92. package/dist/features/full/components/Full.d.ts.map +1 -1
  93. package/dist/features/popup/components/Popup.d.ts.map +1 -1
  94. package/dist/index.js +1 -1
  95. package/dist/queries/sendMessageQuery.d.ts +52 -1
  96. package/dist/queries/sendMessageQuery.d.ts.map +1 -1
  97. package/dist/types/chart.d.ts +86 -0
  98. package/dist/types/chart.d.ts.map +1 -0
  99. package/dist/utils/chartConfigManager.d.ts +54 -0
  100. package/dist/utils/chartConfigManager.d.ts.map +1 -0
  101. package/dist/utils/chartInstanceManager.d.ts +43 -0
  102. package/dist/utils/chartInstanceManager.d.ts.map +1 -0
  103. package/dist/utils/chartPopupManager.d.ts +43 -0
  104. package/dist/utils/chartPopupManager.d.ts.map +1 -0
  105. package/dist/utils/chartPortalManager.d.ts +76 -0
  106. package/dist/utils/chartPortalManager.d.ts.map +1 -0
  107. package/dist/utils/chartTagParser.d.ts +39 -0
  108. package/dist/utils/chartTagParser.d.ts.map +1 -0
  109. package/dist/utils/index.d.ts +77 -0
  110. package/dist/utils/index.d.ts.map +1 -1
  111. package/dist/utils/security.d.ts +50 -0
  112. package/dist/utils/security.d.ts.map +1 -0
  113. package/dist/utils/textStreamSmoother.d.ts +40 -0
  114. package/dist/utils/textStreamSmoother.d.ts.map +1 -0
  115. package/dist/utils/transcriptApi.d.ts +17 -0
  116. package/dist/utils/transcriptApi.d.ts.map +1 -0
  117. package/dist/utils/ultimateJsonParser.d.ts +2 -0
  118. package/dist/utils/ultimateJsonParser.d.ts.map +1 -0
  119. package/dist/web.d.ts +2 -0
  120. package/dist/web.d.ts.map +1 -1
  121. package/dist/web.js +1 -1
  122. package/dist/window.d.ts +1 -0
  123. package/dist/window.d.ts.map +1 -1
  124. package/docs/chart-rendering-implementation-plan.md +565 -0
  125. package/{.env → flowise-chatbox/.env.example} +3 -5
  126. package/flowise-chatbox/.eslintrc.cjs +15 -0
  127. package/flowise-chatbox/.prettierignore +3 -0
  128. package/flowise-chatbox/.prettierrc +8 -0
  129. package/flowise-chatbox/AGENTS.md +166 -0
  130. package/flowise-chatbox/README.md +349 -0
  131. package/flowise-chatbox/auggie_shell.ps1 +10 -0
  132. package/flowise-chatbox/auggie_shell_user_request.txt +75 -0
  133. package/flowise-chatbox/base.json +21 -0
  134. package/flowise-chatbox/docs/chart-rendering-implementation-plan.md +565 -0
  135. package/flowise-chatbox/images/ChatEmbed.gif +0 -0
  136. package/flowise-chatbox/images/proxyserver.png +0 -0
  137. package/flowise-chatbox/package-lock.json +11914 -0
  138. package/flowise-chatbox/package.json +86 -0
  139. package/flowise-chatbox/public/index.html +43 -0
  140. package/flowise-chatbox/server.js +401 -0
  141. package/flowise-chatbox/yarn.lock +6294 -0
  142. package/package.json +13 -8
  143. package/public/index.html +33 -142
  144. package/server.js +401 -401
  145. package/.husky/pre-commit +0 -18
  146. package/.idea/codeStyles/Project.xml +0 -60
  147. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  148. package/.idea/inspectionProfiles/Project_Default.xml +0 -16
  149. package/.idea/prettier.xml +0 -6
  150. package/a.json +0 -57
  151. package/bun.lockb +0 -0
  152. package/dist/components/ImageUploadButton.d.ts +0 -11
  153. package/dist/components/ImageUploadButton.d.ts.map +0 -1
  154. package/dist/components/RecordAudioButton.d.ts +0 -11
  155. package/dist/components/RecordAudioButton.d.ts.map +0 -1
  156. package/dist/components/SendButton.d.ts +0 -12
  157. package/dist/components/SendButton.d.ts.map +0 -1
  158. package/test.html +0 -17
@@ -8,6 +8,5 @@
8
8
  </content>
9
9
  <orderEntry type="inheritedJdk" />
10
10
  <orderEntry type="sourceFolder" forTests="false" />
11
- <orderEntry type="module" module-name="Flowise-share-chatbox-main" />
12
11
  </component>
13
12
  </module>
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/Flowise-share-chatbox.iml" filepath="$PROJECT_DIR$/.idea/Flowise-share-chatbox.iml" />
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
- <mapping directory="$PROJECT_DIR$/../Flowise-share-chatbox-main" vcs="Git" />
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
+