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