@glodon-aiot/bot-client-sdk 3.26.0-alpha.9 → 3.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +271 -225
- package/dist/es/AgentSession.mjs +301 -228
- package/dist/es/BotClient.mjs +200 -123
- package/dist/es/Config.mjs +56 -67
- package/dist/es/DialogSession.mjs +123 -118
- package/dist/es/EventBus.mjs +38 -34
- package/dist/es/Logger.mjs +19 -21
- package/dist/es/PayloadTypes.mjs +13 -2
- package/dist/es/Session.mjs +405 -312
- package/dist/es/api/index.mjs +31 -30
- package/dist/es/builtinTools/constants.mjs +12 -5
- package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +182 -160
- package/dist/es/builtinTools/paths.mjs +34 -27
- package/dist/es/builtinTools/platformSkills.mjs +248 -0
- package/dist/es/builtinTools/schemas.mjs +63 -18
- package/dist/es/builtinTools/tools.mjs +368 -244
- package/dist/es/index.mjs +73 -67
- package/dist/es/localFiles/adapters/FileSnapshotAdapter.mjs +160 -0
- package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +113 -131
- package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +60 -55
- package/dist/es/localFiles/constants.mjs +24 -28
- package/dist/es/localFiles/createLocalFilesPlugin.mjs +53 -52
- package/dist/es/localFiles/errors.mjs +44 -35
- package/dist/es/localFiles/host/connectHostBridge.mjs +20 -15
- package/dist/es/localFiles/host/protocol.mjs +27 -14
- package/dist/es/localFiles/host/sandboxClient.mjs +297 -127
- package/dist/es/localFiles/preview.mjs +33 -0
- package/dist/es/localFiles/schemas.mjs +22 -53
- package/dist/es/localFiles/workspace/LocalWorkspace.mjs +156 -89
- package/dist/es/localFiles/workspace/WorkspaceFiles.mjs +246 -0
- package/dist/es/localMcp/client.mjs +234 -0
- package/dist/es/localMcp/endpoints.mjs +94 -0
- package/dist/es/localMcp/register.mjs +207 -0
- package/dist/es/localMcp/registry.mjs +43 -0
- package/dist/es/package.json.mjs +34 -54
- package/dist/es/sessionUpload.mjs +49 -0
- package/dist/es/utils.mjs +24 -11
- package/dist/lib/index.js +48 -40
- package/dist/src/AgentSession.d.ts +13 -0
- package/dist/src/BotClient.d.ts +13 -1
- package/dist/src/Config.d.ts +6 -7
- package/dist/src/EventBus.d.ts +3 -0
- package/dist/src/Logger.d.ts +15 -8
- package/dist/src/PayloadTypes.d.ts +20 -0
- package/dist/src/Session.d.ts +24 -3
- package/dist/src/api/index.d.ts +2 -2
- package/dist/src/builtinTools/command.d.ts +7 -0
- package/dist/src/builtinTools/constants.d.ts +10 -2
- package/dist/src/builtinTools/paths.d.ts +3 -2
- package/dist/src/builtinTools/platformSkills.d.ts +92 -0
- package/dist/src/builtinTools/tools.d.ts +13 -0
- package/dist/src/constant.d.ts +1 -1
- package/dist/src/index.d.ts +6 -3
- package/dist/src/localFiles/adapters/FileSnapshotAdapter.d.ts +24 -0
- package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +7 -4
- package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +8 -0
- package/dist/src/localFiles/constants.d.ts +4 -13
- package/dist/src/localFiles/errors.d.ts +1 -1
- package/dist/src/localFiles/host/protocol.d.ts +14 -3
- package/dist/src/localFiles/host/sandboxClient.d.ts +50 -0
- package/dist/src/localFiles/index.d.ts +9 -5
- package/dist/src/localFiles/preview.d.ts +2 -0
- package/dist/src/localFiles/schemas.d.ts +0 -2
- package/dist/src/localFiles/types.d.ts +2 -22
- package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +25 -3
- package/dist/src/localFiles/workspace/WorkspaceFiles.d.ts +63 -0
- package/dist/src/localMcp/client.d.ts +15 -0
- package/dist/src/localMcp/endpoints.d.ts +19 -0
- package/dist/src/localMcp/register.d.ts +34 -0
- package/dist/src/localMcp/registry.d.ts +27 -0
- package/dist/src/sessionUpload.d.ts +14 -0
- package/dist/src/utils.d.ts +6 -0
- package/package.json +4 -24
|
@@ -9,7 +9,7 @@ var E = (e, t, r) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writab
|
|
|
9
9
|
for (var r of G(t))
|
|
10
10
|
Q.call(t, r) && E(e, r, t[r]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
12
|
+
}, h = (e, t) => B(e, K(t));
|
|
13
13
|
var _ = (e, t, r) => (E(e, typeof t != "symbol" ? t + "" : t, r), r);
|
|
14
14
|
var F = (e, t, r) => new Promise((d, s) => {
|
|
15
15
|
var o = (a) => {
|
|
@@ -28,26 +28,27 @@ var F = (e, t, r) => new Promise((d, s) => {
|
|
|
28
28
|
i((r = r.apply(e, t)).next());
|
|
29
29
|
});
|
|
30
30
|
import { v4 as U } from "uuid";
|
|
31
|
-
import
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
import V from "../Logger.mjs";
|
|
32
|
+
import { LOCAL_FILES_FUNCTION_CODES as X, TRANSFER_FUNCTION_CODES as Y, SEARCH_FUNCTION_CODES as Z, WORKSPACE_GRANT_ID as $ } from "./constants.mjs";
|
|
33
|
+
import { cancelledError as g, workspaceNotGranted as k, ToolError as f, ToolCode as m, toToolError as ee } from "./errors.mjs";
|
|
34
|
+
import { LOCAL_FILE_TOOL_SCHEMAS as te } from "./schemas.mjs";
|
|
35
|
+
import { assertGrantId as re } from "./security/pathPolicy.mjs";
|
|
36
|
+
import { listDirectory as ie, readFile as ae, statFile as oe, searchFiles as ne, searchText as se } from "./tools/readTools.mjs";
|
|
37
|
+
import { uploadFile as le, downloadFile as de } from "./tools/transferTools.mjs";
|
|
38
|
+
import { applyPatch as ce, writeFile as ue } from "./tools/writeTools.mjs";
|
|
39
|
+
import { validateToolInput as me } from "./validate.mjs";
|
|
40
|
+
const fe = new V("[LocalFiles] "), he = {
|
|
41
|
+
list_directory: ie,
|
|
42
|
+
read_file: ae,
|
|
43
|
+
stat_file: oe,
|
|
44
|
+
search_files: ne,
|
|
45
|
+
search_text: se,
|
|
46
|
+
apply_patch: ce,
|
|
47
|
+
write_file: ue,
|
|
48
|
+
upload_file: le,
|
|
49
|
+
download_file: de
|
|
49
50
|
};
|
|
50
|
-
class
|
|
51
|
+
class ge {
|
|
51
52
|
constructor(t, r) {
|
|
52
53
|
_(this, "remaining");
|
|
53
54
|
_(this, "startedAt", 0);
|
|
@@ -66,23 +67,23 @@ class he {
|
|
|
66
67
|
this.pause(), this.remaining = 0;
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
70
|
+
function pe(e, t) {
|
|
71
|
+
return Y.includes(t) ? e.limits.transferTimeoutMs : Z.includes(t) ? e.limits.searchTimeoutMs : e.limits.toolTimeoutMs;
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
+
function ve(e) {
|
|
73
74
|
if (typeof e != "string")
|
|
74
75
|
return e;
|
|
75
76
|
try {
|
|
76
77
|
return JSON.parse(e);
|
|
77
78
|
} catch (t) {
|
|
78
|
-
throw new
|
|
79
|
+
throw new f(m.BadRequest, "参数不是合法的 JSON 对象。");
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
|
-
function
|
|
82
|
+
function Ie(e) {
|
|
82
83
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
83
84
|
return;
|
|
84
85
|
const t = e;
|
|
85
|
-
return (t.grantId === void 0 || t.grantId === null || t.grantId === "") && (t.grantId =
|
|
86
|
+
return (t.grantId === void 0 || t.grantId === null || t.grantId === "") && (t.grantId = $), t.grantId;
|
|
86
87
|
}
|
|
87
88
|
function W(e) {
|
|
88
89
|
return new Promise((t, r) => {
|
|
@@ -91,7 +92,7 @@ function W(e) {
|
|
|
91
92
|
});
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
|
-
function
|
|
95
|
+
function be(e) {
|
|
95
96
|
return u({
|
|
96
97
|
code: e.code,
|
|
97
98
|
message: e.message
|
|
@@ -99,7 +100,7 @@ function ve(e) {
|
|
|
99
100
|
data: e.data
|
|
100
101
|
} : {});
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
+
function Te(e, t, r, d, s) {
|
|
103
104
|
return F(this, null, function* () {
|
|
104
105
|
var N, S, q, P, C, D, R, x;
|
|
105
106
|
const o = {
|
|
@@ -115,7 +116,7 @@ function Ie(e, t, r, d, s) {
|
|
|
115
116
|
functionCode: t
|
|
116
117
|
}, i = new AbortController();
|
|
117
118
|
let a = !1;
|
|
118
|
-
const c = new
|
|
119
|
+
const c = new ge(pe(e, t), () => {
|
|
119
120
|
a = !0, i.abort();
|
|
120
121
|
}), v = () => i.abort();
|
|
121
122
|
(N = o.signal) == null || N.addEventListener("abort", v, {
|
|
@@ -123,16 +124,16 @@ function Ie(e, t, r, d, s) {
|
|
|
123
124
|
}), (S = o.signal) != null && S.aborted && i.abort();
|
|
124
125
|
let p = null, I, L = !1;
|
|
125
126
|
try {
|
|
126
|
-
const b =
|
|
127
|
-
l != null &&
|
|
128
|
-
const w =
|
|
127
|
+
const b = ve(r), l = Ie(b);
|
|
128
|
+
l != null && re(l);
|
|
129
|
+
const w = me(b, te[t].parameters), M = (q = w.path) != null ? q : w.destPath;
|
|
129
130
|
if (typeof M == "string" && (n.path = M), yield e.ready, i.signal.aborted)
|
|
130
131
|
throw g();
|
|
131
132
|
const y = e.adapter;
|
|
132
133
|
if (!y)
|
|
133
|
-
throw
|
|
134
|
+
throw k();
|
|
134
135
|
if (p = e.acquireSlot(), !p)
|
|
135
|
-
throw new
|
|
136
|
+
throw new f(m.TooManyRequests, "同时进行的文件操作过多,请稍后重试。");
|
|
136
137
|
I = e.track(i), L = !0, e.emit("tool:start", u({}, n)), c.resume();
|
|
137
138
|
const H = {
|
|
138
139
|
adapter: y,
|
|
@@ -143,11 +144,11 @@ function Ie(e, t, r, d, s) {
|
|
|
143
144
|
allowWorkspaceWideTextSearch: e.allowWorkspaceWideTextSearch,
|
|
144
145
|
transfer: e.transfer,
|
|
145
146
|
fetch: e.fetch,
|
|
146
|
-
context:
|
|
147
|
+
context: h(u({}, o), {
|
|
147
148
|
signal: i.signal
|
|
148
149
|
}),
|
|
149
150
|
signal: i.signal,
|
|
150
|
-
requestApproval: (O, j) =>
|
|
151
|
+
requestApproval: (O, j) => _e(e, {
|
|
151
152
|
approvalPath: O,
|
|
152
153
|
preview: j,
|
|
153
154
|
context: o,
|
|
@@ -157,32 +158,32 @@ function Ie(e, t, r, d, s) {
|
|
|
157
158
|
base: n
|
|
158
159
|
}),
|
|
159
160
|
progress: (O) => e.emit("tool:progress", u(u({}, n), O))
|
|
160
|
-
}, T = yield Promise.race([
|
|
161
|
+
}, T = yield Promise.race([he[t](w, H), W(i.signal)]), A = {
|
|
161
162
|
code: m.Ok,
|
|
162
163
|
message: "ok",
|
|
163
164
|
data: T.data
|
|
164
165
|
};
|
|
165
|
-
T.truncated && (A.truncated = !0), (C = T.warnings) != null && C.length && (A.warnings = T.warnings), e.emit("tool:finish",
|
|
166
|
+
T.truncated && (A.truncated = !0), (C = T.warnings) != null && C.length && (A.warnings = T.warnings), e.emit("tool:finish", h(u({}, n), {
|
|
166
167
|
code: m.Ok
|
|
167
168
|
})), d(A);
|
|
168
169
|
} catch (b) {
|
|
169
|
-
let l =
|
|
170
|
-
a ? l = new
|
|
170
|
+
let l = ee(b);
|
|
171
|
+
a ? l = new f(m.Timeout, "操作超时,已中止。") : i.signal.aborted && l.code !== m.Cancelled && (l = g()), ((D = l.data) == null ? void 0 : D.reason) === "workspace_not_granted" && L && e.handlePermissionLost(), l.code === m.Cancelled ? e.emit("tool:cancelled", u({}, n)) : e.emit("tool:error", h(u({}, n), {
|
|
171
172
|
code: l.code,
|
|
172
173
|
message: l.message,
|
|
173
174
|
reason: (R = l.data) == null ? void 0 : R.reason
|
|
174
|
-
})), d(
|
|
175
|
+
})), d(be(l));
|
|
175
176
|
} finally {
|
|
176
177
|
c.clear(), (x = o.signal) == null || x.removeEventListener("abort", v), p == null || p(), I == null || I();
|
|
177
178
|
}
|
|
178
179
|
});
|
|
179
180
|
}
|
|
180
|
-
function
|
|
181
|
+
function _e(e, t) {
|
|
181
182
|
return F(this, null, function* () {
|
|
182
183
|
var i;
|
|
183
184
|
const r = e.getApprovalHandler();
|
|
184
185
|
if (!r)
|
|
185
|
-
throw new
|
|
186
|
+
throw new f(m.Forbidden, "当前环境未提供操作确认能力,无法执行写入或传输操作。", {
|
|
186
187
|
reason: "approval_unavailable"
|
|
187
188
|
});
|
|
188
189
|
if (t.signal.aborted)
|
|
@@ -201,7 +202,7 @@ function be(e, t) {
|
|
|
201
202
|
preview: t.preview,
|
|
202
203
|
signal: d.signal
|
|
203
204
|
};
|
|
204
|
-
t.timer.pause(), e.emit("tool:approval-required",
|
|
205
|
+
t.timer.pause(), e.emit("tool:approval-required", h(u({}, t.base), {
|
|
205
206
|
path: t.approvalPath,
|
|
206
207
|
approvalId: o.id
|
|
207
208
|
}));
|
|
@@ -213,11 +214,11 @@ function be(e, t) {
|
|
|
213
214
|
if (t.signal.aborted)
|
|
214
215
|
throw g();
|
|
215
216
|
if (a !== !0)
|
|
216
|
-
throw new
|
|
217
|
+
throw new f(m.Forbidden, "用户拒绝了本次操作。", {
|
|
217
218
|
reason: "user_rejected"
|
|
218
219
|
});
|
|
219
220
|
} catch (a) {
|
|
220
|
-
throw a instanceof
|
|
221
|
+
throw a instanceof f ? a : new f(m.Forbidden, "操作确认失败,已取消本次操作。", {
|
|
221
222
|
reason: "user_rejected"
|
|
222
223
|
});
|
|
223
224
|
} finally {
|
|
@@ -225,24 +226,24 @@ function be(e, t) {
|
|
|
225
226
|
}
|
|
226
227
|
});
|
|
227
228
|
}
|
|
228
|
-
function
|
|
229
|
+
function Ce({
|
|
229
230
|
pluginCode: e,
|
|
230
231
|
workspace: t
|
|
231
232
|
}) {
|
|
232
233
|
const r = {};
|
|
233
|
-
return
|
|
234
|
+
return X.forEach((d) => {
|
|
234
235
|
r[d] = (s, o, n) => {
|
|
235
236
|
let i = !1;
|
|
236
|
-
|
|
237
|
+
Te(t, d, s, (c) => {
|
|
237
238
|
if (!i) {
|
|
238
239
|
i = !0;
|
|
239
240
|
try {
|
|
240
241
|
o(c);
|
|
241
242
|
} catch (v) {
|
|
242
|
-
|
|
243
|
+
fe.report("callback failed", v);
|
|
243
244
|
}
|
|
244
245
|
}
|
|
245
|
-
},
|
|
246
|
+
}, h(u({}, n), {
|
|
246
247
|
pluginCode: e
|
|
247
248
|
}));
|
|
248
249
|
};
|
|
@@ -251,5 +252,5 @@ function Se({
|
|
|
251
252
|
};
|
|
252
253
|
}
|
|
253
254
|
export {
|
|
254
|
-
|
|
255
|
+
Ce as createLocalFilesPlugin
|
|
255
256
|
};
|
|
@@ -1,57 +1,66 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
class
|
|
6
|
-
constructor(
|
|
7
|
-
super(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.name = "ToolError", this.code =
|
|
1
|
+
var E = Object.defineProperty;
|
|
2
|
+
var f = (t, e, n) => e in t ? E(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var s = (t, e, n) => (f(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
|
+
var w = /* @__PURE__ */ ((t) => (t[t.Ok = 0] = "Ok", t[t.BadRequest = 400] = "BadRequest", t[t.Forbidden = 403] = "Forbidden", t[t.NotFound = 404] = "NotFound", t[t.Timeout = 408] = "Timeout", t[t.Conflict = 409] = "Conflict", t[t.TooLarge = 413] = "TooLarge", t[t.TooManyRequests = 429] = "TooManyRequests", t[t.Cancelled = 499] = "Cancelled", t[t.Internal = 500] = "Internal", t[t.NotImplemented = 501] = "NotImplemented", t))(w || {});
|
|
5
|
+
class r extends Error {
|
|
6
|
+
constructor(n, a, i) {
|
|
7
|
+
super(a);
|
|
8
|
+
s(this, "code");
|
|
9
|
+
s(this, "data");
|
|
10
|
+
this.name = "ToolError", this.code = n, this.data = i;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
return new
|
|
13
|
+
const m = "尚未授权工作文件夹,请先在助手中选择或恢复访问工作文件夹。";
|
|
14
|
+
function d() {
|
|
15
|
+
return new r(403, m, {
|
|
16
16
|
reason: "workspace_not_granted"
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return new
|
|
19
|
+
function u() {
|
|
20
|
+
return new r(499, "操作已取消。");
|
|
21
21
|
}
|
|
22
|
-
function N(
|
|
23
|
-
if (
|
|
24
|
-
throw
|
|
22
|
+
function N(t) {
|
|
23
|
+
if (t != null && t.aborted)
|
|
24
|
+
throw u();
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
function c(t) {
|
|
27
|
+
const e = t && typeof t == "object" && "message" in t ? String(t.message) : "";
|
|
28
|
+
return /[\u4e00-\u9fff]/.test(e) ? e : void 0;
|
|
29
|
+
}
|
|
30
|
+
function p(t) {
|
|
31
|
+
var n, a;
|
|
32
|
+
if (t instanceof r)
|
|
33
|
+
return t;
|
|
34
|
+
switch (t && typeof t == "object" && "name" in t ? String(t.name) : "") {
|
|
30
35
|
case "NotFoundError":
|
|
31
|
-
return new
|
|
36
|
+
return new r(404, "文件或目录不存在。");
|
|
32
37
|
case "TypeMismatchError":
|
|
33
|
-
return new
|
|
38
|
+
return new r(400, "路径类型不匹配:目标是目录而不是文件,或路径中的某一段不是目录。");
|
|
34
39
|
case "NotAllowedError":
|
|
35
40
|
case "SecurityError":
|
|
36
|
-
return
|
|
41
|
+
return d();
|
|
37
42
|
case "AbortError":
|
|
38
|
-
return
|
|
43
|
+
return u();
|
|
39
44
|
case "NoModificationAllowedError":
|
|
40
45
|
case "InvalidModificationError":
|
|
41
46
|
case "InvalidStateError":
|
|
42
|
-
return new
|
|
47
|
+
return new r(403, "文件当前不可写,可能正被其他程序占用或为只读。");
|
|
43
48
|
case "QuotaExceededError":
|
|
44
|
-
return new
|
|
49
|
+
return new r(413, (n = c(t)) != null ? n : "磁盘空间不足或超出写入配额。");
|
|
50
|
+
case "TooManyRequestsError":
|
|
51
|
+
return new r(429, (a = c(t)) != null ? a : "排队的文件操作过多,请稍后重试。");
|
|
52
|
+
case "PreviewLimitError":
|
|
53
|
+
return new r(413, "同时预览的文件过多,请先关掉一些预览。");
|
|
45
54
|
default:
|
|
46
|
-
return new
|
|
55
|
+
return new r(500, "本地文件操作失败,请稍后重试。");
|
|
47
56
|
}
|
|
48
57
|
}
|
|
49
58
|
export {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
w as ToolCode,
|
|
60
|
+
r as ToolError,
|
|
61
|
+
m as WORKSPACE_NOT_GRANTED_MESSAGE,
|
|
62
|
+
u as cancelledError,
|
|
54
63
|
N as throwIfAborted,
|
|
55
|
-
|
|
56
|
-
|
|
64
|
+
p as toToolError,
|
|
65
|
+
d as workspaceNotGranted
|
|
57
66
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import l from "../../Logger.mjs";
|
|
1
2
|
import { HostBridgeAdapter as f } from "../adapters/HostBridgeAdapter.mjs";
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
3
|
+
import { getHostBridge as y, HOST_CHANNEL as m, parseHostMessage as c } from "./protocol.mjs";
|
|
4
|
+
function u(o) {
|
|
4
5
|
if (!o || typeof o != "object")
|
|
5
6
|
return;
|
|
6
7
|
const e = o;
|
|
@@ -15,39 +16,43 @@ function m(o) {
|
|
|
15
16
|
reason: typeof e.reason == "string" ? e.reason : void 0
|
|
16
17
|
};
|
|
17
18
|
}
|
|
19
|
+
const d = new l("[HostBridge] ");
|
|
18
20
|
let s;
|
|
19
|
-
function
|
|
21
|
+
function h(o) {
|
|
20
22
|
s == null || s(), s = void 0;
|
|
21
|
-
const e =
|
|
23
|
+
const e = y();
|
|
22
24
|
if (!e)
|
|
23
|
-
return () => {
|
|
25
|
+
return d.log("missing"), () => {
|
|
24
26
|
};
|
|
25
|
-
const i = new f(e),
|
|
26
|
-
const t =
|
|
27
|
+
const i = new f(e), p = (g) => {
|
|
28
|
+
const t = c(g.data);
|
|
27
29
|
if (t) {
|
|
28
30
|
if (t.type === "workspace") {
|
|
29
|
-
const
|
|
31
|
+
const r = t.granted === !0, n = typeof t.displayName == "string" ? t.displayName : "";
|
|
30
32
|
i.setCapabilities(t.capabilities, {
|
|
31
33
|
version: t.sandboxVersion
|
|
32
|
-
}), i.applySandbox(
|
|
34
|
+
}), i.applySandbox(u(t.sandbox)), d.log("workspace", {
|
|
35
|
+
granted: r,
|
|
36
|
+
displayName: n
|
|
37
|
+
}), r ? (i.displayName = n || "工程目录", (o.status !== "granted" || o.displayName !== i.displayName) && o.attachAdapter(i, i.displayName)) : o.status === "granted" && o.clear();
|
|
33
38
|
return;
|
|
34
39
|
}
|
|
35
40
|
if (t.type === "fs-changed") {
|
|
36
|
-
const
|
|
37
|
-
o.notifyFilesChanged(
|
|
41
|
+
const r = Array.isArray(t.paths) ? t.paths.filter((n) => typeof n == "string") : [];
|
|
42
|
+
o.notifyFilesChanged(r);
|
|
38
43
|
return;
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
};
|
|
42
|
-
e.addEventListener("message", d), e.postMessage({
|
|
43
|
-
channel:
|
|
47
|
+
e.addEventListener("message", p), d.log("hello"), e.postMessage({
|
|
48
|
+
channel: m,
|
|
44
49
|
type: "hello"
|
|
45
50
|
});
|
|
46
51
|
const a = () => {
|
|
47
|
-
e.removeEventListener("message",
|
|
52
|
+
e.removeEventListener("message", p), s === a && (s = void 0);
|
|
48
53
|
};
|
|
49
54
|
return s = a, a;
|
|
50
55
|
}
|
|
51
56
|
export {
|
|
52
|
-
|
|
57
|
+
h as connectHostBridge
|
|
53
58
|
};
|
|
@@ -1,27 +1,40 @@
|
|
|
1
|
-
const
|
|
2
|
-
function
|
|
1
|
+
const i = "glodon-workspace", o = "__glodonHostBridge", c = 1, f = 524288e3;
|
|
2
|
+
function d(t) {
|
|
3
3
|
let e = t;
|
|
4
4
|
if (typeof e == "string")
|
|
5
5
|
try {
|
|
6
6
|
e = JSON.parse(e);
|
|
7
|
-
} catch (
|
|
7
|
+
} catch (s) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
if (!e || typeof e != "object")
|
|
11
11
|
return;
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
12
|
+
const n = e;
|
|
13
|
+
if (n.channel === i)
|
|
14
|
+
return n;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function r(t) {
|
|
17
|
+
if (!t || typeof t != "object")
|
|
18
|
+
return;
|
|
19
|
+
const e = t;
|
|
20
|
+
if (!(typeof e.postMessage != "function" || typeof e.addEventListener != "function" || typeof e.removeEventListener != "function"))
|
|
21
|
+
return e;
|
|
22
|
+
}
|
|
23
|
+
function g(t) {
|
|
24
|
+
const e = globalThis;
|
|
25
|
+
t ? e[o] = t : delete e[o];
|
|
26
|
+
}
|
|
27
|
+
function u() {
|
|
17
28
|
var e;
|
|
18
|
-
const t = (
|
|
19
|
-
|
|
20
|
-
return t;
|
|
29
|
+
const t = r(globalThis[o]);
|
|
30
|
+
return t || r((e = globalThis.chrome) == null ? void 0 : e.webview);
|
|
21
31
|
}
|
|
22
32
|
export {
|
|
23
|
-
|
|
24
|
-
i as
|
|
25
|
-
|
|
26
|
-
|
|
33
|
+
o as HOST_BRIDGE_GLOBAL,
|
|
34
|
+
i as HOST_CHANNEL,
|
|
35
|
+
f as SANDBOX_MAX_FILE_BYTES,
|
|
36
|
+
c as SANDBOX_PROTOCOL,
|
|
37
|
+
u as getHostBridge,
|
|
38
|
+
d as parseHostMessage,
|
|
39
|
+
g as registerHostBridge
|
|
27
40
|
};
|