@ai-ecoverse/slicc-kernel 1.39.2 → 1.40.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 -3
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +45 -16
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +216 -35
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +45 -16
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +216 -35
- package/dist/process-worker.js.map +4 -4
- package/package.json +1 -1
package/dist/kernel-worker.js
CHANGED
|
@@ -5063,18 +5063,19 @@ async function withPackagePaths(fs, pkg, command) {
|
|
|
5063
5063
|
}
|
|
5064
5064
|
async function packages(fs, modules) {
|
|
5065
5065
|
const names = await fs.readdir(modules).catch(() => []);
|
|
5066
|
-
const
|
|
5066
|
+
const packageNames = [];
|
|
5067
5067
|
for (const name2 of names) {
|
|
5068
5068
|
if (name2.startsWith(".")) continue;
|
|
5069
5069
|
if (!name2.startsWith("@")) {
|
|
5070
|
-
|
|
5070
|
+
packageNames.push(name2);
|
|
5071
5071
|
continue;
|
|
5072
5072
|
}
|
|
5073
5073
|
for (const inner of await fs.readdir(`${modules}/${name2}`).catch(() => [])) {
|
|
5074
|
-
|
|
5074
|
+
packageNames.push(`${name2}/${inner}`);
|
|
5075
5075
|
}
|
|
5076
5076
|
}
|
|
5077
|
-
|
|
5077
|
+
packageNames.sort();
|
|
5078
|
+
return packageNames.map((name2) => `${modules}/${name2}`);
|
|
5078
5079
|
}
|
|
5079
5080
|
async function pnpmGlobalRoots(fs, home) {
|
|
5080
5081
|
const roots = [];
|
|
@@ -5133,8 +5134,10 @@ async function scanFilesystems(fs, modules) {
|
|
|
5133
5134
|
return found;
|
|
5134
5135
|
}
|
|
5135
5136
|
var SUFFIX = /^\.[A-Za-z0-9_+-][A-Za-z0-9._+-]*$/;
|
|
5136
|
-
async function scanBinfmts(fs, modules) {
|
|
5137
|
+
async function scanBinfmts(fs, modules, warn = () => {
|
|
5138
|
+
}) {
|
|
5137
5139
|
const found = /* @__PURE__ */ new Map();
|
|
5140
|
+
const owners = /* @__PURE__ */ new Map();
|
|
5138
5141
|
for (const pkg of await packagesIn(fs, modules)) {
|
|
5139
5142
|
let manifest;
|
|
5140
5143
|
try {
|
|
@@ -5146,7 +5149,15 @@ async function scanBinfmts(fs, modules) {
|
|
|
5146
5149
|
if (!declared || typeof declared !== "object") continue;
|
|
5147
5150
|
for (const [suffix, command] of Object.entries(declared)) {
|
|
5148
5151
|
if (!SUFFIX.test(suffix) || typeof command !== "string" || !NAME.test(command)) continue;
|
|
5149
|
-
|
|
5152
|
+
const owner = owners.get(suffix);
|
|
5153
|
+
if (owner === void 0) {
|
|
5154
|
+
found.set(suffix, command);
|
|
5155
|
+
owners.set(suffix, pkg);
|
|
5156
|
+
} else if (found.get(suffix) !== command) {
|
|
5157
|
+
warn(
|
|
5158
|
+
`binfmt ${suffix}: ${owner} maps it to ${found.get(suffix)}, so ${pkg}'s ${command} is ignored`
|
|
5159
|
+
);
|
|
5160
|
+
}
|
|
5150
5161
|
}
|
|
5151
5162
|
}
|
|
5152
5163
|
return found;
|
|
@@ -5664,6 +5675,7 @@ var ChildTable = class {
|
|
|
5664
5675
|
if ("fd" in slot) return this.parentFds.get(slot.fd).retain();
|
|
5665
5676
|
if ("input" in slot) return bytesSource(slot.input);
|
|
5666
5677
|
if ("device" in slot) return deviceFile(slot.device, slot.access);
|
|
5678
|
+
if ("dir" in slot) return heldFile({ dir: slot.dir });
|
|
5667
5679
|
if ("capture" in slot) {
|
|
5668
5680
|
const chunks = [];
|
|
5669
5681
|
captured.set(n, chunks);
|
|
@@ -7047,6 +7059,7 @@ var AsyncOps = class {
|
|
|
7047
7059
|
next = 1;
|
|
7048
7060
|
results = /* @__PURE__ */ new Map();
|
|
7049
7061
|
ready = [];
|
|
7062
|
+
running = /* @__PURE__ */ new Map();
|
|
7050
7063
|
waiters = /* @__PURE__ */ new Set();
|
|
7051
7064
|
closed = false;
|
|
7052
7065
|
run;
|
|
@@ -7057,7 +7070,9 @@ var AsyncOps = class {
|
|
|
7057
7070
|
}
|
|
7058
7071
|
submit(req) {
|
|
7059
7072
|
const id = this.hold();
|
|
7060
|
-
|
|
7073
|
+
const running = new AbortController();
|
|
7074
|
+
this.running.set(id, running);
|
|
7075
|
+
this.run(req, running.signal).then(
|
|
7061
7076
|
(result) => this.complete(id, result),
|
|
7062
7077
|
(err) => this.complete(id, { ok: false, errno: "EIO", message: String(err) })
|
|
7063
7078
|
);
|
|
@@ -7077,10 +7092,15 @@ var AsyncOps = class {
|
|
|
7077
7092
|
if (!this.results.has(id)) throw new KernelError("EINVAL");
|
|
7078
7093
|
const result = this.results.get(id);
|
|
7079
7094
|
if (!result) throw new KernelError("EAGAIN");
|
|
7080
|
-
this.
|
|
7095
|
+
this.forget(id);
|
|
7081
7096
|
return result;
|
|
7082
7097
|
}
|
|
7083
7098
|
cancel(id) {
|
|
7099
|
+
this.running.get(id)?.abort();
|
|
7100
|
+
this.forget(id);
|
|
7101
|
+
}
|
|
7102
|
+
forget(id) {
|
|
7103
|
+
this.running.delete(id);
|
|
7084
7104
|
this.results.delete(id);
|
|
7085
7105
|
const at = this.ready.indexOf(id);
|
|
7086
7106
|
if (at >= 0) this.ready.splice(at, 1);
|
|
@@ -7126,6 +7146,7 @@ var AsyncOps = class {
|
|
|
7126
7146
|
});
|
|
7127
7147
|
}
|
|
7128
7148
|
complete(id, result) {
|
|
7149
|
+
this.running.delete(id);
|
|
7129
7150
|
if (!this.results.has(id)) return;
|
|
7130
7151
|
this.results.set(id, result);
|
|
7131
7152
|
this.ready.push(id);
|
|
@@ -8939,13 +8960,13 @@ var WasmProcess = class {
|
|
|
8939
8960
|
this.wake?.();
|
|
8940
8961
|
for (const listener of this.stateListeners) listener("continued", SIG.CONT);
|
|
8941
8962
|
}
|
|
8942
|
-
async syscall(req) {
|
|
8963
|
+
async syscall(req, cancelled) {
|
|
8943
8964
|
this.options.onSyscall?.(req);
|
|
8944
8965
|
for (; ; ) {
|
|
8945
8966
|
await this.resumed;
|
|
8946
8967
|
if (this.dying) return DYING;
|
|
8947
8968
|
const stops = this.stops;
|
|
8948
|
-
const result = await this.dispatch(req);
|
|
8969
|
+
const result = await this.dispatch(req, cancelled);
|
|
8949
8970
|
if (this.dying) return DYING;
|
|
8950
8971
|
const restart = !result.ok && result.errno === "EINTR" && this.stops !== stops;
|
|
8951
8972
|
if (restart && !this.options.hasPending?.()) continue;
|
|
@@ -8964,9 +8985,9 @@ var WasmProcess = class {
|
|
|
8964
8985
|
this.interrupt.abort();
|
|
8965
8986
|
this.wake?.();
|
|
8966
8987
|
}
|
|
8967
|
-
async dispatch(req) {
|
|
8988
|
+
async dispatch(req, cancelled) {
|
|
8968
8989
|
try {
|
|
8969
|
-
if (isFdSyscall(req)) return await this.fdSyscall(req);
|
|
8990
|
+
if (isFdSyscall(req)) return await this.fdSyscall(req, cancelled);
|
|
8970
8991
|
if (isTtySyscall(req)) return this.ttySyscall(req);
|
|
8971
8992
|
if (isJobSyscall(req)) return this.jobSyscall(req);
|
|
8972
8993
|
if (isSocketSyscall(req)) return await this.socketSyscall(req);
|
|
@@ -9067,7 +9088,7 @@ var WasmProcess = class {
|
|
|
9067
9088
|
this.nodes
|
|
9068
9089
|
);
|
|
9069
9090
|
}
|
|
9070
|
-
async fdSyscall(req) {
|
|
9091
|
+
async fdSyscall(req, cancelled) {
|
|
9071
9092
|
if (isVfsSyscall(req)) return this.vfsSyscall(req);
|
|
9072
9093
|
switch (req.op) {
|
|
9073
9094
|
case "fd-read":
|
|
@@ -9138,7 +9159,8 @@ var WasmProcess = class {
|
|
|
9138
9159
|
return { ok: true, kind: "json", json: this.options.jobs?.terminalNames() ?? [] };
|
|
9139
9160
|
case "fd-select": {
|
|
9140
9161
|
const { read, write, timeoutMs } = req;
|
|
9141
|
-
const
|
|
9162
|
+
const blocking = this.blockingSignal();
|
|
9163
|
+
const signal = cancelled ? AbortSignal.any([blocking, cancelled]) : blocking;
|
|
9142
9164
|
const selected = await selectFds(this.fds, read, write, timeoutMs, signal);
|
|
9143
9165
|
return { ok: true, kind: "json", json: selected };
|
|
9144
9166
|
}
|
|
@@ -9417,7 +9439,7 @@ var WasmProcess = class {
|
|
|
9417
9439
|
alarm;
|
|
9418
9440
|
dlLog = [];
|
|
9419
9441
|
asyncOps = new AsyncOps(
|
|
9420
|
-
(req) => this.syscall(req),
|
|
9442
|
+
(req, cancelled) => this.syscall(req, cancelled),
|
|
9421
9443
|
() => this.options.onAsync?.()
|
|
9422
9444
|
);
|
|
9423
9445
|
alarmEvery;
|
|
@@ -11254,6 +11276,7 @@ var Launcher = class {
|
|
|
11254
11276
|
env;
|
|
11255
11277
|
catalog;
|
|
11256
11278
|
binfmts;
|
|
11279
|
+
warned = /* @__PURE__ */ new Set();
|
|
11257
11280
|
compiled = /* @__PURE__ */ new Map();
|
|
11258
11281
|
processes = /* @__PURE__ */ new Map();
|
|
11259
11282
|
zombies = /* @__PURE__ */ new Set();
|
|
@@ -11360,7 +11383,13 @@ var Launcher = class {
|
|
|
11360
11383
|
return this.catalog;
|
|
11361
11384
|
}
|
|
11362
11385
|
interpreters() {
|
|
11363
|
-
this.binfmts ??= this.roots().then(
|
|
11386
|
+
this.binfmts ??= this.roots().then(
|
|
11387
|
+
(roots) => scanBinfmts(this.base, roots, (message2) => {
|
|
11388
|
+
if (this.warned.has(message2)) return;
|
|
11389
|
+
this.warned.add(message2);
|
|
11390
|
+
console.warn(message2);
|
|
11391
|
+
})
|
|
11392
|
+
);
|
|
11364
11393
|
return this.binfmts;
|
|
11365
11394
|
}
|
|
11366
11395
|
async roots() {
|