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