@glodon-aiot/agent-cli-ui 3.3.5-alpha.21 → 3.3.5-alpha.23

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.
@@ -1,149 +1,136 @@
1
- var z = Object.defineProperty, ee = Object.defineProperties;
2
- var te = Object.getOwnPropertyDescriptors;
1
+ var Q = Object.defineProperty, T = Object.defineProperties;
2
+ var X = Object.getOwnPropertyDescriptors;
3
3
  var y = Object.getOwnPropertySymbols;
4
- var oe = Object.prototype.hasOwnProperty, ne = Object.prototype.propertyIsEnumerable;
5
- var I = (n, t, e) => t in n ? z(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, f = (n, t) => {
4
+ var Y = Object.prototype.hasOwnProperty, Z = Object.prototype.propertyIsEnumerable;
5
+ var R = (o, t, e) => t in o ? Q(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, f = (o, t) => {
6
6
  for (var e in t || (t = {}))
7
- oe.call(t, e) && I(n, e, t[e]);
7
+ Y.call(t, e) && R(o, e, t[e]);
8
8
  if (y)
9
9
  for (var e of y(t))
10
- ne.call(t, e) && I(n, e, t[e]);
11
- return n;
12
- }, h = (n, t) => ee(n, te(t));
10
+ Z.call(t, e) && R(o, e, t[e]);
11
+ return o;
12
+ }, g = (o, t) => T(o, X(t));
13
13
  import { jsx as s, jsxs as x } from "react/jsx-runtime";
14
- import { forwardRef as ie, useRef as k, useState as d, useEffect as A, useImperativeHandle as se } from "react";
15
- /* empty css */import { AgentClientProvider as le } from "./context.mjs";
16
- import { Resizable as ae } from "react-resizable";
17
- import re from "./Dialog/index.mjs";
18
- import { configure as de, BotClient as me } from "@glodon-aiot/bot-client-sdk";
19
- import { JWT as ce } from "./utils/index.mjs";
20
- import { ConfigProvider as L, Spin as fe, Button as U } from "antd";
21
- import he from "antd/es/locale/zh_CN";
22
- const ke = ie((n, t) => {
14
+ import { forwardRef as _, useRef as U, useState as r, useEffect as k, useImperativeHandle as B } from "react";
15
+ /* empty css */import { AgentClientProvider as z } from "./context.mjs";
16
+ import { Resizable as ee } from "react-resizable";
17
+ import te from "./Dialog/index.mjs";
18
+ import { ConfigProvider as A, Spin as ne, Button as L } from "antd";
19
+ import oe from "antd/es/locale/zh_CN";
20
+ const Ne = _((o, t) => {
23
21
  const {
24
22
  className: e,
25
23
  triggerButton: l,
26
- size: o,
24
+ size: n,
27
25
  theme: $,
28
- icon: g,
26
+ icon: p,
29
27
  docViewerUrl: H,
30
- token: m,
31
- debug: W,
32
- env: j,
33
- plugins: M,
34
- mcp: P,
35
- footer: S,
36
- defaultInput: T,
37
- onComment: D,
38
- onSessionLoad: E,
39
- onSessionUnload: J,
40
- onMessage: O,
41
- beforeMessageSend: V,
42
- bodyStyle: p,
43
- apiUrl: q,
44
- sessionId: F,
45
- disabled: G,
46
- transform: K,
47
- features: Q,
48
- stream: X
49
- } = n, u = k(null), [Y, ge] = d(!1), [C, Z] = d(), [b, _] = d(), [i, w] = d(o), [v, N] = d(n.open), c = k(null);
50
- A(() => {
51
- if (!m)
52
- return;
53
- const a = ce(m);
54
- Z(a.rid), de({
55
- debug: W,
56
- env: j,
57
- apiRoot: q
58
- });
59
- const r = new me(m, {
60
- plugins: M,
61
- mcp: P,
62
- stream: X
63
- });
64
- _(r);
65
- }, [m]), L.config({
28
+ token: ie,
29
+ debug: se,
30
+ env: le,
31
+ plugins: ae,
32
+ mcp: de,
33
+ footer: j,
34
+ defaultInput: M,
35
+ onComment: P,
36
+ onSessionLoad: S,
37
+ onSessionUnload: W,
38
+ onMessage: D,
39
+ beforeMessageSend: E,
40
+ bodyStyle: u,
41
+ apiUrl: re,
42
+ sessionId: O,
43
+ disabled: V,
44
+ transform: q,
45
+ features: F,
46
+ stream: me,
47
+ agentClient: m,
48
+ application: d
49
+ } = o, b = U(null), [G, ce] = r(!1), [C, J] = r(), [i, v] = r(n), [w, N] = r(o.open), c = U(null);
50
+ k(() => {
51
+ d && (console.log("[AgentClientUI] token", m, d), J(d.id));
52
+ }, [d]), A.config({
66
53
  theme: $
67
- }), A(() => {
68
- o && w(o);
69
- }, [o]);
70
- const B = (a, {
71
- element: r,
72
- size: R
54
+ }), k(() => {
55
+ n && v(n);
56
+ }, [n]);
57
+ const K = (a, {
58
+ element: h,
59
+ size: I
73
60
  }) => {
74
- w({
75
- width: Number(R.width),
76
- height: R.height
61
+ v({
62
+ width: Number(I.width),
63
+ height: I.height
77
64
  });
78
65
  };
79
- return se(t, () => ({
66
+ return B(t, () => ({
80
67
  sessionCreate: (a) => {
81
- var r;
82
- return (r = c.current) == null ? void 0 : r.sessionCreate(a);
68
+ var h;
69
+ return (h = c.current) == null ? void 0 : h.sessionCreate(a);
83
70
  },
84
71
  getSessionList: () => {
85
72
  var a;
86
73
  return (a = c.current) == null ? void 0 : a.getSessionList();
87
74
  }
88
- })), /* @__PURE__ */ s(L, {
89
- locale: he,
90
- children: /* @__PURE__ */ x(le, {
91
- value: h(f({}, n), {
92
- popupContainer: u,
93
- agentClient: b,
94
- footer: S,
95
- defaultInput: T,
96
- onComment: D,
97
- onSessionLoad: E,
98
- onSessionUnload: J,
99
- onMessage: O,
100
- beforeMessageSend: V,
101
- bodyStyle: p,
102
- disabled: G,
103
- transform: K,
104
- features: Q
75
+ })), /* @__PURE__ */ s(A, {
76
+ locale: oe,
77
+ children: /* @__PURE__ */ x(z, {
78
+ value: g(f({}, o), {
79
+ popupContainer: b,
80
+ agentClient: m,
81
+ footer: j,
82
+ defaultInput: M,
83
+ onComment: P,
84
+ onSessionLoad: S,
85
+ onSessionUnload: W,
86
+ onMessage: D,
87
+ beforeMessageSend: E,
88
+ bodyStyle: u,
89
+ disabled: V,
90
+ transform: q,
91
+ features: F
105
92
  }),
106
- children: [/* @__PURE__ */ s(ae, {
93
+ children: [/* @__PURE__ */ s(ee, {
107
94
  height: (i == null ? void 0 : i.height) || "100%",
108
95
  width: (i == null ? void 0 : i.width) || "100%",
109
96
  maxConstraints: [document.body.clientWidth - 45],
110
- minConstraints: [Number(o == null ? void 0 : o.minWidth)],
111
- onResize: B,
97
+ minConstraints: [Number(n == null ? void 0 : n.minWidth)],
98
+ onResize: K,
112
99
  handle: /* @__PURE__ */ s("span", {
113
100
  className: "resize-handle-ew"
114
101
  }),
115
102
  resizeHandles: e == "float" ? ["w"] : [],
116
103
  children: /* @__PURE__ */ x("div", {
117
104
  id: "dialog-modal",
118
- className: `gbot-dialog-modal ${e} ${v ? "opened" : "closed"}`,
119
- style: h(f({}, o), {
120
- width: e == "float" ? i == null ? void 0 : i.width : o == null ? void 0 : o.width,
121
- height: e === "float" ? i == null ? void 0 : i.height : o == null ? void 0 : o.height,
105
+ className: `gbot-dialog-modal ${e} ${w ? "opened" : "closed"}`,
106
+ style: g(f({}, n), {
107
+ width: e == "float" ? i == null ? void 0 : i.width : n == null ? void 0 : n.width,
108
+ height: e === "float" ? i == null ? void 0 : i.height : n == null ? void 0 : n.height,
122
109
  maxHeight: "100vh"
123
110
  }),
124
- ref: u,
125
- children: [Y ? /* @__PURE__ */ s("div", {
111
+ ref: b,
112
+ children: [G ? /* @__PURE__ */ s("div", {
126
113
  className: "loading",
127
- children: /* @__PURE__ */ s(fe, {})
128
- }) : C && b ? /* @__PURE__ */ s(re, {
114
+ children: /* @__PURE__ */ s(ne, {})
115
+ }) : C && m ? /* @__PURE__ */ s(te, {
129
116
  ref: c,
130
117
  appId: C,
131
118
  docViewerUrl: H,
132
- bodyStyle: p,
133
- sessionId: F
134
- }) : null, (l == null ? void 0 : l.visible) && /* @__PURE__ */ s(U, {
119
+ bodyStyle: u,
120
+ sessionId: O
121
+ }) : null, (l == null ? void 0 : l.visible) && /* @__PURE__ */ s(L, {
135
122
  className: "trigger-btn close-btn",
136
123
  icon: /* @__PURE__ */ s("img", {
137
- src: g
124
+ src: p
138
125
  }),
139
126
  onClick: () => N(!1)
140
127
  })]
141
128
  })
142
- }), (l == null ? void 0 : l.visible) && !v && /* @__PURE__ */ s(U, {
129
+ }), (l == null ? void 0 : l.visible) && !w && /* @__PURE__ */ s(L, {
143
130
  className: `${e}-trigger-btn open-btn`,
144
131
  style: l.style,
145
132
  icon: /* @__PURE__ */ s("img", {
146
- src: g
133
+ src: p
147
134
  }),
148
135
  onClick: () => N(!0)
149
136
  })]
@@ -151,5 +138,5 @@ const ke = ie((n, t) => {
151
138
  });
152
139
  });
153
140
  export {
154
- ke as default
141
+ Ne as default
155
142
  };
@@ -17,17 +17,17 @@ var v = (i, o, n) => new Promise((l, g) => {
17
17
  } catch (u) {
18
18
  g(u);
19
19
  }
20
- }, a = (e) => {
20
+ }, r = (e) => {
21
21
  try {
22
22
  f(n.throw(e));
23
23
  } catch (u) {
24
24
  g(u);
25
25
  }
26
- }, f = (e) => e.done ? l(e.value) : Promise.resolve(e.value).then(s, a);
26
+ }, f = (e) => e.done ? l(e.value) : Promise.resolve(e.value).then(s, r);
27
27
  f((n = n.apply(i, o)).next());
28
28
  });
29
- import { jsx as r, jsxs as A } from "react/jsx-runtime";
30
- import { forwardRef as B, useState as p, useContext as F, useRef as G, useEffect as I, useImperativeHandle as J } from "react";
29
+ import { jsx as a, jsxs as A } from "react/jsx-runtime";
30
+ import { forwardRef as B, useState as p, useContext as F, useRef as G, useEffect as y, useImperativeHandle as J } from "react";
31
31
  import M from "../context.mjs";
32
32
  import Q from "./AgentChat/index.mjs";
33
33
  import T from "../components/KnowledgeList/index.mjs";
@@ -37,17 +37,17 @@ import W from "./SessionList/index.mjs";
37
37
  sessionId: n,
38
38
  appId: l,
39
39
  docViewerUrl: g
40
- } = i, [s, a] = p(), {
40
+ } = i, [s, r] = p(), {
41
41
  showHeader: f,
42
42
  agentClient: e,
43
43
  sider: u,
44
44
  onSessionLoad: m,
45
45
  features: c
46
- } = F(M), [h, H] = p(), y = G(null), [K, D] = p(""), [S, k] = p(), [b, N] = p(!1);
47
- I(() => {
46
+ } = F(M), [h, H] = p(), I = G(null), [K, D] = p(""), [S, k] = p(), [b, N] = p(!1);
47
+ y(() => {
48
48
  var d;
49
49
  N(s ? !!((d = s.data) != null && d.netOpen) : typeof (c == null ? void 0 : c.connectNetwork) == "object" && typeof (c == null ? void 0 : c.connectNetwork.default) == "boolean" ? c.connectNetwork.default : !1);
50
- }, [s]), I(() => {
50
+ }, [s]), y(() => {
51
51
  const d = () => v(void 0, null, function* () {
52
52
  const t = e == null ? void 0 : e.application;
53
53
  if (!(t != null && t.id))
@@ -58,18 +58,22 @@ import W from "./SessionList/index.mjs";
58
58
  const O = w[0].embeddingService;
59
59
  D(O), H(t);
60
60
  });
61
+ if (e != null && e.ready) {
62
+ d();
63
+ return;
64
+ }
61
65
  return e == null || e.addEventListener("ready", () => d()), () => {
62
66
  e == null || e.removeEventListener("ready", d);
63
67
  };
64
- }, []), I(() => {
68
+ }, [e]), y(() => {
65
69
  e && n && (e.ready ? e == null || e.getSessions().then((d) => v(void 0, null, function* () {
66
- a == null || a(d.find((t) => t.id === n));
70
+ r == null || r(d.find((t) => t.id === n));
67
71
  })) : e.addEventListener("ready", () => v(void 0, null, function* () {
68
72
  e == null || e.getSessions().then((d) => v(void 0, null, function* () {
69
- a == null || a(d.find((t) => t.id === n));
73
+ r == null || r(d.find((t) => t.id === n));
70
74
  }));
71
75
  }), !0));
72
- }, [e, n]), I(() => {
76
+ }, [e, n]), y(() => {
73
77
  if (!s) {
74
78
  m && m({
75
79
  applicationId: l,
@@ -95,7 +99,7 @@ import W from "./SessionList/index.mjs";
95
99
  }, [s]);
96
100
  const L = (d) => {
97
101
  var t;
98
- return (t = y.current) == null ? void 0 : t.create(j(R({}, d), {
102
+ return (t = I.current) == null ? void 0 : t.create(j(R({}, d), {
99
103
  knowledges: S
100
104
  }));
101
105
  };
@@ -103,40 +107,40 @@ import W from "./SessionList/index.mjs";
103
107
  sessionCreate: (d) => L(d),
104
108
  getSessionList: () => {
105
109
  var t;
106
- const d = ((t = y.current) == null ? void 0 : t.list()) || [];
110
+ const d = ((t = I.current) == null ? void 0 : t.list()) || [];
107
111
  return Promise.resolve(d);
108
112
  }
109
- })), /* @__PURE__ */ r("div", {
113
+ })), /* @__PURE__ */ a("div", {
110
114
  className: "dialog",
111
115
  children: /* @__PURE__ */ A("div", {
112
116
  className: "dialog-pannel",
113
- children: [/* @__PURE__ */ r("div", {
117
+ children: [/* @__PURE__ */ a("div", {
114
118
  className: "dialog-sider",
115
- children: /* @__PURE__ */ r(W, {
116
- ref: y,
119
+ children: /* @__PURE__ */ a(W, {
120
+ ref: I,
117
121
  sider: u,
118
122
  appId: l,
119
123
  networkStatus: b,
120
124
  currentSession: s,
121
125
  application: h,
122
- setCurrentSession: a,
126
+ setCurrentSession: r,
123
127
  checkKnowledges: S,
124
128
  setCheckKnowledges: f ? k : void 0
125
129
  })
126
- }), /* @__PURE__ */ r("div", {
130
+ }), /* @__PURE__ */ a("div", {
127
131
  className: "dialog-content",
128
132
  children: /* @__PURE__ */ A("div", {
129
133
  className: "dialog-chat",
130
- children: [f && /* @__PURE__ */ r("div", {
134
+ children: [f && /* @__PURE__ */ a("div", {
131
135
  className: "dialog-chat-header",
132
- children: /* @__PURE__ */ r(T, {
136
+ children: /* @__PURE__ */ a(T, {
133
137
  setCheckKnowledges: k,
134
138
  application: h,
135
139
  currentSession: s
136
140
  })
137
- }), /* @__PURE__ */ r("div", {
141
+ }), /* @__PURE__ */ a("div", {
138
142
  className: "dialog-chat-content",
139
- children: (h == null ? void 0 : h.id) && /* @__PURE__ */ r(Q, {
143
+ children: (h == null ? void 0 : h.id) && /* @__PURE__ */ a(Q, {
140
144
  setNetworkStatus: N,
141
145
  networkStatus: b,
142
146
  application: h,
@@ -144,7 +148,7 @@ import W from "./SessionList/index.mjs";
144
148
  onCreateSession: L,
145
149
  docViewerUrl: g,
146
150
  embeddingService: K,
147
- setCurrentSession: a
151
+ setCurrentSession: r
148
152
  })
149
153
  })]
150
154
  })