@glodon-aiot/bot-client-sdk 3.26.0-alpha.32 → 3.26.0-alpha.34
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 +234 -214
- package/dist/es/BotClient.mjs +125 -82
- package/dist/es/Config.mjs +42 -42
- package/dist/es/DialogSession.mjs +121 -116
- package/dist/es/EventBus.mjs +38 -34
- package/dist/es/Logger.mjs +19 -21
- package/dist/es/Session.mjs +306 -277
- package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +69 -69
- package/dist/es/builtinTools/platformSkills.mjs +85 -59
- package/dist/es/localFiles/createLocalFilesPlugin.mjs +53 -52
- package/dist/es/localFiles/host/connectHostBridge.mjs +20 -15
- package/dist/es/localFiles/workspace/LocalWorkspace.mjs +39 -34
- package/dist/es/localMcp/client.mjs +101 -90
- package/dist/es/localMcp/endpoints.mjs +94 -0
- package/dist/es/localMcp/register.mjs +149 -97
- package/dist/es/localMcp/registry.mjs +22 -18
- package/dist/es/package.json.mjs +28 -50
- package/dist/lib/index.js +45 -45
- package/dist/src/AgentSession.d.ts +2 -0
- package/dist/src/BotClient.d.ts +6 -1
- package/dist/src/Config.d.ts +2 -1
- package/dist/src/EventBus.d.ts +3 -0
- package/dist/src/Logger.d.ts +15 -8
- package/dist/src/Session.d.ts +4 -2
- package/dist/src/builtinTools/platformSkills.d.ts +22 -1
- package/dist/src/constant.d.ts +1 -1
- package/dist/src/localMcp/client.d.ts +4 -0
- package/dist/src/localMcp/endpoints.d.ts +19 -0
- package/dist/src/localMcp/register.d.ts +2 -0
- package/dist/src/localMcp/registry.d.ts +1 -0
- package/package.json +3 -25
package/dist/es/BotClient.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
var x = Object.defineProperty,
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var m = (
|
|
1
|
+
var x = Object.defineProperty, R = Object.defineProperties;
|
|
2
|
+
var E = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var y = Object.getOwnPropertySymbols;
|
|
4
|
+
var L = Object.prototype.hasOwnProperty, W = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var m = (l, i, e) => i in l ? x(l, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[i] = e, _ = (l, i) => {
|
|
6
6
|
for (var e in i || (i = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
}, u = (
|
|
13
|
-
var
|
|
14
|
-
var p = (
|
|
7
|
+
L.call(i, e) && m(l, e, i[e]);
|
|
8
|
+
if (y)
|
|
9
|
+
for (var e of y(i))
|
|
10
|
+
W.call(i, e) && m(l, e, i[e]);
|
|
11
|
+
return l;
|
|
12
|
+
}, u = (l, i) => R(l, E(i));
|
|
13
|
+
var h = (l, i, e) => (m(l, typeof i != "symbol" ? i + "" : i, e), e);
|
|
14
|
+
var p = (l, i, e) => new Promise((t, o) => {
|
|
15
15
|
var n = (a) => {
|
|
16
16
|
try {
|
|
17
17
|
s(e.next(a));
|
|
@@ -25,89 +25,104 @@ var p = (h, i, e) => new Promise((t, o) => {
|
|
|
25
25
|
o(c);
|
|
26
26
|
}
|
|
27
27
|
}, s = (a) => a.done ? t(a.value) : Promise.resolve(a.value).then(n, r);
|
|
28
|
-
s((e = e.apply(
|
|
28
|
+
s((e = e.apply(l, i)).next());
|
|
29
29
|
});
|
|
30
|
-
import { parseJWT as
|
|
31
|
-
import
|
|
32
|
-
import { getAIShopService as M, getCVForceService as
|
|
33
|
-
import { configure as
|
|
34
|
-
import { PlatformSkillSync as
|
|
35
|
-
import { HostBridgeAdapter as
|
|
36
|
-
import { connectHostBridge as
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
import { parseJWT as S } from "./utils.mjs";
|
|
31
|
+
import B from "./Logger.mjs";
|
|
32
|
+
import { getAIShopService as M, getCVForceService as C } from "./api/index.mjs";
|
|
33
|
+
import { configure as w, configuration as f, setActiveLocalWorkspace as A, refreshBuiltinPlugins as I } from "./Config.mjs";
|
|
34
|
+
import { PlatformSkillSync as T, pullArrangeSkills as V } from "./builtinTools/platformSkills.mjs";
|
|
35
|
+
import { HostBridgeAdapter as O } from "./localFiles/adapters/HostBridgeAdapter.mjs";
|
|
36
|
+
import { connectHostBridge as H } from "./localFiles/host/connectHostBridge.mjs";
|
|
37
|
+
import { connectLocalMcpBridge as D } from "./localMcp/endpoints.mjs";
|
|
38
|
+
import { LocalWorkspace as F } from "./localFiles/workspace/LocalWorkspace.mjs";
|
|
39
|
+
import { createIndexedDbStore as j } from "./localFiles/workspace/handleStore.mjs";
|
|
40
|
+
import { createDefaultSessionFileTransfer as z } from "./localFiles/transfer/SessionFileTransfer.mjs";
|
|
41
|
+
import { ApplicationTypes as k, PromptVariableType as b } from "@glodon-aiot/apis";
|
|
42
|
+
import Q from "./AgentSession.mjs";
|
|
43
|
+
import J from "./DialogSession.mjs";
|
|
44
|
+
import $ from "./EventBus.mjs";
|
|
45
|
+
import P from "./package.json.mjs";
|
|
46
|
+
const d = new B("[BotClient] ");
|
|
47
|
+
class li {
|
|
47
48
|
constructor(i, e, t = !0, o = {
|
|
48
49
|
analytics: {
|
|
49
50
|
enabled: !1
|
|
50
51
|
}
|
|
51
52
|
}) {
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
h(this, "event", new $());
|
|
54
|
+
h(this, "cvforceApi");
|
|
54
55
|
//从token解析出来的用户信息
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
h(this, "_applicationId");
|
|
57
|
+
h(this, "_application", null);
|
|
57
58
|
//session列表,被加载过的session将会被缓存到这个列表中
|
|
58
|
-
|
|
59
|
+
h(this, "_sessions", []);
|
|
59
60
|
//活跃的session,只支持一个活跃的session
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
h(this, "_activeSession");
|
|
62
|
+
h(this, "_ready", !1);
|
|
62
63
|
//问题长度
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
h(this, "_questionContextMaxLength", 4e3);
|
|
65
|
+
h(this, "_promptVariables", []);
|
|
66
|
+
h(this, "_localWorkspace");
|
|
67
|
+
h(this, "_disconnectHost");
|
|
68
|
+
/** 后进入的会话作废尚未返回的编排刷新。 */
|
|
69
|
+
h(this, "arrangeSkillEpoch", 0);
|
|
70
|
+
if (this._token = i, this.lazyload = t, this.sdkConfigs = o, w(e, {
|
|
68
71
|
refreshBuiltinPlugins: !1
|
|
69
|
-
}), this._applicationId =
|
|
72
|
+
}), this._applicationId = S(i).rid || f.applicationId, !this._applicationId)
|
|
70
73
|
throw "token is not vaild";
|
|
71
|
-
this.cvforceApi = this.getService(), this.setupLocalWorkspace(), this.loadApplication().then((n) => {
|
|
72
|
-
|
|
73
|
-
stream: e.stream === void 0 ? (n == null ? void 0 : n.type) ===
|
|
74
|
-
})), this.event.emit("ready");
|
|
74
|
+
this.cvforceApi = this.getService(), D(), this.setupLocalWorkspace(), this.loadApplication().then((n) => {
|
|
75
|
+
w(u(_({}, e), {
|
|
76
|
+
stream: e.stream === void 0 ? (n == null ? void 0 : n.type) === k.Dialog || (n == null ? void 0 : n.type) === k.Agent : e.stream
|
|
77
|
+
})), this.logReady(), this.event.emit("ready");
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
logReady() {
|
|
81
|
+
var i, e;
|
|
82
|
+
d.log("ready", {
|
|
83
|
+
applicationId: this._applicationId,
|
|
84
|
+
type: (i = this._application) == null ? void 0 : i.type,
|
|
85
|
+
stream: f.stream,
|
|
86
|
+
workspace: (e = this._localWorkspace) == null ? void 0 : e.status
|
|
75
87
|
});
|
|
76
88
|
}
|
|
77
89
|
setupLocalWorkspace() {
|
|
78
|
-
var o, n;
|
|
90
|
+
var o, n, r;
|
|
79
91
|
const i = (o = f.builtinPlugins) == null ? void 0 : o.localFiles;
|
|
80
92
|
if (!(i != null && i.enabled)) {
|
|
81
|
-
|
|
93
|
+
d.log("workspace:disabled"), A(void 0), I();
|
|
82
94
|
return;
|
|
83
95
|
}
|
|
84
|
-
|
|
96
|
+
d.log("workspace:setup", {
|
|
97
|
+
backend: (n = i.backend) != null ? n : "file-system-access"
|
|
98
|
+
});
|
|
99
|
+
const e = [], t = (r = i.backend) != null ? r : "file-system-access";
|
|
85
100
|
if (t !== "file-system-access" && t !== "host-bridge")
|
|
86
101
|
e.push(new Error(`[LocalFiles] 不支持的 backend:${i.backend}`));
|
|
87
102
|
else {
|
|
88
|
-
const
|
|
89
|
-
this._localWorkspace = new
|
|
103
|
+
const s = M(f.apiRoot, this.token, (a, c) => d.error(c));
|
|
104
|
+
this._localWorkspace = new F({
|
|
90
105
|
applicationId: this._applicationId,
|
|
91
106
|
config: i,
|
|
92
|
-
store:
|
|
107
|
+
store: j(),
|
|
93
108
|
picker: t === "host-bridge" ? null : void 0,
|
|
94
|
-
transfer:
|
|
95
|
-
}),
|
|
109
|
+
transfer: z(() => this.cvforceApi, () => s)
|
|
110
|
+
}), A(this._localWorkspace), this._localWorkspace.platformSkills = new T({
|
|
96
111
|
applicationId: () => this._applicationId,
|
|
97
112
|
getToken: () => this.token,
|
|
98
113
|
getSkills: () => {
|
|
99
|
-
var
|
|
100
|
-
return (
|
|
114
|
+
var a, c, g, v;
|
|
115
|
+
return (v = (g = (c = (a = this._application) == null ? void 0 : a.arrange) == null ? void 0 : c[0]) == null ? void 0 : g.skills) != null ? v : [];
|
|
101
116
|
},
|
|
102
117
|
apiRoot: () => f.apiRoot,
|
|
103
118
|
getSandbox: () => {
|
|
104
|
-
var
|
|
105
|
-
const
|
|
106
|
-
return
|
|
119
|
+
var c;
|
|
120
|
+
const a = (c = this._localWorkspace) == null ? void 0 : c.adapter;
|
|
121
|
+
return a instanceof O ? a.sandbox : void 0;
|
|
107
122
|
}
|
|
108
|
-
}), t === "host-bridge" ? this._disconnectHost =
|
|
123
|
+
}), t === "host-bridge" ? this._disconnectHost = H(this._localWorkspace) : this._localWorkspace.restore();
|
|
109
124
|
}
|
|
110
|
-
e.push(...
|
|
125
|
+
e.push(...I()), e.length && Promise.resolve().then(() => e.forEach((s) => this.event.emit("error", s)));
|
|
111
126
|
}
|
|
112
127
|
/** 启用 builtinPlugins.localFiles 后可用;UI 与纯 SDK 集成共用此实例。 */
|
|
113
128
|
get localWorkspace() {
|
|
@@ -148,7 +163,7 @@ class ni {
|
|
|
148
163
|
{
|
|
149
164
|
ui: (e = this.sdkConfigs.ui) == null ? void 0 : e.name,
|
|
150
165
|
uiVersion: (t = this.sdkConfigs.ui) == null ? void 0 : t.version,
|
|
151
|
-
sdkVersion:
|
|
166
|
+
sdkVersion: P.version
|
|
152
167
|
}
|
|
153
168
|
).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
169
|
arrange: [u(_({}, s.arrange[0]), {
|
|
@@ -157,23 +172,23 @@ class ni {
|
|
|
157
172
|
})));
|
|
158
173
|
const i = (r = (n = (o = this._application) == null ? void 0 : o.arrange) == null ? void 0 : n[0]) == null ? void 0 : r.llmModel;
|
|
159
174
|
return i && (this._questionContextMaxLength = yield this.cvforceApi.getBaseModel(i).then((s) => s.maxModelLength)), this._promptVariables = yield Promise.all([this.cvforceApi.getPrompts(this._applicationId, {
|
|
160
|
-
type:
|
|
175
|
+
type: b.User
|
|
161
176
|
}), this.cvforceApi.getPrompts(this._applicationId, {
|
|
162
|
-
type:
|
|
177
|
+
type: b.System
|
|
163
178
|
})]).then(([s, a]) => [...s, ...a]), this._ready = !0, this.event.emit("application:loaded"), this._application;
|
|
164
179
|
});
|
|
165
180
|
}
|
|
166
181
|
getService() {
|
|
167
|
-
return this.cvforceApi ? this.cvforceApi :
|
|
182
|
+
return this.cvforceApi ? this.cvforceApi : C(f.apiRoot, this.token, (i, e) => d.error(e));
|
|
168
183
|
}
|
|
169
184
|
get token() {
|
|
170
185
|
return this._token;
|
|
171
186
|
}
|
|
172
187
|
set token(i) {
|
|
173
188
|
this.checkReady(), this._token = i, this.ready = !1;
|
|
174
|
-
const e =
|
|
189
|
+
const e = S(i).rid;
|
|
175
190
|
this._applicationId !== e && (this._applicationId = e, this._application = null, this.loadApplication().then(() => {
|
|
176
|
-
this.event.emit("ready");
|
|
191
|
+
this.logReady(), this.event.emit("ready");
|
|
177
192
|
}), this.clean());
|
|
178
193
|
}
|
|
179
194
|
get applicationId() {
|
|
@@ -195,13 +210,13 @@ class ni {
|
|
|
195
210
|
return p(this, null, function* () {
|
|
196
211
|
const r = this;
|
|
197
212
|
return new Promise((s, a) => {
|
|
198
|
-
const c = (
|
|
199
|
-
if (
|
|
200
|
-
s(new
|
|
201
|
-
else if (
|
|
202
|
-
s(new
|
|
213
|
+
const c = (g) => p(this, null, function* () {
|
|
214
|
+
if (g === k.Agent)
|
|
215
|
+
s(new Q(i, e, t, o, n, r));
|
|
216
|
+
else if (g === k.Dialog)
|
|
217
|
+
s(new J(i, e, t, o, n, r));
|
|
203
218
|
else
|
|
204
|
-
throw Error(`不支持的应用类型:${
|
|
219
|
+
throw Error(`不支持的应用类型:${g}`);
|
|
205
220
|
});
|
|
206
221
|
if (this.ready) {
|
|
207
222
|
if (!this._application)
|
|
@@ -247,7 +262,10 @@ class ni {
|
|
|
247
262
|
r.push(c);
|
|
248
263
|
}
|
|
249
264
|
}
|
|
250
|
-
if (
|
|
265
|
+
if (d.log("sessions", {
|
|
266
|
+
count: r.length,
|
|
267
|
+
paged: !!(i != null && i.pageSize)
|
|
268
|
+
}), i != null && i.pageSize) {
|
|
251
269
|
const s = [...this._sessions, ...r], a = /* @__PURE__ */ new Map();
|
|
252
270
|
for (const c of s)
|
|
253
271
|
a.set(c.id, c);
|
|
@@ -268,12 +286,37 @@ class ni {
|
|
|
268
286
|
});
|
|
269
287
|
});
|
|
270
288
|
}
|
|
289
|
+
/** 只更新 arrange[0].skills。查询失败时保留内存中的名单,会话仍可进入。 */
|
|
290
|
+
refreshArrangeSkills() {
|
|
291
|
+
return p(this, null, function* () {
|
|
292
|
+
var t, o, n;
|
|
293
|
+
const i = (o = (t = this._application) == null ? void 0 : t.arrange) == null ? void 0 : o[0], e = ++this.arrangeSkillEpoch;
|
|
294
|
+
try {
|
|
295
|
+
yield V({
|
|
296
|
+
// 已发布的 IArrange 类型尚未带上 skills,与 getSkills 一样在这里收窄。
|
|
297
|
+
arrange: i,
|
|
298
|
+
fetchApplication: () => this.cvforceApi.getApplicationId(this._applicationId),
|
|
299
|
+
stillCurrent: () => {
|
|
300
|
+
var s, a;
|
|
301
|
+
return e === this.arrangeSkillEpoch && ((a = (s = this._application) == null ? void 0 : s.arrange) == null ? void 0 : a[0]) === i;
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
const r = (n = i == null ? void 0 : i.skills) != null ? n : [];
|
|
305
|
+
d.log("arrange:skills", r.map((s) => s.name).filter(Boolean));
|
|
306
|
+
} catch (r) {
|
|
307
|
+
d.error("刷新编排技能失败", r);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
}
|
|
271
311
|
loadSession(i = "", e) {
|
|
272
312
|
return p(this, null, function* () {
|
|
273
313
|
var o, n;
|
|
274
|
-
this.checkReady(), (n = (o = this._localWorkspace) == null ? void 0 : o.platformSkills) == null || n.sync();
|
|
314
|
+
this.checkReady(), yield this.refreshArrangeSkills(), (n = (o = this._localWorkspace) == null ? void 0 : o.platformSkills) == null || n.sync();
|
|
275
315
|
let t = this.sessions.find((r) => r.id === i);
|
|
276
|
-
if (
|
|
316
|
+
if (d.log("loadSession", {
|
|
317
|
+
sessionId: i || "(new)",
|
|
318
|
+
existing: !!t
|
|
319
|
+
}), t || (t = yield this.createSession(this.token, i, e), this._sessions.push(t)), this._activeSession) {
|
|
277
320
|
if (this._activeSession === t)
|
|
278
321
|
return t;
|
|
279
322
|
this._activeSession.inactivate();
|
|
@@ -293,7 +336,7 @@ class ni {
|
|
|
293
336
|
yield this.reload();
|
|
294
337
|
let e = this._sessions.find((t) => t.id === i) || this._activeSession;
|
|
295
338
|
if (!e) {
|
|
296
|
-
|
|
339
|
+
d.warn("reloadSession session failed.");
|
|
297
340
|
return;
|
|
298
341
|
}
|
|
299
342
|
return yield e.reload(), e;
|
|
@@ -303,7 +346,7 @@ class ni {
|
|
|
303
346
|
return p(this, null, function* () {
|
|
304
347
|
let o = i ? this._sessions.find((n) => n.id === i) : this._activeSession;
|
|
305
348
|
if (!o) {
|
|
306
|
-
|
|
349
|
+
d.warn("setTop session failed.");
|
|
307
350
|
return;
|
|
308
351
|
}
|
|
309
352
|
return yield o.setTop(e), this.getSessions({
|
|
@@ -331,7 +374,7 @@ class ni {
|
|
|
331
374
|
const o = this._sessions[t];
|
|
332
375
|
e && (yield o.delete()), this._sessions.splice(t, 1);
|
|
333
376
|
} else
|
|
334
|
-
|
|
377
|
+
d.warn("session delete failed, session is not exist.");
|
|
335
378
|
});
|
|
336
379
|
}
|
|
337
380
|
clean() {
|
|
@@ -340,5 +383,5 @@ class ni {
|
|
|
340
383
|
}
|
|
341
384
|
}
|
|
342
385
|
export {
|
|
343
|
-
|
|
386
|
+
li as default
|
|
344
387
|
};
|
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 B = Object.defineProperty, R = Object.defineProperties;
|
|
2
|
+
var w = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var v = Object.getOwnPropertySymbols;
|
|
4
|
+
var k = Object.prototype.hasOwnProperty, E = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var b = (e, i, o) => i in e ? B(e, i, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[i] = o, c = (e, i) => {
|
|
6
|
+
for (var o in i || (i = {}))
|
|
7
|
+
k.call(i, o) && b(e, o, i[o]);
|
|
8
|
+
if (v)
|
|
9
|
+
for (var o of v(i))
|
|
10
|
+
E.call(i, o) && b(e, o, i[o]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
13
|
-
import
|
|
14
|
-
import { LOCAL_FILES_PLUGIN_CODES as
|
|
15
|
-
import { createBuiltinToolsPlugin as
|
|
16
|
-
import { applyLocalMcpPlugins as
|
|
17
|
-
const
|
|
18
|
-
var
|
|
12
|
+
}, P = (e, i) => R(e, w(i));
|
|
13
|
+
import h from "./Logger.mjs";
|
|
14
|
+
import { LOCAL_FILES_PLUGIN_CODES as I } from "./localFiles/constants.mjs";
|
|
15
|
+
import { createBuiltinToolsPlugin as S } from "./builtinTools/createBuiltinToolsPlugin.mjs";
|
|
16
|
+
import { applyLocalMcpPlugins as T } from "./localMcp/registry.mjs";
|
|
17
|
+
const C = new h("[Config] ");
|
|
18
|
+
var L = /* @__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))(L || {});
|
|
19
19
|
let n = {
|
|
20
20
|
debug: !1,
|
|
21
21
|
env: "prod",
|
|
@@ -32,57 +32,57 @@ let n = {
|
|
|
32
32
|
loadRelatedQuesions: !0,
|
|
33
33
|
stream: !1
|
|
34
34
|
}, u, l;
|
|
35
|
-
const
|
|
35
|
+
const r = /* @__PURE__ */ new Set();
|
|
36
36
|
function G(e) {
|
|
37
|
-
u !== e && (u = e, l = void 0,
|
|
37
|
+
u !== e && (u = e, l = void 0, r.clear());
|
|
38
38
|
}
|
|
39
39
|
function M() {
|
|
40
40
|
if (!l)
|
|
41
41
|
return;
|
|
42
42
|
const {
|
|
43
43
|
pluginCode: e,
|
|
44
|
-
table:
|
|
45
|
-
} = l,
|
|
46
|
-
if (!(!
|
|
44
|
+
table: i
|
|
45
|
+
} = l, o = n.plugins[e], t = i[e];
|
|
46
|
+
if (!(!o || o.shell !== t.shell))
|
|
47
47
|
return e;
|
|
48
48
|
}
|
|
49
|
-
function _(e,
|
|
50
|
-
return (e == null ? void 0 : e.pluginCode) ||
|
|
49
|
+
function _(e, i) {
|
|
50
|
+
return (e == null ? void 0 : e.pluginCode) || I[i];
|
|
51
51
|
}
|
|
52
52
|
function O() {
|
|
53
|
-
var
|
|
54
|
-
const e = (
|
|
55
|
-
if (!!!(
|
|
56
|
-
return g(t),
|
|
53
|
+
var f, p;
|
|
54
|
+
const e = (f = n.businessPlugins) != null ? f : {}, i = (p = n.builtinPlugins) == null ? void 0 : p.localFiles, o = [], t = c({}, e);
|
|
55
|
+
if (!!!(i != null && i.enabled))
|
|
56
|
+
return g(t), o;
|
|
57
57
|
if (!u)
|
|
58
|
-
return
|
|
59
|
-
const s =
|
|
60
|
-
return s ? e[s] ?
|
|
58
|
+
return o.push("[BuiltinTools] 内置工具依赖已启用的本地工作区。工具未注册。"), g(t), o;
|
|
59
|
+
const s = i != null && i.enabled ? _(i, n.env) : void 0;
|
|
60
|
+
return s ? e[s] ? o.push(`[BuiltinTools] 业务插件中已存在 pluginCode「${s}」,已保留业务插件,内置工具未注册。`) : (((l == null ? void 0 : l.workspace) !== u || l.pluginCode !== s) && (l = {
|
|
61
61
|
workspace: u,
|
|
62
62
|
pluginCode: s,
|
|
63
|
-
table:
|
|
63
|
+
table: S({
|
|
64
64
|
pluginCode: s,
|
|
65
65
|
workspace: u
|
|
66
66
|
})
|
|
67
|
-
}), t[s] = l.table[s]) :
|
|
67
|
+
}), t[s] = l.table[s]) : o.push(`[BuiltinTools] 当前环境(env: ${n.env})没有默认的内置工具插件编码,请配置 builtinPlugins.localFiles.pluginCode。内置工具未注册。`), g(t), o;
|
|
68
68
|
}
|
|
69
69
|
function g(e) {
|
|
70
|
-
|
|
70
|
+
T(e), n.plugins = e;
|
|
71
71
|
}
|
|
72
72
|
function W() {
|
|
73
|
-
return O().filter((e) => !
|
|
73
|
+
return O().filter((e) => !r.has(e)).map((e) => (r.add(e), C.report(e), new Error(e)));
|
|
74
74
|
}
|
|
75
|
-
function N(e,
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
apiRoot: (e == null ? void 0 : e.apiRoot) || n.apiRoot || (e != null && e.env ?
|
|
75
|
+
function N(e, i = {}) {
|
|
76
|
+
var o, t, d;
|
|
77
|
+
h.debug = (e == null ? void 0 : e.debug) || !1, n = P(c(c({}, n), e), {
|
|
78
|
+
apiRoot: (e == null ? void 0 : e.apiRoot) || n.apiRoot || (e != null && e.env ? L[e.env || "prod"] : n.apiRoot),
|
|
79
79
|
// 应用未注册插件时 param.plugins 为 undefined,避免覆盖默认空表
|
|
80
|
-
businessPlugins: (t = (
|
|
80
|
+
businessPlugins: (t = (o = e == null ? void 0 : e.plugins) != null ? o : n.businessPlugins) != null ? t : {},
|
|
81
81
|
builtinPlugins: (d = e == null ? void 0 : e.builtinPlugins) != null ? d : n.builtinPlugins
|
|
82
|
-
}),
|
|
82
|
+
}), i.refreshBuiltinPlugins !== !1 && W(), C.log("updated", n);
|
|
83
83
|
}
|
|
84
84
|
export {
|
|
85
|
-
|
|
85
|
+
L as ApiUrl,
|
|
86
86
|
n as configuration,
|
|
87
87
|
N as configure,
|
|
88
88
|
M as getRegisteredLocalFilesPluginCode,
|