@ai-ecoverse/slicc-kernel 1.75.1 → 1.77.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 +6 -6
- package/dist/driver-worker.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kernel-worker.js +87 -15
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-driver-worker.js.map +1 -1
- package/dist/node-process-worker.js +180 -133
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +87 -15
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +54 -7
- package/dist/process-worker.js.map +2 -2
- package/package.json +1 -1
package/dist/kernel-worker.js
CHANGED
|
@@ -6871,7 +6871,8 @@ function commandOf(pkg, name2, raw, packageAbi, shared) {
|
|
|
6871
6871
|
return { name: name2, abi: packageAbi, glue: script, wasm: script, argv0: name2, script, ...withEnv };
|
|
6872
6872
|
}
|
|
6873
6873
|
const abi = abiOf(raw.abi, packageAbi);
|
|
6874
|
-
const
|
|
6874
|
+
const fixed = typeof raw.argv0 === "string" && raw.argv0 !== "";
|
|
6875
|
+
const argv0 = fixed ? raw.argv0 : name2;
|
|
6875
6876
|
const args = argsOf(pkg, raw.args);
|
|
6876
6877
|
if (abi === "js") {
|
|
6877
6878
|
const module = inside(pkg, raw.module);
|
|
@@ -6882,6 +6883,7 @@ function commandOf(pkg, name2, raw, packageAbi, shared) {
|
|
|
6882
6883
|
glue: module,
|
|
6883
6884
|
wasm: module,
|
|
6884
6885
|
argv0,
|
|
6886
|
+
...fixed ? { argv0Fixed: true } : {},
|
|
6885
6887
|
...raw.argv0Path === true ? { argv0Path: true } : {},
|
|
6886
6888
|
...args ? { args } : {},
|
|
6887
6889
|
...withEnv
|
|
@@ -6897,6 +6899,7 @@ function commandOf(pkg, name2, raw, packageAbi, shared) {
|
|
|
6897
6899
|
glue,
|
|
6898
6900
|
wasm,
|
|
6899
6901
|
argv0,
|
|
6902
|
+
...fixed ? { argv0Fixed: true } : {},
|
|
6900
6903
|
...raw.argv0Path === true ? { argv0Path: true } : {},
|
|
6901
6904
|
...abi === "wasi" && raw.preopenRoot === true ? { preopenRoot: true } : {},
|
|
6902
6905
|
...args ? { args } : {},
|
|
@@ -9572,6 +9575,7 @@ var IDLE_OPS = /* @__PURE__ */ new Set([
|
|
|
9572
9575
|
]);
|
|
9573
9576
|
var SYS_CAP_US = 2e4;
|
|
9574
9577
|
var LOCAL = SAB_CLOCK_OFFSET;
|
|
9578
|
+
var BLOCKED = 0;
|
|
9575
9579
|
var IDLE = 1;
|
|
9576
9580
|
function epochMicros() {
|
|
9577
9581
|
return Math.floor((performance.timeOrigin + performance.now()) * 1e3);
|
|
@@ -9646,6 +9650,7 @@ var CpuClock = class {
|
|
|
9646
9650
|
const busy = this.kind === "sys" ? Math.min(spent, SYS_CAP_US) : 0;
|
|
9647
9651
|
this.sys += busy;
|
|
9648
9652
|
this.idle += spent - busy;
|
|
9653
|
+
Atomics.store(slots(this.sab), BLOCKED, BigInt(this.idle));
|
|
9649
9654
|
}
|
|
9650
9655
|
};
|
|
9651
9656
|
var ProcessClocks = class {
|
|
@@ -9990,8 +9995,8 @@ function pidStat(info, boot) {
|
|
|
9990
9995
|
0,
|
|
9991
9996
|
ticks(info.utime ?? 0),
|
|
9992
9997
|
ticks(info.stime ?? 0),
|
|
9993
|
-
0,
|
|
9994
|
-
0,
|
|
9998
|
+
ticks(info.cutime ?? 0),
|
|
9999
|
+
ticks(info.cstime ?? 0),
|
|
9995
10000
|
20,
|
|
9996
10001
|
0,
|
|
9997
10002
|
1,
|
|
@@ -10015,8 +10020,9 @@ function pidStat(info, boot) {
|
|
|
10015
10020
|
`;
|
|
10016
10021
|
}
|
|
10017
10022
|
var sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
|
|
10023
|
+
var STATES = { S: "S (sleeping)", T: "T (stopped)", Z: "Z (zombie)" };
|
|
10018
10024
|
function pidStatus(info) {
|
|
10019
|
-
const state = info.state
|
|
10025
|
+
const state = STATES[info.state];
|
|
10020
10026
|
const c = info.cred ?? ROOT;
|
|
10021
10027
|
const ids = (r, e, s) => `${r} ${e} ${s} ${e}`;
|
|
10022
10028
|
return [
|
|
@@ -11429,6 +11435,7 @@ async function runChild(req, deps) {
|
|
|
11429
11435
|
{
|
|
11430
11436
|
file: req.file,
|
|
11431
11437
|
argv: req.argv,
|
|
11438
|
+
...req.argv0 !== void 0 ? { argv0: req.argv0 } : {},
|
|
11432
11439
|
env: req.env,
|
|
11433
11440
|
cwd: req.cwd,
|
|
11434
11441
|
...req.pgid !== void 0 ? { pgid: req.pgid } : {},
|
|
@@ -12304,6 +12311,16 @@ function words(value) {
|
|
|
12304
12311
|
}
|
|
12305
12312
|
return [...value];
|
|
12306
12313
|
}
|
|
12314
|
+
var ESCAPES = { " ": "\\t", "\n": "\\n", "\r": "\\r" };
|
|
12315
|
+
function clipboardLine(text) {
|
|
12316
|
+
let out = "";
|
|
12317
|
+
for (const c of text) {
|
|
12318
|
+
const code = c.charCodeAt(0);
|
|
12319
|
+
const control = code < 32 || code === 127;
|
|
12320
|
+
out += control ? ESCAPES[c] ?? `\\x${code.toString(16).padStart(2, "0")}` : c;
|
|
12321
|
+
}
|
|
12322
|
+
return out.length > 200 ? `${out.slice(0, 200)}\u2026` : out;
|
|
12323
|
+
}
|
|
12307
12324
|
var DYING = { ok: false, errno: "EINTR", message: "the process is being killed" };
|
|
12308
12325
|
var HOSTS_ONLY = new Resolver({ routes: new Routes() });
|
|
12309
12326
|
var WasmProcess = class {
|
|
@@ -12387,9 +12404,10 @@ var WasmProcess = class {
|
|
|
12387
12404
|
return "deliver";
|
|
12388
12405
|
}
|
|
12389
12406
|
async spawn(req) {
|
|
12390
|
-
const { file, argv, env, cwd, stdio, inherit: inherit2, exec, pgid, session } = req;
|
|
12407
|
+
const { file, argv, argv0, env, cwd, stdio, inherit: inherit2, exec, pgid, session } = req;
|
|
12391
12408
|
const group = { ...pgid !== void 0 ? { pgid } : {}, ...session ? { session } : {} };
|
|
12392
|
-
const
|
|
12409
|
+
const named = argv0 !== void 0 ? { argv0 } : {};
|
|
12410
|
+
const spawned = { file, argv, ...named, env, cwd, ...group, ...exec ? { exec } : {} };
|
|
12393
12411
|
const pid = await this.children.spawn(spawned, stdio, inherit2);
|
|
12394
12412
|
if (!exec) return pid;
|
|
12395
12413
|
if (this.killed) void Promise.allSettled([this.options.kill?.(pid, SIG.KILL)]);
|
|
@@ -12555,7 +12573,22 @@ var WasmProcess = class {
|
|
|
12555
12573
|
if (req.max <= 0) return new Uint8Array(0);
|
|
12556
12574
|
if (channel.unread) channel.stamp = await this.clipboardStamp();
|
|
12557
12575
|
const signal = channel.settled ? this.interrupt.signal : this.blockingSignal(cancelled);
|
|
12558
|
-
|
|
12576
|
+
try {
|
|
12577
|
+
return await channel.read(Math.min(req.max, MAX_READ), signal);
|
|
12578
|
+
} catch (err) {
|
|
12579
|
+
await this.clipboardComplaint(err);
|
|
12580
|
+
throw err;
|
|
12581
|
+
}
|
|
12582
|
+
}
|
|
12583
|
+
async clipboardComplaint(err) {
|
|
12584
|
+
const name2 = this.options.clipboardName;
|
|
12585
|
+
if (name2 === void 0 || !(err instanceof KernelError) || err.detail === void 0) return;
|
|
12586
|
+
if (err.code !== "EACCES" && err.code !== "EIO") return;
|
|
12587
|
+
const stderr = this.fds.has(2) ? this.fds.get(2).file : void 0;
|
|
12588
|
+
if (!stderr?.write || stderr.clipboard) return;
|
|
12589
|
+
const line = `${name2}: /dev/clipboard: ${clipboardLine(err.detail)}
|
|
12590
|
+
`;
|
|
12591
|
+
await stderr.write(new TextEncoder().encode(line), AbortSignal.timeout(1e3)).catch(() => 0);
|
|
12559
12592
|
}
|
|
12560
12593
|
async write(fd, body, nonblock = false, cancelled) {
|
|
12561
12594
|
const file = this.fds.get(fd).file;
|
|
@@ -12768,7 +12801,10 @@ var WasmProcess = class {
|
|
|
12768
12801
|
this.options.locks?.closed(this.pid, req.fd);
|
|
12769
12802
|
const channel = this.fds.get(req.fd).file.clipboard;
|
|
12770
12803
|
if (channel) channel.stamp = await this.clipboardStamp();
|
|
12771
|
-
await Promise.resolve(this.fds.close(req.fd))
|
|
12804
|
+
await Promise.resolve(this.fds.close(req.fd)).catch(async (err) => {
|
|
12805
|
+
if (channel) await this.clipboardComplaint(err);
|
|
12806
|
+
throw err;
|
|
12807
|
+
});
|
|
12772
12808
|
return { ok: true, kind: "void" };
|
|
12773
12809
|
}
|
|
12774
12810
|
case "fd-pipe": {
|
|
@@ -13459,12 +13495,15 @@ function holdingToken(opts, holds, caller) {
|
|
|
13459
13495
|
renamed: (from, to) => holds.renamed(from, to)
|
|
13460
13496
|
});
|
|
13461
13497
|
}
|
|
13498
|
+
function clipboardName(opts) {
|
|
13499
|
+
return opts.program.abi === "js" ? {} : { clipboardName: opts.argv0 };
|
|
13500
|
+
}
|
|
13462
13501
|
function processOptions(opts, header3, hooks, created3) {
|
|
13463
13502
|
return {
|
|
13464
13503
|
...inherited(opts),
|
|
13465
13504
|
...opts.owners ? { owners: true } : {},
|
|
13466
13505
|
...opts.sealed ? { sealed: opts.sealed } : {},
|
|
13467
|
-
...opts.clipboard ? { clipboard: opts.clipboard } : {},
|
|
13506
|
+
...opts.clipboard ? { clipboard: opts.clipboard, ...clipboardName(opts) } : {},
|
|
13468
13507
|
...opts.readonlyAt ? { readonlyAt: opts.readonlyAt } : {},
|
|
13469
13508
|
...opts.dac ? { guard: { dac: opts.dac, fs: opts.fs, created: created3 } } : {},
|
|
13470
13509
|
...opts.identity ? { identity: opts.identity } : {},
|
|
@@ -16217,6 +16256,7 @@ function targetOf(command) {
|
|
|
16217
16256
|
glue: command.glue,
|
|
16218
16257
|
wasm: command.wasm,
|
|
16219
16258
|
argv0: command.argv0,
|
|
16259
|
+
...command.argv0Fixed ? { fixed: true } : {},
|
|
16220
16260
|
...command.args ? { prefix: command.args } : {},
|
|
16221
16261
|
...command.env ? { env: command.env } : {},
|
|
16222
16262
|
...command.unset ? { unset: command.unset } : {},
|
|
@@ -16252,6 +16292,10 @@ function concat5(chunks) {
|
|
|
16252
16292
|
}
|
|
16253
16293
|
return out;
|
|
16254
16294
|
}
|
|
16295
|
+
function addTimes(into, pid, t) {
|
|
16296
|
+
const at = into.get(pid) ?? { utime: 0, stime: 0 };
|
|
16297
|
+
into.set(pid, { utime: at.utime + t.utime, stime: at.stime + t.stime });
|
|
16298
|
+
}
|
|
16255
16299
|
var Launcher = class {
|
|
16256
16300
|
fs;
|
|
16257
16301
|
processFs;
|
|
@@ -16579,8 +16623,10 @@ var Launcher = class {
|
|
|
16579
16623
|
const target = withScriptEnv(found, command);
|
|
16580
16624
|
return { target, args: [...target.prefix ?? [], ...passed], via: [interp] };
|
|
16581
16625
|
}
|
|
16582
|
-
async plan(file, argv, cwd, scope) {
|
|
16583
|
-
const
|
|
16626
|
+
async plan(file, argv, cwd, scope, argv0) {
|
|
16627
|
+
const found = await this.resolve(file, argv[0] ?? file, cwd, scope);
|
|
16628
|
+
const named = typeof argv0 === "string" && found && !found.fixed;
|
|
16629
|
+
const direct = named ? { ...found, argv0 } : found;
|
|
16584
16630
|
if (direct) return { target: direct, args: [...direct.prefix ?? [], ...argv.slice(1)] };
|
|
16585
16631
|
const script = await this.interpreted(file, argv, cwd, scope);
|
|
16586
16632
|
return script && { ...script, script: true };
|
|
@@ -16787,7 +16833,7 @@ var Launcher = class {
|
|
|
16787
16833
|
http: new HttpHandles(this.transport, pid),
|
|
16788
16834
|
locks: this.locks,
|
|
16789
16835
|
resolver: this.resolver,
|
|
16790
|
-
onReap: (child) => this.reaped(child),
|
|
16836
|
+
onReap: (child) => this.reaped(child, pid),
|
|
16791
16837
|
...req.fork ? { fork: req.fork } : {},
|
|
16792
16838
|
...this.shownIds(req)
|
|
16793
16839
|
});
|
|
@@ -16806,9 +16852,14 @@ var Launcher = class {
|
|
|
16806
16852
|
tty: terminal?.name ?? null,
|
|
16807
16853
|
started: Date.now()
|
|
16808
16854
|
});
|
|
16855
|
+
handle.onState(
|
|
16856
|
+
(state) => state === "stopped" ? this.stopped.add(pid) : this.stopped.delete(pid)
|
|
16857
|
+
);
|
|
16809
16858
|
void handle.exited.then(() => {
|
|
16810
16859
|
const spent = handle.times?.();
|
|
16811
16860
|
if (spent) this.spent.set(pid, spent);
|
|
16861
|
+
if (spent) addTimes(this.imageTimes, this.jobs.shown(pid), spent);
|
|
16862
|
+
this.stopped.delete(pid);
|
|
16812
16863
|
this.processes.delete(pid);
|
|
16813
16864
|
if (this.processes.size === 0) {
|
|
16814
16865
|
clearInterval(this.sampler);
|
|
@@ -16836,11 +16887,20 @@ var Launcher = class {
|
|
|
16836
16887
|
this.reapedTimes.stime += spent.stime;
|
|
16837
16888
|
}
|
|
16838
16889
|
this.spent.delete(pid);
|
|
16890
|
+
this.imageTimes.delete(pid);
|
|
16891
|
+
this.childTimes.delete(pid);
|
|
16839
16892
|
this.creds.delete(pid);
|
|
16840
16893
|
this.tags.delete(pid);
|
|
16841
16894
|
this.granted.delete(pid);
|
|
16842
16895
|
}
|
|
16843
|
-
reaped(pid) {
|
|
16896
|
+
reaped(pid, parent) {
|
|
16897
|
+
const own = this.imageTimes.get(pid);
|
|
16898
|
+
const theirs = this.childTimes.get(pid);
|
|
16899
|
+
const into = this.jobs.shown(parent);
|
|
16900
|
+
if (own) addTimes(this.childTimes, into, own);
|
|
16901
|
+
if (theirs) addTimes(this.childTimes, into, theirs);
|
|
16902
|
+
this.imageTimes.delete(pid);
|
|
16903
|
+
this.childTimes.delete(pid);
|
|
16844
16904
|
if (this.zombies.delete(pid)) this.forget(pid);
|
|
16845
16905
|
else this.orphans.add(pid);
|
|
16846
16906
|
}
|
|
@@ -16892,6 +16952,17 @@ var Launcher = class {
|
|
|
16892
16952
|
this.sampler.unref?.();
|
|
16893
16953
|
}
|
|
16894
16954
|
spent = /* @__PURE__ */ new Map();
|
|
16955
|
+
imageTimes = /* @__PURE__ */ new Map();
|
|
16956
|
+
childTimes = /* @__PURE__ */ new Map();
|
|
16957
|
+
stopped = /* @__PURE__ */ new Set();
|
|
16958
|
+
stateOf(pid) {
|
|
16959
|
+
if (!this.processes.has(pid)) return "Z";
|
|
16960
|
+
return this.stopped.has(pid) ? "T" : "S";
|
|
16961
|
+
}
|
|
16962
|
+
childrenOf(pid) {
|
|
16963
|
+
const t = this.childTimes.get(pid);
|
|
16964
|
+
return t ? { cutime: t.utime, cstime: t.stime } : {};
|
|
16965
|
+
}
|
|
16895
16966
|
timesAt(pid) {
|
|
16896
16967
|
return this.processes.get(pid)?.times?.() ?? this.spent.get(pid);
|
|
16897
16968
|
}
|
|
@@ -16937,9 +17008,10 @@ var Launcher = class {
|
|
|
16937
17008
|
sid: member.sid,
|
|
16938
17009
|
...described2,
|
|
16939
17010
|
started: (this.described.get(root.pid) ?? described2).started,
|
|
16940
|
-
state: this.
|
|
17011
|
+
state: this.stateOf(member.pid),
|
|
16941
17012
|
memory: this.processes.get(member.pid)?.memory() ?? 0,
|
|
16942
17013
|
...this.timesOf(member, members),
|
|
17014
|
+
...this.childrenOf(root.pid),
|
|
16943
17015
|
umask: this.umaskOf(member.pid),
|
|
16944
17016
|
cred,
|
|
16945
17017
|
...this.signalMasksOf(member.pid)
|
|
@@ -16969,7 +17041,7 @@ var Launcher = class {
|
|
|
16969
17041
|
}
|
|
16970
17042
|
const cred = grant ? grant.cred : this.credOf(ppid);
|
|
16971
17043
|
const scope = grant ? "" : await this.scopeOf(cred.euid);
|
|
16972
|
-
const planned = await this.plan(req.file, req.argv, req.cwd, scope);
|
|
17044
|
+
const planned = await this.plan(req.file, req.argv, req.cwd, scope, req.argv0);
|
|
16973
17045
|
try {
|
|
16974
17046
|
await this.mayExec(cred, { ...req, pid: ppid }, planned);
|
|
16975
17047
|
} catch (err) {
|