agent-embed-widget 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thesys Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,188 @@
1
+ # Agent Embed Widget
2
+
3
+ A JavaScript library for embedding c1 agent widgets into your application. Works with vanilla JavaScript, TypeScript, and any framework.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install agent-embed-widget
9
+ # or
10
+ yarn add agent-embed-widget
11
+ # or
12
+ pnpm add agent-embed-widget
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### ES Module (Named Import)
18
+
19
+ ```typescript
20
+ import { embedWidget } from 'agent-embed-widget';
21
+ import 'agent-embed-widget/dist/agent-embed-widget.css';
22
+
23
+ const widget = embedWidget({
24
+ type: 'tray', // or 'full-screen'
25
+ url: 'https://console.thesys.dev/your-published-agent-url.com',
26
+ theme: 'dark' // or 'light'
27
+ });
28
+
29
+ // Control the widget programmatically
30
+ widget.open();
31
+ widget.close();
32
+ widget.destroy();
33
+ ```
34
+
35
+ ### CommonJS
36
+
37
+ ```javascript
38
+ const { embedWidget } = require('agent-embed-widget');
39
+ require('agent-embed-widget/dist/agent-embed-widget.css');
40
+
41
+ const widget = embedWidget({
42
+ type: 'tray',
43
+ url: 'https://console.thesys.dev/app/your-app-id',
44
+ theme: 'dark'
45
+ });
46
+ ```
47
+
48
+ ### UMD (Browser)
49
+
50
+ ```html
51
+ <link rel="stylesheet" href="node_modules/agent-embed-widget/dist/agent-embed-widget.css">
52
+ <script src="node_modules/agent-embed-widget/dist/agent-embed-widget.umd.js"></script>
53
+
54
+ <script>
55
+ const { embedWidget } = window.AgentEmbedWidget;
56
+
57
+ const widget = embedWidget({
58
+ type: 'tray',
59
+ url: 'https://console.thesys.dev/app/your-app-id',
60
+ theme: 'dark'
61
+ });
62
+ </script>
63
+ ```
64
+
65
+ ### CDN Usage
66
+
67
+ ```html
68
+ <link rel="stylesheet" href="https://unpkg.com/agent-embed-widget/dist/agent-embed-widget.css">
69
+ <script src="https://unpkg.com/agent-embed-widget/dist/agent-embed-widget.umd.js"></script>
70
+
71
+ <script>
72
+ const { embedWidget } = window.AgentEmbedWidget;
73
+
74
+ const widget = embedWidget({
75
+ type: 'full-screen',
76
+ url: 'https://console.thesys.dev/app/your-app-id',
77
+ theme: 'light'
78
+ });
79
+ </script>
80
+ ```
81
+
82
+ ## API Reference
83
+
84
+ ### `embedWidget(options)`
85
+
86
+ Creates and embeds a widget into your application.
87
+
88
+ #### Options
89
+
90
+ - `type` (optional): `'tray'` | `'full-screen'` - Widget display type. Default: `'tray'`
91
+ - `'tray'`: A compact widget that appears in the bottom-right corner
92
+ - `'full-screen'`: A widget that covers the entire screen when opened
93
+ - `url` (required): `string` - The URL of the playground to embed
94
+ - `theme` (optional): `'dark'` | `'light'` - Widget theme. Default: `'dark'`
95
+
96
+ #### Returns
97
+
98
+ A `WidgetInstance` object with the following methods:
99
+
100
+ - `open()`: Opens/shows the widget
101
+ - `close()`: Closes/hides the widget
102
+ - `destroy()`: Removes the widget from the DOM and cleans up resources
103
+
104
+ #### Example
105
+
106
+ ```typescript
107
+ const widget = embedWidget({
108
+ type: 'tray',
109
+ url: 'https://console.thesys.dev/app/your-app-id',
110
+ theme: 'dark'
111
+ });
112
+
113
+ // Open the widget after 2 seconds
114
+ setTimeout(() => widget.open(), 2000);
115
+
116
+ // Close it after 5 seconds
117
+ setTimeout(() => widget.close(), 5000);
118
+
119
+ // Clean up when done
120
+ // widget.destroy();
121
+ ```
122
+
123
+ ## TypeScript Support
124
+
125
+ This package includes TypeScript declarations out of the box. No additional setup required!
126
+
127
+ ```typescript
128
+ import { embedWidget } from 'agent-embed-widget';
129
+ import type { EmbedWidgetOptions, WidgetInstance } from 'agent-embed-widget';
130
+
131
+ // TypeScript will automatically provide type checking and IntelliSense
132
+ const widget: WidgetInstance = embedWidget({
133
+ type: 'tray',
134
+ url: 'https://console.thesys.dev/app/your-app-id',
135
+ theme: 'dark'
136
+ });
137
+ ```
138
+
139
+ ## Development
140
+
141
+ ### Setup
142
+
143
+ ```bash
144
+ pnpm install
145
+ ```
146
+
147
+ ### Development Server
148
+
149
+ ```bash
150
+ pnpm run dev
151
+ ```
152
+
153
+ ### Build
154
+
155
+ ```bash
156
+ pnpm run build
157
+ ```
158
+
159
+ This will generate:
160
+ - `dist/agent-embed-widget.es.js` - ES module build
161
+ - `dist/agent-embed-widget.umd.js` - UMD build for browser
162
+ - `dist/agent-embed-widget.css` - Styles
163
+ - `dist/index.d.ts` - TypeScript declarations
164
+
165
+ ### Lint
166
+
167
+ ```bash
168
+ pnpm run lint
169
+ ```
170
+
171
+ ## Publishing
172
+
173
+ Before publishing to npm, make sure to:
174
+
175
+ 1. Update the version in `package.json`
176
+ 2. Update the repository URL in `package.json`
177
+ 3. Update the author field in `package.json`
178
+ 4. Build the package: `pnpm run build`
179
+ 5. Publish: `npm publish`
180
+
181
+ ## License
182
+
183
+ MIT
184
+
185
+ ## Peer Dependencies
186
+
187
+ - React 18.0.0+ or 19.0.0+
188
+ - React DOM 18.0.0+ or 19.0.0+