@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
|
@@ -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,6 +1,7 @@
|
|
|
1
|
+
import l from "../../Logger.mjs";
|
|
1
2
|
import { HostBridgeAdapter as f } from "../adapters/HostBridgeAdapter.mjs";
|
|
2
|
-
import { getHostBridge as
|
|
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,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var S = Object.defineProperty, b = Object.defineProperties;
|
|
2
|
+
var H = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var k = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var p = (r, e, t) => e in r ?
|
|
4
|
+
var R = Object.prototype.hasOwnProperty, T = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var p = (r, e, t) => e in r ? S(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
7
|
+
R.call(e, t) && p(r, t, e[t]);
|
|
8
8
|
if (k)
|
|
9
9
|
for (var t of k(e))
|
|
10
|
-
|
|
10
|
+
T.call(e, t) && p(r, t, e[t]);
|
|
11
11
|
return r;
|
|
12
|
-
}, C = (r, e) =>
|
|
12
|
+
}, C = (r, e) => b(r, H(e));
|
|
13
13
|
var s = (r, e, t) => (p(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
14
|
var d = (r, e, t) => new Promise((i, n) => {
|
|
15
15
|
var a = (o) => {
|
|
@@ -27,23 +27,24 @@ var d = (r, e, t) => new Promise((i, n) => {
|
|
|
27
27
|
}, l = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(a, h);
|
|
28
28
|
l((t = t.apply(r, e)).next());
|
|
29
29
|
});
|
|
30
|
-
import
|
|
30
|
+
import F from "../../Logger.mjs";
|
|
31
|
+
import D from "../../EventBus.mjs";
|
|
31
32
|
import { FileSystemAccessAdapter as _ } from "../adapters/FileSystemAccessAdapter.mjs";
|
|
32
|
-
import { HostBridgeAdapter as
|
|
33
|
-
import { FileSnapshotAdapter as
|
|
34
|
-
import { getNativeDirectoryPicker as
|
|
35
|
-
import { LOCAL_FILES_FUNCTION_CODES as
|
|
33
|
+
import { HostBridgeAdapter as W } from "../adapters/HostBridgeAdapter.mjs";
|
|
34
|
+
import { FileSnapshotAdapter as L } from "../adapters/FileSnapshotAdapter.mjs";
|
|
35
|
+
import { getNativeDirectoryPicker as E } from "../adapters/fsaTypes.mjs";
|
|
36
|
+
import { LOCAL_FILES_FUNCTION_CODES as I } from "../constants.mjs";
|
|
36
37
|
import { getDownloadUrlAllowlist as N } from "../security/downloadUrlPolicy.mjs";
|
|
37
|
-
import { SensitiveFilePolicy as
|
|
38
|
-
import { resolveLimits as
|
|
39
|
-
import { createDefaultSessionFileTransfer as
|
|
40
|
-
import { createMemoryStore as
|
|
41
|
-
import { watchDirectoryHandle as
|
|
42
|
-
import { WorkspaceFiles as
|
|
38
|
+
import { SensitiveFilePolicy as q } from "../security/sensitiveFiles.mjs";
|
|
39
|
+
import { resolveLimits as U } from "../limits.mjs";
|
|
40
|
+
import { createDefaultSessionFileTransfer as j } from "../transfer/SessionFileTransfer.mjs";
|
|
41
|
+
import { createMemoryStore as x } from "./handleStore.mjs";
|
|
42
|
+
import { watchDirectoryHandle as K } from "./watchDirectory.mjs";
|
|
43
|
+
import { WorkspaceFiles as V } from "./WorkspaceFiles.mjs";
|
|
43
44
|
const m = {
|
|
44
45
|
mode: "readwrite"
|
|
45
46
|
};
|
|
46
|
-
function
|
|
47
|
+
function M(r) {
|
|
47
48
|
const e = r.replace(/\\/g, "/").trim().replace(/^\.\/+/, "").replace(/\/+$/, "");
|
|
48
49
|
if (!e || e === ".")
|
|
49
50
|
return "";
|
|
@@ -53,10 +54,11 @@ function K(r) {
|
|
|
53
54
|
if (!t.some((i) => !i || i === "." || i === ".."))
|
|
54
55
|
return t.join("/");
|
|
55
56
|
}
|
|
56
|
-
function
|
|
57
|
+
function O(r) {
|
|
57
58
|
return !!r && typeof r == "object" && r.name === "AbortError";
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
+
const P = new F("[LocalWorkspace] ");
|
|
61
|
+
class ne {
|
|
60
62
|
constructor(e) {
|
|
61
63
|
s(this, "applicationId");
|
|
62
64
|
s(this, "limits");
|
|
@@ -73,7 +75,7 @@ class se {
|
|
|
73
75
|
s(this, "files");
|
|
74
76
|
s(this, "store");
|
|
75
77
|
s(this, "picker");
|
|
76
|
-
s(this, "event", new
|
|
78
|
+
s(this, "event", new D(!0));
|
|
77
79
|
s(this, "_status");
|
|
78
80
|
s(this, "_displayName");
|
|
79
81
|
s(this, "_adapter", null);
|
|
@@ -92,8 +94,8 @@ class se {
|
|
|
92
94
|
s(this, "epoch", 0);
|
|
93
95
|
var h, l, o, c, f, g, v, y, w, A;
|
|
94
96
|
const t = (h = e.config) != null ? h : {};
|
|
95
|
-
this.applicationId = e.applicationId, this.store = (l = e.store) != null ? l :
|
|
96
|
-
const i = (c = e.transfer) != null ? c :
|
|
97
|
+
this.applicationId = e.applicationId, this.store = (l = e.store) != null ? l : x(), this.picker = e.picker === null ? void 0 : (o = e.picker) != null ? o : E(), this.limits = U(t.limits), this.sensitive = new q(t.sensitiveRulesAppend), this.downloadUrlAllowlist = N(t.downloadUrlAllowlistAppend), this.allowWorkspaceWideTextSearch = !!t.allowWorkspaceWideTextSearch, this.approvalHandler = t.onApprovalRequired;
|
|
98
|
+
const i = (c = e.transfer) != null ? c : j(() => {
|
|
97
99
|
});
|
|
98
100
|
this.transfer = {
|
|
99
101
|
upload: (g = (f = t.transfer) == null ? void 0 : f.upload) != null ? g : i.upload,
|
|
@@ -106,7 +108,7 @@ class se {
|
|
|
106
108
|
enabled: (a == null ? void 0 : a.enabled) !== !1,
|
|
107
109
|
bashModuleURL: a == null ? void 0 : a.bashModuleURL,
|
|
108
110
|
pyodideIndexURL: a == null ? void 0 : a.pyodideIndexURL
|
|
109
|
-
}, this._status = this.picker ? "none" : "unsupported", this.files = new
|
|
111
|
+
}, this._status = this.picker ? "none" : "unsupported", this.files = new V(this);
|
|
110
112
|
}
|
|
111
113
|
// -------------------------------------------------------------------------
|
|
112
114
|
// 状态
|
|
@@ -139,7 +141,10 @@ class se {
|
|
|
139
141
|
return `disclosure:${this.applicationId}`;
|
|
140
142
|
}
|
|
141
143
|
setStatus(e, t = this._displayName) {
|
|
142
|
-
e === this._status && t === this._displayName || (this._status = e, this._displayName = t,
|
|
144
|
+
e === this._status && t === this._displayName || (this._status = e, this._displayName = t, P.log("status", {
|
|
145
|
+
status: e,
|
|
146
|
+
displayName: t
|
|
147
|
+
}), this.emit("workspace:changed", {
|
|
143
148
|
status: e,
|
|
144
149
|
displayName: t
|
|
145
150
|
}));
|
|
@@ -148,7 +153,7 @@ class se {
|
|
|
148
153
|
this._adapter !== e && this.files.releaseAllUrls(), this._adapter = e;
|
|
149
154
|
}
|
|
150
155
|
attachHandle(e) {
|
|
151
|
-
this.cancelFilesChanged(), this.pendingHandle = e, this.replaceAdapter(new _(e)), this.setStatus("granted", e.name), this.unwatchDirectory(), this.stopWatching =
|
|
156
|
+
this.cancelFilesChanged(), this.pendingHandle = e, this.replaceAdapter(new _(e)), this.setStatus("granted", e.name), this.unwatchDirectory(), this.stopWatching = K(e, (t) => this.notifyFilesChanged(t));
|
|
152
157
|
}
|
|
153
158
|
// -------------------------------------------------------------------------
|
|
154
159
|
// 授权
|
|
@@ -174,7 +179,7 @@ class se {
|
|
|
174
179
|
savedAt: Date.now()
|
|
175
180
|
}).catch(() => {
|
|
176
181
|
}), !0), (t) => {
|
|
177
|
-
if (
|
|
182
|
+
if (O(t))
|
|
178
183
|
return !1;
|
|
179
184
|
throw t;
|
|
180
185
|
});
|
|
@@ -263,7 +268,7 @@ class se {
|
|
|
263
268
|
lastModified: c.lastModified,
|
|
264
269
|
blob: c
|
|
265
270
|
}));
|
|
266
|
-
this.attachAdapter(new
|
|
271
|
+
this.attachAdapter(new L(a, n), n);
|
|
267
272
|
}
|
|
268
273
|
/** 直接挂载一个 Adapter(测试或自定义后端),视为已授权。 */
|
|
269
274
|
attachAdapter(e, t = e.displayName) {
|
|
@@ -279,7 +284,7 @@ class se {
|
|
|
279
284
|
this.refreshAllVisible = !0;
|
|
280
285
|
else
|
|
281
286
|
for (const t of e) {
|
|
282
|
-
const i =
|
|
287
|
+
const i = M(t);
|
|
283
288
|
i === void 0 ? this.refreshAllVisible = !0 : this.pendingChangePaths.add(i);
|
|
284
289
|
}
|
|
285
290
|
clearTimeout(this.changeTimer), this.changeTimer = setTimeout(() => this.flushFilesChanged(), 150);
|
|
@@ -351,7 +356,7 @@ class se {
|
|
|
351
356
|
* 浏览器运行时一次只放一条。
|
|
352
357
|
*/
|
|
353
358
|
acquireCommand() {
|
|
354
|
-
if (this._adapter instanceof
|
|
359
|
+
if (this._adapter instanceof W)
|
|
355
360
|
return () => {
|
|
356
361
|
};
|
|
357
362
|
if (this.activeCommands >= 1)
|
|
@@ -372,7 +377,7 @@ class se {
|
|
|
372
377
|
this.inflight.clear(), e.forEach((t) => t.abort());
|
|
373
378
|
}
|
|
374
379
|
handshake() {
|
|
375
|
-
const e = Object.fromEntries(
|
|
380
|
+
const e = Object.fromEntries(I.map((t) => [t, !0]));
|
|
376
381
|
return {
|
|
377
382
|
protocolVersion: "1.0",
|
|
378
383
|
capabilities: C(u({}, e), {
|
|
@@ -411,10 +416,10 @@ class se {
|
|
|
411
416
|
try {
|
|
412
417
|
this.event.emit(e, t);
|
|
413
418
|
} catch (i) {
|
|
414
|
-
|
|
419
|
+
P.report(`${e} listener failed`, i);
|
|
415
420
|
}
|
|
416
421
|
}
|
|
417
422
|
}
|
|
418
423
|
export {
|
|
419
|
-
|
|
424
|
+
ne as LocalWorkspace
|
|
420
425
|
};
|