@asgard-js/core 0.1.9-canary.3 → 0.1.9-canary.4

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
@@ -19,8 +19,7 @@ import { AsgardServiceClient } from '@asgard-js/core';
19
19
 
20
20
  const client = new AsgardServiceClient({
21
21
  apiKey: 'your-api-key',
22
- botProviderEndpoint:
23
- 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
22
+ botProviderEndpoint: 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
24
23
  debugMode: true, // Enable to see deprecation warnings
25
24
  });
26
25
 
@@ -35,19 +34,19 @@ client.fetchSse({
35
34
  if (client.uploadFile) {
36
35
  const fileInput = document.querySelector('input[type="file"]');
37
36
  const file = fileInput.files[0];
38
-
37
+
39
38
  try {
40
39
  const uploadResponse = await client.uploadFile(file, 'your-channel-id');
41
-
40
+
42
41
  if (uploadResponse.isSuccess && uploadResponse.data[0]) {
43
42
  const blobId = uploadResponse.data[0].blobId;
44
-
43
+
45
44
  // Send message with uploaded file
46
45
  client.fetchSse({
47
46
  customChannelId: 'your-channel-id',
48
47
  text: 'Here is my image:',
49
48
  action: 'message',
50
- blobIds: [blobId]
49
+ blobIds: [blobId],
51
50
  });
52
51
  }
53
52
  } catch (error) {
@@ -56,15 +55,15 @@ if (client.uploadFile) {
56
55
  }
57
56
 
58
57
  // Listen to events
59
- client.on('MESSAGE', (response) => {
58
+ client.on('MESSAGE', response => {
60
59
  console.log('Received message:', response);
61
60
  });
62
61
 
63
- client.on('DONE', (response) => {
62
+ client.on('DONE', response => {
64
63
  console.log('Conversation completed:', response);
65
64
  });
66
65
 
67
- client.on('ERROR', (error) => {
66
+ client.on('ERROR', error => {
68
67
  console.error('Error occurred:', error);
69
68
  });
70
69
  ```
@@ -78,10 +77,8 @@ client.on('ERROR', (error) => {
78
77
  ```javascript
79
78
  const client = new AsgardServiceClient({
80
79
  apiKey: 'your-api-key',
81
- endpoint:
82
- 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}/message/sse',
83
- botProviderEndpoint:
84
- 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
80
+ endpoint: 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}/message/sse',
81
+ botProviderEndpoint: 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
85
82
  });
86
83
  ```
87
84
 
@@ -90,8 +87,7 @@ const client = new AsgardServiceClient({
90
87
  ```javascript
91
88
  const client = new AsgardServiceClient({
92
89
  apiKey: 'your-api-key',
93
- botProviderEndpoint:
94
- 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
90
+ botProviderEndpoint: 'https://api.asgard-ai.com/ns/{namespace}/bot-provider/{botProviderId}',
95
91
  // SSE endpoint is automatically derived as: botProviderEndpoint + '/message/sse'
96
92
  });
97
93
  ```
@@ -184,7 +180,7 @@ const channel = await Channel.reset({
184
180
  client,
185
181
  customChannelId: 'channel-123',
186
182
  conversation,
187
- statesObserver: (states) => {
183
+ statesObserver: states => {
188
184
  console.log('Connection status:', states.isConnecting);
189
185
  console.log('Messages:', Array.from(states.conversation.messages.values()));
190
186
  },
@@ -237,7 +233,6 @@ const updatedConversation = conversation.pushMessage(userMessage);
237
233
  console.log('Messages:', Array.from(updatedConversation.messages.values()));
238
234
  ```
239
235
 
240
-
241
236
  ### File Upload API
242
237
 
243
238
  The core package includes file upload capabilities for sending images through the chatbot.
@@ -248,12 +243,12 @@ const uploadResponse = await client.uploadFile(file, customChannelId);
248
243
 
249
244
  if (uploadResponse.isSuccess && uploadResponse.data[0]) {
250
245
  const blobId = uploadResponse.data[0].blobId;
251
-
246
+
252
247
  client.fetchSse({
253
248
  customChannelId: 'your-channel-id',
254
249
  text: 'Here is my image',
255
250
  action: 'message',
256
- blobIds: [blobId]
251
+ blobIds: [blobId],
257
252
  });
258
253
  }
259
254
  ```
@@ -273,6 +268,7 @@ type AuthState = 'loading' | 'needApiKey' | 'authenticated' | 'error' | 'invalid
273
268
  ```
274
269
 
275
270
  **States:**
271
+
276
272
  - **`loading`**: Authentication in progress
277
273
  - **`needApiKey`**: User needs to provide API key
278
274
  - **`authenticated`**: Successfully authenticated
@@ -280,6 +276,7 @@ type AuthState = 'loading' | 'needApiKey' | 'authenticated' | 'error' | 'invalid
280
276
  - **`invalidApiKey`**: API key is invalid
281
277
 
282
278
  **Usage:**
279
+
283
280
  ```typescript
284
281
  import { AuthState } from '@asgard-js/core';
285
282