@glodon-aiot/bot-client-sdk 3.26.0-alpha.21 → 3.26.0-alpha.24

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.
@@ -1,60 +1,108 @@
1
1
  var B = Object.defineProperty, M = Object.defineProperties;
2
2
  var U = Object.getOwnPropertyDescriptors;
3
- var v = Object.getOwnPropertySymbols;
4
- var _ = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable;
5
- var S = (a, t, e) => t in a ? B(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e, y = (a, t) => {
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
6
  for (var e in t || (t = {}))
7
- _.call(t, e) && S(a, e, t[e]);
8
- if (v)
9
- for (var e of v(t))
10
- C.call(t, e) && S(a, e, t[e]);
11
- return a;
12
- }, N = (a, t) => M(a, U(t));
13
- var w = (a, t, e) => (S(a, typeof t != "symbol" ? t + "" : t, e), e);
14
- var u = (a, t, e) => new Promise((s, r) => {
15
- var i = (o) => {
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
16
  try {
17
- l(e.next(o));
17
+ l(e.next(a));
18
18
  } catch (h) {
19
- r(h);
19
+ s(h);
20
20
  }
21
- }, n = (o) => {
21
+ }, i = (a) => {
22
22
  try {
23
- l(e.throw(o));
23
+ l(e.throw(a));
24
24
  } catch (h) {
25
- r(h);
25
+ s(h);
26
26
  }
27
- }, l = (o) => o.done ? s(o.value) : Promise.resolve(o.value).then(i, n);
28
- l((e = e.apply(a, t)).next());
27
+ }, l = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(o, i);
28
+ l((e = e.apply(n, t)).next());
29
29
  });
30
- import { MAX_COMMAND_OUTPUT_CHARS as m } from "../../builtinTools/command.mjs";
30
+ import { MAX_COMMAND_OUTPUT_CHARS as w } from "../../builtinTools/command.mjs";
31
31
  import { domError as f } from "../adapters/WorkspaceFileAdapter.mjs";
32
- import { SANDBOX_PROTOCOL as A, SANDBOX_MAX_FILE_BYTES as T } from "./protocol.mjs";
33
- import { decodeBinaryFrame as E, MAX_BINARY_PAYLOAD as x, encodeBinaryFrame as O } from "./sandboxFrames.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
+ }
34
80
  const k = "沙箱已退出。";
35
- function b(a) {
36
- if (a instanceof Uint8Array)
37
- return a;
38
- if (a instanceof ArrayBuffer)
39
- return new Uint8Array(a);
81
+ function E(n) {
82
+ if (n instanceof Uint8Array)
83
+ return n;
84
+ if (n instanceof ArrayBuffer)
85
+ return new Uint8Array(n);
40
86
  }
41
- function P(a, t, e, s) {
42
- const r = a.length > m ? a.slice(a.length - m) : a;
43
- if (!t && !e && !s && a.length <= m)
44
- return r;
45
- let i = `
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 = `
46
92
  …输出已截断`;
47
- return e && (i += `,完整输出见 ${e}`), s && (i += ",日志已截断"), r + i;
93
+ return e && (o += `,完整输出见 ${e}`), r && (o += ",日志已截断"), s + o;
48
94
  }
49
- class R {
95
+ class J {
50
96
  constructor(t = (e) => new WebSocket(e)) {
51
- w(this, "notice");
52
- w(this, "socket");
53
- w(this, "generation", 0);
54
- w(this, "authed", !1);
55
- w(this, "seq", 0);
56
- w(this, "calls", /* @__PURE__ */ new Map());
57
- w(this, "outgoing", []);
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", []);
58
106
  this.openSocket = t;
59
107
  }
60
108
  get ready() {
@@ -62,8 +110,8 @@ class R {
62
110
  return (t == null ? void 0 : t.state) === "ready" && t.protocol === A && !!(t.url && t.token);
63
111
  }
64
112
  unavailableMessage() {
65
- var t, e, s, r;
66
- return ((t = this.notice) == null ? void 0 : t.state) === "starting" ? "沙箱正在启动。" : (e = this.notice) != null && e.message ? this.notice.message : ((s = this.notice) == null ? void 0 : s.state) === "exited" || ((r = this.notice) == null ? void 0 : r.state) === "failed" ? k : "沙箱没有就绪。";
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 : "沙箱没有就绪。";
67
115
  }
68
116
  apply(t) {
69
117
  const e = this.notice;
@@ -89,13 +137,13 @@ class R {
89
137
  }
90
138
  url(t) {
91
139
  return u(this, null, function* () {
92
- const s = (yield this.invoke({
140
+ const r = (yield this.invoke({
93
141
  op: "url",
94
142
  path: t
95
143
  })).ticket;
96
- if (typeof s != "string" || !/^[a-f0-9]{32}$/.test(s))
144
+ if (typeof r != "string" || !/^[a-f0-9]{32}$/.test(r))
97
145
  throw f("NotAllowedError", "地址无效。");
98
- return s;
146
+ return r;
99
147
  });
100
148
  }
101
149
  releaseUrl(t) {
@@ -114,125 +162,125 @@ class R {
114
162
  }, e);
115
163
  });
116
164
  }
117
- read(i) {
118
- return u(this, arguments, function* (t, e = 0, s = T, r) {
119
- const n = this.begin({
165
+ read(o) {
166
+ return u(this, arguments, function* (t, e = 0, r = L, s) {
167
+ const i = this.begin({
120
168
  op: "read",
121
169
  path: t,
122
170
  offset: e,
123
- maxBytes: s
124
- }, r), l = [];
125
- let o;
126
- for (; !o; ) {
127
- const d = yield this.next(n), p = b(d);
128
- if (p) {
129
- l.push(E(p).payload);
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);
130
178
  continue;
131
179
  }
132
- o = d;
180
+ a = d;
133
181
  }
134
- if (this.calls.delete(n), o.ok === !1)
135
- throw f(String(o.name || "NotAllowedError"), String(o.message || "读取失败。"));
136
- const h = l.reduce((d, p) => d + p.length, 0), c = new Uint8Array(h);
137
- let g = 0;
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;
138
186
  return l.forEach((d) => {
139
- c.set(d, g), g += d.length;
187
+ c.set(d, p), p += d.length;
140
188
  }), c;
141
189
  });
142
190
  }
143
- write(t, e, s, r) {
191
+ write(t, e, r, s) {
144
192
  return u(this, null, function* () {
145
- const i = this.begin({
193
+ const o = this.begin({
146
194
  op: "write",
147
195
  path: t,
148
196
  size: e.length,
149
- createDirectories: s
150
- }, r);
151
- let n = 0;
152
- for (; n < e.length; ) {
153
- const o = e.subarray(n, n + x), h = n + o.length;
154
- this.send(O(i, n, h === e.length, o)), n = h;
155
- const g = yield this.next(i);
156
- if (g.ok === !1)
157
- throw this.calls.delete(i), f(String(g.name || "NotAllowedError"), String(g.message || "写入失败。"));
158
- if (g.op !== "ack" && g.ok === !0) {
159
- this.calls.delete(i);
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);
160
208
  return;
161
209
  }
162
210
  }
163
- const l = yield this.next(i);
164
- if (this.calls.delete(i), l.ok === !1)
211
+ const l = yield this.next(o);
212
+ if (this.calls.delete(o), l.ok === !1)
165
213
  throw f(String(l.name || "NotAllowedError"), String(l.message || "写入失败。"));
166
214
  });
167
215
  }
168
216
  skillStatus(t, e) {
169
217
  return u(this, null, function* () {
170
- const s = yield this.invoke({
218
+ const r = yield this.invoke({
171
219
  op: "skillStatus",
172
220
  applicationId: t
173
221
  }, e);
174
- return Array.isArray(s.skills) ? s.skills : [];
222
+ return Array.isArray(r.skills) ? r.skills : [];
175
223
  });
176
224
  }
177
- skillRead(t, e, s, r, i) {
225
+ skillRead(t, e, r, s, o) {
178
226
  return u(this, null, function* () {
179
- const n = this.begin({
227
+ const i = this.begin({
180
228
  op: "skillRead",
181
229
  applicationId: t,
182
230
  skillId: e,
183
- version: s,
184
- path: r
185
- }, i), l = [];
186
- let o;
187
- for (; !o; ) {
188
- const d = yield this.next(n), p = b(d);
189
- if (p) {
190
- l.push(E(p).payload);
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);
191
239
  continue;
192
240
  }
193
- o = d;
241
+ a = d;
194
242
  }
195
- if (this.calls.delete(n), o.ok === !1)
196
- throw f(String(o.name || "NotAllowedError"), String(o.message || "读取失败。"));
197
- const h = l.reduce((d, p) => d + p.length, 0), c = new Uint8Array(h);
198
- let g = 0;
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;
199
247
  return l.forEach((d) => {
200
- c.set(d, g), g += d.length;
248
+ c.set(d, p), p += d.length;
201
249
  }), c;
202
250
  });
203
251
  }
204
- installSkill(t, e, s) {
252
+ installSkill(t, e, r) {
205
253
  return u(this, null, function* () {
206
- const r = this.begin(N(y({
254
+ const s = this.begin(N(m({
207
255
  op: "installSkill"
208
256
  }, t), {
209
257
  size: e.length
210
- }), s);
211
- let i = 0;
212
- for (; i < e.length; ) {
213
- const l = e.subarray(i, i + x), o = i + l.length;
214
- this.send(O(r, i, o === e.length, l)), i = o;
215
- const h = yield this.next(r);
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);
216
264
  if (h.ok === !1)
217
- throw this.calls.delete(r), f(String(h.name || "NotAllowedError"), String(h.message || "安装失败。"));
265
+ throw this.calls.delete(s), f(String(h.name || "NotAllowedError"), String(h.message || "安装失败。"));
218
266
  if (h.op !== "ack" && h.ok === !0) {
219
- this.calls.delete(r);
267
+ this.calls.delete(s);
220
268
  return;
221
269
  }
222
270
  }
223
- const n = yield this.next(r);
224
- if (this.calls.delete(r), n.ok === !1)
225
- throw f(String(n.name || "NotAllowedError"), String(n.message || "安装失败。"));
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 || "安装失败。"));
226
274
  });
227
275
  }
228
- skillPrune(t, e, s, r) {
276
+ skillPrune(t, e, r, s) {
229
277
  return u(this, null, function* () {
230
278
  yield this.invoke({
231
279
  op: "skillPrune",
232
280
  applicationId: t,
233
281
  keep: e,
234
- busy: s
235
- }, r);
282
+ busy: r
283
+ }, s);
236
284
  });
237
285
  }
238
286
  mkdir(t) {
@@ -261,144 +309,151 @@ class R {
261
309
  });
262
310
  });
263
311
  }
264
- exec(t, e, s) {
312
+ exec(t, e, r) {
265
313
  return u(this, null, function* () {
266
314
  var h;
267
- const r = this.begin(y({}, t), e, () => {
315
+ const s = this.begin(m({}, t), e, () => {
268
316
  this.send({
269
317
  protocol: A,
270
- id: r,
318
+ id: s,
271
319
  op: "cancel"
272
320
  });
273
321
  });
274
- let i = "", n = "", l = !1, o = !1;
275
- for (; this.calls.has(r); ) {
276
- const c = yield this.next(r);
322
+ let o = "", i = "", l = !1, a = !1;
323
+ for (; this.calls.has(s); ) {
324
+ const c = yield this.next(s);
277
325
  if (c.op === "stdout" || c.op === "stderr") {
278
- const p = String((h = c.text) != null ? h : "");
279
- s == null || s(c.op, p), c.op === "stdout" ? (i += p, i.length > m && (l = !0), i = i.slice(-m)) : (n += p, n.length > m && (o = !0), n = n.slice(-m));
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));
280
328
  continue;
281
329
  }
282
- if (this.calls.delete(r), c.ok === !1)
330
+ if (this.calls.delete(s), c.ok === !1)
283
331
  throw f(String(c.name || "NotAllowedError"), String(c.message || "命令失败。"));
284
- const g = typeof c.logPath == "string" ? c.logPath : void 0, d = c.logTruncated === !0;
285
- return {
332
+ const p = typeof c.logPath == "string" ? c.logPath : void 0, d = c.logTruncated === !0, g = $(c.network);
333
+ return m({
286
334
  exitCode: typeof c.exitCode == "number" ? c.exitCode : 1,
287
335
  timedOut: c.timedOut === !0,
288
- stdout: P(i, l, g, d),
289
- stderr: P(n, o, g, d),
336
+ stdout: j(o, l, p, d),
337
+ stderr: D(j(i, a, p, d), g),
290
338
  cwd: typeof c.cwd == "string" ? c.cwd : void 0
291
- };
339
+ }, g.length ? {
340
+ denied: g
341
+ } : {});
292
342
  }
293
343
  throw f("AbortError", k);
294
344
  });
295
345
  }
296
346
  invoke(t, e) {
297
- const s = this.begin(t, e);
298
- return this.next(s).then((r) => {
299
- this.calls.delete(s);
300
- const i = r;
301
- if (i.ok === !1)
302
- throw f(String(i.name || "NotAllowedError"), String(i.message || "请求失败。"));
303
- return i;
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;
304
354
  });
305
355
  }
306
- begin(t, e, s) {
356
+ begin(t, e, r) {
307
357
  if (!this.ready)
308
358
  throw f("NotAllowedError", this.unavailableMessage());
309
359
  if (e != null && e.aborted)
310
360
  throw f("AbortError");
311
- const r = `sbx-${++this.seq}`;
312
- let i = () => {
361
+ const s = `sbx-${++this.seq}`;
362
+ let o = () => {
313
363
  };
314
- const n = {
364
+ const i = {
315
365
  messages: [],
316
366
  waiters: [],
317
- reject: (o) => i(o)
367
+ reject: (a) => o(a)
318
368
  };
319
- this.calls.set(r, n);
369
+ this.calls.set(s, i);
320
370
  const l = () => {
321
- s == null || s(), n.reject(f("AbortError"));
371
+ r == null || r(), i.reject(f("AbortError"));
322
372
  };
323
373
  return e == null || e.addEventListener("abort", l, {
324
374
  once: !0
325
- }), i = (o) => {
326
- e == null || e.removeEventListener("abort", l), this.calls.delete(r);
327
- const h = n.waiters.shift();
328
- h && h(Promise.reject(o));
329
- }, this.send(y({
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({
330
380
  protocol: A,
331
- id: r
332
- }, t)), r;
381
+ id: s
382
+ }, t)), s;
333
383
  }
334
384
  next(t) {
335
385
  const e = this.calls.get(t);
336
386
  if (!e)
337
387
  return Promise.reject(f("AbortError", k));
338
- const s = e.messages.shift();
339
- return s !== void 0 ? Promise.resolve(s) : new Promise((r, i) => {
340
- e.waiters.push(r), e.reject = (n) => {
341
- this.calls.delete(t), i(n);
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);
342
392
  };
343
393
  });
344
394
  }
345
395
  send(t) {
346
- var s;
396
+ var r;
347
397
  const e = () => {
348
- var i;
349
- const r = t instanceof Uint8Array ? t : JSON.stringify(t);
350
- (i = this.socket) == null || i.send(r);
398
+ var o;
399
+ const s = t instanceof Uint8Array ? t : JSON.stringify(t);
400
+ (o = this.socket) == null || o.send(s);
351
401
  };
352
- this.authed && ((s = this.socket) == null ? void 0 : s.readyState) === 1 ? e() : this.outgoing.push(e);
402
+ this.authed && ((r = this.socket) == null ? void 0 : r.readyState) === 1 ? e() : this.outgoing.push(e);
353
403
  }
354
404
  connect(t, e) {
355
- const s = ++this.generation, r = this.openSocket(t);
356
- this.socket = r, this.authed = !1, r.binaryType = "arraybuffer", r.onopen = () => {
357
- s === this.generation && r.send(JSON.stringify({
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({
358
408
  protocol: A,
359
409
  op: "auth",
360
410
  token: e
361
411
  }));
362
- }, r.onmessage = (i) => {
363
- s === this.generation && this.onFrame(i.data);
364
- }, r.onclose = () => {
365
- s === this.generation && (this.authed = !1, this.failAll(f("AbortError", k)));
366
- }, r.onerror = () => {
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 = () => {
367
417
  };
368
418
  }
369
419
  onFrame(t) {
370
- const e = b(t);
420
+ var s, o;
421
+ const e = E(t);
371
422
  if (e) {
372
- const r = E(e);
373
- this.push(r.id, e);
423
+ const i = v(e);
424
+ this.push(i.id, e);
374
425
  return;
375
426
  }
376
- let s;
427
+ let r;
377
428
  try {
378
- s = JSON.parse(String(t));
379
- } catch (r) {
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;
380
435
  return;
381
436
  }
382
- if (s.op === "auth") {
383
- if (s.ok === !0) {
384
- this.authed = !0;
385
- const r = this.outgoing;
386
- this.outgoing = [], r.forEach((i) => i());
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());
387
442
  }
388
443
  return;
389
444
  }
390
- if (s.op === "bye") {
445
+ if (r.op === "bye") {
391
446
  this.failAll(f("AbortError", k)), this.stop();
392
447
  return;
393
448
  }
394
- typeof s.id == "string" && this.push(s.id, s);
449
+ typeof r.id == "string" && this.push(r.id, r);
395
450
  }
396
451
  push(t, e) {
397
- const s = this.calls.get(t);
398
- if (!s)
452
+ const r = this.calls.get(t);
453
+ if (!r)
399
454
  return;
400
- const r = s.waiters.shift();
401
- r ? r(e) : s.messages.push(e);
455
+ const s = r.waiters.shift();
456
+ s ? s(e) : r.messages.push(e);
402
457
  }
403
458
  failAll(t) {
404
459
  for (const e of this.calls.values())
@@ -416,5 +471,6 @@ class R {
416
471
  }
417
472
  }
418
473
  export {
419
- R as SandboxClient
474
+ P as OFFLINE_POLICY,
475
+ J as SandboxClient
420
476
  };