@glodon-aiot/agent-cli-sdk 3.3.3 → 3.3.4-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,56 +1,56 @@
1
1
  var A = Object.defineProperty, O = Object.defineProperties;
2
2
  var D = Object.getOwnPropertyDescriptors;
3
- var C = Object.getOwnPropertySymbols;
3
+ var v = Object.getOwnPropertySymbols;
4
4
  var P = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable;
5
- var w = (i, c, t) => c in i ? A(i, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[c] = t, u = (i, c) => {
5
+ var C = (i, c, t) => c in i ? A(i, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[c] = t, u = (i, c) => {
6
6
  for (var t in c || (c = {}))
7
- P.call(c, t) && w(i, t, c[t]);
8
- if (C)
9
- for (var t of C(c))
10
- $.call(c, t) && w(i, t, c[t]);
7
+ P.call(c, t) && C(i, t, c[t]);
8
+ if (v)
9
+ for (var t of v(c))
10
+ $.call(c, t) && C(i, t, c[t]);
11
11
  return i;
12
12
  }, R = (i, c) => O(i, D(c));
13
- var v = (i, c, t) => (w(i, typeof c != "symbol" ? c + "" : c, t), t);
14
- var f = (i, c, t) => new Promise((o, m) => {
13
+ var k = (i, c, t) => (C(i, typeof c != "symbol" ? c + "" : c, t), t);
14
+ var f = (i, c, t) => new Promise((o, g) => {
15
15
  var d = (e) => {
16
16
  try {
17
- g(t.next(e));
17
+ m(t.next(e));
18
18
  } catch (l) {
19
- m(l);
19
+ g(l);
20
20
  }
21
21
  }, s = (e) => {
22
22
  try {
23
- g(t.throw(e));
23
+ m(t.throw(e));
24
24
  } catch (l) {
25
- m(l);
25
+ g(l);
26
26
  }
27
- }, g = (e) => e.done ? o(e.value) : Promise.resolve(e.value).then(d, s);
28
- g((t = t.apply(i, c)).next());
27
+ }, m = (e) => e.done ? o(e.value) : Promise.resolve(e.value).then(d, s);
28
+ m((t = t.apply(i, c)).next());
29
29
  });
30
- import { IHistoryRole as k, ChatMessageRole as _ } from "@glodon-aiot/apis";
30
+ import { IHistoryRole as T, ChatMessageRole as _ } from "@glodon-aiot/apis";
31
31
  import x from "./Logger.mjs";
32
32
  import J from "./Session.mjs";
33
33
  import N from "dayjs";
34
- import { configuration as T } from "./Config.mjs";
34
+ import { configuration as M } from "./Config.mjs";
35
35
  import { fetchEventSource as p } from "./api/fetchEventSource/fetch.mjs";
36
36
  const I = new x("[DialogSession] ");
37
37
  class H extends J {
38
- constructor(t, o = "", m, d, s, g) {
39
- super(t, o, m, d, s, g);
40
- v(this, "ctrl", new AbortController());
38
+ constructor(t, o = "", g, d, s, m) {
39
+ super(t, o, g, d, s, m);
40
+ k(this, "ctrl", new AbortController());
41
41
  }
42
42
  prepareConnection() {
43
43
  return new Promise((t) => f(this, null, function* () {
44
44
  this._ready = !0, this.event.emit("ready"), this.frozen = !1, t(!0);
45
45
  }));
46
46
  }
47
- postChatV2EventSource(t, o, m, d, s, g) {
47
+ postChatV2EventSource(t, o, g, d, s, m) {
48
48
  return f(this, null, function* () {
49
49
  const e = {
50
50
  code: 0,
51
51
  // messageId: uuidv4(),
52
52
  content: "",
53
- role: k.Robot,
53
+ role: T.Robot,
54
54
  sessionId: o,
55
55
  reference: [],
56
56
  searchReference: [],
@@ -60,10 +60,10 @@ class H extends J {
60
60
  isAgree: 0
61
61
  },
62
62
  isReplying: !1
63
- }, l = R(u({}, m), {
64
- stream: !0
63
+ }, l = R(u({}, g), {
64
+ stream: M.stream
65
65
  });
66
- p(`${T.apiRoot}/chat/v2/chat?applicationId=${t}&sessionId=${o}`, {
66
+ p(`${M.apiRoot}/chat/v2/chat?applicationId=${t}&sessionId=${o}`, {
67
67
  method: "POST",
68
68
  headers: {
69
69
  Authorization: `Bearer ${this.token}`,
@@ -80,7 +80,7 @@ class H extends J {
80
80
  let a = {};
81
81
  try {
82
82
  a = JSON.parse(n.data);
83
- } catch (M) {
83
+ } catch (w) {
84
84
  }
85
85
  (a == null ? void 0 : a.mtype) === "search" ? e.searchReference.push(a) : e.content = e.content + n.data;
86
86
  const h = {
@@ -113,7 +113,7 @@ class H extends J {
113
113
  };
114
114
  s != null && s.onmessage && s.onmessage(a);
115
115
  } else
116
- return s != null && s.onclose && s.onclose(e), g && g({
116
+ return s != null && s.onclose && s.onclose(e), m && m({
117
117
  code: e.code,
118
118
  message: e.message
119
119
  });
@@ -142,13 +142,13 @@ class H extends J {
142
142
  });
143
143
  });
144
144
  }
145
- postChatV3EventSource(t, o, m, d, s, g) {
145
+ postChatV3EventSource(t, o, g, d, s, m) {
146
146
  return f(this, null, function* () {
147
147
  const e = {
148
148
  code: 0,
149
149
  // messageId: uuidv4(),
150
150
  content: "",
151
- role: k.Robot,
151
+ role: T.Robot,
152
152
  sessionId: o,
153
153
  reference: [],
154
154
  searchReference: [],
@@ -162,10 +162,10 @@ class H extends J {
162
162
  thinkingSecs: "",
163
163
  thinkingStatus: "",
164
164
  searchingStatus: ""
165
- }, l = R(u({}, m), {
166
- stream: !0
165
+ }, l = R(u({}, g), {
166
+ stream: M.stream
167
167
  });
168
- p(`${T.apiRoot}/chat/v3/chat?applicationId=${t}&sessionId=${o}`, {
168
+ p(`${M.apiRoot}/chat/v3/chat?applicationId=${t}&sessionId=${o}`, {
169
169
  method: "POST",
170
170
  headers: {
171
171
  Authorization: `Bearer ${this.token}`,
@@ -187,13 +187,13 @@ class H extends J {
187
187
  console.error("parse eventData to JSON failed. ", n.data);
188
188
  }
189
189
  if (r.code !== 200)
190
- return e.index = -1, e.code = r.code, e.message = r.message, s != null && s.onmessage && s.onmessage(e), g && g({
190
+ return e.index = -1, e.code = r.code, e.message = r.message, s != null && s.onmessage && s.onmessage(e), m && m({
191
191
  code: r.code,
192
192
  message: r.message
193
193
  });
194
194
  const a = r.data.type, h = r.data.payload;
195
195
  e.isReplying = !0;
196
- const M = () => {
196
+ const w = () => {
197
197
  if (!e.searchingStatus) {
198
198
  e.searchingStatus = "start";
199
199
  return;
@@ -203,7 +203,7 @@ class H extends J {
203
203
  return;
204
204
  }
205
205
  };
206
- if (a === "beforeSearch" && M(), a === "searchOver" && M(), a === "search" && e.searchReference.push(h), a === "thinking") {
206
+ if (a === "beforeSearch" && w(), a === "searchOver" && w(), a === "search" && e.searchReference.push(h), a === "thinking") {
207
207
  e.thinkingStatus = "start";
208
208
  const S = h.choices[0];
209
209
  e.reasoningContent = e.reasoningContent + S.delta.reasoningContent;
@@ -239,16 +239,16 @@ class H extends J {
239
239
  return f(this, null, function* () {
240
240
  var l;
241
241
  const {
242
- content: m,
242
+ content: g,
243
243
  fileIds: d,
244
244
  oldMessageId: s
245
245
  } = t, {
246
- stream: g,
246
+ stream: m,
247
247
  referenceFirst: e
248
248
  } = o;
249
249
  if (this.active || (yield this.activate()), this._id) {
250
250
  let n = {
251
- content: m,
251
+ content: g,
252
252
  fileIds: d,
253
253
  referenceFirst: e,
254
254
  oldMessageId: s,