@ai-ecoverse/slicc-kernel 1.189.0 → 1.189.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/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +150 -37
- package/dist/cloudflare.js.map +3 -3
- package/dist/kernel-worker.js +48 -11
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +52 -12
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/types/cloudflare/images.d.ts +17 -5
- package/dist/types/cloudflare/sqlite-store.d.ts +2 -0
- package/dist/types/launcher.d.ts +8 -1
- package/package.json +1 -1
package/dist/cloudflare.js
CHANGED
|
@@ -684,7 +684,10 @@ function remoteWorker(open, options = {}) {
|
|
|
684
684
|
opened2 = await open(wire);
|
|
685
685
|
} catch (err) {
|
|
686
686
|
kernel.end();
|
|
687
|
-
|
|
687
|
+
const status = err?.exitStatus;
|
|
688
|
+
const message3 = err instanceof Error ? err.message : String(err);
|
|
689
|
+
if (typeof status === "number") refuse2(message3, status);
|
|
690
|
+
else queueMicrotask(() => fail4(message3));
|
|
688
691
|
return;
|
|
689
692
|
}
|
|
690
693
|
if (ended) {
|
|
@@ -4818,7 +4821,7 @@ function satisfies(version, range2) {
|
|
|
4818
4821
|
}
|
|
4819
4822
|
|
|
4820
4823
|
// src/version.ts
|
|
4821
|
-
var KERNEL_VERSION = true ? "1.189.
|
|
4824
|
+
var KERNEL_VERSION = true ? "1.189.1" : "0.0.0-dev";
|
|
4822
4825
|
var OS_RELEASE = "6.0.0-slicc";
|
|
4823
4826
|
function procVersion() {
|
|
4824
4827
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -12017,6 +12020,35 @@ function statOf2(attr2, path, mount) {
|
|
|
12017
12020
|
} : {}
|
|
12018
12021
|
};
|
|
12019
12022
|
}
|
|
12023
|
+
var Gathered = class {
|
|
12024
|
+
bytes = new Uint8Array(0);
|
|
12025
|
+
owned = false;
|
|
12026
|
+
size;
|
|
12027
|
+
length = 0;
|
|
12028
|
+
constructor(size) {
|
|
12029
|
+
this.size = size;
|
|
12030
|
+
}
|
|
12031
|
+
add(chunk2) {
|
|
12032
|
+
const need2 = this.length + chunk2.length;
|
|
12033
|
+
if (this.length === 0) {
|
|
12034
|
+
this.bytes = chunk2;
|
|
12035
|
+
} else {
|
|
12036
|
+
if (!this.owned || this.bytes.length < need2) {
|
|
12037
|
+
const grown = new Uint8Array(
|
|
12038
|
+
Math.max(this.size, need2, this.owned ? this.bytes.length * 2 : 0)
|
|
12039
|
+
);
|
|
12040
|
+
grown.set(this.bytes.subarray(0, this.length));
|
|
12041
|
+
this.bytes = grown;
|
|
12042
|
+
this.owned = true;
|
|
12043
|
+
}
|
|
12044
|
+
this.bytes.set(chunk2, this.length);
|
|
12045
|
+
}
|
|
12046
|
+
this.length = need2;
|
|
12047
|
+
}
|
|
12048
|
+
get whole() {
|
|
12049
|
+
return this.length === this.bytes.length ? this.bytes : this.bytes.subarray(0, this.length);
|
|
12050
|
+
}
|
|
12051
|
+
};
|
|
12020
12052
|
function concat4(chunks2, total) {
|
|
12021
12053
|
if (chunks2.length === 1 && chunks2[0]?.length === total) return chunks2[0];
|
|
12022
12054
|
const out = new Uint8Array(total);
|
|
@@ -12509,25 +12541,23 @@ var MountFs = class _MountFs {
|
|
|
12509
12541
|
}
|
|
12510
12542
|
const fh = await this.open(mount, rel2, false);
|
|
12511
12543
|
const chunk2 = mount.caps.maxIo ?? DEFAULT_IO;
|
|
12512
|
-
const
|
|
12513
|
-
let total = 0;
|
|
12544
|
+
const out = new Gathered(attr2.size);
|
|
12514
12545
|
try {
|
|
12515
12546
|
for (; ; ) {
|
|
12516
12547
|
const bytes = await mount.conn.call({
|
|
12517
12548
|
op: "read",
|
|
12518
12549
|
fh,
|
|
12519
|
-
offset:
|
|
12550
|
+
offset: out.length,
|
|
12520
12551
|
size: chunk2
|
|
12521
12552
|
});
|
|
12522
12553
|
if (bytes.length === 0) break;
|
|
12523
|
-
|
|
12524
|
-
|
|
12525
|
-
if (bytes.length < chunk2 && total >= attr2.size) break;
|
|
12554
|
+
out.add(bytes);
|
|
12555
|
+
if (bytes.length < chunk2 && out.length >= attr2.size) break;
|
|
12526
12556
|
}
|
|
12527
12557
|
} finally {
|
|
12528
12558
|
await mount.conn.call({ op: "release", fh });
|
|
12529
12559
|
}
|
|
12530
|
-
return
|
|
12560
|
+
return out.whole;
|
|
12531
12561
|
}
|
|
12532
12562
|
async writeFile(path, content, owner, redirects = 0) {
|
|
12533
12563
|
const real2 = await this.follow(path, 0, true);
|
|
@@ -35884,7 +35914,7 @@ var Launcher = class {
|
|
|
35884
35914
|
const foreign = foreignImports(bytes);
|
|
35885
35915
|
const libc = libcVersionOf(bytes);
|
|
35886
35916
|
const named = customSectionsOf(bytes, "name").length > 0;
|
|
35887
|
-
const compiled = this.compile ? await this.compile(bytes, key) : await WebAssembly.compile(bytes);
|
|
35917
|
+
const compiled = this.compile ? await this.compile(bytes, key, this.sourceOf(path)) : await WebAssembly.compile(bytes);
|
|
35888
35918
|
if (libc !== void 0) this.libcs.set(compiled, libc);
|
|
35889
35919
|
return {
|
|
35890
35920
|
value: { module: compiled, ...memory ? { memory } : {}, foreign, named },
|
|
@@ -35996,10 +36026,20 @@ var Launcher = class {
|
|
|
35996
36026
|
);
|
|
35997
36027
|
}
|
|
35998
36028
|
reread(target, read) {
|
|
36029
|
+
this.forgetCompiled(target.wasm);
|
|
36030
|
+
return read();
|
|
36031
|
+
}
|
|
36032
|
+
forgetCompiled(path) {
|
|
35999
36033
|
for (const key of this.compiled.keys()) {
|
|
36000
|
-
if (key.startsWith(`${
|
|
36034
|
+
if (key.startsWith(`${path}:`) || key.startsWith(`${path}\0`)) this.compiled.delete(key);
|
|
36001
36035
|
}
|
|
36002
|
-
|
|
36036
|
+
}
|
|
36037
|
+
sourceOf(path) {
|
|
36038
|
+
return {
|
|
36039
|
+
path,
|
|
36040
|
+
read: () => this.base.readFileBuffer(path),
|
|
36041
|
+
stale: () => this.forgetCompiled(path)
|
|
36042
|
+
};
|
|
36003
36043
|
}
|
|
36004
36044
|
exeId(target) {
|
|
36005
36045
|
if (target.abi !== "wasi" || (target.copy ?? target.glue) !== target.wasm) {
|
|
@@ -39037,38 +39077,94 @@ function initialMemory(bytes) {
|
|
|
39037
39077
|
}
|
|
39038
39078
|
return 0;
|
|
39039
39079
|
}
|
|
39080
|
+
var viewOf = (source) => source instanceof ArrayBuffer ? new Uint8Array(source) : new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
39081
|
+
var bufferOf2 = (bytes) => bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength && bytes.buffer instanceof ArrayBuffer ? bytes.buffer : bytes.slice().buffer;
|
|
39082
|
+
var ImageError = class extends Error {
|
|
39083
|
+
code;
|
|
39084
|
+
exitStatus;
|
|
39085
|
+
constructor(code, message3) {
|
|
39086
|
+
super(`${code}: ${message3}`);
|
|
39087
|
+
this.code = code;
|
|
39088
|
+
this.exitStatus = code === "ENOENT" ? 127 : 126;
|
|
39089
|
+
}
|
|
39090
|
+
};
|
|
39091
|
+
function unread(path, err) {
|
|
39092
|
+
const code = err?.code;
|
|
39093
|
+
if (code === "ENOENT" || code === "ENOTDIR") {
|
|
39094
|
+
return new ImageError("ENOENT", `${path} is gone since the kernel compiled it`);
|
|
39095
|
+
}
|
|
39096
|
+
const why = err instanceof Error ? err.message : String(err);
|
|
39097
|
+
return new ImageError(typeof code === "string" ? code : "EIO", `${path} cannot be read: ${why}`);
|
|
39098
|
+
}
|
|
39040
39099
|
var Images = class {
|
|
39041
|
-
|
|
39042
|
-
|
|
39043
|
-
|
|
39044
|
-
|
|
39045
|
-
const view2 = source instanceof ArrayBuffer ? new Uint8Array(source) : new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
39100
|
+
images = /* @__PURE__ */ new Map();
|
|
39101
|
+
reading = /* @__PURE__ */ new Map();
|
|
39102
|
+
async register(source, from) {
|
|
39103
|
+
const view2 = viewOf(source);
|
|
39046
39104
|
const image = await digest(view2);
|
|
39047
|
-
const known = this.
|
|
39048
|
-
if (known)
|
|
39105
|
+
const known = this.images.get(image);
|
|
39106
|
+
if (known) {
|
|
39107
|
+
if (from) known.sources.set(from.path, from);
|
|
39108
|
+
else known.bytes ??= view2.slice().buffer;
|
|
39109
|
+
return known.handle;
|
|
39110
|
+
}
|
|
39049
39111
|
const handle = Object.freeze({ image });
|
|
39050
|
-
this.
|
|
39051
|
-
|
|
39052
|
-
|
|
39112
|
+
this.images.set(image, {
|
|
39113
|
+
handle,
|
|
39114
|
+
initial: initialMemory(view2),
|
|
39115
|
+
module: view2.byteLength,
|
|
39116
|
+
sources: new Map(from ? [[from.path, from]] : []),
|
|
39117
|
+
...from ? {} : { bytes: view2.slice().buffer }
|
|
39118
|
+
});
|
|
39053
39119
|
return handle;
|
|
39054
39120
|
}
|
|
39055
|
-
compile = async (bytes) => await this.register(bytes);
|
|
39121
|
+
compile = async (bytes, _key, from) => await this.register(bytes, from);
|
|
39122
|
+
load(image) {
|
|
39123
|
+
const entry = this.images.get(image);
|
|
39124
|
+
if (!entry) return Promise.reject(new ImageError("ENOENT", `no program image ${image}`));
|
|
39125
|
+
if (entry.bytes) return Promise.resolve(entry.bytes);
|
|
39126
|
+
const known = this.reading.get(image);
|
|
39127
|
+
if (known !== void 0) return known;
|
|
39128
|
+
const read = this.read(image, entry).finally(() => this.reading.delete(image));
|
|
39129
|
+
this.reading.set(image, read);
|
|
39130
|
+
return read;
|
|
39131
|
+
}
|
|
39132
|
+
async read(image, entry) {
|
|
39133
|
+
let failed4;
|
|
39134
|
+
for (const source of [...entry.sources.values()]) {
|
|
39135
|
+
try {
|
|
39136
|
+
const bytes = await source.read();
|
|
39137
|
+
if (bytes.byteLength === entry.module && await digest(bytes) === image) {
|
|
39138
|
+
return bufferOf2(bytes);
|
|
39139
|
+
}
|
|
39140
|
+
failed4 ??= new ImageError("ESTALE", `${source.path} changed since the kernel compiled it`);
|
|
39141
|
+
} catch (err) {
|
|
39142
|
+
failed4 ??= unread(source.path, err);
|
|
39143
|
+
}
|
|
39144
|
+
entry.sources.delete(source.path);
|
|
39145
|
+
source.stale?.();
|
|
39146
|
+
}
|
|
39147
|
+
throw failed4 ?? new ImageError("ENOENT", `no file holds program image ${image}`);
|
|
39148
|
+
}
|
|
39056
39149
|
get(image) {
|
|
39057
|
-
const bytes = this.
|
|
39058
|
-
if (!bytes) throw new Error(`no program image ${image}`);
|
|
39150
|
+
const bytes = this.images.get(image)?.bytes;
|
|
39151
|
+
if (!bytes) throw new Error(`no program image ${image} kept in memory: load() reads it`);
|
|
39059
39152
|
return bytes;
|
|
39060
39153
|
}
|
|
39061
39154
|
sizeOf(image) {
|
|
39062
|
-
|
|
39063
|
-
|
|
39064
|
-
module: this.bytes.get(image)?.byteLength ?? 0
|
|
39065
|
-
};
|
|
39155
|
+
const entry = this.images.get(image);
|
|
39156
|
+
return { initial: entry?.initial ?? 0, module: entry?.module ?? 0 };
|
|
39066
39157
|
}
|
|
39067
39158
|
has(image) {
|
|
39068
|
-
return this.
|
|
39159
|
+
return this.images.has(image);
|
|
39069
39160
|
}
|
|
39070
39161
|
get size() {
|
|
39071
|
-
return this.
|
|
39162
|
+
return this.images.size;
|
|
39163
|
+
}
|
|
39164
|
+
get held() {
|
|
39165
|
+
let total = 0;
|
|
39166
|
+
for (const entry of this.images.values()) total += entry.bytes?.byteLength ?? 0;
|
|
39167
|
+
return total;
|
|
39072
39168
|
}
|
|
39073
39169
|
};
|
|
39074
39170
|
function imageOf(module) {
|
|
@@ -39829,12 +39925,16 @@ function parentOf11(init) {
|
|
|
39829
39925
|
function cloudflareProcesses(loader, images, gate, code, memory = {}) {
|
|
39830
39926
|
let hostDigest;
|
|
39831
39927
|
let loads = 0;
|
|
39928
|
+
const failedLoads = /* @__PURE__ */ new Map();
|
|
39832
39929
|
const idOf3 = async (ref) => {
|
|
39833
39930
|
hostDigest ??= digest(`${code.host}\0${code.process}\0${code.localForks !== false}`);
|
|
39834
39931
|
const imports = ref.imports ? `-${ref.imports.digest.slice(0, 16)}` : "";
|
|
39835
|
-
|
|
39932
|
+
const failed4 = failedLoads.get(keyOf3(ref));
|
|
39933
|
+
const again = failed4 === void 0 ? "" : `-r${failed4}`;
|
|
39934
|
+
return `slicc-${(await hostDigest).slice(0, 16)}-${ref.image.slice(0, 40)}${imports}${again}`;
|
|
39836
39935
|
};
|
|
39837
|
-
const workerCode = (ref) => {
|
|
39936
|
+
const workerCode = async (ref) => {
|
|
39937
|
+
const wasm = await images.load(ref.image);
|
|
39838
39938
|
loads++;
|
|
39839
39939
|
const env = {
|
|
39840
39940
|
...code.localForks === false ? { SLICC_LOCAL_FORKS: "off" } : {},
|
|
@@ -39847,7 +39947,7 @@ function cloudflareProcesses(loader, images, gate, code, memory = {}) {
|
|
|
39847
39947
|
modules: {
|
|
39848
39948
|
"host.js": code.host,
|
|
39849
39949
|
"process.js": code.process,
|
|
39850
|
-
"program.wasm": { wasm
|
|
39950
|
+
"program.wasm": { wasm },
|
|
39851
39951
|
"imports.js": ref.imports?.source ?? NO_IMPORTS_MODULE
|
|
39852
39952
|
},
|
|
39853
39953
|
globalOutbound: null,
|
|
@@ -39932,8 +40032,13 @@ function cloudflareProcesses(loader, images, gate, code, memory = {}) {
|
|
|
39932
40032
|
if (pid !== void 0 && seated.get(pid) === seat) seated.delete(pid);
|
|
39933
40033
|
seat.release();
|
|
39934
40034
|
};
|
|
40035
|
+
const cold = {};
|
|
40036
|
+
const code2 = () => workerCode(ref).catch((err) => {
|
|
40037
|
+
cold.failed = err;
|
|
40038
|
+
throw err;
|
|
40039
|
+
});
|
|
39935
40040
|
try {
|
|
39936
|
-
const host = loader.get(seat.id,
|
|
40041
|
+
const host = loader.get(seat.id, code2).getEntrypoint();
|
|
39937
40042
|
return await openLink(host, release, {
|
|
39938
40043
|
forks,
|
|
39939
40044
|
sized: (bytes) => seat.memory(bytes),
|
|
@@ -39942,7 +40047,11 @@ function cloudflareProcesses(loader, images, gate, code, memory = {}) {
|
|
|
39942
40047
|
});
|
|
39943
40048
|
} catch (err) {
|
|
39944
40049
|
release();
|
|
39945
|
-
|
|
40050
|
+
const failed4 = cold.failed ?? err;
|
|
40051
|
+
if (failed4 instanceof ImageError) {
|
|
40052
|
+
failedLoads.set(keyOf3(ref), (failedLoads.get(keyOf3(ref)) ?? 0) + 1);
|
|
40053
|
+
}
|
|
40054
|
+
throw failed4;
|
|
39946
40055
|
}
|
|
39947
40056
|
}
|
|
39948
40057
|
};
|
|
@@ -40093,6 +40202,10 @@ var SqlStore = class {
|
|
|
40093
40202
|
rows(query, ...bindings) {
|
|
40094
40203
|
return this.sql.exec(query, ...bindings).toArray();
|
|
40095
40204
|
}
|
|
40205
|
+
each(query, ...bindings) {
|
|
40206
|
+
const cursor = this.sql.exec(query, ...bindings);
|
|
40207
|
+
return cursor[Symbol.iterator] ? cursor : cursor.toArray();
|
|
40208
|
+
}
|
|
40096
40209
|
row(query, ...bindings) {
|
|
40097
40210
|
return this.rows(query, ...bindings)[0];
|
|
40098
40211
|
}
|
|
@@ -40524,7 +40637,7 @@ var Files = class {
|
|
|
40524
40637
|
const first = Math.floor(start2 / CHUNK_BYTES);
|
|
40525
40638
|
const last = Math.floor((end - 1) / CHUNK_BYTES);
|
|
40526
40639
|
const state = this.chunks.get(node);
|
|
40527
|
-
const rows = this.store.
|
|
40640
|
+
const rows = this.store.each(
|
|
40528
40641
|
`SELECT idx, substr(data, max(? - idx * ${CHUNK_BYTES}, 0) + 1, min(? - idx * ${CHUNK_BYTES}, ${CHUNK_BYTES}) - max(? - idx * ${CHUNK_BYTES}, 0)) AS part FROM slicc_chunks WHERE node = ? AND idx BETWEEN ? AND ?`,
|
|
40529
40642
|
start2,
|
|
40530
40643
|
end,
|