@glodon-aiot/bot-client-sdk 3.3.2-beta.8 → 3.3.5-alpha.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.
@@ -1,42 +1,42 @@
1
- var b = Object.defineProperty, A = Object.defineProperties;
1
+ var T = Object.defineProperty, A = Object.defineProperties;
2
2
  var I = Object.getOwnPropertyDescriptors;
3
3
  var M = Object.getOwnPropertySymbols;
4
- var k = Object.prototype.hasOwnProperty, D = Object.prototype.propertyIsEnumerable;
5
- var R = (o, n, a) => n in o ? b(o, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[n] = a, f = (o, n) => {
4
+ var P = Object.prototype.hasOwnProperty, k = Object.prototype.propertyIsEnumerable;
5
+ var R = (o, n, a) => n in o ? T(o, n, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[n] = a, f = (o, n) => {
6
6
  for (var a in n || (n = {}))
7
- k.call(n, a) && R(o, a, n[a]);
7
+ P.call(n, a) && R(o, a, n[a]);
8
8
  if (M)
9
9
  for (var a of M(n))
10
- D.call(n, a) && R(o, a, n[a]);
10
+ k.call(n, a) && R(o, a, n[a]);
11
11
  return o;
12
12
  }, u = (o, n) => A(o, I(n));
13
13
  var w = (o, n, a) => (R(o, typeof n != "symbol" ? n + "" : n, a), a);
14
- var h = (o, n, a) => new Promise((m, i) => {
14
+ var h = (o, n, a) => new Promise((m, g) => {
15
15
  var d = (r) => {
16
16
  try {
17
- g(a.next(r));
17
+ l(a.next(r));
18
18
  } catch (c) {
19
- i(c);
19
+ g(c);
20
20
  }
21
21
  }, e = (r) => {
22
22
  try {
23
- g(a.throw(r));
23
+ l(a.throw(r));
24
24
  } catch (c) {
25
- i(c);
25
+ g(c);
26
26
  }
27
- }, g = (r) => r.done ? m(r.value) : Promise.resolve(r.value).then(d, e);
28
- g((a = a.apply(o, n)).next());
27
+ }, l = (r) => r.done ? m(r.value) : Promise.resolve(r.value).then(d, e);
28
+ l((a = a.apply(o, n)).next());
29
29
  });
30
- import { IHistoryRole as C, ChatMessageRole as P } from "@glodon-aiot/apis";
31
- import p from "./Logger.mjs";
32
- import O from "./Session.mjs";
30
+ import { IHistoryRole as b, PromptVariableType as p, ChatMessageRole as D } from "@glodon-aiot/apis";
31
+ import O from "./Logger.mjs";
32
+ import V from "./Session.mjs";
33
33
  import $ from "dayjs";
34
34
  import { configuration as y } from "./Config.mjs";
35
35
  import { fetchEventSource as v } from "./api/fetchEventSource/fetch.mjs";
36
- const T = new p("[DialogSession] ");
37
- class j extends O {
38
- constructor(a, m = "", i, d, e, g) {
39
- super(a, m, i, d, e, g);
36
+ const C = new O("[DialogSession] ");
37
+ class B extends V {
38
+ constructor(a, m = "", g, d, e, l) {
39
+ super(a, m, g, d, e, l);
40
40
  w(this, "ctrl", new AbortController());
41
41
  }
42
42
  prepareConnection() {
@@ -44,13 +44,13 @@ class j extends O {
44
44
  this._ready = !0, this.event.emit("ready"), this.frozen = !1, a(!0);
45
45
  }));
46
46
  }
47
- postChatV2EventSource(a, m, i, d, e, g) {
47
+ postChatV2EventSource(a, m, g, d, e, l) {
48
48
  return h(this, null, function* () {
49
49
  const r = {
50
50
  code: 0,
51
51
  // messageId: uuidv4(),
52
52
  content: "",
53
- role: C.Robot,
53
+ role: b.Robot,
54
54
  sessionId: m,
55
55
  reference: [],
56
56
  searchReference: [],
@@ -60,7 +60,7 @@ class j extends O {
60
60
  isAgree: 0
61
61
  },
62
62
  isReplying: !1
63
- }, c = u(f({}, i), {
63
+ }, c = u(f({}, g), {
64
64
  stream: y.stream
65
65
  });
66
66
  v(`${y.apiRoot}/chat/v2/chat?applicationId=${a}&sessionId=${m}`, {
@@ -72,17 +72,17 @@ class j extends O {
72
72
  body: JSON.stringify(c),
73
73
  openWhenHidden: !0,
74
74
  signal: d,
75
- onopen(l) {
76
- return l.ok && e != null && e.onopen && e.onopen(), Promise.resolve();
75
+ onopen(i) {
76
+ return i.ok && e != null && e.onopen && e.onopen(), Promise.resolve();
77
77
  },
78
- onmessage(l) {
79
- if (!l.data.includes('{"code": ')) {
78
+ onmessage(i) {
79
+ if (!i.data.includes('{"code": ')) {
80
80
  let t = {};
81
81
  try {
82
- t = JSON.parse(l.data);
82
+ t = JSON.parse(i.data);
83
83
  } catch (_) {
84
84
  }
85
- (t == null ? void 0 : t.mtype) === "search" ? r.searchReference.push(t) : r.content = r.content + l.data;
85
+ (t == null ? void 0 : t.mtype) === "search" ? r.searchReference.push(t) : r.content = r.content + i.data;
86
86
  const S = {
87
87
  content: r.content,
88
88
  role: 1,
@@ -98,7 +98,7 @@ class j extends O {
98
98
  };
99
99
  return (e == null ? void 0 : e.onmessage) && e.onmessage(S);
100
100
  }
101
- const s = JSON.parse(l.data);
101
+ const s = JSON.parse(i.data);
102
102
  if (r.reference = s.data.reference, r.searchReference = s.data.searchReference, r.messageTime = s.data.messageTime, r.messageId = s.data.messageId, r.llmModel = s.data.llmModel, r.content = s.data.content, r.code = s.code, s.code === 200) {
103
103
  const t = {
104
104
  code: r.code,
@@ -113,7 +113,7 @@ class j extends O {
113
113
  };
114
114
  e != null && e.onmessage && e.onmessage(t);
115
115
  } else
116
- return e != null && e.onclose && e.onclose(r), g && g({
116
+ return e != null && e.onclose && e.onclose(r), l && l({
117
117
  code: r.code,
118
118
  message: r.message
119
119
  });
@@ -122,7 +122,7 @@ class j extends O {
122
122
  e != null && e.onerror && e.onerror();
123
123
  },
124
124
  onclose() {
125
- const l = {
125
+ const i = {
126
126
  code: r.code,
127
127
  content: r.content,
128
128
  role: 1,
@@ -137,18 +137,18 @@ class j extends O {
137
137
  isReplying: !1,
138
138
  index: -1
139
139
  };
140
- e != null && e.onclose && e.onclose(l);
140
+ e != null && e.onclose && e.onclose(i);
141
141
  }
142
142
  });
143
143
  });
144
144
  }
145
- postChatV3EventSource(a, m, i, d, e, g) {
145
+ postChatV3EventSource(a, m, g, d, e, l) {
146
146
  return h(this, null, function* () {
147
147
  const r = this, c = {
148
148
  code: 0,
149
149
  // messageId: uuidv4(),
150
150
  content: "",
151
- role: C.Robot,
151
+ role: b.Robot,
152
152
  sessionId: m,
153
153
  reference: [],
154
154
  searchReference: [],
@@ -162,7 +162,7 @@ class j extends O {
162
162
  thinkingSecs: "",
163
163
  thinkingStatus: "",
164
164
  searchingStatus: ""
165
- }, l = u(f({}, i), {
165
+ }, i = u(f({}, g), {
166
166
  stream: y.stream
167
167
  });
168
168
  v(`${y.apiRoot}/chat/v3/chat?applicationId=${a}&sessionId=${m}`, {
@@ -171,7 +171,7 @@ class j extends O {
171
171
  Authorization: `Bearer ${this.token}`,
172
172
  "Content-Type": "application/json"
173
173
  },
174
- body: JSON.stringify(l),
174
+ body: JSON.stringify(i),
175
175
  openWhenHidden: !0,
176
176
  signal: d,
177
177
  onopen(s) {
@@ -187,7 +187,7 @@ class j extends O {
187
187
  console.error("parse eventData to JSON failed. ", s.data);
188
188
  }
189
189
  if (t.code !== 200)
190
- return c.index = -1, c.code = t.code, c.message = t.message, e != null && e.onmessage && e.onmessage(c), g && g({
190
+ return c.index = -1, c.code = t.code, c.message = t.message, e != null && e.onmessage && e.onmessage(c), l && l({
191
191
  code: t.code,
192
192
  message: t.message
193
193
  });
@@ -209,36 +209,39 @@ class j extends O {
209
209
  return h(this, null, function* () {
210
210
  var c;
211
211
  const {
212
- content: i,
212
+ content: g,
213
213
  fileIds: d,
214
214
  oldMessageId: e
215
215
  } = a, {
216
- stream: g,
216
+ stream: l,
217
217
  referenceFirst: r
218
218
  } = m;
219
219
  if (this.active || (yield this.activate()), this._id) {
220
- let l = {
221
- content: i,
220
+ let i = {
221
+ content: g,
222
222
  fileIds: d,
223
223
  referenceFirst: r,
224
224
  oldMessageId: e,
225
- promptVariables: this.promptVariables.reduce((s, t) => u(f({}, s), {
225
+ promptVariables: this.promptVariables.filter((s) => s.type === p.User).reduce((s, t) => u(f({}, s), {
226
+ [t.key]: t.value
227
+ }), {}),
228
+ systemPromptVariables: this.promptVariables.filter((s) => s.type === p.System).reduce((s, t) => u(f({}, s), {
226
229
  [t.key]: t.value
227
230
  }), {}),
228
231
  knowledges: (c = this.knowledges) == null ? void 0 : c.map((s) => s.id)
229
232
  };
230
- this.ctrl = new AbortController(), this.postChatV3EventSource(this._applicationId, this._id, l, this.ctrl.signal, {
233
+ this.ctrl = new AbortController(), this.postChatV3EventSource(this._applicationId, this._id, i, this.ctrl.signal, {
231
234
  onopen: () => {
232
- T.log("open", this.ctrl);
235
+ C.log("open", this.ctrl);
233
236
  },
234
237
  onmessage: (s) => {
235
238
  if (this._stopAnswer)
236
239
  return;
237
240
  let t = this.messages[this.messages.length - 1];
238
- t && t.role === P.Robot ? (t = f(f({}, t), s), this.messages[this.messages.length - 1] = t, this.event.emit("message:content", t), this.event.emit("message:updated", t)) : (this.pushMessage(s), this.event.emit("message:content", s));
241
+ t && t.role === D.Robot ? (t = f(f({}, t), s), this.messages[this.messages.length - 1] = t, this.event.emit("message:content", t), this.event.emit("message:updated", t)) : (this.pushMessage(s), this.event.emit("message:content", s));
239
242
  },
240
243
  onclose: (s) => h(this, null, function* () {
241
- this._stopAnswer || (T.log(s, "onclose"), this.event.emit("answer:finish", s));
244
+ this._stopAnswer || (C.log(s, "onclose"), this.event.emit("answer:finish", s));
242
245
  }),
243
246
  onerror: () => {
244
247
  this._stopAnswer || (this.event.emit("message:error", ""), this.frozen = !1);
@@ -267,5 +270,5 @@ class j extends O {
267
270
  }
268
271
  }
269
272
  export {
270
- j as default
273
+ B as default
271
274
  };
@@ -1,16 +1,16 @@
1
- var V = Object.defineProperty, x = Object.defineProperties;
2
- var Q = Object.getOwnPropertyDescriptors;
3
- var k = Object.getOwnPropertySymbols;
4
- var M = Object.prototype.hasOwnProperty, T = Object.prototype.propertyIsEnumerable;
5
- var S = (c, e, t) => e in c ? V(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t, f = (c, e) => {
1
+ var x = Object.defineProperty, Q = Object.defineProperties;
2
+ var T = Object.getOwnPropertyDescriptors;
3
+ var b = Object.getOwnPropertySymbols;
4
+ var M = Object.prototype.hasOwnProperty, R = Object.prototype.propertyIsEnumerable;
5
+ var k = (c, e, t) => e in c ? x(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t, f = (c, e) => {
6
6
  for (var t in e || (e = {}))
7
- M.call(e, t) && S(c, t, e[t]);
8
- if (k)
9
- for (var t of k(e))
10
- T.call(e, t) && S(c, t, e[t]);
7
+ M.call(e, t) && k(c, t, e[t]);
8
+ if (b)
9
+ for (var t of b(e))
10
+ R.call(e, t) && k(c, t, e[t]);
11
11
  return c;
12
- }, I = (c, e) => x(c, Q(e));
13
- var l = (c, e, t) => (S(c, typeof e != "symbol" ? e + "" : e, t), t);
12
+ }, I = (c, e) => Q(c, T(e));
13
+ var l = (c, e, t) => (k(c, typeof e != "symbol" ? e + "" : e, t), t);
14
14
  var d = (c, e, t) => new Promise((i, a) => {
15
15
  var o = (s) => {
16
16
  try {
@@ -27,17 +27,17 @@ var d = (c, e, t) => new Promise((i, a) => {
27
27
  }, r = (s) => s.done ? i(s.value) : Promise.resolve(s.value).then(o, h);
28
28
  r((t = t.apply(c, e)).next());
29
29
  });
30
- import { v4 as b } from "uuid";
31
- import { parseJWT as R, removeNewlines as C, removeLeadingAndTrailingBackslashes as O } from "./utils.mjs";
32
- import { ApplicationTypes as E, PromptStatus as z, ChatMessageRole as L } from "@glodon-aiot/apis";
33
- import P from "./Logger.mjs";
30
+ import { v4 as E } from "uuid";
31
+ import { parseJWT as C, removeNewlines as O, removeLeadingAndTrailingBackslashes as z } from "./utils.mjs";
32
+ import { ApplicationTypes as V, PromptStatus as P, PromptVariableType as L, ChatMessageRole as S } from "@glodon-aiot/apis";
33
+ import q from "./Logger.mjs";
34
34
  import { configuration as A } from "./Config.mjs";
35
- import q from "./EventBus.mjs";
36
- import { getCVForceService as F } from "./api/index.mjs";
37
- import N from "dayjs";
38
- const u = new P("[Session] ");
39
- var B = /* @__PURE__ */ ((c) => (c.DataRequestFailed = "data request error", c.SocketConnectionFailed = "socket error", c.IdUndefined = "session id is not defined", c.SendingEmptyContent = "failed at sending empty content", c.Frozen = "session is frozen", c.UserModeError = "failed at setting socket user mode", c.Inactive = "session is inactive", c))(B || {});
40
- class $ {
35
+ import F from "./EventBus.mjs";
36
+ import { getCVForceService as N } from "./api/index.mjs";
37
+ import B from "dayjs";
38
+ const u = new q("[Session] ");
39
+ var U = /* @__PURE__ */ ((c) => (c.DataRequestFailed = "data request error", c.SocketConnectionFailed = "socket error", c.IdUndefined = "session id is not defined", c.SendingEmptyContent = "failed at sending empty content", c.Frozen = "session is frozen", c.UserModeError = "failed at setting socket user mode", c.Inactive = "session is inactive", c))(U || {});
40
+ class X {
41
41
  /**
42
42
  * Session 类的构造函数,用于初始化会话实例。
43
43
  * @param token - 用户的身份验证令牌,用于解析应用 ID。
@@ -54,7 +54,7 @@ class $ {
54
54
  l(this, "inactivating", !1);
55
55
  l(this, "_ready", !1);
56
56
  // ready = false;
57
- l(this, "event", new q());
57
+ l(this, "event", new F());
58
58
  //从token解析出来的用户信息
59
59
  l(this, "_applicationId");
60
60
  l(this, "_application", null);
@@ -72,7 +72,7 @@ class $ {
72
72
  l(this, "_dataLoading", !1);
73
73
  l(this, "_dataLoaded", !1);
74
74
  l(this, "_mcpServers", null);
75
- this.token = e, this.lazyload = a, this.client = h || null, this._applicationId = R(e).rid || A.applicationId, this.cvforceApi = this.getService(), o && (this._application = o), this.event.emit("init", {
75
+ this.token = e, this.lazyload = a, this.client = h || null, this._applicationId = C(e).rid || A.applicationId, this.cvforceApi = this.getService(), o && (this._application = o), this.event.emit("init", {
76
76
  applicationId: this._applicationId,
77
77
  sessionId: t
78
78
  }), this.loadApplicationInfo().then(() => {
@@ -107,17 +107,17 @@ class $ {
107
107
  return this.setKnowledges((i == null ? void 0 : i.knowledges) || void 0);
108
108
  }))(), yield (() => {
109
109
  if (i != null && i.promptVariables) {
110
- const w = this._promptVariables.map((g) => {
111
- var y, v;
112
- const n = ((v = (y = i.promptVariables) == null ? void 0 : y.find((_) => _.key === g.key)) == null ? void 0 : v.value) || "";
110
+ const y = this._promptVariables.map((g) => {
111
+ var w, v;
112
+ const n = ((v = (w = i.promptVariables) == null ? void 0 : w.find((_) => _.key === g.key)) == null ? void 0 : v.value) || "";
113
113
  return I(f({}, g), {
114
114
  value: n
115
115
  });
116
116
  }).sort((g, n) => g.key.localeCompare(n.key));
117
- return this.setPromptVariables(w || []);
117
+ return this.setPromptVariables(y || []);
118
118
  } else
119
119
  return;
120
- })(), this.event.emit("data:created", this.data), this.event.emit("data:loaded", this.data), this.event.emit("data:updated", this.data), ((m = this.application) == null ? void 0 : m.type) !== E.Agent && (this._ready = !0, this.event.emit("ready"));
120
+ })(), this.event.emit("data:created", this.data), this.event.emit("data:loaded", this.data), this.event.emit("data:updated", this.data), ((m = this.application) == null ? void 0 : m.type) !== V.Agent && (this._ready = !0, this.event.emit("ready"));
121
121
  }));
122
122
  }
123
123
  });
@@ -181,12 +181,12 @@ class $ {
181
181
  throw Error("session id is not defined");
182
182
  if (!this.data)
183
183
  throw Error("session data is not loaded");
184
- const e = this.promptVariables.filter((t) => t.status === z.Quoted).filter((t) => !t.value);
184
+ const e = this.promptVariables.filter((t) => t.status === P.Quoted).filter((t) => !t.value);
185
185
  if (e.length)
186
186
  throw Error(`在提示词中被引用的变量值不能为空, 请检查以下变量: ${e.map((t) => t.key).join(", ")}`);
187
187
  }
188
188
  get promptVariables() {
189
- return this._promptVariables.filter((e) => e.key !== "query");
189
+ return this._promptVariables.filter((e) => !(e.type === L.User && e.key === "query") && !(e.type === L.System && e.key === "datetime"));
190
190
  }
191
191
  setPromptVariables(e) {
192
192
  return d(this, null, function* () {
@@ -197,7 +197,7 @@ class $ {
197
197
  value: a
198
198
  });
199
199
  }).sort((i, a) => i.key.localeCompare(a.key));
200
- if (yield Promise.all(t.filter((i) => i.key !== "query").map((i) => {
200
+ if (yield Promise.all(t.filter((i) => !(i.type === L.User && i.key === "query") && !(i.type === L.System && i.key === "datetime")).map((i) => {
201
201
  if (!this.data)
202
202
  throw Error("session data is not loaded");
203
203
  if (!(!i.id || !i.key))
@@ -224,7 +224,7 @@ class $ {
224
224
  setNetOpen(e) {
225
225
  return d(this, null, function* () {
226
226
  var t, i, a;
227
- if (u.log("setNetOpen:", e), u.log("application arrange setting value: ", (t = this._application) == null ? void 0 : t.arrange[0].enableNetOpen), ((i = this._application) == null ? void 0 : i.type) === E.Agent) {
227
+ if (u.log("setNetOpen:", e), u.log("application arrange setting value: ", (t = this._application) == null ? void 0 : t.arrange[0].enableNetOpen), ((i = this._application) == null ? void 0 : i.type) === V.Agent) {
228
228
  console.warn("Agent Application Sessions are disabled to setNetOpen.");
229
229
  return;
230
230
  }
@@ -243,7 +243,7 @@ class $ {
243
243
  });
244
244
  }
245
245
  getService() {
246
- return F(A.apiRoot, this.token, (e, t) => {
246
+ return N(A.apiRoot, this.token, (e, t) => {
247
247
  const i = new Error(
248
248
  "data request error"
249
249
  /* DataRequestFailed */
@@ -281,10 +281,10 @@ class $ {
281
281
  e = f(f({}, t), e), this.event.emit("history:loading"), u.log("history:loading"), (e.endTime || e.startTime) && (this.event.emit("history:moreloading", e), u.log("history:moreloading", e)), this._loadingMessages = !0;
282
282
  const o = yield this.cvforceApi.getChatHistorySessionId(this._applicationId, this._id, e), h = o.map((s, p) => {
283
283
  var g, n;
284
- let m = [], w;
285
- return typeof ((g = s.agentHistoryList) == null ? void 0 : g.agentList) == "string" && (m = JSON.parse(s.agentHistoryList.agentList).reduce((v, _) => (v[_.data.step - 1] || (v[_.data.step - 1] = []), v[_.data.step - 1].push(_), v), [])), p === o.length - 1 && (w = (n = this.data) == null ? void 0 : n.lastRelatedQuestion), I(f({}, s), {
284
+ let m = [], y;
285
+ return typeof ((g = s.agentHistoryList) == null ? void 0 : g.agentList) == "string" && (m = JSON.parse(s.agentHistoryList.agentList).reduce((v, _) => (v[_.data.step - 1] || (v[_.data.step - 1] = []), v[_.data.step - 1].push(_), v), [])), p === o.length - 1 && (y = (n = this.data) == null ? void 0 : n.lastRelatedQuestion), I(f({}, s), {
286
286
  actions: m,
287
- relatedQuesion: w
287
+ relatedQuesion: y
288
288
  });
289
289
  });
290
290
  if (!e.endTime && !e.startTime) {
@@ -404,7 +404,7 @@ class $ {
404
404
  const {
405
405
  stream: a = A.stream,
406
406
  referenceFirst: o = !1
407
- } = t, h = e.uuid || b(), r = ((g = e.text) == null ? void 0 : g.trim()) || "", s = e.fileIds;
407
+ } = t, h = e.uuid || E(), r = ((g = e.text) == null ? void 0 : g.trim()) || "", s = e.fileIds;
408
408
  if (!r && /*!files.length &&*/
409
409
  !(s != null && s.length)) {
410
410
  const n = new Error(
@@ -453,10 +453,10 @@ class $ {
453
453
  referenceFirst: o
454
454
  };
455
455
  this.pushMessage(p), this.event.emit("question:content", r);
456
- const w = (n) => d(this, null, function* () {
457
- if (n.role !== L.Robot)
456
+ const y = (n) => d(this, null, function* () {
457
+ if (n.role !== S.Robot)
458
458
  return;
459
- switch (this.removeEventListener("answer:finish", w), this._id && n.content && n.index && n.index < 0 && (this.data = yield this.cvforceApi.patchSessionsId(this.applicationId, this._id, {
459
+ switch (this.removeEventListener("answer:finish", y), this._id && n.content && n.index && n.index < 0 && (this.data = yield this.cvforceApi.patchSessionsId(this.applicationId, this._id, {
460
460
  finialMessage: n.content
461
461
  }), this.event.emit("data:updated", this.data), this.event.emit("data:updated:finialMessage", {
462
462
  finialMessage: n.content
@@ -471,15 +471,15 @@ class $ {
471
471
  n.content = n.message || "未知错误", n.isLoading = !1, n.index = -1, this.event.emit("message:error", n);
472
472
  }
473
473
  this.getRelatedQuesion(n), n.isLoading = !1;
474
- let y = this.messages[this.messages.length - 1];
475
- if (y && y.role === L.Robot) {
476
- const v = f(f({}, y), n);
474
+ let w = this.messages[this.messages.length - 1];
475
+ if (w && w.role === S.Robot) {
476
+ const v = f(f({}, w), n);
477
477
  this.messages[this.messages.length - 1] = v, this.event.emit("message:updated", v);
478
478
  } else
479
479
  this.pushMessage(n);
480
480
  this.frozen = !1;
481
481
  });
482
- return this.addEventListener("answer:finish", w), this.sendQuestion(m, I(f({}, t), {
482
+ return this.addEventListener("answer:finish", y), this.sendQuestion(m, I(f({}, t), {
483
483
  stream: a,
484
484
  referenceFirst: o
485
485
  })), p;
@@ -504,7 +504,7 @@ class $ {
504
504
  relatedQuesion: r
505
505
  }), this.event.emit("message:updated", s), s;
506
506
  }
507
- const i = (h = t.content) == null ? void 0 : h.split("*").map(C).map(O).filter((r) => !!r);
507
+ const i = (h = t.content) == null ? void 0 : h.split("*").map(O).map(z).filter((r) => !!r);
508
508
  e.relatedQuesion = i, e.index = -3, e.isLoading = !1;
509
509
  const a = I(f({}, e), {
510
510
  relatedQuesion: i,
@@ -534,7 +534,7 @@ class $ {
534
534
  stream: i = A.stream
535
535
  } = e;
536
536
  let a;
537
- t.role !== L.User && (a = e.oldMessageId || t.messageId, this.messages.splice(this.messages.length - 1, 1), this.event.emit("message:remove", t), this.event.emit("history:remove", t));
537
+ t.role !== S.User && (a = e.oldMessageId || t.messageId, this.messages.splice(this.messages.length - 1, 1), this.event.emit("message:remove", t), this.event.emit("history:remove", t));
538
538
  const o = this.messages[this.messages.length - 1], h = {
539
539
  content: o.content,
540
540
  fileIds: o.fileIds,
@@ -542,7 +542,7 @@ class $ {
542
542
  stream: i,
543
543
  oldMessageId: a
544
544
  }, r = (s) => d(this, null, function* () {
545
- if (s.role === L.Robot && s.index === -1) {
545
+ if (s.role === S.Robot && s.index === -1) {
546
546
  switch (this._id && s.content && s.index && s.index < 0 && (this.data = yield this.cvforceApi.patchSessionsId(this.applicationId, this._id, {
547
547
  finialMessage: s.content
548
548
  }), this.event.emit("data:updated", this.data), this.event.emit("data:updated:finialMessage", {
@@ -587,17 +587,17 @@ class $ {
587
587
  this.stopAnswer(), this.frozen = !1, this._stopAnswer = !0;
588
588
  let e = this.messages[this.messages.length - 1];
589
589
  const t = {
590
- messageId: b(),
590
+ messageId: E(),
591
591
  // 生成唯一的消息 ID
592
592
  isLoading: !1,
593
593
  // 标记消息已停止加载
594
594
  index: -2,
595
595
  // 消息索引,用于标识特殊状态
596
- messageTime: N(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:ss:mm"),
596
+ messageTime: B(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:ss:mm"),
597
597
  // 消息时间
598
598
  content: "",
599
599
  // 消息内容
600
- role: L.System,
600
+ role: S.System,
601
601
  // 消息角色为系统消息
602
602
  sessionId: this.id || "",
603
603
  // 会话 ID
@@ -661,7 +661,7 @@ class $ {
661
661
  return;
662
662
  }
663
663
  };
664
- if (i === "beforeSearch" && o(), i === "searchOver" && o(), i === "search" && t.searchReference.push(a), i === "thinking") {
664
+ if (i === "error" && (t.index = -1), i === "beforeSearch" && o(), i === "searchOver" && o(), i === "search" && t.searchReference.push(a), i === "thinking") {
665
665
  t.thinkingStatus = "start";
666
666
  const r = a.choices[0];
667
667
  t.reasoningContent = t.reasoningContent + r.delta.reasoningContent;
@@ -719,6 +719,6 @@ class $ {
719
719
  }
720
720
  }
721
721
  export {
722
- B as SessionErrors,
723
- $ as default
722
+ U as SessionErrors,
723
+ X as default
724
724
  };
@@ -1,4 +1,4 @@
1
- const e = "@glodon-aiot/bot-client-sdk", t = "3.3.2-beta.8", i = "glodoncv", s = "aiot bot client js sdk", n = "module", y = !1, o = [
1
+ const e = "@glodon-aiot/bot-client-sdk", t = "3.3.5-alpha.16", i = "glodoncv", s = "aiot bot client js sdk", n = "module", y = !1, o = [
2
2
  "aiot",
3
3
  "bot",
4
4
  "bot client",
@@ -23,7 +23,7 @@ const e = "@glodon-aiot/bot-client-sdk", t = "3.3.2-beta.8", i = "glodoncv", s =
23
23
  check: "yarn prettier --check .",
24
24
  write: "yarn prettier --write .",
25
25
  lint: "eslint --ext .tsx,.ts --fix ./example -c .eslintrc.js"
26
- }, b = {
26
+ }, g = {
27
27
  "@babel/core": "^7.20.12",
28
28
  "@commitlint/cli": "^17.0.3",
29
29
  "@commitlint/config-conventional": "^17.0.3",
@@ -55,11 +55,11 @@ const e = "@glodon-aiot/bot-client-sdk", t = "3.3.2-beta.8", i = "glodoncv", s =
55
55
  "vite-plugin-dts": "^4.3.0",
56
56
  "vite-plugin-externalize-deps": "^0.9.0",
57
57
  "vite-tsconfig-paths": "^5.1.4"
58
- }, g = {
58
+ }, m = {
59
59
  access: "public",
60
60
  registry: "https://registry.npmjs.org/"
61
- }, m = {
62
- "@glodon-aiot/apis": "^3.3.2-beta.8",
61
+ }, b = {
62
+ "@glodon-aiot/apis": "^3.3.5-alpha.16",
63
63
  axios: "0.24.0",
64
64
  buffer: "^6.0.3",
65
65
  dayjs: "^1.11.13",
@@ -81,19 +81,19 @@ const e = "@glodon-aiot/bot-client-sdk", t = "3.3.2-beta.8", i = "glodoncv", s =
81
81
  exports: d,
82
82
  license: a,
83
83
  scripts: u,
84
- devDependencies: b,
84
+ devDependencies: g,
85
85
  "lint-staged": {
86
86
  "*.{js,css,md,jsx,less,ts,tsx,json}": "prettier --write"
87
87
  },
88
- publishConfig: g,
89
- dependencies: m
88
+ publishConfig: m,
89
+ dependencies: b
90
90
  };
91
91
  export {
92
92
  i as author,
93
93
  x as default,
94
- m as dependencies,
94
+ b as dependencies,
95
95
  s as description,
96
- b as devDependencies,
96
+ g as devDependencies,
97
97
  d as exports,
98
98
  l as files,
99
99
  o as keywords,
@@ -101,7 +101,7 @@ export {
101
101
  c as main,
102
102
  p as module,
103
103
  e as name,
104
- g as publishConfig,
104
+ m as publishConfig,
105
105
  u as scripts,
106
106
  y as sideEffects,
107
107
  n as type,