@mcp-b/embedded-agent 1.2.5-beta.0 → 1.2.6
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/LICENSE +23 -0
- package/README.md +212 -43
- package/dist/jsx.d.ts +45 -0
- package/dist/styles/globals.css +2 -2
- package/dist/styles.d.ts +2 -0
- package/dist/web-component-standalone.css +37 -0
- package/dist/web-component-standalone.css.map +1 -0
- package/dist/web-component-standalone.iife.js +118570 -145
- package/dist/web-component-standalone.iife.js.map +1 -0
- package/dist/web-component.d.ts +38 -59
- package/dist/web-component.d.ts.map +1 -1
- package/dist/web-component.js +10437 -8737
- package/dist/web-component.js.map +1 -1
- package/package.json +128 -105
- package/dist/index.d.ts +0 -136
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -9441
- package/dist/index.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Kukumis Inc. Proprietary License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kukumis Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software, including all source code, object code, documentation, and any
|
|
6
|
+
related materials (collectively, the "Software"), is proprietary to Kukumis
|
|
7
|
+
Inc. and is protected by applicable intellectual property laws.
|
|
8
|
+
|
|
9
|
+
No part of the Software may be used, copied, modified, merged, published,
|
|
10
|
+
distributed, sublicensed, and/or sold, in whole or in part, except as expressly
|
|
11
|
+
authorized in a written license agreement signed by Kukumis Inc.
|
|
12
|
+
|
|
13
|
+
No license or other rights are granted by Kukumis Inc. under any patents,
|
|
14
|
+
copyrights, trade secrets, trademarks, or other intellectual property rights,
|
|
15
|
+
whether by implication, estoppel, or otherwise, except as expressly set forth
|
|
16
|
+
in such written license agreement.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
21
|
+
KUKUMIS INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
22
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,89 +2,258 @@
|
|
|
2
2
|
|
|
3
3
|
An Intercom-like AI chat widget with MCP tool support and voice mode. Drop it into your app and you're done.
|
|
4
4
|
|
|
5
|
+
Styles are isolated using Shadow DOM. Customize appearance by setting CSS variables on the host page.
|
|
6
|
+
|
|
7
|
+
## Build Architecture
|
|
8
|
+
|
|
9
|
+
This package provides the `<webmcp-agent>` custom element in two formats:
|
|
10
|
+
|
|
11
|
+
| Export | Format | Use Case |
|
|
12
|
+
|--------|--------|----------|
|
|
13
|
+
| `@mcp-b/embedded-agent` / `@mcp-b/embedded-agent/web-component` | ESM web component | Bundlers, monorepo dev |
|
|
14
|
+
| `@mcp-b/embedded-agent/standalone` | IIFE web component | `<script>` tag embeds |
|
|
15
|
+
|
|
16
|
+
### Why Two Builds?
|
|
17
|
+
|
|
18
|
+
**ESM Build** (root export or `/web-component`)
|
|
19
|
+
- Web component entrypoint for bundlers
|
|
20
|
+
- React is externalized via `peerDependencies` (install `react` and `react-dom`)
|
|
21
|
+
- Smaller bundle; no duplicate React if the host already uses it
|
|
22
|
+
- Uses Shadow DOM for style isolation
|
|
23
|
+
- Use for: bundlers, monorepo consumers
|
|
24
|
+
|
|
25
|
+
**Standalone IIFE Build** (`/standalone`)
|
|
26
|
+
- Web component via `<script>` tag
|
|
27
|
+
- React is bundled inside the package
|
|
28
|
+
- Uses Shadow DOM for complete JS/CSS isolation
|
|
29
|
+
- Separate React instances in separate DOM trees = no conflict
|
|
30
|
+
- Use for: `<script>` tag embedding on any website (React or not)
|
|
31
|
+
|
|
32
|
+
### The "Two Reacts" Problem
|
|
33
|
+
|
|
34
|
+
When a React app loads the standalone bundle, you get duplicate React instances which causes the infamous "hooks can only be called inside a function component" error.
|
|
35
|
+
|
|
36
|
+
**Shadow DOM solves this**: Each React instance manages its own separate DOM tree inside the shadow boundary, so they never conflict.
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
Host Page (React 18)
|
|
40
|
+
├── <div id="root"> ← Host's React
|
|
41
|
+
│ └── ... host app ...
|
|
42
|
+
│
|
|
43
|
+
└── <webmcp-agent>
|
|
44
|
+
└── #shadow-root ← Isolation boundary
|
|
45
|
+
└── <div> ← Bundled React 19
|
|
46
|
+
└── ... widget ...
|
|
47
|
+
```
|
|
48
|
+
|
|
5
49
|
## Installation
|
|
6
50
|
|
|
7
51
|
```bash
|
|
8
52
|
npm install @mcp-b/embedded-agent
|
|
9
53
|
```
|
|
10
54
|
|
|
11
|
-
##
|
|
55
|
+
## Usage
|
|
12
56
|
|
|
13
|
-
|
|
57
|
+
`<webmcp-agent>` renders as a full-viewport overlay.
|
|
14
58
|
|
|
15
|
-
|
|
16
|
-
import { EmbeddedAgent } from '@mcp-b/embedded-agent'
|
|
59
|
+
### Web Component (ESM)
|
|
17
60
|
|
|
18
|
-
|
|
61
|
+
```tsx
|
|
62
|
+
import "@mcp-b/embedded-agent/web-component";
|
|
19
63
|
|
|
20
64
|
function App() {
|
|
21
|
-
|
|
65
|
+
return <webmcp-agent auth-token="eyJhbGciOi..." />;
|
|
22
66
|
}
|
|
23
67
|
```
|
|
24
68
|
|
|
25
|
-
###
|
|
69
|
+
### Monorepo Dogfooding
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import "@mcp-b/embedded-agent/web-component";
|
|
73
|
+
|
|
74
|
+
// authToken from your existing IDP session
|
|
75
|
+
const authToken = session?.idToken ?? "";
|
|
76
|
+
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const agent =
|
|
79
|
+
document.querySelector("webmcp-agent") ?? document.createElement("webmcp-agent");
|
|
80
|
+
|
|
81
|
+
if (!agent.isConnected) {
|
|
82
|
+
document.body.appendChild(agent);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
agent.setAttribute("auth-token", authToken ?? "");
|
|
86
|
+
agent.setAttribute("dev-mode", JSON.stringify({ useLocalApi: true }));
|
|
87
|
+
agent.setAttribute("enable-debug-tools", String(import.meta.env.DEV));
|
|
88
|
+
}, [authToken]);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Script Tag (Any Website)
|
|
26
92
|
|
|
27
93
|
```html
|
|
28
94
|
<script src="https://cdn.webmcp.ai/agent.js"></script>
|
|
29
|
-
<webmcp-agent
|
|
95
|
+
<webmcp-agent auth-token="eyJhbGciOi..."></webmcp-agent>
|
|
30
96
|
```
|
|
31
97
|
|
|
32
|
-
|
|
98
|
+
### Web Component Attributes
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<webmcp-agent
|
|
102
|
+
auth-token="eyJhbGciOi..."
|
|
103
|
+
dev-mode='{"anthropicApiKey": "sk-ant-..."}'
|
|
104
|
+
enable-debug-tools="true"
|
|
105
|
+
></webmcp-agent>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Props / Attributes
|
|
109
|
+
|
|
110
|
+
| Prop | Attribute | Type | Description |
|
|
111
|
+
|------|-----------|------|-------------|
|
|
112
|
+
| `authToken` | `auth-token` | string | IDP token for stateful sessions (optional; omit for stateless) |
|
|
113
|
+
| `open` | `open` | boolean | Controlled open state (optional) |
|
|
114
|
+
| `devMode` | `dev-mode` | object/JSON | Development mode config (optional) |
|
|
115
|
+
| `enableDebugTools` | `enable-debug-tools` | boolean | Enable debug tools (default: false) |
|
|
116
|
+
|
|
117
|
+
## Customization
|
|
118
|
+
|
|
119
|
+
Customize appearance by setting CSS variables on the host page:
|
|
120
|
+
|
|
121
|
+
```css
|
|
122
|
+
webmcp-agent {
|
|
123
|
+
/* Brand colors */
|
|
124
|
+
--wm-color-primary: #8b5cf6;
|
|
125
|
+
--wm-color-primary-foreground: #ffffff;
|
|
126
|
+
|
|
127
|
+
/* Layout */
|
|
128
|
+
--wm-radius: 12px;
|
|
129
|
+
--wm-font-sans: 'Inter', sans-serif;
|
|
130
|
+
|
|
131
|
+
/* Backgrounds */
|
|
132
|
+
--wm-color-background: #ffffff;
|
|
133
|
+
--wm-color-foreground: #1a1a1a;
|
|
134
|
+
--wm-color-muted: #f5f5f5;
|
|
135
|
+
|
|
136
|
+
/* Messages */
|
|
137
|
+
--wm-user-bubble-bg: #8b5cf6;
|
|
138
|
+
--wm-user-bubble-text: #ffffff;
|
|
139
|
+
--wm-assistant-bubble-bg: #f5f5f5;
|
|
140
|
+
--wm-assistant-bubble-text: #1a1a1a;
|
|
141
|
+
|
|
142
|
+
/* Composer */
|
|
143
|
+
--wm-composer-bg: #ffffff;
|
|
144
|
+
--wm-composer-border: #e5e5e5;
|
|
145
|
+
--wm-composer-button-bg: #8b5cf6;
|
|
146
|
+
|
|
147
|
+
/* Tools */
|
|
148
|
+
--wm-tool-bg: #f9fafb;
|
|
149
|
+
--wm-tool-border: #e5e7eb;
|
|
150
|
+
--wm-tool-approve-bg: #10b981;
|
|
151
|
+
--wm-tool-deny-bg: #ef4444;
|
|
152
|
+
|
|
153
|
+
/* Code blocks */
|
|
154
|
+
--wm-code-bg: #1e1e1e;
|
|
155
|
+
--wm-code-text: #d4d4d4;
|
|
156
|
+
|
|
157
|
+
/* Font sizes */
|
|
158
|
+
--wm-font-size-xs: 0.75rem;
|
|
159
|
+
--wm-font-size-sm: 0.875rem;
|
|
160
|
+
--wm-font-size-base: 1rem;
|
|
161
|
+
--wm-font-size-lg: 1.125rem;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* Dark mode */
|
|
165
|
+
webmcp-agent.dark {
|
|
166
|
+
--wm-color-background: #1a1a1a;
|
|
167
|
+
--wm-color-foreground: #ffffff;
|
|
168
|
+
--wm-color-muted: #2a2a2a;
|
|
169
|
+
/* ... other dark mode overrides */
|
|
170
|
+
}
|
|
171
|
+
```
|
|
33
172
|
|
|
34
173
|
## Development Mode
|
|
35
174
|
|
|
36
|
-
|
|
175
|
+
Use your own API keys during development (stateless):
|
|
37
176
|
|
|
38
|
-
```
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
anthropicApiKey: 'sk-ant-...', // Required for chat
|
|
43
|
-
openaiApiKey: 'sk-...', // Optional, enables voice mode
|
|
44
|
-
}}
|
|
45
|
-
/>
|
|
177
|
+
```html
|
|
178
|
+
<webmcp-agent
|
|
179
|
+
dev-mode='{"anthropicApiKey":"sk-ant-...","openaiApiKey":"sk-...","useLocalApi":true}'
|
|
180
|
+
></webmcp-agent>
|
|
46
181
|
```
|
|
47
182
|
|
|
48
|
-
|
|
183
|
+
**Development modes:**
|
|
184
|
+
- `anthropicApiKey`: Use your own Anthropic API key (falls back to Gemini if not provided)
|
|
185
|
+
- `openaiApiKey`: Enable voice mode with your OpenAI key
|
|
186
|
+
- `useLocalApi`: Point to localhost instead of production API
|
|
187
|
+
|
|
188
|
+
Common combinations:
|
|
189
|
+
- `{ useLocalApi: true }` - Internal monorepo development
|
|
190
|
+
- `{ anthropicApiKey: "sk-ant-..." }` - External dev with your own key
|
|
191
|
+
- `{ anthropicApiKey: "...", openaiApiKey: "...", useLocalApi: true }` - Full stack local dev
|
|
49
192
|
|
|
50
193
|
## Features
|
|
51
194
|
|
|
52
195
|
- **MCP Tool Support** - Connect to any MCP server
|
|
53
|
-
- **Voice Mode** - Talk to your AI assistant
|
|
54
|
-
- **Action-First UI** - Shows what the AI is doing
|
|
55
|
-
- **
|
|
196
|
+
- **Voice Mode** - Talk to your AI assistant
|
|
197
|
+
- **Action-First UI** - Shows what the AI is doing
|
|
198
|
+
- **Shadow DOM Isolation** - Styles don't leak in or out
|
|
199
|
+
- **Stateful Sessions** - Messages persist across page refreshes (when authToken is provided)
|
|
200
|
+
- **CSS Variable Theming** - Customize appearance without JavaScript
|
|
56
201
|
|
|
57
|
-
##
|
|
202
|
+
## Migration Guide
|
|
58
203
|
|
|
59
|
-
###
|
|
204
|
+
### Upgrading from Previous Versions
|
|
60
205
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
206
|
+
**Removed props:**
|
|
207
|
+
- `apiKey` / `userId` - Replaced by `authToken` (use your existing IDP token)
|
|
208
|
+
- `appId` - No longer needed (removed dead code)
|
|
209
|
+
- `siteId` - Org-level routing in SSO-first mode (no site scoping)
|
|
210
|
+
- `theme` - Use CSS variables instead (see Customization section)
|
|
211
|
+
- `isolateStyles` - Always enabled (Shadow DOM is always used)
|
|
212
|
+
- `disableShadowDOM` - Deprecated (Shadow DOM is always enabled)
|
|
65
213
|
|
|
66
|
-
|
|
214
|
+
**Migration examples:**
|
|
67
215
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
216
|
+
```html
|
|
217
|
+
<!-- OLD: -->
|
|
218
|
+
<webmcp-agent
|
|
219
|
+
app-id="app_123"
|
|
220
|
+
site-id="site_123"
|
|
221
|
+
api-key="sk_live_xxx"
|
|
222
|
+
theme='{"primaryColor":"#ff0000","mode":"dark"}'
|
|
223
|
+
isolate-styles="false"
|
|
224
|
+
></webmcp-agent>
|
|
72
225
|
|
|
73
|
-
|
|
226
|
+
<!-- NEW (SSO-first): -->
|
|
227
|
+
<webmcp-agent auth-token="eyJhbGciOi..."></webmcp-agent>
|
|
74
228
|
|
|
75
|
-
|
|
229
|
+
<!-- NEW (stateless): -->
|
|
230
|
+
<webmcp-agent></webmcp-agent>
|
|
76
231
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
-
|
|
232
|
+
<!-- Customize via CSS: -->
|
|
233
|
+
<style>
|
|
234
|
+
webmcp-agent {
|
|
235
|
+
--wm-color-primary: #ff0000;
|
|
236
|
+
}
|
|
237
|
+
webmcp-agent.dark {
|
|
238
|
+
--wm-color-background: #1a1a1a;
|
|
239
|
+
}
|
|
240
|
+
</style>
|
|
241
|
+
```
|
|
80
242
|
|
|
81
|
-
|
|
243
|
+
**Benefits:**
|
|
244
|
+
- Smaller bundle size (~200 lines removed)
|
|
245
|
+
- Simpler API (fewer required attributes)
|
|
246
|
+
- More flexible styling (CSS variables work everywhere)
|
|
247
|
+
- Consistent Shadow DOM isolation (no edge cases)
|
|
248
|
+
- No API keys to manage (uses existing IDP tokens)
|
|
82
249
|
|
|
83
250
|
## Development
|
|
84
251
|
|
|
85
252
|
```bash
|
|
86
|
-
pnpm
|
|
87
|
-
pnpm
|
|
88
|
-
pnpm
|
|
89
|
-
pnpm
|
|
253
|
+
pnpm --filter @mcp-b/embedded-agent dev # Watch TS build
|
|
254
|
+
pnpm --filter @mcp-b/embedded-agent dev:css # Watch Tailwind CSS
|
|
255
|
+
pnpm --filter @mcp-b/embedded-agent storybook # http://localhost:6006
|
|
256
|
+
pnpm --filter @mcp-b/embedded-agent build
|
|
257
|
+
pnpm --filter @mcp-b/embedded-agent check:types
|
|
258
|
+
pnpm --filter @mcp-b/embedded-agent test
|
|
90
259
|
```
|
package/dist/jsx.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript JSX type declarations for the webmcp-agent custom element.
|
|
3
|
+
*
|
|
4
|
+
* This file provides proper typing for the <webmcp-agent> custom element
|
|
5
|
+
* when used in React/TypeScript projects.
|
|
6
|
+
*
|
|
7
|
+
* @see https://www.totaltypescript.com/workshops/advanced-typescript-patterns/advanced-challenges/custom-jsx-elements
|
|
8
|
+
* @see https://www.typescriptlang.org/docs/handbook/jsx.html
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import 'react';
|
|
12
|
+
|
|
13
|
+
declare module 'react' {
|
|
14
|
+
namespace JSX {
|
|
15
|
+
interface IntrinsicElements {
|
|
16
|
+
'webmcp-agent': React.DetailedHTMLProps<
|
|
17
|
+
React.HTMLAttributes<HTMLElement> & {
|
|
18
|
+
/**
|
|
19
|
+
* IDP token for SSO-First authentication.
|
|
20
|
+
* When provided, the agent will authenticate the user and persist threads to the backend.
|
|
21
|
+
* When omitted, the agent runs in stateless mode (memory-only).
|
|
22
|
+
*/
|
|
23
|
+
'auth-token'?: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Whether the agent panel should be open by default.
|
|
27
|
+
*/
|
|
28
|
+
open?: boolean;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Development mode configuration (JSON string).
|
|
32
|
+
* Example: JSON.stringify({ useLocalApi: true })
|
|
33
|
+
*/
|
|
34
|
+
'dev-mode'?: string;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Enable debug tools panel for development.
|
|
38
|
+
*/
|
|
39
|
+
'enable-debug-tools'?: boolean;
|
|
40
|
+
},
|
|
41
|
+
HTMLElement
|
|
42
|
+
>;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|