@glodon-aiot/agent-cli-sdk 3.3.2 → 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.
- package/dist/es/AgentSession.mjs +93 -93
- package/dist/es/BotClient.mjs +48 -46
- package/dist/es/Config.mjs +7 -6
- package/dist/es/DialogSession.mjs +37 -37
- package/dist/es/Session.mjs +130 -131
- package/dist/es/api/index.mjs +26 -26
- package/dist/lib/index.js +3 -3
- package/dist/src/Config.d.ts +2 -0
- package/package.json +2 -2
package/dist/es/AgentSession.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var R = Object.defineProperty,
|
|
2
|
-
var
|
|
1
|
+
var R = Object.defineProperty, S = Object.defineProperties;
|
|
2
|
+
var b = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var _ = Object.getOwnPropertySymbols;
|
|
4
4
|
var A = Object.prototype.hasOwnProperty, E = Object.prototype.propertyIsEnumerable;
|
|
5
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) => {
|
|
@@ -9,73 +9,73 @@ var P = (d, t, n) => t in d ? R(d, t, { enumerable: !0, configurable: !0, writab
|
|
|
9
9
|
for (var n of _(t))
|
|
10
10
|
E.call(t, n) && P(d, n, t[n]);
|
|
11
11
|
return d;
|
|
12
|
-
}, k = (d, t) =>
|
|
13
|
-
var
|
|
14
|
-
var
|
|
12
|
+
}, k = (d, t) => S(d, b(t));
|
|
13
|
+
var v = (d, t, n) => new Promise((r, i) => {
|
|
14
|
+
var s = (c) => {
|
|
15
15
|
try {
|
|
16
|
-
|
|
16
|
+
o(n.next(c));
|
|
17
17
|
} catch (g) {
|
|
18
18
|
i(g);
|
|
19
19
|
}
|
|
20
|
-
},
|
|
20
|
+
}, e = (c) => {
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
o(n.throw(c));
|
|
23
23
|
} catch (g) {
|
|
24
24
|
i(g);
|
|
25
25
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, o = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(s, e);
|
|
27
|
+
o((n = n.apply(d, t)).next());
|
|
28
28
|
});
|
|
29
29
|
import { ChatMessageRole as I } from "@glodon-aiot/apis";
|
|
30
30
|
import q from "./Logger.mjs";
|
|
31
|
-
import { configuration as
|
|
31
|
+
import { configuration as f } from "./Config.mjs";
|
|
32
32
|
import { io as x } from "socket.io-client";
|
|
33
33
|
import { UserMode as w } from "./PayloadTypes.mjs";
|
|
34
34
|
import L, { SessionErrors as y } from "./Session.mjs";
|
|
35
|
-
const
|
|
35
|
+
const p = new q("[AgentSession] ");
|
|
36
36
|
class D extends L {
|
|
37
|
-
constructor(t, n = "",
|
|
38
|
-
super(t, n,
|
|
37
|
+
constructor(t, n = "", r, i, s, e) {
|
|
38
|
+
super(t, n, r, i, s, e);
|
|
39
39
|
}
|
|
40
40
|
prepareConnection() {
|
|
41
|
-
return new Promise((t) =>
|
|
41
|
+
return new Promise((t) => v(this, null, function* () {
|
|
42
42
|
this.socket && t(!0);
|
|
43
43
|
const n = {
|
|
44
44
|
version: "1.0",
|
|
45
|
-
stream:
|
|
45
|
+
stream: JSON.stringify(f.stream === void 0 ? !0 : f.stream),
|
|
46
46
|
appId: this._applicationId,
|
|
47
47
|
sessionId: this.id,
|
|
48
48
|
Authorization: `${this.token}`,
|
|
49
|
-
userMode:
|
|
50
|
-
},
|
|
51
|
-
path:
|
|
49
|
+
userMode: f.debug ? w.Debug : w.Normal
|
|
50
|
+
}, r = new URL(f.apiRoot), i = yield x(r.origin, {
|
|
51
|
+
path: r.pathname.replace("api", "socketio") + "/copilot",
|
|
52
52
|
query: n,
|
|
53
53
|
transports: ["websocket"]
|
|
54
54
|
});
|
|
55
55
|
i.on("connect", () => {
|
|
56
|
-
|
|
56
|
+
p.log("socket:connect"), this.event.emit("socket:connect"), i.emit("init");
|
|
57
57
|
}), i.on("disconnect", () => {
|
|
58
|
-
|
|
59
|
-
}), i.on("ready", (
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
58
|
+
p.log("socket:disconnect"), this.event.emit("socket:disconnect"), this._ready = !1;
|
|
59
|
+
}), i.on("ready", (s) => {
|
|
60
|
+
if (s.code === 200) {
|
|
61
|
+
p.log("ready");
|
|
62
|
+
const e = f.debug ? w.Debug : w.Normal;
|
|
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);
|
|
66
|
-
const
|
|
66
|
+
const e = new Error(
|
|
67
67
|
y.SocketConnectionFailed
|
|
68
68
|
// , {
|
|
69
69
|
// cause: data,
|
|
70
70
|
// }
|
|
71
71
|
);
|
|
72
|
-
|
|
72
|
+
p.error("error", e), this.event.emit("error", e), t(!1);
|
|
73
73
|
}
|
|
74
|
-
}), i.on("action", (
|
|
74
|
+
}), i.on("action", (s, e) => v(this, null, function* () {
|
|
75
75
|
if (this._stopAnswer || !this.id)
|
|
76
76
|
return;
|
|
77
77
|
const {
|
|
78
|
-
type:
|
|
78
|
+
type: o,
|
|
79
79
|
data: {
|
|
80
80
|
runnerIsClient: c,
|
|
81
81
|
pluginCode: g,
|
|
@@ -83,14 +83,14 @@ class D extends L {
|
|
|
83
83
|
parameters: a,
|
|
84
84
|
requestBody: N
|
|
85
85
|
}
|
|
86
|
-
} =
|
|
87
|
-
if (!
|
|
88
|
-
|
|
89
|
-
messageId:
|
|
90
|
-
action:
|
|
91
|
-
}), this.event.emit("message:updated",
|
|
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,
|
|
90
|
+
action: s
|
|
91
|
+
}), this.event.emit("message:updated", l);
|
|
92
92
|
else {
|
|
93
|
-
const
|
|
93
|
+
const u = {
|
|
94
94
|
messageId: "",
|
|
95
95
|
content: "",
|
|
96
96
|
role: I.Robot,
|
|
@@ -99,18 +99,18 @@ class D extends L {
|
|
|
99
99
|
searchReference: [],
|
|
100
100
|
isLoading: !0,
|
|
101
101
|
messageTime: "",
|
|
102
|
-
actions: [[
|
|
102
|
+
actions: [[s]],
|
|
103
103
|
comment: {
|
|
104
104
|
isAgree: 0
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
|
-
this.pushMessage(
|
|
108
|
-
messageId:
|
|
109
|
-
action:
|
|
107
|
+
this.pushMessage(u), this.event.emit("message:action", {
|
|
108
|
+
messageId: u.messageId,
|
|
109
|
+
action: s
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
if (this.inactivating) {
|
|
113
|
-
const
|
|
113
|
+
const u = new Error(
|
|
114
114
|
y.Inactive
|
|
115
115
|
// {
|
|
116
116
|
// cause: {
|
|
@@ -120,18 +120,18 @@ class D extends L {
|
|
|
120
120
|
// },
|
|
121
121
|
// }
|
|
122
122
|
);
|
|
123
|
-
|
|
124
|
-
} else if (
|
|
125
|
-
if (
|
|
126
|
-
${JSON.stringify(a)}`), !
|
|
127
|
-
|
|
123
|
+
p.warn("error", u), this.event.emit("error", u);
|
|
124
|
+
} 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]) {
|
|
127
|
+
e({
|
|
128
128
|
code: 404,
|
|
129
129
|
message: "对不起,没有找到插件。"
|
|
130
130
|
});
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
|
-
const
|
|
134
|
-
typeof
|
|
133
|
+
const u = f.plugins[g][m];
|
|
134
|
+
typeof u != "function" && e({
|
|
135
135
|
code: 404,
|
|
136
136
|
message: "对不起,没有找到插件方法。"
|
|
137
137
|
});
|
|
@@ -140,18 +140,18 @@ class D extends L {
|
|
|
140
140
|
M = JSON.parse(a == null ? void 0 : a.query);
|
|
141
141
|
} catch (C) {
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
this._stopAnswer ||
|
|
143
|
+
u(M, (...C) => {
|
|
144
|
+
this._stopAnswer || e(...C);
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
})), i.on("answer", (
|
|
147
|
+
})), i.on("answer", (s) => {
|
|
148
148
|
if (!this._stopAnswer)
|
|
149
|
-
if (
|
|
150
|
-
let
|
|
151
|
-
if (
|
|
152
|
-
|
|
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 = h(h({}, e), s.data), this.event.emit("message:content", e), this.event.emit("message:updated", e), this.event.emit("answer:finish", e);
|
|
153
153
|
else {
|
|
154
|
-
const
|
|
154
|
+
const o = h({
|
|
155
155
|
messageId: "",
|
|
156
156
|
content: "",
|
|
157
157
|
role: I.Robot,
|
|
@@ -164,14 +164,14 @@ class D extends L {
|
|
|
164
164
|
comment: {
|
|
165
165
|
isAgree: 0
|
|
166
166
|
}
|
|
167
|
-
},
|
|
168
|
-
this.event.emit("message:content",
|
|
167
|
+
}, s.data);
|
|
168
|
+
this.event.emit("message:content", o), this.pushMessage(o), this.event.emit("answer:finish", o);
|
|
169
169
|
}
|
|
170
170
|
} else {
|
|
171
|
-
let
|
|
172
|
-
|
|
171
|
+
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));
|
|
173
173
|
}
|
|
174
|
-
}), i.on("reference", (
|
|
174
|
+
}), i.on("reference", (s) => v(this, null, function* () {
|
|
175
175
|
if (this._stopAnswer)
|
|
176
176
|
return;
|
|
177
177
|
if (!this.id) {
|
|
@@ -181,14 +181,14 @@ class D extends L {
|
|
|
181
181
|
// cause: SESSION_ERROR_CAUSE[SessionErrors.IdUndefined],
|
|
182
182
|
// }
|
|
183
183
|
);
|
|
184
|
-
|
|
184
|
+
p.error(a), this.event.emit("error", a), this.frozen = !1;
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
187
|
const {
|
|
188
|
-
type:
|
|
189
|
-
data:
|
|
188
|
+
type: e,
|
|
189
|
+
data: o,
|
|
190
190
|
requestId: c
|
|
191
|
-
} =
|
|
191
|
+
} = s, g = this.messages.findIndex((a) => a.messageId === c && a.role === I.User);
|
|
192
192
|
if (g < 0)
|
|
193
193
|
return;
|
|
194
194
|
const m = g + 1;
|
|
@@ -209,70 +209,70 @@ class D extends L {
|
|
|
209
209
|
};
|
|
210
210
|
this.pushMessage(a);
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
reference:
|
|
214
|
-
}), yield this.fillMessageReference(this.messages[m]), this.event.emit("message:reference",
|
|
215
|
-
searchReference:
|
|
216
|
-
}), this.event.emit("message:searchreference",
|
|
212
|
+
e === "KG" ? (this.messages[m] = k(h({}, this.messages[m]), {
|
|
213
|
+
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]), {
|
|
215
|
+
searchReference: o.knowledgeReference
|
|
216
|
+
}), this.event.emit("message:searchreference", o.searchReference), this.event.emit("message:updated", this.messages[m]));
|
|
217
217
|
})), this.socket = i, i.open();
|
|
218
218
|
}));
|
|
219
219
|
}
|
|
220
220
|
registerMcpFromClientConfig() {
|
|
221
|
-
return
|
|
221
|
+
return f.mcp ? new Promise((t, n) => {
|
|
222
222
|
if (!this.socket) {
|
|
223
223
|
n("socket is undefined");
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
226
|
-
this.socket.emit("add_mcp_servers",
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}), t(!0)) : (console.error("MCP Server 注册失败。",
|
|
226
|
+
this.socket.emit("add_mcp_servers", f.mcp, (r) => {
|
|
227
|
+
r.code === 200 ? (Object.keys(r.data).forEach((i) => {
|
|
228
|
+
r.data[i].code !== 200 && console.error(i, "MCP Server 注册失败。", r.data[i]);
|
|
229
|
+
}), t(!0)) : (console.error("MCP Server 注册失败。", r), n(r));
|
|
230
230
|
});
|
|
231
231
|
}) : Promise.resolve(!0);
|
|
232
232
|
}
|
|
233
233
|
addMcpServers(t) {
|
|
234
|
-
return
|
|
235
|
-
return this.ready ? this.socket ? new Promise((n,
|
|
234
|
+
return v(this, null, function* () {
|
|
235
|
+
return this.ready ? this.socket ? new Promise((n, r) => {
|
|
236
236
|
this.socket && this.socket.emit("add_mcp_servers", t, (i) => {
|
|
237
|
-
i.code === 200 ? (Object.keys(i.data).forEach((
|
|
238
|
-
i.data[
|
|
239
|
-
}), n(!0)) : (console.error("MCP Server 注册失败。", i),
|
|
237
|
+
i.code === 200 ? (Object.keys(i.data).forEach((s) => {
|
|
238
|
+
i.data[s].code !== 200 && console.error(s, "MCP Server 注册失败。", i.data[s]);
|
|
239
|
+
}), n(!0)) : (console.error("MCP Server 注册失败。", i), r(i));
|
|
240
240
|
});
|
|
241
241
|
}) : (console.error(" socket is undefined."), Promise.reject("socket is undefined")) : (console.error("session is not avalible."), Promise.reject("session is not avalible"));
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
listMcpServers() {
|
|
245
|
-
return
|
|
245
|
+
return v(this, null, function* () {
|
|
246
246
|
return this.ready ? this.socket ? new Promise((t, n) => {
|
|
247
|
-
this.socket && this.socket.emit("list_mcp_servers", (
|
|
248
|
-
|
|
247
|
+
this.socket && this.socket.emit("list_mcp_servers", (r) => {
|
|
248
|
+
r.code === 200 ? t(r.data) : n(r);
|
|
249
249
|
});
|
|
250
250
|
}) : (console.error(" socket is undefined."), Promise.reject("socket is undefined")) : (console.error("session is not avalible."), Promise.reject("session is not avalible"));
|
|
251
251
|
});
|
|
252
252
|
}
|
|
253
253
|
sendQuestion(t, n) {
|
|
254
|
-
return
|
|
255
|
-
var i,
|
|
256
|
-
let
|
|
257
|
-
promptVariables: this.promptVariables.reduce((
|
|
254
|
+
return v(this, null, function* () {
|
|
255
|
+
var i, s, e;
|
|
256
|
+
let r = k(h({}, t), {
|
|
257
|
+
promptVariables: this.promptVariables.reduce((o, c) => k(h({}, o), {
|
|
258
258
|
[c.key]: c.value
|
|
259
259
|
}), {}),
|
|
260
|
-
knowledges: (i = this.knowledges) == null ? void 0 : i.map((
|
|
260
|
+
knowledges: (i = this.knowledges) == null ? void 0 : i.map((o) => o.id)
|
|
261
261
|
});
|
|
262
262
|
if (!this.active) {
|
|
263
263
|
if (yield this.activate(), !this.socket) {
|
|
264
|
-
const
|
|
264
|
+
const o = new Error(
|
|
265
265
|
y.SocketConnectionFailed
|
|
266
266
|
// {
|
|
267
267
|
// cause: { code: -1, message: 'socket is null' },
|
|
268
268
|
// }
|
|
269
269
|
);
|
|
270
|
-
return
|
|
270
|
+
return p.warn("error", o), this.event.emit("error", o), !1;
|
|
271
271
|
}
|
|
272
|
-
(
|
|
272
|
+
(s = this.socket) == null || s.emit("question", r);
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
(
|
|
275
|
+
(e = this.socket) == null || e.emit("question", r);
|
|
276
276
|
});
|
|
277
277
|
}
|
|
278
278
|
stopAnswer() {
|
package/dist/es/BotClient.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var w = Object.defineProperty, k = Object.defineProperties;
|
|
2
|
+
var A = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var g = Object.getOwnPropertySymbols;
|
|
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
6
|
for (var e in i || (i = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
7
|
+
x.call(i, e) && u(o, e, i[e]);
|
|
8
|
+
if (g)
|
|
9
|
+
for (var e of g(i))
|
|
10
|
+
I.call(i, e) && u(o, e, i[e]);
|
|
11
11
|
return o;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
12
|
+
}, f = (o, i) => k(o, A(i));
|
|
13
|
+
var l = (o, i, e) => (u(o, typeof i != "symbol" ? i + "" : i, e), e);
|
|
14
14
|
var c = (o, i, e) => new Promise((t, s) => {
|
|
15
15
|
var n = (a) => {
|
|
16
16
|
try {
|
|
@@ -18,43 +18,45 @@ var c = (o, i, e) => new Promise((t, s) => {
|
|
|
18
18
|
} catch (h) {
|
|
19
19
|
s(h);
|
|
20
20
|
}
|
|
21
|
-
},
|
|
21
|
+
}, d = (a) => {
|
|
22
22
|
try {
|
|
23
23
|
r(e.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,
|
|
27
|
+
}, r = (a) => a.done ? t(a.value) : Promise.resolve(a.value).then(n, d);
|
|
28
28
|
r((e = e.apply(o, i)).next());
|
|
29
29
|
});
|
|
30
|
-
import { parseJWT as
|
|
31
|
-
import
|
|
32
|
-
import { getCVForceService as
|
|
33
|
-
import { configure as
|
|
34
|
-
import { ApplicationTypes as
|
|
30
|
+
import { parseJWT as m } from "./utils.mjs";
|
|
31
|
+
import R from "./Logger.mjs";
|
|
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";
|
|
35
35
|
import L from "./AgentSession.mjs";
|
|
36
36
|
import M from "./DialogSession.mjs";
|
|
37
37
|
import C from "./EventBus.mjs";
|
|
38
|
-
const T = new
|
|
38
|
+
const T = new R("[BotClient] ");
|
|
39
39
|
class z {
|
|
40
40
|
constructor(i, e, t = !0) {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
l(this, "event", new C());
|
|
42
|
+
l(this, "cvforceApi");
|
|
43
43
|
//从token解析出来的用户信息
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
l(this, "_applicationId");
|
|
45
|
+
l(this, "_application", null);
|
|
46
46
|
//session列表,被加载过的session将会被缓存到这个列表中
|
|
47
|
-
|
|
47
|
+
l(this, "_sessions", []);
|
|
48
48
|
//活跃的session,只支持一个活跃的session
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
l(this, "_activeSession");
|
|
50
|
+
l(this, "_ready", !1);
|
|
51
51
|
//问题长度
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (this._token = i, this.lazyload = t,
|
|
52
|
+
l(this, "_questionContextMaxLength", 4e3);
|
|
53
|
+
l(this, "_promptVariables", []);
|
|
54
|
+
if (this._token = i, this.lazyload = t, S(e), this._applicationId = m(i).rid || y.applicationId, !this._applicationId)
|
|
55
55
|
throw "token is not vaild";
|
|
56
|
-
this.cvforceApi = this.getService(), this.loadApplication().then(() => {
|
|
57
|
-
|
|
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
|
|
59
|
+
})), this.event.emit("ready");
|
|
58
60
|
});
|
|
59
61
|
}
|
|
60
62
|
checkReady() {
|
|
@@ -86,8 +88,8 @@ class z {
|
|
|
86
88
|
loadApplication() {
|
|
87
89
|
return c(this, null, function* () {
|
|
88
90
|
var e, t, s;
|
|
89
|
-
this._application = yield this.cvforceApi.getApplicationId(this._applicationId).then((n) => (typeof n.arrange[0].recommendQuestionOpen != "boolean" && (n.arrange[0].recommendQuestionOpen = !0),
|
|
90
|
-
arrange: [
|
|
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]), {
|
|
91
93
|
recommendQuestionOpen: y.loadRelatedQuesions && n.arrange[0].recommendQuestionOpen
|
|
92
94
|
})]
|
|
93
95
|
})));
|
|
@@ -96,14 +98,14 @@ class z {
|
|
|
96
98
|
});
|
|
97
99
|
}
|
|
98
100
|
getService() {
|
|
99
|
-
return this.cvforceApi ? this.cvforceApi :
|
|
101
|
+
return this.cvforceApi ? this.cvforceApi : E(y.apiRoot, this.token, (i, e) => T.error(e));
|
|
100
102
|
}
|
|
101
103
|
get token() {
|
|
102
104
|
return this._token;
|
|
103
105
|
}
|
|
104
106
|
set token(i) {
|
|
105
107
|
this.checkReady(), this._token = i, this.ready = !1;
|
|
106
|
-
const e =
|
|
108
|
+
const e = m(i).rid;
|
|
107
109
|
this._applicationId !== e && (this._applicationId = e, this._application = null, this.loadApplication().then(() => {
|
|
108
110
|
this.event.emit("ready");
|
|
109
111
|
}), this.clean());
|
|
@@ -125,15 +127,15 @@ class z {
|
|
|
125
127
|
}
|
|
126
128
|
createSession(i, e, t, s, n) {
|
|
127
129
|
return c(this, null, function* () {
|
|
128
|
-
const
|
|
130
|
+
const d = this;
|
|
129
131
|
return new Promise((r, a) => {
|
|
130
|
-
const h = (
|
|
131
|
-
if (
|
|
132
|
-
r(new L(i, e, t, s, n,
|
|
133
|
-
else if (
|
|
134
|
-
r(new M(i, e, t, s, n,
|
|
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));
|
|
135
137
|
else
|
|
136
|
-
throw Error(`不支持的应用类型:${
|
|
138
|
+
throw Error(`不支持的应用类型:${_}`);
|
|
137
139
|
});
|
|
138
140
|
if (this.ready) {
|
|
139
141
|
if (!this._application)
|
|
@@ -152,16 +154,16 @@ class z {
|
|
|
152
154
|
return c(this, null, function* () {
|
|
153
155
|
return new Promise((e, t) => {
|
|
154
156
|
const s = () => this.cvforceApi.listSessions(this._applicationId, i).then((n) => {
|
|
155
|
-
const
|
|
157
|
+
const d = [];
|
|
156
158
|
return n.forEach((r) => c(this, null, function* () {
|
|
157
159
|
const a = this._sessions.find((h) => r.id === h.id);
|
|
158
160
|
if (a)
|
|
159
|
-
a.data = r, this._application ? a.application = this._application : a.loadApplicationInfo(),
|
|
161
|
+
a.data = r, this._application ? a.application = this._application : a.loadApplicationInfo(), d.push(a);
|
|
160
162
|
else {
|
|
161
163
|
const h = yield this.createSession(this.token, r.id, r, this.lazyload, this._application || void 0);
|
|
162
|
-
|
|
164
|
+
d.push(h);
|
|
163
165
|
}
|
|
164
|
-
})), this.sessions =
|
|
166
|
+
})), this.sessions = d, d;
|
|
165
167
|
});
|
|
166
168
|
if (this.ready) {
|
|
167
169
|
if (!this._application)
|
package/dist/es/Config.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
1
|
+
var s = Object.defineProperty, v = Object.defineProperties;
|
|
2
2
|
var u = 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 ?
|
|
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) => {
|
|
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) =>
|
|
12
|
+
}, l = (o, t) => v(o, u(t));
|
|
13
13
|
import d from "./Logger.mjs";
|
|
14
14
|
const R = new d("[Config] ");
|
|
15
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 || {});
|
|
@@ -22,9 +22,10 @@ let c = {
|
|
|
22
22
|
applicationId: "",
|
|
23
23
|
plugins: {},
|
|
24
24
|
mcp: void 0,
|
|
25
|
-
loadRelatedQuesions: !0
|
|
25
|
+
loadRelatedQuesions: !0,
|
|
26
|
+
stream: !1
|
|
26
27
|
};
|
|
27
|
-
function
|
|
28
|
+
function w(o) {
|
|
28
29
|
d.debug = (o == null ? void 0 : o.debug) || !1, c = l(i(i({}, c), o), {
|
|
29
30
|
apiRoot: (o == null ? void 0 : o.apiRoot) || c.apiRoot || (o != null && o.env ? f[o.env || "prod"] : c.apiRoot)
|
|
30
31
|
}), d.debug && R.log("updated", c);
|
|
@@ -32,5 +33,5 @@ function x(o) {
|
|
|
32
33
|
export {
|
|
33
34
|
f as ApiUrl,
|
|
34
35
|
c as configuration,
|
|
35
|
-
|
|
36
|
+
w as configure
|
|
36
37
|
};
|