@glodon-aiot/agent-cli-ui 3.3.2-beta.14 → 3.3.2-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/es/AgentClientUI.mjs +119 -109
  2. package/dist/es/Dialog/AgentChat/index.mjs +281 -269
  3. package/dist/es/Dialog/SessionList/index.mjs +35 -34
  4. package/dist/es/Dialog/index.mjs +101 -94
  5. package/dist/es/components/FilePreview/index.mjs +26 -25
  6. package/dist/es/index.mjs +212 -182
  7. package/dist/es/packages/agent-cli-ui/package.json.mjs +3 -3
  8. package/dist/es/packages/react-components/dist/es/index.mjs +1 -1
  9. package/dist/es/src/style.css +1 -1
  10. package/dist/es/src/style10.css +1 -1
  11. package/dist/es/src/style11.css +1 -1
  12. package/dist/es/src/style12.css +1 -1
  13. package/dist/es/src/style13.css +1 -1
  14. package/dist/es/src/style14.css +1 -1
  15. package/dist/es/src/style15.css +1 -1
  16. package/dist/es/src/style16.css +1 -1
  17. package/dist/es/src/style17.css +1 -1
  18. package/dist/es/src/style18.css +1 -1
  19. package/dist/es/src/style19.css +1 -1
  20. package/dist/es/src/style20.css +1 -1
  21. package/dist/es/src/style21.css +1 -1
  22. package/dist/es/src/style22.css +1 -1
  23. package/dist/es/src/style23.css +1 -1
  24. package/dist/es/src/style24.css +1 -1
  25. package/dist/es/src/style25.css +1 -1
  26. package/dist/es/src/style26.css +1 -1
  27. package/dist/es/src/style27.css +1 -1
  28. package/dist/es/src/style28.css +1 -1
  29. package/dist/es/src/style29.css +1 -1
  30. package/dist/es/src/style3.css +1 -1
  31. package/dist/es/src/style30.css +1 -1
  32. package/dist/es/src/style31.css +1 -1
  33. package/dist/es/src/style4.css +1 -1
  34. package/dist/es/src/style5.css +1 -1
  35. package/dist/es/src/style6.css +1 -1
  36. package/dist/es/src/style7.css +1 -1
  37. package/dist/es/src/style8.css +1 -1
  38. package/dist/es/src/style9.css +1 -1
  39. package/dist/lib/index.css +1 -1
  40. package/dist/lib/index.js +30 -30
  41. package/dist/src/AgentClientUI.d.ts +10 -2
  42. package/dist/src/Dialog/SessionList/index.d.ts +1 -0
  43. package/dist/src/Dialog/index.d.ts +9 -1
  44. package/dist/src/index.d.ts +7 -2
  45. package/dist/src/types.d.ts +2 -1
  46. package/package.json +3 -3
package/dist/es/index.mjs CHANGED
@@ -1,189 +1,193 @@
1
- var ii = Object.defineProperty, ei = Object.defineProperties;
2
- var ti = Object.getOwnPropertyDescriptors;
3
- var Y = Object.getOwnPropertySymbols;
4
- var si = Object.prototype.hasOwnProperty, oi = Object.prototype.propertyIsEnumerable;
5
- var S = (f, e, r) => e in f ? ii(f, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : f[e] = r, n = (f, e) => {
6
- for (var r in e || (e = {}))
7
- si.call(e, r) && S(f, r, e[r]);
8
- if (Y)
9
- for (var r of Y(e))
10
- oi.call(e, r) && S(f, r, e[r]);
11
- return f;
12
- }, w = (f, e) => ei(f, ti(e));
13
- var l = (f, e, r) => (S(f, typeof e != "symbol" ? e + "" : e, r), r);
14
- var I = (f, e, r) => new Promise((c, u) => {
15
- var C = (h) => {
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(h));
18
- } catch (g) {
19
- u(g);
17
+ C(n.next(h));
18
+ } catch (d) {
19
+ f(d);
20
20
  }
21
- }, b = (h) => {
21
+ }, u = (h) => {
22
22
  try {
23
- v(r.throw(h));
24
- } catch (g) {
25
- u(g);
23
+ C(n.throw(h));
24
+ } catch (d) {
25
+ f(d);
26
26
  }
27
- }, v = (h) => h.done ? c(h.value) : Promise.resolve(h.value).then(C, b);
28
- v((r = r.apply(f, 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 ni } 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 ri from "./AgentClientUI.mjs";
34
- import { notification as Z } from "antd";
35
- import ai from "axios";
36
- import hi from "./packages/agent-cli-ui/package.json.mjs";
37
- import { defaultUIConfig as gi, defaultApiUrl as li, defaultDovViewerUrl as fi } from "./constant.mjs";
38
- import { ApiUrl as di } from "./types.mjs";
39
- /* empty css */import { BotClientApi as ui, ApplicationTypes as ci } from "@glodon-aiot/apis";
40
- import { JWT as pi, isExpired as mi } from "./utils/index.mjs";
41
- import { configuration as Ci, configure as q, 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", gi);
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, D, T, 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: c,
67
- mode: u = "float",
68
- triggerButton: C,
69
- size: b,
70
- apiUrl: v,
67
+ env: n,
68
+ token: g,
69
+ mode: f = "float",
70
+ triggerButton: c,
71
+ size: u,
72
+ apiUrl: C,
71
73
  docViewerUrl: h,
72
- errorHandlers: g,
73
- features: i,
74
+ errorHandlers: d,
75
+ features: e,
74
76
  sessionId: o,
75
77
  icon: t,
76
78
  logo: s,
77
79
  stream: a
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 = c, this.rId = 0, this._defatulSessionId = o, this.errorHandlers = n(n({}, this.errorHandlers), g);
84
- const d = {
85
- sessionOpen: u === "float",
86
- sessionList: u === "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");
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: (D = i == null ? void 0 : i.userMessageBox) == null ? void 0 : D.copy,
94
- userEdit: (T = i == null ? void 0 : i.userMessageBox) == null ? void 0 : T.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: u === "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
- }), u === "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), d), 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), d), 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 = u, this.env = r || "prod", this.stream = a, q({
148
+ this._mode = f, this.env = n || "prod", this.stream = a, ee({
147
149
  stream: this.stream
148
- }), this._applicationId = pi(c).rid, this.apiUrl = v || di[this.env] || li, this.docViewerUrl = h || fi, this.service = this.setService(), this.render();
150
+ }), this._applicationId = me(g).rid, this.apiUrl = C || ce[this.env] || de, this.docViewerUrl = h || ue, this.service = this.setService(), this.createBotClientSDK().then(() => {
151
+ this.render();
152
+ });
149
153
  }
150
154
  get token() {
151
155
  return this._token;
152
156
  }
153
- set token(e) {
154
- this._token = e, this.reload();
157
+ set token(i) {
158
+ this._token = i, this.reload();
155
159
  }
156
160
  get mode() {
157
161
  return this._mode;
158
162
  }
159
- set mode(e) {
160
- if (e === "inlay") {
161
- const r = {
162
- triggerButton: p({
163
+ set mode(i) {
164
+ if (i === "inlay") {
165
+ const n = {
166
+ triggerButton: b({
163
167
  visible: !1
164
168
  }, this.uiConfig.triggerButton),
165
169
  open: !0,
166
170
  resizable: !1,
167
- size: p({
171
+ size: b({
168
172
  width: "100%",
169
173
  height: "100%",
170
174
  maxWidth: "100%",
171
175
  maxHeight: "100%",
172
176
  minWidth: "100%"
173
177
  }, this.uiConfig.size),
174
- theme: p(this.uiConfig.theme, _),
178
+ theme: b(this.uiConfig.theme, I),
175
179
  history: !0
176
180
  };
177
- 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();
178
182
  } else {
179
- const r = {
180
- triggerButton: p(this.uiConfig.triggerButton, this.uiConfig.triggerButton),
181
- size: p(this.uiConfig.size, n({}, this.uiConfig.size)),
182
- 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)
183
187
  };
184
- 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);
185
189
  }
186
- this._mode = e;
190
+ this._mode = i, this.render();
187
191
  }
188
192
  get activeSession() {
189
193
  return this._activeSession;
@@ -192,12 +196,12 @@ class Ei {
192
196
  return this._applicationId;
193
197
  }
194
198
  setService() {
195
- const e = this.apiUrl, r = (h) => {
196
- var i;
197
- const g = this.token;
198
- if (!g)
199
+ const i = this.apiUrl, n = (h) => {
200
+ var e;
201
+ const d = this.token;
202
+ if (!d)
199
203
  return h;
200
- if (mi(g)) {
204
+ if (Ce(d)) {
201
205
  const o = "token is timeout";
202
206
  this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
203
207
  // @ts-ignore
@@ -209,53 +213,55 @@ class Ei {
209
213
  })
210
214
  ) : console.error("errorHandlers.token is not a function") : console.error(o);
211
215
  }
212
- return h.headers = (i = h.headers) != null ? i : {}, h.headers = w(n({}, h.headers), {
213
- Authorization: g ? `Bearer ${g}` : ""
216
+ return h.headers = (e = h.headers) != null ? e : {}, h.headers = w(r({}, h.headers), {
217
+ Authorization: d ? `Bearer ${d}` : ""
214
218
  }), h;
215
219
  };
216
- function c(h, g = !0) {
217
- const i = `${e}${h}`, o = ai.create({
218
- baseURL: i
220
+ function g(h, d = !0) {
221
+ const e = `${i}${h}`, o = ge.create({
222
+ baseURL: e
219
223
  });
220
- return g && o.interceptors.request.use(r), o;
224
+ return d && o.interceptors.request.use(n), o;
221
225
  }
222
- const u = (h, g) => {
226
+ const f = (h, d) => {
223
227
  if (h === 401) {
224
- const i = "token is invalid";
228
+ const e = "token is invalid";
225
229
  this.errorHandlers.token ? typeof this.errorHandlers.token == "function" ? this.errorHandlers.token(
226
230
  // @ts-ignore
227
- new Error(i, {
231
+ new Error(e, {
228
232
  cause: {
229
233
  status: 401,
230
- message: i
234
+ message: e
231
235
  }
232
236
  })
233
- ) : console.error("errorHandlers.token is not a function") : console.error(i);
237
+ ) : console.error("errorHandlers.token is not a function") : console.error(e);
234
238
  }
235
- }, C = (h, g, i) => {
236
- h !== 10001 && h !== 10215 && (i || (Z.config({
239
+ }, c = (h, d, e) => {
240
+ h !== 10001 && h !== 10215 && (e || (B.config({
237
241
  getContainer: this.uiConfig.getContainer
238
- }), Z.error({
239
- message: g
242
+ }), B.error({
243
+ message: d
244
+ }), B.config({
245
+ getContainer: void 0
240
246
  })));
241
- }, b = c("");
242
- return new ui(b, () => this.token, {
243
- onHttpStatusError: u,
244
- onAppStatusError: C
247
+ }, u = g("");
248
+ return new pe(u, () => this.token, {
249
+ onHttpStatusError: f,
250
+ onAppStatusError: c
245
251
  });
246
252
  }
247
253
  reload() {
248
- var e;
249
- 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(() => {
250
256
  this.service = this.setService(), this.rId = this.rId + 1, this.render();
251
257
  });
252
258
  }
253
- getMessageList(e) {
254
- var r, c;
255
- return e || (e = (r = this.activeSession) == null ? void 0 : r.id), !this.applicationId || !e ? Promise.resolve([]) : (c = this.service) == null ? void 0 : c.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);
256
262
  }
257
- input(e) {
258
- this._defaultInputText = e, this.render();
263
+ input(i) {
264
+ this._defaultInputText = i, this.render();
259
265
  }
260
266
  disable() {
261
267
  this._inputDisabled = !0, this.render();
@@ -263,15 +269,37 @@ class Ei {
263
269
  enable() {
264
270
  this._inputDisabled = !1, this.render();
265
271
  }
272
+ getSessionList() {
273
+ return this._agentClientRef.current ? new Promise((n, g) => {
274
+ var f, c;
275
+ (c = (f = this._agentClientRef.current) == null ? void 0 : f.getSessionList()) == null || c.then((u) => {
276
+ n(u);
277
+ }).catch((u) => {
278
+ g(u);
279
+ });
280
+ }) : Promise.reject(new Error("client is not loaded"));
281
+ }
282
+ sessionCreate(i) {
283
+ return this._agentClientRef.current ? new Promise((g, f) => {
284
+ var c, u;
285
+ (u = (c = this._agentClientRef.current) == null ? void 0 : c.sessionCreate(r({
286
+ name: "新建会话"
287
+ }, i))) == null || u.then((C) => {
288
+ g(C);
289
+ }).catch((C) => {
290
+ f(C);
291
+ });
292
+ }) : Promise.reject(new Error("client is not loaded"));
293
+ }
266
294
  createBotClientSDK() {
267
- return I(this, null, function* () {
268
- return new Promise((e, r) => {
295
+ return k(this, null, function* () {
296
+ return new Promise((i, n) => {
269
297
  if (this.token)
270
- q({
298
+ ee({
271
299
  debug: this.uiConfig.debug,
272
300
  env: this.uiConfig.env,
273
301
  apiRoot: this.apiUrl
274
- }), this.botClient = new bi(this.token, {
302
+ }), this.botClient = new ve(this.token, {
275
303
  plugins: this.uiConfig.plugins,
276
304
  mcp: this.uiConfig.mcp,
277
305
  stream: this.uiConfig.stream
@@ -282,10 +310,11 @@ class Ei {
282
310
  // 这里记录应用的名称和版本,以便后期数据分析
283
311
  ui: {
284
312
  name: "bot-client-ui",
285
- version: hi.version
313
+ version: le.version
286
314
  }
287
- }), this.botClient.ready ? e(this.botClient) : this.botClient.addEventListener("ready", () => I(this, null, function* () {
288
- this.botClient ? 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);
289
318
  }), !0);
290
319
  else
291
320
  throw Error("token is required");
@@ -293,12 +322,12 @@ class Ei {
293
322
  });
294
323
  }
295
324
  render() {
296
- return I(this, null, function* () {
297
- var r, c, u, C, b, v, h, g, i;
298
- let e = this.wrapper.getBoundingClientRect().height;
299
- if (this.wrapper.style.height = `${e}px`, yield this.createBotClientSDK(), !((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))
300
329
  throw Error("application is required");
301
- this.botClient.application.type === ci.Text ? x.render(/* @__PURE__ */ U(vi, {
330
+ this.botClient.application.type === q.Text ? x.render(/* @__PURE__ */ U(we, {
302
331
  rId: this.rId,
303
332
  application: this.botClient.application,
304
333
  sessionId: this._defatulSessionId,
@@ -306,7 +335,7 @@ class Ei {
306
335
  apiUrl: this.apiUrl,
307
336
  env: this.uiConfig.env,
308
337
  debug: this.uiConfig.debug,
309
- mode: "inlay",
338
+ mode: this.mode,
310
339
  token: this.token,
311
340
  className: this.mode,
312
341
  open: this.uiConfig.open,
@@ -315,7 +344,7 @@ class Ei {
315
344
  theme: this.uiConfig.theme,
316
345
  greeting: this.uiConfig.greeting,
317
346
  size: this.uiConfig.size,
318
- triggerButton: n({
347
+ triggerButton: r({
319
348
  visible: !0
320
349
  }, this.uiConfig.triggerButton),
321
350
  history: this.uiConfig.history,
@@ -323,8 +352,8 @@ class Ei {
323
352
  docViewerUrl: this.docViewerUrl,
324
353
  plugins: this.uiConfig.plugins,
325
354
  mcp: this.uiConfig.mcp,
326
- transform: w(n({}, this.uiConfig.transform), {
327
- knowledges: ((c = this.uiConfig.features) == null ? void 0 : c.knowledges) === !0 || typeof ((u = this.uiConfig.features) == null ? void 0 : u.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
328
357
  }),
329
358
  features: this.uiConfig.features,
330
359
  disabled: this._inputDisabled,
@@ -354,8 +383,8 @@ class Ei {
354
383
  return !0;
355
384
  try {
356
385
  return ((a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.beforemessagesend) == null ? void 0 : a.call(s, o)) || !1;
357
- } catch (d) {
358
- return console.error(d), !1;
386
+ } catch (m) {
387
+ return console.error(m), !1;
359
388
  }
360
389
  },
361
390
  onSessionUnload: (o) => {
@@ -375,8 +404,8 @@ class Ei {
375
404
  this._activeSession = o.session;
376
405
  try {
377
406
  (a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.sessionload) == null || a.call(s, o);
378
- } catch (d) {
379
- console.error(d);
407
+ } catch (m) {
408
+ console.error(m);
380
409
  }
381
410
  }
382
411
  },
@@ -385,8 +414,8 @@ class Ei {
385
414
  if (((t = this._activeSession) == null ? void 0 : t.id) === o.sessionId)
386
415
  try {
387
416
  (a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.historyload) == null || a.call(s, o);
388
- } catch (d) {
389
- console.error(d);
417
+ } catch (m) {
418
+ console.error(m);
390
419
  }
391
420
  },
392
421
  defaultInput: this._defaultInputText !== void 0 ? {
@@ -394,7 +423,8 @@ class Ei {
394
423
  } : void 0,
395
424
  bodyStyle: this.uiConfig.bodyStyle,
396
425
  stream: this.stream
397
- }), this.wrapper) : x.render(/* @__PURE__ */ U(ri, {
426
+ }), this.wrapper) : x.render(/* @__PURE__ */ U(he, {
427
+ ref: this._agentClientRef,
398
428
  rId: this.rId,
399
429
  application: this.botClient.application,
400
430
  agentClient: this.botClient,
@@ -412,7 +442,7 @@ class Ei {
412
442
  theme: this.uiConfig.theme,
413
443
  greeting: this.uiConfig.greeting,
414
444
  size: this.uiConfig.size,
415
- triggerButton: n({
445
+ triggerButton: r({
416
446
  visible: !0
417
447
  }, this.uiConfig.triggerButton),
418
448
  history: this.uiConfig.history,
@@ -420,8 +450,8 @@ class Ei {
420
450
  docViewerUrl: this.docViewerUrl,
421
451
  plugins: this.uiConfig.plugins,
422
452
  mcp: this.uiConfig.mcp,
423
- transform: w(n({}, this.uiConfig.transform), {
424
- knowledges: ((v = this.uiConfig.features) == null ? void 0 : v.knowledges) === !0 || typeof ((h = this.uiConfig.features) == null ? void 0 : h.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
425
455
  }),
426
456
  features: this.uiConfig.features,
427
457
  disabled: this._inputDisabled,
@@ -450,8 +480,8 @@ class Ei {
450
480
  return !0;
451
481
  try {
452
482
  return ((a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.beforemessagesend) == null ? void 0 : a.call(s, o)) || !1;
453
- } catch (d) {
454
- return console.error(d), !1;
483
+ } catch (m) {
484
+ return console.error(m), !1;
455
485
  }
456
486
  },
457
487
  onSessionUnload: (o) => {
@@ -471,8 +501,8 @@ class Ei {
471
501
  this._activeSession = o.session;
472
502
  try {
473
503
  (a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.sessionload) == null || a.call(s, o);
474
- } catch (d) {
475
- console.error(d);
504
+ } catch (m) {
505
+ console.error(m);
476
506
  }
477
507
  }
478
508
  },
@@ -481,8 +511,8 @@ class Ei {
481
511
  if (((t = this._activeSession) == null ? void 0 : t.id) === o.sessionId)
482
512
  try {
483
513
  (a = (s = this.uiConfig.eventListeners) == null ? void 0 : s.historyload) == null || a.call(s, o);
484
- } catch (d) {
485
- console.error(d);
514
+ } catch (m) {
515
+ console.error(m);
486
516
  }
487
517
  },
488
518
  defaultInput: this._defaultInputText !== void 0 ? {
@@ -493,10 +523,10 @@ class Ei {
493
523
  }), this.wrapper), this._defaultInputText = "";
494
524
  });
495
525
  }
496
- destroy(e) {
497
- x.render(/* @__PURE__ */ U(ni, {}), this.wrapper, e);
526
+ destroy(i) {
527
+ x.render(/* @__PURE__ */ U(re, {}), this.wrapper, i);
498
528
  }
499
529
  }
500
530
  export {
501
- Ei as default
531
+ Ne as default
502
532
  };
@@ -1,4 +1,4 @@
1
- const e = "@glodon-aiot/agent-cli-ui", t = "3.3.2-beta.14", s = "./dist/es/index.mjs", i = "./dist/lib/index.js", o = "./dist/src/index.d.ts", n = {
1
+ const e = "@glodon-aiot/agent-cli-ui", t = "3.3.2-beta.16", s = "./dist/es/index.mjs", i = "./dist/lib/index.js", o = "./dist/src/index.d.ts", n = {
2
2
  import: "./dist/es/index.mjs",
3
3
  require: "./dist/lib/index.js",
4
4
  types: "./dist/src/index.d.ts"
@@ -22,8 +22,8 @@ const e = "@glodon-aiot/agent-cli-ui", t = "3.3.2-beta.14", s = "./dist/es/index
22
22
  webpack: "*"
23
23
  }, p = {
24
24
  "@ant-design/icons": "^5.3.4",
25
- "@glodon-aiot/apis": "^3.3.2-beta.14",
26
- "@glodon-aiot/bot-client-sdk": "^3.3.2-beta.14",
25
+ "@glodon-aiot/apis": "^3.3.2-beta.16",
26
+ "@glodon-aiot/bot-client-sdk": "^3.3.2-beta.16",
27
27
  "@matejmazur/react-mathjax": "^0.1.10",
28
28
  "@react-pdf-viewer/core": "^3.12.0",
29
29
  "@react-pdf-viewer/default-layout": "^3.12.0",