@ai-ecoverse/slicc-kernel 1.154.2 → 1.155.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 +2 -2
- package/dist/driver-worker.js +5 -2
- package/dist/driver-worker.js.map +2 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +69 -7
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-driver-worker.js +5 -2
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.js +9 -2
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +74 -9
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +9 -2
- package/dist/process-worker.js.map +2 -2
- package/dist/types/embedder-relay.d.ts +3 -0
- package/dist/types/kernel/socket-syscalls.d.ts +3 -0
- package/dist/types/kernel/socket.d.ts +6 -0
- package/dist/types/process/js/js-net.d.ts +1 -0
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -186,6 +186,7 @@ function embedderAsker(port) {
|
|
|
186
186
|
void asked.body.cancel(message3.error.message).catch(() => void 0);
|
|
187
187
|
push(asked, message3.error);
|
|
188
188
|
} else if ("progress" in message3) asked.progress(message3.progress);
|
|
189
|
+
else if ("bodyCancel" in message3) void asked.body.cancel("the page").catch(() => void 0);
|
|
189
190
|
else void sendBody(message3.id, asked);
|
|
190
191
|
};
|
|
191
192
|
return { hookFor, answer: answer2 };
|
|
@@ -213,7 +214,8 @@ function bodyStream(id2, state, post) {
|
|
|
213
214
|
const next3 = state.body.shift();
|
|
214
215
|
if (next3) controller.enqueue(next3);
|
|
215
216
|
else controller.close();
|
|
216
|
-
}
|
|
217
|
+
},
|
|
218
|
+
cancel: () => post({ id: id2, bodyCancel: true })
|
|
217
219
|
},
|
|
218
220
|
{ highWaterMark: 0 }
|
|
219
221
|
);
|
|
@@ -234,14 +236,16 @@ function embedderAnswerer(port, hookFor) {
|
|
|
234
236
|
throw Object.assign(new Error(`this page does not answer ${ask.kind}`), {
|
|
235
237
|
name: "NotSupportedError"
|
|
236
238
|
});
|
|
239
|
+
const body = bodyStream(ask.id, state, post);
|
|
237
240
|
const reply = await hook.handle({
|
|
238
241
|
kind: ask.kind,
|
|
239
242
|
options: ask.options,
|
|
240
|
-
body
|
|
243
|
+
body,
|
|
241
244
|
stamp: ask.stamp,
|
|
242
245
|
signal: state.abort.signal,
|
|
243
246
|
progress: (line) => post({ id: ask.id, progress: String(line) })
|
|
244
247
|
});
|
|
248
|
+
if (!(reply instanceof ReadableStream)) post({ id: ask.id, bodyCancel: true });
|
|
245
249
|
state.reader = bytesOf(reply).getReader();
|
|
246
250
|
post({ id: ask.id, ready: true });
|
|
247
251
|
} catch (err) {
|
|
@@ -1891,8 +1895,8 @@ function link(a, b) {
|
|
|
1891
1895
|
pipe.openRead();
|
|
1892
1896
|
pipe.openWrite();
|
|
1893
1897
|
}
|
|
1894
|
-
a.attach({ rx: ba, tx: ab });
|
|
1895
|
-
b.attach({ rx: ab, tx: ba });
|
|
1898
|
+
a.attach({ rx: ba, tx: ab, peer: b });
|
|
1899
|
+
b.attach({ rx: ab, tx: ba, peer: a });
|
|
1896
1900
|
}
|
|
1897
1901
|
var SERVE_CHUNK = 64 * 1024;
|
|
1898
1902
|
var NEVER_ABORTED = new AbortController().signal;
|
|
@@ -1904,6 +1908,8 @@ var KernelSocket = class _KernelSocket {
|
|
|
1904
1908
|
dialing;
|
|
1905
1909
|
failed;
|
|
1906
1910
|
reset;
|
|
1911
|
+
abortive = false;
|
|
1912
|
+
refused;
|
|
1907
1913
|
local;
|
|
1908
1914
|
peer;
|
|
1909
1915
|
peerCred;
|
|
@@ -1940,20 +1946,25 @@ var KernelSocket = class _KernelSocket {
|
|
|
1940
1946
|
}
|
|
1941
1947
|
async read(max, signal) {
|
|
1942
1948
|
const { rx } = this.connection();
|
|
1949
|
+
if (this.refused) throw this.refused;
|
|
1943
1950
|
if (this.readShut || max <= 0) return new Uint8Array(0);
|
|
1944
1951
|
const bytes = await pipeCall(() => rx.read(max, signal));
|
|
1952
|
+
if (this.refused) throw this.refused;
|
|
1945
1953
|
if (bytes.length === 0 && this.reset) throw this.reset;
|
|
1946
1954
|
return bytes;
|
|
1947
1955
|
}
|
|
1948
1956
|
async peek(max, signal) {
|
|
1949
1957
|
const { rx } = this.connection();
|
|
1958
|
+
if (this.refused) throw this.refused;
|
|
1950
1959
|
if (this.readShut || max <= 0) return new Uint8Array(0);
|
|
1951
1960
|
const bytes = await pipeCall(() => rx.peek(max, signal));
|
|
1961
|
+
if (this.refused) throw this.refused;
|
|
1952
1962
|
if (bytes.length === 0 && this.reset) throw this.reset;
|
|
1953
1963
|
return bytes;
|
|
1954
1964
|
}
|
|
1955
1965
|
async write(bytes, signal) {
|
|
1956
1966
|
const { tx } = this.connection();
|
|
1967
|
+
if (this.refused) throw this.refused;
|
|
1957
1968
|
if (this.writeShut) throw new KernelError("EPIPE");
|
|
1958
1969
|
if (this.reset?.code === "EPROTO") throw this.reset;
|
|
1959
1970
|
return pipeCall(() => tx.write(bytes, signal));
|
|
@@ -2140,10 +2151,11 @@ var KernelSocket = class _KernelSocket {
|
|
|
2140
2151
|
handshaking = false;
|
|
2141
2152
|
signal.removeEventListener("abort", abandon);
|
|
2142
2153
|
}
|
|
2143
|
-
|
|
2154
|
+
const plain3 = uplinkLink(made2.conn, (err) => {
|
|
2144
2155
|
this.reset = err instanceof KernelError && err.code === "EPROTO" ? err : new KernelError("ECONNRESET");
|
|
2145
2156
|
this.changes.wake();
|
|
2146
2157
|
});
|
|
2158
|
+
this.link = { ...plain3, ...raw2.peer ? { peer: raw2.peer } : {} };
|
|
2147
2159
|
this.changes.wake();
|
|
2148
2160
|
return made2.info;
|
|
2149
2161
|
}
|
|
@@ -2261,8 +2273,22 @@ var KernelSocket = class _KernelSocket {
|
|
|
2261
2273
|
setOption(level, name2, value2) {
|
|
2262
2274
|
this.options.set(`${level}:${name2}`, value2);
|
|
2263
2275
|
}
|
|
2276
|
+
resetOnClose() {
|
|
2277
|
+
this.connection();
|
|
2278
|
+
this.abortive = true;
|
|
2279
|
+
}
|
|
2280
|
+
abort() {
|
|
2281
|
+
const link2 = this.link;
|
|
2282
|
+
if (link2.peer) link2.peer.resetBy();
|
|
2283
|
+
else link2.tx.closeRead();
|
|
2284
|
+
}
|
|
2285
|
+
resetBy() {
|
|
2286
|
+
this.refused ??= new KernelError("ECONNRESET");
|
|
2287
|
+
this.changes.wake();
|
|
2288
|
+
}
|
|
2264
2289
|
close() {
|
|
2265
2290
|
const was = this.state;
|
|
2291
|
+
if (this.abortive && was === "connected") this.abort();
|
|
2266
2292
|
this.state = "closed";
|
|
2267
2293
|
this.dialing?.abort(new KernelError("ECONNABORTED"));
|
|
2268
2294
|
this.dialing = void 0;
|
|
@@ -3562,7 +3588,7 @@ function satisfies(version, range2) {
|
|
|
3562
3588
|
}
|
|
3563
3589
|
|
|
3564
3590
|
// src/version.ts
|
|
3565
|
-
var KERNEL_VERSION = true ? "1.
|
|
3591
|
+
var KERNEL_VERSION = true ? "1.155.0" : "0.0.0-dev";
|
|
3566
3592
|
var OS_RELEASE = "6.0.0-slicc";
|
|
3567
3593
|
function procVersion() {
|
|
3568
3594
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -7957,6 +7983,7 @@ var BodyPipe = class {
|
|
|
7957
7983
|
queue = [];
|
|
7958
7984
|
size = 0;
|
|
7959
7985
|
ended = false;
|
|
7986
|
+
dropped = false;
|
|
7960
7987
|
wake;
|
|
7961
7988
|
room;
|
|
7962
7989
|
stream;
|
|
@@ -7975,7 +8002,8 @@ var BodyPipe = class {
|
|
|
7975
8002
|
this.room?.();
|
|
7976
8003
|
controller.enqueue(next3);
|
|
7977
8004
|
} else controller.close();
|
|
7978
|
-
}
|
|
8005
|
+
},
|
|
8006
|
+
cancel: () => this.drop()
|
|
7979
8007
|
},
|
|
7980
8008
|
{ highWaterMark: 0 }
|
|
7981
8009
|
);
|
|
@@ -7983,8 +8011,14 @@ var BodyPipe = class {
|
|
|
7983
8011
|
get full() {
|
|
7984
8012
|
return this.size >= EMBEDDER_WINDOW;
|
|
7985
8013
|
}
|
|
8014
|
+
drop() {
|
|
8015
|
+
this.dropped = true;
|
|
8016
|
+
this.queue = [];
|
|
8017
|
+
this.size = 0;
|
|
8018
|
+
this.end();
|
|
8019
|
+
}
|
|
7986
8020
|
push(bytes) {
|
|
7987
|
-
if (bytes.length === 0) return;
|
|
8021
|
+
if (bytes.length === 0 || this.dropped) return;
|
|
7988
8022
|
this.queue.push(bytes.slice());
|
|
7989
8023
|
this.size += bytes.length;
|
|
7990
8024
|
this.wake?.();
|
|
@@ -8000,6 +8034,30 @@ var BodyPipe = class {
|
|
|
8000
8034
|
this.room?.();
|
|
8001
8035
|
}
|
|
8002
8036
|
};
|
|
8037
|
+
function endsWith(stream2, ended) {
|
|
8038
|
+
const reader = stream2.getReader();
|
|
8039
|
+
return new ReadableStream(
|
|
8040
|
+
{
|
|
8041
|
+
pull: async (controller) => {
|
|
8042
|
+
let got;
|
|
8043
|
+
try {
|
|
8044
|
+
got = await reader.read();
|
|
8045
|
+
} catch (err) {
|
|
8046
|
+
ended();
|
|
8047
|
+
throw err;
|
|
8048
|
+
}
|
|
8049
|
+
if (!got.done) return controller.enqueue(got.value);
|
|
8050
|
+
ended();
|
|
8051
|
+
controller.close();
|
|
8052
|
+
},
|
|
8053
|
+
cancel: (reason) => {
|
|
8054
|
+
ended();
|
|
8055
|
+
return reader.cancel(reason);
|
|
8056
|
+
}
|
|
8057
|
+
},
|
|
8058
|
+
{ highWaterMark: 0 }
|
|
8059
|
+
);
|
|
8060
|
+
}
|
|
8003
8061
|
function replyStream(reply) {
|
|
8004
8062
|
if (reply instanceof ReadableStream) return reply;
|
|
8005
8063
|
const bytes = typeof reply === "string" ? new TextEncoder().encode(reply) : reply instanceof Uint8Array ? reply : new Uint8Array(0);
|
|
@@ -8074,7 +8132,10 @@ var EmbedderChannel = class {
|
|
|
8074
8132
|
signal: this.abort.signal,
|
|
8075
8133
|
progress
|
|
8076
8134
|
})
|
|
8077
|
-
).then((reply) =>
|
|
8135
|
+
).then((reply) => {
|
|
8136
|
+
if (!(reply instanceof ReadableStream)) body.drop();
|
|
8137
|
+
return endsWith(replyStream(reply), () => body.drop()).getReader();
|
|
8138
|
+
});
|
|
8078
8139
|
this.replied = asked.catch((err) => {
|
|
8079
8140
|
body.end();
|
|
8080
8141
|
throw this.fail(err);
|
|
@@ -19149,6 +19210,7 @@ var SOCKET_OPS = [
|
|
|
19149
19210
|
"sock-accept",
|
|
19150
19211
|
"sock-connect",
|
|
19151
19212
|
"sock-shutdown",
|
|
19213
|
+
"sock-reset",
|
|
19152
19214
|
"sock-name",
|
|
19153
19215
|
"sock-getopt",
|
|
19154
19216
|
"sock-setopt",
|
|
@@ -19216,6 +19278,9 @@ async function socketSyscall(req, proc) {
|
|
|
19216
19278
|
case "sock-shutdown":
|
|
19217
19279
|
anySocketAt(fds, req.fd).shutdown(req.how);
|
|
19218
19280
|
return ok3();
|
|
19281
|
+
case "sock-reset":
|
|
19282
|
+
socketAt(fds, req.fd).resetOnClose();
|
|
19283
|
+
return ok3();
|
|
19219
19284
|
case "sock-name": {
|
|
19220
19285
|
const socket = anySocketAt(fds, req.fd);
|
|
19221
19286
|
const addr = req.peer ? socket.peer : socket.local;
|