@glodon-aiot/agent-cli-ui 3.3.2-beta.15 → 3.3.2-beta.17
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/dist/es/AgentClientUI.mjs +119 -109
- package/dist/es/Dialog/AgentChat/HistoryItem/index.mjs +1 -1
- package/dist/es/Dialog/AgentChat/index.mjs +282 -269
- package/dist/es/Dialog/SessionList/index.mjs +35 -34
- package/dist/es/Dialog/index.mjs +101 -94
- package/dist/es/ReactTextGenerationUI/components/TextSiders/index.mjs +124 -120
- package/dist/es/components/FilePreview/index.mjs +26 -25
- package/dist/es/index.mjs +238 -211
- package/dist/es/packages/agent-cli-ui/package.json.mjs +3 -3
- package/dist/es/packages/react-components/dist/es/index.mjs +1 -1
- package/dist/es/src/style.css +1 -1
- package/dist/es/src/style10.css +1 -1
- package/dist/es/src/style11.css +1 -1
- package/dist/es/src/style12.css +1 -1
- package/dist/es/src/style13.css +1 -1
- package/dist/es/src/style14.css +1 -1
- package/dist/es/src/style15.css +1 -1
- package/dist/es/src/style16.css +1 -1
- package/dist/es/src/style17.css +1 -1
- package/dist/es/src/style18.css +1 -1
- package/dist/es/src/style19.css +1 -1
- package/dist/es/src/style20.css +1 -1
- package/dist/es/src/style21.css +1 -1
- package/dist/es/src/style22.css +1 -1
- package/dist/es/src/style23.css +1 -1
- package/dist/es/src/style24.css +1 -1
- package/dist/es/src/style25.css +1 -1
- package/dist/es/src/style26.css +1 -1
- package/dist/es/src/style27.css +1 -1
- package/dist/es/src/style28.css +1 -1
- package/dist/es/src/style29.css +1 -1
- package/dist/es/src/style3.css +1 -1
- package/dist/es/src/style30.css +1 -1
- package/dist/es/src/style31.css +1 -1
- package/dist/es/src/style5.css +1 -1
- package/dist/es/src/style6.css +1 -1
- package/dist/es/src/style7.css +1 -1
- package/dist/es/src/style8.css +1 -1
- package/dist/es/src/style9.css +1 -1
- package/dist/lib/index.css +1 -1
- package/dist/lib/index.js +30 -30
- package/dist/src/AgentClientUI.d.ts +10 -2
- package/dist/src/Dialog/SessionList/index.d.ts +1 -0
- package/dist/src/Dialog/index.d.ts +9 -1
- package/dist/src/index.d.ts +7 -2
- package/dist/src/types.d.ts +2 -1
- package/package.json +3 -3
package/dist/es/index.mjs
CHANGED
|
@@ -1,191 +1,193 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var S = (
|
|
6
|
-
for (var
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}, w = (
|
|
13
|
-
var l = (
|
|
14
|
-
var
|
|
15
|
-
var
|
|
1
|
+
var ie = Object.defineProperty, te = Object.defineProperties;
|
|
2
|
+
var se = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Z = Object.getOwnPropertySymbols;
|
|
4
|
+
var oe = Object.prototype.hasOwnProperty, ne = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var S = (p, i, n) => i in p ? ie(p, i, { enumerable: !0, configurable: !0, writable: !0, value: n }) : p[i] = n, r = (p, i) => {
|
|
6
|
+
for (var n in i || (i = {}))
|
|
7
|
+
oe.call(i, n) && S(p, n, i[n]);
|
|
8
|
+
if (Z)
|
|
9
|
+
for (var n of Z(i))
|
|
10
|
+
ne.call(i, n) && S(p, n, i[n]);
|
|
11
|
+
return p;
|
|
12
|
+
}, w = (p, i) => te(p, se(i));
|
|
13
|
+
var l = (p, i, n) => (S(p, typeof i != "symbol" ? i + "" : i, n), n);
|
|
14
|
+
var k = (p, i, n) => new Promise((g, f) => {
|
|
15
|
+
var c = (h) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
|
|
17
|
+
C(n.next(h));
|
|
18
|
+
} catch (d) {
|
|
19
|
+
f(d);
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, u = (h) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
|
|
23
|
+
C(n.throw(h));
|
|
24
|
+
} catch (d) {
|
|
25
|
+
f(d);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, C = (h) => h.done ? g(h.value) : Promise.resolve(h.value).then(c, u);
|
|
28
|
+
C((n = n.apply(p, i)).next());
|
|
29
29
|
});
|
|
30
|
-
import { jsx as U, Fragment as
|
|
31
|
-
import
|
|
30
|
+
import { jsx as U, Fragment as re } from "react/jsx-runtime";
|
|
31
|
+
import ae from "react";
|
|
32
|
+
import b from "lodash/merge";
|
|
32
33
|
import x from "react-dom";
|
|
33
|
-
import
|
|
34
|
-
import { notification as
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import { defaultUIConfig as
|
|
38
|
-
import { ApiUrl as
|
|
39
|
-
/* empty css */import { BotClientApi as
|
|
40
|
-
import { JWT as
|
|
41
|
-
import { configuration as
|
|
42
|
-
import
|
|
43
|
-
const
|
|
44
|
-
class
|
|
45
|
-
constructor(
|
|
34
|
+
import he from "./AgentClientUI.mjs";
|
|
35
|
+
import { notification as B } from "antd";
|
|
36
|
+
import ge from "axios";
|
|
37
|
+
import le from "./packages/agent-cli-ui/package.json.mjs";
|
|
38
|
+
import { defaultUIConfig as fe, defaultApiUrl as de, defaultDovViewerUrl as ue } from "./constant.mjs";
|
|
39
|
+
import { ApiUrl as ce } from "./types.mjs";
|
|
40
|
+
/* empty css */import { BotClientApi as pe, ApplicationTypes as q } from "@glodon-aiot/apis";
|
|
41
|
+
import { JWT as me, isExpired as Ce } from "./utils/index.mjs";
|
|
42
|
+
import { configuration as be, configure as ee, BotClient as ve } from "@glodon-aiot/bot-client-sdk";
|
|
43
|
+
import we from "./ReactTextGenerationUI/index.mjs";
|
|
44
|
+
const I = {};
|
|
45
|
+
class Ne {
|
|
46
|
+
constructor(i) {
|
|
46
47
|
l(this, "_token");
|
|
47
48
|
l(this, "_activeSession", null);
|
|
48
49
|
l(this, "_applicationId");
|
|
49
50
|
l(this, "_defaultInputText", "");
|
|
50
51
|
l(this, "_inputDisabled", !1);
|
|
51
52
|
l(this, "_defatulSessionId", "");
|
|
53
|
+
l(this, "_agentClientRef", ae.createRef());
|
|
52
54
|
l(this, "apiUrl");
|
|
53
55
|
l(this, "docViewerUrl");
|
|
54
56
|
l(this, "env", "prod");
|
|
55
|
-
l(this, "stream",
|
|
57
|
+
l(this, "stream", be.stream);
|
|
56
58
|
l(this, "service");
|
|
57
59
|
l(this, "rId", 0);
|
|
58
60
|
l(this, "_mode", "float");
|
|
59
|
-
l(this, "uiConfig",
|
|
61
|
+
l(this, "uiConfig", fe);
|
|
60
62
|
l(this, "errorHandlers", {});
|
|
61
63
|
l(this, "wrapper", document.createElement("div"));
|
|
62
64
|
l(this, "botClient", null);
|
|
63
|
-
var H,
|
|
65
|
+
var H, z, M, V, E, R, A, N, T, D, j, F, P, W, $, O, J, K, Q, G, X, Y;
|
|
64
66
|
const {
|
|
65
|
-
env:
|
|
66
|
-
token:
|
|
67
|
-
mode:
|
|
68
|
-
triggerButton:
|
|
69
|
-
size:
|
|
70
|
-
apiUrl:
|
|
71
|
-
docViewerUrl:
|
|
72
|
-
errorHandlers:
|
|
73
|
-
features:
|
|
67
|
+
env: n,
|
|
68
|
+
token: g,
|
|
69
|
+
mode: f = "float",
|
|
70
|
+
triggerButton: c,
|
|
71
|
+
size: u,
|
|
72
|
+
apiUrl: C,
|
|
73
|
+
docViewerUrl: h,
|
|
74
|
+
errorHandlers: d,
|
|
75
|
+
features: e,
|
|
74
76
|
sessionId: o,
|
|
75
77
|
icon: t,
|
|
76
78
|
logo: s,
|
|
77
|
-
stream:
|
|
78
|
-
} =
|
|
79
|
-
this.uiConfig.icon = t || this.uiConfig.icon, this.uiConfig.logo = s || this.uiConfig.logo, (
|
|
80
|
-
greeting:
|
|
81
|
-
}) : this.uiConfig.features = w(
|
|
82
|
-
greeting:
|
|
83
|
-
})), this._token =
|
|
84
|
-
const
|
|
85
|
-
sessionOpen:
|
|
86
|
-
sessionList:
|
|
87
|
-
},
|
|
88
|
-
(N = (
|
|
79
|
+
stream: a
|
|
80
|
+
} = i;
|
|
81
|
+
this.uiConfig.icon = t || this.uiConfig.icon, this.uiConfig.logo = s || this.uiConfig.logo, (e == null ? void 0 : e.greeting) !== void 0 && (typeof e.greeting == "object" ? this.uiConfig.features = w(r({}, this.uiConfig.features), {
|
|
82
|
+
greeting: r(r({}, typeof ((H = this.uiConfig.features) == null ? void 0 : H.greeting) != "object" ? {} : (z = this.uiConfig.features) == null ? void 0 : z.greeting), e.greeting)
|
|
83
|
+
}) : this.uiConfig.features = w(r({}, this.uiConfig.features), {
|
|
84
|
+
greeting: e.greeting
|
|
85
|
+
})), this._token = g, this.rId = 0, this._defatulSessionId = o, this.errorHandlers = r(r({}, this.errorHandlers), d);
|
|
86
|
+
const m = {
|
|
87
|
+
sessionOpen: f === "float",
|
|
88
|
+
sessionList: f === "float"
|
|
89
|
+
}, L = (E = (V = (M = e == null ? void 0 : e.botMessageBox) == null ? void 0 : M.footer) == null ? void 0 : V.items) == null ? void 0 : E.find((v) => v.componentName === "AnswerAgain");
|
|
90
|
+
(N = (A = (R = e == null ? void 0 : e.botMessageBox) == null ? void 0 : R.footer) == null ? void 0 : A.items) == null || N.find((v) => v.componentName === "Copy");
|
|
89
91
|
const y = {
|
|
90
|
-
sessionList:
|
|
91
|
-
sessionOpen:
|
|
92
|
-
fileUpload:
|
|
93
|
-
userCopy: (T =
|
|
94
|
-
userEdit: (D =
|
|
95
|
-
userPrompt:
|
|
96
|
-
prompt:
|
|
97
|
-
relate: (
|
|
98
|
-
again: !(
|
|
92
|
+
sessionList: e == null ? void 0 : e.sessionList,
|
|
93
|
+
sessionOpen: e == null ? void 0 : e.newSession,
|
|
94
|
+
fileUpload: e == null ? void 0 : e.fileUpload,
|
|
95
|
+
userCopy: (T = e == null ? void 0 : e.userMessageBox) == null ? void 0 : T.copy,
|
|
96
|
+
userEdit: (D = e == null ? void 0 : e.userMessageBox) == null ? void 0 : D.editAgain,
|
|
97
|
+
userPrompt: e == null ? void 0 : e.fileUpload,
|
|
98
|
+
prompt: e == null ? void 0 : e.prompts,
|
|
99
|
+
relate: (j = e == null ? void 0 : e.botMessageBox) == null ? void 0 : j.relatedQuesions,
|
|
100
|
+
again: !(L && L.visible === !1),
|
|
99
101
|
reference: {
|
|
100
|
-
iconVisible: (
|
|
101
|
-
referenceFirst: (
|
|
102
|
-
isExpand: (
|
|
102
|
+
iconVisible: (P = (F = e == null ? void 0 : e.botMessageBox) == null ? void 0 : F.reference) == null ? void 0 : P.file,
|
|
103
|
+
referenceFirst: (W = e == null ? void 0 : e.botMessageBox) == null ? void 0 : W.referenceFirst,
|
|
104
|
+
isExpand: (O = ($ = e == null ? void 0 : e.botMessageBox) == null ? void 0 : $.reference) == null ? void 0 : O.itemExpanded
|
|
103
105
|
},
|
|
104
|
-
searchReference: (
|
|
105
|
-
knowledges: !!(
|
|
106
|
-
metadata:
|
|
107
|
-
greet: (
|
|
108
|
-
imageUpload:
|
|
109
|
-
promptVariables: (
|
|
110
|
-
connectNetwork: (
|
|
111
|
-
},
|
|
112
|
-
sider:
|
|
106
|
+
searchReference: (J = e == null ? void 0 : e.botMessageBox) == null ? void 0 : J.searchReference,
|
|
107
|
+
knowledges: !!(e != null && e.knowledges),
|
|
108
|
+
metadata: e == null ? void 0 : e.metadata,
|
|
109
|
+
greet: (e == null ? void 0 : e.greeting) !== !1,
|
|
110
|
+
imageUpload: e == null ? void 0 : e.imageUpload,
|
|
111
|
+
promptVariables: (e == null ? void 0 : e.promptVariables) === void 0 ? (K = this.uiConfig.transform) == null ? void 0 : K.promptVariables : (e == null ? void 0 : e.promptVariables) === !0 || typeof (e == null ? void 0 : e.promptVariables) == "object" && ((Q = e == null ? void 0 : e.promptVariables) == null ? void 0 : Q.visible) !== !1 ? (G = this.uiConfig.transform) == null ? void 0 : G.promptVariables : !1,
|
|
112
|
+
connectNetwork: (e == null ? void 0 : e.connectNetwork) === void 0 ? (X = this.uiConfig.transform) == null ? void 0 : X.connectNetwork : (e == null ? void 0 : e.connectNetwork) === !0 || (typeof (e == null ? void 0 : e.connectNetwork) == "object" && typeof (e == null ? void 0 : e.connectNetwork.visible) == "boolean" ? e == null ? void 0 : e.connectNetwork.visible : (Y = this.uiConfig.transform) == null ? void 0 : Y.connectNetwork)
|
|
113
|
+
}, _ = {
|
|
114
|
+
sider: f === "inlay"
|
|
113
115
|
};
|
|
114
|
-
if (
|
|
115
|
-
y[
|
|
116
|
-
}),
|
|
117
|
-
const
|
|
118
|
-
triggerButton:
|
|
116
|
+
if (i.header !== void 0 && (_.showHeader = !!i.header), i.sider !== void 0 && (_.sider = !!i.sider), Object.keys(y).forEach((v) => {
|
|
117
|
+
y[v] === void 0 && delete y[v];
|
|
118
|
+
}), f === "inlay") {
|
|
119
|
+
const v = {
|
|
120
|
+
triggerButton: b({
|
|
119
121
|
visible: !1
|
|
120
|
-
},
|
|
122
|
+
}, c),
|
|
121
123
|
open: !0,
|
|
122
124
|
resizable: !1,
|
|
123
|
-
size:
|
|
125
|
+
size: b({
|
|
124
126
|
width: "100%",
|
|
125
127
|
height: "100%",
|
|
126
128
|
maxWidth: "100%",
|
|
127
129
|
maxHeight: "100%",
|
|
128
130
|
minWidth: "100%"
|
|
129
|
-
},
|
|
130
|
-
theme:
|
|
131
|
+
}, u),
|
|
132
|
+
theme: b(this.uiConfig.theme, I),
|
|
131
133
|
history: !0
|
|
132
134
|
};
|
|
133
|
-
this.uiConfig = w(
|
|
134
|
-
transform:
|
|
135
|
+
this.uiConfig = w(r(r(r(r({}, this.uiConfig), i), v), _), {
|
|
136
|
+
transform: r(r(r(r({}, this.uiConfig.transform), m), i.transform), y)
|
|
135
137
|
}), this.wrapper = this.uiConfig.getContainer();
|
|
136
138
|
} else {
|
|
137
|
-
const
|
|
138
|
-
triggerButton:
|
|
139
|
-
size:
|
|
140
|
-
theme:
|
|
139
|
+
const v = {
|
|
140
|
+
triggerButton: b(this.uiConfig.triggerButton, c),
|
|
141
|
+
size: b(this.uiConfig.size, r({}, u)),
|
|
142
|
+
theme: b(this.uiConfig.theme, I)
|
|
141
143
|
};
|
|
142
|
-
this.uiConfig = w(
|
|
143
|
-
transform:
|
|
144
|
+
this.uiConfig = w(r(r(r(r(r({}, this.uiConfig), i), v), _), y), {
|
|
145
|
+
transform: r(r(r(r({}, this.uiConfig.transform), m), i.transform), y)
|
|
144
146
|
}), this.uiConfig.getContainer().append(this.wrapper);
|
|
145
147
|
}
|
|
146
|
-
this._mode =
|
|
148
|
+
this._mode = f, this.env = n || "prod", this.stream = a, ee({
|
|
147
149
|
stream: this.stream
|
|
148
|
-
}), this._applicationId =
|
|
150
|
+
}), this._applicationId = me(g).rid, this.apiUrl = C || ce[this.env] || de, this.docViewerUrl = h || ue, this.service = this.setService(), this.createBotClientSDK().then(() => {
|
|
149
151
|
this.render();
|
|
150
152
|
});
|
|
151
153
|
}
|
|
152
154
|
get token() {
|
|
153
155
|
return this._token;
|
|
154
156
|
}
|
|
155
|
-
set token(
|
|
156
|
-
this._token =
|
|
157
|
+
set token(i) {
|
|
158
|
+
this._token = i, this.reload();
|
|
157
159
|
}
|
|
158
160
|
get mode() {
|
|
159
161
|
return this._mode;
|
|
160
162
|
}
|
|
161
|
-
set mode(
|
|
162
|
-
if (
|
|
163
|
-
const
|
|
164
|
-
triggerButton:
|
|
163
|
+
set mode(i) {
|
|
164
|
+
if (i === "inlay") {
|
|
165
|
+
const n = {
|
|
166
|
+
triggerButton: b({
|
|
165
167
|
visible: !1
|
|
166
168
|
}, this.uiConfig.triggerButton),
|
|
167
169
|
open: !0,
|
|
168
170
|
resizable: !1,
|
|
169
|
-
size:
|
|
171
|
+
size: b({
|
|
170
172
|
width: "100%",
|
|
171
173
|
height: "100%",
|
|
172
174
|
maxWidth: "100%",
|
|
173
175
|
maxHeight: "100%",
|
|
174
176
|
minWidth: "100%"
|
|
175
177
|
}, this.uiConfig.size),
|
|
176
|
-
theme:
|
|
178
|
+
theme: b(this.uiConfig.theme, I),
|
|
177
179
|
history: !0
|
|
178
180
|
};
|
|
179
|
-
this.uiConfig =
|
|
181
|
+
this.uiConfig = r(r({}, this.uiConfig), n), this.wrapper = this.uiConfig.getContainer();
|
|
180
182
|
} else {
|
|
181
|
-
const
|
|
182
|
-
triggerButton:
|
|
183
|
-
size:
|
|
184
|
-
theme:
|
|
183
|
+
const n = {
|
|
184
|
+
triggerButton: b(this.uiConfig.triggerButton, this.uiConfig.triggerButton),
|
|
185
|
+
size: b(this.uiConfig.size, r({}, this.uiConfig.size)),
|
|
186
|
+
theme: b(this.uiConfig.theme, I)
|
|
185
187
|
};
|
|
186
|
-
this.uiConfig =
|
|
188
|
+
this.uiConfig = r(r({}, this.uiConfig), n), this._mode === "inlay" && this.wrapper.remove(), this.uiConfig.getContainer().append(this.wrapper);
|
|
187
189
|
}
|
|
188
|
-
this._mode =
|
|
190
|
+
this._mode = i, this.render();
|
|
189
191
|
}
|
|
190
192
|
get activeSession() {
|
|
191
193
|
return this._activeSession;
|
|
@@ -194,12 +196,12 @@ class Ei {
|
|
|
194
196
|
return this._applicationId;
|
|
195
197
|
}
|
|
196
198
|
setService() {
|
|
197
|
-
const
|
|
198
|
-
var
|
|
199
|
-
const
|
|
200
|
-
if (!
|
|
201
|
-
return
|
|
202
|
-
if (
|
|
199
|
+
const i = this.apiUrl, n = (h) => {
|
|
200
|
+
var e;
|
|
201
|
+
const d = this.token;
|
|
202
|
+
if (!d)
|
|
203
|
+
return h;
|
|
204
|
+
if (Ce(d)) {
|
|
203
205
|
const o = "token is timeout";
|
|
204
206
|
this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
|
|
205
207
|
// @ts-ignore
|
|
@@ -211,53 +213,55 @@ class Ei {
|
|
|
211
213
|
})
|
|
212
214
|
) : console.error("errorHandlers.token is not a function") : console.error(o);
|
|
213
215
|
}
|
|
214
|
-
return
|
|
215
|
-
Authorization:
|
|
216
|
-
}),
|
|
216
|
+
return h.headers = (e = h.headers) != null ? e : {}, h.headers = w(r({}, h.headers), {
|
|
217
|
+
Authorization: d ? `Bearer ${d}` : ""
|
|
218
|
+
}), h;
|
|
217
219
|
};
|
|
218
|
-
function
|
|
219
|
-
const
|
|
220
|
-
baseURL:
|
|
220
|
+
function g(h, d = !0) {
|
|
221
|
+
const e = `${i}${h}`, o = ge.create({
|
|
222
|
+
baseURL: e
|
|
221
223
|
});
|
|
222
|
-
return
|
|
224
|
+
return d && o.interceptors.request.use(n), o;
|
|
223
225
|
}
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
226
|
-
const
|
|
226
|
+
const f = (h, d) => {
|
|
227
|
+
if (h === 401) {
|
|
228
|
+
const e = "token is invalid";
|
|
227
229
|
this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
|
|
228
230
|
// @ts-ignore
|
|
229
|
-
new Error(
|
|
231
|
+
new Error(e, {
|
|
230
232
|
cause: {
|
|
231
233
|
status: 401,
|
|
232
|
-
message:
|
|
234
|
+
message: e
|
|
233
235
|
}
|
|
234
236
|
})
|
|
235
|
-
) : console.error("errorHandlers.token is not a function") : console.error(
|
|
237
|
+
) : console.error("errorHandlers.token is not a function") : console.error(e);
|
|
236
238
|
}
|
|
237
|
-
},
|
|
238
|
-
|
|
239
|
+
}, c = (h, d, e) => {
|
|
240
|
+
h !== 10001 && h !== 10215 && (e || (B.config({
|
|
239
241
|
getContainer: this.uiConfig.getContainer
|
|
240
|
-
}),
|
|
241
|
-
message:
|
|
242
|
+
}), B.error({
|
|
243
|
+
message: d
|
|
244
|
+
}), B.config({
|
|
245
|
+
getContainer: void 0
|
|
242
246
|
})));
|
|
243
|
-
},
|
|
244
|
-
return new
|
|
245
|
-
onHttpStatusError:
|
|
246
|
-
onAppStatusError:
|
|
247
|
+
}, u = g("");
|
|
248
|
+
return new pe(u, () => this.token, {
|
|
249
|
+
onHttpStatusError: f,
|
|
250
|
+
onAppStatusError: c
|
|
247
251
|
});
|
|
248
252
|
}
|
|
249
253
|
reload() {
|
|
250
|
-
var
|
|
251
|
-
this._defatulSessionId = (
|
|
254
|
+
var i;
|
|
255
|
+
this._defatulSessionId = (i = this.activeSession) == null ? void 0 : i.id, this.destroy(() => {
|
|
252
256
|
this.service = this.setService(), this.rId = this.rId + 1, this.render();
|
|
253
257
|
});
|
|
254
258
|
}
|
|
255
|
-
getMessageList(
|
|
256
|
-
var
|
|
257
|
-
return
|
|
259
|
+
getMessageList(i) {
|
|
260
|
+
var n, g;
|
|
261
|
+
return i || (i = (n = this.activeSession) == null ? void 0 : n.id), !this.applicationId || !i ? Promise.resolve([]) : (g = this.service) == null ? void 0 : g.getChatHistorySessionId(this.applicationId, i);
|
|
258
262
|
}
|
|
259
|
-
input(
|
|
260
|
-
this._defaultInputText =
|
|
263
|
+
input(i) {
|
|
264
|
+
this._defaultInputText = i, this.render();
|
|
261
265
|
}
|
|
262
266
|
disable() {
|
|
263
267
|
this._inputDisabled = !0, this.render();
|
|
@@ -265,15 +269,37 @@ class Ei {
|
|
|
265
269
|
enable() {
|
|
266
270
|
this._inputDisabled = !1, this.render();
|
|
267
271
|
}
|
|
272
|
+
getSessionList() {
|
|
273
|
+
return this._agentClientRef.current ? new Promise((n, g) => {
|
|
274
|
+
var f, c;
|
|
275
|
+
(c = (f = this._agentClientRef.current) == null ? void 0 : f.getSessionList()) == null || c.then((u) => {
|
|
276
|
+
n(u);
|
|
277
|
+
}).catch((u) => {
|
|
278
|
+
g(u);
|
|
279
|
+
});
|
|
280
|
+
}) : Promise.reject(new Error("client is not loaded"));
|
|
281
|
+
}
|
|
282
|
+
sessionCreate(i) {
|
|
283
|
+
return this._agentClientRef.current ? new Promise((g, f) => {
|
|
284
|
+
var c, u;
|
|
285
|
+
(u = (c = this._agentClientRef.current) == null ? void 0 : c.sessionCreate(r({
|
|
286
|
+
name: "新建会话"
|
|
287
|
+
}, i))) == null || u.then((C) => {
|
|
288
|
+
g(C);
|
|
289
|
+
}).catch((C) => {
|
|
290
|
+
f(C);
|
|
291
|
+
});
|
|
292
|
+
}) : Promise.reject(new Error("client is not loaded"));
|
|
293
|
+
}
|
|
268
294
|
createBotClientSDK() {
|
|
269
|
-
return
|
|
270
|
-
return new Promise((
|
|
295
|
+
return k(this, null, function* () {
|
|
296
|
+
return new Promise((i, n) => {
|
|
271
297
|
if (this.token)
|
|
272
|
-
|
|
298
|
+
ee({
|
|
273
299
|
debug: this.uiConfig.debug,
|
|
274
300
|
env: this.uiConfig.env,
|
|
275
301
|
apiRoot: this.apiUrl
|
|
276
|
-
}), this.botClient = new
|
|
302
|
+
}), this.botClient = new ve(this.token, {
|
|
277
303
|
plugins: this.uiConfig.plugins,
|
|
278
304
|
mcp: this.uiConfig.mcp,
|
|
279
305
|
stream: this.uiConfig.stream
|
|
@@ -284,11 +310,11 @@ class Ei {
|
|
|
284
310
|
// 这里记录应用的名称和版本,以便后期数据分析
|
|
285
311
|
ui: {
|
|
286
312
|
name: "bot-client-ui",
|
|
287
|
-
version:
|
|
313
|
+
version: le.version
|
|
288
314
|
}
|
|
289
|
-
}), this.botClient.ready ?
|
|
290
|
-
var
|
|
291
|
-
this.botClient ? (((
|
|
315
|
+
}), this.botClient.ready ? i(this.botClient) : this.botClient.addEventListener("ready", () => k(this, null, function* () {
|
|
316
|
+
var g;
|
|
317
|
+
this.botClient ? (((g = this.botClient.application) == null ? void 0 : g.type) === q.Text && (this.mode = "inlay"), i(this.botClient)) : n(this.botClient);
|
|
292
318
|
}), !0);
|
|
293
319
|
else
|
|
294
320
|
throw Error("token is required");
|
|
@@ -296,12 +322,12 @@ class Ei {
|
|
|
296
322
|
});
|
|
297
323
|
}
|
|
298
324
|
render() {
|
|
299
|
-
return
|
|
300
|
-
var
|
|
301
|
-
let
|
|
302
|
-
if (this.wrapper.style.height = `${
|
|
325
|
+
return k(this, null, function* () {
|
|
326
|
+
var n, g, f, c, u, C, h, d, e;
|
|
327
|
+
let i = this.wrapper.getBoundingClientRect().height;
|
|
328
|
+
if (this.wrapper.style.height = `${i}px`, !((n = this.botClient) != null && n.application))
|
|
303
329
|
throw Error("application is required");
|
|
304
|
-
this.botClient.application.type === q.Text ? x.render(/* @__PURE__ */ U(
|
|
330
|
+
this.botClient.application.type === q.Text ? x.render(/* @__PURE__ */ U(we, {
|
|
305
331
|
rId: this.rId,
|
|
306
332
|
application: this.botClient.application,
|
|
307
333
|
sessionId: this._defatulSessionId,
|
|
@@ -318,7 +344,7 @@ class Ei {
|
|
|
318
344
|
theme: this.uiConfig.theme,
|
|
319
345
|
greeting: this.uiConfig.greeting,
|
|
320
346
|
size: this.uiConfig.size,
|
|
321
|
-
triggerButton:
|
|
347
|
+
triggerButton: r({
|
|
322
348
|
visible: !0
|
|
323
349
|
}, this.uiConfig.triggerButton),
|
|
324
350
|
history: this.uiConfig.history,
|
|
@@ -326,8 +352,8 @@ class Ei {
|
|
|
326
352
|
docViewerUrl: this.docViewerUrl,
|
|
327
353
|
plugins: this.uiConfig.plugins,
|
|
328
354
|
mcp: this.uiConfig.mcp,
|
|
329
|
-
transform: w(
|
|
330
|
-
knowledges: ((
|
|
355
|
+
transform: w(r({}, this.uiConfig.transform), {
|
|
356
|
+
knowledges: ((g = this.uiConfig.features) == null ? void 0 : g.knowledges) === !0 || typeof ((f = this.uiConfig.features) == null ? void 0 : f.knowledges) == "object" && ((u = (c = this.uiConfig.features) == null ? void 0 : c.knowledges) == null ? void 0 : u.visible) !== !1
|
|
331
357
|
}),
|
|
332
358
|
features: this.uiConfig.features,
|
|
333
359
|
disabled: this._inputDisabled,
|
|
@@ -337,8 +363,8 @@ class Ei {
|
|
|
337
363
|
var t, s;
|
|
338
364
|
try {
|
|
339
365
|
(s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.comment) == null || s.call(t, o);
|
|
340
|
-
} catch (
|
|
341
|
-
console.error(
|
|
366
|
+
} catch (a) {
|
|
367
|
+
console.error(a);
|
|
342
368
|
}
|
|
343
369
|
},
|
|
344
370
|
agentClient: this.botClient,
|
|
@@ -347,18 +373,18 @@ class Ei {
|
|
|
347
373
|
if (o.message.messageId)
|
|
348
374
|
try {
|
|
349
375
|
(s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.message) == null || s.call(t, o);
|
|
350
|
-
} catch (
|
|
351
|
-
console.error(
|
|
376
|
+
} catch (a) {
|
|
377
|
+
console.error(a);
|
|
352
378
|
}
|
|
353
379
|
},
|
|
354
380
|
beforeMessageSend: (o) => {
|
|
355
|
-
var t, s,
|
|
381
|
+
var t, s, a;
|
|
356
382
|
if (!((t = this.uiConfig.eventListeners) != null && t.beforemessagesend))
|
|
357
383
|
return !0;
|
|
358
384
|
try {
|
|
359
|
-
return ((
|
|
360
|
-
} catch (
|
|
361
|
-
return console.error(
|
|
385
|
+
return ((a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.beforemessagesend) == null ? void 0 : a.call(s, o)) || !1;
|
|
386
|
+
} catch (m) {
|
|
387
|
+
return console.error(m), !1;
|
|
362
388
|
}
|
|
363
389
|
},
|
|
364
390
|
onSessionUnload: (o) => {
|
|
@@ -366,30 +392,30 @@ class Ei {
|
|
|
366
392
|
this._activeSession = null;
|
|
367
393
|
try {
|
|
368
394
|
(s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.sessionunload) == null || s.call(t, o);
|
|
369
|
-
} catch (
|
|
370
|
-
console.error(
|
|
395
|
+
} catch (a) {
|
|
396
|
+
console.error(a);
|
|
371
397
|
}
|
|
372
398
|
},
|
|
373
399
|
onSessionLoad: (o) => {
|
|
374
|
-
var t, s,
|
|
400
|
+
var t, s, a;
|
|
375
401
|
if (((t = this._activeSession) == null ? void 0 : t.id) === o.sessionId)
|
|
376
402
|
this._activeSession = o.session;
|
|
377
403
|
else {
|
|
378
404
|
this._activeSession = o.session;
|
|
379
405
|
try {
|
|
380
|
-
(
|
|
381
|
-
} catch (
|
|
382
|
-
console.error(
|
|
406
|
+
(a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.sessionload) == null || a.call(s, o);
|
|
407
|
+
} catch (m) {
|
|
408
|
+
console.error(m);
|
|
383
409
|
}
|
|
384
410
|
}
|
|
385
411
|
},
|
|
386
412
|
onHistoryLoad: (o) => {
|
|
387
|
-
var t, s,
|
|
413
|
+
var t, s, a;
|
|
388
414
|
if (((t = this._activeSession) == null ? void 0 : t.id) === o.sessionId)
|
|
389
415
|
try {
|
|
390
|
-
(
|
|
391
|
-
} catch (
|
|
392
|
-
console.error(
|
|
416
|
+
(a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.historyload) == null || a.call(s, o);
|
|
417
|
+
} catch (m) {
|
|
418
|
+
console.error(m);
|
|
393
419
|
}
|
|
394
420
|
},
|
|
395
421
|
defaultInput: this._defaultInputText !== void 0 ? {
|
|
@@ -397,7 +423,8 @@ class Ei {
|
|
|
397
423
|
} : void 0,
|
|
398
424
|
bodyStyle: this.uiConfig.bodyStyle,
|
|
399
425
|
stream: this.stream
|
|
400
|
-
}), this.wrapper) : x.render(/* @__PURE__ */ U(
|
|
426
|
+
}), this.wrapper) : x.render(/* @__PURE__ */ U(he, {
|
|
427
|
+
ref: this._agentClientRef,
|
|
401
428
|
rId: this.rId,
|
|
402
429
|
application: this.botClient.application,
|
|
403
430
|
agentClient: this.botClient,
|
|
@@ -415,7 +442,7 @@ class Ei {
|
|
|
415
442
|
theme: this.uiConfig.theme,
|
|
416
443
|
greeting: this.uiConfig.greeting,
|
|
417
444
|
size: this.uiConfig.size,
|
|
418
|
-
triggerButton:
|
|
445
|
+
triggerButton: r({
|
|
419
446
|
visible: !0
|
|
420
447
|
}, this.uiConfig.triggerButton),
|
|
421
448
|
history: this.uiConfig.history,
|
|
@@ -423,8 +450,8 @@ class Ei {
|
|
|
423
450
|
docViewerUrl: this.docViewerUrl,
|
|
424
451
|
plugins: this.uiConfig.plugins,
|
|
425
452
|
mcp: this.uiConfig.mcp,
|
|
426
|
-
transform: w(
|
|
427
|
-
knowledges: ((
|
|
453
|
+
transform: w(r({}, this.uiConfig.transform), {
|
|
454
|
+
knowledges: ((C = this.uiConfig.features) == null ? void 0 : C.knowledges) === !0 || typeof ((h = this.uiConfig.features) == null ? void 0 : h.knowledges) == "object" && ((e = (d = this.uiConfig.features) == null ? void 0 : d.knowledges) == null ? void 0 : e.visible) !== !1
|
|
428
455
|
}),
|
|
429
456
|
features: this.uiConfig.features,
|
|
430
457
|
disabled: this._inputDisabled,
|
|
@@ -434,8 +461,8 @@ class Ei {
|
|
|
434
461
|
var t, s;
|
|
435
462
|
try {
|
|
436
463
|
(s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.comment) == null || s.call(t, o);
|
|
437
|
-
} catch (
|
|
438
|
-
console.error(
|
|
464
|
+
} catch (a) {
|
|
465
|
+
console.error(a);
|
|
439
466
|
}
|
|
440
467
|
},
|
|
441
468
|
onMessage: (o) => {
|
|
@@ -443,18 +470,18 @@ class Ei {
|
|
|
443
470
|
if (o.message.messageId)
|
|
444
471
|
try {
|
|
445
472
|
(s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.message) == null || s.call(t, o);
|
|
446
|
-
} catch (
|
|
447
|
-
console.error(
|
|
473
|
+
} catch (a) {
|
|
474
|
+
console.error(a);
|
|
448
475
|
}
|
|
449
476
|
},
|
|
450
477
|
beforeMessageSend: (o) => {
|
|
451
|
-
var t, s,
|
|
478
|
+
var t, s, a;
|
|
452
479
|
if (!((t = this.uiConfig.eventListeners) != null && t.beforemessagesend))
|
|
453
480
|
return !0;
|
|
454
481
|
try {
|
|
455
|
-
return ((
|
|
456
|
-
} catch (
|
|
457
|
-
return console.error(
|
|
482
|
+
return ((a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.beforemessagesend) == null ? void 0 : a.call(s, o)) || !1;
|
|
483
|
+
} catch (m) {
|
|
484
|
+
return console.error(m), !1;
|
|
458
485
|
}
|
|
459
486
|
},
|
|
460
487
|
onSessionUnload: (o) => {
|
|
@@ -462,30 +489,30 @@ class Ei {
|
|
|
462
489
|
this._activeSession = null;
|
|
463
490
|
try {
|
|
464
491
|
(s = (t = this.uiConfig.eventListeners) == null ? void 0 : t.sessionunload) == null || s.call(t, o);
|
|
465
|
-
} catch (
|
|
466
|
-
console.error(
|
|
492
|
+
} catch (a) {
|
|
493
|
+
console.error(a);
|
|
467
494
|
}
|
|
468
495
|
},
|
|
469
496
|
onSessionLoad: (o) => {
|
|
470
|
-
var t, s,
|
|
497
|
+
var t, s, a;
|
|
471
498
|
if (((t = this._activeSession) == null ? void 0 : t.id) === o.sessionId)
|
|
472
499
|
this._activeSession = o.session;
|
|
473
500
|
else {
|
|
474
501
|
this._activeSession = o.session;
|
|
475
502
|
try {
|
|
476
|
-
(
|
|
477
|
-
} catch (
|
|
478
|
-
console.error(
|
|
503
|
+
(a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.sessionload) == null || a.call(s, o);
|
|
504
|
+
} catch (m) {
|
|
505
|
+
console.error(m);
|
|
479
506
|
}
|
|
480
507
|
}
|
|
481
508
|
},
|
|
482
509
|
onHistoryLoad: (o) => {
|
|
483
|
-
var t, s,
|
|
510
|
+
var t, s, a;
|
|
484
511
|
if (((t = this._activeSession) == null ? void 0 : t.id) === o.sessionId)
|
|
485
512
|
try {
|
|
486
|
-
(
|
|
487
|
-
} catch (
|
|
488
|
-
console.error(
|
|
513
|
+
(a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.historyload) == null || a.call(s, o);
|
|
514
|
+
} catch (m) {
|
|
515
|
+
console.error(m);
|
|
489
516
|
}
|
|
490
517
|
},
|
|
491
518
|
defaultInput: this._defaultInputText !== void 0 ? {
|
|
@@ -496,10 +523,10 @@ class Ei {
|
|
|
496
523
|
}), this.wrapper), this._defaultInputText = "";
|
|
497
524
|
});
|
|
498
525
|
}
|
|
499
|
-
destroy(
|
|
500
|
-
x.render(/* @__PURE__ */ U(
|
|
526
|
+
destroy(i) {
|
|
527
|
+
x.render(/* @__PURE__ */ U(re, {}), this.wrapper, i);
|
|
501
528
|
}
|
|
502
529
|
}
|
|
503
530
|
export {
|
|
504
|
-
|
|
531
|
+
Ne as default
|
|
505
532
|
};
|