@glodon-aiot/agent-cli-ui 3.3.2-beta.15 → 3.3.2-beta.17

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