@ai-ecoverse/slicc-kernel 1.129.0 → 1.130.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 +19 -1
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +230 -54
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +149 -31
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +230 -54
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +129 -14
- package/dist/process-worker.js.map +4 -4
- package/dist/types/index.d.ts +1 -0
- package/dist/types/kernel/js-threads.d.ts +38 -0
- package/dist/types/kernel/protocol.d.ts +35 -0
- package/dist/types/process/js/js-context.d.ts +3 -0
- package/dist/types/process/js/js-thread.d.ts +22 -0
- package/package.json +2 -2
package/dist/types/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export type { JsStatFs } from './process/js/js-io.js';
|
|
|
39
39
|
export type { JsAddress, JsConnection, JsConnectOptions, JsListener, JsListenOptions, JsNet, JsResolveOptions, JsTlsCipher, JsTlsOptions, JsTlsSession, } from './process/js/js-net.js';
|
|
40
40
|
export type { JsRunOptions, JsRunResult, JsRunStdio } from './process/js/js-run.js';
|
|
41
41
|
export type { JsCred, JsSyncContext, JsSyncFile } from './process/js/js-sync.js';
|
|
42
|
+
export type { JsThread, JsThreadContext, JsThreadSpawnOptions } from './process/js/js-thread.js';
|
|
42
43
|
export type { JsTermios, JsTty, JsTtySize } from './process/js/js-tty.js';
|
|
43
44
|
export type { JsWebSocket, JsWebSocketClose, JsWebSocketMessage, JsWebSocketOptions, } from './process/js/js-websocket.js';
|
|
44
45
|
export type { ApproveHook, SudoAnswer, SudoRequest } from './sudo.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { SyncFsResult } from '../realm/sync-fs-wire.js';
|
|
2
|
+
import type { SyncSabDispatchRequest } from '../realm/sync-sab-responder.js';
|
|
3
|
+
import type { ProcessClocks } from './cpu-clock.js';
|
|
4
|
+
import type { WasmWorkerLike } from './host.js';
|
|
5
|
+
import { type JsLane, type JsProcessInitMsg, type JsThreadSpawnMsg } from './protocol.js';
|
|
6
|
+
export declare const JS_OOM: RegExp;
|
|
7
|
+
export declare function jsThreadCap(env: Readonly<Record<string, string>>): number;
|
|
8
|
+
type Dispatch = (req: SyncSabDispatchRequest, block?: () => void) => Promise<SyncFsResult>;
|
|
9
|
+
export interface JsThreadDeps {
|
|
10
|
+
cap: number;
|
|
11
|
+
wakes: Set<Int32Array>;
|
|
12
|
+
createWorker: () => WasmWorkerLike;
|
|
13
|
+
init: (sab: SharedArrayBuffer, lane: JsLane) => JsProcessInitMsg;
|
|
14
|
+
openLane: (dispatch: Dispatch) => {
|
|
15
|
+
lane: JsLane;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
};
|
|
18
|
+
attach: (worker: WasmWorkerLike, sab: SharedArrayBuffer, dispatch: Dispatch) => {
|
|
19
|
+
dispose(): void;
|
|
20
|
+
};
|
|
21
|
+
dispatch: Dispatch;
|
|
22
|
+
clocks: Pick<ProcessClocks, 'thread' | 'threadEnded' | 'timed'>;
|
|
23
|
+
}
|
|
24
|
+
export declare class JsThreads {
|
|
25
|
+
private readonly deps;
|
|
26
|
+
private readonly live;
|
|
27
|
+
private readonly headers;
|
|
28
|
+
private frozen;
|
|
29
|
+
private last;
|
|
30
|
+
private closed;
|
|
31
|
+
constructor(deps: JsThreadDeps);
|
|
32
|
+
get size(): number;
|
|
33
|
+
spawn(msg: JsThreadSpawnMsg): void;
|
|
34
|
+
private crashed;
|
|
35
|
+
stopped(stopped: boolean): void;
|
|
36
|
+
close(): void;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -13,6 +13,13 @@ export declare const WASM_THREAD_INIT = "wasm-thread-init";
|
|
|
13
13
|
export declare const WASM_THREAD_EXIT = "wasm-thread-exit";
|
|
14
14
|
export declare const WASM_MAX_THREADS = 256;
|
|
15
15
|
export declare const WASM_DEFAULT_THREADS = 64;
|
|
16
|
+
export declare const JS_THREAD_SPAWN = "js-thread-spawn";
|
|
17
|
+
export declare const JS_THREAD_INIT = "js-thread-init";
|
|
18
|
+
export declare const JS_THREAD_EXIT = "js-thread-exit";
|
|
19
|
+
export declare const JS_MAX_THREADS = 256;
|
|
20
|
+
export declare const JS_DEFAULT_THREADS = 16;
|
|
21
|
+
export declare const JS_THREAD_NO_MEMORY = 256;
|
|
22
|
+
export declare const JS_THREAD_CRASHED = 257;
|
|
16
23
|
export interface WasmProgram {
|
|
17
24
|
abi?: 'emscripten' | 'wasi';
|
|
18
25
|
glue: string;
|
|
@@ -99,6 +106,34 @@ export type JsProcessInitMsg = Omit<WasmProcessInitMsg, 'program' | 'fork'> & {
|
|
|
99
106
|
lane?: JsLane;
|
|
100
107
|
};
|
|
101
108
|
export type ProcessInitMsg = WasmProcessInitMsg | JsProcessInitMsg;
|
|
109
|
+
export interface JsThreadSpawnMsg {
|
|
110
|
+
type: typeof JS_THREAD_SPAWN;
|
|
111
|
+
data: unknown;
|
|
112
|
+
port: MessagePort;
|
|
113
|
+
control: MessagePort;
|
|
114
|
+
transfer: Transferable[];
|
|
115
|
+
}
|
|
116
|
+
export interface JsThreadStart {
|
|
117
|
+
tid: number;
|
|
118
|
+
port: MessagePort;
|
|
119
|
+
data: unknown;
|
|
120
|
+
}
|
|
121
|
+
export type JsThreadInitMsg = Omit<JsProcessInitMsg, 'type'> & {
|
|
122
|
+
type: typeof JS_THREAD_INIT;
|
|
123
|
+
thread: JsThreadStart;
|
|
124
|
+
};
|
|
125
|
+
export interface JsThreadExitMsg {
|
|
126
|
+
type: typeof JS_THREAD_EXIT;
|
|
127
|
+
code: number;
|
|
128
|
+
}
|
|
129
|
+
export type JsThreadControl = {
|
|
130
|
+
tid: number;
|
|
131
|
+
} | {
|
|
132
|
+
errno: 'EAGAIN' | 'ESRCH';
|
|
133
|
+
message: string;
|
|
134
|
+
} | {
|
|
135
|
+
exited: number;
|
|
136
|
+
};
|
|
102
137
|
export interface WasmProcessExitMsg {
|
|
103
138
|
type: typeof WASM_PROCESS_EXIT;
|
|
104
139
|
code: number;
|
|
@@ -4,6 +4,7 @@ import { type JsFdType, type JsOpenOptions, type JsStatFs, type JsWriteOptions }
|
|
|
4
4
|
import { type JsKernel } from './js-kernel.js';
|
|
5
5
|
import { type JsNet } from './js-net.js';
|
|
6
6
|
import { type JsSyncContext, type SyncCall } from './js-sync.js';
|
|
7
|
+
import type { JsThreadContext } from './js-thread.js';
|
|
7
8
|
import { type JsTty } from './js-tty.js';
|
|
8
9
|
import { type JsWatcher, type JsWatchListener, type JsWatchOptions } from './js-watch.js';
|
|
9
10
|
import { type JsWebSocket, type JsWebSocketOptions } from './js-websocket.js';
|
|
@@ -90,6 +91,7 @@ export interface JsProgramContext {
|
|
|
90
91
|
tty: JsTty;
|
|
91
92
|
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
92
93
|
exit(code?: number): never;
|
|
94
|
+
readonly thread: JsThreadContext;
|
|
93
95
|
onUncaught(listener: JsStrayListener): () => void;
|
|
94
96
|
onUnhandledRejection(listener: JsStrayListener): () => void;
|
|
95
97
|
}
|
|
@@ -144,6 +146,7 @@ export interface ContextOptions {
|
|
|
144
146
|
random?: (bytes: Uint8Array) => void;
|
|
145
147
|
lane?: SyncCall;
|
|
146
148
|
strays?: JsStrays;
|
|
149
|
+
thread: JsThreadContext;
|
|
147
150
|
}
|
|
148
151
|
export interface Identity {
|
|
149
152
|
pid: number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type JsThreadStart } from '../../kernel/protocol.js';
|
|
2
|
+
import type { SabPostLike } from '../../realm/sync-sab-bridge.js';
|
|
3
|
+
export interface JsThread {
|
|
4
|
+
readonly tid: number;
|
|
5
|
+
readonly port: MessagePort;
|
|
6
|
+
readonly exited: Promise<number>;
|
|
7
|
+
terminate(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface JsThreadSpawnOptions {
|
|
10
|
+
data?: unknown;
|
|
11
|
+
transfer?: readonly Transferable[];
|
|
12
|
+
}
|
|
13
|
+
export interface JsThreadContext {
|
|
14
|
+
readonly tid: number;
|
|
15
|
+
readonly port: MessagePort | undefined;
|
|
16
|
+
readonly data: unknown;
|
|
17
|
+
readonly NO_MEMORY: number;
|
|
18
|
+
readonly CRASHED: number;
|
|
19
|
+
spawn(options?: JsThreadSpawnOptions): Promise<JsThread>;
|
|
20
|
+
}
|
|
21
|
+
export declare function outOfMemory(err: unknown): boolean;
|
|
22
|
+
export declare function threadContext(post: SabPostLike, start?: JsThreadStart): JsThreadContext;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-kernel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.130.0",
|
|
4
4
|
"description": "SLICC's wasm-realm kernel: run Emscripten programs in the browser against OPFS, with fork, spawn, pipes and waitpid",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@ai-ecoverse/slicc-scrub": "1.0.0",
|
|
69
69
|
"@ai-ecoverse/slicc-shared-web": "1.24.2",
|
|
70
70
|
"@ai-ecoverse/wasi-cargo": "0.99.0-3",
|
|
71
|
-
"@ai-ecoverse/wasi-pnpm": "12.9.1-
|
|
71
|
+
"@ai-ecoverse/wasi-pnpm": "12.9.1-15",
|
|
72
72
|
"@ai-ecoverse/wasi-ripgrep": "15.2.0-5",
|
|
73
73
|
"@ai-ecoverse/wasi-rustc": "1.98.1-6",
|
|
74
74
|
"@ai-ecoverse/wasi-zig": "0.16.0-17",
|