@glodon-aiot/agent-cli-ui 3.3.5-alpha.28 → 3.3.5-beta.30
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/Dialog/AgentChat/index.mjs +175 -173
- package/dist/es/ReactTextGenerationUI/components/TextSiders/index.mjs +13 -13
- package/dist/es/components/Recommend/index.mjs +52 -34
- package/dist/es/constant.mjs +7 -3
- package/dist/es/index.mjs +117 -109
- 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/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/style21.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/style30.css +1 -1
- package/dist/es/src/style5.css +1 -1
- package/dist/es/src/style6.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 +36 -36
- package/dist/src/components/Recommend/index.d.ts +1 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/types.d.ts +1 -0
- package/package.json +3 -3
|
@@ -27,7 +27,7 @@ var p = (n, d, l) => new Promise((u, v) => {
|
|
|
27
27
|
x((l = l.apply(n, d)).next());
|
|
28
28
|
});
|
|
29
29
|
import { jsxs as w, jsx as o, Fragment as ve } from "react/jsx-runtime";
|
|
30
|
-
import { useState as h, useRef as Se, useContext as xe, useEffect as
|
|
30
|
+
import { useState as h, useRef as Se, useContext as xe, useEffect as N } from "react";
|
|
31
31
|
import { Form as M, Collapse as _, Input as K, Button as be, message as C, notification as Pe } from "antd";
|
|
32
32
|
import { PromptVariableType as y } from "@glodon-aiot/apis";
|
|
33
33
|
import { v4 as pe } from "uuid";
|
|
@@ -45,7 +45,7 @@ const {
|
|
|
45
45
|
sessionId: d,
|
|
46
46
|
docViewerUrl: l
|
|
47
47
|
}) => {
|
|
48
|
-
const u = n.id, [v, q] = h(""), [S, x] = h(""), [f, b] = h(), [L,
|
|
48
|
+
const u = n.id, [v, q] = h(""), [S, x] = h(""), [f, b] = h(), [L, T] = h(!1), D = Se(null), [H, ee] = h([]), [A, O] = h([]), [te, Y] = h(0), [$, j] = h(), [c, R] = h(), [E] = M.useForm(), [U, re] = h({}), [B, se] = h({}), [ne, ae] = h(0), {
|
|
49
49
|
service: g,
|
|
50
50
|
agentClient: I,
|
|
51
51
|
popupContainer: P,
|
|
@@ -131,7 +131,7 @@ const {
|
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
133
|
};
|
|
134
|
-
|
|
134
|
+
N(() => {
|
|
135
135
|
if (!(n != null && n.id))
|
|
136
136
|
return;
|
|
137
137
|
const e = n.arrange;
|
|
@@ -141,7 +141,7 @@ const {
|
|
|
141
141
|
ee(i), Y(i.length);
|
|
142
142
|
const t = i.map((r) => r.id);
|
|
143
143
|
O(t);
|
|
144
|
-
}, [n]),
|
|
144
|
+
}, [n]), N(() => {
|
|
145
145
|
if (!(n != null && n.id) || !I)
|
|
146
146
|
return;
|
|
147
147
|
const e = I.questionContextMaxLength || 4e3;
|
|
@@ -156,7 +156,7 @@ const {
|
|
|
156
156
|
});
|
|
157
157
|
j(e);
|
|
158
158
|
});
|
|
159
|
-
|
|
159
|
+
N(() => {
|
|
160
160
|
!u || !g || Promise.all([g.getApplicationIdPromptVariables(u, {
|
|
161
161
|
type: y.User,
|
|
162
162
|
status: 1
|
|
@@ -173,7 +173,7 @@ const {
|
|
|
173
173
|
}));
|
|
174
174
|
R(r);
|
|
175
175
|
});
|
|
176
|
-
}, [g, u]),
|
|
176
|
+
}, [g, u]), N(() => {
|
|
177
177
|
if (!c)
|
|
178
178
|
return;
|
|
179
179
|
const e = c.filter((r) => r.type === y.User), a = c.filter((r) => r.type === y.System), i = {};
|
|
@@ -197,7 +197,7 @@ const {
|
|
|
197
197
|
}, ue = () => p(void 0, null, function* () {
|
|
198
198
|
if (!u || !g || !I)
|
|
199
199
|
return;
|
|
200
|
-
|
|
200
|
+
T(!0);
|
|
201
201
|
for (const t in U)
|
|
202
202
|
U[t] || (C.config({
|
|
203
203
|
getContainer: () => (P == null ? void 0 : P.current) || document.body
|
|
@@ -224,8 +224,8 @@ const {
|
|
|
224
224
|
return s.value = m[0].value, s;
|
|
225
225
|
});
|
|
226
226
|
yield Promise.all(r.map((s) => ie(s.id, s.value))), R(r);
|
|
227
|
-
})).
|
|
228
|
-
|
|
227
|
+
})).catch((t) => {
|
|
228
|
+
console.log(t), T(!1);
|
|
229
229
|
});
|
|
230
230
|
const i = {
|
|
231
231
|
content: v,
|
|
@@ -236,21 +236,21 @@ const {
|
|
|
236
236
|
};
|
|
237
237
|
le(u, e.id, i, {
|
|
238
238
|
onmessage: (t) => {
|
|
239
|
-
|
|
239
|
+
b(void 0), x(t.content);
|
|
240
240
|
},
|
|
241
241
|
onclose: (t) => p(void 0, null, function* () {
|
|
242
|
-
if (
|
|
242
|
+
if (T(!1), t.code == 200) {
|
|
243
243
|
x(t.content);
|
|
244
244
|
const r = yield Promise.all(t.reference.map((s) => g.getKnowledgeIdFileId(s.knowledgeId, s.docId)));
|
|
245
245
|
t.reference = t.reference.map((s, m) => V(V({}, s), r[m])), b(t);
|
|
246
246
|
}
|
|
247
247
|
}),
|
|
248
248
|
onerror: () => {
|
|
249
|
-
|
|
249
|
+
T(!1);
|
|
250
250
|
}
|
|
251
251
|
});
|
|
252
252
|
});
|
|
253
|
-
|
|
253
|
+
N(() => {
|
|
254
254
|
if (!S)
|
|
255
255
|
return;
|
|
256
256
|
const e = D.current;
|
|
@@ -1,58 +1,76 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
/* empty css */import { Space as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
const
|
|
1
|
+
import { jsxs as h, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as N, useState as l, useImperativeHandle as q, useEffect as m } from "react";
|
|
3
|
+
/* empty css */import { Space as O, Row as b, Col as j } from "antd";
|
|
4
|
+
import k from "./tip.svg.mjs";
|
|
5
|
+
import B from "./RecommendItem.mjs";
|
|
6
|
+
const L = N((g, R) => {
|
|
7
7
|
const {
|
|
8
|
-
onItemClick:
|
|
8
|
+
onItemClick: v,
|
|
9
9
|
data: s,
|
|
10
|
-
isRecommendClearing:
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
isRecommendClearing: I,
|
|
11
|
+
layoutBreakpoints: a = [450]
|
|
12
|
+
// 默认临界值
|
|
13
|
+
} = g, [t, C] = l(), [x, u] = l(), [y, f] = l(!1), [z, Q] = l(2);
|
|
14
|
+
return q(R, () => ({
|
|
13
15
|
clear() {
|
|
14
|
-
|
|
16
|
+
u(void 0);
|
|
15
17
|
}
|
|
16
|
-
})),
|
|
18
|
+
})), m(() => {
|
|
19
|
+
const e = document.getElementById("dialog-modal");
|
|
20
|
+
if (!e)
|
|
21
|
+
return;
|
|
22
|
+
const n = (c) => {
|
|
23
|
+
const p = [...a].sort((d, E) => d - E), w = p.findIndex((d) => c < d);
|
|
24
|
+
return w === -1 ? p.length + 1 : w + 1;
|
|
25
|
+
}, i = () => {
|
|
26
|
+
const c = e.clientWidth;
|
|
27
|
+
Q(n(c));
|
|
28
|
+
};
|
|
29
|
+
i();
|
|
30
|
+
let o = null;
|
|
31
|
+
return window.ResizeObserver ? (o = new ResizeObserver(i), o.observe(e)) : window.addEventListener("resize", i), () => {
|
|
32
|
+
o == null || o.disconnect(), window.removeEventListener("resize", i);
|
|
33
|
+
};
|
|
34
|
+
}, [a]), m(() => {
|
|
17
35
|
if (s != null && s.length) {
|
|
18
|
-
|
|
36
|
+
C(s);
|
|
19
37
|
return;
|
|
20
38
|
}
|
|
21
|
-
}, [s]),
|
|
22
|
-
if (!
|
|
39
|
+
}, [s]), m(() => {
|
|
40
|
+
if (!t)
|
|
23
41
|
return;
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
}, [
|
|
42
|
+
const e = t.find((n) => n.file.url || n.icon || n.name);
|
|
43
|
+
f(!e);
|
|
44
|
+
}, [t]), /* @__PURE__ */ h("div", {
|
|
27
45
|
className: "questions",
|
|
28
|
-
children: [/* @__PURE__ */
|
|
46
|
+
children: [/* @__PURE__ */ h(O, {
|
|
29
47
|
size: 8,
|
|
30
48
|
className: "question-tip",
|
|
31
|
-
children: [/* @__PURE__ */
|
|
32
|
-
src:
|
|
49
|
+
children: [/* @__PURE__ */ r("img", {
|
|
50
|
+
src: k,
|
|
33
51
|
alt: ""
|
|
34
|
-
}), /* @__PURE__ */
|
|
52
|
+
}), /* @__PURE__ */ r("span", {
|
|
35
53
|
children: "请试试这样提问:"
|
|
36
54
|
})]
|
|
37
|
-
}), /* @__PURE__ */
|
|
55
|
+
}), /* @__PURE__ */ r(b, {
|
|
38
56
|
gutter: [12, 12],
|
|
39
57
|
wrap: !0,
|
|
40
58
|
className: "question-row",
|
|
41
|
-
children:
|
|
42
|
-
span:
|
|
43
|
-
children: /* @__PURE__ */
|
|
44
|
-
item:
|
|
45
|
-
isRecommendClearing:
|
|
46
|
-
isOnlyQuestion:
|
|
47
|
-
question:
|
|
48
|
-
setQuestion:
|
|
49
|
-
onItemClick:
|
|
59
|
+
children: t == null ? void 0 : t.map((e, n) => /* @__PURE__ */ r(j, {
|
|
60
|
+
span: 24 / z,
|
|
61
|
+
children: /* @__PURE__ */ r(B, {
|
|
62
|
+
item: e,
|
|
63
|
+
isRecommendClearing: I,
|
|
64
|
+
isOnlyQuestion: y,
|
|
65
|
+
question: x,
|
|
66
|
+
setQuestion: u,
|
|
67
|
+
onItemClick: v
|
|
50
68
|
})
|
|
51
69
|
}, n))
|
|
52
70
|
})]
|
|
53
71
|
});
|
|
54
72
|
});
|
|
55
|
-
|
|
73
|
+
L.displayName = "Recommend";
|
|
56
74
|
export {
|
|
57
|
-
|
|
75
|
+
L as default
|
|
58
76
|
};
|
package/dist/es/constant.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import e from "./assets/icon.svg.mjs";
|
|
|
2
2
|
import t from "./assets/brand.svg.mjs";
|
|
3
3
|
import o from "./assets/doc-icons/pdf.svg.mjs";
|
|
4
4
|
import r from "./assets/doc-icons/doc.svg.mjs";
|
|
5
|
-
import
|
|
5
|
+
import s from "./assets/doc-icons/docx.svg.mjs";
|
|
6
6
|
const u = {
|
|
7
7
|
triggerButton: {
|
|
8
8
|
visible: !0
|
|
@@ -52,7 +52,11 @@ const u = {
|
|
|
52
52
|
promptVariables: !0
|
|
53
53
|
},
|
|
54
54
|
features: {
|
|
55
|
-
greeting:
|
|
55
|
+
greeting: {
|
|
56
|
+
questions: !0,
|
|
57
|
+
layoutBreakpoints: [450]
|
|
58
|
+
// 默认临界值
|
|
59
|
+
},
|
|
56
60
|
sessionList: !0,
|
|
57
61
|
newSession: !0,
|
|
58
62
|
fileUpload: !0,
|
|
@@ -97,7 +101,7 @@ const u = {
|
|
|
97
101
|
}
|
|
98
102
|
}, c = "https://copilot.glodon.com/api/cvforcepd", f = "https://copilot.glodon.com/portal/_/aecpilot/fe/", m = 1024, d = 1024 * 1024, g = 1024 * 1024 * 1024, h = {
|
|
99
103
|
doc: r,
|
|
100
|
-
docx:
|
|
104
|
+
docx: s,
|
|
101
105
|
pdf: o
|
|
102
106
|
};
|
|
103
107
|
export {
|
package/dist/es/index.mjs
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
var D = Object.defineProperty, j = Object.defineProperties;
|
|
2
2
|
var F = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
4
|
-
var P = Object.prototype.hasOwnProperty,
|
|
5
|
-
var L = (m, s, n) => s in m ? D(m, s, { enumerable: !0, configurable: !0, writable: !0, value: n }) : m[s] = n,
|
|
3
|
+
var z = Object.getOwnPropertySymbols;
|
|
4
|
+
var P = Object.prototype.hasOwnProperty, W = 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, a = (m, s) => {
|
|
6
6
|
for (var n in s || (s = {}))
|
|
7
7
|
P.call(s, n) && L(m, n, s[n]);
|
|
8
|
-
if (
|
|
9
|
-
for (var n of
|
|
10
|
-
|
|
8
|
+
if (z)
|
|
9
|
+
for (var n of z(s))
|
|
10
|
+
W.call(s, n) && L(m, n, s[n]);
|
|
11
11
|
return m;
|
|
12
12
|
}, C = (m, s) => j(m, F(s));
|
|
13
|
-
var
|
|
14
|
-
var B = (m, s, n) => new Promise((e,
|
|
15
|
-
var
|
|
13
|
+
var f = (m, s, n) => (L(m, typeof s != "symbol" ? s + "" : s, n), n);
|
|
14
|
+
var B = (m, s, n) => new Promise((e, c) => {
|
|
15
|
+
var d = (h) => {
|
|
16
16
|
try {
|
|
17
|
-
u(n.next(
|
|
17
|
+
u(n.next(h));
|
|
18
18
|
} catch (l) {
|
|
19
|
-
|
|
19
|
+
c(l);
|
|
20
20
|
}
|
|
21
|
-
}, g = (
|
|
21
|
+
}, g = (h) => {
|
|
22
22
|
try {
|
|
23
|
-
u(n.throw(
|
|
23
|
+
u(n.throw(h));
|
|
24
24
|
} catch (l) {
|
|
25
|
-
|
|
25
|
+
c(l);
|
|
26
26
|
}
|
|
27
|
-
}, u = (
|
|
27
|
+
}, u = (h) => h.done ? e(h.value) : Promise.resolve(h.value).then(d, g);
|
|
28
28
|
u((n = n.apply(m, s)).next());
|
|
29
29
|
});
|
|
30
|
-
import { jsx as
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import { notification as
|
|
36
|
-
import
|
|
30
|
+
import { jsx as A } from "react/jsx-runtime";
|
|
31
|
+
import O from "react";
|
|
32
|
+
import v from "lodash/merge";
|
|
33
|
+
import H from "react-dom";
|
|
34
|
+
import $ from "./AgentClientUI.mjs";
|
|
35
|
+
import { notification as E } from "antd";
|
|
36
|
+
import K from "axios";
|
|
37
|
+
import { v4 as J } from "uuid";
|
|
37
38
|
import Q from "./packages/agent-cli-ui/package.json.mjs";
|
|
38
39
|
import { defaultUIConfig as N, defaultApiUrl as G, defaultDovViewerUrl as X } from "./constant.mjs";
|
|
39
40
|
import { ApiUrl as Y } from "./types.mjs";
|
|
@@ -41,37 +42,39 @@ import { ApiUrl as Y } from "./types.mjs";
|
|
|
41
42
|
import { JWT as q, isExpired as ee } from "./utils/index.mjs";
|
|
42
43
|
import { configuration as ie, configure as T, BotClient as te } from "@glodon-aiot/bot-client-sdk";
|
|
43
44
|
import se from "./ReactTextGenerationUI/index.mjs";
|
|
44
|
-
const
|
|
45
|
+
const M = {};
|
|
45
46
|
class we {
|
|
46
47
|
constructor(s) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
48
|
+
f(this, "_token");
|
|
49
|
+
f(this, "_activeSession", null);
|
|
50
|
+
f(this, "_applicationId");
|
|
51
|
+
f(this, "_defaultInputText", "");
|
|
52
|
+
f(this, "_inputDisabled", !1);
|
|
53
|
+
f(this, "_defatulSessionId", "");
|
|
54
|
+
f(this, "_agentClientRef", O.createRef());
|
|
55
|
+
f(this, "_config");
|
|
56
|
+
f(this, "_uuid", "");
|
|
57
|
+
f(this, "apiUrl");
|
|
58
|
+
f(this, "docViewerUrl");
|
|
59
|
+
f(this, "env", "prod");
|
|
60
|
+
f(this, "stream", ie.stream);
|
|
61
|
+
f(this, "service");
|
|
62
|
+
f(this, "rId", 0);
|
|
63
|
+
f(this, "_mode", "float");
|
|
64
|
+
f(this, "uiConfig", N);
|
|
65
|
+
f(this, "errorHandlers", {});
|
|
66
|
+
f(this, "wrapper", document.createElement("div"));
|
|
67
|
+
f(this, "botClient", null);
|
|
68
|
+
var _, w, y, I, S;
|
|
69
|
+
this._uuid = J();
|
|
67
70
|
const {
|
|
68
71
|
env: n,
|
|
69
72
|
token: e,
|
|
70
|
-
mode:
|
|
71
|
-
triggerButton:
|
|
73
|
+
mode: c = "float",
|
|
74
|
+
triggerButton: d,
|
|
72
75
|
size: g,
|
|
73
76
|
apiUrl: u,
|
|
74
|
-
docViewerUrl:
|
|
77
|
+
docViewerUrl: h,
|
|
75
78
|
errorHandlers: l,
|
|
76
79
|
features: t,
|
|
77
80
|
sessionId: i,
|
|
@@ -79,31 +82,31 @@ class we {
|
|
|
79
82
|
logo: r,
|
|
80
83
|
stream: p
|
|
81
84
|
} = 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(
|
|
83
|
-
greeting:
|
|
84
|
-
}) : this.uiConfig.features = C(
|
|
85
|
+
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(a({}, this.uiConfig.features), {
|
|
86
|
+
greeting: a(a({}, typeof ((_ = this.uiConfig.features) == null ? void 0 : _.greeting) != "object" ? {} : (w = this.uiConfig.features) == null ? void 0 : w.greeting), t.greeting)
|
|
87
|
+
}) : this.uiConfig.features = C(a({}, this.uiConfig.features), {
|
|
85
88
|
greeting: t.greeting
|
|
86
|
-
})), this._token = e, this.rId = 0, this._defatulSessionId = i, this.errorHandlers =
|
|
87
|
-
const
|
|
88
|
-
s.header !== void 0 && (
|
|
89
|
-
const
|
|
90
|
-
triggerButton:
|
|
91
|
-
size:
|
|
92
|
-
theme:
|
|
89
|
+
})), this._token = e, this.rId = 0, this._defatulSessionId = i, this.errorHandlers = a(a({}, this.errorHandlers), l), (S = (I = (y = t == null ? void 0 : t.botMessageBox) == null ? void 0 : y.footer) == null ? void 0 : I.items) == null || S.find((U) => U.componentName === "Copy");
|
|
90
|
+
const b = {};
|
|
91
|
+
s.header !== void 0 && (b.showHeader = !!s.header);
|
|
92
|
+
const k = {
|
|
93
|
+
triggerButton: v(this.uiConfig.triggerButton, d),
|
|
94
|
+
size: v(this.uiConfig.size, a({}, g)),
|
|
95
|
+
theme: v(this.uiConfig.theme, M)
|
|
93
96
|
};
|
|
94
|
-
this.updateUIConfig(
|
|
97
|
+
this.updateUIConfig(k, b), this.env = n || "prod", this.stream = p, T({
|
|
95
98
|
stream: this.stream
|
|
96
|
-
}), this._applicationId = q(e).rid, this.apiUrl = u || Y[this.env] || G, this.docViewerUrl =
|
|
97
|
-
this.mode =
|
|
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;
|
|
98
101
|
});
|
|
99
102
|
}
|
|
100
103
|
updateUIConfig(s, n) {
|
|
101
|
-
var u,
|
|
104
|
+
var u, h, l, t, i, o, r, p, b, k, _, w, y, I, S, U, V;
|
|
102
105
|
let e = this._config.features;
|
|
103
|
-
const
|
|
106
|
+
const c = {
|
|
104
107
|
sessionOpen: this._mode === "float",
|
|
105
108
|
sessionList: this._mode === "float"
|
|
106
|
-
},
|
|
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 = {
|
|
107
110
|
sessionList: e == null ? void 0 : e.sessionList,
|
|
108
111
|
sessionOpen: e == null ? void 0 : e.newSession,
|
|
109
112
|
fileUpload: e == null ? void 0 : e.fileUpload,
|
|
@@ -112,26 +115,29 @@ class we {
|
|
|
112
115
|
userPrompt: e == null ? void 0 : e.fileUpload,
|
|
113
116
|
prompt: e == null ? void 0 : e.prompts,
|
|
114
117
|
relate: (o = e == null ? void 0 : e.botMessageBox) == null ? void 0 : o.relatedQuesions,
|
|
115
|
-
again: !(
|
|
118
|
+
again: !(d && d.visible === !1),
|
|
116
119
|
reference: {
|
|
117
120
|
iconVisible: (p = (r = e == null ? void 0 : e.botMessageBox) == null ? void 0 : r.reference) == null ? void 0 : p.file,
|
|
118
|
-
referenceFirst: (
|
|
119
|
-
isExpand: (
|
|
121
|
+
referenceFirst: (b = e == null ? void 0 : e.botMessageBox) == null ? void 0 : b.referenceFirst,
|
|
122
|
+
isExpand: (_ = (k = e == null ? void 0 : e.botMessageBox) == null ? void 0 : k.reference) == null ? void 0 : _.itemExpanded
|
|
120
123
|
},
|
|
121
|
-
searchReference: (
|
|
124
|
+
searchReference: (w = e == null ? void 0 : e.botMessageBox) == null ? void 0 : w.searchReference,
|
|
122
125
|
knowledges: !!(e != null && e.knowledges),
|
|
123
126
|
metadata: e == null ? void 0 : e.metadata,
|
|
124
127
|
greet: (e == null ? void 0 : e.greeting) !== !1,
|
|
125
128
|
imageUpload: e == null ? void 0 : e.imageUpload,
|
|
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 ? (
|
|
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 : (
|
|
129
|
+
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 ? (S = this.uiConfig.transform) == null ? void 0 : S.promptVariables : !1,
|
|
130
|
+
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 : (V = this.uiConfig.transform) == null ? void 0 : V.connectNetwork)
|
|
128
131
|
};
|
|
129
132
|
Object.keys(g).forEach((x) => {
|
|
130
133
|
g[x] === void 0 && delete g[x];
|
|
131
|
-
}), this.uiConfig = C(
|
|
132
|
-
transform:
|
|
134
|
+
}), this.uiConfig = C(a(a(a(a(a({}, this.uiConfig), this._config), s), n), g), {
|
|
135
|
+
transform: a(a(a(a({}, this.uiConfig.transform), c), this._config.transform), g)
|
|
133
136
|
});
|
|
134
137
|
}
|
|
138
|
+
_initWrapper() {
|
|
139
|
+
this.wrapper.id !== this._uuid && (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
|
+
}
|
|
135
141
|
get token() {
|
|
136
142
|
return this._token;
|
|
137
143
|
}
|
|
@@ -142,33 +148,35 @@ class we {
|
|
|
142
148
|
return this._mode;
|
|
143
149
|
}
|
|
144
150
|
set mode(s) {
|
|
151
|
+
var e;
|
|
152
|
+
this._defatulSessionId = (e = this.activeSession) == null ? void 0 : e.id;
|
|
145
153
|
const n = {
|
|
146
154
|
sider: s === "inlay"
|
|
147
155
|
};
|
|
148
156
|
if (s === "inlay") {
|
|
149
|
-
const
|
|
150
|
-
triggerButton:
|
|
157
|
+
const c = {
|
|
158
|
+
triggerButton: v({
|
|
151
159
|
visible: !1
|
|
152
160
|
}, this.uiConfig.triggerButton),
|
|
153
161
|
open: !0,
|
|
154
162
|
resizable: !1,
|
|
155
|
-
size:
|
|
163
|
+
size: v({
|
|
156
164
|
width: "100%",
|
|
157
165
|
height: "100%",
|
|
158
166
|
maxWidth: "100%",
|
|
159
167
|
maxHeight: "100%",
|
|
160
168
|
minWidth: "100%"
|
|
161
169
|
}, this._config.size),
|
|
162
|
-
theme:
|
|
170
|
+
theme: v(this.uiConfig.theme, M),
|
|
163
171
|
history: !0
|
|
164
172
|
};
|
|
165
|
-
this.updateUIConfig(
|
|
173
|
+
this.updateUIConfig(c, n);
|
|
166
174
|
} else {
|
|
167
|
-
const
|
|
168
|
-
size:
|
|
169
|
-
theme:
|
|
175
|
+
const c = {
|
|
176
|
+
size: a(a(a({}, this.uiConfig.size), N.size), this._config.size),
|
|
177
|
+
theme: v(this.uiConfig.theme, M)
|
|
170
178
|
};
|
|
171
|
-
this.updateUIConfig(
|
|
179
|
+
this.updateUIConfig(c, n);
|
|
172
180
|
}
|
|
173
181
|
this._mode = s, this.render();
|
|
174
182
|
}
|
|
@@ -179,11 +187,11 @@ class we {
|
|
|
179
187
|
return this._applicationId;
|
|
180
188
|
}
|
|
181
189
|
setService() {
|
|
182
|
-
const s = this.apiUrl, n = (
|
|
190
|
+
const s = this.apiUrl, n = (h) => {
|
|
183
191
|
var t;
|
|
184
192
|
const l = this.token;
|
|
185
193
|
if (!l)
|
|
186
|
-
return
|
|
194
|
+
return h;
|
|
187
195
|
if (ee(l)) {
|
|
188
196
|
const i = "token is timeout";
|
|
189
197
|
this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
|
|
@@ -196,18 +204,18 @@ class we {
|
|
|
196
204
|
})
|
|
197
205
|
) : console.error("errorHandlers.token is not a function") : console.error(i);
|
|
198
206
|
}
|
|
199
|
-
return
|
|
207
|
+
return h.headers = (t = h.headers) != null ? t : {}, h.headers = C(a({}, h.headers), {
|
|
200
208
|
Authorization: l ? `Bearer ${l}` : ""
|
|
201
|
-
}),
|
|
209
|
+
}), h;
|
|
202
210
|
};
|
|
203
|
-
function e(
|
|
204
|
-
const t = `${s}${
|
|
211
|
+
function e(h, l = !0) {
|
|
212
|
+
const t = `${s}${h}`, i = K.create({
|
|
205
213
|
baseURL: t
|
|
206
214
|
});
|
|
207
215
|
return l && i.interceptors.request.use(n), i;
|
|
208
216
|
}
|
|
209
|
-
const
|
|
210
|
-
if (
|
|
217
|
+
const c = (h, l) => {
|
|
218
|
+
if (h === 401) {
|
|
211
219
|
const t = "token is invalid";
|
|
212
220
|
this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
|
|
213
221
|
// @ts-ignore
|
|
@@ -219,18 +227,18 @@ class we {
|
|
|
219
227
|
})
|
|
220
228
|
) : console.error("errorHandlers.token is not a function") : console.error(t);
|
|
221
229
|
}
|
|
222
|
-
},
|
|
223
|
-
|
|
230
|
+
}, d = (h, l, t) => {
|
|
231
|
+
h !== 10001 && h !== 10215 && (t || (E.config({
|
|
224
232
|
getContainer: this.uiConfig.getContainer
|
|
225
|
-
}),
|
|
233
|
+
}), E.error({
|
|
226
234
|
message: l
|
|
227
|
-
}),
|
|
235
|
+
}), E.config({
|
|
228
236
|
getContainer: void 0
|
|
229
237
|
})));
|
|
230
238
|
}, g = e("");
|
|
231
239
|
return new Z(g, () => this.token, {
|
|
232
|
-
onHttpStatusError:
|
|
233
|
-
onAppStatusError:
|
|
240
|
+
onHttpStatusError: c,
|
|
241
|
+
onAppStatusError: d
|
|
234
242
|
});
|
|
235
243
|
}
|
|
236
244
|
reload() {
|
|
@@ -256,8 +264,8 @@ class we {
|
|
|
256
264
|
}
|
|
257
265
|
getSessionList() {
|
|
258
266
|
return this._agentClientRef.current ? new Promise((n, e) => {
|
|
259
|
-
var
|
|
260
|
-
(
|
|
267
|
+
var c, d;
|
|
268
|
+
(d = (c = this._agentClientRef.current) == null ? void 0 : c.getSessionList()) == null || d.then((g) => {
|
|
261
269
|
n(g);
|
|
262
270
|
}).catch((g) => {
|
|
263
271
|
e(g);
|
|
@@ -265,14 +273,14 @@ class we {
|
|
|
265
273
|
}) : Promise.reject(new Error("client is not loaded"));
|
|
266
274
|
}
|
|
267
275
|
createSession(s) {
|
|
268
|
-
return this._agentClientRef.current ? new Promise((e,
|
|
269
|
-
var
|
|
270
|
-
(g = (
|
|
276
|
+
return this._agentClientRef.current ? new Promise((e, c) => {
|
|
277
|
+
var d, g;
|
|
278
|
+
(g = (d = this._agentClientRef.current) == null ? void 0 : d.createSession(a({
|
|
271
279
|
name: "新建会话"
|
|
272
280
|
}, s))) == null || g.then((u) => {
|
|
273
281
|
e(u);
|
|
274
282
|
}).catch((u) => {
|
|
275
|
-
|
|
283
|
+
c(u);
|
|
276
284
|
});
|
|
277
285
|
}) : Promise.reject(new Error("client is not loaded"));
|
|
278
286
|
}
|
|
@@ -308,10 +316,10 @@ class we {
|
|
|
308
316
|
}
|
|
309
317
|
render() {
|
|
310
318
|
return B(this, null, function* () {
|
|
311
|
-
var s, n, e,
|
|
319
|
+
var s, n, e, c, d, g, u, h, l;
|
|
312
320
|
if (this.wrapper.style.height = "100%", !((s = this.botClient) != null && s.application))
|
|
313
321
|
throw Error("application is required");
|
|
314
|
-
this.botClient.application.type === R.Text ?
|
|
322
|
+
this.botClient.application.type === R.Text ? H.render(/* @__PURE__ */ A(se, {
|
|
315
323
|
rId: this.rId,
|
|
316
324
|
application: this.botClient.application,
|
|
317
325
|
sessionId: this._defatulSessionId,
|
|
@@ -328,7 +336,7 @@ class we {
|
|
|
328
336
|
theme: this.uiConfig.theme,
|
|
329
337
|
greeting: this.uiConfig.greeting,
|
|
330
338
|
size: this.uiConfig.size,
|
|
331
|
-
triggerButton:
|
|
339
|
+
triggerButton: a({
|
|
332
340
|
visible: !0
|
|
333
341
|
}, this.uiConfig.triggerButton),
|
|
334
342
|
history: this.uiConfig.history,
|
|
@@ -336,8 +344,8 @@ class we {
|
|
|
336
344
|
docViewerUrl: this.docViewerUrl,
|
|
337
345
|
plugins: this.uiConfig.plugins,
|
|
338
346
|
mcp: this.uiConfig.mcp,
|
|
339
|
-
transform: C(
|
|
340
|
-
knowledges: ((n = this.uiConfig.features) == null ? void 0 : n.knowledges) === !0 || typeof ((e = this.uiConfig.features) == null ? void 0 : e.knowledges) == "object" && ((
|
|
347
|
+
transform: C(a({}, this.uiConfig.transform), {
|
|
348
|
+
knowledges: ((n = this.uiConfig.features) == null ? void 0 : n.knowledges) === !0 || typeof ((e = this.uiConfig.features) == null ? void 0 : e.knowledges) == "object" && ((d = (c = this.uiConfig.features) == null ? void 0 : c.knowledges) == null ? void 0 : d.visible) !== !1
|
|
341
349
|
}),
|
|
342
350
|
features: this.uiConfig.features,
|
|
343
351
|
disabled: this._inputDisabled,
|
|
@@ -407,7 +415,7 @@ class we {
|
|
|
407
415
|
} : void 0,
|
|
408
416
|
bodyStyle: this.uiConfig.bodyStyle,
|
|
409
417
|
stream: this.stream
|
|
410
|
-
}), this.wrapper) :
|
|
418
|
+
}), this.wrapper) : H.render(/* @__PURE__ */ A($, {
|
|
411
419
|
ref: this._agentClientRef,
|
|
412
420
|
rId: this.rId,
|
|
413
421
|
application: this.botClient.application,
|
|
@@ -426,7 +434,7 @@ class we {
|
|
|
426
434
|
theme: this.uiConfig.theme,
|
|
427
435
|
greeting: this.uiConfig.greeting,
|
|
428
436
|
size: this.uiConfig.size,
|
|
429
|
-
triggerButton:
|
|
437
|
+
triggerButton: a({
|
|
430
438
|
visible: !0
|
|
431
439
|
}, this.uiConfig.triggerButton),
|
|
432
440
|
history: this.uiConfig.history,
|
|
@@ -434,8 +442,8 @@ class we {
|
|
|
434
442
|
docViewerUrl: this.docViewerUrl,
|
|
435
443
|
plugins: this.uiConfig.plugins,
|
|
436
444
|
mcp: this.uiConfig.mcp,
|
|
437
|
-
transform: C(
|
|
438
|
-
knowledges: ((g = this.uiConfig.features) == null ? void 0 : g.knowledges) === !0 || typeof ((u = this.uiConfig.features) == null ? void 0 : u.knowledges) == "object" && ((l = (
|
|
445
|
+
transform: C(a({}, this.uiConfig.transform), {
|
|
446
|
+
knowledges: ((g = this.uiConfig.features) == null ? void 0 : g.knowledges) === !0 || typeof ((u = this.uiConfig.features) == null ? void 0 : u.knowledges) == "object" && ((l = (h = this.uiConfig.features) == null ? void 0 : h.knowledges) == null ? void 0 : l.visible) !== !1
|
|
439
447
|
}),
|
|
440
448
|
features: this.uiConfig.features,
|
|
441
449
|
disabled: this._inputDisabled,
|
|
@@ -508,7 +516,7 @@ class we {
|
|
|
508
516
|
});
|
|
509
517
|
}
|
|
510
518
|
destroy(s) {
|
|
511
|
-
|
|
519
|
+
H.unmountComponentAtNode(this.wrapper), this.wrapper && this.wrapper.remove(), s == null || s();
|
|
512
520
|
}
|
|
513
521
|
}
|
|
514
522
|
export {
|