@glodon-aiot/agent-cli-sdk 3.25.0-alpha.9 → 3.25.1-alpha.0

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,39 +1,39 @@
1
- var R = Object.defineProperty, S = Object.defineProperties;
2
- var b = Object.getOwnPropertyDescriptors;
3
- var _ = Object.getOwnPropertySymbols;
4
- var A = Object.prototype.hasOwnProperty, E = Object.prototype.propertyIsEnumerable;
5
- var P = (d, t, n) => t in d ? R(d, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : d[t] = n, h = (d, t) => {
1
+ var b = Object.defineProperty, A = Object.defineProperties;
2
+ var E = Object.getOwnPropertyDescriptors;
3
+ var R = Object.getOwnPropertySymbols;
4
+ var q = Object.prototype.hasOwnProperty, x = Object.prototype.propertyIsEnumerable;
5
+ var S = (d, t, n) => t in d ? b(d, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : d[t] = n, g = (d, t) => {
6
6
  for (var n in t || (t = {}))
7
- A.call(t, n) && P(d, n, t[n]);
8
- if (_)
9
- for (var n of _(t))
10
- E.call(t, n) && P(d, n, t[n]);
7
+ q.call(t, n) && S(d, n, t[n]);
8
+ if (R)
9
+ for (var n of R(t))
10
+ x.call(t, n) && S(d, n, t[n]);
11
11
  return d;
12
- }, k = (d, t) => S(d, b(t));
12
+ }, k = (d, t) => A(d, E(t));
13
13
  var v = (d, t, n) => new Promise((r, i) => {
14
14
  var s = (c) => {
15
15
  try {
16
16
  o(n.next(c));
17
- } catch (g) {
18
- i(g);
17
+ } catch (h) {
18
+ i(h);
19
19
  }
20
20
  }, e = (c) => {
21
21
  try {
22
22
  o(n.throw(c));
23
- } catch (g) {
24
- i(g);
23
+ } catch (h) {
24
+ i(h);
25
25
  }
26
26
  }, o = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(s, e);
27
27
  o((n = n.apply(d, t)).next());
28
28
  });
29
29
  import { ChatMessageRole as I } from "@glodon-aiot/apis";
30
- import q from "./Logger.mjs";
31
- import { configuration as f } from "./Config.mjs";
32
- import { io as x } from "socket.io-client";
30
+ import L from "./Logger.mjs";
31
+ import { configuration as u } from "./Config.mjs";
32
+ import { io as N } from "socket.io-client";
33
33
  import { UserMode as w } from "./PayloadTypes.mjs";
34
- import L, { SessionErrors as y } from "./Session.mjs";
35
- const p = new q("[AgentSession] ");
36
- class D extends L {
34
+ import O, { SessionErrors as y } from "./Session.mjs";
35
+ const p = new L("[AgentSession] ");
36
+ class B extends O {
37
37
  constructor(t, n = "", r, i, s, e) {
38
38
  super(t, n, r, i, s, e);
39
39
  }
@@ -42,12 +42,12 @@ class D extends L {
42
42
  this.socket && t(!0);
43
43
  const n = {
44
44
  version: "1.0",
45
- stream: JSON.stringify(f.stream === void 0 ? !0 : f.stream),
45
+ stream: JSON.stringify(u.stream === void 0 ? !0 : u.stream),
46
46
  appId: this._applicationId,
47
47
  sessionId: this.id,
48
48
  Authorization: `${this.token}`,
49
- userMode: f.debug ? w.Debug : w.Normal
50
- }, r = new URL(f.apiRoot), i = yield x(r.origin, {
49
+ userMode: u.debug ? w.Debug : w.Normal
50
+ }, r = new URL(u.apiRoot), i = yield N(r.origin, {
51
51
  path: r.pathname.replace("api", "socketio") + "/copilot",
52
52
  query: n,
53
53
  transports: ["websocket"]
@@ -59,7 +59,7 @@ class D extends L {
59
59
  }), i.on("ready", (s) => {
60
60
  if (s.code === 200) {
61
61
  p.log("ready");
62
- const e = f.debug ? w.Debug : w.Normal;
62
+ const e = u.debug ? w.Debug : w.Normal;
63
63
  e === w.Debug && s.userMode, this._ready = !0, this.event.emit("ready"), this.frozen = !1, this.registerMcpFromClientConfig(), t(!0);
64
64
  } else {
65
65
  this._ready && (this._ready = !1);
@@ -72,25 +72,26 @@ class D extends L {
72
72
  p.error("error", e), this.event.emit("error", e), t(!1);
73
73
  }
74
74
  }), i.on("action", (s, e) => v(this, null, function* () {
75
+ var M;
75
76
  if (this._stopAnswer || !this.id)
76
77
  return;
77
78
  const {
78
79
  type: o,
79
80
  data: {
80
81
  runnerIsClient: c,
81
- pluginCode: g,
82
+ pluginCode: h,
82
83
  funcCode: m,
83
84
  parameters: a,
84
- requestBody: N
85
+ requestBody: U
85
86
  }
86
- } = s, l = this.messages[this.messages.length - 1];
87
- if (!l.messageId)
88
- l.actions || (l.actions = []), l.actions[s.data.step - 1] || (l.actions[s.data.step - 1] = []), l.actions[s.data.step - 1].push(s), this.event.emit("message:action", {
89
- messageId: l.messageId,
87
+ } = s, f = this.messages[this.messages.length - 1];
88
+ if (!f.messageId)
89
+ f.actions || (f.actions = []), f.actions[s.data.step - 1] || (f.actions[s.data.step - 1] = []), f.actions[s.data.step - 1].push(s), this.event.emit("message:action", {
90
+ messageId: f.messageId,
90
91
  action: s
91
- }), this.event.emit("message:updated", l);
92
+ }), this.event.emit("message:updated", f);
92
93
  else {
93
- const u = {
94
+ const l = {
94
95
  messageId: "",
95
96
  content: "",
96
97
  role: I.Robot,
@@ -104,13 +105,13 @@ class D extends L {
104
105
  isAgree: 0
105
106
  }
106
107
  };
107
- this.pushMessage(u), this.event.emit("message:action", {
108
- messageId: u.messageId,
108
+ this.pushMessage(l), this.event.emit("message:action", {
109
+ messageId: l.messageId,
109
110
  action: s
110
111
  });
111
112
  }
112
113
  if (this.inactivating) {
113
- const u = new Error(
114
+ const l = new Error(
114
115
  y.Inactive
115
116
  // {
116
117
  // cause: {
@@ -120,28 +121,33 @@ class D extends L {
120
121
  // },
121
122
  // }
122
123
  );
123
- p.warn("error", u), this.event.emit("error", u);
124
+ p.warn("error", l), this.event.emit("error", l);
124
125
  } else if (o === "FUNCTION_CALL" && c) {
125
- if (p.log(`calling function ${m} of plugin ${g} with argument:
126
- ${JSON.stringify(a)}`), !f.plugins[g]) {
126
+ p.log(`calling function ${m} of plugin ${h} with argument:
127
+ ${JSON.stringify(a)}`);
128
+ const l = (M = u.plugins) == null ? void 0 : M[h];
129
+ if (!l) {
127
130
  e({
128
131
  code: 404,
129
- message: "对不起,没有找到插件。"
132
+ message: "没有找到插件。"
130
133
  });
131
134
  return;
132
135
  }
133
- const u = f.plugins[g][m];
134
- typeof u != "function" && e({
135
- code: 404,
136
- message: "对不起,没有找到插件方法。"
137
- });
138
- let M = a == null ? void 0 : a.query;
136
+ const C = l[m];
137
+ if (typeof C != "function") {
138
+ e({
139
+ code: 404,
140
+ message: "没有找到插件方法。"
141
+ });
142
+ return;
143
+ }
144
+ let _ = a == null ? void 0 : a.query;
139
145
  try {
140
- M = JSON.parse(a == null ? void 0 : a.query);
141
- } catch (C) {
146
+ _ = JSON.parse(a == null ? void 0 : a.query);
147
+ } catch (P) {
142
148
  }
143
- u(M, (...C) => {
144
- this._stopAnswer || e(...C);
149
+ C(_, (...P) => {
150
+ this._stopAnswer || e(...P);
145
151
  });
146
152
  }
147
153
  })), i.on("answer", (s) => {
@@ -149,9 +155,9 @@ class D extends L {
149
155
  if (s.data.code !== 200 && (s.data.index = -1, this.event.emit("error", s.data)), s.data.index === -1) {
150
156
  let e = this.messages[this.messages.length - 1];
151
157
  if (e && !e.messageId)
152
- e = h(h({}, e), s.data), this.event.emit("message:content", e), this.event.emit("message:updated", e), this.event.emit("answer:finish", e);
158
+ e = g(g({}, e), s.data), this.event.emit("message:content", e), this.event.emit("message:updated", e), this.event.emit("answer:finish", e);
153
159
  else {
154
- const o = h({
160
+ const o = g({
155
161
  messageId: "",
156
162
  content: "",
157
163
  role: I.Robot,
@@ -169,7 +175,7 @@ class D extends L {
169
175
  }
170
176
  } else {
171
177
  let e = this.messages[this.messages.length - 1];
172
- e && !e.messageId ? (e = h(h({}, e), s.data), this.messages[this.messages.length - 1] = e, this.event.emit("message:content", e), this.event.emit("message:updated", e)) : (this.pushMessage(s.data), this.event.emit("message:content", s.data));
178
+ e && !e.messageId ? (e = g(g({}, e), s.data), this.messages[this.messages.length - 1] = e, this.event.emit("message:content", e), this.event.emit("message:updated", e)) : (this.pushMessage(s.data), this.event.emit("message:content", s.data));
173
179
  }
174
180
  }), i.on("reference", (s) => v(this, null, function* () {
175
181
  if (this._stopAnswer)
@@ -188,10 +194,10 @@ class D extends L {
188
194
  type: e,
189
195
  data: o,
190
196
  requestId: c
191
- } = s, g = this.messages.findIndex((a) => a.messageId === c && a.role === I.User);
192
- if (g < 0)
197
+ } = s, h = this.messages.findIndex((a) => a.messageId === c && a.role === I.User);
198
+ if (h < 0)
193
199
  return;
194
- const m = g + 1;
200
+ const m = h + 1;
195
201
  if (m >= this.messages.length) {
196
202
  const a = {
197
203
  messageId: "",
@@ -209,21 +215,21 @@ class D extends L {
209
215
  };
210
216
  this.pushMessage(a);
211
217
  }
212
- e === "KG" ? (this.messages[m] = k(h({}, this.messages[m]), {
218
+ e === "KG" ? (this.messages[m] = k(g({}, this.messages[m]), {
213
219
  reference: o.knowledgeReference
214
- }), yield this.fillMessageReference(this.messages[m]), this.event.emit("message:reference", o.knowledgeReference), this.event.emit("message:updated", this.messages[m])) : e === "WEB_SEARCH" && (this.messages[m] = k(h({}, this.messages[m]), {
220
+ }), yield this.fillMessageReference(this.messages[m]), this.event.emit("message:reference", o.knowledgeReference), this.event.emit("message:updated", this.messages[m])) : e === "WEB_SEARCH" && (this.messages[m] = k(g({}, this.messages[m]), {
215
221
  searchReference: o.knowledgeReference
216
222
  }), this.event.emit("message:searchreference", o.searchReference), this.event.emit("message:updated", this.messages[m]));
217
223
  })), this.socket = i, i.open();
218
224
  }));
219
225
  }
220
226
  registerMcpFromClientConfig() {
221
- return f.mcp ? new Promise((t, n) => {
227
+ return u.mcp ? new Promise((t, n) => {
222
228
  if (!this.socket) {
223
229
  n("socket is undefined");
224
230
  return;
225
231
  }
226
- this.socket.emit("add_mcp_servers", f.mcp, (r) => {
232
+ this.socket.emit("add_mcp_servers", u.mcp, (r) => {
227
233
  r.code === 200 ? (Object.keys(r.data).forEach((i) => {
228
234
  r.data[i].code !== 200 && console.error(i, "MCP Server 注册失败。", r.data[i]);
229
235
  }), t(!0)) : (console.error("MCP Server 注册失败。", r), n(r));
@@ -253,8 +259,8 @@ class D extends L {
253
259
  sendQuestion(t, n) {
254
260
  return v(this, null, function* () {
255
261
  var i, s, e;
256
- let r = k(h({}, t), {
257
- promptVariables: this.promptVariables.reduce((o, c) => k(h({}, o), {
262
+ let r = k(g({}, t), {
263
+ promptVariables: this.promptVariables.reduce((o, c) => k(g({}, o), {
258
264
  [c.key]: c.value
259
265
  }), {}),
260
266
  knowledges: (i = this.knowledges) == null ? void 0 : i.map((o) => o.id)
@@ -281,5 +287,5 @@ class D extends L {
281
287
  }
282
288
  }
283
289
  export {
284
- D as default
290
+ B as default
285
291
  };
@@ -2,42 +2,42 @@ var w = Object.defineProperty, k = Object.defineProperties;
2
2
  var A = Object.getOwnPropertyDescriptors;
3
3
  var g = Object.getOwnPropertySymbols;
4
4
  var x = Object.prototype.hasOwnProperty, I = Object.prototype.propertyIsEnumerable;
5
- var u = (o, i, e) => i in o ? w(o, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[i] = e, p = (o, i) => {
6
- for (var e in i || (i = {}))
7
- x.call(i, e) && u(o, e, i[e]);
5
+ var u = (n, i, t) => i in n ? w(n, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[i] = t, d = (n, i) => {
6
+ for (var t in i || (i = {}))
7
+ x.call(i, t) && u(n, t, i[t]);
8
8
  if (g)
9
- for (var e of g(i))
10
- I.call(i, e) && u(o, e, i[e]);
11
- return o;
12
- }, f = (o, i) => k(o, A(i));
13
- var l = (o, i, e) => (u(o, typeof i != "symbol" ? i + "" : i, e), e);
14
- var c = (o, i, e) => new Promise((t, s) => {
15
- var n = (a) => {
9
+ for (var t of g(i))
10
+ I.call(i, t) && u(n, t, i[t]);
11
+ return n;
12
+ }, f = (n, i) => k(n, A(i));
13
+ var l = (n, i, t) => (u(n, typeof i != "symbol" ? i + "" : i, t), t);
14
+ var c = (n, i, t) => new Promise((e, s) => {
15
+ var o = (a) => {
16
16
  try {
17
- r(e.next(a));
17
+ r(t.next(a));
18
18
  } catch (h) {
19
19
  s(h);
20
20
  }
21
- }, d = (a) => {
21
+ }, p = (a) => {
22
22
  try {
23
- r(e.throw(a));
23
+ r(t.throw(a));
24
24
  } catch (h) {
25
25
  s(h);
26
26
  }
27
- }, r = (a) => a.done ? t(a.value) : Promise.resolve(a.value).then(n, d);
28
- r((e = e.apply(o, i)).next());
27
+ }, r = (a) => a.done ? e(a.value) : Promise.resolve(a.value).then(o, p);
28
+ r((t = t.apply(n, i)).next());
29
29
  });
30
30
  import { parseJWT as m } from "./utils.mjs";
31
31
  import R from "./Logger.mjs";
32
32
  import { getCVForceService as E } from "./api/index.mjs";
33
- import { configure as S, configuration as y } from "./Config.mjs";
34
- import { ApplicationTypes as v } from "@glodon-aiot/apis";
33
+ import { configure as S, configuration as v } from "./Config.mjs";
34
+ import { ApplicationTypes as y } from "@glodon-aiot/apis";
35
35
  import L from "./AgentSession.mjs";
36
36
  import M from "./DialogSession.mjs";
37
37
  import C from "./EventBus.mjs";
38
38
  const T = new R("[BotClient] ");
39
39
  class z {
40
- constructor(i, e, t = !0) {
40
+ constructor(i, t, e = !0) {
41
41
  l(this, "event", new C());
42
42
  l(this, "cvforceApi");
43
43
  //从token解析出来的用户信息
@@ -51,11 +51,11 @@ class z {
51
51
  //问题长度
52
52
  l(this, "_questionContextMaxLength", 4e3);
53
53
  l(this, "_promptVariables", []);
54
- if (this._token = i, this.lazyload = t, S(e), this._applicationId = m(i).rid || y.applicationId, !this._applicationId)
54
+ if (this._token = i, this.lazyload = e, S(t), this._applicationId = m(i).rid || v.applicationId, !this._applicationId)
55
55
  throw "token is not vaild";
56
56
  this.cvforceApi = this.getService(), this.loadApplication().then((s) => {
57
- S(f(p({}, e), {
58
- stream: e.stream === void 0 ? (s == null ? void 0 : s.type) === v.Dialog : e.stream
57
+ S(f(d({}, t), {
58
+ stream: t.stream === void 0 ? (s == null ? void 0 : s.type) === y.Dialog : t.stream
59
59
  })), this.event.emit("ready");
60
60
  });
61
61
  }
@@ -87,26 +87,26 @@ class z {
87
87
  }
88
88
  loadApplication() {
89
89
  return c(this, null, function* () {
90
- var e, t, s;
91
- this._application = yield this.cvforceApi.getApplicationId(this._applicationId).then((n) => (typeof n.arrange[0].recommendQuestionOpen != "boolean" && (n.arrange[0].recommendQuestionOpen = !0), f(p({}, n), {
92
- arrange: [f(p({}, n.arrange[0]), {
93
- recommendQuestionOpen: y.loadRelatedQuesions && n.arrange[0].recommendQuestionOpen
90
+ var t, e, s;
91
+ this._application = yield this.cvforceApi.getApplicationId(this._applicationId).then((o) => f(d({}, o), {
92
+ arrange: [f(d({}, o.arrange[0]), {
93
+ recommendQuestionOpen: v.loadRelatedQuesions && o.arrange[0].recommendQuestionOpen
94
94
  })]
95
- })));
96
- const i = (s = (t = (e = this._application) == null ? void 0 : e.arrange) == null ? void 0 : t[0]) == null ? void 0 : s.llmModel;
97
- return i && (this._questionContextMaxLength = yield this.cvforceApi.getBaseModel(i).then((n) => n.maxModelLength)), this._promptVariables = yield this.cvforceApi.getPrompts(this._applicationId), this._ready = !0, this.event.emit("application:loaded"), this._application;
95
+ }));
96
+ const i = (s = (e = (t = this._application) == null ? void 0 : t.arrange) == null ? void 0 : e[0]) == null ? void 0 : s.llmModel;
97
+ return i && (this._questionContextMaxLength = yield this.cvforceApi.getBaseModel(i).then((o) => o.maxModelLength)), this._promptVariables = yield this.cvforceApi.getPrompts(this._applicationId), this._ready = !0, this.event.emit("application:loaded"), this._application;
98
98
  });
99
99
  }
100
100
  getService() {
101
- return this.cvforceApi ? this.cvforceApi : E(y.apiRoot, this.token, (i, e) => T.error(e));
101
+ return this.cvforceApi ? this.cvforceApi : E(v.apiRoot, this.token, (i, t) => T.error(t));
102
102
  }
103
103
  get token() {
104
104
  return this._token;
105
105
  }
106
106
  set token(i) {
107
107
  this.checkReady(), this._token = i, this.ready = !1;
108
- const e = m(i).rid;
109
- this._applicationId !== e && (this._applicationId = e, this._application = null, this.loadApplication().then(() => {
108
+ const t = m(i).rid;
109
+ this._applicationId !== t && (this._applicationId = t, this._application = null, this.loadApplication().then(() => {
110
110
  this.event.emit("ready");
111
111
  }), this.clean());
112
112
  }
@@ -121,19 +121,19 @@ class z {
121
121
  return this.checkReady(), ((i = this._activeSession) == null ? void 0 : i.id) || "";
122
122
  }
123
123
  set activeSession(i) {
124
- this.checkReady(), this.loadSession(i).then((e) => {
125
- this._activeSession && this._activeSession.id !== i && this._activeSession.inactivate(), this._activeSession = e;
124
+ this.checkReady(), this.loadSession(i).then((t) => {
125
+ this._activeSession && this._activeSession.id !== i && this._activeSession.inactivate(), this._activeSession = t;
126
126
  });
127
127
  }
128
- createSession(i, e, t, s, n) {
128
+ createSession(i, t, e, s, o) {
129
129
  return c(this, null, function* () {
130
- const d = this;
130
+ const p = this;
131
131
  return new Promise((r, a) => {
132
132
  const h = (_) => c(this, null, function* () {
133
- if (_ === v.Agent)
134
- r(new L(i, e, t, s, n, d));
135
- else if (_ === v.Dialog)
136
- r(new M(i, e, t, s, n, d));
133
+ if (_ === y.Agent)
134
+ r(new L(i, t, e, s, o, p));
135
+ else if (_ === y.Dialog)
136
+ r(new M(i, t, e, s, o, p));
137
137
  else
138
138
  throw Error(`不支持的应用类型:${_}`);
139
139
  });
@@ -152,44 +152,44 @@ class z {
152
152
  }
153
153
  getSessions(i) {
154
154
  return c(this, null, function* () {
155
- return new Promise((e, t) => {
156
- const s = () => this.cvforceApi.listSessions(this._applicationId, i).then((n) => {
157
- const d = [];
158
- return n.forEach((r) => c(this, null, function* () {
155
+ return new Promise((t, e) => {
156
+ const s = () => this.cvforceApi.listSessions(this._applicationId, i).then((o) => {
157
+ const p = [];
158
+ return o.forEach((r) => c(this, null, function* () {
159
159
  const a = this._sessions.find((h) => r.id === h.id);
160
160
  if (a)
161
- a.data = r, this._application ? a.application = this._application : a.loadApplicationInfo(), d.push(a);
161
+ a.data = r, this._application ? a.application = this._application : a.loadApplicationInfo(), p.push(a);
162
162
  else {
163
163
  const h = yield this.createSession(this.token, r.id, r, this.lazyload, this._application || void 0);
164
- d.push(h);
164
+ p.push(h);
165
165
  }
166
- })), this.sessions = d, d;
166
+ })), this.sessions = p, p;
167
167
  });
168
168
  if (this.ready) {
169
169
  if (!this._application)
170
170
  throw Error("_application is null");
171
- e(s());
171
+ t(s());
172
172
  } else
173
173
  this.event.on("ready", () => {
174
174
  if (!this._application)
175
175
  throw Error("_application is null");
176
- e(s());
176
+ t(s());
177
177
  }, !0);
178
178
  });
179
179
  });
180
180
  }
181
- loadSession(i = "", e) {
181
+ loadSession(i = "", t) {
182
182
  return c(this, null, function* () {
183
183
  this.checkReady();
184
- let t = this.sessions.find((s) => s.id === i);
185
- if (t || (t = yield this.createSession(this.token, i, e), this._sessions.push(t)), this._activeSession) {
186
- if (this._activeSession === t)
187
- return t;
184
+ let e = this.sessions.find((s) => s.id === i);
185
+ if (e || (e = yield this.createSession(this.token, i, t), this._sessions.push(e)), this._activeSession) {
186
+ if (this._activeSession === e)
187
+ return e;
188
188
  this._activeSession.inactivate();
189
189
  }
190
- return t.id ? (yield t.activate(), this._activeSession = t) : t.addEventListener("data:loaded", () => {
191
- this._activeSession !== t && (t == null || t.activate(), this._activeSession = t);
192
- }, !0), t;
190
+ return e.id ? (yield e.activate(), this._activeSession = e) : e.addEventListener("data:loaded", () => {
191
+ this._activeSession !== e && (e == null || e.activate(), this._activeSession = e);
192
+ }, !0), e;
193
193
  });
194
194
  }
195
195
  reload() {
@@ -200,45 +200,45 @@ class z {
200
200
  reloadSession(i) {
201
201
  return c(this, null, function* () {
202
202
  yield this.reload();
203
- let e = this._sessions.find((t) => t.id === i) || this._activeSession;
204
- if (!e) {
203
+ let t = this._sessions.find((e) => e.id === i) || this._activeSession;
204
+ if (!t) {
205
205
  console.warn("reloadSession session failed.");
206
206
  return;
207
207
  }
208
- return yield e.reload(), e;
208
+ return yield t.reload(), t;
209
209
  });
210
210
  }
211
- setTop(i, e, t = "top_time desc, sort_status desc, updated_at desc") {
211
+ setTop(i, t, e = "top_time desc, sort_status desc, updated_at desc") {
212
212
  return c(this, null, function* () {
213
- let s = i ? this._sessions.find((n) => n.id === i) : this._activeSession;
213
+ let s = i ? this._sessions.find((o) => o.id === i) : this._activeSession;
214
214
  if (!s) {
215
215
  console.warn("setTop session failed.");
216
216
  return;
217
217
  }
218
- return yield s.setTop(e), this.getSessions({
219
- order: t
218
+ return yield s.setTop(t), this.getSessions({
219
+ order: e
220
220
  });
221
221
  });
222
222
  }
223
- addEventListener(i, e, t = !1) {
224
- if (typeof e != "function")
223
+ addEventListener(i, t, e = !1) {
224
+ if (typeof t != "function")
225
225
  throw Error("event listener is not a function");
226
- if (t) {
227
- this.event.once(i, e);
226
+ if (e) {
227
+ this.event.once(i, t);
228
228
  return;
229
229
  }
230
- this.event.on(i, e);
230
+ this.event.on(i, t);
231
231
  }
232
- removeEventListener(i, e) {
233
- this.event.off(i, e);
232
+ removeEventListener(i, t) {
233
+ this.event.off(i, t);
234
234
  }
235
- removeSession(i, e) {
235
+ removeSession(i, t) {
236
236
  return c(this, null, function* () {
237
237
  this.checkReady();
238
- let t = -1;
239
- if (typeof i == "string" ? t = this._sessions.findIndex((s) => s.id === i) : t = this._sessions.findIndex((s) => s.id === i.id), t > -1) {
240
- const s = this._sessions[t];
241
- e && (yield s.delete()), this._sessions.splice(t, 1);
238
+ let e = -1;
239
+ if (typeof i == "string" ? e = this._sessions.findIndex((s) => s.id === i) : e = this._sessions.findIndex((s) => s.id === i.id), e > -1) {
240
+ const s = this._sessions[e];
241
+ t && (yield s.delete()), this._sessions.splice(e, 1);
242
242
  } else
243
243
  console.warn("session delete failed, session is not exist.");
244
244
  });
@@ -1,19 +1,19 @@
1
- var s = Object.defineProperty, v = Object.defineProperties;
2
- var u = Object.getOwnPropertyDescriptors;
1
+ var u = Object.defineProperty, f = Object.defineProperties;
2
+ var v = Object.getOwnPropertyDescriptors;
3
3
  var n = Object.getOwnPropertySymbols;
4
4
  var p = Object.prototype.hasOwnProperty, h = Object.prototype.propertyIsEnumerable;
5
- var g = (o, t, e) => t in o ? s(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, i = (o, t) => {
5
+ var g = (o, t, e) => t in o ? u(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, c = (o, t) => {
6
6
  for (var e in t || (t = {}))
7
7
  p.call(t, e) && g(o, e, t[e]);
8
8
  if (n)
9
9
  for (var e of n(t))
10
10
  h.call(t, e) && g(o, e, t[e]);
11
11
  return o;
12
- }, l = (o, t) => v(o, u(t));
12
+ }, l = (o, t) => f(o, v(t));
13
13
  import d from "./Logger.mjs";
14
14
  const R = new d("[Config] ");
15
- var f = /* @__PURE__ */ ((o) => (o.dev = "https://aiot-dev.glodon.com/api/cvforcepd", o.test = "https://aiot-dev.glodon.com/api/cvforce", o.prod = "https://copilot.glodon.com/api/cvforce", o.local = "http://localhost:3000/api/cvforcepd", o))(f || {});
16
- let c = {
15
+ var s = /* @__PURE__ */ ((o) => (o.dev = "https://aiot-dev.glodon.com/api/cvforcepd", o.test = "https://aiot-dev.glodon.com/api/cvforce", o.prod = "https://copilot.glodon.com/api/cvforce", o.local = "http://localhost:3000/api/cvforcepd", o))(s || {});
16
+ let i = {
17
17
  debug: !1,
18
18
  env: "prod",
19
19
  //AIoT 环境, 与apiRoot配对使用
@@ -25,13 +25,16 @@ let c = {
25
25
  loadRelatedQuesions: !0,
26
26
  stream: !1
27
27
  };
28
- function w(o) {
29
- d.debug = (o == null ? void 0 : o.debug) || !1, c = l(i(i({}, c), o), {
30
- apiRoot: (o == null ? void 0 : o.apiRoot) || c.apiRoot || (o != null && o.env ? f[o.env || "prod"] : c.apiRoot)
31
- }), d.debug && R.log("updated", c);
28
+ function x(o) {
29
+ var t, e;
30
+ d.debug = (o == null ? void 0 : o.debug) || !1, i = l(c(c({}, i), o), {
31
+ apiRoot: (o == null ? void 0 : o.apiRoot) || i.apiRoot || (o != null && o.env ? s[o.env || "prod"] : i.apiRoot),
32
+ // 应用未注册插件时 param.plugins 为 undefined,避免覆盖默认空表
33
+ plugins: (e = (t = o == null ? void 0 : o.plugins) != null ? t : i.plugins) != null ? e : {}
34
+ }), d.debug && R.log("updated", i);
32
35
  }
33
36
  export {
34
- f as ApiUrl,
35
- c as configuration,
36
- w as configure
37
+ s as ApiUrl,
38
+ i as configuration,
39
+ x as configure
37
40
  };