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