@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/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")) {
|
|
@@ -8279,7 +8320,7 @@ function statOf(attr2, path, mount) {
|
|
|
8279
8320
|
size: attr2.size,
|
|
8280
8321
|
mode: attr2.mode ?? fallback,
|
|
8281
8322
|
mtime,
|
|
8282
|
-
atime: mtime,
|
|
8323
|
+
atime: attr2.atime === void 0 ? mtime : new Date(attr2.atime),
|
|
8283
8324
|
ctime: mtime,
|
|
8284
8325
|
ino: attr2.ino ?? inodeOf(path),
|
|
8285
8326
|
...!inodeless(mount, attr2) && attr2.nlink !== void 0 ? { nlink: attr2.nlink } : {},
|
|
@@ -9324,7 +9365,7 @@ var MountFs = class _MountFs {
|
|
|
9324
9365
|
([to], n) => this.utimes(to, atime, mtime, n)
|
|
9325
9366
|
);
|
|
9326
9367
|
}
|
|
9327
|
-
await this.
|
|
9368
|
+
await this.setTimes(found, real, atime, mtime);
|
|
9328
9369
|
}
|
|
9329
9370
|
async lutimes(path, atime, mtime, redirects = 0) {
|
|
9330
9371
|
const found = this.at(path);
|
|
@@ -9341,12 +9382,13 @@ var MountFs = class _MountFs {
|
|
|
9341
9382
|
if (!found.mount.caps.linkTimes && (await this.lstat(real)).isSymbolicLink) {
|
|
9342
9383
|
throw errnoError("EOPNOTSUPP", path);
|
|
9343
9384
|
}
|
|
9344
|
-
await this.
|
|
9385
|
+
await this.setTimes(found, real, atime, mtime);
|
|
9345
9386
|
}
|
|
9346
|
-
async
|
|
9387
|
+
async setTimes(found, real, atime, mtime) {
|
|
9347
9388
|
this.writable(found.mount, real);
|
|
9348
9389
|
this.table.forget(found.mount, real);
|
|
9349
|
-
|
|
9390
|
+
const times = { mtime: mtime.getTime(), atime: atime.getTime() };
|
|
9391
|
+
await found.mount.conn.call({ op: "setattr", path: found.rel, ...times });
|
|
9350
9392
|
}
|
|
9351
9393
|
noLinks() {
|
|
9352
9394
|
const noLinkBase = this.base.noLinks.call(this.base);
|
|
@@ -10108,14 +10150,6 @@ function attachSyncSabResponder(port, sab, token, opts) {
|
|
|
10108
10150
|
}
|
|
10109
10151
|
|
|
10110
10152
|
// src/kernel/cpu-clock.ts
|
|
10111
|
-
var IDLE_OPS = /* @__PURE__ */ new Set([
|
|
10112
|
-
"fd-select",
|
|
10113
|
-
"proc-wait",
|
|
10114
|
-
"proc-exec",
|
|
10115
|
-
"sig-pause",
|
|
10116
|
-
"sock-accept",
|
|
10117
|
-
"sock-connect"
|
|
10118
|
-
]);
|
|
10119
10153
|
var SYS_CAP_US = 2e4;
|
|
10120
10154
|
var LOCAL = SAB_CLOCK_OFFSET;
|
|
10121
10155
|
var BLOCKED = 0;
|
|
@@ -10147,9 +10181,16 @@ var CpuClock = class {
|
|
|
10147
10181
|
this.now = now;
|
|
10148
10182
|
this.start = now();
|
|
10149
10183
|
}
|
|
10150
|
-
enter(
|
|
10184
|
+
enter() {
|
|
10151
10185
|
this.since = this.now();
|
|
10152
|
-
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";
|
|
10153
10194
|
}
|
|
10154
10195
|
leave() {
|
|
10155
10196
|
if (this.since === 0) return;
|
|
@@ -10239,9 +10280,10 @@ var ProcessClocks = class {
|
|
|
10239
10280
|
}
|
|
10240
10281
|
timed(clock, dispatch2) {
|
|
10241
10282
|
const c = clock ?? this.main;
|
|
10283
|
+
const block = () => c.block();
|
|
10242
10284
|
return (req) => {
|
|
10243
|
-
c.enter(
|
|
10244
|
-
return dispatch2(req).finally(() => c.leave());
|
|
10285
|
+
c.enter();
|
|
10286
|
+
return dispatch2(req, block).finally(() => c.leave());
|
|
10245
10287
|
};
|
|
10246
10288
|
}
|
|
10247
10289
|
all() {
|
|
@@ -10500,7 +10542,7 @@ function mountTable(mounts = []) {
|
|
|
10500
10542
|
}
|
|
10501
10543
|
|
|
10502
10544
|
// src/version.ts
|
|
10503
|
-
var KERNEL_VERSION = true ? "1.
|
|
10545
|
+
var KERNEL_VERSION = true ? "1.94.0" : "0.0.0-dev";
|
|
10504
10546
|
var OS_RELEASE = "6.0.0-slicc";
|
|
10505
10547
|
function procVersion() {
|
|
10506
10548
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -14192,7 +14234,8 @@ var WasmProcess = class {
|
|
|
14192
14234
|
this.wake?.();
|
|
14193
14235
|
for (const listener of this.stateListeners) listener("continued", SIG.CONT);
|
|
14194
14236
|
}
|
|
14195
|
-
|
|
14237
|
+
blocks = /* @__PURE__ */ new WeakMap();
|
|
14238
|
+
async syscall(req, cancelled, block) {
|
|
14196
14239
|
this.options.onSyscall?.(req);
|
|
14197
14240
|
for (; ; ) {
|
|
14198
14241
|
await this.resumed;
|
|
@@ -14202,6 +14245,7 @@ var WasmProcess = class {
|
|
|
14202
14245
|
const forward = () => scope.abort();
|
|
14203
14246
|
if (cancelled?.aborted) scope.abort();
|
|
14204
14247
|
cancelled?.addEventListener("abort", forward, { once: true });
|
|
14248
|
+
if (block) this.blocks.set(scope.signal, block);
|
|
14205
14249
|
const result = await this.dispatch(req, scope.signal).finally(() => {
|
|
14206
14250
|
cancelled?.removeEventListener("abort", forward);
|
|
14207
14251
|
this.waiting.delete(scope.signal);
|
|
@@ -14284,6 +14328,7 @@ var WasmProcess = class {
|
|
|
14284
14328
|
}
|
|
14285
14329
|
if (this.options.hasPending?.() || cancelled.aborted) throw new KernelError("EINTR");
|
|
14286
14330
|
if (owing) this.waiting.add(cancelled);
|
|
14331
|
+
if (owing) this.blocks.get(cancelled)?.();
|
|
14287
14332
|
return this.cancelSignal(cancelled);
|
|
14288
14333
|
}
|
|
14289
14334
|
cancelSignal(cancelled) {
|
|
@@ -14925,6 +14970,7 @@ var WasmProcess = class {
|
|
|
14925
14970
|
case "proc-identity":
|
|
14926
14971
|
return { ok: true, kind: "json", json: await this.options.identity?.() ?? null };
|
|
14927
14972
|
case "proc-exec": {
|
|
14973
|
+
this.blocks.get(cancelled)?.();
|
|
14928
14974
|
this.adoptExec(req.pid);
|
|
14929
14975
|
this.options.jobs?.exec(this.pid, req.pid);
|
|
14930
14976
|
await this.fds.closeAll();
|
|
@@ -15255,6 +15301,9 @@ function killThread(thread, caught, sig) {
|
|
|
15255
15301
|
function unblocked(header4) {
|
|
15256
15302
|
return Atomics.load(header4, SAB_I_SIGNALS) & ~Atomics.load(header4, SAB_I_BLOCKED);
|
|
15257
15303
|
}
|
|
15304
|
+
function threadCall(process2, req, cancelled, block) {
|
|
15305
|
+
return isWasmSyscall(req) ? process2.syscall(req, cancelled, block) : dispatchSyncFs(req);
|
|
15306
|
+
}
|
|
15258
15307
|
function threadSignalsOf(sab) {
|
|
15259
15308
|
return { header: new Int32Array(sab, 0, SAB_HEADER_I32), interrupt: new AbortController() };
|
|
15260
15309
|
}
|
|
@@ -15458,7 +15507,9 @@ function spawnWasmProcess(opts) {
|
|
|
15458
15507
|
process2.keptHandle = (handle2) => holds.keptFor(handle2)?.hidden;
|
|
15459
15508
|
const worker = opts.createWorker();
|
|
15460
15509
|
const dying = new Dying();
|
|
15461
|
-
const dispatch2 = (req) => dying.serving(
|
|
15510
|
+
const dispatch2 = (req, block) => dying.serving(
|
|
15511
|
+
() => isWasmSyscall(req) ? process2.syscall(req, void 0, block) : dispatchSyncFs(req)
|
|
15512
|
+
);
|
|
15462
15513
|
const clocks = new ProcessClocks(sab, opts.program.abi !== "js", process2);
|
|
15463
15514
|
const responder = attachSyncSabResponder(worker, sab, token, {
|
|
15464
15515
|
dispatch: clocks.timed(void 0, dispatch2)
|
|
@@ -15528,9 +15579,7 @@ function spawnWasmProcess(opts) {
|
|
|
15528
15579
|
const tsignals = threadSignalsOf(tsab);
|
|
15529
15580
|
if (thread.blocked) storeBlocked(tsignals.header, thread.blocked);
|
|
15530
15581
|
threadSignals.set(thread.tid, tsignals);
|
|
15531
|
-
const tdispatch = (req) => dying.serving(
|
|
15532
|
-
() => isWasmSyscall(req) ? process2.syscall(req, threadCancel(tsignals)) : dispatchSyncFs(req)
|
|
15533
|
-
);
|
|
15582
|
+
const tdispatch = (req, block) => dying.serving(() => threadCall(process2, req, threadCancel(tsignals), block));
|
|
15534
15583
|
const tresponder = attachSyncSabResponder(tw, tsab, token, {
|
|
15535
15584
|
dispatch: clocks.timed(clocks.thread(thread.tid, tsab), tdispatch)
|
|
15536
15585
|
});
|
|
@@ -16786,6 +16835,12 @@ function withOwner(base, owner) {
|
|
|
16786
16835
|
function fsError2(code, message3 = code) {
|
|
16787
16836
|
return Object.assign(new Error(message3), { code });
|
|
16788
16837
|
}
|
|
16838
|
+
var SET_ATTRS = ["mode", "mtime", "atime", "size", "uid", "gid"];
|
|
16839
|
+
function setAttrOf(req) {
|
|
16840
|
+
const attr2 = {};
|
|
16841
|
+
for (const key of SET_ATTRS) if (req[key] !== void 0) attr2[key] = req[key];
|
|
16842
|
+
return attr2;
|
|
16843
|
+
}
|
|
16789
16844
|
async function dispatch(h, req) {
|
|
16790
16845
|
switch (req.op) {
|
|
16791
16846
|
case "getattr":
|
|
@@ -16830,13 +16885,7 @@ async function dispatch(h, req) {
|
|
|
16830
16885
|
if (!h.readlink) throw fsError2("EINVAL", `${req.path} is not a symlink`);
|
|
16831
16886
|
return h.readlink(req.path);
|
|
16832
16887
|
case "setattr":
|
|
16833
|
-
return h.setattr?.(req.path,
|
|
16834
|
-
...req.mode !== void 0 ? { mode: req.mode } : {},
|
|
16835
|
-
...req.mtime !== void 0 ? { mtime: req.mtime } : {},
|
|
16836
|
-
...req.size !== void 0 ? { size: req.size } : {},
|
|
16837
|
-
...req.uid !== void 0 ? { uid: req.uid } : {},
|
|
16838
|
-
...req.gid !== void 0 ? { gid: req.gid } : {}
|
|
16839
|
-
});
|
|
16888
|
+
return h.setattr?.(req.path, setAttrOf(req));
|
|
16840
16889
|
case "statfs":
|
|
16841
16890
|
return h.statfs?.() ?? null;
|
|
16842
16891
|
default:
|
|
@@ -18048,11 +18097,13 @@ function idOption2(value) {
|
|
|
18048
18097
|
return value !== void 0 && /^\d+$/.test(value) ? Number(value) : 0;
|
|
18049
18098
|
}
|
|
18050
18099
|
function created2(ino, kind, mode, from, owner) {
|
|
18100
|
+
const now = Date.now();
|
|
18051
18101
|
return {
|
|
18052
18102
|
kind,
|
|
18053
18103
|
ino,
|
|
18054
18104
|
mode: owner?.mode === void 0 ? mode : mode & ~4095 | owner.mode & 4095,
|
|
18055
|
-
mtime:
|
|
18105
|
+
mtime: now,
|
|
18106
|
+
atime: now,
|
|
18056
18107
|
data: new ChunkedBytes(),
|
|
18057
18108
|
target: "",
|
|
18058
18109
|
children: /* @__PURE__ */ new Map(),
|
|
@@ -18070,6 +18121,7 @@ function attr(node) {
|
|
|
18070
18121
|
kind: node.kind,
|
|
18071
18122
|
size: node.kind === "file" ? node.data.size : node.kind === "symlink" ? node.target.length : 4096,
|
|
18072
18123
|
mtime: node.mtime,
|
|
18124
|
+
atime: node.atime,
|
|
18073
18125
|
mode: node.mode,
|
|
18074
18126
|
ino: node.ino,
|
|
18075
18127
|
...node.kind === "directory" ? {} : { nlink: node.links },
|
|
@@ -18232,6 +18284,7 @@ function tmpfs() {
|
|
|
18232
18284
|
node.mtime = Date.now();
|
|
18233
18285
|
}
|
|
18234
18286
|
if (change.mtime !== void 0) node.mtime = change.mtime;
|
|
18287
|
+
if (change.atime !== void 0) node.atime = change.atime;
|
|
18235
18288
|
owned3(node, change);
|
|
18236
18289
|
},
|
|
18237
18290
|
async statfs() {
|
|
@@ -19251,8 +19304,8 @@ var Launcher = class {
|
|
|
19251
19304
|
let found = this.catalogs.get(scope);
|
|
19252
19305
|
if (!found) {
|
|
19253
19306
|
found = this.trustedAppended().then(async (appended) => {
|
|
19254
|
-
const
|
|
19255
|
-
return scanCommands(this.scanned,
|
|
19307
|
+
const tiers = await this.tiers(scope, appended);
|
|
19308
|
+
return scanCommands(this.scanned, tiers, tiers.length - appended.length);
|
|
19256
19309
|
}).then((commands) => commands.set(SUDO_COMMAND.name, SUDO_COMMAND));
|
|
19257
19310
|
this.catalogs.set(scope, found);
|
|
19258
19311
|
}
|
|
@@ -19280,13 +19333,16 @@ var Launcher = class {
|
|
|
19280
19333
|
}
|
|
19281
19334
|
return found;
|
|
19282
19335
|
}
|
|
19283
|
-
async
|
|
19336
|
+
async tiers(scope = "", appended) {
|
|
19284
19337
|
const system = [
|
|
19285
|
-
this.modulesDir,
|
|
19286
|
-
|
|
19287
|
-
...appended ?? await this.trustedAppended()
|
|
19338
|
+
[this.modulesDir],
|
|
19339
|
+
await pnpmGlobalRoots(this.base, this.pnpmHome),
|
|
19340
|
+
...(appended ?? await this.trustedAppended()).map((root) => [root])
|
|
19288
19341
|
];
|
|
19289
|
-
return scope ? [
|
|
19342
|
+
return scope ? [await pnpmGlobalRoots(this.base, scope), ...system] : system;
|
|
19343
|
+
}
|
|
19344
|
+
async roots(scope = "") {
|
|
19345
|
+
return (await this.tiers(scope)).flat();
|
|
19290
19346
|
}
|
|
19291
19347
|
async rootOnlyPath(root) {
|
|
19292
19348
|
for (const at of chain(root)) {
|
|
@@ -20898,6 +20954,17 @@ function proxyAddresses() {
|
|
|
20898
20954
|
}
|
|
20899
20955
|
return out;
|
|
20900
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
|
+
}
|
|
20901
20968
|
function ensureSubscribed() {
|
|
20902
20969
|
if (subscribed) return;
|
|
20903
20970
|
subscribed = true;
|
|
@@ -20912,10 +20979,14 @@ function ensureSubscribed() {
|
|
|
20912
20979
|
socket.destroy(err2);
|
|
20913
20980
|
return;
|
|
20914
20981
|
}
|
|
20915
|
-
const
|
|
20916
|
-
if (
|
|
20917
|
-
|
|
20918
|
-
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;
|
|
20919
20990
|
}
|
|
20920
20991
|
const place = placeOf(address);
|
|
20921
20992
|
if (!place) return;
|