@ai-ecoverse/slicc-kernel 1.93.3 → 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 +4 -4
- package/dist/kernel-worker.js +85 -34
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +7 -4
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +104 -38
- 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/node.js
CHANGED
|
@@ -6158,10 +6158,15 @@ async function binCommandsOf(physical, pkg, manifest, taken) {
|
|
|
6158
6158
|
}
|
|
6159
6159
|
return out;
|
|
6160
6160
|
}
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
const
|
|
6164
|
-
|
|
6161
|
+
var PACKAGE_NAME = /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/;
|
|
6162
|
+
function replacesOf(manifest) {
|
|
6163
|
+
const replaces = manifest.slicc?.replaces;
|
|
6164
|
+
if (!Array.isArray(replaces)) return [];
|
|
6165
|
+
return replaces.every((name2) => typeof name2 === "string" && PACKAGE_NAME.test(name2)) ? replaces : [];
|
|
6166
|
+
}
|
|
6167
|
+
async function tierPackages(fs, physical, roots, bins) {
|
|
6168
|
+
const out = [];
|
|
6169
|
+
for (const root of roots) {
|
|
6165
6170
|
for (const pkg of await packages(fs, root)) {
|
|
6166
6171
|
let manifest;
|
|
6167
6172
|
try {
|
|
@@ -6171,11 +6176,47 @@ async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY) {
|
|
|
6171
6176
|
}
|
|
6172
6177
|
const own = commandsOf(pkg, manifest);
|
|
6173
6178
|
const named = new Set(own.map((command) => command.name));
|
|
6174
|
-
const
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
+
const extra = bins ? await binCommandsOf(physical, pkg, manifest, named) : [];
|
|
6180
|
+
out.push({
|
|
6181
|
+
name: pkg.slice(root.length + 1),
|
|
6182
|
+
pkg,
|
|
6183
|
+
replaces: replacesOf(manifest),
|
|
6184
|
+
commands: [...own, ...extra]
|
|
6185
|
+
});
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6188
|
+
return out;
|
|
6189
|
+
}
|
|
6190
|
+
function winners(tier) {
|
|
6191
|
+
const providers = /* @__PURE__ */ new Map();
|
|
6192
|
+
for (const entry of tier) {
|
|
6193
|
+
for (const command of entry.commands) {
|
|
6194
|
+
const list = providers.get(command.name) ?? [];
|
|
6195
|
+
if (!list.includes(entry)) list.push(entry);
|
|
6196
|
+
providers.set(command.name, list);
|
|
6197
|
+
}
|
|
6198
|
+
}
|
|
6199
|
+
const out = /* @__PURE__ */ new Map();
|
|
6200
|
+
for (const [name2, list] of providers) {
|
|
6201
|
+
const kept = list.filter(
|
|
6202
|
+
(entry2) => !list.some((other) => other !== entry2 && other.replaces.includes(entry2.name))
|
|
6203
|
+
);
|
|
6204
|
+
const entry = kept[0] ?? list[0];
|
|
6205
|
+
const command = entry.commands.find((c) => c.name === name2);
|
|
6206
|
+
out.set(name2, { pkg: entry.pkg, command });
|
|
6207
|
+
}
|
|
6208
|
+
return out;
|
|
6209
|
+
}
|
|
6210
|
+
async function scanCommands(fs, modules, binsFrom = Number.POSITIVE_INFINITY) {
|
|
6211
|
+
const found = /* @__PURE__ */ new Map();
|
|
6212
|
+
const physical = physicalResolver(fs);
|
|
6213
|
+
const tiers = (typeof modules === "string" ? [modules] : modules).map(
|
|
6214
|
+
(tier) => typeof tier === "string" ? [tier] : tier
|
|
6215
|
+
);
|
|
6216
|
+
for (const [index, roots] of tiers.entries()) {
|
|
6217
|
+
const tier = await tierPackages(fs, physical, roots, index >= binsFrom);
|
|
6218
|
+
for (const [name2, { pkg, command }] of winners(tier)) {
|
|
6219
|
+
if (!found.has(name2)) found.set(name2, await withPackagePaths(fs, pkg, command));
|
|
6179
6220
|
}
|
|
6180
6221
|
}
|
|
6181
6222
|
if (!found.has("sh") && found.has("bash")) {
|
|
@@ -10109,14 +10150,6 @@ function attachSyncSabResponder(port, sab, token, opts) {
|
|
|
10109
10150
|
}
|
|
10110
10151
|
|
|
10111
10152
|
// src/kernel/cpu-clock.ts
|
|
10112
|
-
var IDLE_OPS = /* @__PURE__ */ new Set([
|
|
10113
|
-
"fd-select",
|
|
10114
|
-
"proc-wait",
|
|
10115
|
-
"proc-exec",
|
|
10116
|
-
"sig-pause",
|
|
10117
|
-
"sock-accept",
|
|
10118
|
-
"sock-connect"
|
|
10119
|
-
]);
|
|
10120
10153
|
var SYS_CAP_US = 2e4;
|
|
10121
10154
|
var LOCAL = SAB_CLOCK_OFFSET;
|
|
10122
10155
|
var BLOCKED = 0;
|
|
@@ -10148,9 +10181,16 @@ var CpuClock = class {
|
|
|
10148
10181
|
this.now = now;
|
|
10149
10182
|
this.start = now();
|
|
10150
10183
|
}
|
|
10151
|
-
enter(
|
|
10184
|
+
enter() {
|
|
10152
10185
|
this.since = this.now();
|
|
10153
|
-
this.kind = this.stopped
|
|
10186
|
+
this.kind = this.stopped ? "idle" : "sys";
|
|
10187
|
+
}
|
|
10188
|
+
block() {
|
|
10189
|
+
if (this.since === 0 || this.kind === "idle" || this.frozen !== void 0) return;
|
|
10190
|
+
const now = this.now();
|
|
10191
|
+
this.add(now - this.since);
|
|
10192
|
+
this.since = now;
|
|
10193
|
+
this.kind = "idle";
|
|
10154
10194
|
}
|
|
10155
10195
|
leave() {
|
|
10156
10196
|
if (this.since === 0) return;
|
|
@@ -10240,9 +10280,10 @@ var ProcessClocks = class {
|
|
|
10240
10280
|
}
|
|
10241
10281
|
timed(clock, dispatch2) {
|
|
10242
10282
|
const c = clock ?? this.main;
|
|
10283
|
+
const block = () => c.block();
|
|
10243
10284
|
return (req) => {
|
|
10244
|
-
c.enter(
|
|
10245
|
-
return dispatch2(req).finally(() => c.leave());
|
|
10285
|
+
c.enter();
|
|
10286
|
+
return dispatch2(req, block).finally(() => c.leave());
|
|
10246
10287
|
};
|
|
10247
10288
|
}
|
|
10248
10289
|
all() {
|
|
@@ -10501,7 +10542,7 @@ function mountTable(mounts = []) {
|
|
|
10501
10542
|
}
|
|
10502
10543
|
|
|
10503
10544
|
// src/version.ts
|
|
10504
|
-
var KERNEL_VERSION = true ? "1.
|
|
10545
|
+
var KERNEL_VERSION = true ? "1.94.0" : "0.0.0-dev";
|
|
10505
10546
|
var OS_RELEASE = "6.0.0-slicc";
|
|
10506
10547
|
function procVersion() {
|
|
10507
10548
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -14193,7 +14234,8 @@ var WasmProcess = class {
|
|
|
14193
14234
|
this.wake?.();
|
|
14194
14235
|
for (const listener of this.stateListeners) listener("continued", SIG.CONT);
|
|
14195
14236
|
}
|
|
14196
|
-
|
|
14237
|
+
blocks = /* @__PURE__ */ new WeakMap();
|
|
14238
|
+
async syscall(req, cancelled, block) {
|
|
14197
14239
|
this.options.onSyscall?.(req);
|
|
14198
14240
|
for (; ; ) {
|
|
14199
14241
|
await this.resumed;
|
|
@@ -14203,6 +14245,7 @@ var WasmProcess = class {
|
|
|
14203
14245
|
const forward = () => scope.abort();
|
|
14204
14246
|
if (cancelled?.aborted) scope.abort();
|
|
14205
14247
|
cancelled?.addEventListener("abort", forward, { once: true });
|
|
14248
|
+
if (block) this.blocks.set(scope.signal, block);
|
|
14206
14249
|
const result = await this.dispatch(req, scope.signal).finally(() => {
|
|
14207
14250
|
cancelled?.removeEventListener("abort", forward);
|
|
14208
14251
|
this.waiting.delete(scope.signal);
|
|
@@ -14285,6 +14328,7 @@ var WasmProcess = class {
|
|
|
14285
14328
|
}
|
|
14286
14329
|
if (this.options.hasPending?.() || cancelled.aborted) throw new KernelError("EINTR");
|
|
14287
14330
|
if (owing) this.waiting.add(cancelled);
|
|
14331
|
+
if (owing) this.blocks.get(cancelled)?.();
|
|
14288
14332
|
return this.cancelSignal(cancelled);
|
|
14289
14333
|
}
|
|
14290
14334
|
cancelSignal(cancelled) {
|
|
@@ -14926,6 +14970,7 @@ var WasmProcess = class {
|
|
|
14926
14970
|
case "proc-identity":
|
|
14927
14971
|
return { ok: true, kind: "json", json: await this.options.identity?.() ?? null };
|
|
14928
14972
|
case "proc-exec": {
|
|
14973
|
+
this.blocks.get(cancelled)?.();
|
|
14929
14974
|
this.adoptExec(req.pid);
|
|
14930
14975
|
this.options.jobs?.exec(this.pid, req.pid);
|
|
14931
14976
|
await this.fds.closeAll();
|
|
@@ -15256,6 +15301,9 @@ function killThread(thread, caught, sig) {
|
|
|
15256
15301
|
function unblocked(header4) {
|
|
15257
15302
|
return Atomics.load(header4, SAB_I_SIGNALS) & ~Atomics.load(header4, SAB_I_BLOCKED);
|
|
15258
15303
|
}
|
|
15304
|
+
function threadCall(process2, req, cancelled, block) {
|
|
15305
|
+
return isWasmSyscall(req) ? process2.syscall(req, cancelled, block) : dispatchSyncFs(req);
|
|
15306
|
+
}
|
|
15259
15307
|
function threadSignalsOf(sab) {
|
|
15260
15308
|
return { header: new Int32Array(sab, 0, SAB_HEADER_I32), interrupt: new AbortController() };
|
|
15261
15309
|
}
|
|
@@ -15459,7 +15507,9 @@ function spawnWasmProcess(opts) {
|
|
|
15459
15507
|
process2.keptHandle = (handle2) => holds.keptFor(handle2)?.hidden;
|
|
15460
15508
|
const worker = opts.createWorker();
|
|
15461
15509
|
const dying = new Dying();
|
|
15462
|
-
const dispatch2 = (req) => dying.serving(
|
|
15510
|
+
const dispatch2 = (req, block) => dying.serving(
|
|
15511
|
+
() => isWasmSyscall(req) ? process2.syscall(req, void 0, block) : dispatchSyncFs(req)
|
|
15512
|
+
);
|
|
15463
15513
|
const clocks = new ProcessClocks(sab, opts.program.abi !== "js", process2);
|
|
15464
15514
|
const responder = attachSyncSabResponder(worker, sab, token, {
|
|
15465
15515
|
dispatch: clocks.timed(void 0, dispatch2)
|
|
@@ -15529,9 +15579,7 @@ function spawnWasmProcess(opts) {
|
|
|
15529
15579
|
const tsignals = threadSignalsOf(tsab);
|
|
15530
15580
|
if (thread.blocked) storeBlocked(tsignals.header, thread.blocked);
|
|
15531
15581
|
threadSignals.set(thread.tid, tsignals);
|
|
15532
|
-
const tdispatch = (req) => dying.serving(
|
|
15533
|
-
() => isWasmSyscall(req) ? process2.syscall(req, threadCancel(tsignals)) : dispatchSyncFs(req)
|
|
15534
|
-
);
|
|
15582
|
+
const tdispatch = (req, block) => dying.serving(() => threadCall(process2, req, threadCancel(tsignals), block));
|
|
15535
15583
|
const tresponder = attachSyncSabResponder(tw, tsab, token, {
|
|
15536
15584
|
dispatch: clocks.timed(clocks.thread(thread.tid, tsab), tdispatch)
|
|
15537
15585
|
});
|
|
@@ -19256,8 +19304,8 @@ var Launcher = class {
|
|
|
19256
19304
|
let found = this.catalogs.get(scope);
|
|
19257
19305
|
if (!found) {
|
|
19258
19306
|
found = this.trustedAppended().then(async (appended) => {
|
|
19259
|
-
const
|
|
19260
|
-
return scanCommands(this.scanned,
|
|
19307
|
+
const tiers = await this.tiers(scope, appended);
|
|
19308
|
+
return scanCommands(this.scanned, tiers, tiers.length - appended.length);
|
|
19261
19309
|
}).then((commands) => commands.set(SUDO_COMMAND.name, SUDO_COMMAND));
|
|
19262
19310
|
this.catalogs.set(scope, found);
|
|
19263
19311
|
}
|
|
@@ -19285,13 +19333,16 @@ var Launcher = class {
|
|
|
19285
19333
|
}
|
|
19286
19334
|
return found;
|
|
19287
19335
|
}
|
|
19288
|
-
async
|
|
19336
|
+
async tiers(scope = "", appended) {
|
|
19289
19337
|
const system = [
|
|
19290
|
-
this.modulesDir,
|
|
19291
|
-
|
|
19292
|
-
...appended ?? await this.trustedAppended()
|
|
19338
|
+
[this.modulesDir],
|
|
19339
|
+
await pnpmGlobalRoots(this.base, this.pnpmHome),
|
|
19340
|
+
...(appended ?? await this.trustedAppended()).map((root) => [root])
|
|
19293
19341
|
];
|
|
19294
|
-
return scope ? [
|
|
19342
|
+
return scope ? [await pnpmGlobalRoots(this.base, scope), ...system] : system;
|
|
19343
|
+
}
|
|
19344
|
+
async roots(scope = "") {
|
|
19345
|
+
return (await this.tiers(scope)).flat();
|
|
19295
19346
|
}
|
|
19296
19347
|
async rootOnlyPath(root) {
|
|
19297
19348
|
for (const at of chain(root)) {
|
|
@@ -20903,6 +20954,17 @@ function proxyAddresses() {
|
|
|
20903
20954
|
}
|
|
20904
20955
|
return out;
|
|
20905
20956
|
}
|
|
20957
|
+
var proxied = /* @__PURE__ */ new Set();
|
|
20958
|
+
function tupleOf(socket) {
|
|
20959
|
+
if (!socket.localPort || !socket.remotePort) return void 0;
|
|
20960
|
+
return `${socket.localAddress}:${socket.localPort} ${socket.remoteAddress}:${socket.remotePort}`;
|
|
20961
|
+
}
|
|
20962
|
+
function toProxy(connectParams) {
|
|
20963
|
+
const proxies = proxyAddresses();
|
|
20964
|
+
if (proxies.size === 0 || !connectParams.hostname) return false;
|
|
20965
|
+
const port = connectParams.port || (connectParams.protocol === "https:" ? "443" : "80");
|
|
20966
|
+
return proxies.has(`${connectParams.hostname}:${port}`);
|
|
20967
|
+
}
|
|
20906
20968
|
function ensureSubscribed() {
|
|
20907
20969
|
if (subscribed) return;
|
|
20908
20970
|
subscribed = true;
|
|
@@ -20917,10 +20979,14 @@ function ensureSubscribed() {
|
|
|
20917
20979
|
socket.destroy(err2);
|
|
20918
20980
|
return;
|
|
20919
20981
|
}
|
|
20920
|
-
const
|
|
20921
|
-
if (
|
|
20922
|
-
|
|
20923
|
-
if (
|
|
20982
|
+
const tuple = tupleOf(socket);
|
|
20983
|
+
if (tuple && proxied.has(tuple)) return;
|
|
20984
|
+
if (toProxy(connectParams)) {
|
|
20985
|
+
if (tuple) {
|
|
20986
|
+
proxied.add(tuple);
|
|
20987
|
+
socket.once("close", () => proxied.delete(tuple));
|
|
20988
|
+
}
|
|
20989
|
+
return;
|
|
20924
20990
|
}
|
|
20925
20991
|
const place = placeOf(address);
|
|
20926
20992
|
if (!place) return;
|