@ai-ecoverse/slicc-kernel 1.124.1 → 1.124.3
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 +11 -3
- package/dist/kernel-worker.js +108 -36
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +42 -11
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +108 -36
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +42 -11
- package/dist/process-worker.js.map +3 -3
- package/dist/types/fs/remote.d.ts +8 -0
- package/dist/types/kernel/proc-info.d.ts +3 -0
- package/dist/types/kernel/wasm-memories.d.ts +8 -2
- package/dist/types/realm/live-vfs-fs.d.ts +1 -0
- package/dist/types/realm/sync-fs-dispatch.d.ts +1 -0
- package/dist/types/realm/sync-sab-bridge.d.ts +2 -0
- package/package.json +5 -5
package/dist/node.js
CHANGED
|
@@ -4112,6 +4112,8 @@ var ProtectedFs = class {
|
|
|
4112
4112
|
// src/fs/remote.ts
|
|
4113
4113
|
var ANNOUNCE_WAIT_MS = 500;
|
|
4114
4114
|
var PRUNE_EVERY_MS = 3e4;
|
|
4115
|
+
var MOURN_TRIES = 5;
|
|
4116
|
+
var MOURN_RETRY_MS = 100;
|
|
4115
4117
|
function lockManager() {
|
|
4116
4118
|
return globalThis.navigator?.locks;
|
|
4117
4119
|
}
|
|
@@ -4120,6 +4122,7 @@ var RemoteWatch = class {
|
|
|
4120
4122
|
name;
|
|
4121
4123
|
tab = crypto.randomUUID();
|
|
4122
4124
|
peers = /* @__PURE__ */ new Set();
|
|
4125
|
+
mourned = /* @__PURE__ */ new Set();
|
|
4123
4126
|
others = /* @__PURE__ */ new Map();
|
|
4124
4127
|
union = /* @__PURE__ */ new Set();
|
|
4125
4128
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -4188,8 +4191,7 @@ var RemoteWatch = class {
|
|
|
4188
4191
|
receive(data) {
|
|
4189
4192
|
if (data.hello !== void 0) this.greeted(data.hello);
|
|
4190
4193
|
if (data.here !== void 0 && data.to === this.tab) {
|
|
4191
|
-
this.
|
|
4192
|
-
this.recount();
|
|
4194
|
+
this.arrived(data.here);
|
|
4193
4195
|
this.met?.();
|
|
4194
4196
|
}
|
|
4195
4197
|
if (data.tab !== void 0 && data.paths !== void 0) this.announced(data);
|
|
@@ -4198,9 +4200,36 @@ var RemoteWatch = class {
|
|
|
4198
4200
|
}
|
|
4199
4201
|
if (data.changed !== void 0) this.emit({ paths: data.changed, trees: [] });
|
|
4200
4202
|
}
|
|
4201
|
-
|
|
4203
|
+
arrived(peer) {
|
|
4202
4204
|
this.peers.add(peer);
|
|
4203
4205
|
this.recount();
|
|
4206
|
+
void this.mourn(peer);
|
|
4207
|
+
}
|
|
4208
|
+
async mourn(peer, tries = MOURN_TRIES) {
|
|
4209
|
+
if (!this.locks || this.mourned.has(peer)) return;
|
|
4210
|
+
this.mourned.add(peer);
|
|
4211
|
+
const name2 = this.lockOf(peer);
|
|
4212
|
+
const { held = [], pending = [] } = await this.locks.query();
|
|
4213
|
+
if (![...held, ...pending].some((lock) => lock.name === name2)) {
|
|
4214
|
+
this.mourned.delete(peer);
|
|
4215
|
+
if (tries > 1 && this.peers.has(peer)) {
|
|
4216
|
+
setTimeout(() => void this.mourn(peer, tries - 1), MOURN_RETRY_MS);
|
|
4217
|
+
}
|
|
4218
|
+
return;
|
|
4219
|
+
}
|
|
4220
|
+
void this.locks.request(name2, async () => {
|
|
4221
|
+
this.mourned.delete(peer);
|
|
4222
|
+
this.others.delete(peer);
|
|
4223
|
+
this.peers.delete(peer);
|
|
4224
|
+
this.rebuild();
|
|
4225
|
+
this.recount();
|
|
4226
|
+
for (const wait2 of this.waiting.values()) {
|
|
4227
|
+
if (wait2.left.delete(peer) && wait2.left.size === 0) wait2.done();
|
|
4228
|
+
}
|
|
4229
|
+
});
|
|
4230
|
+
}
|
|
4231
|
+
greeted(peer) {
|
|
4232
|
+
this.arrived(peer);
|
|
4204
4233
|
const answer = () => {
|
|
4205
4234
|
this.channel.postMessage({ here: this.tab, to: peer });
|
|
4206
4235
|
if (this.mine.length > 0) void this.announce(this.mine);
|
|
@@ -4210,8 +4239,7 @@ var RemoteWatch = class {
|
|
|
4210
4239
|
}
|
|
4211
4240
|
announced({ tab, paths, seq: seq2 }) {
|
|
4212
4241
|
const from = tab;
|
|
4213
|
-
this.
|
|
4214
|
-
this.recount();
|
|
4242
|
+
this.arrived(from);
|
|
4215
4243
|
if (paths.length > 0) this.others.set(from, paths);
|
|
4216
4244
|
else this.others.delete(from);
|
|
4217
4245
|
this.rebuild();
|
|
@@ -4819,7 +4847,8 @@ var OpfsFs = class {
|
|
|
4819
4847
|
async linkAlong(path) {
|
|
4820
4848
|
for (const entry of await this.meta.get(prefixes(path))) {
|
|
4821
4849
|
if (entry?.link === void 0) continue;
|
|
4822
|
-
if (
|
|
4850
|
+
if (entry.path !== path && await this.real(entry.path)) continue;
|
|
4851
|
+
if (await this.real(parentOf4(entry.path))) return entry;
|
|
4823
4852
|
}
|
|
4824
4853
|
return void 0;
|
|
4825
4854
|
}
|
|
@@ -6541,7 +6570,7 @@ var CdpFacade = class {
|
|
|
6541
6570
|
for (const conn of this.connections) conn.close();
|
|
6542
6571
|
}
|
|
6543
6572
|
async acceptLoop() {
|
|
6544
|
-
const
|
|
6573
|
+
const served2 = /* @__PURE__ */ new Set();
|
|
6545
6574
|
for (; ; ) {
|
|
6546
6575
|
let conn;
|
|
6547
6576
|
try {
|
|
@@ -6549,10 +6578,10 @@ var CdpFacade = class {
|
|
|
6549
6578
|
} catch {
|
|
6550
6579
|
break;
|
|
6551
6580
|
}
|
|
6552
|
-
const done4 = this.serve(conn).finally(() =>
|
|
6553
|
-
|
|
6581
|
+
const done4 = this.serve(conn).finally(() => served2.delete(done4));
|
|
6582
|
+
served2.add(done4);
|
|
6554
6583
|
}
|
|
6555
|
-
await Promise.allSettled([...
|
|
6584
|
+
await Promise.allSettled([...served2]);
|
|
6556
6585
|
}
|
|
6557
6586
|
async serve(conn) {
|
|
6558
6587
|
this.connections.add(conn);
|
|
@@ -6944,7 +6973,7 @@ function satisfies(version, range2) {
|
|
|
6944
6973
|
}
|
|
6945
6974
|
|
|
6946
6975
|
// src/version.ts
|
|
6947
|
-
var KERNEL_VERSION = true ? "1.124.
|
|
6976
|
+
var KERNEL_VERSION = true ? "1.124.3" : "0.0.0-dev";
|
|
6948
6977
|
var OS_RELEASE = "6.0.0-slicc";
|
|
6949
6978
|
function procVersion() {
|
|
6950
6979
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -8359,7 +8388,7 @@ var RealmProxy = class {
|
|
|
8359
8388
|
for (const conn of this.connections) conn.close();
|
|
8360
8389
|
}
|
|
8361
8390
|
async acceptLoop() {
|
|
8362
|
-
const
|
|
8391
|
+
const served2 = /* @__PURE__ */ new Set();
|
|
8363
8392
|
try {
|
|
8364
8393
|
for (; ; ) {
|
|
8365
8394
|
await this.slots.acquire(1, this.stop.signal);
|
|
@@ -8372,13 +8401,13 @@ var RealmProxy = class {
|
|
|
8372
8401
|
}
|
|
8373
8402
|
const done4 = this.serve(conn).finally(() => {
|
|
8374
8403
|
this.slots.release(1);
|
|
8375
|
-
|
|
8404
|
+
served2.delete(done4);
|
|
8376
8405
|
});
|
|
8377
|
-
|
|
8406
|
+
served2.add(done4);
|
|
8378
8407
|
}
|
|
8379
8408
|
} catch {
|
|
8380
8409
|
}
|
|
8381
|
-
await Promise.allSettled([...
|
|
8410
|
+
await Promise.allSettled([...served2]);
|
|
8382
8411
|
}
|
|
8383
8412
|
async serve(conn) {
|
|
8384
8413
|
this.connections.add(conn);
|
|
@@ -12110,7 +12139,12 @@ var IDENTITY_OPS = /* @__PURE__ */ new Set([
|
|
|
12110
12139
|
"chown",
|
|
12111
12140
|
"lchown"
|
|
12112
12141
|
]);
|
|
12142
|
+
var served = 0;
|
|
12143
|
+
function servedFsCalls() {
|
|
12144
|
+
return served;
|
|
12145
|
+
}
|
|
12113
12146
|
async function dispatchSyncFs(req) {
|
|
12147
|
+
served++;
|
|
12114
12148
|
const entry = resolveSyncFsToken(req.token);
|
|
12115
12149
|
if (!entry) return { ok: false, errno: "EACCES", message: "sync-fs: unknown or revoked token" };
|
|
12116
12150
|
if (!req.identity || !IDENTITY_OPS.has(req.op)) return dispatchOne(entry, req);
|
|
@@ -12816,7 +12850,11 @@ var SYS_TREE = {
|
|
|
12816
12850
|
osrelease: `${OS_RELEASE}
|
|
12817
12851
|
`,
|
|
12818
12852
|
ostype: "Linux\n",
|
|
12819
|
-
slicc_wasm_memories: (listing) => `${listing.wasm?.live ?? 0} ${listing.wasm?.ceiling ?? 0}
|
|
12853
|
+
slicc_wasm_memories: (listing) => `${listing.wasm?.live ?? 0} ${listing.wasm?.ceiling ?? 0} ${listing.wasm?.source ?? "none"}
|
|
12854
|
+
`,
|
|
12855
|
+
slicc_shared_root: (listing) => `${listing.peers ?? 0}
|
|
12856
|
+
`,
|
|
12857
|
+
slicc_fs_calls: (listing) => `${listing.fsCalls ?? 0}
|
|
12820
12858
|
`
|
|
12821
12859
|
}
|
|
12822
12860
|
};
|
|
@@ -21863,37 +21901,65 @@ var SettlingChildren = class {
|
|
|
21863
21901
|
|
|
21864
21902
|
// src/kernel/wasm-memories.ts
|
|
21865
21903
|
var DEFAULT_CEILING = 112;
|
|
21904
|
+
var CEILING_FLOOR = 16;
|
|
21866
21905
|
var IDLE_MS = 1e4;
|
|
21867
21906
|
var MARGIN = 16;
|
|
21907
|
+
var DECAY_MS = 6e4;
|
|
21908
|
+
var DECAY_STEP = 8;
|
|
21868
21909
|
var WasmMemories = class {
|
|
21869
21910
|
live = 0;
|
|
21870
|
-
|
|
21911
|
+
learned;
|
|
21871
21912
|
waiters = /* @__PURE__ */ new Set();
|
|
21913
|
+
base;
|
|
21872
21914
|
idleMs;
|
|
21873
|
-
|
|
21874
|
-
|
|
21915
|
+
now;
|
|
21916
|
+
constructor(ceiling, idleMs = IDLE_MS, now = Date.now) {
|
|
21917
|
+
this.base = ceiling;
|
|
21875
21918
|
this.idleMs = idleMs;
|
|
21919
|
+
this.now = now;
|
|
21920
|
+
}
|
|
21921
|
+
ceiling() {
|
|
21922
|
+
const learned = this.learned;
|
|
21923
|
+
if (!learned) return this.base;
|
|
21924
|
+
const steps = Math.floor((this.now() - learned.at) / DECAY_MS);
|
|
21925
|
+
const raised = learned.ceiling + steps * DECAY_STEP;
|
|
21926
|
+
if (raised < (this.base ?? DEFAULT_CEILING)) return raised;
|
|
21927
|
+
this.learned = void 0;
|
|
21928
|
+
return this.base;
|
|
21876
21929
|
}
|
|
21877
21930
|
count() {
|
|
21878
|
-
|
|
21931
|
+
const ceiling = this.ceiling();
|
|
21932
|
+
const source = this.learned ? "learned" : ceiling === void 0 ? "none" : "default";
|
|
21933
|
+
return { live: this.live, ceiling: ceiling ?? 0, source };
|
|
21879
21934
|
}
|
|
21880
21935
|
ended() {
|
|
21881
21936
|
this.live = Math.max(0, this.live - 1);
|
|
21882
21937
|
this.progress();
|
|
21883
21938
|
}
|
|
21884
21939
|
learn() {
|
|
21885
|
-
|
|
21940
|
+
const top = this.base ?? DEFAULT_CEILING;
|
|
21941
|
+
this.learned = {
|
|
21942
|
+
ceiling: Math.min(top, Math.max(CEILING_FLOOR, this.live - 1)),
|
|
21943
|
+
at: this.now()
|
|
21944
|
+
};
|
|
21886
21945
|
}
|
|
21887
21946
|
near() {
|
|
21888
|
-
|
|
21947
|
+
const ceiling = this.ceiling();
|
|
21948
|
+
return ceiling !== void 0 && this.live + MARGIN >= ceiling;
|
|
21889
21949
|
}
|
|
21890
21950
|
async admit() {
|
|
21891
|
-
|
|
21951
|
+
for (let ceiling = this.ceiling(); ceiling !== void 0 && this.live >= ceiling; ) {
|
|
21892
21952
|
if (!await this.changed()) throw new SpawnError("EAGAIN");
|
|
21953
|
+
ceiling = this.ceiling();
|
|
21893
21954
|
}
|
|
21894
21955
|
this.live += 1;
|
|
21895
21956
|
this.progress();
|
|
21896
21957
|
}
|
|
21958
|
+
async refused() {
|
|
21959
|
+
const ceiling = this.ceiling();
|
|
21960
|
+
if (ceiling === void 0 || this.live >= ceiling) return;
|
|
21961
|
+
if (!await this.changed()) throw new SpawnError("EAGAIN");
|
|
21962
|
+
}
|
|
21897
21963
|
progress() {
|
|
21898
21964
|
const waiters = [...this.waiters];
|
|
21899
21965
|
this.waiters.clear();
|
|
@@ -23092,7 +23158,7 @@ async function openHostfs(spec, connect2, timing = {}) {
|
|
|
23092
23158
|
...active?.capabilities.ranges === true ? { ranges: true } : {},
|
|
23093
23159
|
...active ? { maxIo: Math.min(active.maxIo, HOSTFS_IO) } : {}
|
|
23094
23160
|
});
|
|
23095
|
-
const
|
|
23161
|
+
const served2 = serveFilesystem(
|
|
23096
23162
|
port2,
|
|
23097
23163
|
{ ...slot2.handlers, mount: ranged2 },
|
|
23098
23164
|
{
|
|
@@ -23109,12 +23175,12 @@ async function openHostfs(spec, connect2, timing = {}) {
|
|
|
23109
23175
|
up(client) {
|
|
23110
23176
|
active = timed(client, timing.callMs ?? HOSTFS_CALL_MS);
|
|
23111
23177
|
slot2.insert(client, handlers);
|
|
23112
|
-
|
|
23178
|
+
served2.invalidate(true);
|
|
23113
23179
|
},
|
|
23114
|
-
event: (event) =>
|
|
23180
|
+
event: (event) => served2.invalidate(invalidation(event)),
|
|
23115
23181
|
down() {
|
|
23116
23182
|
slot2.eject();
|
|
23117
|
-
|
|
23183
|
+
served2.invalidate(true);
|
|
23118
23184
|
},
|
|
23119
23185
|
...timing
|
|
23120
23186
|
},
|
|
@@ -25222,6 +25288,10 @@ var Launcher = class {
|
|
|
25222
25288
|
return handle;
|
|
25223
25289
|
}
|
|
25224
25290
|
await handle.exited;
|
|
25291
|
+
await this.memories.refused().catch(async (err) => {
|
|
25292
|
+
await fds.closeAll();
|
|
25293
|
+
throw err;
|
|
25294
|
+
});
|
|
25225
25295
|
}
|
|
25226
25296
|
}
|
|
25227
25297
|
start(req) {
|
|
@@ -25287,7 +25357,9 @@ var Launcher = class {
|
|
|
25287
25357
|
processes: this.list(this.credOf(pid)),
|
|
25288
25358
|
load: this.loadAverage(),
|
|
25289
25359
|
cpu: this.cpuTotal(),
|
|
25290
|
-
wasm: this.memories.count()
|
|
25360
|
+
wasm: this.memories.count(),
|
|
25361
|
+
peers: Number(this.locks.shared?.() === true),
|
|
25362
|
+
fsCalls: servedFsCalls()
|
|
25291
25363
|
}),
|
|
25292
25364
|
sudo: (call, signal) => this.sudo(pid, call, signal),
|
|
25293
25365
|
crontab: (call) => this.crontab(pid, call),
|
|
@@ -25781,7 +25853,7 @@ var Launcher = class {
|
|
|
25781
25853
|
const worker = this.createDriverWorker();
|
|
25782
25854
|
const driver = new MessageChannel();
|
|
25783
25855
|
const client = new MessageChannel();
|
|
25784
|
-
const
|
|
25856
|
+
const served2 = serveClient(client.port1, {
|
|
25785
25857
|
launcher: async () => this,
|
|
25786
25858
|
scope: "transport"
|
|
25787
25859
|
});
|
|
@@ -25793,7 +25865,7 @@ var Launcher = class {
|
|
|
25793
25865
|
port: driver.port1,
|
|
25794
25866
|
dispose: () => {
|
|
25795
25867
|
worker.terminate();
|
|
25796
|
-
|
|
25868
|
+
served2.detach();
|
|
25797
25869
|
driver.port1.close();
|
|
25798
25870
|
},
|
|
25799
25871
|
onCrash: (listener) => worker.addEventListener("error", (event) => {
|
|
@@ -25807,12 +25879,12 @@ var Launcher = class {
|
|
|
25807
25879
|
const ask = (handle) => this.onMountPending?.({ target, source, ...handle ? { handle } : {} });
|
|
25808
25880
|
const { port1, port2 } = new MessageChannel();
|
|
25809
25881
|
const medium = removableMedium((handle) => {
|
|
25810
|
-
|
|
25882
|
+
served2.invalidate(true);
|
|
25811
25883
|
ask(handle);
|
|
25812
25884
|
});
|
|
25813
|
-
const
|
|
25885
|
+
const served2 = serveFilesystem(port2, medium.handlers, FSA_CAPABILITIES);
|
|
25814
25886
|
const id2 = source.slice("fsa:".length);
|
|
25815
|
-
this.removable.set(target, { id: id2, medium, served });
|
|
25887
|
+
this.removable.set(target, { id: id2, medium, served: served2 });
|
|
25816
25888
|
const stored = this.inserted.get(id2) ?? await this.media.get(id2);
|
|
25817
25889
|
if (stored && await granted(stored)) medium.insert(stored);
|
|
25818
25890
|
else ask(stored);
|
|
@@ -27871,14 +27943,14 @@ async function createNodeKernel(options = {}) {
|
|
|
27871
27943
|
throw fsError("ENOENT", `no user ${String(user)}`);
|
|
27872
27944
|
}
|
|
27873
27945
|
const { port1, port2 } = new MessageChannel2();
|
|
27874
|
-
const
|
|
27946
|
+
const served2 = serveClient(port1, {
|
|
27875
27947
|
launcher: async () => launcher,
|
|
27876
27948
|
signal: signalNumber,
|
|
27877
27949
|
...user !== void 0 ? { user } : {},
|
|
27878
27950
|
...tag !== void 0 ? { tag } : {}
|
|
27879
27951
|
});
|
|
27880
|
-
clients.add(
|
|
27881
|
-
void
|
|
27952
|
+
clients.add(served2);
|
|
27953
|
+
void served2.closed.then(() => clients.delete(served2));
|
|
27882
27954
|
return port2;
|
|
27883
27955
|
},
|
|
27884
27956
|
terminate() {
|