@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.
Files changed (110) hide show
  1. package/.env.example +34 -0
  2. package/.eslintrc.cjs +15 -0
  3. package/.idea/flowise-chatbox.iml +10 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/workspace.xml +4 -0
  6. package/.prettierignore +3 -0
  7. package/.prettierrc +8 -0
  8. package/AGENTS.md +184 -0
  9. package/README.md +213 -0
  10. package/base.json +21 -0
  11. package/dist/api/chatRoom.d.ts +84 -0
  12. package/dist/assets/notificationSounds.d.ts +2 -0
  13. package/dist/components/Badge.d.ts +9 -0
  14. package/dist/components/Bot.d.ts +132 -0
  15. package/dist/components/FeedbackContentDialog.d.ts +12 -0
  16. package/dist/components/RoomReconnectAlert.d.ts +13 -0
  17. package/dist/components/Toast.d.ts +9 -0
  18. package/dist/components/TypingBubble.d.ts +1 -0
  19. package/dist/components/avatars/Avatar.d.ts +3 -0
  20. package/dist/components/avatars/DefaultAvatar.d.ts +1 -0
  21. package/dist/components/bubbles/AgentReasoningBubble.d.ts +15 -0
  22. package/dist/components/bubbles/BotBubble.d.ts +39 -0
  23. package/dist/components/bubbles/ChartBubble.d.ts +72 -0
  24. package/dist/components/bubbles/ChartLoadingPlaceholder.d.ts +7 -0
  25. package/dist/components/bubbles/ChartPlaceholder.d.ts +19 -0
  26. package/dist/components/bubbles/ChartPopupModal.d.ts +3 -0
  27. package/dist/components/bubbles/FollowUpPromptBubble.d.ts +7 -0
  28. package/dist/components/bubbles/GuestBubble.d.ts +15 -0
  29. package/dist/components/bubbles/LeadCaptureBubble.d.ts +19 -0
  30. package/dist/components/bubbles/LoadingBubble.d.ts +7 -0
  31. package/dist/components/bubbles/SourceBubble.d.ts +8 -0
  32. package/dist/components/bubbles/StableChartWrapper.d.ts +17 -0
  33. package/dist/components/bubbles/StarterPromptBubble.d.ts +7 -0
  34. package/dist/components/buttons/AttachmentUploadButton.d.ts +10 -0
  35. package/dist/components/buttons/CancelButton.d.ts +9 -0
  36. package/dist/components/buttons/CopyMessageButton.d.ts +9 -0
  37. package/dist/components/buttons/EditMessageButton.d.ts +7 -0
  38. package/dist/components/buttons/FeedbackButtons.d.ts +13 -0
  39. package/dist/components/buttons/ImageUploadButton.d.ts +10 -0
  40. package/dist/components/buttons/LeadCaptureButtons.d.ts +10 -0
  41. package/dist/components/buttons/PopupToast.d.ts +6 -0
  42. package/dist/components/buttons/RecordAudioButton.d.ts +10 -0
  43. package/dist/components/buttons/SendButton.d.ts +12 -0
  44. package/dist/components/dialogs/EditMessageDialog.d.ts +8 -0
  45. package/dist/components/icons/AddImageIcon.d.ts +2 -0
  46. package/dist/components/icons/AttachmentIcon.d.ts +2 -0
  47. package/dist/components/icons/CheckIcon.d.ts +2 -0
  48. package/dist/components/icons/CircleDotIcon.d.ts +2 -0
  49. package/dist/components/icons/ClipboardIcon.d.ts +2 -0
  50. package/dist/components/icons/CopyIcon.d.ts +4 -0
  51. package/dist/components/icons/DeleteIcon.d.ts +2 -0
  52. package/dist/components/icons/EditIcon.d.ts +4 -0
  53. package/dist/components/icons/FullScreenIcon.d.ts +2 -0
  54. package/dist/components/icons/RecordIcon.d.ts +2 -0
  55. package/dist/components/icons/ResetZoomIcon.d.ts +2 -0
  56. package/dist/components/icons/SendIcon.d.ts +2 -0
  57. package/dist/components/icons/SparklesIcon.d.ts +2 -0
  58. package/dist/components/icons/StopIcon.d.ts +2 -0
  59. package/dist/components/icons/ThumbsDownIcon.d.ts +4 -0
  60. package/dist/components/icons/ThumbsUpIcon.d.ts +4 -0
  61. package/dist/components/icons/TickIcon.d.ts +1 -0
  62. package/dist/components/icons/TrashIcon.d.ts +2 -0
  63. package/dist/components/icons/XIcon.d.ts +4 -0
  64. package/dist/components/icons/ZoomInIcon.d.ts +2 -0
  65. package/dist/components/icons/ZoomOutIcon.d.ts +2 -0
  66. package/dist/components/icons/index.d.ts +21 -0
  67. package/dist/components/image/PreviewImage.d.ts +4 -0
  68. package/dist/components/index.d.ts +3 -0
  69. package/dist/components/inputs/textInput/components/FilePreview.d.ts +11 -0
  70. package/dist/components/inputs/textInput/components/ShortTextInput.d.ts +13 -0
  71. package/dist/components/inputs/textInput/components/TextInput.d.ts +50 -0
  72. package/dist/components/inputs/textInput/index.d.ts +2 -0
  73. package/dist/constants.d.ts +2 -0
  74. package/dist/features/bubble/components/Bubble.d.ts +4 -0
  75. package/dist/features/bubble/components/BubbleButton.d.ts +15 -0
  76. package/dist/features/bubble/components/Tooltip.d.ts +14 -0
  77. package/dist/features/bubble/components/index.d.ts +1 -0
  78. package/dist/features/bubble/index.d.ts +1 -0
  79. package/dist/features/bubble/types.d.ts +108 -0
  80. package/dist/features/full/components/Full.d.ts +6 -0
  81. package/dist/features/full/components/index.d.ts +1 -0
  82. package/dist/features/full/index.d.ts +1 -0
  83. package/dist/features/popup/components/DisclaimerPopup.d.ts +13 -0
  84. package/dist/features/popup/components/Popup.d.ts +8 -0
  85. package/dist/features/popup/components/index.d.ts +2 -0
  86. package/dist/features/popup/index.d.ts +1 -0
  87. package/dist/features/popup/types.d.ts +7 -0
  88. package/dist/index.d.ts +2 -0
  89. package/dist/queries/sendMessageQuery.d.ts +165 -0
  90. package/dist/register.d.ts +1 -0
  91. package/dist/store/constant.d.ts +42 -0
  92. package/dist/types/chart.d.ts +85 -0
  93. package/dist/utils/audioRecording.d.ts +20 -0
  94. package/dist/utils/chartInstanceManager.d.ts +42 -0
  95. package/dist/utils/chartTagParser.d.ts +38 -0
  96. package/dist/utils/chatInputHistory.d.ts +21 -0
  97. package/dist/utils/chatStreamHelper.d.ts +18 -0
  98. package/dist/utils/index.d.ts +26 -0
  99. package/dist/utils/isMobileSignal.d.ts +1 -0
  100. package/dist/utils/transcriptApi.d.ts +7 -0
  101. package/dist/utils/ultimateJsonParser.d.ts +1 -0
  102. package/dist/web.d.ts +34 -0
  103. package/dist/web.js +1 -0
  104. package/dist/window.d.ts +35 -0
  105. package/docs/chart-rendering-implementation-plan.md +565 -0
  106. package/images/ChatEmbed.gif +0 -0
  107. package/images/proxyserver.png +0 -0
  108. package/package.json +87 -0
  109. package/public/index.html +43 -0
  110. package/server.js +477 -0
package/.env.example ADDED
@@ -0,0 +1,34 @@
1
+ # ==============================================
2
+ # REQUIRED CONFIGURATION
3
+ # ==============================================
4
+
5
+ # API Host URL (required)
6
+ # This should be the URL where your backend instance is running
7
+ # Example: https://your-backend-instance.com
8
+ API_HOST=
9
+
10
+ # API Key (required)
11
+ # Generate this from your backend instance settings page
12
+ # Example: OxxGE-h_LaH7ZYorStjTOik1XY999RxxoHpCSYl8BXxc
13
+ CAGENT_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 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 ADDED
@@ -0,0 +1,15 @@
1
+ // eslint-disable-next-line no-undef
2
+ module.exports = {
3
+ root: true,
4
+ extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier', 'plugin:solid/typescript'],
5
+ plugins: ['@typescript-eslint', 'solid'],
6
+ parser: '@typescript-eslint/parser',
7
+ ignorePatterns: ['**/*.md'],
8
+ rules: {
9
+ '@next/next/no-img-element': 'off',
10
+ '@next/next/no-html-link-for-pages': 'off',
11
+ 'solid/no-innerhtml': 'off',
12
+ '@typescript-eslint/no-namespace': 'off',
13
+ '@typescript-eslint/no-explicit-any': 'off'
14
+ }
15
+ }
@@ -0,0 +1,10 @@
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$/.idea" />
6
+ </content>
7
+ <orderEntry type="inheritedJdk" />
8
+ <orderEntry type="sourceFolder" forTests="false" />
9
+ </component>
10
+ </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>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="PropertiesComponent">{}</component>
4
+ </project>
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ build
3
+ dist
package/.prettierrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": true,
4
+ "tabWidth": 2,
5
+ "trailingComma": "all",
6
+ "printWidth": 150,
7
+ "endOfLine": "lf"
8
+ }
package/AGENTS.md ADDED
@@ -0,0 +1,184 @@
1
+ # AGENTS.md - Coding Guidelines
2
+
3
+ > **Purpose:** Guidelines for code quality, development process, and decision-making
4
+ > **Target Audience:** AI coding assistants and developers
5
+ > **Version:** 1.0
6
+
7
+ ---
8
+
9
+ ## Code Quality Standards
10
+
11
+ ### Core Principles
12
+
13
+ #### No Unused Code
14
+
15
+ - **Rule:** Don't write unused code
16
+ - **Requirement:** Ensure everything written is utilized in the project
17
+ - **Priority:** Critical
18
+
19
+ #### Readability First
20
+
21
+ - **Rule:** Prioritize readability for human understanding over execution efficiency
22
+ - **Priority:** Critical
23
+
24
+ #### Maintainability
25
+
26
+ - **Rule:** Maintain long-term maintainability over short-term optimization
27
+ - **Priority:** High
28
+
29
+ #### Simplicity
30
+
31
+ - **Rule:** Avoid unnecessary complexity
32
+ - **Approach:** Implement simple solutions unless complexity is truly required
33
+ - **Priority:** High
34
+
35
+ #### Clean Code Philosophy
36
+
37
+ - **Rule:** Follow Linus Torvalds' clean code principles
38
+ - **Priority:** High
39
+ - **Guidelines:**
40
+ 1. Keep it simple
41
+ 2. Make code readable like prose
42
+ 3. Avoid premature optimization
43
+ 4. Express intent clearly
44
+ 5. Minimize abstraction layers
45
+
46
+ ---
47
+
48
+ ### Documentation Standards
49
+
50
+ #### Comment Purpose
51
+
52
+ - **Rule:** Comments must explain "what" (business logic/purpose) and "why" (reasoning/decisions), not "how"
53
+ - **Priority:** High
54
+
55
+ #### Avoid Over-Commenting
56
+
57
+ - **Rule:** Avoid over-commenting
58
+ - **Rationale:** Excessive comments indicate poor code quality
59
+ - **Priority:** Medium
60
+
61
+ #### Function Comments
62
+
63
+ - **Rule:** Function comments must explain purpose and reasoning
64
+ - **Placement:** Placed at function beginnings
65
+ - **Priority:** Medium
66
+
67
+ #### Self-Explanatory Code
68
+
69
+ - **Rule:** Well-written code should be self-explanatory
70
+ - **Method:** Through meaningful names and clear structure
71
+ - **Priority:** High
72
+
73
+ ---
74
+
75
+ ## Development Process
76
+
77
+ > **Description:** Follow these steps in order for effective development
78
+ > **Priority:** Critical
79
+
80
+ | Step | Name | Action/Rationale | Importance |
81
+ | ---- | ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
82
+ | 1 | Understand First | Use available tools to understand data structures before implementation | Critical |
83
+ | 2 | Design Data Structures | Good data structures lead to good code | Critical |
84
+ | 3 | Define Interfaces | Specify all input/output structures before writing logic | High |
85
+ | 4 | Define Functions | Create all function signatures before implementation | High |
86
+ | 5 | Implement Logic | Write implementation only after structures and definitions are complete | High |
87
+ | 6 | Validate Code Quality | Always run lint and typecheck after writing code. Fix all linting errors and type errors before considering the task complete. Zero tolerance for lint and typecheck errors | Critical |
88
+
89
+ ---
90
+
91
+ ## Quality Guidelines
92
+
93
+ #### Avoid Over-Engineering
94
+
95
+ - **Rule:** Avoid over-engineering
96
+ - **Focus:** Focus on minimal viable solutions meeting acceptance criteria
97
+ - **Priority:** High
98
+
99
+ #### Testing Approach
100
+
101
+ - **Rule:** Only create automated tests if explicitly required
102
+ - **Priority:** Medium
103
+
104
+ #### Feature Scope
105
+
106
+ - **Rule:** Never add functionality "just in case"
107
+ - **Requirement:** Implement only what's needed now
108
+ - **Priority:** High
109
+
110
+ #### Code Validation
111
+
112
+ - **Rule:** Always run lint and typecheck after code changes
113
+ - **Requirement:** Must fix all linting and type checking errors before completion
114
+ - **Process:** Run lint command, then typecheck command. Address all errors and warnings
115
+ - **Tolerance:** Zero tolerance for lint or typecheck errors
116
+ - **Priority:** Critical
117
+
118
+ ---
119
+
120
+ ## Decision Making Framework
121
+
122
+ > **Description:** Apply these principles systematically for all decisions
123
+ > **Priority:** High
124
+
125
+ | Step | Principle | Importance |
126
+ | ---- | ---------------------------- | ---------- |
127
+ | 1 | Gather Complete Information | Critical |
128
+ | 2 | Multi-Perspective Analysis | High |
129
+ | 3 | Consider All Stakeholders | High |
130
+ | 4 | Evaluate Alternatives | High |
131
+ | 5 | Assess Impact & Consequences | High |
132
+ | 6 | Apply Ethical Framework | Medium |
133
+ | 7 | Take Responsibility | High |
134
+ | 8 | Learn & Adapt | High |
135
+
136
+ ---
137
+
138
+ ## Code Validation Workflow
139
+
140
+ > **Description:** Mandatory validation process after writing or modifying code
141
+ > **Priority:** Critical
142
+
143
+ #### Validation Commands
144
+
145
+ - **Lint Fix Command:** `yarn run lint-fix`
146
+ - **Type Check Command:** `yarn run type-check`
147
+ - **Combined Command:** `yarn run lint-fix && yarn run type-check`
148
+
149
+ #### Required Workflow
150
+
151
+ | Step | Action | Description |
152
+ | ---- | --------------- | -------------------------------------------------- |
153
+ | 1 | Write/Edit Code | Make your code changes |
154
+ | 2 | Run Validation | Execute `yarn run lint-fix && yarn run type-check` |
155
+ | 3 | Review Results | Check for any remaining errors |
156
+ | 4 | Fix Errors | Address all lint and type errors |
157
+ | 5 | Repeat | Run validation again until all errors are resolved |
158
+
159
+ #### Rules
160
+
161
+ - **Rule:** Always run validation commands after every code change
162
+ - **Requirement:** Must run both lint-fix and type-check before considering task complete
163
+ - **Tolerance:** Zero errors allowed - all lint and type errors must be fixed
164
+ - **Priority:** Critical
165
+
166
+ ---
167
+
168
+ ## Package Manager
169
+
170
+ #### Required Package Manager
171
+
172
+ - **Rule:** Use `yarn` as the package manager for this project
173
+ - **Requirement:** All package installations and script executions must use `yarn`
174
+ - **Prohibited:** Do NOT use `npm`, `pnpm`, or `bun`
175
+ - **Priority:** Critical
176
+
177
+ #### Examples
178
+
179
+ | Action | Correct | Incorrect |
180
+ | -------------------- | ----------------------- | ----------------------------- |
181
+ | Install dependencies | `yarn install` | `npm install`, `pnpm install` |
182
+ | Add package | `yarn add <package>` | `npm install <package>` |
183
+ | Run script | `yarn run <script>` | `npm run <script>` |
184
+ | Remove package | `yarn remove <package>` | `npm uninstall <package>` |
package/README.md ADDED
@@ -0,0 +1,213 @@
1
+ <!-- markdownlint-disable MD030 -->
2
+
3
+ # Agent Studio Embed
4
+
5
+ Javascript library to display the Agent Studio chatbot on your website
6
+
7
+ Install:
8
+
9
+ ```bash
10
+ yarn install --frozen-lockfile
11
+ ```
12
+
13
+ Dev:
14
+
15
+ ```bash
16
+ yarn dev
17
+ ```
18
+
19
+ A development server will be running on http://localhost:5678 automatically. Update `public/index.html` to connect directly to your backend:
20
+
21
+ ```html
22
+ <!-- public/index.html -->
23
+ <script type="module">
24
+ import Chatbot from 'https://localhost:5678/web.js'; // Change to from './web.js' to 'https://localhost:5678/web.js'
25
+ Chatbot.init({
26
+ chatflowid: '91e9c803-5169-4db9-8207-3c0915d71c5f', // Add your chatflowid
27
+ apiHost: 'https://your-backend-instance.com', // Add your apiHost
28
+ });
29
+ </script>
30
+ ```
31
+
32
+ Build:
33
+
34
+ ```bash
35
+ yarn build
36
+ ```
37
+
38
+ ## Embed in your HTML
39
+
40
+ ### PopUp
41
+
42
+ ```html
43
+ <script type="module">
44
+ import Chatbot from 'https://cdn.jsdelivr.net/npm/c-agent-embedding@latest/dist/web.js';
45
+ Chatbot.init({
46
+ chatflowid: '<chatflowid>',
47
+ apiHost: 'http://localhost:3000',
48
+ });
49
+ </script>
50
+ ```
51
+
52
+ ### FullPage
53
+
54
+ ```html
55
+ <script type="module">
56
+ import Chatbot from 'https://cdn.jsdelivr.net/npm/c-agent-embedding@latest/dist/web.js';
57
+ Chatbot.initFull({
58
+ chatflowid: '<chatflowid>',
59
+ apiHost: 'http://localhost:3000',
60
+ });
61
+ </script>
62
+ <cagent-fullchatbot></cagent-fullchatbot>
63
+ ```
64
+
65
+ To enable full screen, add `margin: 0` to <code>body</code> style, and confirm you don't set height and width
66
+
67
+ ```html
68
+ <body style="margin: 0">
69
+ <script type="module">
70
+ import Chatbot from 'https://cdn.jsdelivr.net/npm/c-agent-embedding@latest/dist/web.js';
71
+ Chatbot.initFull({
72
+ chatflowid: '<chatflowid>',
73
+ apiHost: 'http://localhost:3000',
74
+ theme: {
75
+ chatWindow: {
76
+ // height: 700, don't set height
77
+ // width: 400, don't set width
78
+ },
79
+ },
80
+ });
81
+ </script>
82
+ </body>
83
+ ```
84
+
85
+ ## Configuration
86
+
87
+ You can also customize chatbot with different configuration
88
+
89
+ ```html
90
+ <script type="module">
91
+ import Chatbot from 'https://cdn.jsdelivr.net/npm/c-agent-embedding/dist/web.js';
92
+ Chatbot.init({
93
+ chatflowid: '91e9c803-5169-4db9-8207-3c0915d71c5f',
94
+ apiHost: 'http://localhost:3000',
95
+ chatflowConfig: {
96
+ // topK: 2
97
+ },
98
+ theme: {
99
+ disclaimer: {
100
+ title: 'Disclaimer',
101
+ message: 'By using this chatbot, you agree to the <a target="_blank" href="#">Terms & Condition</a>',
102
+ },
103
+ chatWindow: {
104
+ showTitle: true,
105
+ title: 'Agent Studio Bot',
106
+ welcomeMessage: 'Hello! This is custom welcome message',
107
+ textInput: {
108
+ placeholder: 'Type your question',
109
+ sendMessageSound: true,
110
+ receiveMessageSound: true,
111
+ },
112
+ footer: {
113
+ text: 'Powered by',
114
+ company: 'Agent Studio',
115
+ companyLink: '#',
116
+ },
117
+ },
118
+ },
119
+ });
120
+ </script>
121
+ ```
122
+
123
+ ## (Experimental) Proxy Server Setup
124
+
125
+ The proxy server enhances the security of your chatbot implementation by acting as a protective intermediary layer. It removes the need to expose sensitive backend instance details in your frontend code and provides several key security benefits:
126
+
127
+ - **Enhanced Security**: Conceals your API host and chatflow IDs from client-side exposure
128
+ - **Access Control**: Implements strict domain-based restrictions for chatbot embedding
129
+ - **Secure Communication**: Acts as a secure gateway for all interactions between your website and the backend instance
130
+ - **Authentication Management**: Handles API key authentication securely on the server side, away from client exposure
131
+
132
+ This proxy server can be deployed to any Node.js hosting platform.
133
+
134
+ ## Quick Start
135
+
136
+ 1. Configure environment:
137
+
138
+ ```bash
139
+ # Copy .env.example to .env and configure required settings:
140
+ API_HOST=https://your-backend-instance.com
141
+ CAGENT_API_KEY=your-api-key
142
+
143
+ # Configure your chatflows:
144
+ # Format: [identifier]=[chatflowId],[allowedDomain1],[allowedDomain2],...
145
+ #
146
+ # identifier: Any name you choose (e.g., agent1, support, salesbot)
147
+ # chatflowId: The UUID of your chatflow
148
+ # allowedDomains: Comma-separated list of domains where this chat can be embedded
149
+ #
150
+ # Examples:
151
+ support=abc123-def456,https://example.com
152
+ agent1=xyz789-uvw456,https://sales.example.com
153
+ helpdesk=ghi123-jkl456,https://help.example.com,https://support.example.com
154
+ ```
155
+
156
+ 2. Install dependencies: (assuming you did not run `yarn install` yet)
157
+
158
+ ```bash
159
+ yarn install
160
+ ```
161
+
162
+ 3. Start proxy server:
163
+
164
+ ```bash
165
+ yarn start
166
+ # Server will be available at:
167
+ # - Local: http://localhost:3001
168
+ # - Cloud: [Your Platform URL]
169
+ ```
170
+
171
+ 4. Once the proxy server is running in production, you will be able to embed your chatbots safely without exposing your API host and chatflow IDs:
172
+
173
+ ```html
174
+ <script type="module">
175
+ import Chatbot from 'your-proxy-server-url/web.js'; // Must be 'your-proxy-server-url/web.js'
176
+ Chatbot.init({
177
+ chatflowid: 'your-identifier-here', // Must match an identifier from your .env
178
+ apiHost: 'your-proxy-server-url', // Must match the URL of your proxy server
179
+ });
180
+ </script>
181
+ ```
182
+
183
+ **Important Notes:**
184
+
185
+ - To ensure secure embedding, you must explicitly whitelist the websites authorized to embed each chatbot. This configuration is done within the .env file. This also applies to your server's URL when deployed to a cloud environment, or http://localhost:3001 for local development.
186
+ - Wildcard domains (\*) are not supported for security reasons
187
+ - Identifiers are case-insensitive (e.g., 'Support' and 'support' are treated the same)
188
+
189
+ ## Cloud Deployment Requirements
190
+
191
+ When deploying to cloud platforms, you must configure the environment variables directly in your platform. The proxy server will not start without these variables being properly set.
192
+
193
+ ## Development Mode (For Local Testing)
194
+
195
+ For full page testing, use this configuration:
196
+
197
+ ```html
198
+ <!-- public/index.html -->
199
+ <cagent-fullchatbot></cagent-fullchatbot>
200
+ <script type="module">
201
+ import Chatbot from './web.js';
202
+ Chatbot.initFull({
203
+ chatflowid: 'agent1', // Must match an identifier from your .env
204
+ apiHost: 'http://localhost:3001',
205
+ });
206
+ </script>
207
+ ```
208
+
209
+ **Note:** The development URL (http://localhost:5678) is automatically added to allowed domains in development mode.
210
+
211
+ ## License
212
+
213
+ Source code in this repository is made available under the MIT License.
package/base.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "display": "Default",
4
+ "compilerOptions": {
5
+ "composite": false,
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "inlineSources": false,
11
+ "isolatedModules": true,
12
+ "moduleResolution": "node",
13
+ "noUnusedLocals": false,
14
+ "noUnusedParameters": false,
15
+ "preserveWatchOutput": true,
16
+ "skipLibCheck": true,
17
+ "strict": true,
18
+ "downlevelIteration": true
19
+ },
20
+ "exclude": ["node_modules"]
21
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Chat Room API
3
+ * API functions for managing chat rooms and human advisor connections
4
+ */
5
+ import { RoomStatus } from '@/store/constant';
6
+ export interface ApiResponse<T> {
7
+ success: boolean;
8
+ data?: T;
9
+ error?: string;
10
+ }
11
+ export interface RoomInfo {
12
+ roomId: string;
13
+ status: RoomStatus;
14
+ createdAt: string;
15
+ humanAdvisorId?: string;
16
+ humanAdvisorName?: string;
17
+ conversationId?: string;
18
+ }
19
+ export interface MessageInfo {
20
+ id: string;
21
+ content: string;
22
+ sender: 'user' | 'agent' | 'human' | 'system';
23
+ timestamp: string;
24
+ metadata?: Record<string, any>;
25
+ }
26
+ /**
27
+ * Create a new chat room
28
+ */
29
+ export declare const createRoom: (chatflowId: string, chatId: string, apiHost?: string) => Promise<ApiResponse<RoomInfo>>;
30
+ /**
31
+ * Join an existing chat room
32
+ */
33
+ export declare const joinRoom: (roomId: string, userId?: string, apiHost?: string) => Promise<ApiResponse<RoomInfo>>;
34
+ /**
35
+ * Leave a chat room
36
+ */
37
+ export declare const leaveRoom: (roomId: string, userId?: string, apiHost?: string) => Promise<ApiResponse<{
38
+ success: boolean;
39
+ }>>;
40
+ /**
41
+ * Close a chat room (end conversation with human advisor)
42
+ */
43
+ export declare const closeRoom: (roomId: string, apiHost?: string) => Promise<ApiResponse<{
44
+ success: boolean;
45
+ }>>;
46
+ /**
47
+ * Get room status
48
+ */
49
+ export declare const getRoomStatus: (roomId: string, apiHost?: string) => Promise<ApiResponse<RoomInfo>>;
50
+ /**
51
+ * Get messages from a room
52
+ */
53
+ export declare const getRoomMessages: (roomId: string, limit?: number, before?: string, apiHost?: string) => Promise<ApiResponse<MessageInfo[]>>;
54
+ /**
55
+ * Request human advisor support
56
+ */
57
+ export declare const requestHumanAdvisor: (roomId: string, chatflowId: string, userInfo?: {
58
+ name?: string;
59
+ email?: string;
60
+ phone?: string;
61
+ }, apiHost?: string) => Promise<ApiResponse<{
62
+ requestId: string;
63
+ status: string;
64
+ }>>;
65
+ /**
66
+ * Check if room has active human advisor
67
+ */
68
+ export declare const hasActiveHumanAdvisor: (roomInfo: RoomInfo | null) => boolean;
69
+ /**
70
+ * Check if room is waiting for human advisor
71
+ */
72
+ export declare const isWaitingForHuman: (roomInfo: RoomInfo | null) => boolean;
73
+ /**
74
+ * Get stored room ID from localStorage
75
+ */
76
+ export declare const getStoredRoomId: (chatflowId: string) => string | null;
77
+ /**
78
+ * Store room ID to localStorage
79
+ */
80
+ export declare const storeRoomId: (chatflowId: string, roomId: string) => void;
81
+ /**
82
+ * Clear stored room ID from localStorage
83
+ */
84
+ export declare const clearStoredRoomId: (chatflowId: string) => void;
@@ -0,0 +1,2 @@
1
+ export declare const defaultSendSound = "data:audio/wav;base64,UklGRqQHAABXQVZFZm10IBAAAAABAAEAQB8AAIA+AAACABAAZGF0YYAHAAAAAF0ALgHNAZgBVwBw/rv8Fvzx/Aj/egE8A5oDlwLnAIb/Kv/S/8EA6QCS/+78NPof+RD7KgDvBqYMbg6iCs8B1Pbm7ejqqu/6+uAIIBRPGLITAgi7+U7u2emM7Un3twJFCyIOUAtXBcb/Uf12/lQB3QKqAJj6OfPI7g3xK/t9CjYZpSA7HPEL2/SE35PUJdlr7KsHwiAsLt4qUhjj/bnlm9h92irpov1iDyMYUBYmDaACOPwm/HUAYQQ5A1X7ee/k5UrlKfFTBwAgrTCtMGYdOPz42HbBxr/T1Sv8qyQXQDJE3i9vCx7lJssUxq3Vs/HzDX0fwCGDF4IIFP3z+Tf+XQS8BZj+qPC24mjdr+Yi/iscrjQjPPsstAow4T3ANLVLxSzr2Rg5PelKhD0nG6jxu9Chw/7Mh+ZuBM4aqiJBHPMNaQAP+hf8WwIhBjICKvY659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cD+9L+gwFiAsEBlwDi/xsADAEGAlgCtwFmAAn/QP5R/gH/wP8=";
@@ -0,0 +1,9 @@
1
+ import { FooterTheme } from '@/features/bubble/types';
2
+ type Props = {
3
+ footer?: FooterTheme;
4
+ botContainer: HTMLDivElement | undefined;
5
+ poweredByTextColor?: string;
6
+ badgeBackgroundColor?: string;
7
+ };
8
+ export declare const Badge: (props: Props) => import("solid-js").JSX.Element;
9
+ export {};