@glodon-aiot/bot-client-sdk 3.26.0-alpha.33 → 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 +230 -214
- package/dist/es/BotClient.mjs +127 -85
- 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/register.mjs +3 -3
- package/dist/es/package.json.mjs +28 -50
- package/dist/lib/index.js +44 -44
- package/dist/src/AgentSession.d.ts +1 -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/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 L = Object.prototype.hasOwnProperty,
|
|
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
|
-
L.call(i, e) && m(
|
|
8
|
-
if (
|
|
9
|
-
for (var e of
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
},
|
|
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,90 +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 { connectLocalMcpBridge as
|
|
38
|
-
import { LocalWorkspace as
|
|
39
|
-
import { createIndexedDbStore as
|
|
40
|
-
import { createDefaultSessionFileTransfer as
|
|
41
|
-
import { ApplicationTypes as
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
const
|
|
47
|
-
class
|
|
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 {
|
|
48
48
|
constructor(i, e, t = !0, o = {
|
|
49
49
|
analytics: {
|
|
50
50
|
enabled: !1
|
|
51
51
|
}
|
|
52
52
|
}) {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
h(this, "event", new $());
|
|
54
|
+
h(this, "cvforceApi");
|
|
55
55
|
//从token解析出来的用户信息
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
h(this, "_applicationId");
|
|
57
|
+
h(this, "_application", null);
|
|
58
58
|
//session列表,被加载过的session将会被缓存到这个列表中
|
|
59
|
-
|
|
59
|
+
h(this, "_sessions", []);
|
|
60
60
|
//活跃的session,只支持一个活跃的session
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
h(this, "_activeSession");
|
|
62
|
+
h(this, "_ready", !1);
|
|
63
63
|
//问题长度
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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, {
|
|
69
71
|
refreshBuiltinPlugins: !1
|
|
70
|
-
}), this._applicationId =
|
|
72
|
+
}), this._applicationId = S(i).rid || f.applicationId, !this._applicationId)
|
|
71
73
|
throw "token is not vaild";
|
|
72
|
-
this.cvforceApi = this.getService(),
|
|
73
|
-
|
|
74
|
-
stream: e.stream === void 0 ? (n == null ? void 0 : n.type) ===
|
|
75
|
-
})), 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
|
|
76
87
|
});
|
|
77
88
|
}
|
|
78
89
|
setupLocalWorkspace() {
|
|
79
|
-
var o, n;
|
|
90
|
+
var o, n, r;
|
|
80
91
|
const i = (o = f.builtinPlugins) == null ? void 0 : o.localFiles;
|
|
81
92
|
if (!(i != null && i.enabled)) {
|
|
82
|
-
|
|
93
|
+
d.log("workspace:disabled"), A(void 0), I();
|
|
83
94
|
return;
|
|
84
95
|
}
|
|
85
|
-
|
|
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";
|
|
86
100
|
if (t !== "file-system-access" && t !== "host-bridge")
|
|
87
101
|
e.push(new Error(`[LocalFiles] 不支持的 backend:${i.backend}`));
|
|
88
102
|
else {
|
|
89
|
-
const
|
|
90
|
-
this._localWorkspace = new
|
|
103
|
+
const s = M(f.apiRoot, this.token, (a, c) => d.error(c));
|
|
104
|
+
this._localWorkspace = new F({
|
|
91
105
|
applicationId: this._applicationId,
|
|
92
106
|
config: i,
|
|
93
|
-
store:
|
|
107
|
+
store: j(),
|
|
94
108
|
picker: t === "host-bridge" ? null : void 0,
|
|
95
|
-
transfer:
|
|
96
|
-
}),
|
|
109
|
+
transfer: z(() => this.cvforceApi, () => s)
|
|
110
|
+
}), A(this._localWorkspace), this._localWorkspace.platformSkills = new T({
|
|
97
111
|
applicationId: () => this._applicationId,
|
|
98
112
|
getToken: () => this.token,
|
|
99
113
|
getSkills: () => {
|
|
100
|
-
var
|
|
101
|
-
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 : [];
|
|
102
116
|
},
|
|
103
117
|
apiRoot: () => f.apiRoot,
|
|
104
118
|
getSandbox: () => {
|
|
105
|
-
var
|
|
106
|
-
const
|
|
107
|
-
return
|
|
119
|
+
var c;
|
|
120
|
+
const a = (c = this._localWorkspace) == null ? void 0 : c.adapter;
|
|
121
|
+
return a instanceof O ? a.sandbox : void 0;
|
|
108
122
|
}
|
|
109
|
-
}), t === "host-bridge" ? this._disconnectHost =
|
|
123
|
+
}), t === "host-bridge" ? this._disconnectHost = H(this._localWorkspace) : this._localWorkspace.restore();
|
|
110
124
|
}
|
|
111
|
-
e.push(...
|
|
125
|
+
e.push(...I()), e.length && Promise.resolve().then(() => e.forEach((s) => this.event.emit("error", s)));
|
|
112
126
|
}
|
|
113
127
|
/** 启用 builtinPlugins.localFiles 后可用;UI 与纯 SDK 集成共用此实例。 */
|
|
114
128
|
get localWorkspace() {
|
|
@@ -149,32 +163,32 @@ class ri {
|
|
|
149
163
|
{
|
|
150
164
|
ui: (e = this.sdkConfigs.ui) == null ? void 0 : e.name,
|
|
151
165
|
uiVersion: (t = this.sdkConfigs.ui) == null ? void 0 : t.version,
|
|
152
|
-
sdkVersion:
|
|
166
|
+
sdkVersion: P.version
|
|
153
167
|
}
|
|
154
|
-
).then((s) => (typeof s.arrange[0].thinkingModeOpen != "boolean" && (s.arrange[0].thinkingModeOpen = !0), typeof s.arrange[0].thinkingTextOpen != "boolean" && (s.arrange[0].thinkingTextOpen = !0),
|
|
155
|
-
arrange: [
|
|
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), {
|
|
169
|
+
arrange: [u(_({}, s.arrange[0]), {
|
|
156
170
|
recommendQuestionOpen: f.loadRelatedQuesions && s.arrange[0].recommendQuestionOpen
|
|
157
171
|
})]
|
|
158
172
|
})));
|
|
159
173
|
const i = (r = (n = (o = this._application) == null ? void 0 : o.arrange) == null ? void 0 : n[0]) == null ? void 0 : r.llmModel;
|
|
160
174
|
return i && (this._questionContextMaxLength = yield this.cvforceApi.getBaseModel(i).then((s) => s.maxModelLength)), this._promptVariables = yield Promise.all([this.cvforceApi.getPrompts(this._applicationId, {
|
|
161
|
-
type:
|
|
175
|
+
type: b.User
|
|
162
176
|
}), this.cvforceApi.getPrompts(this._applicationId, {
|
|
163
|
-
type:
|
|
177
|
+
type: b.System
|
|
164
178
|
})]).then(([s, a]) => [...s, ...a]), this._ready = !0, this.event.emit("application:loaded"), this._application;
|
|
165
179
|
});
|
|
166
180
|
}
|
|
167
181
|
getService() {
|
|
168
|
-
return this.cvforceApi ? this.cvforceApi :
|
|
182
|
+
return this.cvforceApi ? this.cvforceApi : C(f.apiRoot, this.token, (i, e) => d.error(e));
|
|
169
183
|
}
|
|
170
184
|
get token() {
|
|
171
185
|
return this._token;
|
|
172
186
|
}
|
|
173
187
|
set token(i) {
|
|
174
188
|
this.checkReady(), this._token = i, this.ready = !1;
|
|
175
|
-
const e =
|
|
189
|
+
const e = S(i).rid;
|
|
176
190
|
this._applicationId !== e && (this._applicationId = e, this._application = null, this.loadApplication().then(() => {
|
|
177
|
-
this.event.emit("ready");
|
|
191
|
+
this.logReady(), this.event.emit("ready");
|
|
178
192
|
}), this.clean());
|
|
179
193
|
}
|
|
180
194
|
get applicationId() {
|
|
@@ -196,13 +210,13 @@ class ri {
|
|
|
196
210
|
return p(this, null, function* () {
|
|
197
211
|
const r = this;
|
|
198
212
|
return new Promise((s, a) => {
|
|
199
|
-
const c = (
|
|
200
|
-
if (
|
|
201
|
-
s(new
|
|
202
|
-
else if (
|
|
203
|
-
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));
|
|
204
218
|
else
|
|
205
|
-
throw Error(`不支持的应用类型:${
|
|
219
|
+
throw Error(`不支持的应用类型:${g}`);
|
|
206
220
|
});
|
|
207
221
|
if (this.ready) {
|
|
208
222
|
if (!this._application)
|
|
@@ -248,7 +262,10 @@ class ri {
|
|
|
248
262
|
r.push(c);
|
|
249
263
|
}
|
|
250
264
|
}
|
|
251
|
-
if (
|
|
265
|
+
if (d.log("sessions", {
|
|
266
|
+
count: r.length,
|
|
267
|
+
paged: !!(i != null && i.pageSize)
|
|
268
|
+
}), i != null && i.pageSize) {
|
|
252
269
|
const s = [...this._sessions, ...r], a = /* @__PURE__ */ new Map();
|
|
253
270
|
for (const c of s)
|
|
254
271
|
a.set(c.id, c);
|
|
@@ -269,12 +286,37 @@ class ri {
|
|
|
269
286
|
});
|
|
270
287
|
});
|
|
271
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
|
+
}
|
|
272
311
|
loadSession(i = "", e) {
|
|
273
312
|
return p(this, null, function* () {
|
|
274
313
|
var o, n;
|
|
275
|
-
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();
|
|
276
315
|
let t = this.sessions.find((r) => r.id === i);
|
|
277
|
-
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) {
|
|
278
320
|
if (this._activeSession === t)
|
|
279
321
|
return t;
|
|
280
322
|
this._activeSession.inactivate();
|
|
@@ -294,7 +336,7 @@ class ri {
|
|
|
294
336
|
yield this.reload();
|
|
295
337
|
let e = this._sessions.find((t) => t.id === i) || this._activeSession;
|
|
296
338
|
if (!e) {
|
|
297
|
-
|
|
339
|
+
d.warn("reloadSession session failed.");
|
|
298
340
|
return;
|
|
299
341
|
}
|
|
300
342
|
return yield e.reload(), e;
|
|
@@ -304,7 +346,7 @@ class ri {
|
|
|
304
346
|
return p(this, null, function* () {
|
|
305
347
|
let o = i ? this._sessions.find((n) => n.id === i) : this._activeSession;
|
|
306
348
|
if (!o) {
|
|
307
|
-
|
|
349
|
+
d.warn("setTop session failed.");
|
|
308
350
|
return;
|
|
309
351
|
}
|
|
310
352
|
return yield o.setTop(e), this.getSessions({
|
|
@@ -332,7 +374,7 @@ class ri {
|
|
|
332
374
|
const o = this._sessions[t];
|
|
333
375
|
e && (yield o.delete()), this._sessions.splice(t, 1);
|
|
334
376
|
} else
|
|
335
|
-
|
|
377
|
+
d.warn("session delete failed, session is not exist.");
|
|
336
378
|
});
|
|
337
379
|
}
|
|
338
380
|
clean() {
|
|
@@ -341,5 +383,5 @@ class ri {
|
|
|
341
383
|
}
|
|
342
384
|
}
|
|
343
385
|
export {
|
|
344
|
-
|
|
386
|
+
li as default
|
|
345
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,
|