@ai-ecoverse/slicc-kernel 1.110.7 → 1.111.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 +18 -2
- package/dist/kernel-worker.js +1031 -826
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +106 -23
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +615 -410
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +103 -20
- package/dist/process-worker.js.map +3 -3
- package/dist/types/kernel/fd-table.d.ts +1 -1
- package/dist/types/kernel/net/datagram-wire.d.ts +1 -0
- package/dist/types/kernel/socket-syscalls.d.ts +1 -0
- package/dist/types/kernel/socket.d.ts +6 -0
- package/dist/types/kernel/unix-dgram.d.ts +47 -0
- package/dist/types/process/wasi/wasi-host.d.ts +4 -0
- package/package.json +3 -3
package/dist/process-worker.js
CHANGED
|
@@ -2515,7 +2515,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
2515
2515
|
var init_version = __esm({
|
|
2516
2516
|
"src/version.ts"() {
|
|
2517
2517
|
"use strict";
|
|
2518
|
-
KERNEL_VERSION = true ? "1.
|
|
2518
|
+
KERNEL_VERSION = true ? "1.111.0" : "0.0.0-dev";
|
|
2519
2519
|
OS_RELEASE = "6.0.0-slicc";
|
|
2520
2520
|
}
|
|
2521
2521
|
});
|
|
@@ -8344,6 +8344,7 @@ function decodeReceived(raw) {
|
|
|
8344
8344
|
const length = view.getUint8(3);
|
|
8345
8345
|
return {
|
|
8346
8346
|
truncated: (view.getUint8(0) & 1) !== 0,
|
|
8347
|
+
unix: (view.getUint8(0) & 2) !== 0,
|
|
8347
8348
|
port: view.getUint16(1),
|
|
8348
8349
|
host: new TextDecoder().decode(raw.subarray(4, 4 + length)),
|
|
8349
8350
|
bytes: raw.subarray(4 + length)
|
|
@@ -8480,7 +8481,7 @@ function ipv4(host) {
|
|
|
8480
8481
|
}
|
|
8481
8482
|
function openRequest(af, type) {
|
|
8482
8483
|
if (af !== INET4 && af !== INET6 && af !== UNIX) throw new WasiError("EAFNOSUPPORT");
|
|
8483
|
-
if (type !== STREAM &&
|
|
8484
|
+
if (type !== STREAM && type !== DGRAM) throw new WasiError("EPROTONOSUPPORT");
|
|
8484
8485
|
const domain = af === UNIX ? "unix" : "inet";
|
|
8485
8486
|
return {
|
|
8486
8487
|
op: "sock-open",
|
|
@@ -8488,6 +8489,16 @@ function openRequest(af, type) {
|
|
|
8488
8489
|
...type === DGRAM ? { type: "dgram" } : {}
|
|
8489
8490
|
};
|
|
8490
8491
|
}
|
|
8492
|
+
function pairRequest(af, type) {
|
|
8493
|
+
if (af !== UNIX)
|
|
8494
|
+
throw new WasiError(af === INET4 || af === INET6 ? "EOPNOTSUPP" : "EAFNOSUPPORT");
|
|
8495
|
+
if (type !== STREAM && type !== DGRAM) throw new WasiError("EPROTONOSUPPORT");
|
|
8496
|
+
return {
|
|
8497
|
+
op: "sock-pair",
|
|
8498
|
+
domain: "unix",
|
|
8499
|
+
...type === DGRAM ? { type: "dgram" } : {}
|
|
8500
|
+
};
|
|
8501
|
+
}
|
|
8491
8502
|
function absolute(cwd, addr) {
|
|
8492
8503
|
if (addr.family !== "unix" || addr.path === "" || addr.path.startsWith("\0")) return addr;
|
|
8493
8504
|
return addr.path.startsWith("/") ? addr : { family: "unix", path: `${cwd}/${addr.path}` };
|
|
@@ -8508,12 +8519,13 @@ function datagramCalls(host) {
|
|
|
8508
8519
|
const view = mem.view();
|
|
8509
8520
|
view.setUint32(outLen, mem.scatter(iovs, n, got.bytes), true);
|
|
8510
8521
|
view.setUint16(outFlags, got.truncated ? RECV_DATA_TRUNCATED : 0, true);
|
|
8511
|
-
|
|
8512
|
-
|
|
8522
|
+
const from = got.unix ? { family: "unix", path: got.host } : { family: "inet", host: got.host, port: got.port };
|
|
8523
|
+
if (outAddr) writeAddr(mem.view(), outAddr, from);
|
|
8513
8524
|
return E.SUCCESS;
|
|
8514
8525
|
},
|
|
8515
8526
|
sendTo(fd, nonblock, iovs, n, addr, out) {
|
|
8516
|
-
const
|
|
8527
|
+
const named = optionalAddr(mem.view(), addr);
|
|
8528
|
+
const to = named && absolute(host.cwd, named);
|
|
8517
8529
|
const body = mem.gather(iovs, n);
|
|
8518
8530
|
const sent = call2({ op: "sock-sendto", fd, body, ...to ? { addr: to } : {}, nonblock });
|
|
8519
8531
|
mem.view().setUint32(out, sent, true);
|
|
@@ -8547,14 +8559,12 @@ function wasixSocketImports(host, preview1) {
|
|
|
8547
8559
|
mem.view().setUint32(out, fd, true);
|
|
8548
8560
|
},
|
|
8549
8561
|
sock_pair: (af, type, _proto, out1, out2) => {
|
|
8550
|
-
|
|
8551
|
-
throw new WasiError(af === INET4 || af === INET6 ? "EOPNOTSUPP" : "EAFNOSUPPORT");
|
|
8552
|
-
if (type !== STREAM) throw new WasiError("EPROTONOSUPPORT");
|
|
8562
|
+
const req = pairRequest(af, type);
|
|
8553
8563
|
mem.view().setUint32(out1, 0, true);
|
|
8554
8564
|
mem.view().setUint32(out2, 0, true);
|
|
8555
|
-
const [a, b] = call2(
|
|
8556
|
-
fds.adopt(a, "socket", false);
|
|
8557
|
-
fds.adopt(b, "socket", false);
|
|
8565
|
+
const [a, b] = call2(req);
|
|
8566
|
+
fds.adopt(a, "socket", false, "type" in req);
|
|
8567
|
+
fds.adopt(b, "socket", false, "type" in req);
|
|
8558
8568
|
mem.view().setUint32(out1, a, true);
|
|
8559
8569
|
mem.view().setUint32(out2, b, true);
|
|
8560
8570
|
},
|
|
@@ -8774,7 +8784,7 @@ function wrap(table) {
|
|
|
8774
8784
|
}
|
|
8775
8785
|
return out;
|
|
8776
8786
|
}
|
|
8777
|
-
var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
|
|
8787
|
+
var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, S_IFLNK2, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, FD_ALIAS, STDIO_FDS, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
|
|
8778
8788
|
var init_wasi_host = __esm({
|
|
8779
8789
|
"src/process/wasi/wasi-host.ts"() {
|
|
8780
8790
|
"use strict";
|
|
@@ -8809,9 +8819,12 @@ var init_wasi_host = __esm({
|
|
|
8809
8819
|
ROOT_IDS = Object.freeze({ uid: 0, gid: 0 });
|
|
8810
8820
|
GONE = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
|
|
8811
8821
|
S_IFIFO = 4096;
|
|
8822
|
+
S_IFLNK2 = 40960;
|
|
8812
8823
|
DEFAULT_UMASK = 18;
|
|
8813
8824
|
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS4;
|
|
8814
8825
|
MAX_READ = 1024 * 1024;
|
|
8826
|
+
FD_ALIAS = /^\/(?:dev\/(stdin|stdout|stderr)|dev\/fd\/(\d+)|proc\/(self|[1-9]\d*)\/fd\/(\d+))$/;
|
|
8827
|
+
STDIO_FDS = { stdin: 0, stdout: 1, stderr: 2 };
|
|
8815
8828
|
SIGPIPE_EXIT = 128 + SIG.PIPE;
|
|
8816
8829
|
SIG_IGN = 1;
|
|
8817
8830
|
SEALED_MODE = 8630;
|
|
@@ -8924,7 +8937,20 @@ var init_wasi_host = __esm({
|
|
|
8924
8937
|
return void 0;
|
|
8925
8938
|
}
|
|
8926
8939
|
};
|
|
8940
|
+
const fdMode = (fd) => {
|
|
8941
|
+
const e = fds.get(fd);
|
|
8942
|
+
const kind = e.type === "kernel" ? fds.kind(fd, e) : void 0;
|
|
8943
|
+
if (kind === "stream") return S_IFIFO | 384;
|
|
8944
|
+
if (kind === "sealed" || kind === "clipboard") return SEALED_MODE;
|
|
8945
|
+
return modeOf2(this.o.fs.stat(pathOf(fd)));
|
|
8946
|
+
};
|
|
8927
8947
|
const pathOwned = (path, follow2) => {
|
|
8948
|
+
const alias = this.fdAlias(path);
|
|
8949
|
+
if (alias && !follow2) return alias.stdio ? ROOT_IDS : void 0;
|
|
8950
|
+
if (alias) {
|
|
8951
|
+
this.openFd(alias.fd);
|
|
8952
|
+
return fdOwned(alias.fd);
|
|
8953
|
+
}
|
|
8928
8954
|
if (this.synthetic(path)) return ROOT_IDS;
|
|
8929
8955
|
return follow2 ? this.o.fs.stat(path) : this.o.fs.lstat(path);
|
|
8930
8956
|
};
|
|
@@ -8974,14 +9000,18 @@ var init_wasi_host = __esm({
|
|
|
8974
9000
|
const old = this.o.kernel.call({ op: "proc-umask", mask });
|
|
8975
9001
|
mem.view().setUint32(out, old, true);
|
|
8976
9002
|
},
|
|
8977
|
-
fd_mode: (fd, out) =>
|
|
8978
|
-
const e = fds.get(fd);
|
|
8979
|
-
const kind = e.type === "kernel" ? fds.kind(fd, e) : void 0;
|
|
8980
|
-
const mode = kind === "stream" ? S_IFIFO | 384 : kind === "sealed" || kind === "clipboard" ? SEALED_MODE : modeOf2(this.o.fs.stat(pathOf(fd)));
|
|
8981
|
-
mem.view().setUint32(out, mode, true);
|
|
8982
|
-
},
|
|
9003
|
+
fd_mode: (fd, out) => void mem.view().setUint32(out, fdMode(fd), true),
|
|
8983
9004
|
path_mode: (dirfd, p, l, flags, out) => {
|
|
8984
9005
|
const path = at(dirfd, p, l);
|
|
9006
|
+
const alias = this.fdAlias(path);
|
|
9007
|
+
if (alias && flags & AT_SYMLINK_NOFOLLOW2) {
|
|
9008
|
+
this.fdTarget(alias);
|
|
9009
|
+
return void mem.view().setUint32(out, S_IFLNK2 | 511, true);
|
|
9010
|
+
}
|
|
9011
|
+
if (alias) {
|
|
9012
|
+
this.openFd(alias.fd);
|
|
9013
|
+
return void mem.view().setUint32(out, fdMode(alias.fd), true);
|
|
9014
|
+
}
|
|
8985
9015
|
if (this.synthetic(path) && deviceOf(path) === void 0)
|
|
8986
9016
|
return void mem.view().setUint32(out, SEALED_MODE, true);
|
|
8987
9017
|
const st = flags & AT_SYMLINK_NOFOLLOW2 ? this.o.fs.lstat(path) : this.o.fs.stat(path);
|
|
@@ -9276,7 +9306,10 @@ var init_wasi_host = __esm({
|
|
|
9276
9306
|
path_open: (dirfd, lookup2, p, l, oflags, rights, _inheriting, fdflags, out) => {
|
|
9277
9307
|
const follow2 = (lookup2 & LOOKUP_SYMLINK_FOLLOW) !== 0;
|
|
9278
9308
|
try {
|
|
9279
|
-
const
|
|
9309
|
+
const asked = at(dirfd, p, l);
|
|
9310
|
+
const alias = this.fdAlias(asked);
|
|
9311
|
+
if (alias && !alias.stdio) this.openFd(alias.fd);
|
|
9312
|
+
const path = alias && !alias.stdio ? `/dev/fd/${alias.fd}` : asked;
|
|
9280
9313
|
if (deviceOf(path)) this.interrupted?.();
|
|
9281
9314
|
const fresh = (oflags & OFLAGS.CREAT) !== 0 && !this.synthetic(path) && !o.fs.exists(path);
|
|
9282
9315
|
mem.view().setUint32(out, fds.open(path, oflags, rights, fdflags), true);
|
|
@@ -9338,7 +9371,9 @@ var init_wasi_host = __esm({
|
|
|
9338
9371
|
o.fs.symlink(mem.string(tp, tl), path);
|
|
9339
9372
|
},
|
|
9340
9373
|
path_readlink: (dirfd, p, l, buf, len, used) => {
|
|
9341
|
-
const
|
|
9374
|
+
const path = at(dirfd, p, l);
|
|
9375
|
+
const alias = this.fdAlias(path);
|
|
9376
|
+
const target = new TextEncoder().encode(alias ? this.fdTarget(alias) : o.fs.readlink(path));
|
|
9342
9377
|
const n = Math.min(len, target.length);
|
|
9343
9378
|
mem.bytes(buf, n).set(target.subarray(0, n));
|
|
9344
9379
|
mem.view().setUint32(used, n, true);
|
|
@@ -9677,7 +9712,55 @@ var init_wasi_host = __esm({
|
|
|
9677
9712
|
return void 0;
|
|
9678
9713
|
}
|
|
9679
9714
|
}
|
|
9715
|
+
fdAlias(path) {
|
|
9716
|
+
const m = FD_ALIAS.exec(path);
|
|
9717
|
+
if (!m) return void 0;
|
|
9718
|
+
if (m[1]) return { fd: STDIO_FDS[m[1]], stdio: true };
|
|
9719
|
+
if (m[3] !== void 0 && m[3] !== "self" && Number(m[3]) !== this.o.pid) return void 0;
|
|
9720
|
+
return { fd: Number(m[2] ?? m[4]), stdio: false };
|
|
9721
|
+
}
|
|
9722
|
+
openFd(fd) {
|
|
9723
|
+
try {
|
|
9724
|
+
this.fds.get(fd);
|
|
9725
|
+
} catch {
|
|
9726
|
+
throw new WasiError("ENOENT");
|
|
9727
|
+
}
|
|
9728
|
+
}
|
|
9729
|
+
fdTarget(alias) {
|
|
9730
|
+
if (alias.stdio) return `/proc/self/fd/${alias.fd}`;
|
|
9731
|
+
this.openFd(alias.fd);
|
|
9732
|
+
const e = this.fds.get(alias.fd);
|
|
9733
|
+
if (e.type === "file") return e.file.path;
|
|
9734
|
+
if (e.type === "dir") return e.path;
|
|
9735
|
+
if (e.type === "device") return `/dev/${e.device}`;
|
|
9736
|
+
const kind = e.type === "kernel" ? this.fds.kind(alias.fd, e) : void 0;
|
|
9737
|
+
if (kind === "file") {
|
|
9738
|
+
const vfs = this.kernelStat(alias.fd);
|
|
9739
|
+
if (vfs.path) return vfs.path;
|
|
9740
|
+
}
|
|
9741
|
+
if (kind === "tty") return "/dev/tty";
|
|
9742
|
+
if (kind === "device") return "/dev/null";
|
|
9743
|
+
const ino = this.fdFilestat(alias.fd).ino;
|
|
9744
|
+
if (kind === "stream") return `pipe:[${ino}]`;
|
|
9745
|
+
if (kind === "socket") return `socket:[${ino}]`;
|
|
9746
|
+
return `anon_inode:[${kind ?? "fd"}]`;
|
|
9747
|
+
}
|
|
9748
|
+
aliasFilestat(path, alias, lookup2) {
|
|
9749
|
+
if ((lookup2 & LOOKUP_SYMLINK_FOLLOW) === 0) {
|
|
9750
|
+
const target = this.fdTarget(alias);
|
|
9751
|
+
return this.local({
|
|
9752
|
+
filetype: FILETYPE.SYMBOLIC_LINK,
|
|
9753
|
+
size: BigInt(new TextEncoder().encode(target).length),
|
|
9754
|
+
ino: pathInode(path),
|
|
9755
|
+
mtimeNs: 0n
|
|
9756
|
+
});
|
|
9757
|
+
}
|
|
9758
|
+
this.openFd(alias.fd);
|
|
9759
|
+
return this.fdFilestat(alias.fd);
|
|
9760
|
+
}
|
|
9680
9761
|
pathFilestat(path, lookup2) {
|
|
9762
|
+
const alias = this.fdAlias(path);
|
|
9763
|
+
if (alias) return this.aliasFilestat(path, alias, lookup2);
|
|
9681
9764
|
if (this.synthetic(path)) {
|
|
9682
9765
|
return this.local({
|
|
9683
9766
|
filetype: FILETYPE.CHARACTER_DEVICE,
|