@ai-ecoverse/slicc-kernel 1.71.0 → 1.72.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 +21 -4
- package/dist/index.js +29 -0
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +400 -37
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +43 -7
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +367 -35
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +43 -7
- package/dist/process-worker.js.map +2 -2
- package/package.json +5 -4
package/dist/process-worker.js
CHANGED
|
@@ -6025,6 +6025,7 @@ var init_wasi_fds = __esm({
|
|
|
6025
6025
|
}
|
|
6026
6026
|
}
|
|
6027
6027
|
resolve(dirfd, path) {
|
|
6028
|
+
if (path === "") throw new WasiError("ENOENT");
|
|
6028
6029
|
const joined2 = path.startsWith("/") ? path : `${this.dir(dirfd).path}/${path}`;
|
|
6029
6030
|
return joined2.split("/").includes("..") ? physical(this.fs, joined2) : normalize(joined2);
|
|
6030
6031
|
}
|
|
@@ -6935,7 +6936,11 @@ var init_wasi_host = __esm({
|
|
|
6935
6936
|
o.fs.rename(from, to);
|
|
6936
6937
|
fds.renamed(from, to, replaced);
|
|
6937
6938
|
},
|
|
6938
|
-
path_symlink: (tp, tl, dirfd, p, l) =>
|
|
6939
|
+
path_symlink: (tp, tl, dirfd, p, l) => {
|
|
6940
|
+
const path = at(dirfd, p, l);
|
|
6941
|
+
if (tl === 0) throw new WasiError("ENOENT");
|
|
6942
|
+
o.fs.symlink(mem.string(tp, tl), path);
|
|
6943
|
+
},
|
|
6939
6944
|
path_readlink: (dirfd, p, l, buf, len, used) => {
|
|
6940
6945
|
const target = new TextEncoder().encode(o.fs.readlink(at(dirfd, p, l)));
|
|
6941
6946
|
const n = Math.min(len, target.length);
|
|
@@ -10950,6 +10955,11 @@ var init_js_kernel = __esm({
|
|
|
10950
10955
|
freeze() {
|
|
10951
10956
|
while (Atomics.load(this.header, SAB_I_STOP) === 1) Atomics.wait(this.header, SAB_I_STOP, 1);
|
|
10952
10957
|
}
|
|
10958
|
+
disposition(sig) {
|
|
10959
|
+
if (this.handlers.has(sig)) return "caught";
|
|
10960
|
+
if (this.ignored & sigbit(sig)) return "ignored";
|
|
10961
|
+
return defaultAction(sig);
|
|
10962
|
+
}
|
|
10953
10963
|
setHandler(sig, handler) {
|
|
10954
10964
|
if (sig === SIG.KILL || sig === SIG.STOP) {
|
|
10955
10965
|
return Promise.reject(new JsCallError("EINVAL", "signal"));
|
|
@@ -11603,7 +11613,7 @@ function settled(lane, writes) {
|
|
|
11603
11613
|
});
|
|
11604
11614
|
return out;
|
|
11605
11615
|
}
|
|
11606
|
-
function exitAtOnce(lane, writes, modes, status2) {
|
|
11616
|
+
function exitAtOnce(lane, writes, modes, status2, last = { op: "proc-exit", status: status2 & 255 }) {
|
|
11607
11617
|
const done = settled(lane, writes);
|
|
11608
11618
|
const broken = /* @__PURE__ */ new Set();
|
|
11609
11619
|
for (const w of writes) {
|
|
@@ -11613,7 +11623,7 @@ function exitAtOnce(lane, writes, modes, status2) {
|
|
|
11613
11623
|
if (!writeOut(lane, w.fd, w.data.subarray(w.at + (sent ?? 0)))) broken.add(w.fd);
|
|
11614
11624
|
}
|
|
11615
11625
|
for (const mode of modes) restoreMode(lane, mode);
|
|
11616
|
-
lane(
|
|
11626
|
+
lane(last);
|
|
11617
11627
|
const parked = new Int32Array(new SharedArrayBuffer(4));
|
|
11618
11628
|
for (; ; ) Atomics.wait(parked, 0, 0);
|
|
11619
11629
|
}
|
|
@@ -12180,7 +12190,7 @@ var init_js_run = __esm({
|
|
|
12180
12190
|
|
|
12181
12191
|
// src/process/js/js-sync.ts
|
|
12182
12192
|
function laneOf(lane) {
|
|
12183
|
-
if (!lane) return
|
|
12193
|
+
if (!lane) return noLane;
|
|
12184
12194
|
const transport = createSyncSabTransport(lane.sab, lane.port);
|
|
12185
12195
|
return (req) => transport.call(req, Number.POSITIVE_INFINITY, req.op);
|
|
12186
12196
|
}
|
|
@@ -12381,7 +12391,7 @@ function syncPathOps(kernel, resolve, statOf, open) {
|
|
|
12381
12391
|
}
|
|
12382
12392
|
};
|
|
12383
12393
|
}
|
|
12384
|
-
var encoder3, JsSyncKernel;
|
|
12394
|
+
var encoder3, noLane, JsSyncKernel;
|
|
12385
12395
|
var init_js_sync = __esm({
|
|
12386
12396
|
"src/process/js/js-sync.ts"() {
|
|
12387
12397
|
"use strict";
|
|
@@ -12392,6 +12402,7 @@ var init_js_sync = __esm({
|
|
|
12392
12402
|
init_js_io();
|
|
12393
12403
|
init_js_kernel();
|
|
12394
12404
|
encoder3 = new TextEncoder();
|
|
12405
|
+
noLane = () => ({ ok: false, errno: "ENOSYS", message: "no sync lane" });
|
|
12395
12406
|
JsSyncKernel = class {
|
|
12396
12407
|
lane;
|
|
12397
12408
|
kernel;
|
|
@@ -12706,6 +12717,30 @@ function resolvePath(cwd, path) {
|
|
|
12706
12717
|
}
|
|
12707
12718
|
return `/${parts.join("/")}`;
|
|
12708
12719
|
}
|
|
12720
|
+
function killer(d) {
|
|
12721
|
+
return (pid, signal = "SIGTERM") => {
|
|
12722
|
+
const sig = signal === 0 ? 0 : signalNumber(signal);
|
|
12723
|
+
const self = sig !== 0 && includesSelf(d.syncKernel, d.self, pid);
|
|
12724
|
+
if (!self || d.kernel.disposition(sig) !== "terminate") {
|
|
12725
|
+
d.syncKernel.call({ op: "proc-kill", pid, sig });
|
|
12726
|
+
return;
|
|
12727
|
+
}
|
|
12728
|
+
const target = pid === d.self ? {} : { target: pid };
|
|
12729
|
+
const r = d.lane({ op: "proc-kill-self", sig, ...target, probe: true });
|
|
12730
|
+
if (!r.ok) throw new JsCallError(r.errno, "kill");
|
|
12731
|
+
if (r.kind === "void") return;
|
|
12732
|
+
exitAtOnce(d.lane, [...d.writes], d.modes(), 128 + sig, {
|
|
12733
|
+
op: "proc-kill-self",
|
|
12734
|
+
sig,
|
|
12735
|
+
...target
|
|
12736
|
+
});
|
|
12737
|
+
};
|
|
12738
|
+
}
|
|
12739
|
+
function includesSelf(kernel, self, pid) {
|
|
12740
|
+
if (pid === self || pid === 0) return true;
|
|
12741
|
+
if (pid > 0 || pid === -1) return false;
|
|
12742
|
+
return kernel.json({ op: "proc-getpgid", pid: 0 }) === -pid;
|
|
12743
|
+
}
|
|
12709
12744
|
function writer(kernel, info, pid) {
|
|
12710
12745
|
const writes = /* @__PURE__ */ new Set();
|
|
12711
12746
|
const sendAll = async (fd, data, i, w, signal) => {
|
|
@@ -12817,7 +12852,7 @@ function createContext(o) {
|
|
|
12817
12852
|
};
|
|
12818
12853
|
const fs = pathOps(kernel, resolve, statOf, open);
|
|
12819
12854
|
const lane = o.lane ?? laneOf(void 0);
|
|
12820
|
-
if (o.lane) kernel.syncLane = o.lane;
|
|
12855
|
+
if (o.lane && o.lane !== noLane) kernel.syncLane = o.lane;
|
|
12821
12856
|
const syncKernel = new JsSyncKernel(lane, kernel, unwind);
|
|
12822
12857
|
const terminal = ttyOps(kernel);
|
|
12823
12858
|
const sync = {
|
|
@@ -12826,7 +12861,8 @@ function createContext(o) {
|
|
|
12826
12861
|
exit: (status2 = 0) => {
|
|
12827
12862
|
exiting ??= status2 & 255;
|
|
12828
12863
|
return exitAtOnce(lane, [...writes], terminal.modes(), exiting);
|
|
12829
|
-
}
|
|
12864
|
+
},
|
|
12865
|
+
kill: killer({ self: o.pid, kernel, syncKernel, lane, writes, modes: terminal.modes })
|
|
12830
12866
|
};
|
|
12831
12867
|
const io = { read: read2, send: writeAll, close: (fd) => ctx.close(fd) };
|
|
12832
12868
|
const children = childOps(kernel, io, { env: o.env, cwd: o.cwd, signal: signalNumber });
|