@ai-ecoverse/slicc-kernel 1.67.0 → 1.68.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 +10 -0
- package/dist/index.js +49 -2
- package/dist/index.js.map +3 -3
- package/dist/kernel-worker.js +269 -24
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +87 -21
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +225 -17
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +87 -21
- package/dist/process-worker.js.map +3 -3
- package/package.json +1 -1
|
@@ -1315,7 +1315,7 @@ function promoteRequest(fd, f, handed) {
|
|
|
1315
1315
|
...f.buffer.handle !== void 0 ? { handle: f.buffer.handle } : {}
|
|
1316
1316
|
};
|
|
1317
1317
|
}
|
|
1318
|
-
var SYNTHETIC_DIRS, O_NONBLOCK, O_WRONLY, O_RDWR, O_APPEND, DEVICES, WasiFds, GEN;
|
|
1318
|
+
var SYNTHETIC_DIRS, O_NONBLOCK, O_WRONLY, O_RDWR, O_APPEND, DEVICES, SEALED_PATH, WasiFds, GEN;
|
|
1319
1319
|
var init_wasi_fds = __esm({
|
|
1320
1320
|
"src/process/wasi/wasi-fds.ts"() {
|
|
1321
1321
|
"use strict";
|
|
@@ -1334,6 +1334,7 @@ var init_wasi_fds = __esm({
|
|
|
1334
1334
|
"/dev/urandom": "urandom",
|
|
1335
1335
|
"/dev/random": "urandom"
|
|
1336
1336
|
};
|
|
1337
|
+
SEALED_PATH = "/dev/sealed";
|
|
1337
1338
|
WasiFds = class {
|
|
1338
1339
|
table = /* @__PURE__ */ new Map();
|
|
1339
1340
|
buffers = /* @__PURE__ */ new Map();
|
|
@@ -1798,16 +1799,30 @@ var init_wasi_fds = __esm({
|
|
|
1798
1799
|
const joined2 = path.startsWith("/") ? path : `${this.dir(dirfd).path}/${path}`;
|
|
1799
1800
|
return joined2.split("/").includes("..") ? physical(this.fs, joined2) : normalize(joined2);
|
|
1800
1801
|
}
|
|
1802
|
+
openKernelDevice(path, oflags, fdflags) {
|
|
1803
|
+
const { openSealed, openTty } = this.kernel.sys;
|
|
1804
|
+
const nonblock = (fdflags & FDFLAGS.NONBLOCK) !== 0;
|
|
1805
|
+
let fd;
|
|
1806
|
+
let kind;
|
|
1807
|
+
if (path === SEALED_PATH && openSealed) {
|
|
1808
|
+
if (oflags & OFLAGS.DIRECTORY) throw new WasiError("ENOTDIR");
|
|
1809
|
+
if (oflags & OFLAGS.CREAT && oflags & OFLAGS.EXCL) throw new WasiError("EEXIST");
|
|
1810
|
+
fd = openSealed.call(this.kernel.sys);
|
|
1811
|
+
kind = "sealed";
|
|
1812
|
+
} else if (path === "/dev/tty" || /^\/dev\/tty\d+$/.test(path)) {
|
|
1813
|
+
fd = openTty?.call(this.kernel.sys, path === "/dev/tty" ? void 0 : path);
|
|
1814
|
+
if (fd === void 0) throw new WasiError("ENXIO");
|
|
1815
|
+
kind = "tty";
|
|
1816
|
+
} else return void 0;
|
|
1817
|
+
this.adopt(fd, kind, nonblock);
|
|
1818
|
+
this.bump();
|
|
1819
|
+
return fd;
|
|
1820
|
+
}
|
|
1801
1821
|
open(path, oflags, rights, fdflags) {
|
|
1802
1822
|
const device2 = deviceOf(path);
|
|
1803
1823
|
if (device2) return this.install({ type: "device", device: device2 });
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
if (fd === void 0) throw new WasiError("ENXIO");
|
|
1807
|
-
this.table.set(fd, { ...kernelEntry(), kind: "tty" });
|
|
1808
|
-
this.bump();
|
|
1809
|
-
return fd;
|
|
1810
|
-
}
|
|
1824
|
+
const kernelDevice = this.openKernelDevice(path, oflags, fdflags);
|
|
1825
|
+
if (kernelDevice !== void 0) return kernelDevice;
|
|
1811
1826
|
const alias = stdioAlias(path);
|
|
1812
1827
|
if (alias !== void 0) return this.reopen(alias);
|
|
1813
1828
|
const exclusive = (oflags & OFLAGS.CREAT) !== 0 && (oflags & OFLAGS.EXCL) !== 0;
|
|
@@ -2248,6 +2263,7 @@ function filestatOf(path, s) {
|
|
|
2248
2263
|
function kernelFiletype(kind) {
|
|
2249
2264
|
switch (kind) {
|
|
2250
2265
|
case "tty":
|
|
2266
|
+
case "sealed":
|
|
2251
2267
|
return { filetype: FILETYPE.CHARACTER_DEVICE, seeks: false };
|
|
2252
2268
|
case "device":
|
|
2253
2269
|
return { filetype: FILETYPE.CHARACTER_DEVICE, seeks: true };
|
|
@@ -2288,7 +2304,7 @@ function wrap(table) {
|
|
|
2288
2304
|
}
|
|
2289
2305
|
return out;
|
|
2290
2306
|
}
|
|
2291
|
-
var WasiExit, IDS, NS_PER_MS, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, WasiHost;
|
|
2307
|
+
var WasiExit, IDS, NS_PER_MS, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SEALED_MODE, WasiHost;
|
|
2292
2308
|
var init_wasi_host = __esm({
|
|
2293
2309
|
"src/process/wasi/wasi-host.ts"() {
|
|
2294
2310
|
"use strict";
|
|
@@ -2318,6 +2334,7 @@ var init_wasi_host = __esm({
|
|
|
2318
2334
|
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS;
|
|
2319
2335
|
MAX_READ = 1024 * 1024;
|
|
2320
2336
|
SIGPIPE_EXIT = 141;
|
|
2337
|
+
SEALED_MODE = 8630;
|
|
2321
2338
|
WasiHost = class {
|
|
2322
2339
|
mem = new WasiMemory();
|
|
2323
2340
|
fds;
|
|
@@ -2403,7 +2420,9 @@ var init_wasi_host = __esm({
|
|
|
2403
2420
|
const fdOwned = (fd) => {
|
|
2404
2421
|
const e = fds.get(fd);
|
|
2405
2422
|
if (e.type === "device") return ROOT_IDS;
|
|
2406
|
-
|
|
2423
|
+
const kind = e.type === "kernel" ? fds.kind(fd, e) : "file";
|
|
2424
|
+
if (kind === "sealed") return ROOT_IDS;
|
|
2425
|
+
if (kind !== "file") return void 0;
|
|
2407
2426
|
try {
|
|
2408
2427
|
return this.o.fs.stat(pathOf(fd));
|
|
2409
2428
|
} catch (err) {
|
|
@@ -2412,7 +2431,7 @@ var init_wasi_host = __esm({
|
|
|
2412
2431
|
}
|
|
2413
2432
|
};
|
|
2414
2433
|
const pathOwned = (path, follow2) => {
|
|
2415
|
-
if (
|
|
2434
|
+
if (this.synthetic(path)) return ROOT_IDS;
|
|
2416
2435
|
return follow2 ? this.o.fs.stat(path) : this.o.fs.lstat(path);
|
|
2417
2436
|
};
|
|
2418
2437
|
return wrap({
|
|
@@ -2441,7 +2460,7 @@ var init_wasi_host = __esm({
|
|
|
2441
2460
|
path_access: (dirfd, p, l, amode, flags) => {
|
|
2442
2461
|
const path = at(dirfd, p, l);
|
|
2443
2462
|
const nofollow = (flags & AT_SYMLINK_NOFOLLOW) !== 0;
|
|
2444
|
-
if (
|
|
2463
|
+
if (this.synthetic(path)) {
|
|
2445
2464
|
if (this.o.fs.owners && amode & 1) throw new WasiError("EACCES");
|
|
2446
2465
|
return;
|
|
2447
2466
|
}
|
|
@@ -2458,12 +2477,14 @@ var init_wasi_host = __esm({
|
|
|
2458
2477
|
},
|
|
2459
2478
|
fd_mode: (fd, out) => {
|
|
2460
2479
|
const e = fds.get(fd);
|
|
2461
|
-
const
|
|
2462
|
-
const mode =
|
|
2480
|
+
const kind = e.type === "kernel" ? fds.kind(fd, e) : void 0;
|
|
2481
|
+
const mode = kind === "stream" ? S_IFIFO | 384 : kind === "sealed" ? SEALED_MODE : modeOf(this.o.fs.stat(pathOf(fd)));
|
|
2463
2482
|
mem.view().setUint32(out, mode, true);
|
|
2464
2483
|
},
|
|
2465
2484
|
path_mode: (dirfd, p, l, flags, out) => {
|
|
2466
2485
|
const path = at(dirfd, p, l);
|
|
2486
|
+
if (path === SEALED_PATH && this.o.kernel.sys.openSealed)
|
|
2487
|
+
return void mem.view().setUint32(out, SEALED_MODE, true);
|
|
2467
2488
|
const st = flags & AT_SYMLINK_NOFOLLOW ? this.o.fs.lstat(path) : this.o.fs.stat(path);
|
|
2468
2489
|
mem.view().setUint32(out, modeOf(st), true);
|
|
2469
2490
|
}
|
|
@@ -2651,7 +2672,7 @@ var init_wasi_host = __esm({
|
|
|
2651
2672
|
path_open: (dirfd, _lookup, p, l, oflags, rights, _inheriting, fdflags, out) => {
|
|
2652
2673
|
const path = at(dirfd, p, l);
|
|
2653
2674
|
if (deviceOf(path)) this.interrupted?.();
|
|
2654
|
-
const fresh = (oflags & OFLAGS.CREAT) !== 0 && !o.fs.exists(path);
|
|
2675
|
+
const fresh = (oflags & OFLAGS.CREAT) !== 0 && !this.synthetic(path) && !o.fs.exists(path);
|
|
2655
2676
|
mem.view().setUint32(out, fds.open(path, oflags, rights, fdflags), true);
|
|
2656
2677
|
if (fresh) this.created(path, 438);
|
|
2657
2678
|
},
|
|
@@ -2960,8 +2981,11 @@ var init_wasi_host = __esm({
|
|
|
2960
2981
|
const out = this.sized(path, s, size);
|
|
2961
2982
|
return gone ? { ...out, nlink: 0n } : out;
|
|
2962
2983
|
}
|
|
2984
|
+
synthetic(path) {
|
|
2985
|
+
return deviceOf(path) !== void 0 || path === SEALED_PATH && !!this.o.kernel.sys.openSealed;
|
|
2986
|
+
}
|
|
2963
2987
|
pathFilestat(path, lookup) {
|
|
2964
|
-
if (
|
|
2988
|
+
if (this.synthetic(path)) {
|
|
2965
2989
|
return this.local({
|
|
2966
2990
|
filetype: FILETYPE.CHARACTER_DEVICE,
|
|
2967
2991
|
size: 0n,
|
|
@@ -6857,10 +6881,28 @@ function ptyStat(path) {
|
|
|
6857
6881
|
ctime: now
|
|
6858
6882
|
};
|
|
6859
6883
|
}
|
|
6884
|
+
function sealedStat() {
|
|
6885
|
+
const now = /* @__PURE__ */ new Date();
|
|
6886
|
+
return {
|
|
6887
|
+
dev: 22,
|
|
6888
|
+
ino: 1,
|
|
6889
|
+
mode: 8630,
|
|
6890
|
+
nlink: 1,
|
|
6891
|
+
uid: 0,
|
|
6892
|
+
gid: 0,
|
|
6893
|
+
rdev: 10 << 8 | 250,
|
|
6894
|
+
size: 0,
|
|
6895
|
+
blksize: 4096,
|
|
6896
|
+
blocks: 0,
|
|
6897
|
+
atime: now,
|
|
6898
|
+
mtime: now,
|
|
6899
|
+
ctime: now
|
|
6900
|
+
};
|
|
6901
|
+
}
|
|
6860
6902
|
function nonblocking(stream) {
|
|
6861
6903
|
return (stream.flags & O_NONBLOCK2) !== 0 ? { nonblock: true } : void 0;
|
|
6862
6904
|
}
|
|
6863
|
-
var POLLIN, POLLOUT, POLLERR, POLLHUP, POLLRDNORM, POLLWRNORM, TCSETSF, O_NONBLOCK2, SOCKET_MODE, PTY_PATH, TTY_PATH, TTY_NAME, O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC2, KILLED_BY_SIGPIPE, ProcessExit, SyscallError, KernelStreams;
|
|
6905
|
+
var POLLIN, POLLOUT, POLLERR, POLLHUP, POLLRDNORM, POLLWRNORM, TCSETSF, O_NONBLOCK2, SOCKET_MODE, PTY_PATH, TTY_PATH, TTY_NAME, SEALED_PATH2, O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC2, KILLED_BY_SIGPIPE, ProcessExit, SyscallError, KernelStreams;
|
|
6864
6906
|
var init_kernel_streams = __esm({
|
|
6865
6907
|
"src/process/kernel-streams.ts"() {
|
|
6866
6908
|
"use strict";
|
|
@@ -6877,6 +6919,7 @@ var init_kernel_streams = __esm({
|
|
|
6877
6919
|
PTY_PATH = /^\/dev\/(?:ptmx|pts\/(\d+))$/;
|
|
6878
6920
|
TTY_PATH = /^\/dev\/tty\d+$/;
|
|
6879
6921
|
TTY_NAME = /^tty\d+$/;
|
|
6922
|
+
SEALED_PATH2 = "/dev/sealed";
|
|
6880
6923
|
O_CREAT = 64;
|
|
6881
6924
|
O_EXCL = 128;
|
|
6882
6925
|
O_NOCTTY = 256;
|
|
@@ -6950,6 +6993,15 @@ var init_kernel_streams = __esm({
|
|
|
6950
6993
|
if (typeof this.Fs.stat !== "function") return;
|
|
6951
6994
|
stream.stream_ops = { ...stream.stream_ops, getattr: () => this.Fs.stat?.(name2) ?? {} };
|
|
6952
6995
|
}
|
|
6996
|
+
listSealed() {
|
|
6997
|
+
const { analyzePath, mkdev, makedev } = this.Fs;
|
|
6998
|
+
if (!this.sys.openSealed || !analyzePath || !mkdev || !makedev) return;
|
|
6999
|
+
if (analyzePath.call(this.Fs, SEALED_PATH2).exists) return;
|
|
7000
|
+
try {
|
|
7001
|
+
mkdev.call(this.Fs, SEALED_PATH2, makedev.call(this.Fs, 10, 250));
|
|
7002
|
+
} catch {
|
|
7003
|
+
}
|
|
7004
|
+
}
|
|
6953
7005
|
creatingTerminal = false;
|
|
6954
7006
|
useTerminalNodes() {
|
|
6955
7007
|
const fs = this.Fs;
|
|
@@ -7042,13 +7094,14 @@ var init_kernel_streams = __esm({
|
|
|
7042
7094
|
if (typeof this.Fs.open !== "function") return;
|
|
7043
7095
|
this.usePtyPaths();
|
|
7044
7096
|
this.useTerminalNodes();
|
|
7097
|
+
this.listSealed();
|
|
7045
7098
|
const open = this.Fs.open.bind(this.Fs);
|
|
7046
7099
|
this.Fs.open = (path, flags, mode) => {
|
|
7047
7100
|
const device2 = typeof path === "string" ? this.devicePath(path) : void 0;
|
|
7048
7101
|
if (device2 !== void 0 && TTY_PATH.test(device2) && !this.terminalExists(device2)) {
|
|
7049
7102
|
throw new this.Fs.ErrnoError(wasiErrno("ENOENT"));
|
|
7050
7103
|
}
|
|
7051
|
-
const pty = this.openPty(open, path, flags, mode);
|
|
7104
|
+
const pty = this.openPty(open, path, flags, mode) ?? this.openSealed(open, path, flags, mode);
|
|
7052
7105
|
if (pty) return pty;
|
|
7053
7106
|
this.refuseExclusiveLink(path, flags);
|
|
7054
7107
|
const stream = this.openRacing(open, path, flags, mode);
|
|
@@ -7106,15 +7159,24 @@ var init_kernel_streams = __esm({
|
|
|
7106
7159
|
const kfd = this.call(
|
|
7107
7160
|
() => pts ? openPts(Number(pts[1]), (flags & O_NOCTTY) !== 0) : openPty()
|
|
7108
7161
|
);
|
|
7162
|
+
return this.vessel(open, kfd, { path, flags, mode }, true);
|
|
7163
|
+
}
|
|
7164
|
+
openSealed(open, path, flags, mode) {
|
|
7165
|
+
const { openSealed } = this.sys;
|
|
7166
|
+
if (path !== SEALED_PATH2 || !openSealed) return void 0;
|
|
7167
|
+
const kfd = this.call(() => openSealed.call(this.sys));
|
|
7168
|
+
return this.vessel(open, kfd, { path, flags, mode }, false);
|
|
7169
|
+
}
|
|
7170
|
+
vessel(open, kfd, at, terminal) {
|
|
7109
7171
|
let stream;
|
|
7110
7172
|
try {
|
|
7111
|
-
stream = open("/dev/null", flags & ~(O_CREAT | O_EXCL | O_TRUNC2), mode);
|
|
7173
|
+
stream = open("/dev/null", at.flags & ~(O_CREAT | O_EXCL | O_TRUNC2), at.mode);
|
|
7112
7174
|
} catch (e) {
|
|
7113
7175
|
this.sys.close(kfd);
|
|
7114
7176
|
throw e;
|
|
7115
7177
|
}
|
|
7116
|
-
this.attach(stream, kfd,
|
|
7117
|
-
this.nameStream(stream, path);
|
|
7178
|
+
this.attach(stream, kfd, terminal);
|
|
7179
|
+
this.nameStream(stream, at.path);
|
|
7118
7180
|
return stream;
|
|
7119
7181
|
}
|
|
7120
7182
|
usePtyPaths() {
|
|
@@ -7128,6 +7190,7 @@ var init_kernel_streams = __esm({
|
|
|
7128
7190
|
const original = fs[name2];
|
|
7129
7191
|
if (typeof original !== "function") continue;
|
|
7130
7192
|
fs[name2] = (path, ...rest2) => {
|
|
7193
|
+
if (path === SEALED_PATH2 && this.sys.openSealed) return sealedStat();
|
|
7131
7194
|
const owned = this.ownedTty(path);
|
|
7132
7195
|
if (owned && isPtyPath(path)) return this.owned(path, ptyStat(path));
|
|
7133
7196
|
if (!isPtyPath(path)) {
|
|
@@ -9255,6 +9318,9 @@ function kernelSys(transport) {
|
|
|
9255
9318
|
openPts(n, noctty) {
|
|
9256
9319
|
return json2(call2({ op: "pty-slave-open", n, noctty }, `pty-slave-open ${n}`));
|
|
9257
9320
|
},
|
|
9321
|
+
openSealed() {
|
|
9322
|
+
return json2(call2({ op: "fd-open-sealed" }, "fd-open-sealed"));
|
|
9323
|
+
},
|
|
9258
9324
|
ptyNumbers() {
|
|
9259
9325
|
return json2(call2({ op: "pty-list" }, "pty-list"));
|
|
9260
9326
|
},
|