@glodon-aiot/bot-client-sdk 3.26.0-alpha.21 → 3.26.0-alpha.23
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/README.md +130 -180
- package/dist/es/BotClient.mjs +136 -154
- package/dist/es/Config.mjs +88 -51
- package/dist/es/Session.mjs +23 -35
- package/dist/es/index.mjs +64 -66
- package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +113 -185
- package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +137 -127
- package/dist/es/localFiles/adapters/MemoryWorkspaceAdapter.mjs +97 -132
- package/dist/es/localFiles/adapters/WorkspaceFileAdapter.mjs +28 -32
- package/dist/es/localFiles/constants.mjs +29 -24
- package/dist/es/localFiles/createLocalPythonPlugin.mjs +196 -0
- package/dist/es/localFiles/errors.mjs +19 -21
- package/dist/es/localFiles/host/connectHostBridge.mjs +34 -37
- package/dist/es/localFiles/host/protocol.mjs +13 -27
- package/dist/es/localFiles/schemas.mjs +86 -40
- package/dist/es/localFiles/validate.mjs +37 -37
- package/dist/es/localFiles/workspace/LocalWorkspace.mjs +87 -161
- package/dist/es/package.json.mjs +29 -38
- package/dist/lib/index.js +9 -373
- package/dist/src/Config.d.ts +7 -5
- package/dist/src/Session.d.ts +0 -6
- package/dist/src/index.d.ts +1 -2
- package/dist/src/localFiles/adapters/FileSystemAccessAdapter.d.ts +1 -4
- package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +14 -30
- package/dist/src/localFiles/adapters/MemoryWorkspaceAdapter.d.ts +1 -4
- package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +0 -22
- package/dist/src/localFiles/adapters/fsaTypes.d.ts +0 -2
- package/dist/src/localFiles/constants.d.ts +13 -3
- package/dist/src/localFiles/host/protocol.d.ts +16 -34
- package/dist/src/localFiles/index.d.ts +6 -11
- package/dist/src/localFiles/schemas.d.ts +5 -2
- package/dist/src/localFiles/types.d.ts +23 -16
- package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +1 -32
- package/package.json +4 -13
- package/dist/es/builtinTools/browserRuntime/BrowserCommandRunner.mjs +0 -201
- package/dist/es/builtinTools/browserRuntime/PythonRunner.mjs +0 -356
- package/dist/es/builtinTools/browserRuntime/WorkspaceBashFs.mjs +0 -350
- package/dist/es/builtinTools/browserRuntime/assets.mjs +0 -9
- package/dist/es/builtinTools/browserRuntime/loadBash.mjs +0 -17
- package/dist/es/builtinTools/browserRuntime/pyodideRunner.py.mjs +0 -96
- package/dist/es/builtinTools/browserRuntime/pyodideWorker.mjs +0 -242
- package/dist/es/builtinTools/command.mjs +0 -56
- package/dist/es/builtinTools/constants.mjs +0 -10
- package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +0 -261
- package/dist/es/builtinTools/overview.mjs +0 -77
- package/dist/es/builtinTools/paths.mjs +0 -69
- package/dist/es/builtinTools/platformSkills.mjs +0 -210
- package/dist/es/builtinTools/schemas.mjs +0 -216
- package/dist/es/builtinTools/tools.mjs +0 -494
- package/dist/es/localFiles/adapters/FileSnapshotAdapter.mjs +0 -160
- package/dist/es/localFiles/host/sandboxClient.mjs +0 -420
- package/dist/es/localFiles/host/sandboxFrames.mjs +0 -21
- package/dist/es/localFiles/preview.mjs +0 -33
- package/dist/es/localFiles/workspace/WorkspaceFiles.mjs +0 -246
- package/dist/es/sessionUpload.mjs +0 -49
- package/dist/src/builtinTools/browserRuntime/BrowserCommandRunner.d.ts +0 -26
- package/dist/src/builtinTools/browserRuntime/PythonRunner.d.ts +0 -67
- package/dist/src/builtinTools/browserRuntime/WorkspaceBashFs.d.ts +0 -51
- package/dist/src/builtinTools/browserRuntime/assets.d.ts +0 -13
- package/dist/src/builtinTools/browserRuntime/loadBash.d.ts +0 -3
- package/dist/src/builtinTools/browserRuntime/pyodideWorker.d.ts +0 -44
- package/dist/src/builtinTools/command.d.ts +0 -35
- package/dist/src/builtinTools/constants.d.ts +0 -17
- package/dist/src/builtinTools/createBuiltinToolsPlugin.d.ts +0 -11
- package/dist/src/builtinTools/overview.d.ts +0 -5
- package/dist/src/builtinTools/paths.d.ts +0 -16
- package/dist/src/builtinTools/platformSkills.d.ts +0 -67
- package/dist/src/builtinTools/schemas.d.ts +0 -3
- package/dist/src/builtinTools/tools.d.ts +0 -64
- package/dist/src/localFiles/adapters/FileSnapshotAdapter.d.ts +0 -24
- package/dist/src/localFiles/host/sandboxClient.d.ts +0 -81
- package/dist/src/localFiles/host/sandboxFrames.d.ts +0 -9
- package/dist/src/localFiles/preview.d.ts +0 -2
- package/dist/src/localFiles/workspace/WorkspaceFiles.d.ts +0 -63
- package/dist/src/sessionUpload.d.ts +0 -14
package/dist/es/BotClient.mjs
CHANGED
|
@@ -1,55 +1,53 @@
|
|
|
1
1
|
var x = Object.defineProperty, b = Object.defineProperties;
|
|
2
2
|
var R = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
3
|
+
var m = Object.getOwnPropertySymbols;
|
|
4
4
|
var E = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
E.call(
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
L.call(
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
var l = (
|
|
14
|
-
var
|
|
5
|
+
var v = (c, e, i) => e in c ? x(c, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : c[e] = i, f = (c, e) => {
|
|
6
|
+
for (var i in e || (e = {}))
|
|
7
|
+
E.call(e, i) && v(c, i, e[i]);
|
|
8
|
+
if (m)
|
|
9
|
+
for (var i of m(e))
|
|
10
|
+
L.call(e, i) && v(c, i, e[i]);
|
|
11
|
+
return c;
|
|
12
|
+
}, _ = (c, e) => b(c, R(e));
|
|
13
|
+
var l = (c, e, i) => (v(c, typeof e != "symbol" ? e + "" : e, i), i);
|
|
14
|
+
var d = (c, e, i) => new Promise((t, s) => {
|
|
15
15
|
var n = (a) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
|
|
17
|
+
o(i.next(a));
|
|
18
|
+
} catch (h) {
|
|
19
|
+
s(h);
|
|
20
20
|
}
|
|
21
21
|
}, r = (a) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
|
|
23
|
+
o(i.throw(a));
|
|
24
|
+
} catch (h) {
|
|
25
|
+
s(h);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, o = (a) => a.done ? t(a.value) : Promise.resolve(a.value).then(n, r);
|
|
28
|
+
o((i = i.apply(c, e)).next());
|
|
29
29
|
});
|
|
30
30
|
import { parseJWT as y } from "./utils.mjs";
|
|
31
31
|
import W from "./Logger.mjs";
|
|
32
|
-
import { getAIShopService as M, getCVForceService as
|
|
33
|
-
import { configure as k, configuration as
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import { createDefaultSessionFileTransfer as P } from "./localFiles/transfer/SessionFileTransfer.mjs";
|
|
40
|
-
import { ApplicationTypes as g, PromptVariableType as A } from "@glodon-aiot/apis";
|
|
32
|
+
import { getAIShopService as M, getCVForceService as C } from "./api/index.mjs";
|
|
33
|
+
import { configure as k, configuration as p, setActiveLocalWorkspace as S, refreshBuiltinPlugins as w } from "./Config.mjs";
|
|
34
|
+
import { connectHostBridge as T } from "./localFiles/host/connectHostBridge.mjs";
|
|
35
|
+
import { LocalWorkspace as V } from "./localFiles/workspace/LocalWorkspace.mjs";
|
|
36
|
+
import { createIndexedDbStore as B } from "./localFiles/workspace/handleStore.mjs";
|
|
37
|
+
import { createDefaultSessionFileTransfer as O } from "./localFiles/transfer/SessionFileTransfer.mjs";
|
|
38
|
+
import { ApplicationTypes as u, PromptVariableType as A } from "@glodon-aiot/apis";
|
|
41
39
|
import D from "./AgentSession.mjs";
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
40
|
+
import H from "./DialogSession.mjs";
|
|
41
|
+
import F from "./EventBus.mjs";
|
|
42
|
+
import P from "./package.json.mjs";
|
|
45
43
|
const I = new W("[BotClient] ");
|
|
46
|
-
class
|
|
47
|
-
constructor(
|
|
44
|
+
class ie {
|
|
45
|
+
constructor(e, i, t = !0, s = {
|
|
48
46
|
analytics: {
|
|
49
47
|
enabled: !1
|
|
50
48
|
}
|
|
51
49
|
}) {
|
|
52
|
-
l(this, "event", new
|
|
50
|
+
l(this, "event", new F());
|
|
53
51
|
l(this, "cvforceApi");
|
|
54
52
|
//从token解析出来的用户信息
|
|
55
53
|
l(this, "_applicationId");
|
|
@@ -64,50 +62,35 @@ class ni {
|
|
|
64
62
|
l(this, "_promptVariables", []);
|
|
65
63
|
l(this, "_localWorkspace");
|
|
66
64
|
l(this, "_disconnectHost");
|
|
67
|
-
if (this._token =
|
|
68
|
-
refreshBuiltinPlugins: !1
|
|
69
|
-
}), this._applicationId = y(i).rid || f.applicationId, !this._applicationId)
|
|
65
|
+
if (this._token = e, this.lazyload = t, this.sdkConfigs = s, k(i), this._applicationId = y(e).rid || p.applicationId, !this._applicationId)
|
|
70
66
|
throw "token is not vaild";
|
|
71
67
|
this.cvforceApi = this.getService(), this.setupLocalWorkspace(), this.loadApplication().then((n) => {
|
|
72
|
-
k(
|
|
73
|
-
stream:
|
|
68
|
+
k(_(f({}, i), {
|
|
69
|
+
stream: i.stream === void 0 ? (n == null ? void 0 : n.type) === u.Dialog || (n == null ? void 0 : n.type) === u.Agent : i.stream
|
|
74
70
|
})), this.event.emit("ready");
|
|
75
71
|
});
|
|
76
72
|
}
|
|
77
73
|
setupLocalWorkspace() {
|
|
78
|
-
var
|
|
79
|
-
const
|
|
80
|
-
if (!(
|
|
74
|
+
var s, n;
|
|
75
|
+
const e = (s = p.builtinPlugins) == null ? void 0 : s.localFiles;
|
|
76
|
+
if (!(e != null && e.enabled)) {
|
|
81
77
|
S(void 0), w();
|
|
82
78
|
return;
|
|
83
79
|
}
|
|
84
|
-
const
|
|
80
|
+
const i = [], t = (n = e.backend) != null ? n : "file-system-access";
|
|
85
81
|
if (t !== "file-system-access" && t !== "host-bridge")
|
|
86
|
-
|
|
82
|
+
i.push(new Error(`[LocalFiles] 不支持的 backend:${e.backend}`));
|
|
87
83
|
else {
|
|
88
|
-
const r = M(
|
|
89
|
-
this._localWorkspace = new
|
|
84
|
+
const r = M(p.apiRoot, this.token, (o, a) => I.error(a));
|
|
85
|
+
this._localWorkspace = new V({
|
|
90
86
|
applicationId: this._applicationId,
|
|
91
|
-
config:
|
|
92
|
-
store:
|
|
87
|
+
config: e,
|
|
88
|
+
store: B(),
|
|
93
89
|
picker: t === "host-bridge" ? null : void 0,
|
|
94
|
-
transfer:
|
|
95
|
-
}), S(this._localWorkspace), this.
|
|
96
|
-
applicationId: () => this._applicationId,
|
|
97
|
-
getToken: () => this.token,
|
|
98
|
-
getSkills: () => {
|
|
99
|
-
var s, a, c, d;
|
|
100
|
-
return (d = (c = (a = (s = this._application) == null ? void 0 : s.arrange) == null ? void 0 : a[0]) == null ? void 0 : c.skills) != null ? d : [];
|
|
101
|
-
},
|
|
102
|
-
apiRoot: () => f.apiRoot,
|
|
103
|
-
getSandbox: () => {
|
|
104
|
-
var a;
|
|
105
|
-
const s = (a = this._localWorkspace) == null ? void 0 : a.adapter;
|
|
106
|
-
return s instanceof B ? s.sandbox : void 0;
|
|
107
|
-
}
|
|
108
|
-
}), t === "host-bridge" ? this._disconnectHost = V(this._localWorkspace) : this._localWorkspace.restore();
|
|
90
|
+
transfer: O(() => this.cvforceApi, () => r)
|
|
91
|
+
}), S(this._localWorkspace), t === "host-bridge" ? this._disconnectHost = T(this._localWorkspace) : this._localWorkspace.restore();
|
|
109
92
|
}
|
|
110
|
-
|
|
93
|
+
i.push(...w()), i.length && Promise.resolve().then(() => i.forEach((r) => this.event.emit("error", r)));
|
|
111
94
|
}
|
|
112
95
|
/** 启用 builtinPlugins.localFiles 后可用;UI 与纯 SDK 集成共用此实例。 */
|
|
113
96
|
get localWorkspace() {
|
|
@@ -120,8 +103,8 @@ class ni {
|
|
|
120
103
|
get ready() {
|
|
121
104
|
return this._ready;
|
|
122
105
|
}
|
|
123
|
-
set ready(
|
|
124
|
-
this._ready =
|
|
106
|
+
set ready(e) {
|
|
107
|
+
this._ready = e;
|
|
125
108
|
}
|
|
126
109
|
get questionContextMaxLength() {
|
|
127
110
|
return this.checkReady(), this._questionContextMaxLength;
|
|
@@ -130,49 +113,49 @@ class ni {
|
|
|
130
113
|
return this.checkReady(), this._promptVariables;
|
|
131
114
|
}
|
|
132
115
|
get knowledges() {
|
|
133
|
-
var
|
|
134
|
-
return this.checkReady(), (
|
|
116
|
+
var e;
|
|
117
|
+
return this.checkReady(), (e = this._application) == null ? void 0 : e.arrange[0].knowledges;
|
|
135
118
|
}
|
|
136
119
|
get sessions() {
|
|
137
120
|
return this.checkReady(), this._sessions;
|
|
138
121
|
}
|
|
139
|
-
set sessions(
|
|
140
|
-
this.checkReady(), this._sessions =
|
|
122
|
+
set sessions(e) {
|
|
123
|
+
this.checkReady(), this._sessions = e, this.event.emit("sessions:updated", e);
|
|
141
124
|
}
|
|
142
125
|
loadApplication() {
|
|
143
|
-
return
|
|
144
|
-
var
|
|
126
|
+
return d(this, null, function* () {
|
|
127
|
+
var i, t, s, n, r;
|
|
145
128
|
this._application = yield this.cvforceApi.getApplicationId(
|
|
146
129
|
this._applicationId,
|
|
147
130
|
// 这里记录应用的名称和版本,以便后期数据分析
|
|
148
131
|
{
|
|
149
|
-
ui: (
|
|
132
|
+
ui: (i = this.sdkConfigs.ui) == null ? void 0 : i.name,
|
|
150
133
|
uiVersion: (t = this.sdkConfigs.ui) == null ? void 0 : t.version,
|
|
151
|
-
sdkVersion:
|
|
134
|
+
sdkVersion: P.version
|
|
152
135
|
}
|
|
153
|
-
).then((
|
|
154
|
-
arrange: [
|
|
155
|
-
recommendQuestionOpen:
|
|
136
|
+
).then((o) => (typeof o.arrange[0].thinkingModeOpen != "boolean" && (o.arrange[0].thinkingModeOpen = !0), typeof o.arrange[0].thinkingTextOpen != "boolean" && (o.arrange[0].thinkingTextOpen = !0), _(f({}, o), {
|
|
137
|
+
arrange: [_(f({}, o.arrange[0]), {
|
|
138
|
+
recommendQuestionOpen: p.loadRelatedQuesions && o.arrange[0].recommendQuestionOpen
|
|
156
139
|
})]
|
|
157
140
|
})));
|
|
158
|
-
const
|
|
159
|
-
return
|
|
141
|
+
const e = (r = (n = (s = this._application) == null ? void 0 : s.arrange) == null ? void 0 : n[0]) == null ? void 0 : r.llmModel;
|
|
142
|
+
return e && (this._questionContextMaxLength = yield this.cvforceApi.getBaseModel(e).then((o) => o.maxModelLength)), this._promptVariables = yield Promise.all([this.cvforceApi.getPrompts(this._applicationId, {
|
|
160
143
|
type: A.User
|
|
161
144
|
}), this.cvforceApi.getPrompts(this._applicationId, {
|
|
162
145
|
type: A.System
|
|
163
|
-
})]).then(([
|
|
146
|
+
})]).then(([o, a]) => [...o, ...a]), this._ready = !0, this.event.emit("application:loaded"), this._application;
|
|
164
147
|
});
|
|
165
148
|
}
|
|
166
149
|
getService() {
|
|
167
|
-
return this.cvforceApi ? this.cvforceApi :
|
|
150
|
+
return this.cvforceApi ? this.cvforceApi : C(p.apiRoot, this.token, (e, i) => I.error(i));
|
|
168
151
|
}
|
|
169
152
|
get token() {
|
|
170
153
|
return this._token;
|
|
171
154
|
}
|
|
172
|
-
set token(
|
|
173
|
-
this.checkReady(), this._token =
|
|
174
|
-
const
|
|
175
|
-
this._applicationId !==
|
|
155
|
+
set token(e) {
|
|
156
|
+
this.checkReady(), this._token = e, this.ready = !1;
|
|
157
|
+
const i = y(e).rid;
|
|
158
|
+
this._applicationId !== i && (this._applicationId = i, this._application = null, this.loadApplication().then(() => {
|
|
176
159
|
this.event.emit("ready");
|
|
177
160
|
}), this.clean());
|
|
178
161
|
}
|
|
@@ -183,35 +166,35 @@ class ni {
|
|
|
183
166
|
return this.checkReady(), this._application;
|
|
184
167
|
}
|
|
185
168
|
get activeSession() {
|
|
186
|
-
var
|
|
187
|
-
return this.checkReady(), ((
|
|
169
|
+
var e;
|
|
170
|
+
return this.checkReady(), ((e = this._activeSession) == null ? void 0 : e.id) || "";
|
|
188
171
|
}
|
|
189
|
-
set activeSession(
|
|
190
|
-
this.checkReady(), this.loadSession(
|
|
191
|
-
this._activeSession && this._activeSession.id !==
|
|
172
|
+
set activeSession(e) {
|
|
173
|
+
this.checkReady(), this.loadSession(e).then((i) => {
|
|
174
|
+
this._activeSession && this._activeSession.id !== e && this._activeSession.inactivate(), this._activeSession = i;
|
|
192
175
|
});
|
|
193
176
|
}
|
|
194
|
-
createSession(
|
|
195
|
-
return
|
|
177
|
+
createSession(e, i, t, s, n) {
|
|
178
|
+
return d(this, null, function* () {
|
|
196
179
|
const r = this;
|
|
197
|
-
return new Promise((
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
else if (
|
|
202
|
-
|
|
180
|
+
return new Promise((o, a) => {
|
|
181
|
+
const h = (g) => d(this, null, function* () {
|
|
182
|
+
if (g === u.Agent)
|
|
183
|
+
o(new D(e, i, t, s, n, r));
|
|
184
|
+
else if (g === u.Dialog)
|
|
185
|
+
o(new H(e, i, t, s, n, r));
|
|
203
186
|
else
|
|
204
|
-
throw Error(`不支持的应用类型:${
|
|
187
|
+
throw Error(`不支持的应用类型:${g}`);
|
|
205
188
|
});
|
|
206
189
|
if (this.ready) {
|
|
207
190
|
if (!this._application)
|
|
208
191
|
throw Error("client is not ready");
|
|
209
|
-
|
|
192
|
+
h(this._application.type);
|
|
210
193
|
} else
|
|
211
194
|
this.event.on("ready", () => {
|
|
212
195
|
if (!this._application)
|
|
213
196
|
throw Error("_application is null");
|
|
214
|
-
|
|
197
|
+
h(this._application.type);
|
|
215
198
|
}, !0);
|
|
216
199
|
});
|
|
217
200
|
});
|
|
@@ -219,38 +202,38 @@ class ni {
|
|
|
219
202
|
/**
|
|
220
203
|
* 获取会话产出物。不传 sessionId 时取当前活跃会话。没有产出物时返回空数组。
|
|
221
204
|
*/
|
|
222
|
-
getArtifacts(
|
|
223
|
-
return
|
|
205
|
+
getArtifacts(e) {
|
|
206
|
+
return d(this, null, function* () {
|
|
224
207
|
var n, r;
|
|
225
208
|
this.checkReady();
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
209
|
+
const i = e || ((n = this._activeSession) == null ? void 0 : n.id);
|
|
210
|
+
if (!i)
|
|
228
211
|
throw new Error("session id is not defined");
|
|
229
|
-
const t = this._sessions.find((
|
|
212
|
+
const t = this._sessions.find((o) => o.id === i);
|
|
230
213
|
if (t)
|
|
231
214
|
return t.getArtifacts();
|
|
232
|
-
const
|
|
233
|
-
return (r =
|
|
215
|
+
const s = yield this.cvforceApi.getSessionArtifacts(this._applicationId, i);
|
|
216
|
+
return (r = s == null ? void 0 : s.artifacts) != null ? r : [];
|
|
234
217
|
});
|
|
235
218
|
}
|
|
236
|
-
getSessions(
|
|
237
|
-
return
|
|
238
|
-
return new Promise((
|
|
239
|
-
const
|
|
219
|
+
getSessions(e) {
|
|
220
|
+
return d(this, null, function* () {
|
|
221
|
+
return new Promise((i, t) => {
|
|
222
|
+
const s = () => this.cvforceApi.listSessions(this._applicationId, e).then((n) => d(this, null, function* () {
|
|
240
223
|
const r = [];
|
|
241
|
-
for (const
|
|
242
|
-
const a = this._sessions.find((
|
|
224
|
+
for (const o of n) {
|
|
225
|
+
const a = this._sessions.find((h) => h.id === o.id);
|
|
243
226
|
if (a)
|
|
244
|
-
a.data =
|
|
227
|
+
a.data = o, this._application ? a.application = this._application : yield a.loadApplicationInfo(), r.push(a);
|
|
245
228
|
else {
|
|
246
|
-
const
|
|
247
|
-
r.push(
|
|
229
|
+
const h = yield this.createSession(this.token, o.id, o, this.lazyload, this._application || void 0);
|
|
230
|
+
r.push(h);
|
|
248
231
|
}
|
|
249
232
|
}
|
|
250
|
-
if (
|
|
251
|
-
const
|
|
252
|
-
for (const
|
|
253
|
-
a.set(
|
|
233
|
+
if (e != null && e.pageSize) {
|
|
234
|
+
const o = [...this._sessions, ...r], a = /* @__PURE__ */ new Map();
|
|
235
|
+
for (const h of o)
|
|
236
|
+
a.set(h.id, h);
|
|
254
237
|
return this.sessions = Array.from(a.values()), this.sessions;
|
|
255
238
|
} else
|
|
256
239
|
return this.sessions = r, r;
|
|
@@ -258,22 +241,21 @@ class ni {
|
|
|
258
241
|
if (this.ready) {
|
|
259
242
|
if (!this._application)
|
|
260
243
|
throw Error("_application is null");
|
|
261
|
-
|
|
244
|
+
i(s());
|
|
262
245
|
} else
|
|
263
246
|
this.event.on("ready", () => {
|
|
264
247
|
if (!this._application)
|
|
265
248
|
throw Error("_application is null");
|
|
266
|
-
|
|
249
|
+
i(s());
|
|
267
250
|
}, !0);
|
|
268
251
|
});
|
|
269
252
|
});
|
|
270
253
|
}
|
|
271
|
-
loadSession(
|
|
272
|
-
return
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (t || (t = yield this.createSession(this.token, i, e), this._sessions.push(t)), this._activeSession) {
|
|
254
|
+
loadSession(e = "", i) {
|
|
255
|
+
return d(this, null, function* () {
|
|
256
|
+
this.checkReady();
|
|
257
|
+
let t = this.sessions.find((s) => s.id === e);
|
|
258
|
+
if (t || (t = yield this.createSession(this.token, e, i), this._sessions.push(t)), this._activeSession) {
|
|
277
259
|
if (this._activeSession === t)
|
|
278
260
|
return t;
|
|
279
261
|
this._activeSession.inactivate();
|
|
@@ -284,61 +266,61 @@ class ni {
|
|
|
284
266
|
});
|
|
285
267
|
}
|
|
286
268
|
reload() {
|
|
287
|
-
return this.loadApplication().then(() =>
|
|
269
|
+
return this.loadApplication().then(() => d(this, null, function* () {
|
|
288
270
|
return yield this.getSessions(), this.event.emit("ready"), this;
|
|
289
271
|
}));
|
|
290
272
|
}
|
|
291
|
-
reloadSession(
|
|
292
|
-
return
|
|
273
|
+
reloadSession(e) {
|
|
274
|
+
return d(this, null, function* () {
|
|
293
275
|
yield this.reload();
|
|
294
|
-
let
|
|
295
|
-
if (!
|
|
276
|
+
let i = this._sessions.find((t) => t.id === e) || this._activeSession;
|
|
277
|
+
if (!i) {
|
|
296
278
|
console.warn("reloadSession session failed.");
|
|
297
279
|
return;
|
|
298
280
|
}
|
|
299
|
-
return yield
|
|
281
|
+
return yield i.reload(), i;
|
|
300
282
|
});
|
|
301
283
|
}
|
|
302
|
-
setTop(
|
|
303
|
-
return
|
|
304
|
-
let
|
|
305
|
-
if (!
|
|
284
|
+
setTop(e, i, t = "top_time desc, sort_status desc, updated_at desc") {
|
|
285
|
+
return d(this, null, function* () {
|
|
286
|
+
let s = e ? this._sessions.find((n) => n.id === e) : this._activeSession;
|
|
287
|
+
if (!s) {
|
|
306
288
|
console.warn("setTop session failed.");
|
|
307
289
|
return;
|
|
308
290
|
}
|
|
309
|
-
return yield
|
|
291
|
+
return yield s.setTop(i), this.getSessions({
|
|
310
292
|
order: t
|
|
311
293
|
});
|
|
312
294
|
});
|
|
313
295
|
}
|
|
314
|
-
addEventListener(
|
|
315
|
-
if (typeof
|
|
296
|
+
addEventListener(e, i, t = !1) {
|
|
297
|
+
if (typeof i != "function")
|
|
316
298
|
throw Error("event listener is not a function");
|
|
317
299
|
if (t) {
|
|
318
|
-
this.event.once(
|
|
300
|
+
this.event.once(e, i);
|
|
319
301
|
return;
|
|
320
302
|
}
|
|
321
|
-
this.event.on(
|
|
303
|
+
this.event.on(e, i);
|
|
322
304
|
}
|
|
323
|
-
removeEventListener(
|
|
324
|
-
this.event.off(
|
|
305
|
+
removeEventListener(e, i) {
|
|
306
|
+
this.event.off(e, i);
|
|
325
307
|
}
|
|
326
|
-
removeSession(
|
|
327
|
-
return
|
|
308
|
+
removeSession(e, i) {
|
|
309
|
+
return d(this, null, function* () {
|
|
328
310
|
this.checkReady();
|
|
329
311
|
let t = -1;
|
|
330
|
-
if (typeof
|
|
331
|
-
const
|
|
332
|
-
|
|
312
|
+
if (typeof e == "string" ? t = this._sessions.findIndex((s) => s.id === e) : t = this._sessions.findIndex((s) => s.id === e.id), t > -1) {
|
|
313
|
+
const s = this._sessions[t];
|
|
314
|
+
i && (yield s.delete()), this._sessions.splice(t, 1);
|
|
333
315
|
} else
|
|
334
316
|
console.warn("session delete failed, session is not exist.");
|
|
335
317
|
});
|
|
336
318
|
}
|
|
337
319
|
clean() {
|
|
338
|
-
var
|
|
339
|
-
(
|
|
320
|
+
var e;
|
|
321
|
+
(e = this._disconnectHost) == null || e.call(this), this._disconnectHost = void 0, this._sessions.forEach((i) => i.destroy()), this.sessions = [];
|
|
340
322
|
}
|
|
341
323
|
}
|
|
342
324
|
export {
|
|
343
|
-
|
|
325
|
+
ie as default
|
|
344
326
|
};
|
package/dist/es/Config.mjs
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var O = Object.defineProperty, w = Object.defineProperties;
|
|
2
|
+
var k = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var h = Object.getOwnPropertySymbols;
|
|
4
|
+
var F = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var a = (e, i, o) => i in e ? O(e, i, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[i] = o, c = (e, i) => {
|
|
6
6
|
for (var o in i || (i = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var o of
|
|
10
|
-
|
|
7
|
+
F.call(i, o) && a(e, o, i[o]);
|
|
8
|
+
if (h)
|
|
9
|
+
for (var o of h(i))
|
|
10
|
+
N.call(i, o) && a(e, o, i[o]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
13
|
-
import
|
|
14
|
-
import { LOCAL_FILES_PLUGIN_CODES as
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
}, R = (e, i) => w(e, k(i));
|
|
13
|
+
import f from "./Logger.mjs";
|
|
14
|
+
import { LOCAL_PYTHON_FUNCTION_CODE as y, LOCAL_FILES_PLUGIN_CODES as A, LOCAL_PYTHON_PLUGIN_CODES as E } from "./localFiles/constants.mjs";
|
|
15
|
+
import { createLocalFilesPlugin as I } from "./localFiles/createLocalFilesPlugin.mjs";
|
|
16
|
+
import { createLocalPythonPlugin as $ } from "./localFiles/createLocalPythonPlugin.mjs";
|
|
17
|
+
const q = new f("[Config] ");
|
|
18
|
+
var _ = /* @__PURE__ */ ((e) => (e.dev = "https://aiot-dev.glodon.com/api/cvforcepd", e.test = "https://aiot-dev.glodon.com/api/cvforce", e.prod = "https://copilot.glodon.com/api/cvforce", e.local = "http://localhost:3000/api/cvforcepd", e))(_ || {});
|
|
18
19
|
let n = {
|
|
19
20
|
debug: !1,
|
|
20
21
|
env: "prod",
|
|
@@ -30,59 +31,95 @@ let n = {
|
|
|
30
31
|
mcp: void 0,
|
|
31
32
|
loadRelatedQuesions: !0,
|
|
32
33
|
stream: !1
|
|
33
|
-
}, u,
|
|
34
|
-
const
|
|
35
|
-
function
|
|
36
|
-
u !== e && (u = e,
|
|
34
|
+
}, u, r, d;
|
|
35
|
+
const v = /* @__PURE__ */ new Set();
|
|
36
|
+
function T(e) {
|
|
37
|
+
u !== e && (u = e, r = void 0, d = void 0, v.clear());
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
-
if (!
|
|
39
|
+
function j() {
|
|
40
|
+
if (!r)
|
|
40
41
|
return;
|
|
41
42
|
const {
|
|
42
43
|
pluginCode: e,
|
|
43
44
|
table: i
|
|
44
|
-
} =
|
|
45
|
-
if (!(!o || o.
|
|
45
|
+
} = r, o = n.plugins[e], l = i[e];
|
|
46
|
+
if (!(!o || o.list_directory !== l.list_directory))
|
|
47
|
+
return e;
|
|
48
|
+
}
|
|
49
|
+
function z() {
|
|
50
|
+
if (!d)
|
|
51
|
+
return;
|
|
52
|
+
const {
|
|
53
|
+
pluginCode: e,
|
|
54
|
+
table: i
|
|
55
|
+
} = d, o = n.plugins[e], l = i[e];
|
|
56
|
+
if (!(!o || o[y] !== l[y]))
|
|
46
57
|
return e;
|
|
47
58
|
}
|
|
48
59
|
function S(e, i) {
|
|
49
|
-
return (e == null ? void 0 : e.pluginCode) ||
|
|
60
|
+
return (e == null ? void 0 : e.pluginCode) || A[i];
|
|
61
|
+
}
|
|
62
|
+
function D(e, i, o) {
|
|
63
|
+
return (e == null ? void 0 : e.pluginCode) || o || E[i];
|
|
50
64
|
}
|
|
51
|
-
function
|
|
52
|
-
var
|
|
53
|
-
const e = (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (!u)
|
|
57
|
-
return o.push("[BuiltinTools] 内置工具依赖已启用的本地工作区。工具未注册。"), n.plugins = t, o;
|
|
58
|
-
const l = i != null && i.enabled ? S(i, n.env) : void 0;
|
|
59
|
-
return l ? e[l] ? o.push(`[BuiltinTools] 业务插件中已存在 pluginCode「${l}」,已保留业务插件,内置工具未注册。`) : (((s == null ? void 0 : s.workspace) !== u || s.pluginCode !== l) && (s = {
|
|
65
|
+
function H() {
|
|
66
|
+
var P, C, b;
|
|
67
|
+
const e = (P = n.businessPlugins) != null ? P : {}, i = (C = n.builtinPlugins) == null ? void 0 : C.localFiles, o = (b = n.builtinPlugins) == null ? void 0 : b.localPython, l = [], g = c({}, e);
|
|
68
|
+
let s, p = !1;
|
|
69
|
+
if (i != null && i.enabled && u && (s = S(i, n.env), s ? e[s] ? l.push(`[LocalFiles] 业务插件中已存在 pluginCode「${s}」,已保留业务插件,内置文件工具未注册。`) : (((r == null ? void 0 : r.workspace) !== u || r.pluginCode !== s) && (r = {
|
|
60
70
|
workspace: u,
|
|
61
|
-
pluginCode:
|
|
62
|
-
table:
|
|
63
|
-
pluginCode:
|
|
71
|
+
pluginCode: s,
|
|
72
|
+
table: I({
|
|
73
|
+
pluginCode: s,
|
|
64
74
|
workspace: u
|
|
65
75
|
})
|
|
66
|
-
}),
|
|
76
|
+
}), g[s] = r.table[s], p = !0) : l.push(`[LocalFiles] 当前环境(env: ${n.env})没有默认的内置工具插件编码,请配置 builtinPlugins.localFiles.pluginCode。内置文件工具未注册。`)), o != null && o.enabled) {
|
|
77
|
+
const t = D(o, n.env, s);
|
|
78
|
+
if (!u)
|
|
79
|
+
l.push("[LocalPython] 运行脚本依赖已启用的本地工作区。内置脚本工具未注册。");
|
|
80
|
+
else if (!t)
|
|
81
|
+
l.push(`[LocalPython] 当前环境(env: ${n.env})没有默认的内置工具插件编码,请配置 builtinPlugins.localPython.pluginCode,或与文件工具使用同一个 pluginCode。内置脚本工具未注册。`);
|
|
82
|
+
else if (e[t])
|
|
83
|
+
l.push(`[LocalPython] pluginCode「${t}」已被业务插件占用,已保留业务插件,内置脚本工具未注册。`);
|
|
84
|
+
else if (g[t] && !(p && t === s))
|
|
85
|
+
l.push(`[LocalPython] pluginCode「${t}」已被占用,已保留原插件,内置脚本工具未注册。`);
|
|
86
|
+
else {
|
|
87
|
+
((d == null ? void 0 : d.workspace) !== u || d.pluginCode !== t || d.approve !== o.onApprovalRequired) && (d = {
|
|
88
|
+
workspace: u,
|
|
89
|
+
pluginCode: t,
|
|
90
|
+
approve: o.onApprovalRequired,
|
|
91
|
+
table: $({
|
|
92
|
+
pluginCode: t,
|
|
93
|
+
workspace: u,
|
|
94
|
+
onApprovalRequired: o.onApprovalRequired
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
const L = d.table[t];
|
|
98
|
+
g[t] = p && t === s ? c(c({}, g[t]), L) : L;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return n.plugins = g, l;
|
|
67
102
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
103
|
+
function B() {
|
|
104
|
+
return H().filter((e) => !v.has(e)).map((e) => (v.add(e), console.error(e), new Error(e)));
|
|
70
105
|
}
|
|
71
|
-
function
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
-
apiRoot: (e == null ? void 0 : e.apiRoot) || n.apiRoot || (e != null && e.env ?
|
|
106
|
+
function J(e) {
|
|
107
|
+
var i, o, l;
|
|
108
|
+
f.debug = (e == null ? void 0 : e.debug) || !1, n = R(c(c({}, n), e), {
|
|
109
|
+
apiRoot: (e == null ? void 0 : e.apiRoot) || n.apiRoot || (e != null && e.env ? _[e.env || "prod"] : n.apiRoot),
|
|
75
110
|
// 应用未注册插件时 param.plugins 为 undefined,避免覆盖默认空表
|
|
76
|
-
businessPlugins: (
|
|
77
|
-
builtinPlugins: (
|
|
78
|
-
}),
|
|
111
|
+
businessPlugins: (o = (i = e == null ? void 0 : e.plugins) != null ? i : n.businessPlugins) != null ? o : {},
|
|
112
|
+
builtinPlugins: (l = e == null ? void 0 : e.builtinPlugins) != null ? l : n.builtinPlugins
|
|
113
|
+
}), B(), f.debug && q.log("updated", n);
|
|
79
114
|
}
|
|
80
115
|
export {
|
|
81
|
-
|
|
116
|
+
_ as ApiUrl,
|
|
82
117
|
n as configuration,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
118
|
+
J as configure,
|
|
119
|
+
j as getRegisteredLocalFilesPluginCode,
|
|
120
|
+
z as getRegisteredLocalPythonPluginCode,
|
|
121
|
+
B as refreshBuiltinPlugins,
|
|
86
122
|
S as resolveLocalFilesPluginCode,
|
|
87
|
-
D as
|
|
123
|
+
D as resolveLocalPythonPluginCode,
|
|
124
|
+
T as setActiveLocalWorkspace
|
|
88
125
|
};
|