@glodon-aiot/bot-client-sdk 3.5.2-beta.0 → 3.6.0-alpha.10

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,43 +1,43 @@
1
- var V = 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 ? V(c, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[e] = t, f = (c, e) => {
1
+ var Q = Object.defineProperty, T = Object.defineProperties;
2
+ var M = Object.getOwnPropertyDescriptors;
3
+ var E = Object.getOwnPropertySymbols;
4
+ var C = Object.prototype.hasOwnProperty, R = Object.prototype.propertyIsEnumerable;
5
+ var k = (c, e, t) => e in c ? Q(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) && k(c, t, e[t]);
8
- if (b)
9
- for (var t of b(e))
7
+ C.call(e, t) && k(c, t, e[t]);
8
+ if (E)
9
+ for (var t of E(e))
10
10
  R.call(e, t) && k(c, t, e[t]);
11
11
  return c;
12
- }, I = (c, e) => Q(c, T(e));
12
+ }, y = (c, e) => T(c, M(e));
13
13
  var p = (c, e, t) => (k(c, typeof e != "symbol" ? e + "" : e, t), t);
14
- var h = (c, e, t) => new Promise((i, n) => {
14
+ var h = (c, e, t) => new Promise((i, o) => {
15
15
  var a = (s) => {
16
16
  try {
17
17
  r(t.next(s));
18
18
  } catch (l) {
19
- n(l);
19
+ o(l);
20
20
  }
21
21
  }, d = (s) => {
22
22
  try {
23
23
  r(t.throw(s));
24
24
  } catch (l) {
25
- n(l);
25
+ o(l);
26
26
  }
27
27
  }, r = (s) => s.done ? i(s.value) : Promise.resolve(s.value).then(a, d);
28
28
  r((t = t.apply(c, e)).next());
29
29
  });
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 x, PromptStatus as P, PromptVariableType as L, ChatMessageRole as S } from "@glodon-aiot/apis";
33
- import q from "./Logger.mjs";
30
+ import { v4 as x } from "uuid";
31
+ import { parseJWT as O, removeNewlines as z, removeLeadingAndTrailingBackslashes as P } from "./utils.mjs";
32
+ import { ApplicationTypes as V, PromptStatus as q, PromptVariableType as L, ChatMessageRole as S } from "@glodon-aiot/apis";
33
+ import F from "./Logger.mjs";
34
34
  import { configuration as A } from "./Config.mjs";
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 {
35
+ import N from "./EventBus.mjs";
36
+ import { getCVForceService as B } from "./api/index.mjs";
37
+ import U from "dayjs";
38
+ const u = new F("[Session] ");
39
+ var H = /* @__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))(H || {});
40
+ class Z {
41
41
  /**
42
42
  * Session 类的构造函数,用于初始化会话实例。
43
43
  * @param token - 用户的身份验证令牌,用于解析应用 ID。
@@ -47,14 +47,14 @@ class X {
47
47
  * @param _application - 应用信息,可选参数。
48
48
  * @param client - Bot 客户端实例,可选参数。
49
49
  */
50
- constructor(e, t = "", i, n, a, d) {
50
+ constructor(e, t = "", i, o, a, d) {
51
51
  p(this, "_id");
52
52
  p(this, "_frozen", !1);
53
53
  //是否可发送新问题
54
54
  p(this, "inactivating", !1);
55
55
  p(this, "_ready", !1);
56
56
  // ready = false;
57
- p(this, "event", new F());
57
+ p(this, "event", new N());
58
58
  //从token解析出来的用户信息
59
59
  p(this, "_applicationId");
60
60
  p(this, "_application", null);
@@ -72,13 +72,13 @@ class X {
72
72
  p(this, "_dataLoading", !1);
73
73
  p(this, "_dataLoaded", !1);
74
74
  p(this, "_mcpServers", null);
75
- this.token = e, this.lazyload = n, this.client = d || null, this._applicationId = C(e).rid || A.applicationId, this.cvforceApi = this.getService(), a && (this._application = a), this.event.emit("init", {
75
+ this.token = e, this.lazyload = o, this.client = d || null, this._applicationId = O(e).rid || A.applicationId, this.cvforceApi = this.getService(), a && (this._application = a), this.event.emit("init", {
76
76
  applicationId: this._applicationId,
77
77
  sessionId: t
78
78
  }), this.loadApplicationInfo().then(() => {
79
79
  var r;
80
80
  if (t)
81
- this._id = t, this.event.emit("data:loading"), i ? (this.data = i, n || (this._dataLoading = !0, this.cvforceApi.getSession(this.applicationId, t).then((s) => h(this, null, function* () {
81
+ this._id = t, this.event.emit("data:loading"), i ? (this.data = i, o || (this._dataLoading = !0, this.cvforceApi.getSession(this.applicationId, t).then((s) => h(this, null, function* () {
82
82
  this.data = s, this._promptVariables = yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId, t);
83
83
  })).then(() => h(this, null, function* () {
84
84
  this.messages = [], yield this.fetchMessages(), this.event.emit("data:loaded", this.data), this.event.emit("data:updated", this.data);
@@ -100,24 +100,24 @@ class X {
100
100
  applicationId: this._applicationId
101
101
  }).then((l) => h(this, null, function* () {
102
102
  var m;
103
- this._id = l.id, this.data = I(f({}, l), {
103
+ this._id = l.id, this.data = y(f({}, l), {
104
104
  knowledges: i == null ? void 0 : i.knowledges
105
105
  }), this._promptVariables = yield this.cvforceApi.getApplicationIdSessionIdPromptVariables(this.applicationId, this._id), yield (() => h(this, null, function* () {
106
106
  if (i != null && i.knowledges)
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 _ = this._promptVariables.map((g) => {
111
- var o, v;
112
- const w = ((v = (o = i.promptVariables) == null ? void 0 : o.find((y) => y.key === g.key && y.type === g.type)) == null ? void 0 : v.value) || "";
113
- return I(f({}, g), {
114
- value: w
110
+ const w = this._promptVariables.map((v) => {
111
+ var _, n;
112
+ const I = ((n = (_ = i.promptVariables) == null ? void 0 : _.find((g) => g.key === v.key && g.type === v.type)) == null ? void 0 : n.value) || "";
113
+ return y(f({}, v), {
114
+ value: I
115
115
  });
116
- }).sort((g, w) => g.key.localeCompare(w.key));
117
- return this.setPromptVariables(_ || []);
116
+ }).sort((v, I) => v.key.localeCompare(I.key));
117
+ return this.setPromptVariables(w || []);
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) !== x.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,7 +181,7 @@ class X {
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 === P.Quoted).filter((t) => !t.value);
184
+ const e = this.promptVariables.filter((t) => t.status === q.Quoted).filter((t) => !t.value);
185
185
  if (e.length)
186
186
  throw Error(`在提示词中被引用的变量值不能为空, 请检查以下变量: ${e.map((t) => t.key).join(", ")}`);
187
187
  }
@@ -190,12 +190,12 @@ class X {
190
190
  }
191
191
  setPromptVariables(e) {
192
192
  return h(this, null, function* () {
193
- const t = e == null ? void 0 : e.map((a) => a.type ? a : I(f({}, a), {
193
+ const t = e == null ? void 0 : e.map((a) => a.type ? a : y(f({}, a), {
194
194
  type: "instruction"
195
195
  })), i = this._promptVariables.map((a) => {
196
196
  var r;
197
197
  const d = ((r = t == null ? void 0 : t.find((s) => s.key === a.key && s.type === a.type)) == null ? void 0 : r.value) || a.value;
198
- return I(f({}, a), {
198
+ return y(f({}, a), {
199
199
  value: d
200
200
  });
201
201
  }).sort((a, d) => a.key.localeCompare(d.key));
@@ -227,12 +227,12 @@ class X {
227
227
  */
228
228
  setNetOpen(e) {
229
229
  return h(this, null, function* () {
230
- var t, i, n;
231
- 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) === x.Agent) {
230
+ var t, i, o;
231
+ 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) {
232
232
  console.warn("Agent Application Sessions are disabled to setNetOpen.");
233
233
  return;
234
234
  }
235
- if (((n = this._application) == null ? void 0 : n.arrange[0].enableNetOpen) === !1) {
235
+ if (((o = this._application) == null ? void 0 : o.arrange[0].enableNetOpen) === !1) {
236
236
  console.warn("This Application is disabled to change netOpen.");
237
237
  return;
238
238
  }
@@ -247,7 +247,7 @@ class X {
247
247
  });
248
248
  }
249
249
  getService() {
250
- return N(A.apiRoot, this.token, (e, t) => {
250
+ return B(A.apiRoot, this.token, (e, t) => {
251
251
  const i = new Error("data request error", {
252
252
  cause: {
253
253
  status: e,
@@ -276,18 +276,18 @@ class X {
276
276
  */
277
277
  fetchMessages() {
278
278
  return h(this, arguments, function* (e = {}) {
279
- var i, n;
279
+ var i, o;
280
280
  const t = {
281
281
  pageSize: this._loadingMessagesSize
282
282
  };
283
283
  if (this._id) {
284
284
  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;
285
285
  const a = yield this.cvforceApi.getChatHistorySessionId(this._applicationId, this._id, e), d = a.map((s, l) => {
286
- var g, w;
287
- let m = [], _;
288
- return typeof ((g = s.agentHistoryList) == null ? void 0 : g.agentList) == "string" && (m = JSON.parse(s.agentHistoryList.agentList).reduce((v, y) => (v[y.data.step - 1] || (v[y.data.step - 1] = []), v[y.data.step - 1].push(y), v), [])), l === a.length - 1 && (_ = (w = this.data) == null ? void 0 : w.lastRelatedQuestion), I(f({}, s), {
286
+ var v, I;
287
+ let m = [], w;
288
+ return typeof ((v = s.agentHistoryList) == null ? void 0 : v.agentList) == "string" && (m = JSON.parse(s.agentHistoryList.agentList).reduce((n, g) => (n[g.data.step - 1] || (n[g.data.step - 1] = []), n[g.data.step - 1].push(g), n), [])), l === a.length - 1 && (w = (I = this.data) == null ? void 0 : I.lastRelatedQuestion), y(f({}, s), {
289
289
  actions: m,
290
- relatedQuesion: _
290
+ relatedQuesion: w
291
291
  });
292
292
  });
293
293
  if (!e.endTime && !e.startTime) {
@@ -304,7 +304,7 @@ class X {
304
304
  this.messages.splice(s, l - s + 1, ...d);
305
305
  }
306
306
  const r = this.messages[this.messages.length - 1];
307
- return r && !r.relatedQuesion && (r.relatedQuesion = (n = this.data) == null ? void 0 : n.lastRelatedQuestion), this.event.emit("history:moreloaded", d), u.log("history:loaded", this.messages), this.event.emit("history:loaded", this.messages), this._loadingMessages = !1, d;
307
+ return r && !r.relatedQuesion && (r.relatedQuesion = (o = this.data) == null ? void 0 : o.lastRelatedQuestion), this.event.emit("history:moreloaded", d), u.log("history:loaded", this.messages), this.event.emit("history:loaded", this.messages), this._loadingMessages = !1, d;
308
308
  } else {
309
309
  const a = new Error(
310
310
  "session id is not defined"
@@ -398,48 +398,48 @@ class X {
398
398
  return h(this, arguments, function* (e, t = {
399
399
  stream: A.stream
400
400
  }) {
401
- var w;
401
+ var _;
402
402
  try {
403
403
  this.validateConfigs();
404
- } catch (o) {
405
- console.error(o);
404
+ } catch (n) {
405
+ console.error(n);
406
406
  }
407
407
  const {
408
- stream: n = A.stream,
408
+ stream: o = A.stream,
409
409
  referenceFirst: a = !1
410
- } = t, d = e.uuid || E(), r = ((w = e.text) == null ? void 0 : w.trim()) || "", s = e.files || [], l = e.fileIds;
410
+ } = t, d = e.uuid || x(), r = ((_ = e.text) == null ? void 0 : _.trim()) || "", s = e.files || [], l = e.fileIds, m = e.imageContent;
411
411
  if (!r && !s.length && !(l != null && l.length)) {
412
- const o = new Error(
412
+ const n = new Error(
413
413
  "failed at sending empty content"
414
414
  /* SendingEmptyContent */
415
415
  // {
416
416
  // cause: SESSION_ERROR_CAUSE[SessionErrors.SendingEmptyContent],
417
417
  // }
418
418
  );
419
- return u.error(o), this.event.emit("error", o), !1;
419
+ return u.error(n), this.event.emit("error", n), !1;
420
420
  }
421
421
  if (!this._id) {
422
- const o = new Error(
422
+ const n = new Error(
423
423
  "session id is not defined"
424
424
  /* IdUndefined */
425
425
  // {
426
426
  // cause: SESSION_ERROR_CAUSE[SessionErrors.IdUndefined],
427
427
  // }
428
428
  );
429
- return u.error(o), this.event.emit("error", o), !1;
429
+ return u.error(n), this.event.emit("error", n), !1;
430
430
  }
431
431
  if (this.frozen) {
432
- const o = new Error(
432
+ const n = new Error(
433
433
  "session is frozen"
434
434
  /* Frozen */
435
435
  // {
436
436
  // cause: { code: -1, message: 'session is frozen.' },
437
437
  // }
438
438
  );
439
- return u.error(o), this.event.emit("error", o), !1;
439
+ return u.error(n), this.event.emit("error", n), !1;
440
440
  }
441
441
  this.frozen = !0, this._stopAnswer = !1;
442
- const m = {
442
+ const w = {
443
443
  sessionId: this.id,
444
444
  role: 2,
445
445
  content: r,
@@ -447,45 +447,47 @@ class X {
447
447
  reference: [],
448
448
  searchReference: [],
449
449
  messageTime: "",
450
- files: s
451
- }, _ = {
450
+ files: s,
451
+ imageContent: m
452
+ }, v = {
452
453
  content: r,
453
- stream: n,
454
+ stream: o,
454
455
  requestId: d,
455
456
  fileIds: l,
456
- referenceFirst: a
457
+ referenceFirst: a,
458
+ imageContent: m
457
459
  };
458
- this.pushMessage(m), this.event.emit("question:content", r);
459
- const g = (o) => h(this, null, function* () {
460
- if (o.role !== S.Robot)
460
+ this.pushMessage(w), this.event.emit("question:content", r);
461
+ const I = (n) => h(this, null, function* () {
462
+ if (n.role !== S.Robot)
461
463
  return;
462
- switch (this.removeEventListener("answer:finish", g), this._id && o.content && o.index && o.index < 0 && (this.data = yield this.cvforceApi.patchSessionsId(this.applicationId, this._id, {
463
- finialMessage: o.content
464
+ switch (this.removeEventListener("answer:finish", I), this._id && n.content && n.index && n.index < 0 && (this.data = yield this.cvforceApi.patchSessionsId(this.applicationId, this._id, {
465
+ finialMessage: n.content
464
466
  }), this.event.emit("data:updated", this.data), this.event.emit("data:updated:finialMessage", {
465
- finialMessage: o.content
466
- })), yield this.fillMessageReference(o), o.code) {
467
+ finialMessage: n.content
468
+ })), yield this.fillMessageReference(n), n.code) {
467
469
  case 11915:
468
- o.content = "请您换个问题问我吧~", o.index = -1, o.isSensitive = !0, o.isLoading = !1, o.sessionId = this._id || "", this.event.emit("message:error", o);
470
+ n.content = "请您换个问题问我吧~", n.index = -1, n.isSensitive = !0, n.isLoading = !1, n.sessionId = this._id || "", this.event.emit("message:error", n);
469
471
  break;
470
472
  case 200:
471
- o.index = -1, o.isLoading = !1;
473
+ n.index = -1, n.isLoading = !1;
472
474
  break;
473
475
  default:
474
- o.content = o.message || "未知错误", o.isLoading = !1, o.index = -1, this.event.emit("message:error", o);
476
+ n.content = n.message || "未知错误", n.isLoading = !1, n.index = -1, this.event.emit("message:error", n);
475
477
  }
476
- this.getRelatedQuesion(o), o.isLoading = !1;
477
- let v = this.messages[this.messages.length - 1];
478
- if (v && v.role === S.Robot) {
479
- const y = f(f({}, v), o);
480
- this.messages[this.messages.length - 1] = y, this.event.emit("message:updated", y);
478
+ this.getRelatedQuesion(n), n.isLoading = !1;
479
+ let g = this.messages[this.messages.length - 1];
480
+ if (g && g.role === S.Robot) {
481
+ const b = f(f({}, g), n);
482
+ this.messages[this.messages.length - 1] = b, this.event.emit("message:updated", b);
481
483
  } else
482
- this.pushMessage(o);
484
+ this.pushMessage(n);
483
485
  this.frozen = !1;
484
486
  });
485
- return this.addEventListener("answer:finish", g), this.sendQuestion(_, I(f({}, t), {
486
- stream: n,
487
+ return this.addEventListener("answer:finish", I), this.sendQuestion(v, y(f({}, t), {
488
+ stream: o,
487
489
  referenceFirst: a
488
- })), m;
490
+ })), w;
489
491
  });
490
492
  }
491
493
  getRelatedQuesion(e) {
@@ -498,7 +500,7 @@ class X {
498
500
  content: e.content
499
501
  }).catch((r) => null);
500
502
  if (!t) {
501
- const r = [], s = I(f({}, e), {
503
+ const r = [], s = y(f({}, e), {
502
504
  relatedQuesion: r,
503
505
  index: -3,
504
506
  isLoading: !1
@@ -507,23 +509,23 @@ class X {
507
509
  relatedQuesion: r
508
510
  }), this.event.emit("message:updated", s), s;
509
511
  }
510
- const i = (d = t.content) == null ? void 0 : d.split("*").map(O).map(z).filter((r) => !!r);
512
+ const i = (d = t.content) == null ? void 0 : d.split("*").map(z).map(P).filter((r) => !!r);
511
513
  e.relatedQuesion = i, e.index = -3, e.isLoading = !1;
512
- const n = I(f({}, e), {
514
+ const o = y(f({}, e), {
513
515
  relatedQuesion: i,
514
516
  index: -3,
515
517
  isLoading: !1
516
518
  });
517
- return this.event.emit("message:relatedQuesion:loaded", n), this.event.emit("message:updated", n), this._id && this.cvforceApi.patchSessionsId(this._applicationId, this._id, {
519
+ return this.event.emit("message:relatedQuesion:loaded", o), this.event.emit("message:updated", o), this._id && this.cvforceApi.patchSessionsId(this._applicationId, this._id, {
518
520
  lastRelatedQuestion: i
519
- }), n;
521
+ }), o;
520
522
  });
521
523
  }
522
524
  fillMessageReference(e) {
523
525
  return h(this, null, function* () {
524
526
  try {
525
527
  const t = yield Promise.all(e.reference.map((i) => this.cvforceApi.getKnowledgeIdFileId(i.knowledgeId, i.docId)));
526
- e.reference = e.reference.map((i, n) => f(f({}, i), t[n]));
528
+ e.reference = e.reference.map((i, o) => f(f({}, i), t[o]));
527
529
  } catch (t) {
528
530
  console.error("Failed to fill message reference:", t);
529
531
  }
@@ -541,14 +543,14 @@ class X {
541
543
  const {
542
544
  stream: i = A.stream
543
545
  } = e;
544
- let n;
545
- t.role !== S.User && (n = e.oldMessageId || t.messageId, this.messages.splice(this.messages.length - 1, 1), this.event.emit("message:remove", t), this.event.emit("history:remove", t));
546
+ let o;
547
+ t.role !== S.User && (o = e.oldMessageId || t.messageId, this.messages.splice(this.messages.length - 1, 1), this.event.emit("message:remove", t), this.event.emit("history:remove", t));
546
548
  const a = this.messages[this.messages.length - 1], d = {
547
549
  content: a.content,
548
550
  fileIds: a.fileIds,
549
551
  requestId: a.messageId,
550
552
  stream: i,
551
- oldMessageId: n
553
+ oldMessageId: o
552
554
  }, r = (s) => h(this, null, function* () {
553
555
  if (s.role === S.Robot && s.index === -1) {
554
556
  switch (this._id && s.content && s.index && s.index < 0 && (this.data = yield this.cvforceApi.patchSessionsId(this.applicationId, this._id, {
@@ -568,7 +570,7 @@ class X {
568
570
  this.getRelatedQuesion(s), this.removeEventListener("message:content", r), this.frozen = !1;
569
571
  }
570
572
  });
571
- this.addEventListener("message:content", r), this.sendQuestion(d, I(f({}, e), {
573
+ this.addEventListener("message:content", r), this.sendQuestion(d, y(f({}, e), {
572
574
  stream: i
573
575
  }));
574
576
  });
@@ -595,13 +597,13 @@ class X {
595
597
  this.stopAnswer(), this.frozen = !1, this._stopAnswer = !0;
596
598
  let e = this.messages[this.messages.length - 1];
597
599
  const t = {
598
- messageId: E(),
600
+ messageId: x(),
599
601
  // 生成唯一的消息 ID
600
602
  isLoading: !1,
601
603
  // 标记消息已停止加载
602
604
  index: -2,
603
605
  // 消息索引,用于标识特殊状态
604
- messageTime: B(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:ss:mm"),
606
+ messageTime: U(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:ss:mm"),
605
607
  // 消息时间
606
608
  content: "",
607
609
  // 消息内容
@@ -618,9 +620,9 @@ class X {
618
620
  if (e.index === -2)
619
621
  return;
620
622
  if (e.actions) {
621
- const n = e.actions[((i = e.actions) == null ? void 0 : i.length) - 1];
622
- if (n) {
623
- const a = n[n.length - 1];
623
+ const o = e.actions[((i = e.actions) == null ? void 0 : i.length) - 1];
624
+ if (o) {
625
+ const a = o[o.length - 1];
624
626
  if (a && (a.type === "BEFORE_CALL" || a.type === "FUNCTION_CALL")) {
625
627
  const {
626
628
  pluginName: d,
@@ -628,7 +630,7 @@ class X {
628
630
  funcCode: s,
629
631
  funcName: l
630
632
  } = a.data;
631
- n.push({
633
+ o.push({
632
634
  data: {
633
635
  pluginName: d,
634
636
  pluginCode: r,
@@ -639,7 +641,7 @@ class X {
639
641
  type: "ABORT"
640
642
  }), this.event.emit("message:action", {
641
643
  messageId: e.messageId,
642
- action: n
644
+ action: o
643
645
  });
644
646
  }
645
647
  }
@@ -657,7 +659,7 @@ class X {
657
659
  handleStreamAnswer(e, t) {
658
660
  if (!e.data)
659
661
  return;
660
- const i = e.data.type, n = e.data.payload;
662
+ const i = e.data.type, o = e.data.payload;
661
663
  t.isReplying = !0;
662
664
  const a = () => {
663
665
  if (!t.searchingStatus) {
@@ -669,22 +671,22 @@ class X {
669
671
  return;
670
672
  }
671
673
  };
672
- if (i === "error" && (t.index = -1), i === "beforeSearch" && a(), i === "searchOver" && a(), i === "search" && t.searchReference.push(n), i === "thinking") {
674
+ if (i === "error" && (t.index = -1), i === "beforeSearch" && a(), i === "searchOver" && a(), i === "search" && t.searchReference.push(o), i === "thinking") {
673
675
  t.thinkingStatus = "start";
674
- const r = n.choices[0];
676
+ const r = o.choices[0];
675
677
  t.reasoningContent = t.reasoningContent + r.delta.reasoningContent;
676
678
  }
677
679
  if (i === "thinkingOver") {
678
680
  t.thinkingStatus = "end";
679
- const d = n.thinkingSecs;
681
+ const d = o.thinkingSecs;
680
682
  t.thinkingSecs = d;
681
683
  }
682
684
  if (i === "text") {
683
- const r = n.choices[0];
685
+ const r = o.choices[0];
684
686
  t.content = t.content + r.delta.content;
685
687
  }
686
- if (i === "reference" && (t.reference = n), i === "updateSession" && n && this.data && (this.data = f(f({}, this.data), n), this.event.emit("data:updated", this.data)), i === "result") {
687
- const d = n.messageId, r = n.llmModel, s = n.messageTime;
688
+ if (i === "reference" && (t.reference = o), i === "updateSession" && o && this.data && (this.data = f(f({}, this.data), o), this.event.emit("data:updated", this.data)), i === "result") {
689
+ const d = o.messageId, r = o.llmModel, s = o.messageTime;
688
690
  t.messageId = d, t.llmModel = r, t.messageTime = s;
689
691
  }
690
692
  i === "over" ? t.index = -1 : (t.code = e.code, t.message = e.message);
@@ -699,7 +701,7 @@ class X {
699
701
  if (!this._applicationId || !this._id)
700
702
  throw Error("session is not avalible. id is undefined");
701
703
  return this.cvforceApi.postComments(this._applicationId, this._id, e).then((t) => {
702
- const i = this.messages.find((n) => n.messageId === e.messageId);
704
+ const i = this.messages.find((o) => o.messageId === e.messageId);
703
705
  return i && (i.comment = e, this.event.emit("message:comment", i)), t;
704
706
  });
705
707
  });
@@ -727,6 +729,6 @@ class X {
727
729
  }
728
730
  }
729
731
  export {
730
- U as SessionErrors,
731
- X as default
732
+ H as SessionErrors,
733
+ Z as default
732
734
  };
@@ -1,4 +1,4 @@
1
- const e = "@glodon-aiot/bot-client-sdk", t = "3.5.2-beta.0", i = "glodoncv", s = "aiot bot client js sdk", n = "module", y = !1, o = [
1
+ const e = "@glodon-aiot/bot-client-sdk", t = "3.6.0-alpha.10", 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.5.2-beta.0", 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.5.2-beta.0", 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.5.2-beta.0",
61
+ }, b = {
62
+ "@glodon-aiot/apis": "^3.6.0-alpha.10",
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.5.2-beta.0", 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,