@glodon-aiot/agent-cli-sdk 3.0.9 → 3.0.10-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.
Files changed (78) hide show
  1. package/cdn/agent-cli-sdk.js +34022 -0
  2. package/cdn/agent-cli-sdk.umd.cjs +145 -0
  3. package/cdn/src/AgentPlugin.d.ts +17 -0
  4. package/cdn/src/AgentSession.d.ts +9 -0
  5. package/cdn/src/BotClient.d.ts +48 -0
  6. package/cdn/src/Config.d.ts +32 -0
  7. package/cdn/src/DialogSession.d.ts +22 -0
  8. package/cdn/src/EventBus.d.ts +23 -0
  9. package/cdn/src/Logger.d.ts +12 -0
  10. package/cdn/src/PayloadTypes.d.ts +84 -0
  11. package/cdn/src/Session.d.ts +209 -0
  12. package/cdn/src/api/fetchEventSource/fetch.d.ts +44 -0
  13. package/cdn/src/api/fetchEventSource/index.d.ts +1 -0
  14. package/cdn/src/api/fetchEventSource/parse.d.ts +36 -0
  15. package/cdn/src/api/index.d.ts +2 -0
  16. package/cdn/src/index.d.ts +5 -0
  17. package/cdn/src/utils.d.ts +4 -0
  18. package/dist/es/AgentPlugin.mjs +20 -0
  19. package/dist/es/AgentSession.mjs +246 -0
  20. package/dist/es/BotClient.mjs +236 -0
  21. package/dist/es/Config.mjs +34 -0
  22. package/dist/es/DialogSession.mjs +274 -0
  23. package/dist/es/EventBus.mjs +64 -0
  24. package/dist/es/Logger.mjs +31 -0
  25. package/dist/es/PayloadTypes.mjs +4 -0
  26. package/dist/es/Session.mjs +690 -0
  27. package/dist/es/api/fetchEventSource/fetch.mjs +112 -0
  28. package/dist/es/api/fetchEventSource/parse.mjs +97 -0
  29. package/dist/es/api/index.mjs +41 -0
  30. package/dist/es/index.mjs +11 -0
  31. package/dist/es/node_modules/@socket.io/component-emitter/lib/esm/index.mjs +54 -0
  32. package/dist/es/node_modules/engine.io-client/build/esm/contrib/has-cors.mjs +9 -0
  33. package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseqs.mjs +18 -0
  34. package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseuri.mjs +24 -0
  35. package/dist/es/node_modules/engine.io-client/build/esm/contrib/yeast.mjs +19 -0
  36. package/dist/es/node_modules/engine.io-client/build/esm/globalThis.browser.mjs +4 -0
  37. package/dist/es/node_modules/engine.io-client/build/esm/socket.mjs +317 -0
  38. package/dist/es/node_modules/engine.io-client/build/esm/transport.mjs +113 -0
  39. package/dist/es/node_modules/engine.io-client/build/esm/transports/index.mjs +11 -0
  40. package/dist/es/node_modules/engine.io-client/build/esm/transports/polling.mjs +273 -0
  41. package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.mjs +8 -0
  42. package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket.mjs +87 -0
  43. package/dist/es/node_modules/engine.io-client/build/esm/transports/webtransport.mjs +52 -0
  44. package/dist/es/node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.mjs +21 -0
  45. package/dist/es/node_modules/engine.io-client/build/esm/util.mjs +23 -0
  46. package/dist/es/node_modules/engine.io-parser/build/esm/commons.mjs +21 -0
  47. package/dist/es/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs +14 -0
  48. package/dist/es/node_modules/engine.io-parser/build/esm/decodePacket.browser.mjs +39 -0
  49. package/dist/es/node_modules/engine.io-parser/build/esm/encodePacket.browser.mjs +28 -0
  50. package/dist/es/node_modules/engine.io-parser/build/esm/index.mjs +105 -0
  51. package/dist/es/node_modules/js-base64/base64.mjs +31 -0
  52. package/dist/es/node_modules/socket.io-client/build/esm/contrib/backo2.mjs +26 -0
  53. package/dist/es/node_modules/socket.io-client/build/esm/index.mjs +25 -0
  54. package/dist/es/node_modules/socket.io-client/build/esm/manager.mjs +242 -0
  55. package/dist/es/node_modules/socket.io-client/build/esm/on.mjs +8 -0
  56. package/dist/es/node_modules/socket.io-client/build/esm/socket.mjs +608 -0
  57. package/dist/es/node_modules/socket.io-client/build/esm/url.mjs +19 -0
  58. package/dist/es/node_modules/socket.io-parser/build/esm/binary.mjs +52 -0
  59. package/dist/es/node_modules/socket.io-parser/build/esm/index.mjs +203 -0
  60. package/dist/es/node_modules/socket.io-parser/build/esm/is-binary.mjs +26 -0
  61. package/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +6 -0
  62. package/dist/es/node_modules/uuid/dist/esm-browser/rng.mjs +10 -0
  63. package/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +9 -0
  64. package/dist/es/node_modules/uuid/dist/esm-browser/v4.mjs +19 -0
  65. package/dist/es/utils.mjs +11 -0
  66. package/dist/lib/index.js +4 -0
  67. package/dist/src/AgentSession.d.ts +2 -2
  68. package/dist/src/BotClient.d.ts +2 -2
  69. package/dist/src/DialogSession.d.ts +2 -2
  70. package/dist/src/Session.d.ts +9 -11
  71. package/dist/src/api/fetchEventSource/fetch.d.ts +1 -1
  72. package/dist/src/api/fetchEventSource/index.d.ts +1 -1
  73. package/package.json +18 -11
  74. package/dist/agent-cli-sdk.js +0 -33144
  75. package/dist/agent-cli-sdk.umd.cjs +0 -140
  76. package/dist/src/__ tests __/AgentClient.spec.d.ts +0 -1
  77. package/dist/src/__ tests __/AgentSession.spec.d.ts +0 -1
  78. package/dist/src/__ tests __/DialogClient.spec.d.ts +0 -1
@@ -0,0 +1,246 @@
1
+ var C = Object.defineProperty, S = Object.defineProperties;
2
+ var b = Object.getOwnPropertyDescriptors;
3
+ var A = Object.getOwnPropertySymbols;
4
+ var x = Object.prototype.hasOwnProperty, E = Object.prototype.propertyIsEnumerable;
5
+ var _ = (a, t, i) => t in a ? C(a, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : a[t] = i, l = (a, t) => {
6
+ for (var i in t || (t = {}))
7
+ x.call(t, i) && _(a, i, t[i]);
8
+ if (A)
9
+ for (var i of A(t))
10
+ E.call(t, i) && _(a, i, t[i]);
11
+ return a;
12
+ }, y = (a, t) => S(a, b(t));
13
+ var p = (a, t, i) => new Promise((m, n) => {
14
+ var s = (c) => {
15
+ try {
16
+ r(i.next(c));
17
+ } catch (h) {
18
+ n(h);
19
+ }
20
+ }, e = (c) => {
21
+ try {
22
+ r(i.throw(c));
23
+ } catch (h) {
24
+ n(h);
25
+ }
26
+ }, r = (c) => c.done ? m(c.value) : Promise.resolve(c.value).then(s, e);
27
+ r((i = i.apply(a, t)).next());
28
+ });
29
+ import { ChatMessageRole as I } from "@glodon-aiot/apis";
30
+ import L from "./Logger.mjs";
31
+ import { configuration as w } from "./Config.mjs";
32
+ import { io as q } from "./node_modules/socket.io-client/build/esm/index.mjs";
33
+ import { UserMode as v } from "./PayloadTypes.mjs";
34
+ import N, { SessionErrors as k } from "./Session.mjs";
35
+ const u = new L("[AgentSession] ");
36
+ class J extends N {
37
+ constructor(t, i = "", m, n, s, e) {
38
+ super(t, i, m, n, s, e);
39
+ }
40
+ prepareConnection() {
41
+ return new Promise((t) => p(this, null, function* () {
42
+ this.socket && t(!0);
43
+ const i = {
44
+ version: "1.0",
45
+ stream: "false",
46
+ appId: this._applicationId,
47
+ sessionId: this.id,
48
+ Authorization: `${this.token}`,
49
+ userMode: w.debug ? v.Debug : v.Normal
50
+ }, m = new URL(w.apiRoot), n = yield q(m.origin, {
51
+ path: m.pathname.replace("api", "socketio") + "/copilot",
52
+ query: i,
53
+ transports: ["websocket"]
54
+ });
55
+ n.on("connect", () => {
56
+ u.log("socket:connect"), this.event.emit("socket:connect"), n.emit("init");
57
+ }), n.on("disconnect", () => {
58
+ u.log("socket:disconnect"), this.event.emit("socket:disconnect");
59
+ }), n.on("ready", (s) => {
60
+ if (s.code === 200) {
61
+ u.log("ready");
62
+ const e = w.debug ? v.Debug : v.Normal;
63
+ e === v.Debug && s.userMode, this._ready || (this._ready = !0, this.event.emit("ready")), this.frozen = !1, t(!0);
64
+ } else {
65
+ this._ready && (this._ready = !1);
66
+ const e = new Error(
67
+ k.SocketConnectionFailed
68
+ // , {
69
+ // cause: data,
70
+ // }
71
+ );
72
+ u.error("error", e), this.event.emit("error", e), t(!1);
73
+ }
74
+ }), n.on("action", (s, e) => p(this, null, function* () {
75
+ if (this._stopAnswer || !this.id)
76
+ return;
77
+ const {
78
+ type: r,
79
+ data: {
80
+ runnerIsClient: c,
81
+ pluginCode: h,
82
+ funcCode: g,
83
+ parameters: o,
84
+ requestBody: U
85
+ }
86
+ } = s, d = this.messages[this.messages.length - 1];
87
+ if (!d.messageId)
88
+ d.actions || (d.actions = []), d.actions[s.data.step - 1] || (d.actions[s.data.step - 1] = []), d.actions[s.data.step - 1].push(s), this.event.emit("message:action", {
89
+ messageId: d.messageId,
90
+ action: s
91
+ }), this.event.emit("message:updated", d);
92
+ else {
93
+ const f = {
94
+ messageId: "",
95
+ content: "",
96
+ role: I.Robot,
97
+ sessionId: this.id,
98
+ reference: [],
99
+ searchReference: [],
100
+ isLoading: !0,
101
+ messageTime: "",
102
+ actions: [[s]],
103
+ comment: {
104
+ isAgree: 0
105
+ }
106
+ };
107
+ this.pushMessage(f), this.event.emit("message:action", {
108
+ messageId: f.messageId,
109
+ action: s
110
+ });
111
+ }
112
+ if (this.inactivating) {
113
+ const f = new Error(
114
+ k.Inactive
115
+ // {
116
+ // cause: {
117
+ // code: -1,
118
+ // message:
119
+ // 'session is inactive, skipping plugin client function call',
120
+ // },
121
+ // }
122
+ );
123
+ u.warn("error", f), this.event.emit("error", f);
124
+ } else if (r === "FUNCTION_CALL" && c) {
125
+ if (u.log(`calling function ${g} of plugin ${h} with argument:
126
+ ${JSON.stringify(o)}`), !w.plugins[h]) {
127
+ e({
128
+ code: 404,
129
+ message: "对不起,没有找到插件。"
130
+ });
131
+ return;
132
+ }
133
+ const f = w.plugins[h][g];
134
+ typeof f != "function" && e({
135
+ code: 404,
136
+ message: "对不起,没有找到插件方法。"
137
+ });
138
+ let M = o == null ? void 0 : o.query;
139
+ try {
140
+ M = JSON.parse(o == null ? void 0 : o.query);
141
+ } catch (R) {
142
+ }
143
+ f(M, (...R) => {
144
+ this._stopAnswer || e(...R);
145
+ });
146
+ }
147
+ })), n.on("answer", (s) => {
148
+ if (!this._stopAnswer)
149
+ if (s.data.code !== 200 && (s.data.index = -1, this.event.emit("error", s.data)), s.data.index === -1) {
150
+ let e = this.messages[this.messages.length - 1];
151
+ if (e && !e.messageId)
152
+ e = l(l({}, e), s.data), this.event.emit("message:content", e), this.event.emit("message:updated", e), this.event.emit("answer:finish", e);
153
+ else {
154
+ const r = l({
155
+ messageId: "",
156
+ content: "",
157
+ role: I.Robot,
158
+ sessionId: this.id,
159
+ reference: [],
160
+ searchReference: [],
161
+ isLoading: !1,
162
+ messageTime: "",
163
+ actions: [],
164
+ comment: {
165
+ isAgree: 0
166
+ }
167
+ }, s.data);
168
+ this.event.emit("message:content", r), this.pushMessage(r), this.event.emit("answer:finish", r);
169
+ }
170
+ } else {
171
+ let e = this.messages[this.messages.length - 1];
172
+ e && !e.messageId ? (e = l(l({}, 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
+ }
174
+ }), n.on("reference", (s) => p(this, null, function* () {
175
+ if (this._stopAnswer)
176
+ return;
177
+ if (!this.id) {
178
+ const o = new Error(
179
+ k.IdUndefined
180
+ // {
181
+ // cause: SESSION_ERROR_CAUSE[SessionErrors.IdUndefined],
182
+ // }
183
+ );
184
+ u.error(o), this.event.emit("error", o), this.frozen = !1;
185
+ return;
186
+ }
187
+ const {
188
+ type: e,
189
+ data: r,
190
+ requestId: c
191
+ } = s, h = this.messages.findIndex((o) => o.messageId === c && o.role === I.User);
192
+ if (h < 0)
193
+ return;
194
+ const g = h + 1;
195
+ if (g >= this.messages.length) {
196
+ const o = {
197
+ messageId: "",
198
+ content: "",
199
+ role: I.Robot,
200
+ sessionId: this.id,
201
+ reference: [],
202
+ searchReference: [],
203
+ isLoading: !0,
204
+ messageTime: "",
205
+ actions: [],
206
+ comment: {
207
+ isAgree: 0
208
+ }
209
+ };
210
+ this.pushMessage(o);
211
+ }
212
+ e === "KG" ? (this.messages[g] = y(l({}, this.messages[g]), {
213
+ reference: r.knowledgeReference
214
+ }), yield this.fillMessageReference(this.messages[g]), this.event.emit("message:reference", r.knowledgeReference), this.event.emit("message:updated", this.messages[g])) : e === "WEB_SEARCH" && (this.messages[g] = y(l({}, this.messages[g]), {
215
+ searchReference: r.knowledgeReference
216
+ }), this.event.emit("message:searchreference", r.searchReference), this.event.emit("message:updated", this.messages[g]));
217
+ })), this.socket = n, n.open();
218
+ }));
219
+ }
220
+ sendQuestion(t, i) {
221
+ return p(this, null, function* () {
222
+ var m, n;
223
+ if (!this.active) {
224
+ if (yield this.activate(), !this.socket) {
225
+ const s = new Error(
226
+ k.SocketConnectionFailed
227
+ // {
228
+ // cause: { code: -1, message: 'socket is null' },
229
+ // }
230
+ );
231
+ return u.warn("error", s), this.event.emit("error", s), !1;
232
+ }
233
+ (m = this.socket) == null || m.emit("question", t);
234
+ return;
235
+ }
236
+ (n = this.socket) == null || n.emit("question", t);
237
+ });
238
+ }
239
+ stopAnswer() {
240
+ var t;
241
+ (t = this.socket) == null || t.emit("stop_answer");
242
+ }
243
+ }
244
+ export {
245
+ J as default
246
+ };
@@ -0,0 +1,236 @@
1
+ var v = Object.defineProperty;
2
+ var y = (p, i, t) => i in p ? v(p, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[i] = t;
3
+ var c = (p, i, t) => (y(p, typeof i != "symbol" ? i + "" : i, t), t);
4
+ var a = (p, i, t) => new Promise((e, s) => {
5
+ var l = (n) => {
6
+ try {
7
+ o(t.next(n));
8
+ } catch (r) {
9
+ s(r);
10
+ }
11
+ }, h = (n) => {
12
+ try {
13
+ o(t.throw(n));
14
+ } catch (r) {
15
+ s(r);
16
+ }
17
+ }, o = (n) => n.done ? e(n.value) : Promise.resolve(n.value).then(l, h);
18
+ o((t = t.apply(p, i)).next());
19
+ });
20
+ import { parseJWT as f } from "./utils.mjs";
21
+ import g from "./Logger.mjs";
22
+ import { getCVForceService as S } from "./api/index.mjs";
23
+ import { configure as w, configuration as _ } from "./Config.mjs";
24
+ import { ApplicationTypes as u } from "@glodon-aiot/apis";
25
+ import m from "./AgentSession.mjs";
26
+ import k from "./DialogSession.mjs";
27
+ import A from "./EventBus.mjs";
28
+ const x = new g("[BotClient] ");
29
+ class q {
30
+ constructor(i, t, e = !0) {
31
+ c(this, "event", new A());
32
+ c(this, "cvforceApi");
33
+ //从token解析出来的用户信息
34
+ c(this, "_applicationId");
35
+ c(this, "_application", null);
36
+ //session列表,被加载过的session将会被缓存到这个列表中
37
+ c(this, "_sessions", []);
38
+ //活跃的session,只支持一个活跃的session
39
+ c(this, "_activeSession");
40
+ c(this, "_ready", !1);
41
+ //问题长度
42
+ c(this, "_questionContextMaxLength", 4e3);
43
+ c(this, "_promptVariables", []);
44
+ if (this._token = i, this.lazyload = e, w(t), this._applicationId = f(i).rid || _.applicationId, !this._applicationId)
45
+ throw "token is not vaild";
46
+ this.cvforceApi = this.getService(), this.loadApplication().then(() => {
47
+ this.event.emit("ready");
48
+ });
49
+ }
50
+ checkReady() {
51
+ if (!this.ready)
52
+ throw Error("client is not ready.");
53
+ }
54
+ get ready() {
55
+ return this._ready;
56
+ }
57
+ set ready(i) {
58
+ this._ready = i;
59
+ }
60
+ get questionContextMaxLength() {
61
+ return this.checkReady(), this._questionContextMaxLength;
62
+ }
63
+ get promptVariables() {
64
+ return this.checkReady(), this._promptVariables;
65
+ }
66
+ get knowledges() {
67
+ var i;
68
+ return this.checkReady(), (i = this._application) == null ? void 0 : i.arrange[0].knowledges;
69
+ }
70
+ get sessions() {
71
+ return this.checkReady(), this._sessions;
72
+ }
73
+ set sessions(i) {
74
+ this.checkReady(), this._sessions = i, this.event.emit("sessions:updated", i);
75
+ }
76
+ loadApplication() {
77
+ return a(this, null, function* () {
78
+ var t, e;
79
+ this._application = yield this.cvforceApi.getApplicationId(this._applicationId);
80
+ const i = (e = (t = this._application.arrange) == null ? void 0 : t[0]) == null ? void 0 : e.llmModel;
81
+ return i && (this._questionContextMaxLength = yield this.cvforceApi.getBaseModel(i).then((s) => s.maxModelLength)), this._promptVariables = yield this.cvforceApi.getPrompts(this._applicationId), this._ready = !0, this.event.emit("application:loaded"), this._application;
82
+ });
83
+ }
84
+ getService() {
85
+ return this.cvforceApi ? this.cvforceApi : S(_.apiRoot, this.token, (i, t) => x.error(t));
86
+ }
87
+ get token() {
88
+ return this._token;
89
+ }
90
+ set token(i) {
91
+ this.checkReady(), this._token = i, this.ready = !1;
92
+ const t = f(i).rid;
93
+ this._applicationId !== t && (this._applicationId = t, this._application = null, this.loadApplication().then(() => {
94
+ this.event.emit("ready");
95
+ }), this.clean());
96
+ }
97
+ get applicationId() {
98
+ return this._applicationId;
99
+ }
100
+ get application() {
101
+ return this.checkReady(), this._application;
102
+ }
103
+ get activeSession() {
104
+ var i;
105
+ return this.checkReady(), ((i = this._activeSession) == null ? void 0 : i.id) || "";
106
+ }
107
+ set activeSession(i) {
108
+ this.checkReady(), this.loadSession(i).then((t) => {
109
+ this._activeSession && this._activeSession.id !== i && this._activeSession.inactivate(), this._activeSession = t;
110
+ });
111
+ }
112
+ createSession(i, t, e, s, l) {
113
+ return a(this, null, function* () {
114
+ const h = this;
115
+ return new Promise((o, n) => {
116
+ const r = (d) => a(this, null, function* () {
117
+ if (d === u.Agent)
118
+ o(new m(i, t, e, s, l, h));
119
+ else if (d === u.Dialog)
120
+ o(new k(i, t, e, s, l, h));
121
+ else
122
+ throw Error(`不支持的应用类型:${d}`);
123
+ });
124
+ if (this.ready) {
125
+ if (!this._application)
126
+ throw Error("client is not ready");
127
+ r(this._application.type);
128
+ } else
129
+ this.event.on("ready", () => {
130
+ if (!this._application)
131
+ throw Error("_application is null");
132
+ r(this._application.type);
133
+ }, !0);
134
+ });
135
+ });
136
+ }
137
+ getSessions(i) {
138
+ return a(this, null, function* () {
139
+ return new Promise((t, e) => {
140
+ const s = () => this.cvforceApi.listSessions(this._applicationId, i).then((l) => {
141
+ const h = [];
142
+ return l.forEach((o) => a(this, null, function* () {
143
+ const n = this._sessions.find((r) => o.id === r.id);
144
+ if (n)
145
+ n.data = o, h.push(n);
146
+ else {
147
+ const r = yield this.createSession(this.token, o.id, o, this.lazyload, this._application || void 0);
148
+ h.push(r);
149
+ }
150
+ })), this.sessions = h, h;
151
+ });
152
+ if (this.ready) {
153
+ if (!this._application)
154
+ throw Error("_application is null");
155
+ t(s());
156
+ } else
157
+ this.event.on("ready", () => {
158
+ if (!this._application)
159
+ throw Error("_application is null");
160
+ t(s());
161
+ }, !0);
162
+ });
163
+ });
164
+ }
165
+ loadSession(i = "", t) {
166
+ return a(this, null, function* () {
167
+ this.checkReady();
168
+ let e = this.sessions.find((s) => s.id === i);
169
+ if (e || (e = yield this.createSession(this.token, i, t), this._sessions.push(e)), this._activeSession) {
170
+ if (this._activeSession === e)
171
+ return e;
172
+ this._activeSession.inactivate();
173
+ }
174
+ return e.id ? (yield e.activate(), this._activeSession = e) : e.addEventListener("data:loaded", () => {
175
+ this._activeSession !== e && (e == null || e.activate(), this._activeSession = e);
176
+ }, !0), e;
177
+ });
178
+ }
179
+ reload() {
180
+ return this.loadApplication().then(() => a(this, null, function* () {
181
+ return yield this.getSessions(), this.event.emit("ready"), this;
182
+ }));
183
+ }
184
+ reloadSession(i) {
185
+ return a(this, null, function* () {
186
+ yield this.reload();
187
+ let t = this._sessions.find((e) => e.id === i) || this._activeSession;
188
+ if (!t) {
189
+ console.warn("reloadSession session failed.");
190
+ return;
191
+ }
192
+ return yield t.reload(), t;
193
+ });
194
+ }
195
+ setTop(i, t, e = "top_time desc, sort_status desc, updated_at desc") {
196
+ return a(this, null, function* () {
197
+ let s = i ? this._sessions.find((l) => l.id === i) : this._activeSession;
198
+ if (!s) {
199
+ console.warn("setTop session failed.");
200
+ return;
201
+ }
202
+ return yield s.setTop(t), this.getSessions({
203
+ order: e
204
+ });
205
+ });
206
+ }
207
+ addEventListener(i, t, e = !1) {
208
+ if (typeof t != "function")
209
+ throw Error("event listener is not a function");
210
+ if (e) {
211
+ this.event.once(i, t);
212
+ return;
213
+ }
214
+ this.event.on(i, t);
215
+ }
216
+ removeEventListener(i, t) {
217
+ this.event.off(i, t);
218
+ }
219
+ removeSession(i, t) {
220
+ return a(this, null, function* () {
221
+ this.checkReady();
222
+ let e = -1;
223
+ if (typeof i == "string" ? e = this._sessions.findIndex((s) => s.id === i) : e = this._sessions.findIndex((s) => s.id === i.id), e > -1) {
224
+ const s = this._sessions[e];
225
+ t && (yield s.delete()), this._sessions.splice(e, 1);
226
+ } else
227
+ console.warn("session delete failed, session is not exist.");
228
+ });
229
+ }
230
+ clean() {
231
+ this._sessions.forEach((i) => i.destroy()), this.sessions = [];
232
+ }
233
+ }
234
+ export {
235
+ q as default
236
+ };
@@ -0,0 +1,34 @@
1
+ var v = Object.defineProperty, s = Object.defineProperties;
2
+ var u = Object.getOwnPropertyDescriptors;
3
+ var n = Object.getOwnPropertySymbols;
4
+ var p = Object.prototype.hasOwnProperty, h = Object.prototype.propertyIsEnumerable;
5
+ var g = (o, t, e) => t in o ? v(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e, i = (o, t) => {
6
+ for (var e in t || (t = {}))
7
+ p.call(t, e) && g(o, e, t[e]);
8
+ if (n)
9
+ for (var e of n(t))
10
+ h.call(t, e) && g(o, e, t[e]);
11
+ return o;
12
+ }, l = (o, t) => s(o, u(t));
13
+ import d from "./Logger.mjs";
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 = {
17
+ debug: !1,
18
+ env: "prod",
19
+ //AIoT 环境, 与apiRoot配对使用
20
+ apiRoot: "https://copilot.glodon.com/api/cvforce",
21
+ //https://${hostname}/${PRODUCD_CODE}
22
+ applicationId: "",
23
+ plugins: {}
24
+ };
25
+ function x(o) {
26
+ d.debug = (o == null ? void 0 : o.debug) || !1, c = l(i(i({}, c), o), {
27
+ apiRoot: (o == null ? void 0 : o.apiRoot) || c.apiRoot || (o != null && o.env ? f[o.env || "prod"] : c.apiRoot)
28
+ }), d.debug && R.log("updated", c);
29
+ }
30
+ export {
31
+ f as ApiUrl,
32
+ c as configuration,
33
+ x as configure
34
+ };