@glodon-aiot/bot-client-sdk 3.26.0-alpha.23 → 3.26.0-alpha.26

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.
Files changed (83) hide show
  1. package/README.md +180 -130
  2. package/dist/es/AgentSession.mjs +148 -129
  3. package/dist/es/BotClient.mjs +154 -136
  4. package/dist/es/Config.mjs +56 -89
  5. package/dist/es/Session.mjs +35 -23
  6. package/dist/es/builtinTools/browserRuntime/BrowserCommandRunner.mjs +201 -0
  7. package/dist/es/builtinTools/browserRuntime/PythonRunner.mjs +356 -0
  8. package/dist/es/builtinTools/browserRuntime/WorkspaceBashFs.mjs +350 -0
  9. package/dist/es/builtinTools/browserRuntime/assets.mjs +9 -0
  10. package/dist/es/builtinTools/browserRuntime/loadBash.mjs +17 -0
  11. package/dist/es/builtinTools/browserRuntime/pyodideRunner.py.mjs +96 -0
  12. package/dist/es/builtinTools/browserRuntime/pyodideWorker.mjs +242 -0
  13. package/dist/es/builtinTools/command.mjs +56 -0
  14. package/dist/es/builtinTools/constants.mjs +10 -0
  15. package/dist/es/builtinTools/createBuiltinToolsPlugin.mjs +262 -0
  16. package/dist/es/builtinTools/overview.mjs +77 -0
  17. package/dist/es/builtinTools/paths.mjs +69 -0
  18. package/dist/es/builtinTools/platformSkills.mjs +210 -0
  19. package/dist/es/builtinTools/schemas.mjs +216 -0
  20. package/dist/es/builtinTools/tools.mjs +494 -0
  21. package/dist/es/index.mjs +66 -64
  22. package/dist/es/localFiles/adapters/FileSnapshotAdapter.mjs +160 -0
  23. package/dist/es/localFiles/adapters/FileSystemAccessAdapter.mjs +185 -113
  24. package/dist/es/localFiles/adapters/HostBridgeAdapter.mjs +127 -137
  25. package/dist/es/localFiles/adapters/MemoryWorkspaceAdapter.mjs +132 -97
  26. package/dist/es/localFiles/adapters/WorkspaceFileAdapter.mjs +32 -28
  27. package/dist/es/localFiles/constants.mjs +24 -29
  28. package/dist/es/localFiles/errors.mjs +21 -19
  29. package/dist/es/localFiles/host/connectHostBridge.mjs +37 -34
  30. package/dist/es/localFiles/host/protocol.mjs +27 -13
  31. package/dist/es/localFiles/host/sandboxClient.mjs +476 -0
  32. package/dist/es/localFiles/host/sandboxFrames.mjs +21 -0
  33. package/dist/es/localFiles/preview.mjs +33 -0
  34. package/dist/es/localFiles/schemas.mjs +40 -86
  35. package/dist/es/localFiles/validate.mjs +37 -37
  36. package/dist/es/localFiles/workspace/LocalWorkspace.mjs +167 -86
  37. package/dist/es/localFiles/workspace/WorkspaceFiles.mjs +246 -0
  38. package/dist/es/localMcp/client.mjs +223 -0
  39. package/dist/es/localMcp/register.mjs +155 -0
  40. package/dist/es/localMcp/registry.mjs +39 -0
  41. package/dist/es/package.json.mjs +38 -29
  42. package/dist/es/sessionUpload.mjs +49 -0
  43. package/dist/lib/index.js +379 -10
  44. package/dist/src/AgentSession.d.ts +2 -0
  45. package/dist/src/Config.d.ts +5 -7
  46. package/dist/src/Session.d.ts +6 -0
  47. package/dist/src/builtinTools/browserRuntime/BrowserCommandRunner.d.ts +26 -0
  48. package/dist/src/builtinTools/browserRuntime/PythonRunner.d.ts +67 -0
  49. package/dist/src/builtinTools/browserRuntime/WorkspaceBashFs.d.ts +51 -0
  50. package/dist/src/builtinTools/browserRuntime/assets.d.ts +13 -0
  51. package/dist/src/builtinTools/browserRuntime/loadBash.d.ts +3 -0
  52. package/dist/src/builtinTools/browserRuntime/pyodideWorker.d.ts +44 -0
  53. package/dist/src/builtinTools/command.d.ts +35 -0
  54. package/dist/src/builtinTools/constants.d.ts +17 -0
  55. package/dist/src/builtinTools/createBuiltinToolsPlugin.d.ts +11 -0
  56. package/dist/src/builtinTools/overview.d.ts +5 -0
  57. package/dist/src/builtinTools/paths.d.ts +16 -0
  58. package/dist/src/builtinTools/platformSkills.d.ts +67 -0
  59. package/dist/src/builtinTools/schemas.d.ts +3 -0
  60. package/dist/src/builtinTools/tools.d.ts +64 -0
  61. package/dist/src/index.d.ts +2 -1
  62. package/dist/src/localFiles/adapters/FileSnapshotAdapter.d.ts +24 -0
  63. package/dist/src/localFiles/adapters/FileSystemAccessAdapter.d.ts +4 -1
  64. package/dist/src/localFiles/adapters/HostBridgeAdapter.d.ts +30 -14
  65. package/dist/src/localFiles/adapters/MemoryWorkspaceAdapter.d.ts +4 -1
  66. package/dist/src/localFiles/adapters/WorkspaceFileAdapter.d.ts +22 -0
  67. package/dist/src/localFiles/adapters/fsaTypes.d.ts +2 -0
  68. package/dist/src/localFiles/constants.d.ts +3 -13
  69. package/dist/src/localFiles/host/protocol.d.ts +34 -16
  70. package/dist/src/localFiles/host/sandboxClient.d.ts +104 -0
  71. package/dist/src/localFiles/host/sandboxFrames.d.ts +9 -0
  72. package/dist/src/localFiles/index.d.ts +11 -6
  73. package/dist/src/localFiles/preview.d.ts +2 -0
  74. package/dist/src/localFiles/schemas.d.ts +2 -5
  75. package/dist/src/localFiles/types.d.ts +16 -23
  76. package/dist/src/localFiles/workspace/LocalWorkspace.d.ts +35 -1
  77. package/dist/src/localFiles/workspace/WorkspaceFiles.d.ts +63 -0
  78. package/dist/src/localMcp/client.d.ts +11 -0
  79. package/dist/src/localMcp/register.d.ts +32 -0
  80. package/dist/src/localMcp/registry.d.ts +26 -0
  81. package/dist/src/sessionUpload.d.ts +14 -0
  82. package/package.json +13 -4
  83. package/dist/es/localFiles/createLocalPythonPlugin.mjs +0 -196
@@ -0,0 +1,476 @@
1
+ var B = Object.defineProperty, M = Object.defineProperties;
2
+ var U = Object.getOwnPropertyDescriptors;
3
+ var x = Object.getOwnPropertySymbols;
4
+ var T = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
5
+ var b = (n, t, e) => t in n ? B(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, m = (n, t) => {
6
+ for (var e in t || (t = {}))
7
+ T.call(t, e) && b(n, e, t[e]);
8
+ if (x)
9
+ for (var e of x(t))
10
+ F.call(t, e) && b(n, e, t[e]);
11
+ return n;
12
+ }, N = (n, t) => M(n, U(t));
13
+ var y = (n, t, e) => (b(n, typeof t != "symbol" ? t + "" : t, e), e);
14
+ var u = (n, t, e) => new Promise((r, s) => {
15
+ var o = (a) => {
16
+ try {
17
+ l(e.next(a));
18
+ } catch (h) {
19
+ s(h);
20
+ }
21
+ }, i = (a) => {
22
+ try {
23
+ l(e.throw(a));
24
+ } catch (h) {
25
+ s(h);
26
+ }
27
+ }, l = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(o, i);
28
+ l((e = e.apply(n, t)).next());
29
+ });
30
+ import { MAX_COMMAND_OUTPUT_CHARS as w } from "../../builtinTools/command.mjs";
31
+ import { domError as f } from "../adapters/WorkspaceFileAdapter.mjs";
32
+ import { SANDBOX_PROTOCOL as A, SANDBOX_MAX_FILE_BYTES as L } from "./protocol.mjs";
33
+ import { decodeBinaryFrame as v, MAX_BINARY_PAYLOAD as C, encodeBinaryFrame as O } from "./sandboxFrames.mjs";
34
+ const P = {
35
+ revision: 0,
36
+ network: {
37
+ mode: "off",
38
+ allow: []
39
+ },
40
+ packages: {
41
+ python: {
42
+ enabled: !0
43
+ }
44
+ }
45
+ };
46
+ function _(n) {
47
+ var r, s, o, i, l, a, h;
48
+ if (!n || typeof n != "object")
49
+ return;
50
+ const t = n, e = (r = t.network) == null ? void 0 : r.mode;
51
+ if (!(e !== "off" && e !== "allowlist" && e !== "open"))
52
+ return m({
53
+ revision: typeof t.revision == "number" ? t.revision : 0,
54
+ network: {
55
+ mode: e,
56
+ allow: Array.isArray((s = t.network) == null ? void 0 : s.allow) ? t.network.allow.filter((c) => typeof c == "string") : []
57
+ },
58
+ packages: {
59
+ python: {
60
+ enabled: ((i = (o = t.packages) == null ? void 0 : o.python) == null ? void 0 : i.enabled) !== !1
61
+ }
62
+ }
63
+ }, Number.isInteger((l = t.exec) == null ? void 0 : l.maxConcurrent) && ((a = t.exec) == null ? void 0 : a.maxConcurrent) >= 1 ? {
64
+ exec: {
65
+ maxConcurrent: (h = t.exec) == null ? void 0 : h.maxConcurrent
66
+ }
67
+ } : {});
68
+ }
69
+ function $(n) {
70
+ const t = n == null ? void 0 : n.denied;
71
+ return Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
72
+ }
73
+ function D(n, t) {
74
+ if (!t.length)
75
+ return n;
76
+ const e = `宿主网络策略拒绝了:${t.join("、")}。不要重试这些地址;需要时请用户在宿主设置里允许。`;
77
+ return n ? `${n}
78
+ ${e}` : e;
79
+ }
80
+ const k = "沙箱已退出。";
81
+ function E(n) {
82
+ if (n instanceof Uint8Array)
83
+ return n;
84
+ if (n instanceof ArrayBuffer)
85
+ return new Uint8Array(n);
86
+ }
87
+ function j(n, t, e, r) {
88
+ const s = n.length > w ? n.slice(n.length - w) : n;
89
+ if (!t && !e && !r && n.length <= w)
90
+ return s;
91
+ let o = `
92
+ …输出已截断`;
93
+ return e && (o += `,完整输出见 ${e}`), r && (o += ",日志已截断"), s + o;
94
+ }
95
+ class J {
96
+ constructor(t = (e) => new WebSocket(e)) {
97
+ y(this, "notice");
98
+ /** 沙箱最近一次告知的网络策略。 */
99
+ y(this, "policy", P);
100
+ y(this, "socket");
101
+ y(this, "generation", 0);
102
+ y(this, "authed", !1);
103
+ y(this, "seq", 0);
104
+ y(this, "calls", /* @__PURE__ */ new Map());
105
+ y(this, "outgoing", []);
106
+ this.openSocket = t;
107
+ }
108
+ get ready() {
109
+ const t = this.notice;
110
+ return (t == null ? void 0 : t.state) === "ready" && t.protocol === A && !!(t.url && t.token);
111
+ }
112
+ unavailableMessage() {
113
+ var t, e, r, s;
114
+ return ((t = this.notice) == null ? void 0 : t.state) === "starting" ? "沙箱正在启动。" : (e = this.notice) != null && e.message ? this.notice.message : ((r = this.notice) == null ? void 0 : r.state) === "exited" || ((s = this.notice) == null ? void 0 : s.state) === "failed" ? k : "沙箱没有就绪。";
115
+ }
116
+ apply(t) {
117
+ const e = this.notice;
118
+ if (this.notice = t, !this.ready || !(t != null && t.url) || !t.token) {
119
+ this.failAll(f("NotAllowedError", this.unavailableMessage())), this.stop();
120
+ return;
121
+ }
122
+ (e == null ? void 0 : e.url) === t.url && e.token === t.token && this.socket && this.socket.readyState <= 1 || (this.failAll(f("AbortError", k)), this.stop(), this.connect(t.url, t.token));
123
+ }
124
+ /** `ws://127.0.0.1:port` 的主机和端口,文件地址拼在它前面。 */
125
+ httpOrigin() {
126
+ var e;
127
+ const t = (e = this.notice) == null ? void 0 : e.url;
128
+ return t != null && t.startsWith("ws://") ? t.slice(5).replace(/\/$/, "") : "";
129
+ }
130
+ stat(t) {
131
+ return u(this, null, function* () {
132
+ return this.invoke({
133
+ op: "stat",
134
+ path: t
135
+ });
136
+ });
137
+ }
138
+ url(t) {
139
+ return u(this, null, function* () {
140
+ const r = (yield this.invoke({
141
+ op: "url",
142
+ path: t
143
+ })).ticket;
144
+ if (typeof r != "string" || !/^[a-f0-9]{32}$/.test(r))
145
+ throw f("NotAllowedError", "地址无效。");
146
+ return r;
147
+ });
148
+ }
149
+ releaseUrl(t) {
150
+ return u(this, null, function* () {
151
+ yield this.invoke({
152
+ op: "releaseUrl",
153
+ ticket: t
154
+ });
155
+ });
156
+ }
157
+ list(t, e) {
158
+ return u(this, null, function* () {
159
+ return this.invoke({
160
+ op: "list",
161
+ path: t
162
+ }, e);
163
+ });
164
+ }
165
+ read(o) {
166
+ return u(this, arguments, function* (t, e = 0, r = L, s) {
167
+ const i = this.begin({
168
+ op: "read",
169
+ path: t,
170
+ offset: e,
171
+ maxBytes: r
172
+ }, s), l = [];
173
+ let a;
174
+ for (; !a; ) {
175
+ const d = yield this.next(i), g = E(d);
176
+ if (g) {
177
+ l.push(v(g).payload);
178
+ continue;
179
+ }
180
+ a = d;
181
+ }
182
+ if (this.calls.delete(i), a.ok === !1)
183
+ throw f(String(a.name || "NotAllowedError"), String(a.message || "读取失败。"));
184
+ const h = l.reduce((d, g) => d + g.length, 0), c = new Uint8Array(h);
185
+ let p = 0;
186
+ return l.forEach((d) => {
187
+ c.set(d, p), p += d.length;
188
+ }), c;
189
+ });
190
+ }
191
+ write(t, e, r, s) {
192
+ return u(this, null, function* () {
193
+ const o = this.begin({
194
+ op: "write",
195
+ path: t,
196
+ size: e.length,
197
+ createDirectories: r
198
+ }, s);
199
+ let i = 0;
200
+ for (; i < e.length; ) {
201
+ const a = e.subarray(i, i + C), h = i + a.length;
202
+ this.send(O(o, i, h === e.length, a)), i = h;
203
+ const p = yield this.next(o);
204
+ if (p.ok === !1)
205
+ throw this.calls.delete(o), f(String(p.name || "NotAllowedError"), String(p.message || "写入失败。"));
206
+ if (p.op !== "ack" && p.ok === !0) {
207
+ this.calls.delete(o);
208
+ return;
209
+ }
210
+ }
211
+ const l = yield this.next(o);
212
+ if (this.calls.delete(o), l.ok === !1)
213
+ throw f(String(l.name || "NotAllowedError"), String(l.message || "写入失败。"));
214
+ });
215
+ }
216
+ skillStatus(t, e) {
217
+ return u(this, null, function* () {
218
+ const r = yield this.invoke({
219
+ op: "skillStatus",
220
+ applicationId: t
221
+ }, e);
222
+ return Array.isArray(r.skills) ? r.skills : [];
223
+ });
224
+ }
225
+ skillRead(t, e, r, s, o) {
226
+ return u(this, null, function* () {
227
+ const i = this.begin({
228
+ op: "skillRead",
229
+ applicationId: t,
230
+ skillId: e,
231
+ version: r,
232
+ path: s
233
+ }, o), l = [];
234
+ let a;
235
+ for (; !a; ) {
236
+ const d = yield this.next(i), g = E(d);
237
+ if (g) {
238
+ l.push(v(g).payload);
239
+ continue;
240
+ }
241
+ a = d;
242
+ }
243
+ if (this.calls.delete(i), a.ok === !1)
244
+ throw f(String(a.name || "NotAllowedError"), String(a.message || "读取失败。"));
245
+ const h = l.reduce((d, g) => d + g.length, 0), c = new Uint8Array(h);
246
+ let p = 0;
247
+ return l.forEach((d) => {
248
+ c.set(d, p), p += d.length;
249
+ }), c;
250
+ });
251
+ }
252
+ installSkill(t, e, r) {
253
+ return u(this, null, function* () {
254
+ const s = this.begin(N(m({
255
+ op: "installSkill"
256
+ }, t), {
257
+ size: e.length
258
+ }), r);
259
+ let o = 0;
260
+ for (; o < e.length; ) {
261
+ const l = e.subarray(o, o + C), a = o + l.length;
262
+ this.send(O(s, o, a === e.length, l)), o = a;
263
+ const h = yield this.next(s);
264
+ if (h.ok === !1)
265
+ throw this.calls.delete(s), f(String(h.name || "NotAllowedError"), String(h.message || "安装失败。"));
266
+ if (h.op !== "ack" && h.ok === !0) {
267
+ this.calls.delete(s);
268
+ return;
269
+ }
270
+ }
271
+ const i = yield this.next(s);
272
+ if (this.calls.delete(s), i.ok === !1)
273
+ throw f(String(i.name || "NotAllowedError"), String(i.message || "安装失败。"));
274
+ });
275
+ }
276
+ skillPrune(t, e, r, s) {
277
+ return u(this, null, function* () {
278
+ yield this.invoke({
279
+ op: "skillPrune",
280
+ applicationId: t,
281
+ keep: e,
282
+ busy: r
283
+ }, s);
284
+ });
285
+ }
286
+ mkdir(t) {
287
+ return u(this, null, function* () {
288
+ yield this.invoke({
289
+ op: "mkdir",
290
+ path: t
291
+ });
292
+ });
293
+ }
294
+ remove(t, e) {
295
+ return u(this, null, function* () {
296
+ yield this.invoke({
297
+ op: "remove",
298
+ path: t,
299
+ recursive: e
300
+ });
301
+ });
302
+ }
303
+ move(t, e) {
304
+ return u(this, null, function* () {
305
+ yield this.invoke({
306
+ op: "move",
307
+ from: t,
308
+ to: e
309
+ });
310
+ });
311
+ }
312
+ exec(t, e, r) {
313
+ return u(this, null, function* () {
314
+ var h;
315
+ const s = this.begin(m({}, t), e, () => {
316
+ this.send({
317
+ protocol: A,
318
+ id: s,
319
+ op: "cancel"
320
+ });
321
+ });
322
+ let o = "", i = "", l = !1, a = !1;
323
+ for (; this.calls.has(s); ) {
324
+ const c = yield this.next(s);
325
+ if (c.op === "stdout" || c.op === "stderr") {
326
+ const S = String((h = c.text) != null ? h : "");
327
+ r == null || r(c.op, S), c.op === "stdout" ? (o += S, o.length > w && (l = !0), o = o.slice(-w)) : (i += S, i.length > w && (a = !0), i = i.slice(-w));
328
+ continue;
329
+ }
330
+ if (this.calls.delete(s), c.ok === !1)
331
+ throw f(String(c.name || "NotAllowedError"), String(c.message || "命令失败。"));
332
+ const p = typeof c.logPath == "string" ? c.logPath : void 0, d = c.logTruncated === !0, g = $(c.network);
333
+ return m({
334
+ exitCode: typeof c.exitCode == "number" ? c.exitCode : 1,
335
+ timedOut: c.timedOut === !0,
336
+ stdout: j(o, l, p, d),
337
+ stderr: D(j(i, a, p, d), g),
338
+ cwd: typeof c.cwd == "string" ? c.cwd : void 0
339
+ }, g.length ? {
340
+ denied: g
341
+ } : {});
342
+ }
343
+ throw f("AbortError", k);
344
+ });
345
+ }
346
+ invoke(t, e) {
347
+ const r = this.begin(t, e);
348
+ return this.next(r).then((s) => {
349
+ this.calls.delete(r);
350
+ const o = s;
351
+ if (o.ok === !1)
352
+ throw f(String(o.name || "NotAllowedError"), String(o.message || "请求失败。"));
353
+ return o;
354
+ });
355
+ }
356
+ begin(t, e, r) {
357
+ if (!this.ready)
358
+ throw f("NotAllowedError", this.unavailableMessage());
359
+ if (e != null && e.aborted)
360
+ throw f("AbortError");
361
+ const s = `sbx-${++this.seq}`;
362
+ let o = () => {
363
+ };
364
+ const i = {
365
+ messages: [],
366
+ waiters: [],
367
+ reject: (a) => o(a)
368
+ };
369
+ this.calls.set(s, i);
370
+ const l = () => {
371
+ r == null || r(), i.reject(f("AbortError"));
372
+ };
373
+ return e == null || e.addEventListener("abort", l, {
374
+ once: !0
375
+ }), o = (a) => {
376
+ e == null || e.removeEventListener("abort", l), this.calls.delete(s);
377
+ const h = i.waiters.shift();
378
+ h && h(Promise.reject(a));
379
+ }, this.send(m({
380
+ protocol: A,
381
+ id: s
382
+ }, t)), s;
383
+ }
384
+ next(t) {
385
+ const e = this.calls.get(t);
386
+ if (!e)
387
+ return Promise.reject(f("AbortError", k));
388
+ const r = e.messages.shift();
389
+ return r !== void 0 ? Promise.resolve(r) : new Promise((s, o) => {
390
+ e.waiters.push(s), e.reject = (i) => {
391
+ this.calls.delete(t), o(i);
392
+ };
393
+ });
394
+ }
395
+ send(t) {
396
+ var r;
397
+ const e = () => {
398
+ var o;
399
+ const s = t instanceof Uint8Array ? t : JSON.stringify(t);
400
+ (o = this.socket) == null || o.send(s);
401
+ };
402
+ this.authed && ((r = this.socket) == null ? void 0 : r.readyState) === 1 ? e() : this.outgoing.push(e);
403
+ }
404
+ connect(t, e) {
405
+ const r = ++this.generation, s = this.openSocket(t);
406
+ this.socket = s, this.authed = !1, s.binaryType = "arraybuffer", s.onopen = () => {
407
+ r === this.generation && s.send(JSON.stringify({
408
+ protocol: A,
409
+ op: "auth",
410
+ token: e
411
+ }));
412
+ }, s.onmessage = (o) => {
413
+ r === this.generation && this.onFrame(o.data);
414
+ }, s.onclose = () => {
415
+ r === this.generation && (this.authed = !1, this.failAll(f("AbortError", k)));
416
+ }, s.onerror = () => {
417
+ };
418
+ }
419
+ onFrame(t) {
420
+ var s, o;
421
+ const e = E(t);
422
+ if (e) {
423
+ const i = v(e);
424
+ this.push(i.id, e);
425
+ return;
426
+ }
427
+ let r;
428
+ try {
429
+ r = JSON.parse(String(t));
430
+ } catch (i) {
431
+ return;
432
+ }
433
+ if (r.op === "policy" && r.id === void 0) {
434
+ this.policy = (s = _(r.policy)) != null ? s : this.policy;
435
+ return;
436
+ }
437
+ if (r.op === "auth") {
438
+ if (r.ok === !0) {
439
+ this.policy = (o = _(r.policy)) != null ? o : P, this.authed = !0;
440
+ const i = this.outgoing;
441
+ this.outgoing = [], i.forEach((l) => l());
442
+ }
443
+ return;
444
+ }
445
+ if (r.op === "bye") {
446
+ this.failAll(f("AbortError", k)), this.stop();
447
+ return;
448
+ }
449
+ typeof r.id == "string" && this.push(r.id, r);
450
+ }
451
+ push(t, e) {
452
+ const r = this.calls.get(t);
453
+ if (!r)
454
+ return;
455
+ const s = r.waiters.shift();
456
+ s ? s(e) : r.messages.push(e);
457
+ }
458
+ failAll(t) {
459
+ for (const e of this.calls.values())
460
+ e.reject(t);
461
+ this.calls.clear();
462
+ }
463
+ stop() {
464
+ this.generation += 1, this.authed = !1, this.outgoing = [];
465
+ const t = this.socket;
466
+ this.socket = void 0;
467
+ try {
468
+ t == null || t.close();
469
+ } catch (e) {
470
+ }
471
+ }
472
+ }
473
+ export {
474
+ P as OFFLINE_POLICY,
475
+ J as SandboxClient
476
+ };
@@ -0,0 +1,21 @@
1
+ const g = 1048576;
2
+ function f(e, o, c, n) {
3
+ const s = new TextEncoder().encode(e), t = new Uint8Array(4 + s.length + 8), i = new DataView(t.buffer);
4
+ i.setUint8(0, 1), i.setUint8(1, c ? 1 : 0), i.setUint16(2, s.length), t.set(s, 4), i.setBigUint64(4 + s.length, BigInt(o));
5
+ const r = new Uint8Array(t.length + n.length);
6
+ return r.set(t, 0), r.set(n, t.length), r;
7
+ }
8
+ function h(e) {
9
+ const o = new DataView(e.buffer, e.byteOffset, e.byteLength), n = 4 + o.getUint16(2), s = new TextDecoder().decode(e.subarray(4, n)), t = Number(o.getBigUint64(n)), i = (o.getUint8(1) & 1) === 1;
10
+ return {
11
+ id: s,
12
+ offset: t,
13
+ eof: i,
14
+ payload: e.subarray(n + 8)
15
+ };
16
+ }
17
+ export {
18
+ g as MAX_BINARY_PAYLOAD,
19
+ h as decodeBinaryFrame,
20
+ f as encodeBinaryFrame
21
+ };
@@ -0,0 +1,33 @@
1
+ const g = {
2
+ png: "image/png",
3
+ jpg: "image/jpeg",
4
+ jpeg: "image/jpeg",
5
+ gif: "image/gif",
6
+ webp: "image/webp",
7
+ bmp: "image/bmp",
8
+ avif: "image/avif",
9
+ ico: "image/x-icon",
10
+ svg: "image/svg+xml",
11
+ mp3: "audio/mpeg",
12
+ wav: "audio/wav",
13
+ ogg: "audio/ogg",
14
+ m4a: "audio/mp4",
15
+ aac: "audio/aac",
16
+ flac: "audio/flac",
17
+ mp4: "video/mp4",
18
+ webm: "video/webm",
19
+ mov: "video/quicktime",
20
+ m4v: "video/mp4",
21
+ ogv: "video/ogg",
22
+ pdf: "application/pdf"
23
+ }, m = "只能预览图片、音视频和 PDF。";
24
+ function p(o) {
25
+ var a;
26
+ const i = (a = o.split("/").pop()) != null ? a : "", e = i.lastIndexOf(".");
27
+ if (!(e <= 0))
28
+ return g[i.slice(e + 1).toLowerCase()];
29
+ }
30
+ export {
31
+ m as PREVIEW_TYPE_MESSAGE,
32
+ p as mediaTypeOf
33
+ };