@ai-ecoverse/slicc-kernel 1.93.2 → 1.94.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 +5 -5
- package/dist/driver-worker.js +7 -7
- package/dist/driver-worker.js.map +2 -2
- package/dist/driver.js +7 -7
- package/dist/driver.js.map +2 -2
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +103 -47
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-driver-worker.js +7 -7
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.js +7 -4
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +122 -51
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +7 -4
- package/dist/process-worker.js.map +2 -2
- package/package.json +1 -1
package/dist/kernel-worker.js
CHANGED
|
@@ -7787,10 +7787,15 @@ async function binCommandsOf(physical, pkg, manifest, taken) {
|
|
|
7787
7787
|
}
|
|
7788
7788
|
return out;
|
|
7789
7789
|
}
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
const
|
|
7793
|
-
|
|
7790
|
+
var PACKAGE_NAME = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
|
|
7791
|
+
function replacesOf(manifest) {
|
|
7792
|
+
const replaces = manifest.slicc?.replaces;
|
|
7793
|
+
if (!Array.isArray(replaces)) return [];
|
|
7794
|
+
return replaces.every((name2) => typeof name2 === "string" && PACKAGE_NAME.test(name2)) ? replaces : [];
|
|
7795
|
+
}
|
|
7796
|
+
async function tierPackages(fs, physical, roots, bins) {
|
|
7797
|
+
const out = [];
|
|
7798
|
+
for (const root of roots) {
|
|
7794
7799
|
for (const pkg of await packages(fs, root)) {
|
|
7795
7800
|
let manifest;
|
|
7796
7801
|
try {
|
|
@@ -7800,11 +7805,47 @@ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY) {
|
|
|
7800
7805
|
}
|
|
7801
7806
|
const own = commandsOf(pkg, manifest);
|
|
7802
7807
|
const named = new Set(own.map((command) => command.name));
|
|
7803
|
-
const
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
+
const extra = bins ? await binCommandsOf(physical, pkg, manifest, named) : [];
|
|
7809
|
+
out.push({
|
|
7810
|
+
name: pkg.slice(root.length + 1),
|
|
7811
|
+
pkg,
|
|
7812
|
+
replaces: replacesOf(manifest),
|
|
7813
|
+
commands: [...own, ...extra]
|
|
7814
|
+
});
|
|
7815
|
+
}
|
|
7816
|
+
}
|
|
7817
|
+
return out;
|
|
7818
|
+
}
|
|
7819
|
+
function winners(tier) {
|
|
7820
|
+
const providers = /* @__PURE__ */ new Map();
|
|
7821
|
+
for (const entry of tier) {
|
|
7822
|
+
for (const command of entry.commands) {
|
|
7823
|
+
const list = providers.get(command.name) ?? [];
|
|
7824
|
+
if (!list.includes(entry)) list.push(entry);
|
|
7825
|
+
providers.set(command.name, list);
|
|
7826
|
+
}
|
|
7827
|
+
}
|
|
7828
|
+
const out = /* @__PURE__ */ new Map();
|
|
7829
|
+
for (const [name2, list] of providers) {
|
|
7830
|
+
const kept = list.filter(
|
|
7831
|
+
(entry2) => !list.some((other) => other !== entry2 && other.replaces.includes(entry2.name))
|
|
7832
|
+
);
|
|
7833
|
+
const entry = kept[0] ?? list[0];
|
|
7834
|
+
const command = entry.commands.find((c) => c.name === name2);
|
|
7835
|
+
out.set(name2, { pkg: entry.pkg, command });
|
|
7836
|
+
}
|
|
7837
|
+
return out;
|
|
7838
|
+
}
|
|
7839
|
+
async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY) {
|
|
7840
|
+
const found = /* @__PURE__ */ new Map();
|
|
7841
|
+
const physical = physicalResolver(fs);
|
|
7842
|
+
const tiers = (typeof modules === "string" ? [modules] : modules).map(
|
|
7843
|
+
(tier) => typeof tier === "string" ? [tier] : tier
|
|
7844
|
+
);
|
|
7845
|
+
for (const [index, roots] of tiers.entries()) {
|
|
7846
|
+
const tier = await tierPackages(fs, physical, roots, index >= binsFrom);
|
|
7847
|
+
for (const [name2, { pkg, command }] of winners(tier)) {
|
|
7848
|
+
if (!found.has(name2)) found.set(name2, await withPackagePaths(fs, pkg, command));
|
|
7808
7849
|
}
|
|
7809
7850
|
}
|
|
7810
7851
|
if (!found.has("sh") && found.has("bash")) {
|
|
@@ -9348,7 +9389,7 @@ function statOf(attr2, path, mount) {
|
|
|
9348
9389
|
size: attr2.size,
|
|
9349
9390
|
mode: attr2.mode ?? fallback,
|
|
9350
9391
|
mtime,
|
|
9351
|
-
atime: mtime,
|
|
9392
|
+
atime: attr2.atime === void 0 ? mtime : new Date(attr2.atime),
|
|
9352
9393
|
ctime: mtime,
|
|
9353
9394
|
ino: attr2.ino ?? inodeOf(path),
|
|
9354
9395
|
...!inodeless(mount, attr2) && attr2.nlink !== void 0 ? { nlink: attr2.nlink } : {},
|
|
@@ -10393,7 +10434,7 @@ var MountFs = class _MountFs {
|
|
|
10393
10434
|
([to], n) => this.utimes(to, atime, mtime, n)
|
|
10394
10435
|
);
|
|
10395
10436
|
}
|
|
10396
|
-
await this.
|
|
10437
|
+
await this.setTimes(found, real, atime, mtime);
|
|
10397
10438
|
}
|
|
10398
10439
|
async lutimes(path, atime, mtime, redirects = 0) {
|
|
10399
10440
|
const found = this.at(path);
|
|
@@ -10410,12 +10451,13 @@ var MountFs = class _MountFs {
|
|
|
10410
10451
|
if (!found.mount.caps.linkTimes && (await this.lstat(real)).isSymbolicLink) {
|
|
10411
10452
|
throw errnoError("EOPNOTSUPP", path);
|
|
10412
10453
|
}
|
|
10413
|
-
await this.
|
|
10454
|
+
await this.setTimes(found, real, atime, mtime);
|
|
10414
10455
|
}
|
|
10415
|
-
async
|
|
10456
|
+
async setTimes(found, real, atime, mtime) {
|
|
10416
10457
|
this.writable(found.mount, real);
|
|
10417
10458
|
this.table.forget(found.mount, real);
|
|
10418
|
-
|
|
10459
|
+
const times = { mtime: mtime.getTime(), atime: atime.getTime() };
|
|
10460
|
+
await found.mount.conn.call({ op: "setattr", path: found.rel, ...times });
|
|
10419
10461
|
}
|
|
10420
10462
|
noLinks() {
|
|
10421
10463
|
const noLinkBase = this.base.noLinks.call(this.base);
|
|
@@ -11177,14 +11219,6 @@ function attachSyncSabResponder(port, sab, token, opts) {
|
|
|
11177
11219
|
}
|
|
11178
11220
|
|
|
11179
11221
|
// src/kernel/cpu-clock.ts
|
|
11180
|
-
var IDLE_OPS = /* @__PURE__ */ new Set([
|
|
11181
|
-
"fd-select",
|
|
11182
|
-
"proc-wait",
|
|
11183
|
-
"proc-exec",
|
|
11184
|
-
"sig-pause",
|
|
11185
|
-
"sock-accept",
|
|
11186
|
-
"sock-connect"
|
|
11187
|
-
]);
|
|
11188
11222
|
var SYS_CAP_US = 2e4;
|
|
11189
11223
|
var LOCAL = SAB_CLOCK_OFFSET;
|
|
11190
11224
|
var BLOCKED = 0;
|
|
@@ -11216,9 +11250,16 @@ var CpuClock = class {
|
|
|
11216
11250
|
this.now = now;
|
|
11217
11251
|
this.start = now();
|
|
11218
11252
|
}
|
|
11219
|
-
enter(
|
|
11253
|
+
enter() {
|
|
11220
11254
|
this.since = this.now();
|
|
11221
|
-
this.kind = this.stopped
|
|
11255
|
+
this.kind = this.stopped ? "idle" : "sys";
|
|
11256
|
+
}
|
|
11257
|
+
block() {
|
|
11258
|
+
if (this.since === 0 || this.kind === "idle" || this.frozen !== void 0) return;
|
|
11259
|
+
const now = this.now();
|
|
11260
|
+
this.add(now - this.since);
|
|
11261
|
+
this.since = now;
|
|
11262
|
+
this.kind = "idle";
|
|
11222
11263
|
}
|
|
11223
11264
|
leave() {
|
|
11224
11265
|
if (this.since === 0) return;
|
|
@@ -11308,9 +11349,10 @@ var ProcessClocks = class {
|
|
|
11308
11349
|
}
|
|
11309
11350
|
timed(clock, dispatch2) {
|
|
11310
11351
|
const c = clock ?? this.main;
|
|
11352
|
+
const block = () => c.block();
|
|
11311
11353
|
return (req) => {
|
|
11312
|
-
c.enter(
|
|
11313
|
-
return dispatch2(req).finally(() => c.leave());
|
|
11354
|
+
c.enter();
|
|
11355
|
+
return dispatch2(req, block).finally(() => c.leave());
|
|
11314
11356
|
};
|
|
11315
11357
|
}
|
|
11316
11358
|
all() {
|
|
@@ -11569,7 +11611,7 @@ function mountTable(mounts = []) {
|
|
|
11569
11611
|
}
|
|
11570
11612
|
|
|
11571
11613
|
// src/version.ts
|
|
11572
|
-
var KERNEL_VERSION = true ? "1.
|
|
11614
|
+
var KERNEL_VERSION = true ? "1.94.0" : "0.0.0-dev";
|
|
11573
11615
|
var OS_RELEASE = "6.0.0-slicc";
|
|
11574
11616
|
function procVersion() {
|
|
11575
11617
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -14497,7 +14539,8 @@ var WasmProcess = class {
|
|
|
14497
14539
|
this.wake?.();
|
|
14498
14540
|
for (const listener of this.stateListeners) listener("continued", SIG.CONT);
|
|
14499
14541
|
}
|
|
14500
|
-
|
|
14542
|
+
blocks = /* @__PURE__ */ new WeakMap();
|
|
14543
|
+
async syscall(req, cancelled, block) {
|
|
14501
14544
|
this.options.onSyscall?.(req);
|
|
14502
14545
|
for (; ; ) {
|
|
14503
14546
|
await this.resumed;
|
|
@@ -14507,6 +14550,7 @@ var WasmProcess = class {
|
|
|
14507
14550
|
const forward = () => scope.abort();
|
|
14508
14551
|
if (cancelled?.aborted) scope.abort();
|
|
14509
14552
|
cancelled?.addEventListener("abort", forward, { once: true });
|
|
14553
|
+
if (block) this.blocks.set(scope.signal, block);
|
|
14510
14554
|
const result = await this.dispatch(req, scope.signal).finally(() => {
|
|
14511
14555
|
cancelled?.removeEventListener("abort", forward);
|
|
14512
14556
|
this.waiting.delete(scope.signal);
|
|
@@ -14589,6 +14633,7 @@ var WasmProcess = class {
|
|
|
14589
14633
|
}
|
|
14590
14634
|
if (this.options.hasPending?.() || cancelled.aborted) throw new KernelError("EINTR");
|
|
14591
14635
|
if (owing) this.waiting.add(cancelled);
|
|
14636
|
+
if (owing) this.blocks.get(cancelled)?.();
|
|
14592
14637
|
return this.cancelSignal(cancelled);
|
|
14593
14638
|
}
|
|
14594
14639
|
cancelSignal(cancelled) {
|
|
@@ -15230,6 +15275,7 @@ var WasmProcess = class {
|
|
|
15230
15275
|
case "proc-identity":
|
|
15231
15276
|
return { ok: true, kind: "json", json: await this.options.identity?.() ?? null };
|
|
15232
15277
|
case "proc-exec": {
|
|
15278
|
+
this.blocks.get(cancelled)?.();
|
|
15233
15279
|
this.adoptExec(req.pid);
|
|
15234
15280
|
this.options.jobs?.exec(this.pid, req.pid);
|
|
15235
15281
|
await this.fds.closeAll();
|
|
@@ -15560,6 +15606,9 @@ function killThread(thread, caught, sig) {
|
|
|
15560
15606
|
function unblocked(header3) {
|
|
15561
15607
|
return Atomics.load(header3, SAB_I_SIGNALS) & ~Atomics.load(header3, SAB_I_BLOCKED);
|
|
15562
15608
|
}
|
|
15609
|
+
function threadCall(process, req, cancelled, block) {
|
|
15610
|
+
return isWasmSyscall(req) ? process.syscall(req, cancelled, block) : dispatchSyncFs(req);
|
|
15611
|
+
}
|
|
15563
15612
|
function threadSignalsOf(sab) {
|
|
15564
15613
|
return { header: new Int32Array(sab, 0, SAB_HEADER_I32), interrupt: new AbortController() };
|
|
15565
15614
|
}
|
|
@@ -15763,7 +15812,9 @@ function spawnWasmProcess(opts) {
|
|
|
15763
15812
|
process.keptHandle = (handle2) => holds.keptFor(handle2)?.hidden;
|
|
15764
15813
|
const worker = opts.createWorker();
|
|
15765
15814
|
const dying = new Dying();
|
|
15766
|
-
const dispatch2 = (req) => dying.serving(
|
|
15815
|
+
const dispatch2 = (req, block) => dying.serving(
|
|
15816
|
+
() => isWasmSyscall(req) ? process.syscall(req, void 0, block) : dispatchSyncFs(req)
|
|
15817
|
+
);
|
|
15767
15818
|
const clocks = new ProcessClocks(sab, opts.program.abi !== "js", process);
|
|
15768
15819
|
const responder = attachSyncSabResponder(worker, sab, token, {
|
|
15769
15820
|
dispatch: clocks.timed(void 0, dispatch2)
|
|
@@ -15833,9 +15884,7 @@ function spawnWasmProcess(opts) {
|
|
|
15833
15884
|
const tsignals = threadSignalsOf(tsab);
|
|
15834
15885
|
if (thread.blocked) storeBlocked(tsignals.header, thread.blocked);
|
|
15835
15886
|
threadSignals.set(thread.tid, tsignals);
|
|
15836
|
-
const tdispatch = (req) => dying.serving(
|
|
15837
|
-
() => isWasmSyscall(req) ? process.syscall(req, threadCancel(tsignals)) : dispatchSyncFs(req)
|
|
15838
|
-
);
|
|
15887
|
+
const tdispatch = (req, block) => dying.serving(() => threadCall(process, req, threadCancel(tsignals), block));
|
|
15839
15888
|
const tresponder = attachSyncSabResponder(tw, tsab, token, {
|
|
15840
15889
|
dispatch: clocks.timed(clocks.thread(thread.tid, tsab), tdispatch)
|
|
15841
15890
|
});
|
|
@@ -17091,6 +17140,12 @@ function withOwner(base, owner) {
|
|
|
17091
17140
|
function fsError2(code, message3 = code) {
|
|
17092
17141
|
return Object.assign(new Error(message3), { code });
|
|
17093
17142
|
}
|
|
17143
|
+
var SET_ATTRS = ["mode", "mtime", "atime", "size", "uid", "gid"];
|
|
17144
|
+
function setAttrOf(req) {
|
|
17145
|
+
const attr2 = {};
|
|
17146
|
+
for (const key of SET_ATTRS) if (req[key] !== void 0) attr2[key] = req[key];
|
|
17147
|
+
return attr2;
|
|
17148
|
+
}
|
|
17094
17149
|
async function dispatch(h, req) {
|
|
17095
17150
|
switch (req.op) {
|
|
17096
17151
|
case "getattr":
|
|
@@ -17135,13 +17190,7 @@ async function dispatch(h, req) {
|
|
|
17135
17190
|
if (!h.readlink) throw fsError2("EINVAL", `${req.path} is not a symlink`);
|
|
17136
17191
|
return h.readlink(req.path);
|
|
17137
17192
|
case "setattr":
|
|
17138
|
-
return h.setattr?.(req.path,
|
|
17139
|
-
...req.mode !== void 0 ? { mode: req.mode } : {},
|
|
17140
|
-
...req.mtime !== void 0 ? { mtime: req.mtime } : {},
|
|
17141
|
-
...req.size !== void 0 ? { size: req.size } : {},
|
|
17142
|
-
...req.uid !== void 0 ? { uid: req.uid } : {},
|
|
17143
|
-
...req.gid !== void 0 ? { gid: req.gid } : {}
|
|
17144
|
-
});
|
|
17193
|
+
return h.setattr?.(req.path, setAttrOf(req));
|
|
17145
17194
|
case "statfs":
|
|
17146
17195
|
return h.statfs?.() ?? null;
|
|
17147
17196
|
default:
|
|
@@ -18250,11 +18299,13 @@ function idOption2(value) {
|
|
|
18250
18299
|
return value !== void 0 && /^\d+$/.test(value) ? Number(value) : 0;
|
|
18251
18300
|
}
|
|
18252
18301
|
function created2(ino, kind, mode, from, owner) {
|
|
18302
|
+
const now = Date.now();
|
|
18253
18303
|
return {
|
|
18254
18304
|
kind,
|
|
18255
18305
|
ino,
|
|
18256
18306
|
mode: owner?.mode === void 0 ? mode : mode & ~4095 | owner.mode & 4095,
|
|
18257
|
-
mtime:
|
|
18307
|
+
mtime: now,
|
|
18308
|
+
atime: now,
|
|
18258
18309
|
data: new ChunkedBytes(),
|
|
18259
18310
|
target: "",
|
|
18260
18311
|
children: /* @__PURE__ */ new Map(),
|
|
@@ -18272,6 +18323,7 @@ function attr(node) {
|
|
|
18272
18323
|
kind: node.kind,
|
|
18273
18324
|
size: node.kind === "file" ? node.data.size : node.kind === "symlink" ? node.target.length : 4096,
|
|
18274
18325
|
mtime: node.mtime,
|
|
18326
|
+
atime: node.atime,
|
|
18275
18327
|
mode: node.mode,
|
|
18276
18328
|
ino: node.ino,
|
|
18277
18329
|
...node.kind === "directory" ? {} : { nlink: node.links },
|
|
@@ -18434,6 +18486,7 @@ function tmpfs() {
|
|
|
18434
18486
|
node.mtime = Date.now();
|
|
18435
18487
|
}
|
|
18436
18488
|
if (change.mtime !== void 0) node.mtime = change.mtime;
|
|
18489
|
+
if (change.atime !== void 0) node.atime = change.atime;
|
|
18437
18490
|
owned3(node, change);
|
|
18438
18491
|
},
|
|
18439
18492
|
async statfs() {
|
|
@@ -19453,8 +19506,8 @@ var Launcher = class {
|
|
|
19453
19506
|
let found = this.catalogs.get(scope);
|
|
19454
19507
|
if (!found) {
|
|
19455
19508
|
found = this.trustedAppended().then(async (appended) => {
|
|
19456
|
-
const
|
|
19457
|
-
return scanCommands(this.scanned,
|
|
19509
|
+
const tiers = await this.tiers(scope, appended);
|
|
19510
|
+
return scanCommands(this.scanned, tiers, tiers.length - appended.length);
|
|
19458
19511
|
}).then((commands) => commands.set(SUDO_COMMAND.name, SUDO_COMMAND));
|
|
19459
19512
|
this.catalogs.set(scope, found);
|
|
19460
19513
|
}
|
|
@@ -19482,13 +19535,16 @@ var Launcher = class {
|
|
|
19482
19535
|
}
|
|
19483
19536
|
return found;
|
|
19484
19537
|
}
|
|
19485
|
-
async
|
|
19538
|
+
async tiers(scope = "", appended) {
|
|
19486
19539
|
const system = [
|
|
19487
|
-
this.modulesDir,
|
|
19488
|
-
|
|
19489
|
-
...appended ?? await this.trustedAppended()
|
|
19540
|
+
[this.modulesDir],
|
|
19541
|
+
await pnpmGlobalRoots(this.base, this.pnpmHome),
|
|
19542
|
+
...(appended ?? await this.trustedAppended()).map((root) => [root])
|
|
19490
19543
|
];
|
|
19491
|
-
return scope ? [
|
|
19544
|
+
return scope ? [await pnpmGlobalRoots(this.base, scope), ...system] : system;
|
|
19545
|
+
}
|
|
19546
|
+
async roots(scope = "") {
|
|
19547
|
+
return (await this.tiers(scope)).flat();
|
|
19492
19548
|
}
|
|
19493
19549
|
async rootOnlyPath(root) {
|
|
19494
19550
|
for (const at of chain(root)) {
|