@ai-ecoverse/slicc-kernel 1.183.0 → 1.184.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 +96 -0
- package/dist/async-process.js +14060 -0
- package/dist/async-process.js.map +7 -0
- package/dist/cloudflare-sources.js +2 -0
- package/dist/cloudflare.js +42562 -0
- package/dist/cloudflare.js.map +7 -0
- package/dist/driver-worker.js.map +2 -2
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +134 -39
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.cjs +3985 -574
- package/dist/node-process-worker.cjs.map +4 -4
- package/dist/node-process-worker.js +3985 -574
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +1478 -193
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +3901 -490
- package/dist/process-worker.js.map +4 -4
- package/dist/types/async/header-hook.d.ts +3 -0
- package/dist/types/async/link.d.ts +14 -0
- package/dist/types/async/message-link.d.ts +15 -0
- package/dist/types/async/node-host.d.ts +16 -0
- package/dist/types/async/remote-worker.d.ts +12 -0
- package/dist/types/async/snapshots.d.ts +13 -0
- package/dist/types/async/transport.d.ts +28 -0
- package/dist/types/async/wire.d.ts +113 -0
- package/dist/types/cdp/port.d.ts +2 -1
- package/dist/types/cloudflare/clock-skew.d.ts +2 -0
- package/dist/types/cloudflare/computer-driver.d.ts +65 -0
- package/dist/types/cloudflare/computer.d.ts +105 -0
- package/dist/types/cloudflare/fork-tokens.d.ts +17 -0
- package/dist/types/cloudflare/images.d.ts +20 -0
- package/dist/types/cloudflare/isolates.d.ts +17 -0
- package/dist/types/cloudflare/kernel-end.d.ts +45 -0
- package/dist/types/cloudflare/loader.d.ts +54 -0
- package/dist/types/cloudflare/options.d.ts +81 -0
- package/dist/types/cloudflare/placement.d.ts +61 -0
- package/dist/types/cloudflare/rpc-link.d.ts +49 -0
- package/dist/types/cloudflare/rpc-pack.d.ts +7 -0
- package/dist/types/cloudflare/sqlite-meta.d.ts +4 -0
- package/dist/types/cloudflare/sqlite-root.d.ts +5 -0
- package/dist/types/cloudflare/sqlite-store.d.ts +73 -0
- package/dist/types/cloudflare.d.ts +16 -0
- package/dist/types/facade/port.d.ts +2 -1
- package/dist/types/kernel/host.d.ts +1 -0
- package/dist/types/kernel/process.d.ts +2 -0
- package/dist/types/kernel/protocol.d.ts +1 -0
- package/dist/types/launcher.d.ts +16 -0
- package/dist/types/mount/hostfs.d.ts +2 -1
- package/dist/types/mount/in-process.d.ts +15 -0
- package/dist/types/node.d.ts +14 -0
- package/dist/types/ports.d.ts +7 -0
- package/dist/types/process/wasi/wasi-files.d.ts +1 -0
- package/dist/types/process/wasi/wasi-host.d.ts +3 -2
- package/dist/types/process/wasi/wasi-module.d.ts +2 -0
- package/dist/types/process/wasi/wasi-sigmask.d.ts +2 -1
- package/dist/types/process/wasi/wasm-reentry.d.ts +1 -0
- package/dist/types/realm/sync-sab-bridge.d.ts +1 -0
- package/package.json +10 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface KernelLink {
|
|
2
|
+
post(message: unknown, transfer?: Transferable[]): void;
|
|
3
|
+
call(message: unknown, transfer?: Transferable[]): Promise<unknown>;
|
|
4
|
+
onMessage(handler: (message: unknown) => void): void;
|
|
5
|
+
onClose(handler: (reason: string) => void): void;
|
|
6
|
+
close(): void;
|
|
7
|
+
}
|
|
8
|
+
export interface ProcessLink {
|
|
9
|
+
post(message: unknown, transfer?: Transferable[]): void;
|
|
10
|
+
onPost(handler: (message: unknown) => void): void;
|
|
11
|
+
onCall(handler: (message: unknown) => Promise<unknown>): void;
|
|
12
|
+
onClose(handler: (reason: string) => void): void;
|
|
13
|
+
close(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { KernelLink, ProcessLink } from './link.js';
|
|
2
|
+
export interface MessagePortLike {
|
|
3
|
+
postMessage(message: unknown, transfer?: Transferable[]): void;
|
|
4
|
+
addEventListener(type: 'message' | 'close', handler: (event: {
|
|
5
|
+
data?: unknown;
|
|
6
|
+
}) => void): void;
|
|
7
|
+
start?(): void;
|
|
8
|
+
close?(): void;
|
|
9
|
+
}
|
|
10
|
+
export interface MessageLinks {
|
|
11
|
+
process: ProcessLink;
|
|
12
|
+
kernel: KernelLink;
|
|
13
|
+
close(reason?: string): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function messageLinks(port: MessagePortLike): MessageLinks;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { WasmWorkerLike } from '../kernel/host.js';
|
|
2
|
+
import type { KernelLink } from './link.js';
|
|
3
|
+
export interface AsyncProcessDeps {
|
|
4
|
+
module(image: string): WebAssembly.Module | Promise<WebAssembly.Module>;
|
|
5
|
+
}
|
|
6
|
+
export type AsyncProcessEntry = (link: KernelLink, deps: AsyncProcessDeps) => void;
|
|
7
|
+
export interface AsyncProcessOptions {
|
|
8
|
+
entry?: string | URL;
|
|
9
|
+
inline?: AsyncProcessEntry;
|
|
10
|
+
maxMessageBytes?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface NodeAsyncHost {
|
|
13
|
+
compile(bytes: Uint8Array, key: string): Promise<WebAssembly.Module>;
|
|
14
|
+
createWorker(closed: boolean): WasmWorkerLike;
|
|
15
|
+
}
|
|
16
|
+
export declare function nodeAsyncHost(options: AsyncProcessOptions, live: Set<() => void>): NodeAsyncHost;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { WasmWorkerLike } from '../kernel/host.js';
|
|
2
|
+
import { type WasmProgram } from '../kernel/protocol.js';
|
|
3
|
+
import type { ProcessLink } from './link.js';
|
|
4
|
+
import { type AsyncProcessInit } from './wire.js';
|
|
5
|
+
export interface RemoteWorkerOptions {
|
|
6
|
+
maxMessageBytes?: number;
|
|
7
|
+
snapshot?: (token: string, offset: number, max: number) => Promise<Uint8Array> | Uint8Array;
|
|
8
|
+
image?: (program: WasmProgram) => string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export declare const ASYNC_NO_JS = "the async process host runs no JS programs";
|
|
11
|
+
export declare const ASYNC_NO_THREADS = "the async process host runs no threads";
|
|
12
|
+
export declare function remoteWorker(open: (init: AsyncProcessInit) => ProcessLink | Promise<ProcessLink>, options?: RemoteWorkerOptions): WasmWorkerLike;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const SNAPSHOT_TTL_MS = 60000;
|
|
2
|
+
export interface ForkSnapshotRef {
|
|
3
|
+
token: string;
|
|
4
|
+
total: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ForkSnapshots {
|
|
7
|
+
keep(bytes: Uint8Array): ForkSnapshotRef;
|
|
8
|
+
take(token: string): Uint8Array | undefined;
|
|
9
|
+
read(token: string, offset: number, max: number): Uint8Array | undefined;
|
|
10
|
+
release(token: string): void;
|
|
11
|
+
readonly size: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function forkSnapshots(ttlMs?: number): ForkSnapshots;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SyncFsResult } from '../realm/sync-fs-wire.js';
|
|
2
|
+
import { type SyncSabRequestBody } from '../realm/sync-sab-wire.js';
|
|
3
|
+
import type { KernelLink } from './link.js';
|
|
4
|
+
import type { ForkSnapshots } from './snapshots.js';
|
|
5
|
+
import { type AsyncProcessInit } from './wire.js';
|
|
6
|
+
export type WaitResult = 'ok' | 'not-equal' | 'timed-out';
|
|
7
|
+
export interface AsyncTransport {
|
|
8
|
+
readonly init: Promise<AsyncProcessInit>;
|
|
9
|
+
readonly buffer: ArrayBuffer;
|
|
10
|
+
readonly header: Int32Array;
|
|
11
|
+
readonly clock: BigInt64Array;
|
|
12
|
+
readonly changes: ArrayBuffer | undefined;
|
|
13
|
+
readonly cwds: ArrayBuffer | undefined;
|
|
14
|
+
readonly closed: boolean;
|
|
15
|
+
call(req: SyncSabRequestBody, timeoutMs: number, label: string, transfer?: Transferable[], sink?: Uint8Array): Promise<SyncFsResult>;
|
|
16
|
+
wait(view: Int32Array, index: number, value: number, timeoutMs?: number): Promise<WaitResult>;
|
|
17
|
+
notify(view: Int32Array, index: number): void;
|
|
18
|
+
publish(): void;
|
|
19
|
+
post(message: unknown, transfer?: Transferable[]): void;
|
|
20
|
+
onClose(handler: (reason: string) => void): void;
|
|
21
|
+
}
|
|
22
|
+
export interface AsyncTransportOptions {
|
|
23
|
+
maxMessageBytes?: number;
|
|
24
|
+
memory?: () => number | undefined;
|
|
25
|
+
snapshots?: ForkSnapshots;
|
|
26
|
+
deadlines?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function createAsyncTransport(link: KernelLink, options?: AsyncTransportOptions): AsyncTransport;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ForkState, HeldCwdInit, WasmProcessInitMsg, WasmProgram } from '../kernel/protocol.js';
|
|
2
|
+
import type { SyncSabRequestBody } from '../realm/sync-sab-wire.js';
|
|
3
|
+
import type { ForkSnapshotRef } from './snapshots.js';
|
|
4
|
+
export declare const ASYNC_SYSCALL = "async-syscall";
|
|
5
|
+
export declare const ASYNC_MORE = "async-more";
|
|
6
|
+
export declare const ASYNC_STAGE = "async-stage";
|
|
7
|
+
export declare const ASYNC_WORDS = "async-words";
|
|
8
|
+
export declare const ASYNC_MIRROR = "async-mirror";
|
|
9
|
+
export declare const ASYNC_SNAPSHOT = "async-snapshot";
|
|
10
|
+
export declare const ASYNC_SNAPSHOT_TAKEN = "async-snapshot-taken";
|
|
11
|
+
export interface AsyncSnapshotMsg {
|
|
12
|
+
type: typeof ASYNC_SNAPSHOT;
|
|
13
|
+
token: string;
|
|
14
|
+
offset: number;
|
|
15
|
+
}
|
|
16
|
+
export interface AsyncSnapshotReply {
|
|
17
|
+
bytes: Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
export interface AsyncSnapshotTakenMsg {
|
|
20
|
+
type: typeof ASYNC_SNAPSHOT_TAKEN;
|
|
21
|
+
token: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ProcessWords {
|
|
24
|
+
n: number;
|
|
25
|
+
seen: number;
|
|
26
|
+
signals: number;
|
|
27
|
+
timers: number;
|
|
28
|
+
blocked: [number, number];
|
|
29
|
+
memory: number;
|
|
30
|
+
idle: number;
|
|
31
|
+
}
|
|
32
|
+
export interface MirrorUpdate {
|
|
33
|
+
seq: number;
|
|
34
|
+
signals: number;
|
|
35
|
+
timers: number;
|
|
36
|
+
killed: number;
|
|
37
|
+
async: number;
|
|
38
|
+
stop: number;
|
|
39
|
+
clock: number;
|
|
40
|
+
changes?: Int32Array;
|
|
41
|
+
cwds?: Int32Array;
|
|
42
|
+
}
|
|
43
|
+
export interface MirroredBuffer {
|
|
44
|
+
bytes: number;
|
|
45
|
+
runs: Int32Array;
|
|
46
|
+
}
|
|
47
|
+
export interface InitMirror {
|
|
48
|
+
seq: 0;
|
|
49
|
+
header: Int32Array;
|
|
50
|
+
clock: [number, number];
|
|
51
|
+
changes?: MirroredBuffer;
|
|
52
|
+
cwds?: MirroredBuffer;
|
|
53
|
+
}
|
|
54
|
+
export interface StagedBytes {
|
|
55
|
+
part: number;
|
|
56
|
+
total: number;
|
|
57
|
+
}
|
|
58
|
+
export type AsyncForkState = Omit<ForkState, 'memory'> & {
|
|
59
|
+
memory: Uint8Array | StagedBytes;
|
|
60
|
+
snapshot?: ForkSnapshotRef;
|
|
61
|
+
};
|
|
62
|
+
export type AsyncProgram = Omit<WasmProgram, 'module'> & {
|
|
63
|
+
image: string;
|
|
64
|
+
};
|
|
65
|
+
export type AsyncProcessInit = Omit<WasmProcessInitMsg, 'sab' | 'changes' | 'held' | 'program' | 'fork'> & {
|
|
66
|
+
program: AsyncProgram;
|
|
67
|
+
held?: Omit<HeldCwdInit, 'sab'>;
|
|
68
|
+
fork?: AsyncForkState;
|
|
69
|
+
mirror: InitMirror;
|
|
70
|
+
maxMessageBytes?: number;
|
|
71
|
+
};
|
|
72
|
+
export interface AsyncSyscallMsg {
|
|
73
|
+
type: typeof ASYNC_SYSCALL;
|
|
74
|
+
req: SyncSabRequestBody;
|
|
75
|
+
words: ProcessWords;
|
|
76
|
+
staged?: number;
|
|
77
|
+
}
|
|
78
|
+
export interface AsyncMoreMsg {
|
|
79
|
+
type: typeof ASYNC_MORE;
|
|
80
|
+
part: number;
|
|
81
|
+
offset: number;
|
|
82
|
+
}
|
|
83
|
+
export interface AsyncStageMsg {
|
|
84
|
+
type: typeof ASYNC_STAGE;
|
|
85
|
+
stage: number;
|
|
86
|
+
offset: number;
|
|
87
|
+
total: number;
|
|
88
|
+
bytes: Uint8Array;
|
|
89
|
+
}
|
|
90
|
+
export interface AsyncWordsMsg {
|
|
91
|
+
type: typeof ASYNC_WORDS;
|
|
92
|
+
words: ProcessWords;
|
|
93
|
+
}
|
|
94
|
+
export interface AsyncMirrorMsg {
|
|
95
|
+
type: typeof ASYNC_MIRROR;
|
|
96
|
+
mirror: MirrorUpdate;
|
|
97
|
+
}
|
|
98
|
+
export interface AsyncAnswer {
|
|
99
|
+
status: number;
|
|
100
|
+
bytes: Uint8Array;
|
|
101
|
+
total: number;
|
|
102
|
+
part?: number;
|
|
103
|
+
mirror: MirrorUpdate;
|
|
104
|
+
}
|
|
105
|
+
export interface AsyncRefusal {
|
|
106
|
+
failed: string;
|
|
107
|
+
}
|
|
108
|
+
export type AsyncSyscallReply = AsyncAnswer | AsyncRefusal;
|
|
109
|
+
export interface AsyncMoreReply {
|
|
110
|
+
bytes: Uint8Array;
|
|
111
|
+
}
|
|
112
|
+
export declare function diffRuns(last: Int32Array, now: Int32Array): Int32Array | undefined;
|
|
113
|
+
export declare function applyRuns(view: Int32Array, runs: Int32Array | undefined): void;
|
package/dist/types/cdp/port.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type MakePortPair } from '../ports.js';
|
|
1
2
|
import type { CdpHook, CdpRequest } from './types.js';
|
|
2
3
|
export interface CdpPortLike {
|
|
3
4
|
postMessage(message: unknown): void;
|
|
@@ -21,4 +22,4 @@ export interface CdpOpen {
|
|
|
21
22
|
port: CdpPortLike;
|
|
22
23
|
}
|
|
23
24
|
export declare function serveCdpPort(port: CdpPortLike, hook: CdpHook, request: CdpRequest, onDone?: () => void): () => void;
|
|
24
|
-
export declare function portCdpHook(ask: (request: CdpRequest, port: CdpPortLike) => void, gone?: Promise<unknown
|
|
25
|
+
export declare function portCdpHook(ask: (request: CdpRequest, port: CdpPortLike) => void, gone?: Promise<unknown>, ports?: MakePortPair): CdpHook;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type FilesystemHandlers, type ServedFilesystem } from '../mount/driver.js';
|
|
2
|
+
import type { DriverCapabilities } from '../mount/protocol.js';
|
|
3
|
+
export interface WorkspaceStatLike {
|
|
4
|
+
inode?: number;
|
|
5
|
+
mode: number;
|
|
6
|
+
mtime: number;
|
|
7
|
+
size: number;
|
|
8
|
+
isFile: boolean;
|
|
9
|
+
isDirectory: boolean;
|
|
10
|
+
isSymbolicLink: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface WorkspaceDirentLike {
|
|
13
|
+
name: string;
|
|
14
|
+
isFile: boolean;
|
|
15
|
+
isDirectory: boolean;
|
|
16
|
+
isSymbolicLink: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface WorkspaceFilesystemLike {
|
|
19
|
+
readFile(path: string, options: {
|
|
20
|
+
byteOffset?: number;
|
|
21
|
+
byteLength?: number;
|
|
22
|
+
}): Promise<ReadableStream<Uint8Array> | string>;
|
|
23
|
+
writeFile(path: string, content: Uint8Array | ReadableStream<Uint8Array>, options?: {
|
|
24
|
+
mode?: number;
|
|
25
|
+
exclusive?: boolean;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
stat(path: string): Promise<WorkspaceStatLike>;
|
|
28
|
+
lstat(path: string): Promise<WorkspaceStatLike>;
|
|
29
|
+
readdir(path: string): Promise<WorkspaceDirentLike[]>;
|
|
30
|
+
readlink(path: string): Promise<string>;
|
|
31
|
+
mkdir(path: string, options?: {
|
|
32
|
+
recursive?: boolean;
|
|
33
|
+
mode?: number;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
rm(path: string, options?: {
|
|
36
|
+
recursive?: boolean;
|
|
37
|
+
force?: boolean;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
rename(from: string, to: string): Promise<void>;
|
|
40
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
41
|
+
symlink(target: string, path: string): Promise<void>;
|
|
42
|
+
link?(existing: string, path: string): Promise<void>;
|
|
43
|
+
}
|
|
44
|
+
export interface WorkspaceDriverOptions {
|
|
45
|
+
root?: string;
|
|
46
|
+
maxIo?: number;
|
|
47
|
+
bufferBytes?: number;
|
|
48
|
+
attrTtl?: number;
|
|
49
|
+
writeBehind?: boolean | Partial<WriteBehind>;
|
|
50
|
+
}
|
|
51
|
+
export interface WriteBehind {
|
|
52
|
+
idleMs: number;
|
|
53
|
+
maxMs: number;
|
|
54
|
+
maxEntries: number;
|
|
55
|
+
maxBytes: number;
|
|
56
|
+
}
|
|
57
|
+
export interface WorkspaceDriver extends FilesystemHandlers {
|
|
58
|
+
readonly capabilities: DriverCapabilities;
|
|
59
|
+
settled(): Promise<void>;
|
|
60
|
+
flush(open?: boolean): Promise<void>;
|
|
61
|
+
pending(): boolean;
|
|
62
|
+
served(served: ServedFilesystem): void;
|
|
63
|
+
invalidate(paths?: string[]): void;
|
|
64
|
+
}
|
|
65
|
+
export declare function workspaceDriver(fs: WorkspaceFilesystemLike, options?: WorkspaceDriverOptions): WorkspaceDriver;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { MessagePortLike } from '../client/protocol.js';
|
|
2
|
+
import type { MountSpec } from '../mount/mount-fs.js';
|
|
3
|
+
import { type WorkspaceDriverOptions, type WorkspaceFilesystemLike, workspaceDriver } from './computer-driver.js';
|
|
4
|
+
export type { WorkspaceDirentLike, WorkspaceDriver, WorkspaceDriverOptions, WorkspaceFilesystemLike, WorkspaceStatLike, } from './computer-driver.js';
|
|
5
|
+
export { workspaceDriver };
|
|
6
|
+
export type KillSignalName = 'SIGTERM' | 'SIGKILL' | 'SIGINT' | 'SIGHUP';
|
|
7
|
+
export type ExecEvent = {
|
|
8
|
+
id: string;
|
|
9
|
+
seq: number;
|
|
10
|
+
name: 'stdout';
|
|
11
|
+
value: Uint8Array;
|
|
12
|
+
} | {
|
|
13
|
+
id: string;
|
|
14
|
+
seq: number;
|
|
15
|
+
name: 'stderr';
|
|
16
|
+
value: Uint8Array;
|
|
17
|
+
} | {
|
|
18
|
+
id: string;
|
|
19
|
+
seq: number;
|
|
20
|
+
name: 'exit';
|
|
21
|
+
code: number;
|
|
22
|
+
result?: unknown;
|
|
23
|
+
};
|
|
24
|
+
export interface ShellExecInput {
|
|
25
|
+
source: string;
|
|
26
|
+
cwd?: string;
|
|
27
|
+
id?: string;
|
|
28
|
+
input?: unknown;
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
env?: Record<string, string>;
|
|
31
|
+
stdin?: Uint8Array;
|
|
32
|
+
}
|
|
33
|
+
export interface ShellRPC {
|
|
34
|
+
exec(input: ShellExecInput): Promise<{
|
|
35
|
+
id: string;
|
|
36
|
+
events: ReadableStream<ExecEvent>;
|
|
37
|
+
}>;
|
|
38
|
+
getExec(input: {
|
|
39
|
+
id: string;
|
|
40
|
+
after?: number | 'tail';
|
|
41
|
+
}): Promise<{
|
|
42
|
+
id: string;
|
|
43
|
+
events: ReadableStream<ExecEvent>;
|
|
44
|
+
}>;
|
|
45
|
+
killExec(input: {
|
|
46
|
+
id: string;
|
|
47
|
+
signal?: KillSignalName;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
disposeExec(input: {
|
|
50
|
+
id: string;
|
|
51
|
+
}): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
export interface NoSyncRPC {
|
|
54
|
+
push(): never;
|
|
55
|
+
fetchChanges(): never;
|
|
56
|
+
watermarks(): never;
|
|
57
|
+
readEntry(): never;
|
|
58
|
+
hasObjects(): never;
|
|
59
|
+
fetchObjects(): ReadableStream<never>;
|
|
60
|
+
pushObjects(): never;
|
|
61
|
+
}
|
|
62
|
+
export interface SliccBackendHandle {
|
|
63
|
+
rpc: {
|
|
64
|
+
sync: NoSyncRPC;
|
|
65
|
+
shell: ShellRPC;
|
|
66
|
+
};
|
|
67
|
+
runtimeId: string;
|
|
68
|
+
sync: 'none';
|
|
69
|
+
closed: Promise<void>;
|
|
70
|
+
close(): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
export interface SliccKernelLike {
|
|
73
|
+
mount(spec: MountSpec): Promise<unknown>;
|
|
74
|
+
umount(target: string): Promise<void>;
|
|
75
|
+
connect(options?: {
|
|
76
|
+
user?: string | number;
|
|
77
|
+
tag?: string;
|
|
78
|
+
}): Promise<MessagePortLike>;
|
|
79
|
+
}
|
|
80
|
+
export interface SliccBackendHost {
|
|
81
|
+
readonly fs: WorkspaceFilesystemLike;
|
|
82
|
+
}
|
|
83
|
+
export interface SliccBackendOptions {
|
|
84
|
+
kernel(): SliccKernelLike | Promise<SliccKernelLike>;
|
|
85
|
+
id?: string;
|
|
86
|
+
description?: string;
|
|
87
|
+
mountPoint?: string;
|
|
88
|
+
root?: string;
|
|
89
|
+
type?: string;
|
|
90
|
+
shell?: readonly string[];
|
|
91
|
+
user?: string | number;
|
|
92
|
+
timeoutMs?: number;
|
|
93
|
+
killGraceMs?: number;
|
|
94
|
+
retentionMs?: number;
|
|
95
|
+
logBytes?: number;
|
|
96
|
+
writeBehind?: WorkspaceDriverOptions['writeBehind'];
|
|
97
|
+
}
|
|
98
|
+
export interface SliccBackend {
|
|
99
|
+
readonly id: string;
|
|
100
|
+
readonly type: 'slicc-kernel';
|
|
101
|
+
readonly callable: false;
|
|
102
|
+
readonly description: string;
|
|
103
|
+
connect(host: SliccBackendHost): Promise<SliccBackendHandle>;
|
|
104
|
+
}
|
|
105
|
+
export declare function sliccBackend(options: SliccBackendOptions): SliccBackend;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ProcessEndStub } from './rpc-link.js';
|
|
2
|
+
export declare const FORK_TOKEN_TTL_MS = 30000;
|
|
3
|
+
export declare class ForkTokens {
|
|
4
|
+
private readonly held;
|
|
5
|
+
private readonly ttlMs;
|
|
6
|
+
fetched: number;
|
|
7
|
+
taken: number;
|
|
8
|
+
constructor(ttlMs?: number);
|
|
9
|
+
get size(): number;
|
|
10
|
+
watchCall(message: unknown, end: ProcessEndStub | undefined, hold?: (bytes: number) => () => void): string | undefined;
|
|
11
|
+
watchAnswer(token: string | undefined, answer: unknown): void;
|
|
12
|
+
watchPost(message: unknown): boolean;
|
|
13
|
+
private hold;
|
|
14
|
+
drop(token: string): void;
|
|
15
|
+
read(token: string, offset: number, max: number): Promise<Uint8Array>;
|
|
16
|
+
clear(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface ImageHandle {
|
|
2
|
+
readonly image: string;
|
|
3
|
+
}
|
|
4
|
+
export declare function digest(data: string | Uint8Array): Promise<string>;
|
|
5
|
+
export declare function initialMemory(bytes: Uint8Array): number;
|
|
6
|
+
export declare class Images {
|
|
7
|
+
private readonly initial;
|
|
8
|
+
private readonly bytes;
|
|
9
|
+
private readonly handles;
|
|
10
|
+
register(source: ArrayBuffer | ArrayBufferView): Promise<ImageHandle>;
|
|
11
|
+
compile: (bytes: ArrayBuffer | ArrayBufferView) => Promise<WebAssembly.Module>;
|
|
12
|
+
get(image: string): ArrayBuffer;
|
|
13
|
+
sizeOf(image: string): {
|
|
14
|
+
initial: number;
|
|
15
|
+
module: number;
|
|
16
|
+
};
|
|
17
|
+
has(image: string): boolean;
|
|
18
|
+
get size(): number;
|
|
19
|
+
}
|
|
20
|
+
export declare function imageOf(module: unknown): string | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const MAX_ISOLATES = 8;
|
|
2
|
+
export declare const ISOLATE_WAIT_MS = 10000;
|
|
3
|
+
export declare class IsolateGate {
|
|
4
|
+
private readonly live;
|
|
5
|
+
private readonly queue;
|
|
6
|
+
peak: number;
|
|
7
|
+
readonly max: number;
|
|
8
|
+
readonly waitMs: number;
|
|
9
|
+
constructor(max?: number, waitMs?: number);
|
|
10
|
+
get active(): number;
|
|
11
|
+
private enter;
|
|
12
|
+
private leave;
|
|
13
|
+
tryAcquire(id: string): (() => void) | undefined;
|
|
14
|
+
fits(id: string): boolean;
|
|
15
|
+
private wake;
|
|
16
|
+
acquire(id: string): Promise<() => void>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { RpcTarget } from 'cloudflare:workers';
|
|
2
|
+
import type { ProcessLink } from '../async/link.js';
|
|
3
|
+
import type { ForkTokens } from './fork-tokens.js';
|
|
4
|
+
import { type Answer, Closers, Held, Inbox, type ProcessEndStub } from './rpc-link.js';
|
|
5
|
+
declare class KernelState {
|
|
6
|
+
readonly inbox: Inbox;
|
|
7
|
+
readonly held: Held;
|
|
8
|
+
readonly closers: Closers;
|
|
9
|
+
readonly early: {
|
|
10
|
+
message: unknown;
|
|
11
|
+
resolve(value: unknown): void;
|
|
12
|
+
reject(err: Error): void;
|
|
13
|
+
}[];
|
|
14
|
+
handler: ((message: unknown) => Promise<unknown>) | undefined;
|
|
15
|
+
end: ProcessEndStub | undefined;
|
|
16
|
+
readonly forks: ForkTokens | undefined;
|
|
17
|
+
readonly sized: ((bytes: number) => void) | undefined;
|
|
18
|
+
readonly holds: ((bytes: number) => () => void) | undefined;
|
|
19
|
+
readonly refresh: (() => Promise<unknown>) | undefined;
|
|
20
|
+
constructor(hooks?: LinkHooks);
|
|
21
|
+
words(message: unknown): void;
|
|
22
|
+
get closed(): boolean;
|
|
23
|
+
call(message: unknown): Promise<unknown>;
|
|
24
|
+
listen(handler: (message: unknown) => Promise<unknown>): void;
|
|
25
|
+
close(reason: string): boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare class KernelEnd extends RpcTarget {
|
|
28
|
+
#private;
|
|
29
|
+
constructor(state: KernelState);
|
|
30
|
+
part(bytes: Uint8Array): void;
|
|
31
|
+
post(value: unknown, count: number): void;
|
|
32
|
+
call(value: unknown, count: number, sent?: number): Promise<Answer>;
|
|
33
|
+
take(held: number, index: number): Uint8Array;
|
|
34
|
+
}
|
|
35
|
+
export interface ProcessHostStub {
|
|
36
|
+
open(kernel: KernelEnd): Promise<ProcessEndStub>;
|
|
37
|
+
}
|
|
38
|
+
export interface LinkHooks {
|
|
39
|
+
forks?: ForkTokens;
|
|
40
|
+
sized?: (bytes: number) => void;
|
|
41
|
+
holds?: (bytes: number) => () => void;
|
|
42
|
+
refresh?: () => Promise<unknown>;
|
|
43
|
+
}
|
|
44
|
+
export declare function openLink(host: ProcessHostStub, released: () => void, hooks?: LinkHooks): Promise<ProcessLink>;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ProcessLink } from '../async/link.js';
|
|
2
|
+
import { ForkTokens } from './fork-tokens.js';
|
|
3
|
+
import { type Images } from './images.js';
|
|
4
|
+
import type { IsolateGate } from './isolates.js';
|
|
5
|
+
import { Placement } from './placement.js';
|
|
6
|
+
export type WorkerModule = string | {
|
|
7
|
+
js: string;
|
|
8
|
+
} | {
|
|
9
|
+
wasm: ArrayBuffer;
|
|
10
|
+
} | {
|
|
11
|
+
text: string;
|
|
12
|
+
} | {
|
|
13
|
+
data: ArrayBuffer;
|
|
14
|
+
} | {
|
|
15
|
+
json: unknown;
|
|
16
|
+
};
|
|
17
|
+
export interface WorkerCode {
|
|
18
|
+
compatibilityDate: string;
|
|
19
|
+
compatibilityFlags?: string[];
|
|
20
|
+
mainModule: string;
|
|
21
|
+
modules: Record<string, WorkerModule>;
|
|
22
|
+
globalOutbound?: null;
|
|
23
|
+
env?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
export interface WorkerLoaderLike {
|
|
26
|
+
get(id: string, code: () => WorkerCode | Promise<WorkerCode>): {
|
|
27
|
+
getEntrypoint(name?: string): unknown;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export interface ProcessHostCode {
|
|
31
|
+
host: string;
|
|
32
|
+
process: string;
|
|
33
|
+
compatibilityDate?: string;
|
|
34
|
+
compatibilityFlags?: string[];
|
|
35
|
+
localForks?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare const PROCESS_COMPATIBILITY_DATE = "2026-09-01";
|
|
38
|
+
export declare function imageOfInit(init: unknown): string | undefined;
|
|
39
|
+
export interface Processes {
|
|
40
|
+
readonly forks: ForkTokens;
|
|
41
|
+
readonly placement: Placement;
|
|
42
|
+
open(init: unknown): Promise<ProcessLink>;
|
|
43
|
+
admit(module: unknown, from?: {
|
|
44
|
+
ppid?: number;
|
|
45
|
+
}): Promise<() => void>;
|
|
46
|
+
workerId(image: string): Promise<string>;
|
|
47
|
+
readonly loads: number;
|
|
48
|
+
}
|
|
49
|
+
export interface IsolateMemory {
|
|
50
|
+
budget?: number;
|
|
51
|
+
perInstance?: number;
|
|
52
|
+
clock?: () => Promise<unknown>;
|
|
53
|
+
}
|
|
54
|
+
export declare function cloudflareProcesses(loader: WorkerLoaderLike, images: Images, gate: IsolateGate, code: ProcessHostCode, memory?: IsolateMemory): Processes;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { CronClock } from '../cron/clock.js';
|
|
2
|
+
import type { DenialHook } from '../fs/dac.js';
|
|
3
|
+
import type { MetaStore } from '../fs/meta.js';
|
|
4
|
+
import type { Protection } from '../fs/protect.js';
|
|
5
|
+
import type { UsersMode } from '../fs/types.js';
|
|
6
|
+
import type { ConnectOptions, KernelGroups, KernelUsers, RunOptions, RunResult, Terminal, TerminalOptions } from '../index.js';
|
|
7
|
+
import type { EmbedderHook } from '../kernel/embedder.js';
|
|
8
|
+
import type { RouteTable } from '../kernel/net/routes.js';
|
|
9
|
+
import type { SealedOption } from '../kernel/net/sealed-fetch.js';
|
|
10
|
+
import type { NetworkUplink } from '../kernel/net/uplink.js';
|
|
11
|
+
import type { MountEntry, MountSpec } from '../mount/mount-fs.js';
|
|
12
|
+
import type { ProcessMountPolicy } from '../mount/syscall.js';
|
|
13
|
+
import type { ApproveHook } from '../sudo.js';
|
|
14
|
+
import type { NetworkTransport } from '../transport.js';
|
|
15
|
+
import type { Images } from './images.js';
|
|
16
|
+
import type { IsolateGate } from './isolates.js';
|
|
17
|
+
import type { Processes, ProcessHostCode, WorkerLoaderLike } from './loader.js';
|
|
18
|
+
import type { SqliteOptions, SqlStorageLike } from './sqlite-store.js';
|
|
19
|
+
export interface CloudflareKernelOptions {
|
|
20
|
+
loader: WorkerLoaderLike;
|
|
21
|
+
root?: FileSystemDirectoryHandle;
|
|
22
|
+
meta?: MetaStore;
|
|
23
|
+
ranged?: boolean;
|
|
24
|
+
sql?: SqlStorageLike;
|
|
25
|
+
sqlite?: SqliteOptions;
|
|
26
|
+
processHost?: Partial<ProcessHostCode>;
|
|
27
|
+
isolates?: {
|
|
28
|
+
max?: number;
|
|
29
|
+
waitMs?: number;
|
|
30
|
+
memory?: number;
|
|
31
|
+
perInstance?: number;
|
|
32
|
+
};
|
|
33
|
+
clock?: () => Promise<unknown>;
|
|
34
|
+
modules?: string;
|
|
35
|
+
commands?: {
|
|
36
|
+
append?: readonly string[];
|
|
37
|
+
};
|
|
38
|
+
env?: Record<string, string>;
|
|
39
|
+
network?: {
|
|
40
|
+
transport?: NetworkTransport;
|
|
41
|
+
uplink?: NetworkUplink;
|
|
42
|
+
doh?: string | false;
|
|
43
|
+
};
|
|
44
|
+
processMounts?: ProcessMountPolicy;
|
|
45
|
+
hostname?: string;
|
|
46
|
+
timeZone?: string;
|
|
47
|
+
users?: UsersMode;
|
|
48
|
+
onDenial?: DenialHook;
|
|
49
|
+
sealed?: SealedOption;
|
|
50
|
+
requests?: EmbedderHook;
|
|
51
|
+
approve?: ApproveHook;
|
|
52
|
+
protect?: Protection;
|
|
53
|
+
cron?: {
|
|
54
|
+
clock?: CronClock;
|
|
55
|
+
};
|
|
56
|
+
wasmMemories?: {
|
|
57
|
+
ceiling?: number;
|
|
58
|
+
idleMs?: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface CloudflareKernel {
|
|
62
|
+
readonly root: FileSystemDirectoryHandle;
|
|
63
|
+
readonly images: Images;
|
|
64
|
+
readonly isolates: IsolateGate;
|
|
65
|
+
readonly processes: Processes;
|
|
66
|
+
run(argv: string[], options?: RunOptions): Promise<RunResult>;
|
|
67
|
+
openTerminal(argv: string[], options?: TerminalOptions): Promise<Terminal>;
|
|
68
|
+
writeFile(path: string, data: string | Uint8Array, options?: {
|
|
69
|
+
mode?: number;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
72
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
73
|
+
connect(options?: ConnectOptions): Promise<MessagePort>;
|
|
74
|
+
readonly users: KernelUsers;
|
|
75
|
+
readonly groups: KernelGroups;
|
|
76
|
+
setRoutes(routes: RouteTable): Promise<void>;
|
|
77
|
+
mount(spec: MountSpec): Promise<MountEntry>;
|
|
78
|
+
umount(target: string): Promise<void>;
|
|
79
|
+
mounts(): Promise<MountEntry[]>;
|
|
80
|
+
terminate(): void;
|
|
81
|
+
}
|