@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.
- 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
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
var A = Object.defineProperty, O = Object.defineProperties;
|
|
2
2
|
var D = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
3
|
+
var v = Object.getOwnPropertySymbols;
|
|
4
4
|
var P = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
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) &&
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
$.call(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
|
|
14
|
-
var f = (i, c, t) => new Promise((o,
|
|
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
|
-
|
|
17
|
+
m(t.next(e));
|
|
18
18
|
} catch (l) {
|
|
19
|
-
|
|
19
|
+
g(l);
|
|
20
20
|
}
|
|
21
21
|
}, s = (e) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
m(t.throw(e));
|
|
24
24
|
} catch (l) {
|
|
25
|
-
|
|
25
|
+
g(l);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
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
|
|
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
|
|
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 = "",
|
|
39
|
-
super(t, o,
|
|
40
|
-
|
|
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,
|
|
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:
|
|
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({},
|
|
64
|
-
stream:
|
|
63
|
+
}, l = R(u({}, g), {
|
|
64
|
+
stream: M.stream
|
|
65
65
|
});
|
|
66
|
-
p(`${
|
|
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 (
|
|
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),
|
|
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,
|
|
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:
|
|
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({},
|
|
166
|
-
stream:
|
|
165
|
+
}, l = R(u({}, g), {
|
|
166
|
+
stream: M.stream
|
|
167
167
|
});
|
|
168
|
-
p(`${
|
|
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),
|
|
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
|
|
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" &&
|
|
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:
|
|
242
|
+
content: g,
|
|
243
243
|
fileIds: d,
|
|
244
244
|
oldMessageId: s
|
|
245
245
|
} = t, {
|
|
246
|
-
stream:
|
|
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:
|
|
251
|
+
content: g,
|
|
252
252
|
fileIds: d,
|
|
253
253
|
referenceFirst: e,
|
|
254
254
|
oldMessageId: s,
|