@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
|
@@ -3,27 +3,27 @@ var g = (o, t) => {
|
|
|
3
3
|
return t;
|
|
4
4
|
throw Error("Symbol." + o + " is not defined");
|
|
5
5
|
};
|
|
6
|
-
var
|
|
6
|
+
var w = (o, t, r) => new Promise((e, a) => {
|
|
7
7
|
var c = (i) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
s(r.next(i));
|
|
10
10
|
} catch (n) {
|
|
11
11
|
a(n);
|
|
12
12
|
}
|
|
13
|
-
},
|
|
13
|
+
}, d = (i) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
s(r.throw(i));
|
|
16
16
|
} catch (n) {
|
|
17
17
|
a(n);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, s = (i) => i.done ? e(i.value) : Promise.resolve(i.value).then(c, d);
|
|
20
|
+
s((r = r.apply(o, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var
|
|
23
|
-
import { domError as
|
|
24
|
-
import { throwIfAborted as
|
|
25
|
-
import { splitPath as
|
|
26
|
-
function
|
|
22
|
+
var v = (o, t, r) => (t = o[g("asyncIterator")]) ? t.call(o) : (o = o[g("iterator")](), t = {}, r = (e, a) => (a = o[e]) && (t[e] = (c) => new Promise((d, s, i) => (c = a.call(o, c), i = c.done, Promise.resolve(c.value).then((n) => d({ value: n, done: i }), s)))), r("next"), r("return"), t);
|
|
23
|
+
import { domError as u, toChunks as F, isSameOrInside as H } from "./WorkspaceFileAdapter.mjs";
|
|
24
|
+
import { throwIfAborted as p } from "../errors.mjs";
|
|
25
|
+
import { splitPath as h } from "../security/pathPolicy.mjs";
|
|
26
|
+
function m(o, t) {
|
|
27
27
|
return !!o && typeof o == "object" && o.name === t;
|
|
28
28
|
}
|
|
29
29
|
class b {
|
|
@@ -33,85 +33,67 @@ class b {
|
|
|
33
33
|
get displayName() {
|
|
34
34
|
return this.root.name;
|
|
35
35
|
}
|
|
36
|
-
resolveDirectory(t,
|
|
37
|
-
return
|
|
38
|
-
let
|
|
36
|
+
resolveDirectory(t, r = !1) {
|
|
37
|
+
return w(this, null, function* () {
|
|
38
|
+
let e = this.root;
|
|
39
39
|
for (const a of t)
|
|
40
|
-
|
|
41
|
-
create:
|
|
40
|
+
e = yield e.getDirectoryHandle(a, {
|
|
41
|
+
create: r
|
|
42
42
|
});
|
|
43
|
-
return
|
|
43
|
+
return e;
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
resolveFile(t) {
|
|
47
|
-
return
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
50
|
-
throw
|
|
51
|
-
return (yield this.resolveDirectory(
|
|
47
|
+
return w(this, null, function* () {
|
|
48
|
+
const r = h(t), e = r.pop();
|
|
49
|
+
if (!e)
|
|
50
|
+
throw u("TypeMismatchError");
|
|
51
|
+
return (yield this.resolveDirectory(r)).getFileHandle(e);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
stat(t) {
|
|
55
|
-
return
|
|
56
|
-
const
|
|
57
|
-
if (!
|
|
55
|
+
return w(this, null, function* () {
|
|
56
|
+
const r = h(t), e = r.pop();
|
|
57
|
+
if (!e)
|
|
58
58
|
return {
|
|
59
59
|
name: this.root.name,
|
|
60
60
|
kind: "directory"
|
|
61
61
|
};
|
|
62
|
-
const a = yield this.resolveDirectory(
|
|
62
|
+
const a = yield this.resolveDirectory(r);
|
|
63
63
|
try {
|
|
64
|
-
const c = yield (yield a.getFileHandle(
|
|
64
|
+
const c = yield (yield a.getFileHandle(e)).getFile();
|
|
65
65
|
return {
|
|
66
|
-
name:
|
|
66
|
+
name: e,
|
|
67
67
|
kind: "file",
|
|
68
68
|
size: c.size,
|
|
69
69
|
lastModified: c.lastModified
|
|
70
70
|
};
|
|
71
71
|
} catch (c) {
|
|
72
|
-
if (!
|
|
72
|
+
if (!m(c, "TypeMismatchError"))
|
|
73
73
|
throw c;
|
|
74
|
-
return yield a.getDirectoryHandle(
|
|
75
|
-
name:
|
|
74
|
+
return yield a.getDirectoryHandle(e), {
|
|
75
|
+
name: e,
|
|
76
76
|
kind: "directory"
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
listEntries(t,
|
|
82
|
-
return
|
|
83
|
-
const
|
|
81
|
+
listEntries(t, r) {
|
|
82
|
+
return w(this, null, function* () {
|
|
83
|
+
const e = yield this.resolveDirectory(h(t)), a = [];
|
|
84
84
|
try {
|
|
85
|
-
for (var c =
|
|
86
|
-
const n =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
else
|
|
93
|
-
try {
|
|
94
|
-
const s = yield n.getFile();
|
|
95
|
-
a.push({
|
|
96
|
-
name: n.name,
|
|
97
|
-
kind: "file",
|
|
98
|
-
size: s.size,
|
|
99
|
-
lastModified: s.lastModified
|
|
100
|
-
});
|
|
101
|
-
} catch (s) {
|
|
102
|
-
if (u(s, "NotAllowedError"))
|
|
103
|
-
throw s;
|
|
104
|
-
a.push({
|
|
105
|
-
name: n.name,
|
|
106
|
-
kind: "file"
|
|
107
|
-
});
|
|
108
|
-
}
|
|
85
|
+
for (var c = v(e.values()), d, s, i; d = !(s = yield c.next()).done; d = !1) {
|
|
86
|
+
const n = s.value;
|
|
87
|
+
p(r), a.push({
|
|
88
|
+
name: n.name,
|
|
89
|
+
kind: n.kind === "directory" ? "directory" : "file"
|
|
90
|
+
});
|
|
109
91
|
}
|
|
110
|
-
} catch (
|
|
111
|
-
i = [
|
|
92
|
+
} catch (s) {
|
|
93
|
+
i = [s];
|
|
112
94
|
} finally {
|
|
113
95
|
try {
|
|
114
|
-
|
|
96
|
+
d && (s = c.return) && (yield s.call(c));
|
|
115
97
|
} finally {
|
|
116
98
|
if (i)
|
|
117
99
|
throw i[0];
|
|
@@ -121,140 +103,140 @@ class b {
|
|
|
121
103
|
});
|
|
122
104
|
}
|
|
123
105
|
readFile(t) {
|
|
124
|
-
return
|
|
106
|
+
return w(this, null, function* () {
|
|
125
107
|
return (yield this.resolveFile(t)).getFile();
|
|
126
108
|
});
|
|
127
109
|
}
|
|
128
110
|
writeFile(a, c) {
|
|
129
|
-
return
|
|
130
|
-
const
|
|
131
|
-
if (!
|
|
132
|
-
throw
|
|
133
|
-
const i = yield this.resolveDirectory(
|
|
111
|
+
return w(this, arguments, function* (t, r, e = {}) {
|
|
112
|
+
const d = h(t), s = d.pop();
|
|
113
|
+
if (!s)
|
|
114
|
+
throw u("TypeMismatchError");
|
|
115
|
+
const i = yield this.resolveDirectory(d, e.createDirectories);
|
|
134
116
|
let n = !0;
|
|
135
117
|
try {
|
|
136
|
-
yield i.getFileHandle(
|
|
137
|
-
} catch (
|
|
138
|
-
if (!
|
|
139
|
-
throw
|
|
118
|
+
yield i.getFileHandle(s);
|
|
119
|
+
} catch (f) {
|
|
120
|
+
if (!m(f, "NotFoundError"))
|
|
121
|
+
throw f;
|
|
140
122
|
n = !1;
|
|
141
123
|
}
|
|
142
|
-
const
|
|
124
|
+
const y = yield i.getFileHandle(s, {
|
|
143
125
|
create: !0
|
|
144
126
|
});
|
|
145
|
-
let
|
|
127
|
+
let l;
|
|
146
128
|
try {
|
|
147
|
-
|
|
129
|
+
l = yield y.createWritable();
|
|
148
130
|
try {
|
|
149
|
-
for (var A =
|
|
150
|
-
const
|
|
151
|
-
|
|
131
|
+
for (var A = v(F(r)), S, z, W; S = !(z = yield A.next()).done; S = !1) {
|
|
132
|
+
const f = z.value;
|
|
133
|
+
p(e.signal), yield l.write(f);
|
|
152
134
|
}
|
|
153
|
-
} catch (
|
|
154
|
-
W = [
|
|
135
|
+
} catch (z) {
|
|
136
|
+
W = [z];
|
|
155
137
|
} finally {
|
|
156
138
|
try {
|
|
157
|
-
|
|
139
|
+
S && (z = A.return) && (yield z.call(A));
|
|
158
140
|
} finally {
|
|
159
141
|
if (W)
|
|
160
142
|
throw W[0];
|
|
161
143
|
}
|
|
162
144
|
}
|
|
163
|
-
|
|
164
|
-
} catch (
|
|
165
|
-
throw yield
|
|
166
|
-
}), n || (yield i.removeEntry(
|
|
167
|
-
})),
|
|
145
|
+
p(e.signal), yield l.close();
|
|
146
|
+
} catch (f) {
|
|
147
|
+
throw yield l == null ? void 0 : l.abort().catch(() => {
|
|
148
|
+
}), n || (yield i.removeEntry(s).catch(() => {
|
|
149
|
+
})), f;
|
|
168
150
|
}
|
|
169
151
|
});
|
|
170
152
|
}
|
|
171
153
|
createDirectory(t) {
|
|
172
|
-
return
|
|
173
|
-
yield this.resolveDirectory(
|
|
154
|
+
return w(this, null, function* () {
|
|
155
|
+
yield this.resolveDirectory(h(t), !0);
|
|
174
156
|
});
|
|
175
157
|
}
|
|
176
|
-
remove(
|
|
177
|
-
return
|
|
178
|
-
const a =
|
|
158
|
+
remove(e) {
|
|
159
|
+
return w(this, arguments, function* (t, r = {}) {
|
|
160
|
+
const a = h(t), c = a.pop();
|
|
179
161
|
if (!c)
|
|
180
|
-
throw
|
|
162
|
+
throw u("InvalidModificationError");
|
|
181
163
|
yield (yield this.resolveDirectory(a)).removeEntry(c, {
|
|
182
|
-
recursive:
|
|
164
|
+
recursive: r.recursive === !0
|
|
183
165
|
});
|
|
184
166
|
});
|
|
185
167
|
}
|
|
186
|
-
move(t,
|
|
187
|
-
return
|
|
188
|
-
const
|
|
189
|
-
if (!c || !
|
|
190
|
-
throw
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
193
|
-
throw
|
|
194
|
-
let
|
|
168
|
+
move(t, r) {
|
|
169
|
+
return w(this, null, function* () {
|
|
170
|
+
const e = h(t), a = h(r), c = e.pop(), d = a.pop();
|
|
171
|
+
if (!c || !d)
|
|
172
|
+
throw u("InvalidModificationError");
|
|
173
|
+
const s = yield this.resolveDirectory(e), i = yield E(s, c), n = yield this.resolveDirectory(a);
|
|
174
|
+
if (H(t, r))
|
|
175
|
+
throw u("InvalidModificationError");
|
|
176
|
+
let y;
|
|
195
177
|
try {
|
|
196
|
-
|
|
197
|
-
} catch (
|
|
198
|
-
if (!
|
|
199
|
-
throw
|
|
178
|
+
y = yield E(n, d);
|
|
179
|
+
} catch (l) {
|
|
180
|
+
if (!m(l, "NotFoundError"))
|
|
181
|
+
throw l;
|
|
200
182
|
}
|
|
201
|
-
if (
|
|
202
|
-
throw
|
|
203
|
-
if (!
|
|
183
|
+
if (y && (y.kind === "directory" || i.kind === "directory"))
|
|
184
|
+
throw u("InvalidModificationError");
|
|
185
|
+
if (!y && typeof i.move == "function")
|
|
204
186
|
try {
|
|
205
|
-
yield i.move(n,
|
|
187
|
+
yield i.move(n, d);
|
|
206
188
|
return;
|
|
207
|
-
} catch (
|
|
208
|
-
if (!
|
|
209
|
-
throw
|
|
189
|
+
} catch (l) {
|
|
190
|
+
if (!m(l, "NotSupportedError") && !(l instanceof TypeError))
|
|
191
|
+
throw l;
|
|
210
192
|
}
|
|
211
|
-
yield
|
|
193
|
+
yield D(i, n, d), yield s.removeEntry(c, {
|
|
212
194
|
recursive: !0
|
|
213
195
|
});
|
|
214
196
|
});
|
|
215
197
|
}
|
|
216
198
|
}
|
|
217
199
|
function E(o, t) {
|
|
218
|
-
return
|
|
200
|
+
return w(this, null, function* () {
|
|
219
201
|
try {
|
|
220
202
|
return yield o.getFileHandle(t);
|
|
221
|
-
} catch (
|
|
222
|
-
if (!
|
|
223
|
-
throw
|
|
203
|
+
} catch (r) {
|
|
204
|
+
if (!m(r, "TypeMismatchError"))
|
|
205
|
+
throw r;
|
|
224
206
|
return o.getDirectoryHandle(t);
|
|
225
207
|
}
|
|
226
208
|
});
|
|
227
209
|
}
|
|
228
|
-
function
|
|
229
|
-
return
|
|
210
|
+
function D(o, t, r) {
|
|
211
|
+
return w(this, null, function* () {
|
|
230
212
|
if (o.kind === "file") {
|
|
231
|
-
const i = yield o.getFile(), n = yield (yield t.getFileHandle(
|
|
213
|
+
const i = yield o.getFile(), n = yield (yield t.getFileHandle(r, {
|
|
232
214
|
create: !0
|
|
233
215
|
})).createWritable();
|
|
234
216
|
try {
|
|
235
217
|
yield n.write(i), yield n.close();
|
|
236
|
-
} catch (
|
|
218
|
+
} catch (y) {
|
|
237
219
|
throw yield n.abort().catch(() => {
|
|
238
|
-
}),
|
|
220
|
+
}), y;
|
|
239
221
|
}
|
|
240
222
|
return;
|
|
241
223
|
}
|
|
242
|
-
const
|
|
224
|
+
const e = yield t.getDirectoryHandle(r, {
|
|
243
225
|
create: !0
|
|
244
226
|
});
|
|
245
227
|
try {
|
|
246
|
-
for (var a =
|
|
247
|
-
const i =
|
|
248
|
-
yield
|
|
228
|
+
for (var a = v(o.values()), c, d, s; c = !(d = yield a.next()).done; c = !1) {
|
|
229
|
+
const i = d.value;
|
|
230
|
+
yield D(i, e, i.name);
|
|
249
231
|
}
|
|
250
|
-
} catch (
|
|
251
|
-
|
|
232
|
+
} catch (d) {
|
|
233
|
+
s = [d];
|
|
252
234
|
} finally {
|
|
253
235
|
try {
|
|
254
|
-
c && (
|
|
236
|
+
c && (d = a.return) && (yield d.call(a));
|
|
255
237
|
} finally {
|
|
256
|
-
if (
|
|
257
|
-
throw
|
|
238
|
+
if (s)
|
|
239
|
+
throw s[0];
|
|
258
240
|
}
|
|
259
241
|
}
|
|
260
242
|
});
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var h = (r, t) => {
|
|
3
3
|
if (t = Symbol[r])
|
|
4
4
|
return t;
|
|
5
5
|
throw Error("Symbol." + r + " is not defined");
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
7
|
+
var g = (r, t, e) => t in r ? u(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
8
|
+
var y = (r, t, e) => (g(r, typeof t != "symbol" ? t + "" : t, e), e);
|
|
9
|
+
var o = (r, t, e) => new Promise((s, a) => {
|
|
10
|
+
var n = (i) => {
|
|
11
11
|
try {
|
|
12
|
-
|
|
12
|
+
d(e.next(i));
|
|
13
13
|
} catch (c) {
|
|
14
14
|
a(c);
|
|
15
15
|
}
|
|
16
|
-
},
|
|
16
|
+
}, l = (i) => {
|
|
17
17
|
try {
|
|
18
|
-
|
|
18
|
+
d(e.throw(i));
|
|
19
19
|
} catch (c) {
|
|
20
20
|
a(c);
|
|
21
21
|
}
|
|
22
|
-
},
|
|
23
|
-
|
|
22
|
+
}, d = (i) => i.done ? s(i.value) : Promise.resolve(i.value).then(n, l);
|
|
23
|
+
d((e = e.apply(r, t)).next());
|
|
24
24
|
});
|
|
25
|
-
var f = (r, t, e) => (t = r[
|
|
26
|
-
import { throwIfAborted as
|
|
27
|
-
import { SandboxClient as
|
|
25
|
+
var f = (r, t, e) => (t = r[h("asyncIterator")]) ? t.call(r) : (r = r[h("iterator")](), t = {}, e = (s, a) => (a = r[s]) && (t[s] = (n) => new Promise((l, d, i) => (n = a.call(r, n), i = n.done, Promise.resolve(n.value).then((c) => l({ value: c, done: i }), d)))), e("next"), e("return"), t);
|
|
26
|
+
import { throwIfAborted as v } from "../errors.mjs";
|
|
27
|
+
import { SandboxClient as w } from "../host/sandboxClient.mjs";
|
|
28
28
|
import { SANDBOX_PROTOCOL as A } from "../host/protocol.mjs";
|
|
29
|
-
import { domError as
|
|
29
|
+
import { domError as m, toChunks as M } from "./WorkspaceFileAdapter.mjs";
|
|
30
30
|
function x(r, t) {
|
|
31
31
|
const e = r && typeof r == "object" ? r : {}, s = e.kind === "directory" ? "directory" : "file", a = {
|
|
32
32
|
name: typeof e.name == "string" && e.name ? e.name : t,
|
|
@@ -34,13 +34,13 @@ function x(r, t) {
|
|
|
34
34
|
};
|
|
35
35
|
return s === "file" && typeof e.size == "number" && (a.size = e.size), typeof e.lastModified == "number" && (a.lastModified = e.lastModified), a;
|
|
36
36
|
}
|
|
37
|
-
class
|
|
38
|
-
constructor(t, e = "", s = new
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
class P {
|
|
38
|
+
constructor(t, e = "", s = new w()) {
|
|
39
|
+
y(this, "displayName");
|
|
40
|
+
y(this, "capabilities", /* @__PURE__ */ new Set());
|
|
41
|
+
y(this, "sandboxVersion");
|
|
42
|
+
y(this, "sandboxProtocol");
|
|
43
|
+
y(this, "sandbox");
|
|
44
44
|
this.displayName = e, this.sandbox = s;
|
|
45
45
|
}
|
|
46
46
|
setCapabilities(t, e = {}) {
|
|
@@ -50,7 +50,7 @@ class S {
|
|
|
50
50
|
applySandbox(t) {
|
|
51
51
|
this.sandboxProtocol = t == null ? void 0 : t.protocol, this.sandbox.apply(t);
|
|
52
52
|
}
|
|
53
|
-
/** 沙箱已就绪且协议为
|
|
53
|
+
/** 沙箱已就绪且协议为 1 时,命令走直连。 */
|
|
54
54
|
get canExec() {
|
|
55
55
|
return this.sandbox.ready;
|
|
56
56
|
}
|
|
@@ -61,65 +61,70 @@ class S {
|
|
|
61
61
|
return this.sandbox.unavailableMessage();
|
|
62
62
|
}
|
|
63
63
|
stat(t) {
|
|
64
|
-
return
|
|
64
|
+
return o(this, null, function* () {
|
|
65
65
|
const e = yield this.sandbox.stat(t);
|
|
66
66
|
return x(e.entry, t.split("/").pop() || this.displayName);
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
listEntries(t, e) {
|
|
70
|
-
return
|
|
70
|
+
return o(this, null, function* () {
|
|
71
71
|
const s = yield this.sandbox.list(t, e);
|
|
72
|
-
return (Array.isArray(s.entries) ? s.entries : []).map((
|
|
72
|
+
return (Array.isArray(s.entries) ? s.entries : []).map((n) => x(n, ""));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
url(t) {
|
|
76
|
+
return o(this, null, function* () {
|
|
77
|
+
const e = yield this.sandbox.url(t), s = this.sandbox.httpOrigin();
|
|
78
|
+
if (!s)
|
|
79
|
+
throw m("NotAllowedError", this.unavailableMessage());
|
|
80
|
+
return {
|
|
81
|
+
url: `http://${s}/file/${e}`,
|
|
82
|
+
release: () => {
|
|
83
|
+
this.sandbox.releaseUrl(e).catch(() => {
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
73
87
|
});
|
|
74
88
|
}
|
|
75
89
|
readFile(t, e) {
|
|
76
|
-
return
|
|
90
|
+
return o(this, null, function* () {
|
|
77
91
|
var a;
|
|
78
92
|
const s = yield this.sandbox.read(t, (a = e == null ? void 0 : e.offset) != null ? a : 0, e == null ? void 0 : e.maxBytes);
|
|
79
93
|
return new Blob([s]);
|
|
80
94
|
});
|
|
81
95
|
}
|
|
82
96
|
createDirectory(t) {
|
|
83
|
-
return
|
|
97
|
+
return o(this, null, function* () {
|
|
84
98
|
yield this.sandbox.mkdir(t);
|
|
85
99
|
});
|
|
86
100
|
}
|
|
87
101
|
remove(s) {
|
|
88
|
-
return
|
|
102
|
+
return o(this, arguments, function* (t, e = {}) {
|
|
89
103
|
yield this.sandbox.remove(t, e.recursive === !0);
|
|
90
104
|
});
|
|
91
105
|
}
|
|
92
106
|
move(t, e) {
|
|
93
|
-
return
|
|
107
|
+
return o(this, null, function* () {
|
|
94
108
|
yield this.sandbox.move(t, e);
|
|
95
109
|
});
|
|
96
110
|
}
|
|
97
111
|
exec(t) {
|
|
98
|
-
return
|
|
112
|
+
return o(this, null, function* () {
|
|
99
113
|
const e = yield this.sandbox.exec({
|
|
100
114
|
op: "exec",
|
|
101
115
|
cwd: t.cwd,
|
|
102
116
|
command: t.command,
|
|
103
117
|
argv: t.argv,
|
|
104
|
-
timeoutMs: t.timeoutMs
|
|
118
|
+
timeoutMs: t.timeoutMs,
|
|
119
|
+
skill: t.skill
|
|
105
120
|
}, t.signal, t.onOutput);
|
|
106
121
|
if (e.timedOut)
|
|
107
|
-
throw
|
|
122
|
+
throw m("AbortError", "命令运行超时。");
|
|
108
123
|
return e;
|
|
109
124
|
});
|
|
110
125
|
}
|
|
111
|
-
|
|
112
|
-
return
|
|
113
|
-
return this.sandbox.exec({
|
|
114
|
-
op: "run_python",
|
|
115
|
-
path: t,
|
|
116
|
-
args: e,
|
|
117
|
-
timeoutMs: s
|
|
118
|
-
}, a);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
writeFile(a, o) {
|
|
122
|
-
return n(this, arguments, function* (t, e, s = {}) {
|
|
126
|
+
writeFile(a, n) {
|
|
127
|
+
return o(this, arguments, function* (t, e, s = {}) {
|
|
123
128
|
if (typeof e == "string") {
|
|
124
129
|
yield this.sandbox.write(t, new TextEncoder().encode(e), s.createDirectories === !0, s.signal);
|
|
125
130
|
return;
|
|
@@ -128,30 +133,30 @@ class S {
|
|
|
128
133
|
yield this.sandbox.write(t, e, s.createDirectories === !0, s.signal);
|
|
129
134
|
return;
|
|
130
135
|
}
|
|
131
|
-
const
|
|
136
|
+
const l = [];
|
|
132
137
|
try {
|
|
133
|
-
for (var
|
|
138
|
+
for (var C = f(M(e)), z, L, U; z = !(L = yield C.next()).done; z = !1) {
|
|
134
139
|
const b = L.value;
|
|
135
|
-
|
|
140
|
+
v(s.signal), l.push(b);
|
|
136
141
|
}
|
|
137
142
|
} catch (L) {
|
|
138
|
-
|
|
143
|
+
U = [L];
|
|
139
144
|
} finally {
|
|
140
145
|
try {
|
|
141
|
-
z && (L =
|
|
146
|
+
z && (L = C.return) && (yield L.call(C));
|
|
142
147
|
} finally {
|
|
143
|
-
if (
|
|
144
|
-
throw
|
|
148
|
+
if (U)
|
|
149
|
+
throw U[0];
|
|
145
150
|
}
|
|
146
151
|
}
|
|
147
|
-
const
|
|
152
|
+
const d = l.reduce((b, p) => b + p.byteLength, 0), i = new Uint8Array(d);
|
|
148
153
|
let c = 0;
|
|
149
|
-
|
|
154
|
+
l.forEach((b) => {
|
|
150
155
|
i.set(b, c), c += b.byteLength;
|
|
151
156
|
}), yield this.sandbox.write(t, i, s.createDirectories === !0, s.signal);
|
|
152
157
|
});
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
160
|
export {
|
|
156
|
-
|
|
161
|
+
P as HostBridgeAdapter
|
|
157
162
|
};
|
|
@@ -1,47 +1,43 @@
|
|
|
1
|
-
const
|
|
1
|
+
const T = ["list_directory", "read_file", "stat_file", "search_files", "search_text", "apply_patch", "write_file", "upload_file", "download_file"], _ = "builtin_tools", t = {
|
|
2
2
|
dev: _,
|
|
3
3
|
test: _,
|
|
4
4
|
prod: _,
|
|
5
5
|
local: _
|
|
6
|
-
}, E = t, c = "
|
|
6
|
+
}, E = t, c = "current-workspace", o = 1024, e = 1024 * 1024, s = 50, I = Object.freeze({
|
|
7
7
|
maxReadBytes: 1 * e,
|
|
8
8
|
maxWriteBytes: 5 * e,
|
|
9
9
|
maxSearchResults: 200,
|
|
10
10
|
maxConcurrentRequests: 4,
|
|
11
|
-
maxTransferBytes:
|
|
11
|
+
maxTransferBytes: s * e,
|
|
12
12
|
toolTimeoutMs: 3e4,
|
|
13
|
+
commandTimeoutMs: 10 * 6e4,
|
|
13
14
|
searchTimeoutMs: 6e4,
|
|
14
15
|
transferTimeoutMs: 10 * 6e4,
|
|
15
16
|
approvalTimeoutMs: 5 * 6e4
|
|
16
|
-
}),
|
|
17
|
+
}), n = 200, L = 1e3, S = 8, a = 16, l = 2e3, O = 1 * e, A = 500, R = 3, i = 8 * o, r = Object.freeze(["glodon.com"]), C = Object.freeze([".git", "node_modules", ".svn", ".idea", ".vscode"]), N = Object.freeze(["~$*", ".~lock*", "*.tmp"]), D = ["apply_patch", "write_file", "upload_file", "download_file"], d = ["search_files", "search_text"], F = ["upload_file", "download_file"];
|
|
17
18
|
export {
|
|
18
|
-
|
|
19
|
+
i as BINARY_SNIFF_BYTES,
|
|
19
20
|
_ as BUILTIN_TOOLS_PLUGIN_CODE,
|
|
20
21
|
t as BUILTIN_TOOLS_PLUGIN_CODES,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
r as DEFAULT_DOWNLOAD_URL_ALLOWLIST,
|
|
23
|
+
C as DEFAULT_IGNORED_DIRECTORIES,
|
|
24
|
+
N as DEFAULT_IGNORED_FILE_PATTERNS,
|
|
25
|
+
I as DEFAULT_LIMITS,
|
|
25
26
|
o as KiB,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
n as LIST_DIRECTORY_DEFAULT_LIMIT,
|
|
28
|
+
L as LIST_DIRECTORY_MAX_LIMIT,
|
|
29
|
+
T as LOCAL_FILES_FUNCTION_CODES,
|
|
29
30
|
E as LOCAL_FILES_PLUGIN_CODES,
|
|
30
|
-
c as LOCAL_PYTHON_FUNCTION_CODE,
|
|
31
|
-
I as LOCAL_PYTHON_PLUGIN_CODES,
|
|
32
31
|
e as MiB,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
H as TRANSFER_FUNCTION_CODES,
|
|
45
|
-
S as WORKSPACE_GRANT_ID,
|
|
46
|
-
f as WRITE_FUNCTION_CODES
|
|
32
|
+
S as SEARCH_DEFAULT_DEPTH,
|
|
33
|
+
d as SEARCH_FUNCTION_CODES,
|
|
34
|
+
a as SEARCH_MAX_DEPTH,
|
|
35
|
+
R as TEXT_SEARCH_MAX_CONTEXT_LINES,
|
|
36
|
+
l as TEXT_SEARCH_MAX_FILES,
|
|
37
|
+
O as TEXT_SEARCH_MAX_FILE_BYTES,
|
|
38
|
+
A as TEXT_SEARCH_MAX_LINE_CHARS,
|
|
39
|
+
s as TRANSFER_FILE_SIZE_LIMIT_MB,
|
|
40
|
+
F as TRANSFER_FUNCTION_CODES,
|
|
41
|
+
c as WORKSPACE_GRANT_ID,
|
|
42
|
+
D as WRITE_FUNCTION_CODES
|
|
47
43
|
};
|