@ai-ecoverse/slicc-kernel 1.44.0 → 1.45.0
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 +1 -0
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +193 -62
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +168 -16
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +223 -92
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +168 -16
- package/dist/process-worker.js.map +4 -4
- package/package.json +2 -2
package/dist/kernel-worker.js
CHANGED
|
@@ -1920,8 +1920,8 @@ function serveSocket(socket, port, onClose) {
|
|
|
1920
1920
|
let writes = Promise.resolve();
|
|
1921
1921
|
let credit = 0;
|
|
1922
1922
|
let granted2;
|
|
1923
|
-
const send = (
|
|
1924
|
-
if (!closed) port.postMessage(
|
|
1923
|
+
const send = (message3, transfer) => {
|
|
1924
|
+
if (!closed) port.postMessage(message3, transfer);
|
|
1925
1925
|
};
|
|
1926
1926
|
const close = (reset = false) => {
|
|
1927
1927
|
if (closed) return;
|
|
@@ -2036,8 +2036,8 @@ var BODY_IDLE_MS = 5 * 60 * 1e3;
|
|
|
2036
2036
|
var INBOUND_LIMIT = 16 * 1024 * 1024;
|
|
2037
2037
|
var MESSAGE_LIMIT = 64 * 1024 * 1024;
|
|
2038
2038
|
var TOO_BIG = 1009;
|
|
2039
|
-
function payloadSize(
|
|
2040
|
-
return typeof
|
|
2039
|
+
function payloadSize(message3) {
|
|
2040
|
+
return typeof message3 === "string" ? new TextEncoder().encode(message3).length : message3.length;
|
|
2041
2041
|
}
|
|
2042
2042
|
var MessageQueue = class {
|
|
2043
2043
|
items = [];
|
|
@@ -2057,9 +2057,9 @@ var MessageQueue = class {
|
|
|
2057
2057
|
this.settle = resolve;
|
|
2058
2058
|
});
|
|
2059
2059
|
}
|
|
2060
|
-
push(
|
|
2060
|
+
push(message3) {
|
|
2061
2061
|
if (this.ended) return;
|
|
2062
|
-
const size = payloadSize(
|
|
2062
|
+
const size = payloadSize(message3);
|
|
2063
2063
|
const huge = size > MESSAGE_LIMIT;
|
|
2064
2064
|
if (huge || this.items.length > 0 && this.size + size > this.limit) {
|
|
2065
2065
|
const reason = huge ? `a message is over ${MESSAGE_LIMIT} bytes` : `over ${this.limit} bytes of messages are waiting`;
|
|
@@ -2068,7 +2068,7 @@ var MessageQueue = class {
|
|
|
2068
2068
|
return;
|
|
2069
2069
|
}
|
|
2070
2070
|
this.size += size;
|
|
2071
|
-
this.items.push(
|
|
2071
|
+
this.items.push(message3);
|
|
2072
2072
|
this.wake();
|
|
2073
2073
|
}
|
|
2074
2074
|
end(close) {
|
|
@@ -2107,7 +2107,7 @@ var NO_WEBSOCKET = "WebSocket not supported by this transport (fetchTransport ne
|
|
|
2107
2107
|
var MAX_REQUEST_BODY = 64 * 1024 * 1024;
|
|
2108
2108
|
function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
|
|
2109
2109
|
const open = /* @__PURE__ */ new Map();
|
|
2110
|
-
const
|
|
2110
|
+
const fail2 = (nid, e) => {
|
|
2111
2111
|
open.delete(nid);
|
|
2112
2112
|
const { status, code } = e;
|
|
2113
2113
|
peer.postMessage({
|
|
@@ -2143,7 +2143,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
|
|
|
2143
2143
|
headers: response.headers
|
|
2144
2144
|
});
|
|
2145
2145
|
} catch (e) {
|
|
2146
|
-
|
|
2146
|
+
fail2(call.nid, e);
|
|
2147
2147
|
}
|
|
2148
2148
|
};
|
|
2149
2149
|
const sockets = /* @__PURE__ */ new Map();
|
|
@@ -2177,7 +2177,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
|
|
|
2177
2177
|
peer.postMessage({ net: "ws-opened", nid: call.nid, protocol: socket.protocol });
|
|
2178
2178
|
void relay(call.nid, socket);
|
|
2179
2179
|
} catch (e) {
|
|
2180
|
-
|
|
2180
|
+
fail2(call.nid, e);
|
|
2181
2181
|
}
|
|
2182
2182
|
};
|
|
2183
2183
|
const relay = async (nid, socket) => {
|
|
@@ -2249,7 +2249,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
|
|
|
2249
2249
|
peer.postMessage({ net: "chunk", nid, bytes }, [bytes.buffer]);
|
|
2250
2250
|
}
|
|
2251
2251
|
} catch (e) {
|
|
2252
|
-
|
|
2252
|
+
fail2(nid, e);
|
|
2253
2253
|
}
|
|
2254
2254
|
};
|
|
2255
2255
|
const drop = (nid) => {
|
|
@@ -2726,8 +2726,8 @@ function serveClient(port, host) {
|
|
|
2726
2726
|
const watches = /* @__PURE__ */ new Map();
|
|
2727
2727
|
let net;
|
|
2728
2728
|
const ended = Promise.withResolvers();
|
|
2729
|
-
const send = (
|
|
2730
|
-
if (state !== "closed") port.postMessage(
|
|
2729
|
+
const send = (message3, transfer = []) => {
|
|
2730
|
+
if (state !== "closed") port.postMessage(message3, transfer);
|
|
2731
2731
|
};
|
|
2732
2732
|
const reply = (id2, body, transfer) => send({ id: id2, ...body }, transfer);
|
|
2733
2733
|
const cdps = cdpRegistry(send, ended.promise);
|
|
@@ -2746,8 +2746,8 @@ function serveClient(port, host) {
|
|
|
2746
2746
|
port.close?.();
|
|
2747
2747
|
ended.resolve();
|
|
2748
2748
|
}
|
|
2749
|
-
async function hello(
|
|
2750
|
-
const refused = versionError(
|
|
2749
|
+
async function hello(message3) {
|
|
2750
|
+
const refused = versionError(message3.protocol);
|
|
2751
2751
|
if (refused) {
|
|
2752
2752
|
send({ hello: { protocol: PROTOCOL, error: refused } });
|
|
2753
2753
|
detach();
|
|
@@ -2758,7 +2758,7 @@ function serveClient(port, host) {
|
|
|
2758
2758
|
const transport = host.transport?.() ?? launcher.transport;
|
|
2759
2759
|
net = serveTransport({ postMessage: (m, t) => send(m, t) }, transport);
|
|
2760
2760
|
state = "open";
|
|
2761
|
-
if (
|
|
2761
|
+
if (message3.lock && host.locks) void host.locks.request(message3.lock, () => detach());
|
|
2762
2762
|
send({
|
|
2763
2763
|
hello: {
|
|
2764
2764
|
protocol: PROTOCOL,
|
|
@@ -2918,8 +2918,8 @@ function ownNames(hostname) {
|
|
|
2918
2918
|
// src/kernel/net/http1.ts
|
|
2919
2919
|
var HttpError = class extends Error {
|
|
2920
2920
|
status;
|
|
2921
|
-
constructor(status,
|
|
2922
|
-
super(
|
|
2921
|
+
constructor(status, message3) {
|
|
2922
|
+
super(message3);
|
|
2923
2923
|
this.status = status;
|
|
2924
2924
|
}
|
|
2925
2925
|
};
|
|
@@ -3182,8 +3182,8 @@ var OP = {
|
|
|
3182
3182
|
};
|
|
3183
3183
|
var WsError = class extends Error {
|
|
3184
3184
|
code;
|
|
3185
|
-
constructor(code,
|
|
3186
|
-
super(
|
|
3185
|
+
constructor(code, message3) {
|
|
3186
|
+
super(message3);
|
|
3187
3187
|
this.code = code;
|
|
3188
3188
|
}
|
|
3189
3189
|
};
|
|
@@ -3549,8 +3549,8 @@ function untilAborted(response, signal) {
|
|
|
3549
3549
|
response.then(resolve, reject).finally(() => signal.removeEventListener("abort", onAbort));
|
|
3550
3550
|
});
|
|
3551
3551
|
}
|
|
3552
|
-
function plainResponse(status,
|
|
3553
|
-
const body = latin1Bytes(`slicc realm proxy: ${
|
|
3552
|
+
function plainResponse(status, message3) {
|
|
3553
|
+
const body = latin1Bytes(`slicc realm proxy: ${message3}
|
|
3554
3554
|
`);
|
|
3555
3555
|
return {
|
|
3556
3556
|
status,
|
|
@@ -3732,10 +3732,10 @@ var RealmProxy = class {
|
|
|
3732
3732
|
return await untilAborted(fetching, signal);
|
|
3733
3733
|
} catch (e) {
|
|
3734
3734
|
if (signal.aborted) throw e;
|
|
3735
|
-
const
|
|
3735
|
+
const message3 = e instanceof Error ? e.message : String(e);
|
|
3736
3736
|
const status = e?.status;
|
|
3737
3737
|
const own = typeof status === "number" && status >= 400 && status <= 599 ? status : 502;
|
|
3738
|
-
return plainResponse(own,
|
|
3738
|
+
return plainResponse(own, message3 || "upstream request failed");
|
|
3739
3739
|
}
|
|
3740
3740
|
}
|
|
3741
3741
|
async relay(conn, method, minor, response, keepAlive) {
|
|
@@ -4240,8 +4240,8 @@ var SCRATCH = 64 * 1024;
|
|
|
4240
4240
|
var EOF = -1;
|
|
4241
4241
|
var TlsError = class extends Error {
|
|
4242
4242
|
code;
|
|
4243
|
-
constructor(code,
|
|
4244
|
-
super(
|
|
4243
|
+
constructor(code, message3) {
|
|
4244
|
+
super(message3);
|
|
4245
4245
|
this.code = code;
|
|
4246
4246
|
}
|
|
4247
4247
|
};
|
|
@@ -4630,8 +4630,8 @@ function enableNetwork(net, options) {
|
|
|
4630
4630
|
var TransportError = class extends Error {
|
|
4631
4631
|
status;
|
|
4632
4632
|
code;
|
|
4633
|
-
constructor(
|
|
4634
|
-
super(
|
|
4633
|
+
constructor(message3, status, code) {
|
|
4634
|
+
super(message3);
|
|
4635
4635
|
this.status = status;
|
|
4636
4636
|
this.code = code;
|
|
4637
4637
|
}
|
|
@@ -5089,8 +5089,8 @@ var CdpFacade = class {
|
|
|
5089
5089
|
clearTimeout(timer);
|
|
5090
5090
|
reject(new HttpError(502, `the CDP host closed: ${reason ?? "no reason"}`));
|
|
5091
5091
|
};
|
|
5092
|
-
conn.onmessage = (
|
|
5093
|
-
const parsed2 = JSON.parse(
|
|
5092
|
+
conn.onmessage = (message3) => {
|
|
5093
|
+
const parsed2 = JSON.parse(message3);
|
|
5094
5094
|
if (parsed2.id !== 1) return;
|
|
5095
5095
|
clearTimeout(timer);
|
|
5096
5096
|
resolve(parsed2);
|
|
@@ -5158,9 +5158,9 @@ var Relay = class {
|
|
|
5158
5158
|
void this.end(reason ? CLOSE.error : CLOSE.normal, reason ?? "").then(() => resolve());
|
|
5159
5159
|
};
|
|
5160
5160
|
});
|
|
5161
|
-
this.host.onmessage = (
|
|
5161
|
+
this.host.onmessage = (message3) => {
|
|
5162
5162
|
if (this.ended) return;
|
|
5163
|
-
const bytes = new TextEncoder().encode(
|
|
5163
|
+
const bytes = new TextEncoder().encode(message3);
|
|
5164
5164
|
if (bytes.length > this.max)
|
|
5165
5165
|
void this.end(CLOSE.tooBig, `a message is over ${this.max} bytes`);
|
|
5166
5166
|
else void this.send(frame(OP_TEXT, bytes));
|
|
@@ -5939,10 +5939,10 @@ var SpawnError = class extends Error {
|
|
|
5939
5939
|
};
|
|
5940
5940
|
function interrupted(signal) {
|
|
5941
5941
|
const { promise, reject } = Promise.withResolvers();
|
|
5942
|
-
const
|
|
5943
|
-
if (signal?.aborted)
|
|
5944
|
-
else signal?.addEventListener("abort",
|
|
5945
|
-
return { promise, done: () => signal?.removeEventListener("abort",
|
|
5942
|
+
const fail2 = () => reject(new KernelError("EINTR"));
|
|
5943
|
+
if (signal?.aborted) fail2();
|
|
5944
|
+
else signal?.addEventListener("abort", fail2, { once: true });
|
|
5945
|
+
return { promise, done: () => signal?.removeEventListener("abort", fail2) };
|
|
5946
5946
|
}
|
|
5947
5947
|
function stoppedStatus(sig) {
|
|
5948
5948
|
return (sig & 255) << 8 | 127;
|
|
@@ -6133,8 +6133,8 @@ function unref(timer) {
|
|
|
6133
6133
|
timer.unref?.();
|
|
6134
6134
|
return timer;
|
|
6135
6135
|
}
|
|
6136
|
-
function errnoError(code,
|
|
6137
|
-
return Object.assign(new Error(`${code}: ${
|
|
6136
|
+
function errnoError(code, message3) {
|
|
6137
|
+
return Object.assign(new Error(`${code}: ${message3}`), { code });
|
|
6138
6138
|
}
|
|
6139
6139
|
var DriverConnection = class _DriverConnection {
|
|
6140
6140
|
capabilities;
|
|
@@ -7116,12 +7116,12 @@ function syncError(code, label) {
|
|
|
7116
7116
|
|
|
7117
7117
|
// src/realm/sync-fs-dispatch.ts
|
|
7118
7118
|
function toErrno(err) {
|
|
7119
|
-
const
|
|
7119
|
+
const message3 = err instanceof Error ? err.message : String(err);
|
|
7120
7120
|
const code = err?.code;
|
|
7121
7121
|
if (typeof code === "string" && /^E[A-Z]+$/.test(code)) {
|
|
7122
|
-
return { ok: false, errno: code, message:
|
|
7122
|
+
return { ok: false, errno: code, message: message3 };
|
|
7123
7123
|
}
|
|
7124
|
-
return { ok: false, errno: "EIO", message:
|
|
7124
|
+
return { ok: false, errno: "EIO", message: message3 };
|
|
7125
7125
|
}
|
|
7126
7126
|
function statJson(s) {
|
|
7127
7127
|
return {
|
|
@@ -7602,10 +7602,133 @@ async function hostSyscall(req, ctx) {
|
|
|
7602
7602
|
}
|
|
7603
7603
|
}
|
|
7604
7604
|
|
|
7605
|
+
// src/kernel/net/ws-syscalls.ts
|
|
7606
|
+
var WS_OPS = [
|
|
7607
|
+
"net-ws-open",
|
|
7608
|
+
"net-ws-ready",
|
|
7609
|
+
"net-ws-recv",
|
|
7610
|
+
"net-ws-wait",
|
|
7611
|
+
"net-ws-send",
|
|
7612
|
+
"net-ws-close"
|
|
7613
|
+
];
|
|
7614
|
+
var TOKEN3 = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
7615
|
+
function message(e) {
|
|
7616
|
+
return e instanceof Error ? e.message : String(e);
|
|
7617
|
+
}
|
|
7618
|
+
function fail(errno, text) {
|
|
7619
|
+
return { ok: false, errno, message: text };
|
|
7620
|
+
}
|
|
7621
|
+
var WsHandles = class {
|
|
7622
|
+
transport;
|
|
7623
|
+
open = /* @__PURE__ */ new Map();
|
|
7624
|
+
next;
|
|
7625
|
+
constructor(transport, next2) {
|
|
7626
|
+
this.transport = transport;
|
|
7627
|
+
this.next = next2;
|
|
7628
|
+
}
|
|
7629
|
+
owns(handle) {
|
|
7630
|
+
return this.open.has(handle);
|
|
7631
|
+
}
|
|
7632
|
+
syscall(req) {
|
|
7633
|
+
if (req.op === "net-ws-open") return Promise.resolve(this.start(req));
|
|
7634
|
+
const entry = this.open.get(req.handle);
|
|
7635
|
+
if (!entry) return Promise.resolve(fail("EBADF", `no websocket ${req.handle}`));
|
|
7636
|
+
if (req.op === "net-ws-ready") return entry.ready;
|
|
7637
|
+
if (!entry.socket) return Promise.resolve(fail("ENOTCONN", "websocket not open"));
|
|
7638
|
+
if (req.op === "net-ws-recv") return this.recv(entry.socket, entry);
|
|
7639
|
+
if (req.op === "net-ws-wait") return this.closed(entry.socket);
|
|
7640
|
+
if (req.op === "net-ws-send") return Promise.resolve(this.send(entry.socket, req, entry));
|
|
7641
|
+
entry.ended = true;
|
|
7642
|
+
entry.socket.close(req.code ?? 1e3, req.reason ?? "");
|
|
7643
|
+
return Promise.resolve({ ok: true, kind: "void" });
|
|
7644
|
+
}
|
|
7645
|
+
start(req) {
|
|
7646
|
+
const handle = this.next();
|
|
7647
|
+
const entry = {
|
|
7648
|
+
abort: new AbortController(),
|
|
7649
|
+
ready: Promise.resolve({ ok: true, kind: "void" })
|
|
7650
|
+
};
|
|
7651
|
+
this.open.set(handle, entry);
|
|
7652
|
+
entry.ready = this.connect(handle, req, entry);
|
|
7653
|
+
return { ok: true, kind: "json", json: handle };
|
|
7654
|
+
}
|
|
7655
|
+
async connect(handle, req, entry) {
|
|
7656
|
+
const { transport } = this;
|
|
7657
|
+
if (!transport.traits.websocket || !transport.websocket) return fail("ENOTSUP", NO_WEBSOCKET2);
|
|
7658
|
+
let socket;
|
|
7659
|
+
try {
|
|
7660
|
+
socket = await transport.websocket({
|
|
7661
|
+
url: req.url,
|
|
7662
|
+
protocols: req.protocols,
|
|
7663
|
+
headers: req.headers,
|
|
7664
|
+
signal: entry.abort.signal
|
|
7665
|
+
});
|
|
7666
|
+
} catch (e) {
|
|
7667
|
+
return fail("ECONNREFUSED", message(e));
|
|
7668
|
+
}
|
|
7669
|
+
if (!this.open.has(handle)) {
|
|
7670
|
+
socket.close(1001, "the program went away");
|
|
7671
|
+
return fail("EBADF", `no websocket ${handle}`);
|
|
7672
|
+
}
|
|
7673
|
+
if (socket.protocol && !(req.protocols.includes(socket.protocol) && TOKEN3.test(socket.protocol))) {
|
|
7674
|
+
socket.close(1002, "subprotocol not offered");
|
|
7675
|
+
return fail("EPROTO", "the far end chose a subprotocol the program did not offer");
|
|
7676
|
+
}
|
|
7677
|
+
entry.socket = socket;
|
|
7678
|
+
void socket.closed.then(() => {
|
|
7679
|
+
entry.ended = true;
|
|
7680
|
+
});
|
|
7681
|
+
entry.messages = socket.messages[Symbol.asyncIterator]();
|
|
7682
|
+
return { ok: true, kind: "json", json: { protocol: socket.protocol } };
|
|
7683
|
+
}
|
|
7684
|
+
async recv(socket, entry) {
|
|
7685
|
+
try {
|
|
7686
|
+
const next2 = await entry.messages.next();
|
|
7687
|
+
if (!next2.done) {
|
|
7688
|
+
return typeof next2.value === "string" ? { ok: true, kind: "json", json: { text: next2.value } } : { ok: true, kind: "bytes", bytes: next2.value };
|
|
7689
|
+
}
|
|
7690
|
+
const closed = await socket.closed;
|
|
7691
|
+
return { ok: true, kind: "json", json: { code: closed.code, reason: closed.reason } };
|
|
7692
|
+
} catch (e) {
|
|
7693
|
+
return fail("ECONNRESET", message(e));
|
|
7694
|
+
}
|
|
7695
|
+
}
|
|
7696
|
+
async closed(socket) {
|
|
7697
|
+
const { code, reason } = await socket.closed;
|
|
7698
|
+
return { ok: true, kind: "json", json: { code, reason } };
|
|
7699
|
+
}
|
|
7700
|
+
send(socket, req, entry) {
|
|
7701
|
+
const data = req.text ?? req.body;
|
|
7702
|
+
if (entry.ended) return fail("EPIPE", "the websocket is closed");
|
|
7703
|
+
try {
|
|
7704
|
+
if (data !== void 0) socket.send(data);
|
|
7705
|
+
} catch (e) {
|
|
7706
|
+
return fail("EPIPE", message(e));
|
|
7707
|
+
}
|
|
7708
|
+
return { ok: true, kind: "json", json: socket.buffered };
|
|
7709
|
+
}
|
|
7710
|
+
close(handle) {
|
|
7711
|
+
const entry = this.open.get(handle);
|
|
7712
|
+
if (!entry) return;
|
|
7713
|
+
this.open.delete(handle);
|
|
7714
|
+
entry.abort.abort();
|
|
7715
|
+
entry.socket?.close(1001, "the program went away");
|
|
7716
|
+
}
|
|
7717
|
+
closeAll() {
|
|
7718
|
+
for (const handle of [...this.open.keys()]) this.close(handle);
|
|
7719
|
+
}
|
|
7720
|
+
};
|
|
7721
|
+
|
|
7605
7722
|
// src/kernel/net/http-syscalls.ts
|
|
7606
|
-
var HTTP_OPS = [
|
|
7723
|
+
var HTTP_OPS = [
|
|
7724
|
+
"net-request",
|
|
7725
|
+
"net-read",
|
|
7726
|
+
"net-close",
|
|
7727
|
+
"net-traits",
|
|
7728
|
+
...WS_OPS
|
|
7729
|
+
];
|
|
7607
7730
|
var EMPTY = new Uint8Array(0);
|
|
7608
|
-
function
|
|
7731
|
+
function message2(e) {
|
|
7609
7732
|
return e instanceof Error ? e.message : String(e);
|
|
7610
7733
|
}
|
|
7611
7734
|
async function* once(bytes) {
|
|
@@ -7615,10 +7738,13 @@ var HttpHandles = class {
|
|
|
7615
7738
|
transport;
|
|
7616
7739
|
open = /* @__PURE__ */ new Map();
|
|
7617
7740
|
nextHandle = 0;
|
|
7741
|
+
ws;
|
|
7618
7742
|
constructor(transport) {
|
|
7619
7743
|
this.transport = transport;
|
|
7744
|
+
this.ws = new WsHandles(transport, () => ++this.nextHandle);
|
|
7620
7745
|
}
|
|
7621
7746
|
syscall(req) {
|
|
7747
|
+
if (req.op.startsWith("net-ws-")) return this.ws.syscall(req);
|
|
7622
7748
|
if (req.op === "net-request") return this.request(req);
|
|
7623
7749
|
if (req.op === "net-read") return this.read(req.handle, req.max);
|
|
7624
7750
|
if (req.op === "net-traits") return Promise.resolve(this.traits());
|
|
@@ -7661,7 +7787,7 @@ var HttpHandles = class {
|
|
|
7661
7787
|
};
|
|
7662
7788
|
return { ok: true, kind: "json", json: head };
|
|
7663
7789
|
} catch (e) {
|
|
7664
|
-
const text =
|
|
7790
|
+
const text = message2(e);
|
|
7665
7791
|
if (text === NO_TRANSPORT) return { ok: false, errno: "ENETUNREACH", message: text };
|
|
7666
7792
|
const status = e.status;
|
|
7667
7793
|
if (typeof status !== "number" || status === 502) {
|
|
@@ -7695,7 +7821,7 @@ var HttpHandles = class {
|
|
|
7695
7821
|
} catch (e) {
|
|
7696
7822
|
entry.done = true;
|
|
7697
7823
|
const timedOut = e?.code === "ETIMEDOUT";
|
|
7698
|
-
return { ok: false, errno: timedOut ? "ETIMEDOUT" : "EIO", message:
|
|
7824
|
+
return { ok: false, errno: timedOut ? "ETIMEDOUT" : "EIO", message: message2(e) };
|
|
7699
7825
|
}
|
|
7700
7826
|
}
|
|
7701
7827
|
const bytes = entry.left.subarray(0, Math.max(0, max));
|
|
@@ -7703,6 +7829,10 @@ var HttpHandles = class {
|
|
|
7703
7829
|
return { ok: true, kind: "bytes", bytes };
|
|
7704
7830
|
}
|
|
7705
7831
|
async close(handle) {
|
|
7832
|
+
if (this.ws.owns(handle)) {
|
|
7833
|
+
this.ws.close(handle);
|
|
7834
|
+
return { ok: true, kind: "void" };
|
|
7835
|
+
}
|
|
7706
7836
|
const entry = this.open.get(handle);
|
|
7707
7837
|
if (!entry) return { ok: false, errno: "EBADF", message: `no request ${handle}` };
|
|
7708
7838
|
this.open.delete(handle);
|
|
@@ -7711,6 +7841,7 @@ var HttpHandles = class {
|
|
|
7711
7841
|
return { ok: true, kind: "void" };
|
|
7712
7842
|
}
|
|
7713
7843
|
async closeAll() {
|
|
7844
|
+
this.ws.closeAll();
|
|
7714
7845
|
await Promise.all([...this.open.keys()].map((handle) => this.close(handle)));
|
|
7715
7846
|
}
|
|
7716
7847
|
};
|
|
@@ -7743,7 +7874,7 @@ var Resolver = class {
|
|
|
7743
7874
|
this.routes = options.routes;
|
|
7744
7875
|
this.now = options.now ?? Date.now;
|
|
7745
7876
|
this.timeoutMs = options.timeoutMs ?? RESOLVE_TIMEOUT_MS;
|
|
7746
|
-
this.log = options.log ?? ((
|
|
7877
|
+
this.log = options.log ?? ((message3) => console.warn(message3));
|
|
7747
7878
|
this.own = ownNames(options.hostname ?? DEFAULT_HOSTNAME);
|
|
7748
7879
|
}
|
|
7749
7880
|
async resolve(name2, family, blocking) {
|
|
@@ -8303,10 +8434,10 @@ function ready(fds, read, write) {
|
|
|
8303
8434
|
}
|
|
8304
8435
|
function interruption(signal) {
|
|
8305
8436
|
const { promise, reject } = Promise.withResolvers();
|
|
8306
|
-
const
|
|
8307
|
-
if (signal.aborted)
|
|
8308
|
-
else signal.addEventListener("abort",
|
|
8309
|
-
return { promise, done: () => signal.removeEventListener("abort",
|
|
8437
|
+
const fail2 = () => reject(new KernelError("EINTR"));
|
|
8438
|
+
if (signal.aborted) fail2();
|
|
8439
|
+
else signal.addEventListener("abort", fail2, { once: true });
|
|
8440
|
+
return { promise, done: () => signal.removeEventListener("abort", fail2) };
|
|
8310
8441
|
}
|
|
8311
8442
|
async function selectFds(fds, read, write, timeoutMs, interrupt) {
|
|
8312
8443
|
const deadline = timeoutMs < 0 ? Number.POSITIVE_INFINITY : Date.now() + timeoutMs;
|
|
@@ -10455,8 +10586,8 @@ var SettlingChildren = class {
|
|
|
10455
10586
|
};
|
|
10456
10587
|
|
|
10457
10588
|
// src/mount/driver.ts
|
|
10458
|
-
function fsError2(code,
|
|
10459
|
-
return Object.assign(new Error(
|
|
10589
|
+
function fsError2(code, message3 = code) {
|
|
10590
|
+
return Object.assign(new Error(message3), { code });
|
|
10460
10591
|
}
|
|
10461
10592
|
async function dispatch(h, req) {
|
|
10462
10593
|
switch (req.op) {
|
|
@@ -10506,15 +10637,15 @@ async function dispatch(h, req) {
|
|
|
10506
10637
|
}
|
|
10507
10638
|
function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
10508
10639
|
let open = false;
|
|
10509
|
-
const reply = (
|
|
10510
|
-
async function hello(
|
|
10511
|
-
const refused = driverVersionError(
|
|
10640
|
+
const reply = (message3, transfer = []) => port.postMessage(message3, transfer);
|
|
10641
|
+
async function hello(message3) {
|
|
10642
|
+
const refused = driverVersionError(message3.protocol);
|
|
10512
10643
|
if (refused) {
|
|
10513
10644
|
reply({ hello: { protocol: DRIVER_PROTOCOL, error: refused, errno: "EPROTO" } });
|
|
10514
10645
|
return;
|
|
10515
10646
|
}
|
|
10516
10647
|
try {
|
|
10517
|
-
const refined = await handlers.mount?.(
|
|
10648
|
+
const refined = await handlers.mount?.(message3.mount);
|
|
10518
10649
|
open = true;
|
|
10519
10650
|
reply({
|
|
10520
10651
|
hello: { protocol: DRIVER_PROTOCOL, capabilities: { ...capabilities, ...refined } }
|
|
@@ -11837,10 +11968,10 @@ var Launcher = class {
|
|
|
11837
11968
|
}
|
|
11838
11969
|
interpreters() {
|
|
11839
11970
|
this.binfmts ??= this.roots().then(
|
|
11840
|
-
(roots) => scanBinfmts(this.base, roots, (
|
|
11841
|
-
if (this.warned.has(
|
|
11842
|
-
this.warned.add(
|
|
11843
|
-
console.warn(
|
|
11971
|
+
(roots) => scanBinfmts(this.base, roots, (message3) => {
|
|
11972
|
+
if (this.warned.has(message3)) return;
|
|
11973
|
+
this.warned.add(message3);
|
|
11974
|
+
console.warn(message3);
|
|
11844
11975
|
})
|
|
11845
11976
|
);
|
|
11846
11977
|
return this.binfmts;
|
|
@@ -12467,7 +12598,7 @@ var Launcher = class {
|
|
|
12467
12598
|
},
|
|
12468
12599
|
account
|
|
12469
12600
|
);
|
|
12470
|
-
const report = (
|
|
12601
|
+
const report = (message3) => options.onData(encoder3.encode(`${message3}\r
|
|
12471
12602
|
`));
|
|
12472
12603
|
const handle = await this.launch(planned, { env, cwd, fds, report, ...this.identity(account) });
|
|
12473
12604
|
leader = handle.pid;
|
|
@@ -12497,7 +12628,7 @@ var Launcher = class {
|
|
|
12497
12628
|
};
|
|
12498
12629
|
const stdout = collect(out, options.onStdout);
|
|
12499
12630
|
const stderr = collect(err, options.onStderr);
|
|
12500
|
-
const report = (
|
|
12631
|
+
const report = (message3) => stderr(encoder3.encode(`${message3}
|
|
12501
12632
|
`));
|
|
12502
12633
|
if (!planned) {
|
|
12503
12634
|
report(`${file}: command not found`);
|