@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 CHANGED
@@ -1,147 +1,152 @@
1
- var ie = Object.defineProperty, te = Object.defineProperties;
2
- var se = Object.getOwnPropertyDescriptors;
3
- var Y = Object.getOwnPropertySymbols;
4
- var oe = Object.prototype.hasOwnProperty, ne = Object.prototype.propertyIsEnumerable;
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) => {
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
- p(o.next(a));
18
- } catch (f) {
19
- g(f);
17
+ u(n.next(a));
18
+ } catch (l) {
19
+ d(l);
20
20
  }
21
- }, c = (a) => {
21
+ }, g = (a) => {
22
22
  try {
23
- p(o.throw(a));
24
- } catch (f) {
25
- g(f);
23
+ u(n.throw(a));
24
+ } catch (l) {
25
+ d(l);
26
26
  }
27
- }, p = (a) => a.done ? h(a.value) : Promise.resolve(a.value).then(u, c);
28
- p((o = o.apply(d, t)).next());
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 k, Fragment as re } from "react/jsx-runtime";
31
- import ae from "react";
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 I from "react-dom";
34
- import he from "./AgentClientUI.mjs";
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
- import { JWT as me, isExpired as Ce } from "./utils/index.mjs";
42
- import { configuration as be, configure as q, BotClient as ve } from "@glodon-aiot/bot-client-sdk";
43
- import we from "./ReactTextGenerationUI/index.mjs";
44
- const U = {};
45
- class Te {
46
- constructor(t) {
47
- l(this, "_token");
48
- l(this, "_activeSession", null);
49
- l(this, "_applicationId");
50
- l(this, "_defaultInputText", "");
51
- l(this, "_inputDisabled", !1);
52
- l(this, "_defatulSessionId", "");
53
- l(this, "_agentClientRef", ae.createRef());
54
- l(this, "apiUrl");
55
- l(this, "docViewerUrl");
56
- l(this, "env", "prod");
57
- l(this, "stream", be.stream);
58
- l(this, "service");
59
- l(this, "rId", 0);
60
- l(this, "_mode", "float");
61
- l(this, "uiConfig", fe);
62
- l(this, "errorHandlers", {});
63
- l(this, "wrapper", document.createElement("div"));
64
- l(this, "botClient", null);
65
- var B, H, E, M, V, A, N, R, T, z, j, D, F, P, O, $, W, J, K, Q, G, X;
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: o,
68
- token: h,
69
- mode: g = "float",
70
- triggerButton: u,
71
- size: c,
72
- apiUrl: p,
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: f,
75
- features: e,
75
+ errorHandlers: l,
76
+ features: t,
76
77
  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
- greeting: e.greeting
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 = {
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: (T = e == null ? void 0 : e.userMessageBox) == null ? void 0 : T.copy,
93
- userEdit: (z = e == null ? void 0 : e.userMessageBox) == null ? void 0 : z.editAgain,
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: (j = e == null ? void 0 : e.botMessageBox) == null ? void 0 : j.relatedQuesions,
97
- again: !(x && x.visible === !1),
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: (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
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: (W = e == null ? void 0 : e.botMessageBox) == null ? void 0 : W.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 ? (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)
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
- 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({
122
- stream: this.stream
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(t) {
131
- this._token = t, this.reload();
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(t) {
137
- const o = {
138
- sessionOpen: t === "float",
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 (t === "inlay") {
144
- const g = {
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.uiConfig.size),
157
- theme: b(this.uiConfig.theme, U),
161
+ }, this._config.size),
162
+ theme: b(this.uiConfig.theme, V),
158
163
  history: !0
159
164
  };
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);
165
+ this.updateUIConfig(e, n), this.uiConfig.getContainer().append(this.wrapper);
163
166
  } else {
164
- const g = {
165
- theme: b(this.uiConfig.theme, U)
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.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);
171
+ this.updateUIConfig(e, n), this._mode === "inlay" && this.wrapper.remove(), this.uiConfig.getContainer().append(this.wrapper);
170
172
  }
171
- this._mode = t, this.render();
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 t = this.apiUrl, o = (a) => {
181
- var e;
182
- const f = this.token;
183
- if (!f)
182
+ const s = this.apiUrl, n = (a) => {
183
+ var t;
184
+ const l = this.token;
185
+ if (!l)
184
186
  return a;
185
- if (Ce(f)) {
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 = (e = a.headers) != null ? e : {}, a.headers = C(r({}, a.headers), {
198
- Authorization: f ? `Bearer ${f}` : ""
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 h(a, f = !0) {
202
- const e = `${t}${a}`, i = le.create({
203
- baseURL: e
203
+ function e(a, l = !0) {
204
+ const t = `${s}${a}`, i = J.create({
205
+ baseURL: t
204
206
  });
205
- return f && i.interceptors.request.use(o), i;
207
+ return l && i.interceptors.request.use(n), i;
206
208
  }
207
- const g = (a, f) => {
209
+ const d = (a, l) => {
208
210
  if (a === 401) {
209
- const e = "token is invalid";
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(e, {
214
+ new Error(t, {
213
215
  cause: {
214
216
  status: 401,
215
- message: e
217
+ message: t
216
218
  }
217
219
  })
218
- ) : console.error("errorHandlers.token is not a function") : console.error(e);
220
+ ) : console.error("errorHandlers.token is not a function") : console.error(t);
219
221
  }
220
- }, u = (a, f, e) => {
221
- a !== 10001 && a !== 10215 && (e || (S.config({
222
+ }, f = (a, l, t) => {
223
+ a !== 10001 && a !== 10215 && (t || (M.config({
222
224
  getContainer: this.uiConfig.getContainer
223
- }), S.error({
224
- message: f
225
- }), S.config({
225
+ }), M.error({
226
+ message: l
227
+ }), M.config({
226
228
  getContainer: void 0
227
229
  })));
228
- }, c = h("");
229
- return new pe(c, () => this.token, {
230
- onHttpStatusError: g,
231
- onAppStatusError: u
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 t;
236
- this._defatulSessionId = (t = this.activeSession) == null ? void 0 : t.id, this.destroy(() => {
237
- this.service = this.setService(), this.rId = this.rId + 1, this.render();
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(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);
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(t) {
245
- this._defaultInputText = t, this.render();
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((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);
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(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({
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
- }, t))) == null || c.then((p) => {
269
- h(p);
270
- }).catch((p) => {
271
- g(p);
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 y(this, null, function* () {
277
- return new Promise((t, o) => {
280
+ return B(this, null, function* () {
281
+ return new Promise((s, n) => {
278
282
  if (this.token)
279
- q({
283
+ T({
280
284
  debug: this.uiConfig.debug,
281
285
  env: this.uiConfig.env,
282
286
  apiRoot: this.apiUrl
283
- }), this.botClient = new ve(this.token, {
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: ge.version
298
+ version: Q.version
295
299
  }
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);
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 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))
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 === Z.Text ? I.render(/* @__PURE__ */ k(we, {
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: r({
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(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
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: (e) => {
343
- var i, s;
346
+ onComment: (t) => {
347
+ var i, o;
344
348
  try {
345
- (s = (i = this.uiConfig.eventListeners) == null ? void 0 : i.comment) == null || s.call(i, e);
346
- } catch (n) {
347
- console.error(n);
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: (e) => {
352
- var i, s;
353
- if (e.message.messageId)
355
+ onMessage: (t) => {
356
+ var i, o;
357
+ if (t.message.messageId)
354
358
  try {
355
- (s = (i = this.uiConfig.eventListeners) == null ? void 0 : i.message) == null || s.call(i, e);
356
- } catch (n) {
357
- console.error(n);
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: (e) => {
361
- var i, s, n;
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 ((n = (s = this.uiConfig.eventListeners) == null ? void 0 : s.beforemessagesend) == null ? void 0 : n.call(s, e)) || !1;
366
- } catch (m) {
367
- return console.error(m), !1;
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: (e) => {
371
- var i, s;
374
+ onSessionUnload: (t) => {
375
+ var i, o;
372
376
  this._activeSession = null;
373
377
  try {
374
- (s = (i = this.uiConfig.eventListeners) == null ? void 0 : i.sessionunload) == null || s.call(i, e);
375
- } catch (n) {
376
- console.error(n);
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: (e) => {
380
- var i, s, n;
381
- if (((i = this._activeSession) == null ? void 0 : i.id) === e.sessionId)
382
- this._activeSession = e.session;
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 = e.session;
388
+ this._activeSession = t.session;
385
389
  try {
386
- (n = (s = this.uiConfig.eventListeners) == null ? void 0 : s.sessionload) == null || n.call(s, e);
387
- } catch (m) {
388
- console.error(m);
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: (e) => {
393
- var i, s, n;
394
- if (((i = this._activeSession) == null ? void 0 : i.id) === e.sessionId)
396
+ onHistoryLoad: (t) => {
397
+ var i, o, r;
398
+ if (((i = this._activeSession) == null ? void 0 : i.id) === t.sessionId)
395
399
  try {
396
- (n = (s = this.uiConfig.eventListeners) == null ? void 0 : s.historyload) == null || n.call(s, e);
397
- } catch (m) {
398
- console.error(m);
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) : I.render(/* @__PURE__ */ k(he, {
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: r({
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(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
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: (e) => {
441
- var i, s;
444
+ onComment: (t) => {
445
+ var i, o;
442
446
  try {
443
- (s = (i = this.uiConfig.eventListeners) == null ? void 0 : i.comment) == null || s.call(i, e);
444
- } catch (n) {
445
- console.error(n);
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: (e) => {
449
- var i, s;
450
- if (e.message.messageId)
452
+ onMessage: (t) => {
453
+ var i, o;
454
+ if (t.message.messageId)
451
455
  try {
452
- (s = (i = this.uiConfig.eventListeners) == null ? void 0 : i.message) == null || s.call(i, e);
453
- } catch (n) {
454
- console.error(n);
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: (e) => {
458
- var i, s, n;
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 ((n = (s = this.uiConfig.eventListeners) == null ? void 0 : s.beforemessagesend) == null ? void 0 : n.call(s, e)) || !1;
463
- } catch (m) {
464
- return console.error(m), !1;
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: (e) => {
468
- var i, s;
471
+ onSessionUnload: (t) => {
472
+ var i, o;
469
473
  this._activeSession = null;
470
474
  try {
471
- (s = (i = this.uiConfig.eventListeners) == null ? void 0 : i.sessionunload) == null || s.call(i, e);
472
- } catch (n) {
473
- console.error(n);
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: (e) => {
477
- var i, s, n;
478
- if (((i = this._activeSession) == null ? void 0 : i.id) === e.sessionId)
479
- this._activeSession = e.session;
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 = e.session;
485
+ this._activeSession = t.session;
482
486
  try {
483
- (n = (s = this.uiConfig.eventListeners) == null ? void 0 : s.sessionload) == null || n.call(s, e);
484
- } catch (m) {
485
- console.error(m);
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: (e) => {
490
- var i, s, n;
491
- if (((i = this._activeSession) == null ? void 0 : i.id) === e.sessionId)
493
+ onHistoryLoad: (t) => {
494
+ var i, o, r;
495
+ if (((i = this._activeSession) == null ? void 0 : i.id) === t.sessionId)
492
496
  try {
493
- (n = (s = this.uiConfig.eventListeners) == null ? void 0 : s.historyload) == null || n.call(s, e);
494
- } catch (m) {
495
- console.error(m);
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(t) {
507
- I.render(/* @__PURE__ */ k(re, {}), this.wrapper, t);
510
+ destroy(s) {
511
+ E.render(/* @__PURE__ */ H($, {}), this.wrapper, s);
508
512
  }
509
513
  }
510
514
  export {
511
- Te as default
515
+ we as default
512
516
  };