@ai-ecoverse/slicc-kernel 1.138.1 → 1.139.1
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 +2 -1
- package/dist/kernel-worker.js +1 -1
- package/dist/node-driver-worker.js +11 -0
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.js +61 -17
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +1 -1
- package/dist/process-worker.js +14 -2
- package/dist/process-worker.js.map +3 -3
- package/dist/types/process/js/js-context.d.ts +9 -0
- package/package.json +3 -3
|
@@ -4144,10 +4144,10 @@ var init_wasi_sigmask = __esm({
|
|
|
4144
4144
|
deliver;
|
|
4145
4145
|
process;
|
|
4146
4146
|
tid;
|
|
4147
|
-
constructor(header, deliver,
|
|
4147
|
+
constructor(header, deliver, process2, tid = 1) {
|
|
4148
4148
|
this.header = header;
|
|
4149
4149
|
this.deliver = deliver;
|
|
4150
|
-
this.process =
|
|
4150
|
+
this.process = process2;
|
|
4151
4151
|
this.tid = tid;
|
|
4152
4152
|
this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
|
|
4153
4153
|
this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
|
|
@@ -6710,7 +6710,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
6710
6710
|
var init_version = __esm({
|
|
6711
6711
|
"src/version.ts"() {
|
|
6712
6712
|
"use strict";
|
|
6713
|
-
KERNEL_VERSION = true ? "1.
|
|
6713
|
+
KERNEL_VERSION = true ? "1.139.1" : "0.0.0-dev";
|
|
6714
6714
|
OS_RELEASE = "6.0.0-slicc";
|
|
6715
6715
|
}
|
|
6716
6716
|
});
|
|
@@ -7512,7 +7512,7 @@ var init_js_fetch = __esm({
|
|
|
7512
7512
|
});
|
|
7513
7513
|
|
|
7514
7514
|
// src/process/js/js-net.ts
|
|
7515
|
-
function
|
|
7515
|
+
function fromBase642(text) {
|
|
7516
7516
|
const bin = atob(text);
|
|
7517
7517
|
const out = new Uint8Array(bin.length);
|
|
7518
7518
|
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
|
@@ -7595,7 +7595,7 @@ function sessionOf(r) {
|
|
|
7595
7595
|
authorized: r.authorized === true,
|
|
7596
7596
|
...r.authorizationError ? { authorizationError: r.authorizationError } : {},
|
|
7597
7597
|
servername: r.servername,
|
|
7598
|
-
peerCertificates: Object.freeze((r.peerCertificates ?? []).map(
|
|
7598
|
+
peerCertificates: Object.freeze((r.peerCertificates ?? []).map(fromBase642)),
|
|
7599
7599
|
...controlsOf(r)
|
|
7600
7600
|
});
|
|
7601
7601
|
}
|
|
@@ -15168,6 +15168,15 @@ function heldOn(init, lane, syncKernel) {
|
|
|
15168
15168
|
const ask = () => syncKernel.json({ op: "cwd-check" });
|
|
15169
15169
|
return new HeldCwd(init.sab, init.slot, ask, init);
|
|
15170
15170
|
}
|
|
15171
|
+
function measured(measure) {
|
|
15172
|
+
const got = measure?.() ?? {};
|
|
15173
|
+
const out = {};
|
|
15174
|
+
for (const field2 of MEMORY_FIELDS) {
|
|
15175
|
+
const value2 = got[field2];
|
|
15176
|
+
if (typeof value2 === "number" && Number.isFinite(value2)) out[field2] = value2;
|
|
15177
|
+
}
|
|
15178
|
+
return out;
|
|
15179
|
+
}
|
|
15171
15180
|
function createContext(o) {
|
|
15172
15181
|
const { kernel } = o;
|
|
15173
15182
|
const infos = /* @__PURE__ */ new Map();
|
|
@@ -15308,6 +15317,7 @@ function createContext(o) {
|
|
|
15308
15317
|
tty: terminal.tty,
|
|
15309
15318
|
exit,
|
|
15310
15319
|
thread: o.thread,
|
|
15320
|
+
memory: () => measured(o.memory),
|
|
15311
15321
|
onUncaught: (listener) => listen(strays.exception, listener),
|
|
15312
15322
|
onUnhandledRejection: (listener) => listen(strays.rejection, listener)
|
|
15313
15323
|
};
|
|
@@ -15505,7 +15515,7 @@ function pathOps(kernel, resolve, statOf, open, tryDev) {
|
|
|
15505
15515
|
}
|
|
15506
15516
|
};
|
|
15507
15517
|
}
|
|
15508
|
-
var KERNEL_INFO, JsExit, encoder4, cryptoRandom;
|
|
15518
|
+
var KERNEL_INFO, JsExit, encoder4, cryptoRandom, MEMORY_FIELDS;
|
|
15509
15519
|
var init_js_context = __esm({
|
|
15510
15520
|
"src/process/js/js-context.ts"() {
|
|
15511
15521
|
"use strict";
|
|
@@ -15540,6 +15550,7 @@ var init_js_context = __esm({
|
|
|
15540
15550
|
};
|
|
15541
15551
|
encoder4 = new TextEncoder();
|
|
15542
15552
|
cryptoRandom = (bytes) => void crypto.getRandomValues(bytes);
|
|
15553
|
+
MEMORY_FIELDS = ["heapUsed", "heapTotal", "heapLimit", "external", "arrayBuffers"];
|
|
15543
15554
|
}
|
|
15544
15555
|
});
|
|
15545
15556
|
|
|
@@ -15713,6 +15724,7 @@ async function runJs(init, port3, deps, thread) {
|
|
|
15713
15724
|
fs: { owners: init.owners === true, links: init.links === true },
|
|
15714
15725
|
strays,
|
|
15715
15726
|
thread: threadContext(port3, thread),
|
|
15727
|
+
memory: deps.memory,
|
|
15716
15728
|
...thread?.owned ? { owned: thread.owned } : {},
|
|
15717
15729
|
held: init.held,
|
|
15718
15730
|
failed: () => failedWith
|
|
@@ -17433,9 +17445,9 @@ var init_wasix_host = __esm({
|
|
|
17433
17445
|
};
|
|
17434
17446
|
}
|
|
17435
17447
|
processImports() {
|
|
17436
|
-
const { mem, process } = this;
|
|
17448
|
+
const { mem, process: process2 } = this;
|
|
17437
17449
|
return {
|
|
17438
|
-
proc_fork: (_copy, pidPtr) =>
|
|
17450
|
+
proc_fork: (_copy, pidPtr) => process2.fork(pidPtr),
|
|
17439
17451
|
stack_checkpoint: (snapPtr, retPtr) => {
|
|
17440
17452
|
const back = this.driver.rewound();
|
|
17441
17453
|
if (back === void 0) return this.driver.checkpoint(snapPtr, retPtr);
|
|
@@ -17443,7 +17455,7 @@ var init_wasix_host = __esm({
|
|
|
17443
17455
|
return E.SUCCESS;
|
|
17444
17456
|
},
|
|
17445
17457
|
stack_restore: (snapPtr, val) => void this.driver.restore(snapPtr, val),
|
|
17446
|
-
proc_join: (pidPtr, flags, statusPtr) => void
|
|
17458
|
+
proc_join: (pidPtr, flags, statusPtr) => void process2.join(pidPtr, flags, statusPtr),
|
|
17447
17459
|
proc_signal: (pid, sig) => {
|
|
17448
17460
|
const posix = sig === 0 ? 0 : wasixSignal(sig);
|
|
17449
17461
|
if (posix === void 0) throw new WasiError("EINVAL");
|
|
@@ -17452,14 +17464,14 @@ var init_wasix_host = __esm({
|
|
|
17452
17464
|
},
|
|
17453
17465
|
proc_exec: (n, nl, a, al) => this.execOrExit(n, nl, a, al, 0, 0),
|
|
17454
17466
|
proc_exec2: (n, nl, a, al, e, el) => this.execOrExit(n, nl, a, al, e, el),
|
|
17455
|
-
proc_exec3: (n, nl, a, al, e, el, search, p, pl) =>
|
|
17467
|
+
proc_exec3: (n, nl, a, al, e, el, search, p, pl) => process2.exec({
|
|
17456
17468
|
name: this.str(n, nl),
|
|
17457
17469
|
argv: _WasixHost.lines(this.str(a, al)),
|
|
17458
17470
|
env: _WasixHost.env(_WasixHost.lines(this.str(e, el))),
|
|
17459
17471
|
search: search !== 0,
|
|
17460
17472
|
path: this.str(p, pl)
|
|
17461
17473
|
}),
|
|
17462
|
-
proc_exec4: (n, nl, a, ac, e, ec, search, p, pl) =>
|
|
17474
|
+
proc_exec4: (n, nl, a, ac, e, ec, search, p, pl) => process2.exec({
|
|
17463
17475
|
name: this.str(n, nl),
|
|
17464
17476
|
argv: this.cStrings(a, ac),
|
|
17465
17477
|
env: _WasixHost.env(e === 0 ? void 0 : this.cStrings(e, ec)),
|
|
@@ -17468,7 +17480,7 @@ var init_wasix_host = __esm({
|
|
|
17468
17480
|
}),
|
|
17469
17481
|
proc_spawn2: (...args) => {
|
|
17470
17482
|
const [n, nl, a, al, e, el, ops, opc, , , search, p, pl, out] = args;
|
|
17471
|
-
const pid =
|
|
17483
|
+
const pid = process2.spawn({
|
|
17472
17484
|
name: this.str(n, nl),
|
|
17473
17485
|
argv: _WasixHost.lines(this.str(a, al)),
|
|
17474
17486
|
env: _WasixHost.env(_WasixHost.lines(this.str(e, el))),
|
|
@@ -17480,7 +17492,7 @@ var init_wasix_host = __esm({
|
|
|
17480
17492
|
},
|
|
17481
17493
|
proc_spawn3: (...args) => {
|
|
17482
17494
|
const [n, nl, a, ac, e, ec, ops, opc, , , search, p, pl, out] = args;
|
|
17483
|
-
const pid =
|
|
17495
|
+
const pid = process2.spawn({
|
|
17484
17496
|
name: this.str(n, nl),
|
|
17485
17497
|
argv: this.cStrings(a, ac),
|
|
17486
17498
|
env: _WasixHost.env(e === 0 ? void 0 : this.cStrings(e, ec)),
|
|
@@ -17747,14 +17759,14 @@ function delivering(ns, table, host, driver, before) {
|
|
|
17747
17759
|
}
|
|
17748
17760
|
return out;
|
|
17749
17761
|
}
|
|
17750
|
-
function sigmaskOf(module, sab, gate, threads,
|
|
17762
|
+
function sigmaskOf(module, sab, gate, threads, process2) {
|
|
17751
17763
|
const header = new Int32Array(sab, 0, SAB_HEADER_I32);
|
|
17752
17764
|
if (!importsSlicc(module, "sigmask_set")) {
|
|
17753
17765
|
WasiSigmask.unsupported(header);
|
|
17754
17766
|
return void 0;
|
|
17755
17767
|
}
|
|
17756
17768
|
if (threads) threads.blocked = () => loadBlocked(header);
|
|
17757
|
-
const shared =
|
|
17769
|
+
const shared = process2 && new Int32Array(process2, 0, SAB_HEADER_I32);
|
|
17758
17770
|
return new WasiSigmask(header, () => gate.deliver(), shared, threads?.tid ?? MAIN_TID);
|
|
17759
17771
|
}
|
|
17760
17772
|
function enosys(module, name2, foreign) {
|
|
@@ -18437,6 +18449,7 @@ import { parentPort } from "node:worker_threads";
|
|
|
18437
18449
|
// src/node-lockdown.ts
|
|
18438
18450
|
init_lockdown();
|
|
18439
18451
|
import { isBuiltin, registerHooks } from "node:module";
|
|
18452
|
+
import { getHeapStatistics } from "node:v8";
|
|
18440
18453
|
var NODE_GLOBALS = ["localStorage", "sessionStorage"];
|
|
18441
18454
|
var NODE_SLOTS = [
|
|
18442
18455
|
"require",
|
|
@@ -18463,6 +18476,10 @@ function refused(specifier) {
|
|
|
18463
18476
|
code: "ERR_ACCESS_DENIED"
|
|
18464
18477
|
});
|
|
18465
18478
|
}
|
|
18479
|
+
var BASE64_MODULE = "data:text/javascript;base64,";
|
|
18480
|
+
var fromBase64 = Buffer.from.bind(Buffer);
|
|
18481
|
+
var toText = Function.prototype.call.bind(Buffer.prototype.toString);
|
|
18482
|
+
var PLAIN_BASE64 = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
18466
18483
|
function refuseModules() {
|
|
18467
18484
|
registerHooks({
|
|
18468
18485
|
resolve(specifier, context, next2) {
|
|
@@ -18470,11 +18487,30 @@ function refuseModules() {
|
|
|
18470
18487
|
const resolved2 = next2(specifier, context);
|
|
18471
18488
|
if (!resolved2.url.startsWith("data:")) throw refused(resolved2.url);
|
|
18472
18489
|
return resolved2;
|
|
18490
|
+
},
|
|
18491
|
+
load(url, context, next2) {
|
|
18492
|
+
const payload = url.startsWith(BASE64_MODULE) ? url.slice(BASE64_MODULE.length) : "";
|
|
18493
|
+
if (payload.length % 4 !== 0 || !PLAIN_BASE64.test(payload)) return next2(url, context);
|
|
18494
|
+
const source = toText(fromBase64(payload, "base64"), "utf8");
|
|
18495
|
+
return { format: "module", source, shortCircuit: true };
|
|
18473
18496
|
}
|
|
18474
18497
|
});
|
|
18475
18498
|
}
|
|
18476
18499
|
var locked = /* @__PURE__ */ new WeakSet();
|
|
18477
18500
|
var nodeProcess = typeof globalThis.process === "object" && globalThis.process !== null ? globalThis.process : void 0;
|
|
18501
|
+
var heapStatistics = getHeapStatistics;
|
|
18502
|
+
var memoryUsage = process.memoryUsage.bind(process);
|
|
18503
|
+
function nodeMemory() {
|
|
18504
|
+
const heap = heapStatistics();
|
|
18505
|
+
const usage = memoryUsage();
|
|
18506
|
+
return {
|
|
18507
|
+
heapUsed: heap.used_heap_size,
|
|
18508
|
+
heapTotal: heap.total_heap_size,
|
|
18509
|
+
heapLimit: heap.heap_size_limit,
|
|
18510
|
+
external: heap.external_memory,
|
|
18511
|
+
arrayBuffers: usage.arrayBuffers
|
|
18512
|
+
};
|
|
18513
|
+
}
|
|
18478
18514
|
function nodeLockdown(scope2 = globalThis) {
|
|
18479
18515
|
if (locked.has(scope2)) return;
|
|
18480
18516
|
locked.add(scope2);
|
|
@@ -18592,8 +18628,16 @@ var onMessage = processEntry(
|
|
|
18592
18628
|
},
|
|
18593
18629
|
async () => wasi_runtime_exports,
|
|
18594
18630
|
async () => ({
|
|
18595
|
-
runJsProcess: (init, at) => runJsProcess(init, at, {
|
|
18596
|
-
|
|
18631
|
+
runJsProcess: (init, at) => runJsProcess(init, at, {
|
|
18632
|
+
lockdown: () => nodeLockdown(),
|
|
18633
|
+
scope: strayScope,
|
|
18634
|
+
memory: nodeMemory
|
|
18635
|
+
}),
|
|
18636
|
+
runJsThread: (init, at) => runJsThread(init, at, {
|
|
18637
|
+
lockdown: () => nodeLockdown(),
|
|
18638
|
+
scope: strayScope,
|
|
18639
|
+
memory: nodeMemory
|
|
18640
|
+
})
|
|
18597
18641
|
}),
|
|
18598
18642
|
() => nodeLockdown()
|
|
18599
18643
|
);
|