@glodon-aiot/agent-cli-ui 3.3.6-alpha.1 → 3.3.7-beta.1

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 (40) hide show
  1. package/dist/es/Dialog/AgentChat/index.mjs +347 -362
  2. package/dist/es/Dialog/SessionList/index.mjs +172 -252
  3. package/dist/es/Dialog/index.mjs +76 -83
  4. package/dist/es/QuillEditor/index.mjs +70 -59
  5. package/dist/es/packages/agent-cli-ui/package.json.mjs +3 -3
  6. package/dist/es/packages/react-components/dist/es/index.mjs +1 -1
  7. package/dist/es/src/style10.css +1 -1
  8. package/dist/es/src/style12.css +1 -1
  9. package/dist/es/src/style14.css +1 -1
  10. package/dist/es/src/style15.css +1 -1
  11. package/dist/es/src/style16.css +1 -1
  12. package/dist/es/src/style18.css +1 -1
  13. package/dist/es/src/style19.css +1 -1
  14. package/dist/es/src/style20.css +1 -1
  15. package/dist/es/src/style21.css +1 -1
  16. package/dist/es/src/style22.css +1 -1
  17. package/dist/es/src/style23.css +1 -1
  18. package/dist/es/src/style24.css +1 -1
  19. package/dist/es/src/style26.css +1 -1
  20. package/dist/es/src/style27.css +1 -1
  21. package/dist/es/src/style28.css +1 -1
  22. package/dist/es/src/style29.css +1 -1
  23. package/dist/es/src/style30.css +1 -1
  24. package/dist/es/src/style31.css +1 -1
  25. package/dist/es/src/style6.css +1 -1
  26. package/dist/es/src/style7.css +1 -1
  27. package/dist/es/src/style8.css +1 -1
  28. package/dist/es/src/style9.css +1 -1
  29. package/dist/lib/index.css +1 -1
  30. package/dist/lib/index.js +56 -56
  31. package/dist/src/Dialog/AgentChat/Tools/SessionHistoryDrawer/index.d.ts +5 -4
  32. package/dist/src/Dialog/AgentChat/index.d.ts +0 -2
  33. package/dist/src/Dialog/SessionList/index.d.ts +3 -6
  34. package/dist/src/context/SessionContext.d.ts +15 -0
  35. package/dist/src/hooks/useSessionState.d.ts +7 -0
  36. package/package.json +3 -3
  37. package/dist/es/Dialog/AgentChat/Tools/SessionHistoryDrawer/index.mjs +0 -74
  38. package/dist/es/components/Sider/index.mjs +0 -24
  39. package/dist/es/src/style32.css +0 -1
  40. package/dist/es/src/style33.css +0 -1
@@ -1,295 +1,215 @@
1
- var dt = Object.defineProperty;
2
- var R = Object.getOwnPropertySymbols;
3
- var ot = Object.prototype.hasOwnProperty, it = Object.prototype.propertyIsEnumerable;
4
- var U = (k, r, e) => r in k ? dt(k, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : k[r] = e, G = (k, r) => {
5
- for (var e in r || (r = {}))
6
- ot.call(r, e) && U(k, e, r[e]);
7
- if (R)
8
- for (var e of R(r))
9
- it.call(r, e) && U(k, e, r[e]);
10
- return k;
11
- };
12
- var x = (k, r, e) => new Promise((i, O) => {
13
- var g = (m) => {
1
+ var k = (x, P, N) => new Promise((e, o) => {
2
+ var v = (p) => {
14
3
  try {
15
- E(e.next(m));
16
- } catch (w) {
17
- O(w);
4
+ b(N.next(p));
5
+ } catch (s) {
6
+ o(s);
18
7
  }
19
- }, D = (m) => {
8
+ }, w = (p) => {
20
9
  try {
21
- E(e.throw(m));
22
- } catch (w) {
23
- O(w);
10
+ b(N.throw(p));
11
+ } catch (s) {
12
+ o(s);
24
13
  }
25
- }, E = (m) => m.done ? i(m.value) : Promise.resolve(m.value).then(g, D);
26
- E((e = e.apply(k, r)).next());
14
+ }, b = (p) => p.done ? e(p.value) : Promise.resolve(p.value).then(v, w);
15
+ b((N = N.apply(x, P)).next());
27
16
  });
28
- import { jsx as l, jsxs as A } from "react/jsx-runtime";
29
- import { forwardRef as nt, useState as $, useContext as lt, useEffect as P, useImperativeHandle as ct, useMemo as st } from "react";
30
- import { Button as rt, Popconfirm as q, Input as mt, Space as pt } from "antd";
31
- import N from "dayjs";
32
- import ht from "classnames";
33
- import J from "../../components/Iconfont/index.mjs";
34
- import ft from "../../context.mjs";
35
- /* empty css */import { useMemoizedFn as Q } from "ahooks";
36
- import { NET_OPEN_STATUS as W } from "../../constant.mjs";
37
- const yt = nt((k, r) => {
17
+ import { jsx as n, jsxs as f } from "react/jsx-runtime";
18
+ import { forwardRef as B, useState as L, useContext as q, useEffect as j, useImperativeHandle as G } from "react";
19
+ import { Button as J, Popconfirm as _, Input as Q, Space as W } from "antd";
20
+ import X from "dayjs";
21
+ import Y from "classnames";
22
+ import A from "../../components/Iconfont/index.mjs";
23
+ import Z from "../../context.mjs";
24
+ /* empty css */import { useMemoizedFn as $ } from "ahooks";
25
+ import { NET_OPEN_STATUS as H } from "../../constant.mjs";
26
+ const u = B((x, P) => {
38
27
  const {
28
+ sider: N,
39
29
  currentSession: e,
40
- setCurrentSession: i,
41
- checkKnowledges: O,
42
- application: g,
43
- networkStatus: D,
44
- isShowHeader: E = !0,
45
- sessions: m,
46
- // 👈 从外部接收
47
- setSessions: w,
48
- // 👈 从外部接收
49
- afterSessionClick: Y
50
- } = k, [L, T] = $(), {
51
- agentClient: v,
52
- mode: X,
53
- features: a
54
- } = lt(ft), [H, _] = $(O), K = Q((t) => {
55
- if (!t.id)
30
+ setCurrentSession: o,
31
+ checkKnowledges: v,
32
+ application: w,
33
+ networkStatus: b
34
+ } = x, [p, s] = L(), {
35
+ agentClient: m,
36
+ mode: O,
37
+ features: t
38
+ } = q(Z), [r, E] = L([]), [V, D] = L(v), K = $(() => {
39
+ var a;
40
+ if (!((a = e == null ? void 0 : e.data) != null && a.id))
56
41
  return;
57
- const d = m.map((o) => {
58
- var c;
59
- return ((c = o.data) == null ? void 0 : c.id) === t.id && (o.data = G({}, t)), o;
42
+ const d = r.map((l) => {
43
+ var c, i;
44
+ return ((c = l.data) == null ? void 0 : c.id) === ((i = e.data) == null ? void 0 : i.id) ? e : l;
60
45
  });
61
- w([...d]);
46
+ E([...d]);
62
47
  });
63
- P(() => {
64
- v == null || v.getSessions().then((t) => x(void 0, null, function* () {
65
- var d;
66
- if (w([...t]), !((d = e == null ? void 0 : e.data) != null && d.id) && (t != null && t.length) && X === "inlay") {
67
- const o = t[0];
68
- i == null || i(o);
48
+ j(() => {
49
+ m == null || m.getSessions().then((d) => k(void 0, null, function* () {
50
+ var a;
51
+ if (E([...d]), !((a = e == null ? void 0 : e.data) != null && a.id) && (d != null && d.length) && O === "inlay") {
52
+ const l = d[0];
53
+ o == null || o(l);
69
54
  }
70
55
  }));
71
- }, []), P(() => {
72
- var t;
73
- if (!((t = e == null ? void 0 : e.data) != null && t.id) && O === void 0) {
74
- const d = typeof (a == null ? void 0 : a.knowledges) == "object" && a.knowledges.default || void 0;
75
- _(d);
56
+ }, []), j(() => {
57
+ var d;
58
+ if (!((d = e == null ? void 0 : e.data) != null && d.id) && v === void 0) {
59
+ const a = typeof (t == null ? void 0 : t.knowledges) == "object" && t.knowledges.default || void 0;
60
+ D(a);
76
61
  return;
77
62
  }
78
- _(O);
79
- }, [O]), P(() => {
63
+ D(v);
64
+ }, [v]), j(() => {
80
65
  e == null || e.addEventListener("data:updated", K);
81
- }, [e]), ct(r, () => ({
82
- create(t) {
83
- return z(t).then((d) => (i == null || i(d), d));
66
+ }, [e]), G(P, () => ({
67
+ create(d) {
68
+ return M(d).then((a) => (o == null || o(a), a));
84
69
  },
85
- list: () => Promise.resolve(m)
70
+ list: () => Promise.resolve(r)
86
71
  }));
87
- const z = (t) => {
88
- const d = typeof (a == null ? void 0 : a.connectNetwork) == "object" && typeof (a == null ? void 0 : a.connectNetwork.default) == "boolean" ? a.connectNetwork.default : !1;
89
- return new Promise((o) => x(void 0, null, function* () {
90
- var p;
91
- const c = typeof (a == null ? void 0 : a.promptVariables) == "object" ? (a == null ? void 0 : a.promptVariables.default) || [] : void 0, s = yield v == null ? void 0 : v.loadSession("", {
92
- name: t == null ? void 0 : t.name,
72
+ const M = (d) => {
73
+ const a = typeof (t == null ? void 0 : t.connectNetwork) == "object" && typeof (t == null ? void 0 : t.connectNetwork.default) == "boolean" ? t.connectNetwork.default : !1;
74
+ return new Promise((l) => k(void 0, null, function* () {
75
+ var h;
76
+ const c = typeof (t == null ? void 0 : t.promptVariables) == "object" ? (t == null ? void 0 : t.promptVariables.default) || [] : void 0, i = yield m == null ? void 0 : m.loadSession("", {
77
+ name: d == null ? void 0 : d.name,
93
78
  // @ts-ignore netOpen入参是number 响应是boolen
94
79
  // 只有对话有联网 其它没有
95
80
  // 不传netOpen会默认取defaultNetOpen
96
- netOpen: (g == null ? void 0 : g.type) === 0 ? t != null && t.netOpen ? t.netOpen : d ? W.OPEN : W.CLOSE : void 0,
97
- knowledges: (p = e == null ? void 0 : e.data) != null && p.id ? t == null ? void 0 : t.knowledges : H,
81
+ netOpen: (w == null ? void 0 : w.type) === 0 ? d != null && d.netOpen ? d.netOpen : a ? H.OPEN : H.CLOSE : void 0,
82
+ knowledges: (h = e == null ? void 0 : e.data) != null && h.id ? d == null ? void 0 : d.knowledges : V,
98
83
  promptVariables: c
99
84
  });
100
- s == null || s.addEventListener("data:created", () => x(void 0, null, function* () {
101
- w([s, ...m]), o(s);
85
+ i == null || i.addEventListener("data:created", () => k(void 0, null, function* () {
86
+ E([i, ...r]), l(i);
102
87
  }));
103
88
  }));
104
- }, Z = () => {
105
- z({
106
- knowledges: H
107
- }).then((t) => {
108
- i == null || i(t);
89
+ }, T = () => {
90
+ M({
91
+ knowledges: V
92
+ }).then((d) => {
93
+ o == null || o(d);
109
94
  });
110
- }, S = (t) => {
111
- v == null || v.removeSession(t, !0).then(() => x(void 0, null, function* () {
112
- var o, c;
113
- const d = m.filter((s) => {
114
- var p, b;
115
- return ((p = s.data) == null ? void 0 : p.id) !== ((b = t.data) == null ? void 0 : b.id);
95
+ }, z = (d) => {
96
+ m == null || m.removeSession(d, !0).then(() => k(void 0, null, function* () {
97
+ var l, c;
98
+ const a = r.filter((i) => {
99
+ var h, g;
100
+ return ((h = i.data) == null ? void 0 : h.id) !== ((g = d.data) == null ? void 0 : g.id);
116
101
  });
117
- ((o = t.data) == null ? void 0 : o.id) === ((c = e == null ? void 0 : e.data) == null ? void 0 : c.id) && (d != null && d.length ? i == null || i(d[0]) : i == null || i(void 0)), w([...d]);
102
+ ((l = d.data) == null ? void 0 : l.id) === ((c = e == null ? void 0 : e.data) == null ? void 0 : c.id) && (a != null && a.length ? o == null || o(a[0]) : o == null || o(void 0)), E([...a]);
118
103
  }));
119
- }, I = (t) => {
120
- var d;
121
- T((d = t.data) == null ? void 0 : d.name);
122
- }, tt = (t) => {
123
- L && (t.rename(L), t == null || t.addEventListener("data:updated", K));
124
- }, et = (t) => x(void 0, null, function* () {
125
- i == null || i(t), Y == null || Y(t);
126
- }), at = (t) => {
127
- T(t.target.value);
104
+ }, C = (d) => {
105
+ var a;
106
+ s((a = d.data) == null ? void 0 : a.name);
107
+ }, F = (d) => {
108
+ p && (d.rename(p), d == null || d.addEventListener("data:updated", K));
109
+ }, R = (d) => k(void 0, null, function* () {
110
+ o == null || o(d);
111
+ }), U = (d) => {
112
+ s(d.target.value);
128
113
  };
129
- P(() => {
130
- var d, o, c, s;
114
+ return j(() => {
115
+ var a, l, c, i;
131
116
  if (!(e != null && e.id))
132
117
  return;
133
- const t = {};
134
- typeof (a == null ? void 0 : a.knowledges) == "object" && ((d = a == null ? void 0 : a.knowledges) != null && d.default) && (t.knowledges = (o = a == null ? void 0 : a.knowledges) == null ? void 0 : o.default), typeof (a == null ? void 0 : a.promptVariables) == "object" && ((c = a == null ? void 0 : a.promptVariables) != null && c.default) && (t.promptVariables = (s = a == null ? void 0 : a.promptVariables) == null ? void 0 : s.default), v == null || v.loadSession(e.id, t);
135
- }, [e]);
136
- const B = Q((t) => {
137
- const d = N().endOf("day"), o = d.subtract(1, "day"), c = d.subtract(7, "day"), s = d.subtract(30, "day"), p = [], b = [], M = [], j = [], u = {};
138
- return t.forEach((n) => {
139
- var y;
140
- const h = N((y = n.data) == null ? void 0 : y.createdAt);
141
- if (h.isAfter(o))
142
- b.push(n);
143
- else if (h.isAfter(c))
144
- M.push(n);
145
- else if (h.isAfter(s))
146
- j.push(n);
147
- else {
148
- const f = h.format("YYYY-MM");
149
- u[f] || (u[f] = []), u[f].push(n);
150
- }
151
- }), b.length > 0 && p.push({
152
- title: "今天",
153
- sessions: b.sort((n, h) => {
154
- var y, f;
155
- return N((y = h.data) == null ? void 0 : y.createdAt).valueOf() - N((f = n.data) == null ? void 0 : f.createdAt).valueOf();
156
- }),
157
- key: "today"
158
- }), M.length > 0 && p.push({
159
- title: "7天内",
160
- sessions: M.sort((n, h) => {
161
- var y, f;
162
- return N((y = h.data) == null ? void 0 : y.createdAt).valueOf() - N((f = n.data) == null ? void 0 : f.createdAt).valueOf();
163
- }),
164
- key: "seven-days"
165
- }), j.length > 0 && p.push({
166
- title: "30天内",
167
- sessions: j.sort((n, h) => {
168
- var y, f;
169
- return N((y = h.data) == null ? void 0 : y.createdAt).valueOf() - N((f = n.data) == null ? void 0 : f.createdAt).valueOf();
170
- }),
171
- key: "thirty-days"
172
- }), Object.keys(u).sort((n, h) => h.localeCompare(n)).forEach((n) => {
173
- const h = u[n].sort((y, f) => {
174
- var C, F;
175
- return N((C = f.data) == null ? void 0 : C.createdAt).valueOf() - N((F = y.data) == null ? void 0 : F.createdAt).valueOf();
176
- });
177
- p.push({
178
- title: N(n).format("YYYY年MM月"),
179
- sessions: h,
180
- key: `month-${n}`
181
- });
182
- }), p;
183
- }), V = st(() => B(m), [m, B]);
184
- return /* @__PURE__ */ l("div", {
118
+ const d = {};
119
+ typeof (t == null ? void 0 : t.knowledges) == "object" && ((a = t == null ? void 0 : t.knowledges) != null && a.default) && (d.knowledges = (l = t == null ? void 0 : t.knowledges) == null ? void 0 : l.default), typeof (t == null ? void 0 : t.promptVariables) == "object" && ((c = t == null ? void 0 : t.promptVariables) != null && c.default) && (d.promptVariables = (i = t == null ? void 0 : t.promptVariables) == null ? void 0 : i.default), m == null || m.loadSession(e.id, d);
120
+ }, [e]), /* @__PURE__ */ n("div", {
185
121
  className: "bot-session-container",
186
- children: /* @__PURE__ */ A("div", {
122
+ children: N && O === "inlay" && /* @__PURE__ */ f("div", {
187
123
  className: "agent-sessions",
188
- children: [E && /* @__PURE__ */ l("div", {
124
+ children: [/* @__PURE__ */ f("div", {
189
125
  className: "sessions-header",
190
- children: /* @__PURE__ */ l("div", {
126
+ children: [/* @__PURE__ */ n("span", {
191
127
  className: "session-header-title",
192
- children: (g == null ? void 0 : g.name) || "-"
193
- })
194
- }), /* @__PURE__ */ A("div", {
128
+ children: "会话列表"
129
+ }), /* @__PURE__ */ n(J, {
130
+ className: "session-header-btn",
131
+ onClick: T,
132
+ children: "+ 新建会话"
133
+ })]
134
+ }), /* @__PURE__ */ n("div", {
195
135
  className: "sessions-main",
196
- children: [E && /* @__PURE__ */ l("div", {
197
- className: "session-header-btn-wrapper",
198
- children: /* @__PURE__ */ l(rt, {
199
- className: "session-header-btn",
200
- onClick: Z,
201
- type: "primary",
202
- children: "+ 新会话"
203
- })
204
- }), V == null ? void 0 : V.map((t) => {
205
- var d;
206
- return /* @__PURE__ */ A("div", {
207
- className: "session-group",
208
- children: [/* @__PURE__ */ l("div", {
209
- className: "group-header",
210
- style: {
211
- top: E ? 48 : 0
212
- },
213
- children: t.title
214
- }), (d = t.sessions) == null ? void 0 : d.map((o) => {
215
- var c, s, p, b, M, j;
216
- return /* @__PURE__ */ l("div", {
217
- className: ht({
218
- "session-item": !0,
219
- "session-item__active": ((c = o.data) == null ? void 0 : c.id) === ((s = e == null ? void 0 : e.data) == null ? void 0 : s.id)
220
- }),
221
- onClick: () => et(o),
222
- children: /* @__PURE__ */ A("div", {
223
- className: "session-item-wrapper",
224
- children: [/* @__PURE__ */ A("div", {
225
- className: "session-item-top",
226
- children: [/* @__PURE__ */ l("span", {
227
- className: "item-top-title",
228
- children: ((p = o.data) == null ? void 0 : p.name) || "-"
229
- }), /* @__PURE__ */ A("div", {
230
- className: "item-top-action",
231
- onClick: (u) => u.stopPropagation(),
232
- children: [/* @__PURE__ */ l(q, {
233
- getPopupContainer: (u) => u.parentNode,
234
- icon: !1,
235
- title: /* @__PURE__ */ l(mt, {
236
- placeholder: "请输入内容",
237
- autoComplete: "off",
238
- showCount: !0,
239
- value: L,
240
- onChange: at,
241
- maxLength: 15
242
- }),
243
- onConfirm: () => tt(o),
244
- children: /* @__PURE__ */ l(J, {
245
- type: "icon-bianji2",
246
- onClick: () => I(o),
247
- className: "icon-action",
248
- style: {
249
- marginRight: "8px"
250
- }
251
- })
252
- }), /* @__PURE__ */ l(q, {
253
- getPopupContainer: (u) => u.parentNode,
254
- icon: !1,
255
- title: /* @__PURE__ */ A(pt, {
256
- direction: "vertical",
257
- children: [/* @__PURE__ */ l("div", {
258
- children: "删除确认?"
259
- }), /* @__PURE__ */ l("div", {
260
- children: "会话删除后不可恢复,请确认是否删除!"
261
- })]
262
- }),
263
- onConfirm: () => S(o),
264
- children: /* @__PURE__ */ l(J, {
265
- style: {
266
- fontSize: "18px"
267
- },
268
- className: "icon-action",
269
- type: "icon-del"
270
- })
136
+ children: r == null ? void 0 : r.map((d) => {
137
+ var a, l, c, i, h, g;
138
+ return /* @__PURE__ */ n("div", {
139
+ className: Y({
140
+ "session-item": !0,
141
+ "session-item__active": ((a = d.data) == null ? void 0 : a.id) === ((l = e == null ? void 0 : e.data) == null ? void 0 : l.id)
142
+ }),
143
+ onClick: () => R(d),
144
+ children: /* @__PURE__ */ f("div", {
145
+ className: "session-item-wrapper",
146
+ children: [/* @__PURE__ */ f("div", {
147
+ className: "session-item-top",
148
+ children: [/* @__PURE__ */ n("span", {
149
+ className: "item-top-title",
150
+ children: ((c = d.data) == null ? void 0 : c.name) || "-"
151
+ }), /* @__PURE__ */ f("div", {
152
+ className: "item-top-action",
153
+ onClick: (y) => y.stopPropagation(),
154
+ children: [/* @__PURE__ */ n(_, {
155
+ getPopupContainer: (y) => y.parentNode,
156
+ icon: !1,
157
+ title: /* @__PURE__ */ n(Q, {
158
+ placeholder: "请输入内容",
159
+ autoComplete: "off",
160
+ showCount: !0,
161
+ value: p,
162
+ onChange: U,
163
+ maxLength: 15
164
+ }),
165
+ onConfirm: () => F(d),
166
+ children: /* @__PURE__ */ n(A, {
167
+ type: "icon-bianji2",
168
+ onClick: () => C(d),
169
+ className: "icon-action",
170
+ style: {
171
+ marginRight: "8px"
172
+ }
173
+ })
174
+ }), /* @__PURE__ */ n(_, {
175
+ getPopupContainer: (y) => y.parentNode,
176
+ icon: !1,
177
+ title: /* @__PURE__ */ f(W, {
178
+ direction: "vertical",
179
+ children: [/* @__PURE__ */ n("div", {
180
+ children: "删除确认?"
181
+ }), /* @__PURE__ */ n("div", {
182
+ children: "会话删除后不可恢复,请确认是否删除!"
271
183
  })]
272
- })]
273
- }), /* @__PURE__ */ A("div", {
274
- className: "session-item-bottom",
275
- children: [/* @__PURE__ */ l("span", {
276
- className: "item-bottom-desc",
277
- children: ((b = o.data) == null ? void 0 : b.finialMessage) || "-"
278
- }), /* @__PURE__ */ l("span", {
279
- className: "item-bottom-time",
280
- children: N((M = o.data) == null ? void 0 : M.createdAt).format("MM/DD HH:mm:ss")
281
- })]
184
+ }),
185
+ onConfirm: () => z(d),
186
+ children: /* @__PURE__ */ n(A, {
187
+ style: {
188
+ fontSize: "18px"
189
+ },
190
+ className: "icon-action",
191
+ type: "icon-del"
192
+ })
282
193
  })]
283
- })
284
- }, (j = o.data) == null ? void 0 : j.id);
285
- })]
286
- }, t.key);
287
- })]
194
+ })]
195
+ }), /* @__PURE__ */ f("div", {
196
+ className: "session-item-bottom",
197
+ children: [/* @__PURE__ */ n("span", {
198
+ className: "item-bottom-desc",
199
+ children: ((i = d.data) == null ? void 0 : i.finialMessage) || "-"
200
+ }), /* @__PURE__ */ n("span", {
201
+ className: "item-bottom-time",
202
+ children: X((h = d.data) == null ? void 0 : h.createdAt).format("MM/DD HH:mm:ss")
203
+ })]
204
+ })]
205
+ })
206
+ }, (g = d.data) == null ? void 0 : g.id);
207
+ })
288
208
  })]
289
209
  })
290
210
  });
291
211
  });
292
- yt.displayName = "SessionList";
212
+ u.displayName = "SessionList";
293
213
  export {
294
- yt as default
214
+ u as default
295
215
  };