@ai-ecoverse/slicc-kernel 1.86.0 → 1.87.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 +7 -5
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +53 -28
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +84 -46
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +53 -28
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +84 -46
- package/dist/process-worker.js.map +3 -3
- package/package.json +1 -1
package/dist/process-worker.js
CHANGED
|
@@ -2378,7 +2378,7 @@ var init_kernel_streams = __esm({
|
|
|
2378
2378
|
openSealed(open, path, flags, mode) {
|
|
2379
2379
|
const { openSealed } = this.sys;
|
|
2380
2380
|
if (path !== SEALED_PATH || !openSealed) return void 0;
|
|
2381
|
-
const kfd = this.call(() => openSealed.call(this.sys));
|
|
2381
|
+
const kfd = this.call(() => openSealed.call(this.sys, flags & 3));
|
|
2382
2382
|
return this.vessel(open, kfd, { path, flags, mode }, false);
|
|
2383
2383
|
}
|
|
2384
2384
|
openClipboard(open, path, flags, mode) {
|
|
@@ -3433,8 +3433,8 @@ function describeInherited(Fs, sys, streams, livePath, actions = []) {
|
|
|
3433
3433
|
const out = [];
|
|
3434
3434
|
for (const [fd, stream] of slots3) {
|
|
3435
3435
|
promote(stream);
|
|
3436
|
-
const
|
|
3437
|
-
if (
|
|
3436
|
+
const slot2 = inheritedSlot(fd, stream);
|
|
3437
|
+
if (slot2) out.push(slot2);
|
|
3438
3438
|
}
|
|
3439
3439
|
return out;
|
|
3440
3440
|
}
|
|
@@ -3652,7 +3652,7 @@ function createProcessKernel(deps) {
|
|
|
3652
3652
|
const reaped = /* @__PURE__ */ new Map();
|
|
3653
3653
|
const call2 = (req, label) => transport.call(req, Infinity, label);
|
|
3654
3654
|
const at = (path) => path === "" || path.startsWith("/") ? path : `${Fs.cwd()}/${path}`;
|
|
3655
|
-
const
|
|
3655
|
+
const slot2 = (fd, n, promote) => {
|
|
3656
3656
|
const stream = fd >= 0 ? Fs.getStream(fd) : null;
|
|
3657
3657
|
if (!stream) return { none: true };
|
|
3658
3658
|
promote?.(stream);
|
|
@@ -3701,7 +3701,7 @@ function createProcessKernel(deps) {
|
|
|
3701
3701
|
const unflushed = flushed(deps.beforeSpawn);
|
|
3702
3702
|
if (unflushed < 0) return unflushed;
|
|
3703
3703
|
const promote = deps.stdioPromoter?.();
|
|
3704
|
-
const stdio = [0, 1, 2].map((n) =>
|
|
3704
|
+
const stdio = [0, 1, 2].map((n) => slot2(fds[n] ?? -1, n, promote));
|
|
3705
3705
|
const inherit = deps.inherit?.(actions) ?? [];
|
|
3706
3706
|
const req = {
|
|
3707
3707
|
op: "proc-spawn",
|
|
@@ -4645,8 +4645,8 @@ function kernelSys(transport) {
|
|
|
4645
4645
|
openPts(n, noctty) {
|
|
4646
4646
|
return json2(call2({ op: "pty-slave-open", n, noctty }, `pty-slave-open ${n}`));
|
|
4647
4647
|
},
|
|
4648
|
-
openSealed() {
|
|
4649
|
-
return json2(call2({ op: "fd-open-sealed" }, "fd-open-sealed"));
|
|
4648
|
+
openSealed(flags) {
|
|
4649
|
+
return json2(call2({ op: "fd-open-sealed", flags }, "fd-open-sealed"));
|
|
4650
4650
|
},
|
|
4651
4651
|
openClipboard(flags) {
|
|
4652
4652
|
return json2(call2({ op: "fd-open-clipboard", flags }, "fd-open-clipboard"));
|
|
@@ -6333,12 +6333,10 @@ var init_wasi_fds = __esm({
|
|
|
6333
6333
|
let fd;
|
|
6334
6334
|
let kind;
|
|
6335
6335
|
if (path === SEALED_PATH2 && openSealed) {
|
|
6336
|
-
|
|
6337
|
-
if (oflags & OFLAGS.CREAT && oflags & OFLAGS.EXCL) throw new WasiError("EEXIST");
|
|
6338
|
-
fd = openSealed.call(this.kernel.sys);
|
|
6336
|
+
fd = this.openCharDevice(openSealed, oflags, rights);
|
|
6339
6337
|
kind = "sealed";
|
|
6340
6338
|
} else if (path === CLIPBOARD_PATH2 && openClipboard) {
|
|
6341
|
-
fd = this.
|
|
6339
|
+
fd = this.openCharDevice(openClipboard, oflags, rights);
|
|
6342
6340
|
kind = "clipboard";
|
|
6343
6341
|
} else if (path === "/dev/tty" || /^\/dev\/tty\d+$/.test(path)) {
|
|
6344
6342
|
fd = openTty?.call(this.kernel.sys, path === "/dev/tty" ? void 0 : path);
|
|
@@ -6349,12 +6347,12 @@ var init_wasi_fds = __esm({
|
|
|
6349
6347
|
this.bump();
|
|
6350
6348
|
return fd;
|
|
6351
6349
|
}
|
|
6352
|
-
|
|
6350
|
+
openCharDevice(openDevice2, oflags, rights) {
|
|
6353
6351
|
if (oflags & OFLAGS.DIRECTORY) throw new WasiError("ENOTDIR");
|
|
6354
6352
|
if (oflags & OFLAGS.CREAT && oflags & OFLAGS.EXCL) throw new WasiError("EEXIST");
|
|
6355
6353
|
const want = wantOf2(oflags, rights);
|
|
6356
6354
|
const flags = want === 6 ? O_RDWR4 : want === 2 ? O_WRONLY4 : 0;
|
|
6357
|
-
return
|
|
6355
|
+
return openDevice2.call(this.kernel.sys, flags);
|
|
6358
6356
|
}
|
|
6359
6357
|
open(path, oflags, rights, fdflags) {
|
|
6360
6358
|
const device2 = deviceOf(path);
|
|
@@ -8041,7 +8039,7 @@ function importsContext({
|
|
|
8041
8039
|
}
|
|
8042
8040
|
function processes(host, call2, inThread) {
|
|
8043
8041
|
const close = (fd) => void call2({ op: "fd-close", fd });
|
|
8044
|
-
const
|
|
8042
|
+
const slot2 = (n, how, mine, theirs) => {
|
|
8045
8043
|
if (how === "inherit") return { fd: n };
|
|
8046
8044
|
if (how === "null") return { none: true };
|
|
8047
8045
|
const [read2, write2] = call2({ op: "fd-pipe" });
|
|
@@ -8055,7 +8053,7 @@ function processes(host, call2, inThread) {
|
|
|
8055
8053
|
const theirs = [];
|
|
8056
8054
|
host.fds.promoteFiles();
|
|
8057
8055
|
try {
|
|
8058
|
-
const stdio = STDIO.map((name2, n) =>
|
|
8056
|
+
const stdio = STDIO.map((name2, n) => slot2(n, o[name2] ?? "inherit", mine, theirs));
|
|
8059
8057
|
const req = {
|
|
8060
8058
|
op: "proc-spawn",
|
|
8061
8059
|
file: o.argv[0],
|
|
@@ -11383,7 +11381,7 @@ function writable(io, fd) {
|
|
|
11383
11381
|
abort: () => io.close(fd)
|
|
11384
11382
|
});
|
|
11385
11383
|
}
|
|
11386
|
-
function childOps(kernel, io, defaults) {
|
|
11384
|
+
function childOps(kernel, io, defaults, sync) {
|
|
11387
11385
|
const wait2 = async (pid) => {
|
|
11388
11386
|
const r = await kernel.blocking({ op: "proc-wait", pid, nohang: false });
|
|
11389
11387
|
const [, status2] = r.ok && r.kind === "json" ? r.json : [0, 0];
|
|
@@ -11403,25 +11401,43 @@ function childOps(kernel, io, defaults) {
|
|
|
11403
11401
|
kill: (signal) => kill(pid, signal)
|
|
11404
11402
|
};
|
|
11405
11403
|
};
|
|
11406
|
-
const
|
|
11404
|
+
const request = (o) => {
|
|
11407
11405
|
const [file] = o.argv;
|
|
11408
11406
|
if (file === void 0) throw new JsCallError("EINVAL", "spawn");
|
|
11409
11407
|
const group = groupOf(o, "spawn");
|
|
11410
11408
|
const named = argv0Of(o.argv0, "spawn");
|
|
11409
|
+
return (stdio) => ({
|
|
11410
|
+
op: "proc-spawn",
|
|
11411
|
+
file,
|
|
11412
|
+
argv: [...o.argv],
|
|
11413
|
+
...named,
|
|
11414
|
+
env: { ...o.env ?? defaults.env },
|
|
11415
|
+
cwd: o.cwd ?? defaults.cwd,
|
|
11416
|
+
stdio,
|
|
11417
|
+
...group
|
|
11418
|
+
});
|
|
11419
|
+
};
|
|
11420
|
+
const spawnSync = (o) => {
|
|
11421
|
+
const spawning = request(o);
|
|
11422
|
+
const mine = [];
|
|
11423
|
+
const theirs = [];
|
|
11424
|
+
try {
|
|
11425
|
+
const stdio = slotsSync(sync, o, mine, theirs);
|
|
11426
|
+
return childOf(sync.json(spawning(stdio)), mine);
|
|
11427
|
+
} catch (err) {
|
|
11428
|
+
closeAllSync(sync, mine);
|
|
11429
|
+
throw err;
|
|
11430
|
+
} finally {
|
|
11431
|
+
closeAllSync(sync, theirs);
|
|
11432
|
+
}
|
|
11433
|
+
};
|
|
11434
|
+
const spawn = async (o) => {
|
|
11435
|
+
const spawning = request(o);
|
|
11411
11436
|
const mine = [];
|
|
11412
11437
|
const theirs = [];
|
|
11413
11438
|
try {
|
|
11414
11439
|
const stdio = await slots2(kernel, o, mine, theirs);
|
|
11415
|
-
const pid = await kernel.json(
|
|
11416
|
-
op: "proc-spawn",
|
|
11417
|
-
file,
|
|
11418
|
-
argv: [...o.argv],
|
|
11419
|
-
...named,
|
|
11420
|
-
env: { ...o.env ?? defaults.env },
|
|
11421
|
-
cwd: o.cwd ?? defaults.cwd,
|
|
11422
|
-
stdio,
|
|
11423
|
-
...group
|
|
11424
|
-
});
|
|
11440
|
+
const pid = await kernel.json(spawning(stdio));
|
|
11425
11441
|
return childOf(pid, mine);
|
|
11426
11442
|
} catch (err) {
|
|
11427
11443
|
await closeAll(io, mine);
|
|
@@ -11430,7 +11446,7 @@ function childOps(kernel, io, defaults) {
|
|
|
11430
11446
|
await closeAll(io, theirs);
|
|
11431
11447
|
}
|
|
11432
11448
|
};
|
|
11433
|
-
return { spawn, wait: wait2, kill };
|
|
11449
|
+
return { spawn, wait: wait2, kill, spawnSync };
|
|
11434
11450
|
}
|
|
11435
11451
|
function groupOf(o, call2) {
|
|
11436
11452
|
const { pgid, session } = o;
|
|
@@ -11449,27 +11465,43 @@ function argv0Of(argv0, call2) {
|
|
|
11449
11465
|
async function closeAll(io, fds) {
|
|
11450
11466
|
for (const fd of fds) if (fd !== void 0) await io.close(fd).catch(() => void 0);
|
|
11451
11467
|
}
|
|
11452
|
-
|
|
11468
|
+
function closeAllSync(sync, fds) {
|
|
11469
|
+
for (const fd of fds) if (fd !== void 0) sync.raw({ op: "fd-close", fd });
|
|
11470
|
+
}
|
|
11471
|
+
function checked(hows) {
|
|
11472
|
+
const fds = [];
|
|
11453
11473
|
for (const [n, how] of hows.entries()) {
|
|
11454
11474
|
if (how === "pipe" || how === "null") continue;
|
|
11455
11475
|
if (how !== "inherit" && typeof how !== "number") throw new JsCallError("EINVAL", "spawn");
|
|
11456
|
-
|
|
11476
|
+
fds.push(how === "inherit" ? n : how);
|
|
11457
11477
|
}
|
|
11478
|
+
return fds;
|
|
11479
|
+
}
|
|
11480
|
+
async function preflight(kernel, hows) {
|
|
11481
|
+
for (const fd of checked(hows)) await kernel.json({ op: "fd-info", fd });
|
|
11482
|
+
}
|
|
11483
|
+
function slot(n, how, pipe, mine, theirs) {
|
|
11484
|
+
if (how === "inherit") return { fd: n };
|
|
11485
|
+
if (how === "null") return { none: true };
|
|
11486
|
+
if (typeof how === "number") return { fd: how };
|
|
11487
|
+
const [read2, write2] = pipe();
|
|
11488
|
+
mine[n] = n === 0 ? write2 : read2;
|
|
11489
|
+
theirs.push(n === 0 ? read2 : write2);
|
|
11490
|
+
return { fd: n === 0 ? read2 : write2 };
|
|
11491
|
+
}
|
|
11492
|
+
function slotsSync(sync, o, mine, theirs) {
|
|
11493
|
+
const hows = STDIO2.map((name2) => o[name2] ?? "inherit");
|
|
11494
|
+
for (const fd of checked(hows)) sync.json({ op: "fd-info", fd });
|
|
11495
|
+
const pipe = () => sync.json({ op: "fd-pipe" });
|
|
11496
|
+
return hows.map((how, n) => slot(n, how, pipe, mine, theirs));
|
|
11458
11497
|
}
|
|
11459
11498
|
async function slots2(kernel, o, mine, theirs) {
|
|
11460
11499
|
const hows = STDIO2.map((name2) => o[name2] ?? "inherit");
|
|
11461
11500
|
await preflight(kernel, hows);
|
|
11462
11501
|
const stdio = [];
|
|
11463
11502
|
for (const [n, how] of hows.entries()) {
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
else if (typeof how === "number") stdio.push({ fd: how });
|
|
11467
|
-
else {
|
|
11468
|
-
const [read2, write2] = await kernel.json({ op: "fd-pipe" });
|
|
11469
|
-
mine[n] = n === 0 ? write2 : read2;
|
|
11470
|
-
theirs.push(n === 0 ? read2 : write2);
|
|
11471
|
-
stdio.push({ fd: n === 0 ? read2 : write2 });
|
|
11472
|
-
}
|
|
11503
|
+
const pair = how === "pipe" ? await kernel.json({ op: "fd-pipe" }) : [];
|
|
11504
|
+
stdio.push(slot(n, how, () => pair, mine, theirs));
|
|
11473
11505
|
}
|
|
11474
11506
|
return stdio;
|
|
11475
11507
|
}
|
|
@@ -11735,6 +11767,10 @@ function* aliasOf(fd, abs, o) {
|
|
|
11735
11767
|
}
|
|
11736
11768
|
return { fd: copy2, file };
|
|
11737
11769
|
}
|
|
11770
|
+
function accessFlags(o) {
|
|
11771
|
+
const write2 = o.write === true || o.append === true || o.truncate === true;
|
|
11772
|
+
return write2 ? o.read === true ? 2 : 1 : 0;
|
|
11773
|
+
}
|
|
11738
11774
|
function* opened(abs, o) {
|
|
11739
11775
|
const node = yield* lookup(abs);
|
|
11740
11776
|
if (isExclusive(o)) throw new JsCallError("EEXIST", abs);
|
|
@@ -11743,13 +11779,13 @@ function* opened(abs, o) {
|
|
|
11743
11779
|
return { fd: yield openRequest(abs, { ...o, create: false }), file: false };
|
|
11744
11780
|
case "tty":
|
|
11745
11781
|
return { fd: yield { op: "fd-open-tty" }, file: false };
|
|
11746
|
-
case "clipboard":
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11782
|
+
case "clipboard":
|
|
11783
|
+
return {
|
|
11784
|
+
fd: yield { op: "fd-open-clipboard", flags: accessFlags(o) },
|
|
11785
|
+
file: false
|
|
11786
|
+
};
|
|
11751
11787
|
case "sealed":
|
|
11752
|
-
return { fd: yield { op: "fd-open-sealed" }, file: false };
|
|
11788
|
+
return { fd: yield { op: "fd-open-sealed", flags: accessFlags(o) }, file: false };
|
|
11753
11789
|
case "terminal": {
|
|
11754
11790
|
const req = node.pts === void 0 ? { op: "fd-open-tty", name: node.name } : { op: "pty-slave-open", n: node.pts, noctty: true };
|
|
11755
11791
|
return { fd: yield req, file: false };
|
|
@@ -13246,6 +13282,7 @@ function createContext(o) {
|
|
|
13246
13282
|
const sync = {
|
|
13247
13283
|
...syncOps(syncKernel, { pid: o.pid, resolve, random, infos, handles }),
|
|
13248
13284
|
run: (options) => runSync(syncKernel, { env: o.env, cwd: o.cwd, resolve, signal: signalNumber }, options),
|
|
13285
|
+
spawn: (options) => spawnSync(options),
|
|
13249
13286
|
exit: (status2 = 0) => {
|
|
13250
13287
|
exiting ??= status2 & 255;
|
|
13251
13288
|
return exitAtOnce(lane, [...writes], terminal.modes(), exiting);
|
|
@@ -13260,7 +13297,8 @@ function createContext(o) {
|
|
|
13260
13297
|
}
|
|
13261
13298
|
};
|
|
13262
13299
|
const io = { read: read2, send: writeAll, close: (fd) => ctx.close(fd) };
|
|
13263
|
-
const
|
|
13300
|
+
const defaults = { env: o.env, cwd: o.cwd, signal: signalNumber };
|
|
13301
|
+
const { spawnSync, ...children } = childOps(kernel, io, defaults, syncKernel);
|
|
13264
13302
|
const strays = o.strays ?? { exception: /* @__PURE__ */ new Set(), rejection: /* @__PURE__ */ new Set() };
|
|
13265
13303
|
const ctx = {
|
|
13266
13304
|
argv: o.argv,
|