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