@ai-ecoverse/slicc-kernel 1.125.9 → 1.125.11
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 +13 -4
- package/dist/kernel-worker.js +38 -10
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +76 -15
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +38 -10
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +76 -15
- package/dist/process-worker.js.map +3 -3
- package/dist/types/kernel/process.d.ts +2 -0
- package/dist/types/process/js/js-children.d.ts +5 -0
- package/dist/types/process/js/js-context.d.ts +2 -0
- package/dist/types/process/js/js-sync.d.ts +3 -0
- package/dist/types/process/kernel-streams.d.ts +1 -0
- package/package.json +8 -8
|
@@ -6392,7 +6392,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
6392
6392
|
var init_version = __esm({
|
|
6393
6393
|
"src/version.ts"() {
|
|
6394
6394
|
"use strict";
|
|
6395
|
-
KERNEL_VERSION = true ? "1.125.
|
|
6395
|
+
KERNEL_VERSION = true ? "1.125.11" : "0.0.0-dev";
|
|
6396
6396
|
OS_RELEASE = "6.0.0-slicc";
|
|
6397
6397
|
}
|
|
6398
6398
|
});
|
|
@@ -6464,6 +6464,7 @@ function childOps(kernel, io, defaults, sync) {
|
|
|
6464
6464
|
const group = groupOf(o, "spawn");
|
|
6465
6465
|
const named = argv0Of(o.argv0, "spawn");
|
|
6466
6466
|
const death = deathOf(o.parentDeathSignal, defaults);
|
|
6467
|
+
const inherit = fdsOf(o.fds);
|
|
6467
6468
|
return (stdio) => ({
|
|
6468
6469
|
op: "proc-spawn",
|
|
6469
6470
|
file,
|
|
@@ -6473,6 +6474,7 @@ function childOps(kernel, io, defaults, sync) {
|
|
|
6473
6474
|
cwd: o.cwd ?? defaults.cwd,
|
|
6474
6475
|
...o.cwd !== void 0 ? { chdir: true } : {},
|
|
6475
6476
|
stdio,
|
|
6477
|
+
...inherit.length > 0 ? { inherit } : {},
|
|
6476
6478
|
...group,
|
|
6477
6479
|
...death
|
|
6478
6480
|
});
|
|
@@ -6508,6 +6510,20 @@ function childOps(kernel, io, defaults, sync) {
|
|
|
6508
6510
|
};
|
|
6509
6511
|
return { spawn, wait: wait2, kill, spawnSync };
|
|
6510
6512
|
}
|
|
6513
|
+
function fdsOf(fds) {
|
|
6514
|
+
if (fds === void 0) return [];
|
|
6515
|
+
if (typeof fds !== "object" || fds === null || Array.isArray(fds)) {
|
|
6516
|
+
throw new JsCallError("EINVAL", "spawn");
|
|
6517
|
+
}
|
|
6518
|
+
return Object.entries(fds).map(([key, from]) => {
|
|
6519
|
+
const fd = Number(key);
|
|
6520
|
+
const valid = Number.isInteger(fd) && fd >= 3 && String(fd) === key;
|
|
6521
|
+
if (!valid || !Number.isInteger(from) || from < 0) {
|
|
6522
|
+
throw new JsCallError("EINVAL", "spawn");
|
|
6523
|
+
}
|
|
6524
|
+
return { fd, kernel: from };
|
|
6525
|
+
});
|
|
6526
|
+
}
|
|
6511
6527
|
function groupOf(o, call2) {
|
|
6512
6528
|
const { pgid, session } = o;
|
|
6513
6529
|
const valid = pgid === void 0 || Number.isInteger(pgid) && pgid >= 0;
|
|
@@ -11294,8 +11310,11 @@ function syncOps(kernel, shared) {
|
|
|
11294
11310
|
handles.get(fd)?.();
|
|
11295
11311
|
handles.delete(fd);
|
|
11296
11312
|
infos.delete(fd);
|
|
11313
|
+
shared.closing?.(fd);
|
|
11297
11314
|
kernel.call({ op: "fd-close", fd });
|
|
11298
11315
|
},
|
|
11316
|
+
socketpair: () => kernel.json({ op: "sock-pair", domain: "unix", type: "stream" }),
|
|
11317
|
+
pipe: () => kernel.json({ op: "fd-pipe" }),
|
|
11299
11318
|
open: procOpenSync(open, kernel, { resolve, pid: shared.pid }),
|
|
11300
11319
|
fs: procFsSync(syncPathOps(kernel, resolve, statOf, open, tryDevSync), kernel, {
|
|
11301
11320
|
resolve,
|
|
@@ -12002,12 +12021,37 @@ function watchingSyncOps(kernel, syncKernel, shared) {
|
|
|
12002
12021
|
};
|
|
12003
12022
|
return { ...ops, fs: { ...ops.fs, watch } };
|
|
12004
12023
|
}
|
|
12024
|
+
function pendingReads(kernel, info, random) {
|
|
12025
|
+
const reading = /* @__PURE__ */ new Map();
|
|
12026
|
+
const read2 = async (fd, max = CHUNK, signal) => {
|
|
12027
|
+
index2(max, "read");
|
|
12028
|
+
const emulated = readDevice(await info(fd), max, random);
|
|
12029
|
+
if (emulated) return emulated;
|
|
12030
|
+
const stop = new AbortController();
|
|
12031
|
+
const waits = reading.get(fd) ?? /* @__PURE__ */ new Set();
|
|
12032
|
+
reading.set(fd, waits.add(stop));
|
|
12033
|
+
try {
|
|
12034
|
+
const n = Math.min(max, MAX_IO);
|
|
12035
|
+
if (signal) return await readPipe(kernel, fd, n, AbortSignal.any([signal, stop.signal]));
|
|
12036
|
+
const r = await kernel.blocking({ op: "fd-read", fd, max: n }, stop.signal);
|
|
12037
|
+
return r.ok && r.kind === "bytes" ? r.bytes : new Uint8Array(0);
|
|
12038
|
+
} finally {
|
|
12039
|
+
waits.delete(stop);
|
|
12040
|
+
if (waits.size === 0 && reading.get(fd) === waits) reading.delete(fd);
|
|
12041
|
+
}
|
|
12042
|
+
};
|
|
12043
|
+
const closing = (fd) => {
|
|
12044
|
+
for (const stop of reading.get(fd) ?? []) stop.abort(new JsCallError("EBADF", "read"));
|
|
12045
|
+
reading.delete(fd);
|
|
12046
|
+
};
|
|
12047
|
+
return { read: read2, closing };
|
|
12048
|
+
}
|
|
12005
12049
|
function createContext(o) {
|
|
12006
12050
|
const { kernel } = o;
|
|
12007
12051
|
const infos = /* @__PURE__ */ new Map();
|
|
12008
12052
|
const handles = /* @__PURE__ */ new Map();
|
|
12009
12053
|
const pending = /* @__PURE__ */ new Set();
|
|
12010
|
-
const random = o.random ??
|
|
12054
|
+
const random = o.random ?? cryptoRandom;
|
|
12011
12055
|
const resolve = (path) => resolvePath(o.cwd, path);
|
|
12012
12056
|
const tryDev = (abs) => resolveDevAsync(kernel, abs);
|
|
12013
12057
|
let exiting;
|
|
@@ -12027,12 +12071,7 @@ function createContext(o) {
|
|
|
12027
12071
|
infos.set(fd, got);
|
|
12028
12072
|
return got;
|
|
12029
12073
|
};
|
|
12030
|
-
const
|
|
12031
|
-
index2(max, "read");
|
|
12032
|
-
const emulated = readDevice(await info(fd), max, random);
|
|
12033
|
-
if (emulated) return emulated;
|
|
12034
|
-
return readPipe(kernel, fd, Math.min(max, MAX_IO), signal);
|
|
12035
|
-
};
|
|
12074
|
+
const { read: read2, closing } = pendingReads(kernel, info, random);
|
|
12036
12075
|
const { writes, writeAll } = writer(kernel, info, o.pid);
|
|
12037
12076
|
const write2 = (fd, data) => {
|
|
12038
12077
|
const bytes = typeof data === "string" ? encoder4.encode(data) : data;
|
|
@@ -12075,9 +12114,10 @@ function createContext(o) {
|
|
|
12075
12114
|
if (o.lane && o.lane !== noLane) kernel.syncLane = o.lane;
|
|
12076
12115
|
const syncKernel = new JsSyncKernel(lane, kernel, unwind);
|
|
12077
12116
|
const terminal = ttyOps(kernel);
|
|
12117
|
+
const shared = { pid: o.pid, resolve, random, infos, handles, closing };
|
|
12078
12118
|
const sync = {
|
|
12079
12119
|
kernel: KERNEL_INFO,
|
|
12080
|
-
...watchingSyncOps(kernel, syncKernel,
|
|
12120
|
+
...watchingSyncOps(kernel, syncKernel, shared),
|
|
12081
12121
|
run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve, signal: signalNumber }, options),
|
|
12082
12122
|
spawn: (options) => spawnSync(options),
|
|
12083
12123
|
exit: (status2 = 0) => {
|
|
@@ -12116,8 +12156,11 @@ function createContext(o) {
|
|
|
12116
12156
|
handles.get(fd)?.();
|
|
12117
12157
|
handles.delete(fd);
|
|
12118
12158
|
infos.delete(fd);
|
|
12159
|
+
closing(fd);
|
|
12119
12160
|
await kernel.call({ op: "fd-close", fd });
|
|
12120
12161
|
},
|
|
12162
|
+
socketpair: async () => await kernel.json({ op: "sock-pair", domain: "unix", type: "stream" }),
|
|
12163
|
+
pipe: async () => await kernel.json({ op: "fd-pipe" }),
|
|
12121
12164
|
async fdStatus(fd) {
|
|
12122
12165
|
const type = typeOf(await info(fd));
|
|
12123
12166
|
return { type, tty: type === "tty", seekable: type === "file" };
|
|
@@ -12342,7 +12385,7 @@ function pathOps(kernel, resolve, statOf, open, tryDev) {
|
|
|
12342
12385
|
}
|
|
12343
12386
|
};
|
|
12344
12387
|
}
|
|
12345
|
-
var KERNEL_INFO, JsExit, encoder4;
|
|
12388
|
+
var KERNEL_INFO, JsExit, encoder4, cryptoRandom;
|
|
12346
12389
|
var init_js_context = __esm({
|
|
12347
12390
|
"src/process/js/js-context.ts"() {
|
|
12348
12391
|
"use strict";
|
|
@@ -12373,6 +12416,7 @@ var init_js_context = __esm({
|
|
|
12373
12416
|
}
|
|
12374
12417
|
};
|
|
12375
12418
|
encoder4 = new TextEncoder();
|
|
12419
|
+
cryptoRandom = (bytes) => void crypto.getRandomValues(bytes);
|
|
12376
12420
|
}
|
|
12377
12421
|
});
|
|
12378
12422
|
|
|
@@ -12846,7 +12890,7 @@ var init_kernel_streams = __esm({
|
|
|
12846
12890
|
}
|
|
12847
12891
|
}
|
|
12848
12892
|
}
|
|
12849
|
-
openNode(stream, path, opener) {
|
|
12893
|
+
openNode(stream, path, opener, terminal = false) {
|
|
12850
12894
|
let kfd;
|
|
12851
12895
|
try {
|
|
12852
12896
|
kfd = this.call(() => opener.call(this.sys, stream.flags & 3));
|
|
@@ -12854,7 +12898,7 @@ var init_kernel_streams = __esm({
|
|
|
12854
12898
|
this.Fs.closeStream(stream.fd);
|
|
12855
12899
|
throw e;
|
|
12856
12900
|
}
|
|
12857
|
-
this.attach(stream, kfd,
|
|
12901
|
+
this.attach(stream, kfd, terminal);
|
|
12858
12902
|
this.nameStream(stream, path);
|
|
12859
12903
|
if (path === CLIPBOARD_PATH2) this.reportClose(kfd);
|
|
12860
12904
|
}
|
|
@@ -12944,8 +12988,10 @@ var init_kernel_streams = __esm({
|
|
|
12944
12988
|
const make = (parent, name2) => {
|
|
12945
12989
|
const dir = getPath.call(fs, parent);
|
|
12946
12990
|
if (dir === "/dev" && name2 === "pts") mkdir.call(fs, "/dev/pts", 493);
|
|
12991
|
+
else if (dir === "/dev" && name2 === "ptmx" && this.sys.openPty)
|
|
12992
|
+
this.ptyNode("/dev/ptmx", makedev.call(fs, 5, 2));
|
|
12947
12993
|
else if (dir === "/dev/pts" && numbers().includes(Number(name2)) && /^\d+$/.test(name2))
|
|
12948
|
-
|
|
12994
|
+
this.ptyNode(`/dev/pts/${name2}`, makedev.call(fs, PTS_MAJOR, Number(name2)));
|
|
12949
12995
|
else return false;
|
|
12950
12996
|
return true;
|
|
12951
12997
|
};
|
|
@@ -12969,9 +13015,23 @@ var init_kernel_streams = __esm({
|
|
|
12969
13015
|
const at = path.replace(/\/+$/, "");
|
|
12970
13016
|
if (at === "/dev/pts") return [".", "..", ...numbers().map(String)];
|
|
12971
13017
|
const names = readdir.call(fs, path);
|
|
12972
|
-
|
|
13018
|
+
if (at !== "/dev") return names;
|
|
13019
|
+
const extra = ["pts", ...this.sys.openPty ? ["ptmx"] : []];
|
|
13020
|
+
return [...names, ...extra.filter((name2) => !names.includes(name2))];
|
|
12973
13021
|
};
|
|
12974
13022
|
}
|
|
13023
|
+
ptyNode(path, dev) {
|
|
13024
|
+
const fs = this.Fs;
|
|
13025
|
+
fs.registerDevice?.call(fs, dev, {
|
|
13026
|
+
open: (stream) => {
|
|
13027
|
+
const n = PTY_PATH.exec(path)?.[1];
|
|
13028
|
+
const { openPty, openPts } = this.sys;
|
|
13029
|
+
const opener = () => n === void 0 ? openPty.call(this.sys) : openPts.call(this.sys, Number(n), (stream.flags & O_NOCTTY) !== 0);
|
|
13030
|
+
this.openNode(stream, path, opener, true);
|
|
13031
|
+
}
|
|
13032
|
+
});
|
|
13033
|
+
fs.mkdev?.call(fs, path, dev);
|
|
13034
|
+
}
|
|
12975
13035
|
ptsTarget(path, st) {
|
|
12976
13036
|
if ((st?.rdev ?? 0) < PTS_MAJOR << 8) return void 0;
|
|
12977
13037
|
const { lookupPath } = this.Fs;
|
|
@@ -13172,7 +13232,8 @@ var init_kernel_streams = __esm({
|
|
|
13172
13232
|
if (!isPtyPath(path))
|
|
13173
13233
|
return this.pathStat(path, original.call(fs, path, ...rest2), name2, owned);
|
|
13174
13234
|
this.existingPty(path);
|
|
13175
|
-
|
|
13235
|
+
const st = ptyStat(path);
|
|
13236
|
+
return this.options.owners === true ? { ...st, uid: 0, gid: 0 } : st;
|
|
13176
13237
|
};
|
|
13177
13238
|
}
|
|
13178
13239
|
}
|