@egain/ai-agent-sdk 0.1.0 → 0.1.2
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 +23 -18
- package/dist/browser.js +1 -1
- package/dist/core/AiAgent.d.ts +2 -2
- package/dist/core/AiAgent.js +2 -2
- package/dist/core/api/CacheAdapter.d.ts +1 -1
- package/dist/core/api/CacheAdapter.js +1 -1
- package/dist/core/events/EventEmitter.d.ts +1 -1
- package/dist/core/events/EventEmitter.js +1 -1
- package/dist/core/message/BaseMessageHandler.d.ts +1 -1
- package/dist/core/message/BaseMessageHandler.js +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @egain/ai-agent-sdk
|
|
2
2
|
|
|
3
3
|
TypeScript-first SDK for eGain's AI Agent platform with WebSocket communication, automatic reconnection, and comprehensive message handling.
|
|
4
4
|
|
|
5
|
-
**Current release:** v0.
|
|
5
|
+
**Current release:** v0.1.2
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/@egain/ai-agent-sdk)
|
|
8
8
|
[](https://www.typescriptlang.org/)
|
|
9
9
|
[](https://opensource.org/licenses/MIT)
|
|
10
10
|
|
|
@@ -24,19 +24,24 @@ TypeScript-first SDK for eGain's AI Agent platform with WebSocket communication,
|
|
|
24
24
|
## Installation
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
npm install @
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
**GitHub Packages Configuration** (`.npmrc`):
|
|
31
|
-
```ini
|
|
32
|
-
@eGain:registry=https://npm.pkg.github.com/
|
|
33
|
-
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
|
|
27
|
+
npm install @egain/ai-agent-sdk
|
|
34
28
|
```
|
|
35
29
|
|
|
36
30
|
## Quick Start
|
|
37
31
|
|
|
32
|
+
The sample below uses the **pre-auth** option, where your server obtains an access token and passes it directly to the SDK. Before running it, generate an access token using the PKCE flow:
|
|
33
|
+
|
|
34
|
+
### [Generating An Access Token using PKCE Flow](https://apidev.egain.com/developer-portal/guides/authentication/pkce-flow)
|
|
35
|
+
|
|
36
|
+
**Required scopes:**
|
|
37
|
+
- `core.aiservices.read`
|
|
38
|
+
- `knowledge.portalmgr.manage`
|
|
39
|
+
- `core.customermgr.read` _(required for AI Agent for Customer Self Service only)_
|
|
40
|
+
|
|
41
|
+
### Sample Code
|
|
42
|
+
|
|
38
43
|
```typescript
|
|
39
|
-
import { AiAgent } from "@
|
|
44
|
+
import { AiAgent } from "@egain/ai-agent-sdk";
|
|
40
45
|
|
|
41
46
|
const agent = new AiAgent({
|
|
42
47
|
id: "your-agent-id",
|
|
@@ -62,7 +67,7 @@ await agent.send("Hello!");
|
|
|
62
67
|
For agents that use the portal / profile pipeline, listen for selection events and call `connect()` after `initialized`:
|
|
63
68
|
|
|
64
69
|
```typescript
|
|
65
|
-
import { AiAgent } from "@
|
|
70
|
+
import { AiAgent } from "@egain/ai-agent-sdk";
|
|
66
71
|
|
|
67
72
|
const agent = new AiAgent({
|
|
68
73
|
id: "your-agent-id",
|
|
@@ -154,7 +159,7 @@ import {
|
|
|
154
159
|
createContextMessage,
|
|
155
160
|
createFeedbackMessage,
|
|
156
161
|
createEscalationMessage
|
|
157
|
-
} from "@
|
|
162
|
+
} from "@egain/ai-agent-sdk";
|
|
158
163
|
|
|
159
164
|
// Send context (auto-cached for reconnect)
|
|
160
165
|
await agent.send(createContextMessage({
|
|
@@ -182,7 +187,7 @@ npm install ws
|
|
|
182
187
|
The SDK automatically loads the `ws` package when running in Node.js. Just import and use:
|
|
183
188
|
|
|
184
189
|
```typescript
|
|
185
|
-
import { AiAgent } from "@
|
|
190
|
+
import { AiAgent } from "@egain/ai-agent-sdk";
|
|
186
191
|
|
|
187
192
|
const agent = new AiAgent({
|
|
188
193
|
id: "your-agent-id",
|
|
@@ -198,14 +203,14 @@ If the automatic polyfill doesn't work in your environment, you can set it up ma
|
|
|
198
203
|
import WebSocket from "ws";
|
|
199
204
|
(global as any).WebSocket = WebSocket;
|
|
200
205
|
|
|
201
|
-
import { AiAgent } from "@
|
|
206
|
+
import { AiAgent } from "@egain/ai-agent-sdk";
|
|
202
207
|
// ... rest of code
|
|
203
208
|
```
|
|
204
209
|
|
|
205
210
|
## Browser (UMD)
|
|
206
211
|
|
|
207
212
|
```html
|
|
208
|
-
<script src="https://unpkg.com/@
|
|
213
|
+
<script src="https://unpkg.com/@egain/ai-agent-sdk/dist/browser.js"></script>
|
|
209
214
|
<script>
|
|
210
215
|
const agent = new eGain.AiAgent({ ... });
|
|
211
216
|
</script>
|
|
@@ -230,7 +235,7 @@ npm run docs:build # Build docs
|
|
|
230
235
|
|
|
231
236
|
## Examples
|
|
232
237
|
|
|
233
|
-
See [usage-examples](https://github.com/
|
|
238
|
+
See [usage-examples](https://github.com/egain/ai-agent-sdk/tree/master/ai-agent-sdk/usage-examples) in this repository for complete examples:
|
|
234
239
|
- **Basic Usage** - Simple getting started
|
|
235
240
|
- **Browser Test** - Browser integration with UI
|
|
236
241
|
- **Server Test** - Node.js implementation
|
|
@@ -292,4 +297,4 @@ MIT
|
|
|
292
297
|
|
|
293
298
|
## Support
|
|
294
299
|
|
|
295
|
-
For issues and questions, please open an issue on [GitHub](https://github.com/
|
|
300
|
+
For issues and questions, please open an issue on [GitHub](https://github.com/egain/ai-agent-sdk/issues).
|