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