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