@aomi-labs/widget-lib 0.2.0 โ†’ 1.0.0

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/README.md CHANGED
@@ -1,310 +1,41 @@
1
- # @aomi-labs/widget-lib
1
+ AI assistant + onchain widget library and demo landing page for `@aomi-labs/widget-lib`.
2
2
 
3
- Embeddable AI chat widget with Web3 capabilities for any website.
4
-
5
- ## ๐Ÿš€ Quick Start
6
-
7
- ### Installation
3
+ ## Library usage
8
4
 
9
5
  ```bash
10
- npm install @aomi-labs/widget-lib
11
- ```
12
-
13
- ### Basic Usage
14
-
15
- ```typescript
16
- import { createChatWidget } from '@aomi-labs/widget-lib';
17
-
18
- const widget = createChatWidget('chat-container', {
19
- appCode: 'my-dapp',
20
- theme: 'terminal',
21
- provider: window.ethereum
22
- });
23
- ```
24
-
25
- ### Advanced Usage
26
-
27
- ```typescript
28
- import { createAomiChatWidget } from '@aomi-labs/widget-lib';
29
-
30
- const widget = createAomiChatWidget(container, {
31
- params: {
32
- appCode: 'my-advanced-dapp',
33
- theme: {
34
- baseTheme: 'dark',
35
- primary: '#00ff88',
36
- background: '#0a0a0a'
37
- },
38
- width: '500px',
39
- height: '700px',
40
- enableTransactions: true,
41
- chainId: 1
42
- },
43
- provider: window.ethereum,
44
- listeners: {
45
- onReady: () => console.log('Widget ready!'),
46
- onMessage: (msg) => console.log('New message:', msg),
47
- onTransactionRequest: (tx) => console.log('Transaction:', tx)
48
- }
49
- });
6
+ pnpm install @aomi-labs/widget-lib
50
7
  ```
51
8
 
52
- ## ๐Ÿ“š Documentation
53
-
54
- ### Configuration Options
55
-
56
- ```typescript
57
- interface AomiChatWidgetParams {
58
- // Required
59
- appCode: string;
60
-
61
- // Appearance
62
- theme?: 'light' | 'dark' | 'terminal' | 'neon' | 'minimal' | CustomTheme;
63
- width?: string;
64
- height?: string;
65
- mode?: 'full' | 'minimal' | 'compact' | 'terminal';
66
-
67
- // Behavior
68
- welcomeMessage?: string;
69
- placeholder?: string;
70
- enableTransactions?: boolean;
71
- requireWalletConnection?: boolean;
9
+ Drop the frame into your app:
72
10
 
73
- // Network
74
- chainId?: SupportedChainId;
75
- supportedChains?: SupportedChainId[];
11
+ ```tsx
12
+ import { AomiFrame } from "@aomi-labs/widget-lib";
76
13
 
77
- // Integration
78
- baseUrl?: string;
79
- apiKey?: string;
80
- sessionId?: string;
14
+ export function Assistant() {
15
+ return (
16
+ <AomiFrame height="640px" width="100%">
17
+ {/* optional slots like WalletSystemMessenger */}
18
+ </AomiFrame>
19
+ );
81
20
  }
82
21
  ```
83
22
 
84
- ### Event Handling
85
-
86
- ```typescript
87
- widget.on('ready', () => {
88
- console.log('Widget is ready');
89
- });
90
-
91
- widget.on('message', (message) => {
92
- console.log('New message:', message.content);
93
- });
94
-
95
- widget.on('transactionRequest', async (tx) => {
96
- // Handle transaction request
97
- console.log('Transaction requested:', tx);
98
- });
99
-
100
- widget.on('walletConnect', (address) => {
101
- console.log('Wallet connected:', address);
102
- });
103
-
104
- widget.on('error', (error) => {
105
- console.error('Widget error:', error);
106
- });
107
- ```
108
-
109
- ### Widget Methods
110
-
111
- ```typescript
112
- // Send a message
113
- await widget.sendMessage('Hello AI!');
114
-
115
- // Update configuration
116
- widget.updateParams({
117
- theme: 'light',
118
- enableTransactions: false
119
- });
120
-
121
- // Clear chat history
122
- widget.clearChat();
123
-
124
- // Export chat messages
125
- const messages = widget.exportChat();
126
-
127
- // Resize widget
128
- widget.resize('600px', '800px');
129
-
130
- // Destroy widget
131
- widget.destroy();
132
- ```
133
-
134
- ## ๐ŸŽจ Themes
135
-
136
- ### Predefined Themes
137
-
138
- - `light` - Clean light theme
139
- - `dark` - Modern dark theme
140
- - `terminal` - Green terminal style
141
- - `neon` - Cyberpunk neon theme
142
- - `minimal` - Clean minimal design
143
-
144
- ### Custom Themes
145
-
146
- ```typescript
147
- const customTheme = {
148
- baseTheme: 'dark',
149
- primary: '#ff6b35',
150
- background: '#1a1a1a',
151
- surface: '#2d2d2d',
152
- text: '#ffffff',
153
- textSecondary: '#cccccc',
154
- border: '#404040',
155
- success: '#00d26a',
156
- error: '#ff4757',
157
- warning: '#ffa500',
158
- accent: '#8b5cf6'
159
- };
160
-
161
- widget.updateParams({ theme: customTheme });
162
- ```
163
-
164
- ## ๐ŸŒ Network Support
165
-
166
- Supported networks:
167
- - Ethereum Mainnet (1)
168
- - Goerli Testnet (5)
169
- - Sepolia Testnet (11155111)
170
- - Gnosis Chain (100)
171
- - Polygon (137)
172
- - Arbitrum One (42161)
173
- - Base (8453)
174
- - Optimism (10)
175
-
176
- ## ๐Ÿ”ง Advanced Features
177
-
178
- ### Flexible Configuration
179
-
180
- Configure different settings per network or mode:
181
-
182
- ```typescript
183
- const config = {
184
- appCode: 'my-app',
185
- // Different settings per network
186
- enableTransactions: {
187
- 1: true, // Mainnet: enabled
188
- 5: false, // Goerli: disabled
189
- 100: true // Gnosis: enabled
190
- },
191
- // Different settings per mode
192
- welcomeMessage: {
193
- full: 'Welcome to our full chat experience!',
194
- minimal: 'Hi there!',
195
- compact: 'Hello!'
196
- }
197
- };
198
- ```
199
-
200
- ### Custom Commands
201
-
202
- ```typescript
203
- const widget = createAomiChatWidget(container, {
204
- params: {
205
- appCode: 'my-app',
206
- customCommands: [
207
- {
208
- command: 'balance',
209
- description: 'Check wallet balance',
210
- handler: async (args) => {
211
- // Custom command logic
212
- }
213
- }
214
- ]
215
- }
216
- });
217
- ```
218
-
219
- ### Rate Limiting
220
-
221
- ```typescript
222
- const config = {
223
- appCode: 'my-app',
224
- rateLimiting: {
225
- maxMessages: 10,
226
- windowMs: 60000, // 1 minute
227
- skipWhenConnected: true
228
- }
229
- };
230
- ```
231
-
232
- ## ๐Ÿงช Development
233
-
234
- ### Building
23
+ ## Develop this repo
235
24
 
236
25
  ```bash
237
- npm run build
26
+ pnpm install
27
+ pnpm run build:lib # build the published bundle
28
+ pnpm --filter example dev # run the landing/demo (http://localhost:3000)
29
+ pnpm run dev:example:live # watch the library and run the example together
30
+ pnpm lint # lint library + example source
238
31
  ```
239
32
 
240
- ### Testing
241
-
242
- ```bash
243
- npm test
244
- ```
33
+ The example app lives in `example/` and imports the built library. Re-run `pnpm run build:lib` after changing code in `src/`.
245
34
 
246
- ### Development Server
35
+ ## Env
247
36
 
248
- ```bash
249
- npm run dev
37
+ Create `.env` with your Web3 Project ID from https://docs.reown.com/ and URL endpoint of your backend:
250
38
  ```
251
-
252
- ## ๐Ÿ“ฆ Package Exports
253
-
254
- ```typescript
255
- // Main factory functions
256
- import { createChatWidget, createAomiChatWidget } from '@aomi-labs/widget-lib';
257
-
258
- // Core managers
259
- import { ChatManager, ThemeManager, WalletManager } from '@aomi-labs/widget-lib';
260
-
261
- // Types
262
- import type {
263
- AomiChatWidgetParams,
264
- AomiChatWidgetHandler,
265
- ChatMessage,
266
- WalletTransaction
267
- } from '@aomi-labs/widget-lib';
268
-
269
- // Constants
270
- import {
271
- SUPPORTED_CHAINS,
272
- PREDEFINED_THEMES,
273
- ERROR_CODES
274
- } from '@aomi-labs/widget-lib';
275
-
276
- // Utilities
277
- import {
278
- validateWidgetParams,
279
- generateSessionId,
280
- formatTimestamp
281
- } from '@aomi-labs/widget-lib';
39
+ NEXT_PUBLIC_PROJECT_ID=000000000000000000000000
40
+ NEXT_PUBLIC_BACKEND_URL=http://example.app.com
282
41
  ```
283
-
284
- ## ๐Ÿ”— Related Packages
285
-
286
- - `@aomi-labs/widget-react` - React wrapper component
287
- - `@aomi-labs/widget-vue` - Vue.js wrapper component
288
- - `@aomi-labs/widget-themes` - Additional theme packs
289
-
290
- ## ๐Ÿ“„ License
291
-
292
- MIT License - see LICENSE file for details.
293
-
294
- ## ๐Ÿค Contributing
295
-
296
- 1. Fork the repository
297
- 2. Create a feature branch
298
- 3. Make your changes
299
- 4. Add tests
300
- 5. Submit a pull request
301
-
302
- ## ๐Ÿ“ž Support
303
-
304
- - Documentation: [docs.aomi.ai/widget](https://docs.aomi.ai/widget)
305
- - Issues: [GitHub Issues](https://github.com/aomi-labs/widget-lib/issues)
306
- - Discord: [Aomi Labs Community](https://discord.gg/aomi)
307
-
308
- ---
309
-
310
- Built with โค๏ธ by [Aomi Labs](https://aomi.ai)