bstp-agent-widget 0.0.0 → 0.2.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 +67 -8
- package/dist/agent-widget.cjs +300 -75
- package/dist/agent-widget.cjs.map +1 -1
- package/dist/agent-widget.js +23943 -4968
- package/dist/agent-widget.js.map +1 -1
- package/package.json +8 -1
- package/src/lib/index.d.ts +10 -0
package/README.md
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
# BSTP Agent Widget
|
|
2
2
|
|
|
3
|
-
`bstp-agent-widget
|
|
3
|
+
`bstp-agent-widget` is an Agent Chat widget library that can be integrated into other React projects.
|
|
4
4
|
|
|
5
5
|
## Library Build & Publish
|
|
6
6
|
|
|
7
|
-
### 1)
|
|
7
|
+
### 1) Build the library
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
bun run build:lib
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
### 2)
|
|
13
|
+
### 2) Check package contents
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
bun run pack:check
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
### 3)
|
|
19
|
+
### 3) Publish to npm
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
npm publish --access public
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
>
|
|
25
|
+
> Note: `prepublishOnly` automatically runs `build:lib`.
|
|
26
26
|
|
|
27
|
-
## Consumer Project
|
|
27
|
+
## Consumer Project Usage
|
|
28
28
|
|
|
29
29
|
```bash
|
|
30
30
|
bun add bstp-agent-widget
|
|
@@ -57,8 +57,67 @@ export function Page() {
|
|
|
57
57
|
|
|
58
58
|
## Development Notes
|
|
59
59
|
|
|
60
|
-
- `react`
|
|
61
|
-
-
|
|
60
|
+
- `react` and `react-dom` are defined as `peerDependencies`.
|
|
61
|
+
- Library outputs are generated under `dist/`.
|
|
62
|
+
|
|
63
|
+
## Angular Integration
|
|
64
|
+
|
|
65
|
+
Install the package in your Angular app:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm i bstp-agent-widget
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Add the widget stylesheet once (for example in `src/styles.scss`):
|
|
72
|
+
|
|
73
|
+
```scss
|
|
74
|
+
@import 'bstp-agent-widget/style.css';
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Create a wrapper component:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { AfterViewInit, Component, ElementRef, OnDestroy, ViewChild } from '@angular/core';
|
|
81
|
+
import { mountAgentChatWidgetFromEnvironment } from 'bstp-agent-widget';
|
|
82
|
+
|
|
83
|
+
@Component({
|
|
84
|
+
selector: 'app-agent-chat-widget',
|
|
85
|
+
template: '<div #widgetHost></div>',
|
|
86
|
+
})
|
|
87
|
+
export class AgentChatWidgetComponent implements AfterViewInit, OnDestroy {
|
|
88
|
+
@ViewChild('widgetHost', { static: true }) widgetHost!: ElementRef<HTMLDivElement>;
|
|
89
|
+
private cleanup: (() => void) | null = null;
|
|
90
|
+
|
|
91
|
+
async ngAfterViewInit(): Promise<void> {
|
|
92
|
+
this.cleanup = await mountAgentChatWidgetFromEnvironment(this.widgetHost.nativeElement, {
|
|
93
|
+
runtime: {
|
|
94
|
+
customerId: '590100010884',
|
|
95
|
+
customerToken: 'jwt-token',
|
|
96
|
+
language: 'en-US',
|
|
97
|
+
},
|
|
98
|
+
// Optional: defaults to /environment.json
|
|
99
|
+
// environmentUrl: '/environment.json',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
ngOnDestroy(): void {
|
|
104
|
+
this.cleanup?.();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The function reads `genai.config` from `environment.json`:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"genai": {
|
|
114
|
+
"config": {
|
|
115
|
+
"assistantId": 220,
|
|
116
|
+
"url": "https://.../genai/api/v1"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
62
121
|
|
|
63
122
|
# React Starter Kit
|
|
64
123
|
|