cmcts-c-agent-embedding 1.0.16-vpcp → 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 (152) hide show
  1. package/.env.example +34 -44
  2. package/.eslintrc.cjs +14 -14
  3. package/.idea/flowise-chatbox.iml +12 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/vcs.xml +6 -0
  6. package/.prettierignore +3 -3
  7. package/.prettierrc +8 -8
  8. package/CLAUDE.md +115 -0
  9. package/README.md +349 -349
  10. package/auggie_shell_conversation.txt +162 -0
  11. package/auggie_shell_user_request.txt +81 -0
  12. package/base.json +21 -21
  13. package/dist/BubbleChat.d.ts +1 -4
  14. package/dist/BubbleChat.d.ts.map +1 -1
  15. package/dist/components/Badge.d.ts.map +1 -1
  16. package/dist/components/Bot.d.ts +7 -2
  17. package/dist/components/Bot.d.ts.map +1 -1
  18. package/dist/components/FeedbackContentDialog.d.ts +3 -0
  19. package/dist/components/FeedbackContentDialog.d.ts.map +1 -1
  20. package/dist/components/avatars/DefaultAvatar.d.ts.map +1 -1
  21. package/dist/components/bubbles/BotBubble.d.ts +6 -1
  22. package/dist/components/bubbles/BotBubble.d.ts.map +1 -1
  23. package/dist/components/bubbles/ChartBubble.d.ts +73 -0
  24. package/dist/components/bubbles/ChartBubble.d.ts.map +1 -0
  25. package/dist/components/bubbles/ChartLoadingPlaceholder.d.ts +8 -0
  26. package/dist/components/bubbles/ChartLoadingPlaceholder.d.ts.map +1 -0
  27. package/dist/components/bubbles/ChartPlaceholder.d.ts +20 -0
  28. package/dist/components/bubbles/ChartPlaceholder.d.ts.map +1 -0
  29. package/dist/components/bubbles/ChartPopupModal.d.ts +4 -0
  30. package/dist/components/bubbles/ChartPopupModal.d.ts.map +1 -0
  31. package/dist/components/bubbles/ChartPortalContainer.d.ts +12 -0
  32. package/dist/components/bubbles/ChartPortalContainer.d.ts.map +1 -0
  33. package/dist/components/bubbles/GuestBubble.d.ts.map +1 -1
  34. package/dist/components/bubbles/LoadingBubble.d.ts +7 -1
  35. package/dist/components/bubbles/LoadingBubble.d.ts.map +1 -1
  36. package/dist/components/bubbles/SourceBubble.d.ts.map +1 -1
  37. package/dist/components/bubbles/StableChartWrapper.d.ts +18 -0
  38. package/dist/components/bubbles/StableChartWrapper.d.ts.map +1 -0
  39. package/dist/components/bubbles/StarterPromptBubble.d.ts.map +1 -1
  40. package/dist/components/buttons/ConsultationButton.d.ts +14 -0
  41. package/dist/components/buttons/ConsultationButton.d.ts.map +1 -0
  42. package/dist/components/buttons/CopyMessageButton.d.ts +10 -0
  43. package/dist/components/buttons/CopyMessageButton.d.ts.map +1 -0
  44. package/dist/components/buttons/EditMessageButton.d.ts +10 -0
  45. package/dist/components/buttons/EditMessageButton.d.ts.map +1 -0
  46. package/dist/components/buttons/PopupToast.d.ts +7 -0
  47. package/dist/components/buttons/PopupToast.d.ts.map +1 -0
  48. package/dist/components/buttons/SendButton.d.ts +1 -0
  49. package/dist/components/buttons/SendButton.d.ts.map +1 -1
  50. package/dist/components/dialogs/EditMessageDialog.d.ts +14 -0
  51. package/dist/components/dialogs/EditMessageDialog.d.ts.map +1 -0
  52. package/dist/components/icons/AddImageIcon.d.ts.map +1 -1
  53. package/dist/components/icons/CheckIcon.d.ts +2 -0
  54. package/dist/components/icons/CheckIcon.d.ts.map +1 -0
  55. package/dist/components/icons/CopyIcon.d.ts +2 -0
  56. package/dist/components/icons/CopyIcon.d.ts.map +1 -0
  57. package/dist/components/icons/EditIcon.d.ts +2 -0
  58. package/dist/components/icons/EditIcon.d.ts.map +1 -0
  59. package/dist/components/icons/ResetZoomIcon.d.ts +3 -0
  60. package/dist/components/icons/ResetZoomIcon.d.ts.map +1 -0
  61. package/dist/components/icons/SupportIcon.d.ts +3 -0
  62. package/dist/components/icons/SupportIcon.d.ts.map +1 -0
  63. package/dist/components/icons/ZoomInIcon.d.ts +3 -0
  64. package/dist/components/icons/ZoomInIcon.d.ts.map +1 -0
  65. package/dist/components/icons/ZoomOutIcon.d.ts +3 -0
  66. package/dist/components/icons/ZoomOutIcon.d.ts.map +1 -0
  67. package/dist/components/icons/index.d.ts +8 -1
  68. package/dist/components/icons/index.d.ts.map +1 -1
  69. package/dist/components/image/PreviewImage.d.ts +1 -1
  70. package/dist/components/image/PreviewImage.d.ts.map +1 -1
  71. package/dist/components/inputs/textInput/components/ShortTextInput.d.ts.map +1 -1
  72. package/dist/components/inputs/textInput/components/TextInput.d.ts +2 -1
  73. package/dist/components/inputs/textInput/components/TextInput.d.ts.map +1 -1
  74. package/dist/components/modals/ZaloQRModal.d.ts +8 -0
  75. package/dist/components/modals/ZaloQRModal.d.ts.map +1 -0
  76. package/dist/features/bubble/components/Bubble.d.ts.map +1 -1
  77. package/dist/features/bubble/components/BubbleButton.d.ts.map +1 -1
  78. package/dist/features/bubble/types.d.ts +5 -0
  79. package/dist/features/bubble/types.d.ts.map +1 -1
  80. package/dist/features/full/components/Full.d.ts.map +1 -1
  81. package/dist/features/popup/components/Popup.d.ts.map +1 -1
  82. package/dist/index.js +1 -1
  83. package/dist/queries/sendMessageQuery.d.ts +15 -0
  84. package/dist/queries/sendMessageQuery.d.ts.map +1 -1
  85. package/dist/types/chart.d.ts +86 -0
  86. package/dist/types/chart.d.ts.map +1 -0
  87. package/dist/utils/chartConfigManager.d.ts +54 -0
  88. package/dist/utils/chartConfigManager.d.ts.map +1 -0
  89. package/dist/utils/chartInstanceManager.d.ts +43 -0
  90. package/dist/utils/chartInstanceManager.d.ts.map +1 -0
  91. package/dist/utils/chartPopupManager.d.ts +43 -0
  92. package/dist/utils/chartPopupManager.d.ts.map +1 -0
  93. package/dist/utils/chartPortalManager.d.ts +76 -0
  94. package/dist/utils/chartPortalManager.d.ts.map +1 -0
  95. package/dist/utils/chartTagParser.d.ts +39 -0
  96. package/dist/utils/chartTagParser.d.ts.map +1 -0
  97. package/dist/utils/index.d.ts +77 -0
  98. package/dist/utils/index.d.ts.map +1 -1
  99. package/dist/utils/isMobileSignal.d.ts +1 -3
  100. package/dist/utils/isMobileSignal.d.ts.map +1 -1
  101. package/dist/utils/security.d.ts +50 -0
  102. package/dist/utils/security.d.ts.map +1 -0
  103. package/dist/utils/textStreamSmoother.d.ts +40 -0
  104. package/dist/utils/textStreamSmoother.d.ts.map +1 -0
  105. package/dist/utils/transcriptApi.d.ts +17 -0
  106. package/dist/utils/transcriptApi.d.ts.map +1 -0
  107. package/dist/utils/ultimateJsonParser.d.ts.map +1 -1
  108. package/dist/web.d.ts +2 -6
  109. package/dist/web.d.ts.map +1 -1
  110. package/dist/web.js +1 -1
  111. package/dist/window.d.ts +1 -3
  112. package/dist/window.d.ts.map +1 -1
  113. package/docs/chart-rendering-implementation-plan.md +565 -0
  114. package/flowise-chatbox/.env.example +34 -0
  115. package/flowise-chatbox/.eslintrc.cjs +15 -0
  116. package/flowise-chatbox/.prettierignore +3 -0
  117. package/flowise-chatbox/.prettierrc +8 -0
  118. package/flowise-chatbox/AGENTS.md +166 -0
  119. package/flowise-chatbox/README.md +349 -0
  120. package/flowise-chatbox/auggie_shell.ps1 +10 -0
  121. package/flowise-chatbox/auggie_shell_user_request.txt +75 -0
  122. package/flowise-chatbox/base.json +21 -0
  123. package/flowise-chatbox/docs/chart-rendering-implementation-plan.md +565 -0
  124. package/flowise-chatbox/images/ChatEmbed.gif +0 -0
  125. package/flowise-chatbox/images/proxyserver.png +0 -0
  126. package/flowise-chatbox/package-lock.json +11914 -0
  127. package/flowise-chatbox/package.json +86 -0
  128. package/flowise-chatbox/public/index.html +43 -0
  129. package/flowise-chatbox/server.js +401 -0
  130. package/flowise-chatbox/yarn.lock +6294 -0
  131. package/package.json +84 -81
  132. package/public/index.html +46 -44
  133. package/server.js +401 -403
  134. package/.augment-guidelines +0 -218
  135. package/.env +0 -5
  136. package/GOOGLE_ANALYTICS_INTEGRATION.md +0 -236
  137. package/NUNITO_FONT_IMPLEMENTATION.md +0 -128
  138. package/dist/components/mobile/MobileWelcomeScreen.d.ts +0 -13
  139. package/dist/components/mobile/MobileWelcomeScreen.d.ts.map +0 -1
  140. package/dist/hooks/useMobileDetection.d.ts +0 -52
  141. package/dist/hooks/useMobileDetection.d.ts.map +0 -1
  142. package/dist/test-markdown-component.d.ts +0 -2
  143. package/dist/test-markdown-component.d.ts.map +0 -1
  144. package/dist/utils/googleAnalytics.d.ts +0 -194
  145. package/dist/utils/googleAnalytics.d.ts.map +0 -1
  146. package/dist/utils/mobileUtils.d.ts +0 -32
  147. package/dist/utils/mobileUtils.d.ts.map +0 -1
  148. package/public/icon_bot.png +0 -0
  149. package/public/logo.png +0 -0
  150. package/test-ad-blocker.html +0 -269
  151. package/test-ga-property.html +0 -254
  152. package/tsconfig.typecheck.json +0 -18
package/.env.example CHANGED
@@ -1,44 +1,34 @@
1
- # ==============================================
2
- # REQUIRED CONFIGURATION
3
- # ==============================================
4
-
5
- # API Host URL (required)
6
- # This should be the URL where your Flowise instance is running
7
- # Example: https://your-flowise-instance.com
8
- API_HOST=
9
-
10
- # Flowise API Key (required)
11
- # Generate this from your Flowise instance settings page
12
- # Example: OxxGE-h_LaH7ZYorStjTOik1XY999RxxoHpCSYl8BXxc
13
- FLOWISE_API_KEY=
14
-
15
- # ==============================================
16
- # CHATFLOWS CONFIGURATION (required)
17
- # ==============================================
18
-
19
- # Format: [identifier]=[chatflowId],[allowedDomain1],[allowedDomain2],...
20
- #
21
- # Each entry consists of:
22
- # - identifier: Any name you choose (e.g., agent1, support, salesbot)
23
- # - chatflowId: The UUID of your Flowise chatflow
24
- # - allowedDomains: Comma-separated list of domains where this chat can be embedded
25
- # Note: Wildcard domains (*) are not supported for security reasons
26
- #
27
- # Examples:
28
- # agent1=20db97c6-64c9-4411-bab4-7d6202171600,https://example1.com
29
- # support=1c28f529-a70f-5001-9bc5-4f4c5d03d8c0,https://example2.com,https://another-example2.com
30
- # salesbot=3db97c6-64c9-4411-bab4-7d620217160a,https://sales.example.com
31
-
32
- # Add your chatflows below:
33
- chatflow_1=
34
- chatflow_2=
35
-
36
- # ==============================================
37
- # OPTIONAL CONFIGURATION
38
- # ==============================================
39
-
40
- # Google Analytics Measurement ID (optional - defaults to G-MTB5ZRBS1C)
41
- # Format: G-XXXXXXXXXX (for GA4) or UA-XXXXXXXXX-X (for Universal Analytics)
42
- # Example: G-ABC123DEF4
43
- # If not set, will use default: G-MTB5ZRBS1C
44
- GOOGLE_ANALYTICS_ID=
1
+ # ==============================================
2
+ # REQUIRED CONFIGURATION
3
+ # ==============================================
4
+
5
+ # API Host URL (required)
6
+ # This should be the URL where your Flowise instance is running
7
+ # Example: https://your-flowise-instance.com
8
+ API_HOST=
9
+
10
+ # Flowise API Key (required)
11
+ # Generate this from your Flowise instance settings page
12
+ # Example: OxxGE-h_LaH7ZYorStjTOik1XY999RxxoHpCSYl8BXxc
13
+ FLOWISE_API_KEY=
14
+
15
+ # ==============================================
16
+ # CHATFLOWS CONFIGURATION (required)
17
+ # ==============================================
18
+
19
+ # Format: [identifier]=[chatflowId],[allowedDomain1],[allowedDomain2],...
20
+ #
21
+ # Each entry consists of:
22
+ # - identifier: Any name you choose (e.g., agent1, support, salesbot)
23
+ # - chatflowId: The UUID of your Flowise chatflow
24
+ # - allowedDomains: Comma-separated list of domains where this chat can be embedded
25
+ # Note: Wildcard domains (*) are not supported for security reasons
26
+ #
27
+ # Examples:
28
+ # agent1=20db97c6-64c9-4411-bab4-7d6202171600,https://example1.com
29
+ # support=1c28f529-a70f-5001-9bc5-4f4c5d03d8c0,https://example2.com,https://another-example2.com
30
+ # salesbot=3db97c6-64c9-4411-bab4-7d620217160a,https://sales.example.com
31
+
32
+ # Add your chatflows below:
33
+ chatflow_1=
34
+ chatflow_2=
package/.eslintrc.cjs CHANGED
@@ -1,14 +1,14 @@
1
- module.exports = {
2
- root: true,
3
- extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier', 'plugin:solid/typescript'],
4
- plugins: ['@typescript-eslint', 'solid'],
5
- parser: '@typescript-eslint/parser',
6
- ignorePatterns: ['**/*.md'],
7
- rules: {
8
- '@next/next/no-img-element': 'off',
9
- '@next/next/no-html-link-for-pages': 'off',
10
- 'solid/no-innerhtml': 'off',
11
- '@typescript-eslint/no-namespace': 'off',
12
- '@typescript-eslint/no-explicit-any': 'off'
13
- }
14
- }
1
+ module.exports = {
2
+ root: true,
3
+ extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier', 'plugin:solid/typescript'],
4
+ plugins: ['@typescript-eslint', 'solid'],
5
+ parser: '@typescript-eslint/parser',
6
+ ignorePatterns: ['**/*.md'],
7
+ rules: {
8
+ '@next/next/no-img-element': 'off',
9
+ '@next/next/no-html-link-for-pages': 'off',
10
+ 'solid/no-innerhtml': 'off',
11
+ '@typescript-eslint/no-namespace': 'off',
12
+ '@typescript-eslint/no-explicit-any': 'off'
13
+ }
14
+ }
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="WEB_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6
+ <excludeFolder url="file://$MODULE_DIR$/temp" />
7
+ <excludeFolder url="file://$MODULE_DIR$/tmp" />
8
+ </content>
9
+ <orderEntry type="inheritedJdk" />
10
+ <orderEntry type="sourceFolder" forTests="false" />
11
+ </component>
12
+ </module>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/flowise-chatbox.iml" filepath="$PROJECT_DIR$/.idea/flowise-chatbox.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
package/.prettierignore CHANGED
@@ -1,3 +1,3 @@
1
- node_modules
2
- build
3
- dist
1
+ node_modules
2
+ build
3
+ dist
package/.prettierrc CHANGED
@@ -1,8 +1,8 @@
1
- {
2
- "semi": true,
3
- "singleQuote": true,
4
- "tabWidth": 2,
5
- "trailingComma": "all",
6
- "printWidth": 150,
7
- "endOfLine": "lf"
8
- }
1
+ {
2
+ "semi": true,
3
+ "singleQuote": true,
4
+ "tabWidth": 2,
5
+ "trailingComma": "all",
6
+ "printWidth": 150,
7
+ "endOfLine": "lf"
8
+ }
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
+