@ai-ecoverse/slicc-kernel 1.91.0 → 1.92.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 +4 -2
- package/dist/driver-worker.js +9 -7
- package/dist/driver-worker.js.map +2 -2
- package/dist/kernel-worker.js +30 -8
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +79 -24
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +30 -8
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +79 -24
- package/dist/process-worker.js.map +3 -3
- package/package.json +2 -2
package/dist/process-worker.js
CHANGED
|
@@ -44,17 +44,20 @@ function hide(target, names) {
|
|
|
44
44
|
}
|
|
45
45
|
function vacate(target, names) {
|
|
46
46
|
for (const name2 of names) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const holders = chain(target);
|
|
48
|
+
for (const holder of holders) {
|
|
49
|
+
if (Object.getOwnPropertyDescriptor(holder, name2)?.configurable) {
|
|
50
|
+
Reflect.deleteProperty(holder, name2);
|
|
51
|
+
}
|
|
50
52
|
}
|
|
51
|
-
|
|
53
|
+
const kept = holders.slice(1).some((holder) => Object.hasOwn(holder, name2));
|
|
54
|
+
const opened2 = Reflect.defineProperty(target, name2, {
|
|
52
55
|
value: void 0,
|
|
53
56
|
writable: true,
|
|
54
57
|
enumerable: false,
|
|
55
58
|
configurable: true
|
|
56
59
|
});
|
|
57
|
-
if (Reflect.get(target, name2) !== void 0) {
|
|
60
|
+
if (kept || !opened2 || Reflect.get(target, name2) !== void 0) {
|
|
58
61
|
throw new Error(`slicc-kernel: cannot withhold ${name2} from a JS program`);
|
|
59
62
|
}
|
|
60
63
|
}
|
|
@@ -80,7 +83,6 @@ var init_lockdown = __esm({
|
|
|
80
83
|
"cookieStore",
|
|
81
84
|
"Worker",
|
|
82
85
|
"SharedWorker",
|
|
83
|
-
"BroadcastChannel",
|
|
84
86
|
"postMessage",
|
|
85
87
|
"close",
|
|
86
88
|
"webkitRequestFileSystem",
|
|
@@ -97,7 +99,7 @@ var init_lockdown = __esm({
|
|
|
97
99
|
"hid",
|
|
98
100
|
"serial"
|
|
99
101
|
];
|
|
100
|
-
OPEN_SLOTS = ["fetch", "WebSocket"];
|
|
102
|
+
OPEN_SLOTS = ["fetch", "WebSocket", "BroadcastChannel"];
|
|
101
103
|
}
|
|
102
104
|
});
|
|
103
105
|
|
|
@@ -1135,6 +1137,7 @@ function toMs(v) {
|
|
|
1135
1137
|
return v instanceof Date ? v.getTime() : v;
|
|
1136
1138
|
}
|
|
1137
1139
|
function wantOf(flags) {
|
|
1140
|
+
if (flags & O_PATH) return 0;
|
|
1138
1141
|
const mode = flags & O_ACCMODE;
|
|
1139
1142
|
const read2 = mode === 1 ? 0 : HOLD_READ;
|
|
1140
1143
|
const write2 = mode !== 0 || (flags & O_TRUNC) !== 0 ? HOLD_WRITE : 0;
|
|
@@ -4292,7 +4295,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
4292
4295
|
var init_version = __esm({
|
|
4293
4296
|
"src/version.ts"() {
|
|
4294
4297
|
"use strict";
|
|
4295
|
-
KERNEL_VERSION = true ? "1.
|
|
4298
|
+
KERNEL_VERSION = true ? "1.92.0" : "0.0.0-dev";
|
|
4296
4299
|
OS_RELEASE = "6.0.0-slicc";
|
|
4297
4300
|
}
|
|
4298
4301
|
});
|
|
@@ -8235,6 +8238,7 @@ function importsContext({
|
|
|
8235
8238
|
fs,
|
|
8236
8239
|
fds,
|
|
8237
8240
|
syscall: call2,
|
|
8241
|
+
net: network(raw, call2),
|
|
8238
8242
|
...processes(host, call2, tid !== MAIN_TID),
|
|
8239
8243
|
async: {
|
|
8240
8244
|
submit: (req) => call2({ op: "async-submit", req }),
|
|
@@ -8270,6 +8274,30 @@ function importsContext({
|
|
|
8270
8274
|
gid: { get: () => live().gid, enumerable: true }
|
|
8271
8275
|
});
|
|
8272
8276
|
}
|
|
8277
|
+
function loopbackHost(host) {
|
|
8278
|
+
if (host === "localhost") return "127.0.0.1";
|
|
8279
|
+
if (typeof host === "string" && LOOPBACK.test(host)) return host;
|
|
8280
|
+
throw new WasiError("EINVAL");
|
|
8281
|
+
}
|
|
8282
|
+
function network(raw, call2) {
|
|
8283
|
+
return {
|
|
8284
|
+
connect({ host, port: port2, nonblock = false }) {
|
|
8285
|
+
const to = loopbackHost(host);
|
|
8286
|
+
if (!Number.isInteger(port2) || port2 < 1 || port2 > 65535) throw new WasiError("EINVAL");
|
|
8287
|
+
const fd = call2({ op: "sock-open", domain: "inet" });
|
|
8288
|
+
const addr = { family: "inet", host: to, port: port2 };
|
|
8289
|
+
const r = raw({ op: "sock-connect", fd, addr, ...nonblock ? { nonblock: true } : {} });
|
|
8290
|
+
if (r.ok || nonblock && r.errno === "EINPROGRESS") return fd;
|
|
8291
|
+
raw({ op: "fd-close", fd });
|
|
8292
|
+
throw new WasiError(r.errno);
|
|
8293
|
+
},
|
|
8294
|
+
ready(fd) {
|
|
8295
|
+
const sel = call2({ op: "fd-select", read: [], write: [fd], timeoutMs: 0 });
|
|
8296
|
+
if (!sel.write.includes(fd)) return E.INPROGRESS;
|
|
8297
|
+
return call2({ op: "sock-getopt", fd, level: SOL_SOCKET, name: SO_ERROR });
|
|
8298
|
+
}
|
|
8299
|
+
};
|
|
8300
|
+
}
|
|
8273
8301
|
function processes(host, call2, inThread) {
|
|
8274
8302
|
const close = (fd) => void call2({ op: "fd-close", fd });
|
|
8275
8303
|
const slot2 = (n, how, mine, theirs) => {
|
|
@@ -8327,7 +8355,7 @@ function processes(host, call2, inThread) {
|
|
|
8327
8355
|
}
|
|
8328
8356
|
};
|
|
8329
8357
|
}
|
|
8330
|
-
var UID2, STDIO;
|
|
8358
|
+
var UID2, LOOPBACK, SOL_SOCKET, SO_ERROR, STDIO;
|
|
8331
8359
|
var init_wasi_imports = __esm({
|
|
8332
8360
|
"src/process/wasi/wasi-imports.ts"() {
|
|
8333
8361
|
"use strict";
|
|
@@ -8336,6 +8364,9 @@ var init_wasi_imports = __esm({
|
|
|
8336
8364
|
init_wasi_threads();
|
|
8337
8365
|
init_wasix_process();
|
|
8338
8366
|
UID2 = 1e3;
|
|
8367
|
+
LOOPBACK = /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
8368
|
+
SOL_SOCKET = 1;
|
|
8369
|
+
SO_ERROR = 4;
|
|
8339
8370
|
STDIO = ["stdin", "stdout", "stderr"];
|
|
8340
8371
|
}
|
|
8341
8372
|
});
|
|
@@ -10060,7 +10091,7 @@ function readAddr(view, ptr) {
|
|
|
10060
10091
|
function ipv6Host(bytes) {
|
|
10061
10092
|
const zeros = (n) => bytes.subarray(0, n).every((b) => b === 0);
|
|
10062
10093
|
if (zeros(16)) return "0.0.0.0";
|
|
10063
|
-
if (zeros(15) && bytes[15] === 1) return
|
|
10094
|
+
if (zeros(15) && bytes[15] === 1) return LOOPBACK2;
|
|
10064
10095
|
if (zeros(10) && bytes[10] === 255 && bytes[11] === 255) return bytes.subarray(12).join(".");
|
|
10065
10096
|
const groups = [0, 2, 4, 6, 8, 10, 12, 14].map(
|
|
10066
10097
|
(i) => (bytes[i] << 8 | bytes[i + 1]).toString(16)
|
|
@@ -10217,7 +10248,7 @@ function wasixSocketImports(host, preview1) {
|
|
|
10217
10248
|
}
|
|
10218
10249
|
};
|
|
10219
10250
|
}
|
|
10220
|
-
var INET4, INET6, UNIX, STREAM, ADDR_IP_SIZE,
|
|
10251
|
+
var INET4, INET6, UNIX, STREAM, ADDR_IP_SIZE, LOOPBACK2, OPTIONS;
|
|
10221
10252
|
var init_wasix_sockets = __esm({
|
|
10222
10253
|
"src/process/wasi/wasix-sockets.ts"() {
|
|
10223
10254
|
"use strict";
|
|
@@ -10229,7 +10260,7 @@ var init_wasix_sockets = __esm({
|
|
|
10229
10260
|
UNIX = 3;
|
|
10230
10261
|
STREAM = 1;
|
|
10231
10262
|
ADDR_IP_SIZE = 18;
|
|
10232
|
-
|
|
10263
|
+
LOOPBACK2 = "127.0.0.1";
|
|
10233
10264
|
OPTIONS = {
|
|
10234
10265
|
1: [1, 15],
|
|
10235
10266
|
2: [1, 2],
|
|
@@ -11453,6 +11484,13 @@ var init_async_sab = __esm({
|
|
|
11453
11484
|
});
|
|
11454
11485
|
|
|
11455
11486
|
// src/process/js/js-kernel.ts
|
|
11487
|
+
function umaskRequest(mask) {
|
|
11488
|
+
if (mask === void 0) return { op: "proc-umask" };
|
|
11489
|
+
if (!Number.isInteger(mask) || mask < 0 || mask > 511) {
|
|
11490
|
+
throw new JsCallError("EINVAL", "umask");
|
|
11491
|
+
}
|
|
11492
|
+
return { op: "proc-umask", mask };
|
|
11493
|
+
}
|
|
11456
11494
|
function modeOf(mode) {
|
|
11457
11495
|
if (!Number.isInteger(mode) || mode < 0 || mode > 4095) {
|
|
11458
11496
|
throw new JsCallError("EINVAL", "chmod");
|
|
@@ -11934,7 +11972,8 @@ function openRequest(abs, o) {
|
|
|
11934
11972
|
flags: flagsOf(o),
|
|
11935
11973
|
position: 0,
|
|
11936
11974
|
...isExclusive(o) ? { exclusive: true } : o.create ? { create: true } : { existing: true },
|
|
11937
|
-
...o.truncate ? { truncate: true } : {}
|
|
11975
|
+
...o.truncate ? { truncate: true } : {},
|
|
11976
|
+
...o.create || isExclusive(o) ? { mode: o.mode === void 0 ? 438 : modeOf(o.mode) } : {}
|
|
11938
11977
|
};
|
|
11939
11978
|
}
|
|
11940
11979
|
function index2(n, what) {
|
|
@@ -12865,8 +12904,8 @@ function netOps(kernel, io) {
|
|
|
12865
12904
|
const failed5 = await kernel.json({
|
|
12866
12905
|
op: "sock-getopt",
|
|
12867
12906
|
fd,
|
|
12868
|
-
level:
|
|
12869
|
-
name:
|
|
12907
|
+
level: SOL_SOCKET2,
|
|
12908
|
+
name: SO_ERROR2
|
|
12870
12909
|
});
|
|
12871
12910
|
if (failed5 !== 0) throw new JsCallError(errnoName(failed5), "connect");
|
|
12872
12911
|
return connection(fd);
|
|
@@ -12874,7 +12913,7 @@ function netOps(kernel, io) {
|
|
|
12874
12913
|
}
|
|
12875
12914
|
};
|
|
12876
12915
|
}
|
|
12877
|
-
var SHUT_RD, SHUT_WR, IPV4, NEVER,
|
|
12916
|
+
var SHUT_RD, SHUT_WR, IPV4, NEVER, SOL_SOCKET2, SO_ERROR2;
|
|
12878
12917
|
var init_js_net = __esm({
|
|
12879
12918
|
"src/process/js/js-net.ts"() {
|
|
12880
12919
|
"use strict";
|
|
@@ -12884,8 +12923,8 @@ var init_js_net = __esm({
|
|
|
12884
12923
|
SHUT_WR = 1;
|
|
12885
12924
|
IPV4 = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
12886
12925
|
NEVER = new AbortController().signal;
|
|
12887
|
-
|
|
12888
|
-
|
|
12926
|
+
SOL_SOCKET2 = 1;
|
|
12927
|
+
SO_ERROR2 = 4;
|
|
12889
12928
|
}
|
|
12890
12929
|
});
|
|
12891
12930
|
|
|
@@ -13288,7 +13327,8 @@ function syncPathOps(kernel, resolve, statOf, open) {
|
|
|
13288
13327
|
mkdir: (path, options) => void kernel.call({
|
|
13289
13328
|
op: "mkdir",
|
|
13290
13329
|
path: resolve(path),
|
|
13291
|
-
...options?.recursive === false ? { exclusive: true } : {}
|
|
13330
|
+
...options?.recursive === false ? { exclusive: true } : {},
|
|
13331
|
+
mode: options?.mode === void 0 ? 511 : modeOf(options.mode)
|
|
13292
13332
|
}),
|
|
13293
13333
|
rm: (path) => void kernel.call({ op: "rm", path: resolve(path) }),
|
|
13294
13334
|
unlink: (path) => void kernel.call({ op: "unlink", path: resolve(path) }),
|
|
@@ -13312,8 +13352,14 @@ function syncPathOps(kernel, resolve, statOf, open) {
|
|
|
13312
13352
|
kernel.call({ op: "fd-path-flush", path: abs });
|
|
13313
13353
|
return kernel.bytes({ op: "read", path: abs });
|
|
13314
13354
|
},
|
|
13315
|
-
writeFile(path, data) {
|
|
13316
|
-
const
|
|
13355
|
+
writeFile(path, data, options) {
|
|
13356
|
+
const mode = options?.mode;
|
|
13357
|
+
const file = open(path, {
|
|
13358
|
+
write: true,
|
|
13359
|
+
create: true,
|
|
13360
|
+
truncate: true,
|
|
13361
|
+
...mode !== void 0 ? { mode } : {}
|
|
13362
|
+
});
|
|
13317
13363
|
try {
|
|
13318
13364
|
file.write(0, typeof data === "string" ? encoder3.encode(data) : data);
|
|
13319
13365
|
} finally {
|
|
@@ -13812,6 +13858,7 @@ function createContext(o) {
|
|
|
13812
13858
|
},
|
|
13813
13859
|
kill: killer({ self: o.pid, kernel, syncKernel, lane, writes, modes: terminal.modes }),
|
|
13814
13860
|
cred: () => syncKernel.json({ op: "proc-cred" }),
|
|
13861
|
+
umask: (mask) => syncKernel.json(umaskRequest(mask)),
|
|
13815
13862
|
setcred(change) {
|
|
13816
13863
|
if (typeof change !== "object" || change === null || Array.isArray(change)) {
|
|
13817
13864
|
throw new JsCallError("EINVAL", "setcred");
|
|
@@ -13858,6 +13905,7 @@ function createContext(o) {
|
|
|
13858
13905
|
},
|
|
13859
13906
|
sync,
|
|
13860
13907
|
fetch: fetchOp(kernel),
|
|
13908
|
+
umask: async (mask) => await kernel.json(umaskRequest(mask)),
|
|
13861
13909
|
sudo: async (args) => await kernel.json({
|
|
13862
13910
|
op: "proc-sudo",
|
|
13863
13911
|
args: [...args],
|
|
@@ -14007,7 +14055,8 @@ function pathOps(kernel, resolve, statOf, open) {
|
|
|
14007
14055
|
mkdir: async (path, options) => void await kernel.call({
|
|
14008
14056
|
op: "mkdir",
|
|
14009
14057
|
path: resolve(path),
|
|
14010
|
-
...options?.recursive === false ? { exclusive: true } : {}
|
|
14058
|
+
...options?.recursive === false ? { exclusive: true } : {},
|
|
14059
|
+
mode: options?.mode === void 0 ? 511 : modeOf(options.mode)
|
|
14011
14060
|
}),
|
|
14012
14061
|
rm: async (path) => void await kernel.call({ op: "rm", path: resolve(path) }),
|
|
14013
14062
|
unlink: async (path) => void await kernel.call({ op: "unlink", path: resolve(path) }),
|
|
@@ -14031,8 +14080,14 @@ function pathOps(kernel, resolve, statOf, open) {
|
|
|
14031
14080
|
await kernel.call({ op: "fd-path-flush", path: abs });
|
|
14032
14081
|
return kernel.bytes({ op: "read", path: abs });
|
|
14033
14082
|
},
|
|
14034
|
-
async writeFile(path, data) {
|
|
14035
|
-
const
|
|
14083
|
+
async writeFile(path, data, options) {
|
|
14084
|
+
const mode = options?.mode;
|
|
14085
|
+
const file = await open(path, {
|
|
14086
|
+
write: true,
|
|
14087
|
+
create: true,
|
|
14088
|
+
truncate: true,
|
|
14089
|
+
...mode !== void 0 ? { mode } : {}
|
|
14090
|
+
});
|
|
14036
14091
|
try {
|
|
14037
14092
|
await file.write(0, typeof data === "string" ? encoder4.encode(data) : data);
|
|
14038
14093
|
} finally {
|