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