@ai-ecoverse/slicc-kernel 1.75.0 → 1.76.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 +3 -3
- package/dist/kernel-worker.js +74 -15
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +10 -0
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +74 -15
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +10 -0
- package/dist/process-worker.js.map +2 -2
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -3428,6 +3428,7 @@ async function positioned(handle, op) {
|
|
|
3428
3428
|
function isHandle(child) {
|
|
3429
3429
|
return "kind" in child;
|
|
3430
3430
|
}
|
|
3431
|
+
var FILE_TIMES_MS = 100;
|
|
3431
3432
|
var OpfsFs = class {
|
|
3432
3433
|
root;
|
|
3433
3434
|
meta;
|
|
@@ -3698,8 +3699,50 @@ var OpfsFs = class {
|
|
|
3698
3699
|
const fallback = directory || EXECUTABLE.test(path) ? 493 : 420;
|
|
3699
3700
|
return (directory ? S_IFDIR : S_IFREG) | (meta?.mode ?? fallback);
|
|
3700
3701
|
}
|
|
3702
|
+
id = crypto.randomUUID();
|
|
3701
3703
|
dirTimes = /* @__PURE__ */ new Map();
|
|
3702
3704
|
dirDirty = /* @__PURE__ */ new Set();
|
|
3705
|
+
fileTimes = /* @__PURE__ */ new Map();
|
|
3706
|
+
written(target) {
|
|
3707
|
+
this.committed(target);
|
|
3708
|
+
if (!this.ranged) return;
|
|
3709
|
+
this.fileTimes.set(target, Date.now());
|
|
3710
|
+
this.scheduleFileTimes();
|
|
3711
|
+
}
|
|
3712
|
+
scheduleFileTimes() {
|
|
3713
|
+
if (this.flushing.file || this.fileTimes.size === 0) return;
|
|
3714
|
+
this.flushing.file = setTimeout(() => {
|
|
3715
|
+
void this.flushFileTimes().catch(() => void 0).finally(() => {
|
|
3716
|
+
this.flushing.file = void 0;
|
|
3717
|
+
this.scheduleFileTimes();
|
|
3718
|
+
});
|
|
3719
|
+
}, FILE_TIMES_MS);
|
|
3720
|
+
this.flushing.file.unref?.();
|
|
3721
|
+
}
|
|
3722
|
+
async flushFileTimes() {
|
|
3723
|
+
for (const [path, ms] of [...this.fileTimes]) {
|
|
3724
|
+
const mtimeFor = await this.modified(path).catch(() => 0);
|
|
3725
|
+
await this.meta.update(
|
|
3726
|
+
path,
|
|
3727
|
+
(entry) => this.fileTimes.get(path) !== ms || this.explicitWins(entry, ms) ? entry : { ...entry, path, mtimeMs: ms, mtimeFor, ctimeMs: ms }
|
|
3728
|
+
);
|
|
3729
|
+
if (this.fileTimes.get(path) === ms) this.fileTimes.delete(path);
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3732
|
+
timesOf(path) {
|
|
3733
|
+
return this.dirTimes.get(path) ?? this.fileTimes.get(path);
|
|
3734
|
+
}
|
|
3735
|
+
explicitWins(entry, ms) {
|
|
3736
|
+
if (entry?.timesAt === void 0 || entry.timesBy === this.id) return false;
|
|
3737
|
+
return entry.timesAt >= ms;
|
|
3738
|
+
}
|
|
3739
|
+
movePending(from, to) {
|
|
3740
|
+
for (const [path, ms] of [...this.fileTimes]) {
|
|
3741
|
+
if (!within2(path, from)) continue;
|
|
3742
|
+
this.fileTimes.delete(path);
|
|
3743
|
+
if (to !== void 0) this.fileTimes.set(to + path.slice(from.length), ms);
|
|
3744
|
+
}
|
|
3745
|
+
}
|
|
3703
3746
|
flushing = {};
|
|
3704
3747
|
touch(...dirs) {
|
|
3705
3748
|
const now = Date.now();
|
|
@@ -3723,11 +3766,10 @@ var OpfsFs = class {
|
|
|
3723
3766
|
if (this.dirTimes.get(path) === ms) this.dirTimes.delete(path);
|
|
3724
3767
|
}
|
|
3725
3768
|
}
|
|
3726
|
-
async statOf(path, handle, meta) {
|
|
3769
|
+
async statOf(path, handle, meta, touched) {
|
|
3727
3770
|
const directory = handle.kind === "directory";
|
|
3728
3771
|
const file = directory ? void 0 : await handle.getFile();
|
|
3729
3772
|
const modified = file?.lastModified ?? 0;
|
|
3730
|
-
const touched = directory ? this.dirTimes.get(path) : void 0;
|
|
3731
3773
|
const kept = meta?.mtimeMs !== void 0 && meta.mtimeFor === modified ? meta.mtimeMs : modified;
|
|
3732
3774
|
const mtime = touched ?? kept;
|
|
3733
3775
|
return {
|
|
@@ -3759,13 +3801,14 @@ var OpfsFs = class {
|
|
|
3759
3801
|
}
|
|
3760
3802
|
async describe(found) {
|
|
3761
3803
|
if (found.link) return this.owned(this.linkStat(found.link), found.path, found.link);
|
|
3804
|
+
const touched = this.timesOf(found.path);
|
|
3762
3805
|
if (!this.owners) {
|
|
3763
3806
|
const [meta2] = await this.meta.get([found.path]);
|
|
3764
|
-
return this.statOf(found.path, found.handle, meta2);
|
|
3807
|
+
return this.statOf(found.path, found.handle, meta2, touched);
|
|
3765
3808
|
}
|
|
3766
3809
|
const entries = await this.meta.get(chain(found.path));
|
|
3767
3810
|
const meta = entries.pop();
|
|
3768
|
-
const stat = await this.statOf(found.path, found.handle, meta);
|
|
3811
|
+
const stat = await this.statOf(found.path, found.handle, meta, touched);
|
|
3769
3812
|
return { ...stat, ...ownOf(meta) ?? inherit(entries) };
|
|
3770
3813
|
}
|
|
3771
3814
|
async stat(path) {
|
|
@@ -3822,13 +3865,14 @@ var OpfsFs = class {
|
|
|
3822
3865
|
async pwrite(path, offset, bytes) {
|
|
3823
3866
|
const [handle, , target] = await this.fileFor(path);
|
|
3824
3867
|
await this.retrying(path, () => positioned(handle, (io) => io.write(offset, bytes)), true);
|
|
3825
|
-
this.
|
|
3868
|
+
this.written(target);
|
|
3826
3869
|
}
|
|
3827
3870
|
async truncate(path, size) {
|
|
3828
3871
|
const handle = await this.existing(path, true);
|
|
3829
|
-
const
|
|
3872
|
+
const resolve = this.ranged || this.remote?.watched();
|
|
3873
|
+
const target = resolve ? (await this.locate(path, true)).path : path;
|
|
3830
3874
|
await this.retrying(path, () => positioned(handle, (io) => io.truncate(size)), true);
|
|
3831
|
-
this.
|
|
3875
|
+
this.written(target);
|
|
3832
3876
|
}
|
|
3833
3877
|
async writeSession(path, truncate) {
|
|
3834
3878
|
const [handle, , target] = await this.fileFor(path);
|
|
@@ -3918,13 +3962,16 @@ var OpfsFs = class {
|
|
|
3918
3962
|
async readdirStat(path) {
|
|
3919
3963
|
const [dir, children2] = await this.listing(path);
|
|
3920
3964
|
const base = dir === "/" ? "" : dir;
|
|
3965
|
+
const touched = children2.map(([name2]) => this.timesOf(`${base}/${name2}`));
|
|
3921
3966
|
const metas = await this.meta.get(children2.map(([name2]) => `${base}/${name2}`));
|
|
3922
3967
|
const handed2 = this.owners ? await this.handedTo(dir) : void 0;
|
|
3923
3968
|
const owned4 = (stat, entry) => handed2 ? { ...stat, ...ownOf(entry) ?? handed2 } : stat;
|
|
3924
3969
|
return Promise.all(
|
|
3925
3970
|
children2.map(async ([name2, child], i) => {
|
|
3926
3971
|
if (!isHandle(child)) return [name2, owned4(this.linkStat(child), child)];
|
|
3927
|
-
const stat = await this.statOf(`${base}/${name2}`, child, metas[i]).catch(
|
|
3972
|
+
const stat = await this.statOf(`${base}/${name2}`, child, metas[i], touched[i]).catch(
|
|
3973
|
+
() => null
|
|
3974
|
+
);
|
|
3928
3975
|
return [name2, stat && owned4(stat, metas[i])];
|
|
3929
3976
|
})
|
|
3930
3977
|
);
|
|
@@ -3982,6 +4029,7 @@ var OpfsFs = class {
|
|
|
3982
4029
|
throw translate(err, path);
|
|
3983
4030
|
}
|
|
3984
4031
|
this.changed(found.path);
|
|
4032
|
+
this.movePending(found.path);
|
|
3985
4033
|
}
|
|
3986
4034
|
await this.meta.remove([found.path]);
|
|
3987
4035
|
this.touch(parentOf4(found.path));
|
|
@@ -4045,6 +4093,7 @@ var OpfsFs = class {
|
|
|
4045
4093
|
const moved2 = await this.place(source.handle, dir, staging);
|
|
4046
4094
|
if (swap) await this.rm(destination, { recursive: true });
|
|
4047
4095
|
await this.meta.move(source.path, destination, carry);
|
|
4096
|
+
this.movePending(source.path, destination);
|
|
4048
4097
|
if (!moved2) await this.rm(source.path, { recursive: true });
|
|
4049
4098
|
let copied = !moved2;
|
|
4050
4099
|
if (swap) {
|
|
@@ -4166,6 +4215,7 @@ var OpfsFs = class {
|
|
|
4166
4215
|
const handle = found.handle;
|
|
4167
4216
|
const file = handle.kind === "file" ? await handle.getFile() : void 0;
|
|
4168
4217
|
this.dirTimes.delete(found.path);
|
|
4218
|
+
this.fileTimes.delete(found.path);
|
|
4169
4219
|
const ctimeMs = Date.now();
|
|
4170
4220
|
await this.meta.update(found.path, (entry) => ({
|
|
4171
4221
|
...entry,
|
|
@@ -4174,7 +4224,8 @@ var OpfsFs = class {
|
|
|
4174
4224
|
mtimeMs: mtime.getTime(),
|
|
4175
4225
|
mtimeFor: file?.lastModified ?? 0,
|
|
4176
4226
|
ctimeMs,
|
|
4177
|
-
timesAt: ctimeMs
|
|
4227
|
+
timesAt: ctimeMs,
|
|
4228
|
+
timesBy: this.id
|
|
4178
4229
|
}));
|
|
4179
4230
|
}
|
|
4180
4231
|
async reconcile() {
|
|
@@ -5261,7 +5312,8 @@ function commandOf(pkg, name2, raw, packageAbi, shared) {
|
|
|
5261
5312
|
return { name: name2, abi: packageAbi, glue: script, wasm: script, argv0: name2, script, ...withEnv };
|
|
5262
5313
|
}
|
|
5263
5314
|
const abi = abiOf(raw.abi, packageAbi);
|
|
5264
|
-
const
|
|
5315
|
+
const fixed = typeof raw.argv0 === "string" && raw.argv0 !== "";
|
|
5316
|
+
const argv0 = fixed ? raw.argv0 : name2;
|
|
5265
5317
|
const args = argsOf(pkg, raw.args);
|
|
5266
5318
|
if (abi === "js") {
|
|
5267
5319
|
const module = inside(pkg, raw.module);
|
|
@@ -5272,6 +5324,7 @@ function commandOf(pkg, name2, raw, packageAbi, shared) {
|
|
|
5272
5324
|
glue: module,
|
|
5273
5325
|
wasm: module,
|
|
5274
5326
|
argv0,
|
|
5327
|
+
...fixed ? { argv0Fixed: true } : {},
|
|
5275
5328
|
...raw.argv0Path === true ? { argv0Path: true } : {},
|
|
5276
5329
|
...args ? { args } : {},
|
|
5277
5330
|
...withEnv
|
|
@@ -5287,6 +5340,7 @@ function commandOf(pkg, name2, raw, packageAbi, shared) {
|
|
|
5287
5340
|
glue,
|
|
5288
5341
|
wasm,
|
|
5289
5342
|
argv0,
|
|
5343
|
+
...fixed ? { argv0Fixed: true } : {},
|
|
5290
5344
|
...raw.argv0Path === true ? { argv0Path: true } : {},
|
|
5291
5345
|
...abi === "wasi" && raw.preopenRoot === true ? { preopenRoot: true } : {},
|
|
5292
5346
|
...args ? { args } : {},
|
|
@@ -11112,6 +11166,7 @@ async function runChild(req, deps) {
|
|
|
11112
11166
|
{
|
|
11113
11167
|
file: req.file,
|
|
11114
11168
|
argv: req.argv,
|
|
11169
|
+
...req.argv0 !== void 0 ? { argv0: req.argv0 } : {},
|
|
11115
11170
|
env: req.env,
|
|
11116
11171
|
cwd: req.cwd,
|
|
11117
11172
|
...req.pgid !== void 0 ? { pgid: req.pgid } : {},
|
|
@@ -12070,9 +12125,10 @@ var WasmProcess = class {
|
|
|
12070
12125
|
return "deliver";
|
|
12071
12126
|
}
|
|
12072
12127
|
async spawn(req) {
|
|
12073
|
-
const { file, argv, env, cwd, stdio, inherit: inherit2, exec, pgid, session } = req;
|
|
12128
|
+
const { file, argv, argv0, env, cwd, stdio, inherit: inherit2, exec, pgid, session } = req;
|
|
12074
12129
|
const group = { ...pgid !== void 0 ? { pgid } : {}, ...session ? { session } : {} };
|
|
12075
|
-
const
|
|
12130
|
+
const named = argv0 !== void 0 ? { argv0 } : {};
|
|
12131
|
+
const spawned = { file, argv, ...named, env, cwd, ...group, ...exec ? { exec } : {} };
|
|
12076
12132
|
const pid = await this.children.spawn(spawned, stdio, inherit2);
|
|
12077
12133
|
if (!exec) return pid;
|
|
12078
12134
|
if (this.killed) void Promise.allSettled([this.options.kill?.(pid, SIG.KILL)]);
|
|
@@ -16003,6 +16059,7 @@ function targetOf(command) {
|
|
|
16003
16059
|
glue: command.glue,
|
|
16004
16060
|
wasm: command.wasm,
|
|
16005
16061
|
argv0: command.argv0,
|
|
16062
|
+
...command.argv0Fixed ? { fixed: true } : {},
|
|
16006
16063
|
...command.args ? { prefix: command.args } : {},
|
|
16007
16064
|
...command.env ? { env: command.env } : {},
|
|
16008
16065
|
...command.unset ? { unset: command.unset } : {},
|
|
@@ -16365,8 +16422,10 @@ var Launcher = class {
|
|
|
16365
16422
|
const target = withScriptEnv(found, command);
|
|
16366
16423
|
return { target, args: [...target.prefix ?? [], ...passed], via: [interp] };
|
|
16367
16424
|
}
|
|
16368
|
-
async plan(file, argv, cwd, scope) {
|
|
16369
|
-
const
|
|
16425
|
+
async plan(file, argv, cwd, scope, argv0) {
|
|
16426
|
+
const found = await this.resolve(file, argv[0] ?? file, cwd, scope);
|
|
16427
|
+
const named = typeof argv0 === "string" && found && !found.fixed;
|
|
16428
|
+
const direct = named ? { ...found, argv0 } : found;
|
|
16370
16429
|
if (direct) return { target: direct, args: [...direct.prefix ?? [], ...argv.slice(1)] };
|
|
16371
16430
|
const script = await this.interpreted(file, argv, cwd, scope);
|
|
16372
16431
|
return script && { ...script, script: true };
|
|
@@ -16755,7 +16814,7 @@ var Launcher = class {
|
|
|
16755
16814
|
}
|
|
16756
16815
|
const cred = grant ? grant.cred : this.credOf(ppid);
|
|
16757
16816
|
const scope = grant ? "" : await this.scopeOf(cred.euid);
|
|
16758
|
-
const planned = await this.plan(req.file, req.argv, req.cwd, scope);
|
|
16817
|
+
const planned = await this.plan(req.file, req.argv, req.cwd, scope, req.argv0);
|
|
16759
16818
|
try {
|
|
16760
16819
|
await this.mayExec(cred, { ...req, pid: ppid }, planned);
|
|
16761
16820
|
} catch (err) {
|