@glodon-aiot/agent-cli-ui 3.17.0-alpha.3 → 3.17.0-alpha.5

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,12 +1,12 @@
1
1
  var De = Object.defineProperty;
2
- var pe = Object.getOwnPropertySymbols;
2
+ var ue = Object.getOwnPropertySymbols;
3
3
  var Ie = Object.prototype.hasOwnProperty, Re = Object.prototype.propertyIsEnumerable;
4
- var ue = (N, g, a) => g in N ? De(N, g, { enumerable: !0, configurable: !0, writable: !0, value: a }) : N[g] = a, ye = (N, g) => {
4
+ var ye = (N, g, a) => g in N ? De(N, g, { enumerable: !0, configurable: !0, writable: !0, value: a }) : N[g] = a, ge = (N, g) => {
5
5
  for (var a in g || (g = {}))
6
- Ie.call(g, a) && ue(N, a, g[a]);
7
- if (pe)
8
- for (var a of pe(g))
9
- Re.call(g, a) && ue(N, a, g[a]);
6
+ Ie.call(g, a) && ye(N, a, g[a]);
7
+ if (ue)
8
+ for (var a of ue(g))
9
+ Re.call(g, a) && ye(N, a, g[a]);
10
10
  return N;
11
11
  };
12
12
  var L = (N, g, a) => new Promise((r, O) => {
@@ -26,17 +26,17 @@ var L = (N, g, a) => new Promise((r, O) => {
26
26
  M((a = a.apply(N, g)).next());
27
27
  });
28
28
  import { jsx as f, jsxs as T } from "react/jsx-runtime";
29
- import { forwardRef as Se, useState as k, useContext as Ye, useRef as V, useEffect as D, useImperativeHandle as $e, useMemo as He } from "react";
30
- import { Button as Ve, Typography as Fe, Space as ge, Popconfirm as ve, Input as Ke, Divider as ze, notification as J } from "antd";
29
+ import { forwardRef as Ye, useState as k, useContext as $e, useRef as V, useEffect as C, useImperativeHandle as He, useMemo as Ve } from "react";
30
+ import { Button as Fe, Typography as Ke, Space as ve, Popconfirm as Ae, Input as ze, Divider as Be, notification as J } from "antd";
31
31
  import p from "dayjs";
32
- import Be from "classnames";
33
- import Ae from "../../components/Iconfont/index.mjs";
34
- import Ge from "../../context.mjs";
35
- /* empty css */import { useMemoizedFn as Ne } from "ahooks";
36
- import { MAX_KNOWLEDGES_AND_FILES_COUNT as F, NET_OPEN_STATUS as Ee } from "../../constant.mjs";
37
- import { useSessionState as Ue } from "../../hooks/useSessionState.mjs";
38
- import { calcKnowledgesLeafCount as we } from "../../utils/index.mjs";
39
- const Q = 15, Xe = Se((N, g) => {
32
+ import Ge from "classnames";
33
+ import Ne from "../../components/Iconfont/index.mjs";
34
+ import Ue from "../../context.mjs";
35
+ /* empty css */import { useMemoizedFn as Ee } from "ahooks";
36
+ import { MAX_KNOWLEDGES_AND_FILES_COUNT as F, NET_OPEN_STATUS as we } from "../../constant.mjs";
37
+ import { useSessionState as Xe } from "../../hooks/useSessionState.mjs";
38
+ import { calcKnowledgesLeafCount as be } from "../../utils/index.mjs";
39
+ const Q = 15, We = Ye((N, g) => {
40
40
  const {
41
41
  currentSession: a,
42
42
  setCurrentSession: r,
@@ -50,11 +50,12 @@ const Q = 15, Xe = Se((N, g) => {
50
50
  agentClient: u,
51
51
  mode: te,
52
52
  features: o,
53
- popupContainer: B
54
- } = Ye(Ge), [ae, oe] = k(O), {
53
+ popupContainer: B,
54
+ silencedSeconds: ae
55
+ } = $e(Ue), [oe, ne] = k(O), {
55
56
  sessions: _,
56
57
  setSessions: P
57
- } = Ue(), [ne, G] = k(0), [be, I] = k(""), [ke, de] = k(null), j = 30, [U, R] = k(!1), [S, Y] = k(!0), [Oe, $] = k(!1), H = V(void 0), C = V(0), X = V(null), W = V(null), re = (e) => {
58
+ } = Xe(), [de, G] = k(0), [ke, D] = k(""), [Oe, re] = k(null), j = 30, [U, I] = k(!1), [R, Y] = k(!0), [Me, $] = k(!1), H = V(void 0), S = V(0), X = V(null), W = V(null), ie = (e) => {
58
59
  var n, s;
59
60
  if (!(e != null && e.length))
60
61
  return;
@@ -63,52 +64,52 @@ const Q = 15, Xe = Se((N, g) => {
63
64
  var l, m, h, y;
64
65
  t ? (m = d.data) != null && m.createdAt && p((h = d.data) == null ? void 0 : h.createdAt).valueOf() < p(t).valueOf() && (t = (y = d.data) == null ? void 0 : y.createdAt) : t = (l = d.data) == null ? void 0 : l.createdAt;
65
66
  }), t;
66
- }, ie = Ne((e) => {
67
+ }, le = Ee((e) => {
67
68
  e.id && P((t) => [...t.map((d) => {
68
69
  var l;
69
- return ((l = d.data) == null ? void 0 : l.id) === e.id && (d.data = ye({}, e)), d;
70
+ return ((l = d.data) == null ? void 0 : l.id) === e.id && (d.data = ge({}, e)), d;
70
71
  })].sort((d, l) => {
71
72
  var y, w;
72
73
  const m = p((y = d.data) == null ? void 0 : y.createdAt).valueOf();
73
74
  return p((w = l.data) == null ? void 0 : w.createdAt).valueOf() - m;
74
75
  }));
75
76
  });
76
- D(() => {
77
+ C(() => {
77
78
  if (te === "float") {
78
79
  a === void 0 && !x && (r == null || r(null));
79
80
  return;
80
81
  }
81
- R(!0), H.current = void 0, C.current = 0, u == null || u.getSessions({
82
+ I(!0), H.current = void 0, S.current = 0, u == null || u.getSessions({
82
83
  pageSize: j
83
84
  }).then((e) => L(void 0, null, function* () {
84
85
  var t;
85
- if (P([...e]), C.current = e.length, H.current = re(e), Y(e.length >= j), $(e.length < j), !((t = a == null ? void 0 : a.data) != null && t.id) && (e != null && e.length) && te === "inlay") {
86
+ if (P([...e]), S.current = e.length, H.current = ie(e), Y(e.length >= j), $(e.length < j), !((t = a == null ? void 0 : a.data) != null && t.id) && (e != null && e.length) && te === "inlay") {
86
87
  const n = e[0];
87
88
  x || r == null || r(n);
88
89
  } else
89
90
  a === void 0 && (x || r == null || r(null));
90
- })).finally(() => R(!1));
91
- }, []), D(() => {
91
+ })).finally(() => I(!1));
92
+ }, []), C(() => {
92
93
  var e;
93
94
  if (!((e = a == null ? void 0 : a.data) != null && e.id) && O === void 0) {
94
95
  const t = typeof (o == null ? void 0 : o.knowledges) == "object" && o.knowledges.default || void 0;
95
96
  if (Array.isArray(t) && t.some((d) => Array.isArray(d.fileIds) && d.fileIds.length === 0))
96
97
  throw Error("fileIds cannot be an empty array");
97
- if (we(t || []) > F)
98
+ if (be(t || []) > F)
98
99
  throw Error(`knowledges and fileIds total count cannot exceed ${F}`);
99
- oe(t);
100
+ ne(t);
100
101
  return;
101
102
  }
102
- oe(O);
103
- }, [O]), D(() => {
104
- a == null || a.addEventListener("data:updated", ie);
105
- }, [a]), $e(g, () => ({
103
+ ne(O);
104
+ }, [O]), C(() => {
105
+ a == null || a.addEventListener("data:updated", le);
106
+ }, [a]), He(g, () => ({
106
107
  create(e) {
107
- return le(e).then((t) => (r == null || r(t), t));
108
+ return ce(e).then((t) => (r == null || r(t), t));
108
109
  },
109
110
  list: () => Promise.resolve(_)
110
111
  }));
111
- const le = (e) => {
112
+ const ce = (e) => {
112
113
  const t = typeof (o == null ? void 0 : o.connectNetwork) == "object" && typeof (o == null ? void 0 : o.connectNetwork.default) == "boolean" ? o.connectNetwork.default : !1;
113
114
  return new Promise((n) => L(void 0, null, function* () {
114
115
  var m;
@@ -117,8 +118,8 @@ const Q = 15, Xe = Se((N, g) => {
117
118
  // @ts-ignore netOpen入参是number 响应是boolen
118
119
  // 只有对话有联网 其它没有
119
120
  // 不传netOpen会默认取defaultNetOpen
120
- netOpen: (b == null ? void 0 : b.type) === 0 ? e != null && e.netOpen ? e.netOpen : t ? Ee.OPEN : Ee.CLOSE : void 0,
121
- knowledges: (m = a == null ? void 0 : a.data) != null && m.id ? e == null ? void 0 : e.knowledges : ae,
121
+ netOpen: (b == null ? void 0 : b.type) === 0 ? e != null && e.netOpen ? e.netOpen : t ? we.OPEN : we.CLOSE : void 0,
122
+ knowledges: (m = a == null ? void 0 : a.data) != null && m.id ? e == null ? void 0 : e.knowledges : oe,
122
123
  promptVariables: s
123
124
  }), l = (h) => {
124
125
  var y;
@@ -136,13 +137,13 @@ const Q = 15, Xe = Se((N, g) => {
136
137
  d == null || d.removeEventListener("error", l), P([d, ..._]), n(d);
137
138
  }));
138
139
  }));
139
- }, Me = () => {
140
- le({
141
- knowledges: ae
140
+ }, xe = () => {
141
+ ce({
142
+ knowledges: oe
142
143
  }).then((e) => {
143
144
  r == null || r(e);
144
145
  });
145
- }, xe = (e) => {
146
+ }, Le = (e) => {
146
147
  u == null || u.removeSession(e, !0).then(() => L(void 0, null, function* () {
147
148
  var n, s;
148
149
  const t = _.filter((d) => {
@@ -151,53 +152,53 @@ const Q = 15, Xe = Se((N, g) => {
151
152
  });
152
153
  ((n = e.data) == null ? void 0 : n.id) === ((s = a == null ? void 0 : a.data) == null ? void 0 : s.id) && (t != null && t.length ? r == null || r(t[0]) : r == null || r(null)), P([...t]);
153
154
  }));
154
- }, Le = () => L(void 0, null, function* () {
155
- if (!(U || !S)) {
156
- R(!0);
155
+ }, Te = () => L(void 0, null, function* () {
156
+ if (!(U || !R)) {
157
+ I(!0);
157
158
  try {
158
159
  const e = yield u == null ? void 0 : u.getSessions({
159
160
  pageSize: j,
160
161
  beforeTime: H.current
161
- }), t = (e == null ? void 0 : e.length) || 0, n = t - C.current;
162
- P([...e || []]), H.current = re(e || []), n <= 0 ? (Y(!1), $(!0)) : n < j ? (Y(!1), $(!0), C.current = t) : (Y(!0), $(!1), C.current = t);
162
+ }), t = (e == null ? void 0 : e.length) || 0, n = t - S.current;
163
+ P([...e || []]), H.current = ie(e || []), n <= 0 ? (Y(!1), $(!0)) : n < j ? (Y(!1), $(!0), S.current = t) : (Y(!0), $(!1), S.current = t);
163
164
  } finally {
164
- R(!1);
165
+ I(!1);
165
166
  }
166
167
  }
167
168
  });
168
- D(() => {
169
+ C(() => {
169
170
  if (!X.current || !W.current)
170
171
  return;
171
172
  const e = X.current, t = W.current, n = new IntersectionObserver((s) => {
172
- s[0].isIntersecting && S && !U && Le();
173
+ s[0].isIntersecting && R && !U && Te();
173
174
  }, {
174
175
  root: e,
175
176
  rootMargin: "0px 0px 200px 0px",
176
177
  threshold: 0
177
178
  });
178
179
  return n.observe(t), () => n.disconnect();
179
- }, [S, U]);
180
- const Te = (e) => {
180
+ }, [R, U]);
181
+ const _e = (e) => {
181
182
  var t, n;
182
- z((t = e.data) == null ? void 0 : t.name), I(""), de(((n = e.data) == null ? void 0 : n.id) || null);
183
- }, _e = (e) => {
184
- const t = se(K || "");
183
+ z((t = e.data) == null ? void 0 : t.name), D(""), re(((n = e.data) == null ? void 0 : n.id) || null);
184
+ }, Pe = (e) => {
185
+ const t = fe(K || "");
185
186
  if (t) {
186
- I(t);
187
+ D(t);
187
188
  return;
188
189
  }
189
- e.rename(K.trim()), e == null || e.addEventListener("data:updated", ie), ce();
190
- }, Pe = () => {
191
- ce();
192
- }, ce = () => {
193
- de(null), z(""), I(""), G((e) => e + 1);
194
- }, se = (e) => !e || e.trim().length === 0 ? "会话名称不能为空" : e.length > Q ? `不能超过${Q}个字符` : "", je = (e) => L(void 0, null, function* () {
190
+ e.rename(K.trim()), e == null || e.addEventListener("data:updated", le), se();
191
+ }, je = () => {
192
+ se();
193
+ }, se = () => {
194
+ re(null), z(""), D(""), G((e) => e + 1);
195
+ }, fe = (e) => !e || e.trim().length === 0 ? "会话名称不能为空" : e.length > Q ? `不能超过${Q}个字符` : "", Se = (e) => L(void 0, null, function* () {
195
196
  r == null || r(e), E == null || E(e);
196
197
  }), Ce = (e) => {
197
198
  const t = e.target.value;
198
- z(t), I(se(t));
199
+ z(t), D(fe(t));
199
200
  };
200
- D(() => {
201
+ C(() => {
201
202
  var t, n, s, d;
202
203
  if (!(a != null && a.id))
203
204
  return;
@@ -205,12 +206,12 @@ const Q = 15, Xe = Se((N, g) => {
205
206
  if (typeof (o == null ? void 0 : o.knowledges) == "object" && ((t = o == null ? void 0 : o.knowledges) != null && t.default)) {
206
207
  if (e.knowledges = (n = o == null ? void 0 : o.knowledges) == null ? void 0 : n.default, Array.isArray(e.knowledges) && e.knowledges.some((h) => Array.isArray(h.fileIds) && h.fileIds.length === 0))
207
208
  throw Error("fileIds cannot be an empty array");
208
- if (we(e.knowledges) > F)
209
+ if (be(e.knowledges) > F)
209
210
  throw Error(`knowledges and fileIds total count cannot exceed ${F}`);
210
211
  }
211
212
  typeof (o == null ? void 0 : o.promptVariables) == "object" && ((s = o == null ? void 0 : o.promptVariables) != null && s.default) && (e.promptVariables = (d = o == null ? void 0 : o.promptVariables) == null ? void 0 : d.default), u == null || u.loadSession(a.id, e);
212
213
  }, [a]);
213
- const fe = Ne((e) => {
214
+ const me = Ee((e) => {
214
215
  const t = p().endOf("day"), n = t.subtract(1, "day"), s = t.subtract(7, "day"), d = t.subtract(30, "day"), l = [], m = [], h = [], y = [], w = {};
215
216
  return e.forEach((c) => {
216
217
  var A;
@@ -248,8 +249,8 @@ const Q = 15, Xe = Se((N, g) => {
248
249
  key: "thirty-days"
249
250
  }), Object.keys(w).sort((c, i) => i.localeCompare(c)).forEach((c) => {
250
251
  const i = w[c].sort((A, v) => {
251
- var me, he;
252
- return p((me = v.data) == null ? void 0 : me.createdAt).valueOf() - p((he = A.data) == null ? void 0 : he.createdAt).valueOf();
252
+ var he, pe;
253
+ return p((he = v.data) == null ? void 0 : he.createdAt).valueOf() - p((pe = A.data) == null ? void 0 : pe.createdAt).valueOf();
253
254
  });
254
255
  l.push({
255
256
  title: p(c).format("YYYY年MM月"),
@@ -257,7 +258,7 @@ const Q = 15, Xe = Se((N, g) => {
257
258
  key: `month-${c}`
258
259
  });
259
260
  }), l;
260
- }), Z = He(() => fe(_), [_, fe]);
261
+ }), Z = Ve(() => me(_), [_, me]);
261
262
  return /* @__PURE__ */ f("div", {
262
263
  className: "bot-session-container",
263
264
  children: /* @__PURE__ */ T("div", {
@@ -273,10 +274,11 @@ const Q = 15, Xe = Se((N, g) => {
273
274
  ref: X,
274
275
  children: [M && /* @__PURE__ */ f("div", {
275
276
  className: "session-header-btn-wrapper",
276
- children: /* @__PURE__ */ f(Ve, {
277
+ children: /* @__PURE__ */ f(Fe, {
277
278
  className: "session-header-btn",
278
- onClick: Me,
279
+ onClick: xe,
279
280
  type: "primary",
281
+ disabled: ae ? ae > 0 : !1,
280
282
  children: "+ 新会话"
281
283
  })
282
284
  }), Z == null ? void 0 : Z.map((e) => {
@@ -292,16 +294,16 @@ const Q = 15, Xe = Se((N, g) => {
292
294
  }), (t = e.sessions) == null ? void 0 : t.map((n) => {
293
295
  var s, d, l, m, h, y, w, q, c;
294
296
  return /* @__PURE__ */ f("div", {
295
- className: Be({
297
+ className: Ge({
296
298
  "session-item": !0,
297
299
  "session-item__active": ((s = n.data) == null ? void 0 : s.id) === ((d = a == null ? void 0 : a.data) == null ? void 0 : d.id)
298
300
  }),
299
- onClick: () => je(n),
301
+ onClick: () => Se(n),
300
302
  children: /* @__PURE__ */ f("div", {
301
303
  className: "session-item-wrapper",
302
304
  children: /* @__PURE__ */ T("div", {
303
305
  className: "session-item-top",
304
- children: [/* @__PURE__ */ f(Fe.Paragraph, {
306
+ children: [/* @__PURE__ */ f(Ke.Paragraph, {
305
307
  className: "item-top-title",
306
308
  style: {
307
309
  margin: 0,
@@ -315,40 +317,40 @@ const Q = 15, Xe = Se((N, g) => {
315
317
  }
316
318
  },
317
319
  children: ((m = n.data) == null ? void 0 : m.name) || "-"
318
- }), /* @__PURE__ */ T(ge, {
320
+ }), /* @__PURE__ */ T(ve, {
319
321
  children: [/* @__PURE__ */ f("span", {
320
322
  className: "item-top-time",
321
323
  children: p((h = n.data) == null ? void 0 : h.createdAt).format("MM/DD HH:mm:ss")
322
324
  }), /* @__PURE__ */ T("div", {
323
325
  className: "item-top-action",
324
326
  onClick: (i) => i.stopPropagation(),
325
- children: [/* @__PURE__ */ f(ve, {
326
- open: ke === ((y = n.data) == null ? void 0 : y.id),
327
+ children: [/* @__PURE__ */ f(Ae, {
328
+ open: Oe === ((y = n.data) == null ? void 0 : y.id),
327
329
  getPopupContainer: (i) => i.parentNode,
328
330
  icon: !1,
329
- title: /* @__PURE__ */ f(Ke, {
331
+ title: /* @__PURE__ */ f(ze, {
330
332
  placeholder: "请输入内容",
331
333
  autoComplete: "off",
332
334
  showCount: !0,
333
335
  value: K,
334
336
  onChange: Ce,
335
337
  maxLength: Q,
336
- status: be ? "error" : ""
338
+ status: ke ? "error" : ""
337
339
  }),
338
- onConfirm: () => _e(n),
339
- onCancel: Pe,
340
- children: /* @__PURE__ */ f(Ae, {
340
+ onConfirm: () => Pe(n),
341
+ onCancel: je,
342
+ children: /* @__PURE__ */ f(Ne, {
341
343
  type: "icon-bianji2",
342
- onClick: () => Te(n),
344
+ onClick: () => _e(n),
343
345
  className: "icon-action",
344
346
  style: {
345
347
  marginRight: "8px"
346
348
  }
347
349
  })
348
- }, `edit-${(w = n.data) == null ? void 0 : w.id}-${ne}`), /* @__PURE__ */ f(ve, {
350
+ }, `edit-${(w = n.data) == null ? void 0 : w.id}-${de}`), /* @__PURE__ */ f(Ae, {
349
351
  getPopupContainer: (i) => i.parentNode,
350
352
  icon: !1,
351
- title: /* @__PURE__ */ T(ge, {
353
+ title: /* @__PURE__ */ T(ve, {
352
354
  direction: "vertical",
353
355
  children: [/* @__PURE__ */ f("div", {
354
356
  children: "删除确认?"
@@ -357,19 +359,19 @@ const Q = 15, Xe = Se((N, g) => {
357
359
  })]
358
360
  }),
359
361
  onConfirm: () => {
360
- xe(n), G((i) => i + 1);
362
+ Le(n), G((i) => i + 1);
361
363
  },
362
364
  onCancel: () => {
363
365
  G((i) => i + 1);
364
366
  },
365
- children: /* @__PURE__ */ f(Ae, {
367
+ children: /* @__PURE__ */ f(Ne, {
366
368
  style: {
367
369
  fontSize: "18px"
368
370
  },
369
371
  className: "icon-action",
370
372
  type: "icon-del"
371
373
  })
372
- }, `delete-${(q = n.data) == null ? void 0 : q.id}-${ne}`)]
374
+ }, `delete-${(q = n.data) == null ? void 0 : q.id}-${de}`)]
373
375
  })]
374
376
  })]
375
377
  })
@@ -377,7 +379,7 @@ const Q = 15, Xe = Se((N, g) => {
377
379
  }, (c = n.data) == null ? void 0 : c.id);
378
380
  })]
379
381
  }, e.key);
380
- }), !S && Oe && /* @__PURE__ */ f(ze, {
382
+ }), !R && Me && /* @__PURE__ */ f(Be, {
381
383
  style: {
382
384
  color: "rgb(199 199 199)"
383
385
  },
@@ -393,7 +395,7 @@ const Q = 15, Xe = Se((N, g) => {
393
395
  })
394
396
  });
395
397
  });
396
- Xe.displayName = "SessionList";
398
+ We.displayName = "SessionList";
397
399
  export {
398
- Xe as default
400
+ We as default
399
401
  };