@ai-ecoverse/slicc-kernel 1.26.5 → 1.27.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 +27 -4
- package/dist/driver-worker.js +1 -1
- package/dist/driver-worker.js.map +1 -1
- package/dist/index.js +66 -12
- package/dist/index.js.map +4 -4
- package/dist/kernel-worker.js +299 -18
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js +1 -1
- package/dist/node-driver-worker.js.map +1 -1
- package/dist/node-process-worker.js +90 -20
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +245 -12
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +90 -20
- package/dist/process-worker.js.map +4 -4
- package/dist/testing.js +27 -0
- package/dist/testing.js.map +7 -0
- package/package.json +5 -3
package/dist/process-worker.js
CHANGED
|
@@ -2955,6 +2955,7 @@ function createSocketKernel(deps) {
|
|
|
2955
2955
|
name: (fd, peer) => guard(() => json({ op: "sock-name", fd: kfd(fd), peer })),
|
|
2956
2956
|
getopt: (fd, level, name) => guard(() => ({ value: json({ op: "sock-getopt", fd: kfd(fd), level, name }) })),
|
|
2957
2957
|
setopt: (fd, level, name, value2) => guard(() => done({ op: "sock-setopt", fd: kfd(fd), level, name, value: value2 })),
|
|
2958
|
+
resolve: (name, family = 4) => guard(() => json({ op: "sock-resolve", name, family })),
|
|
2958
2959
|
send: (fd, bytes, flags) => guard(() => {
|
|
2959
2960
|
const stream = socketAt(fd);
|
|
2960
2961
|
const nonblock = flags.dontwait === true || (stream.flags & O_NONBLOCK) !== 0;
|
|
@@ -3259,6 +3260,12 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
3259
3260
|
return [...names];
|
|
3260
3261
|
}
|
|
3261
3262
|
};
|
|
3263
|
+
hashRemoveNode.call(Fs, self);
|
|
3264
|
+
const link = fresh(proc, "self", LINK_MODE2);
|
|
3265
|
+
const shownPid = () => String(find(procList().processes, pid, true)?.pid ?? pid);
|
|
3266
|
+
link.node_ops.readlink = shownPid;
|
|
3267
|
+
const procLookup = proc.node_ops.lookup;
|
|
3268
|
+
proc.node_ops.lookup = (parent, name) => name === "self" ? link : name === shownPid() ? self : procLookup(parent, name);
|
|
3262
3269
|
const selfOps = self.node_ops;
|
|
3263
3270
|
const selfLookup = selfOps.lookup?.bind(selfOps);
|
|
3264
3271
|
const selfReaddir = selfOps.readdir?.bind(selfOps);
|
|
@@ -3274,7 +3281,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
3274
3281
|
readdir: (node) => pidNames(selfReaddir ? selfReaddir(node) : [".", ".."])
|
|
3275
3282
|
};
|
|
3276
3283
|
}
|
|
3277
|
-
var HZ, DIR_MODE2, FILE_MODE, ENOENT, ESRCH, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES;
|
|
3284
|
+
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, ESRCH, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES;
|
|
3278
3285
|
var init_procfs = __esm({
|
|
3279
3286
|
"src/process/procfs.ts"() {
|
|
3280
3287
|
"use strict";
|
|
@@ -3282,6 +3289,7 @@ var init_procfs = __esm({
|
|
|
3282
3289
|
HZ = 100;
|
|
3283
3290
|
DIR_MODE2 = 16749;
|
|
3284
3291
|
FILE_MODE = 33060;
|
|
3292
|
+
LINK_MODE2 = 41471;
|
|
3285
3293
|
ENOENT = 44;
|
|
3286
3294
|
ESRCH = 71;
|
|
3287
3295
|
EINVAL = 28;
|
|
@@ -6334,6 +6342,67 @@ var init_wasix_process = __esm({
|
|
|
6334
6342
|
}
|
|
6335
6343
|
});
|
|
6336
6344
|
|
|
6345
|
+
// src/kernel/net/routes.ts
|
|
6346
|
+
function ipv4Bytes(text) {
|
|
6347
|
+
const parts = text.split(".");
|
|
6348
|
+
if (parts.length !== 4 || !parts.every((p) => /^\d{1,3}$/.test(p))) return void 0;
|
|
6349
|
+
const bytes = parts.map(Number);
|
|
6350
|
+
return bytes.every((b) => b <= 255) ? bytes : void 0;
|
|
6351
|
+
}
|
|
6352
|
+
function ipv6Groups(text) {
|
|
6353
|
+
if (!text.includes(":")) return void 0;
|
|
6354
|
+
let canonical;
|
|
6355
|
+
try {
|
|
6356
|
+
canonical = new URL(`http://[${text}]/`).hostname.slice(1, -1);
|
|
6357
|
+
} catch {
|
|
6358
|
+
return void 0;
|
|
6359
|
+
}
|
|
6360
|
+
const [head, tail] = canonical.split("::");
|
|
6361
|
+
const part = (s) => s ? s.split(":").map((h) => Number.parseInt(h, 16)) : [];
|
|
6362
|
+
const front = part(head);
|
|
6363
|
+
const back = part(tail);
|
|
6364
|
+
return tail === void 0 ? front : [...front, ...new Array(8 - front.length - back.length).fill(0), ...back];
|
|
6365
|
+
}
|
|
6366
|
+
function toBits(values, width) {
|
|
6367
|
+
return values.reduce((acc, v) => acc << BigInt(width) | BigInt(v), 0n);
|
|
6368
|
+
}
|
|
6369
|
+
function addressBits(host) {
|
|
6370
|
+
const v4 = ipv4Bytes(host);
|
|
6371
|
+
if (v4) return { v6: false, bits: toBits(v4, 8) };
|
|
6372
|
+
const v6 = ipv6Groups(host);
|
|
6373
|
+
return v6 ? { v6: true, bits: toBits(v6, 16) } : void 0;
|
|
6374
|
+
}
|
|
6375
|
+
function parsePrefix(text) {
|
|
6376
|
+
const parts = text.trim().split("/");
|
|
6377
|
+
if (parts.length > 2) return void 0;
|
|
6378
|
+
const [address = "", size] = parts;
|
|
6379
|
+
const parsed = addressBits(address);
|
|
6380
|
+
if (!parsed) return void 0;
|
|
6381
|
+
const max = parsed.v6 ? 128 : 32;
|
|
6382
|
+
const length = size === void 0 ? max : /^\d{1,3}$/.test(size) ? Number(size) : -1;
|
|
6383
|
+
if (length < 0 || length > max) return void 0;
|
|
6384
|
+
return { ...parsed, length };
|
|
6385
|
+
}
|
|
6386
|
+
var HOST_ADDRESS, RESERVED;
|
|
6387
|
+
var init_routes = __esm({
|
|
6388
|
+
"src/kernel/net/routes.ts"() {
|
|
6389
|
+
"use strict";
|
|
6390
|
+
init_loopback_names();
|
|
6391
|
+
HOST_ADDRESS = HOST_LOOPBACK_ADDRESS.join(".");
|
|
6392
|
+
RESERVED = [
|
|
6393
|
+
"0.0.0.0/8",
|
|
6394
|
+
"127.0.0.0/8",
|
|
6395
|
+
"169.254.0.0/16",
|
|
6396
|
+
"224.0.0.0/4",
|
|
6397
|
+
"240.0.0.0/4",
|
|
6398
|
+
"::/96",
|
|
6399
|
+
"::ffff:0:0/96",
|
|
6400
|
+
"fe80::/10",
|
|
6401
|
+
"ff00::/8"
|
|
6402
|
+
].map((p) => parsePrefix(p));
|
|
6403
|
+
}
|
|
6404
|
+
});
|
|
6405
|
+
|
|
6337
6406
|
// src/process/wasi/wasix-sockets.ts
|
|
6338
6407
|
function readAddr(view, ptr) {
|
|
6339
6408
|
const tag = view.getUint8(ptr);
|
|
@@ -6380,20 +6449,16 @@ function writeAddr(view, ptr, addr) {
|
|
|
6380
6449
|
const octets = ipv4(addr.host) ?? [127, 0, 0, 1];
|
|
6381
6450
|
octets.forEach((b, i) => void view.setUint8(ptr + 4 + i, b));
|
|
6382
6451
|
}
|
|
6452
|
+
function ipBytes(host) {
|
|
6453
|
+
const groups = ipv4(host) ? void 0 : ipv6Groups(host);
|
|
6454
|
+
return groups ? groups.flatMap((g) => [g >> 8, g & 255]) : ipv4(host);
|
|
6455
|
+
}
|
|
6383
6456
|
function ipv4(host) {
|
|
6384
6457
|
const parts = host.split(".");
|
|
6385
6458
|
if (parts.length !== 4) return void 0;
|
|
6386
6459
|
const bytes = parts.map((p) => /^\d{1,3}$/.test(p) ? Number(p) : Number.NaN);
|
|
6387
6460
|
return bytes.every((b) => b >= 0 && b <= 255) ? bytes : void 0;
|
|
6388
6461
|
}
|
|
6389
|
-
function resolveName(name) {
|
|
6390
|
-
if (name === "localhost" || name === "localhost.localdomain" || name === "ip6-localhost") {
|
|
6391
|
-
return [127, 0, 0, 1];
|
|
6392
|
-
}
|
|
6393
|
-
if (name === "::1") return [127, 0, 0, 1];
|
|
6394
|
-
if (name.toLowerCase() === HOST_LOOPBACK) return [...HOST_LOOPBACK_ADDRESS];
|
|
6395
|
-
return ipv4(name);
|
|
6396
|
-
}
|
|
6397
6462
|
function wasixSocketImports(host, preview1) {
|
|
6398
6463
|
const { mem, fds, o } = host;
|
|
6399
6464
|
const call2 = (req) => o.kernel.call(req);
|
|
@@ -6485,14 +6550,19 @@ function wasixSocketImports(host, preview1) {
|
|
|
6485
6550
|
sock_set_opt_time: (fd) => void socket(fd),
|
|
6486
6551
|
sock_send_file: () => E.NOSYS,
|
|
6487
6552
|
resolve: (name, len, _port, addrs, naddrs, out) => {
|
|
6488
|
-
const
|
|
6489
|
-
|
|
6553
|
+
const found = call2({ op: "sock-resolve", name: mem.string(name, len), family: 0 });
|
|
6554
|
+
const ips = found.map(ipBytes).filter((ip) => ip !== void 0);
|
|
6555
|
+
if (ips.length === 0) throw new WasiError("ENOENT");
|
|
6490
6556
|
if (naddrs < 1) throw new WasiError("EINVAL");
|
|
6491
6557
|
const view = mem.view();
|
|
6492
|
-
|
|
6493
|
-
view.
|
|
6494
|
-
|
|
6495
|
-
|
|
6558
|
+
const count = Math.min(ips.length, naddrs);
|
|
6559
|
+
new Uint8Array(view.buffer, addrs, ADDR_IP_SIZE * count).fill(0);
|
|
6560
|
+
for (let i = 0; i < count; i++) {
|
|
6561
|
+
const at = addrs + i * ADDR_IP_SIZE;
|
|
6562
|
+
view.setUint8(at, ips[i].length === 4 ? INET4 : INET6);
|
|
6563
|
+
new Uint8Array(view.buffer, at + 2, ips[i].length).set(ips[i]);
|
|
6564
|
+
}
|
|
6565
|
+
view.setUint32(out, count, true);
|
|
6496
6566
|
}
|
|
6497
6567
|
};
|
|
6498
6568
|
}
|
|
@@ -6500,7 +6570,7 @@ var INET4, INET6, UNIX, STREAM, ADDR_IP_SIZE, LOOPBACK, OPTIONS;
|
|
|
6500
6570
|
var init_wasix_sockets = __esm({
|
|
6501
6571
|
"src/process/wasi/wasix-sockets.ts"() {
|
|
6502
6572
|
"use strict";
|
|
6503
|
-
|
|
6573
|
+
init_routes();
|
|
6504
6574
|
init_wasi_abi();
|
|
6505
6575
|
init_wasi_files();
|
|
6506
6576
|
INET4 = 1;
|
|
@@ -7009,7 +7079,7 @@ function firstOther(foreign) {
|
|
|
7009
7079
|
function accepted(imp, scope2) {
|
|
7010
7080
|
const { module, name, kind } = imp;
|
|
7011
7081
|
if (module === PREVIEW1 || module === WASIX) return true;
|
|
7012
|
-
if (!
|
|
7082
|
+
if (!RESERVED2.has(module) && (scope2.extended || scope2.wasi && kind === "function")) return true;
|
|
7013
7083
|
if (scope2.pie && (module === "GOT.mem" || module === "GOT.func")) return true;
|
|
7014
7084
|
if (scope2.pie && module === "env" && kind !== "memory") return true;
|
|
7015
7085
|
if (kind === "memory" && scope2.memory?.module === module && scope2.memory.name === name)
|
|
@@ -7037,7 +7107,7 @@ function unsupportedImport(module, memory, extended = false, foreign = {}) {
|
|
|
7037
7107
|
}
|
|
7038
7108
|
function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign, slicc = {}) {
|
|
7039
7109
|
for (const ns of Object.keys(program)) {
|
|
7040
|
-
if (
|
|
7110
|
+
if (RESERVED2.has(ns) || ns === SLICC)
|
|
7041
7111
|
throw new Error(`the imports module may not define ${ns}`);
|
|
7042
7112
|
}
|
|
7043
7113
|
const imports = {
|
|
@@ -7345,7 +7415,7 @@ async function runWasiThread(init, port) {
|
|
|
7345
7415
|
throw e;
|
|
7346
7416
|
}
|
|
7347
7417
|
}
|
|
7348
|
-
var TRAPPED, PREVIEW1, WASIX, SLICC,
|
|
7418
|
+
var TRAPPED, PREVIEW1, WASIX, SLICC, RESERVED2, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
7349
7419
|
var init_wasi_runtime = __esm({
|
|
7350
7420
|
"src/process/wasi/wasi-runtime.ts"() {
|
|
7351
7421
|
"use strict";
|
|
@@ -7371,7 +7441,7 @@ var init_wasi_runtime = __esm({
|
|
|
7371
7441
|
PREVIEW1 = "wasi_snapshot_preview1";
|
|
7372
7442
|
WASIX = "wasix_32v1";
|
|
7373
7443
|
SLICC = "slicc";
|
|
7374
|
-
|
|
7444
|
+
RESERVED2 = RESERVED_NAMESPACES;
|
|
7375
7445
|
noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
|
|
7376
7446
|
FALLBACK_MAXIMUM_PAGES = 32768;
|
|
7377
7447
|
LinkSync = class {
|