@secure-exec/core 0.1.1-rc.2 → 0.2.0-rc.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/dist/esm-compiler.d.ts +5 -1
- package/dist/esm-compiler.js +5 -1
- package/dist/fs-helpers.d.ts +1 -1
- package/dist/generated/isolate-runtime.d.ts +15 -15
- package/dist/generated/isolate-runtime.js +15 -15
- package/dist/index.d.ts +25 -6
- package/dist/index.js +23 -3
- package/dist/isolate-runtime/apply-custom-global-policy.js +3 -3
- package/dist/isolate-runtime/apply-timing-mitigation-freeze.js +10 -8
- package/dist/isolate-runtime/apply-timing-mitigation-off.js +2 -2
- package/dist/isolate-runtime/bridge-attach.js +2 -2
- package/dist/isolate-runtime/bridge-initial-globals.js +3 -3
- package/dist/isolate-runtime/eval-script-result.js +1 -1
- package/dist/isolate-runtime/global-exposure-helpers.js +2 -2
- package/dist/isolate-runtime/init-commonjs-module-globals.js +2 -2
- package/dist/isolate-runtime/override-process-cwd.js +1 -1
- package/dist/isolate-runtime/override-process-env.js +1 -1
- package/dist/isolate-runtime/require-setup.js +2236 -19
- package/dist/isolate-runtime/set-commonjs-file-globals.js +2 -2
- package/dist/isolate-runtime/set-stdin-data.js +1 -1
- package/dist/isolate-runtime/setup-dynamic-import.js +47 -15
- package/dist/isolate-runtime/setup-fs-facade.js +2 -2
- package/dist/kernel/command-registry.d.ts +44 -0
- package/dist/kernel/command-registry.js +114 -0
- package/dist/kernel/device-layer.d.ts +12 -0
- package/dist/kernel/device-layer.js +262 -0
- package/dist/kernel/dns-cache.d.ts +29 -0
- package/dist/kernel/dns-cache.js +52 -0
- package/dist/kernel/fd-table.d.ts +84 -0
- package/dist/kernel/fd-table.js +278 -0
- package/dist/kernel/file-lock.d.ts +34 -0
- package/dist/kernel/file-lock.js +123 -0
- package/dist/kernel/host-adapter.d.ts +50 -0
- package/dist/kernel/host-adapter.js +8 -0
- package/dist/kernel/index.d.ts +36 -0
- package/dist/kernel/index.js +34 -0
- package/dist/kernel/inode-table.d.ts +43 -0
- package/dist/kernel/inode-table.js +85 -0
- package/dist/kernel/kernel.d.ts +9 -0
- package/dist/kernel/kernel.js +1396 -0
- package/dist/kernel/permissions.d.ts +27 -0
- package/dist/kernel/permissions.js +118 -0
- package/dist/kernel/pipe-manager.d.ts +64 -0
- package/dist/kernel/pipe-manager.js +267 -0
- package/dist/kernel/proc-layer.d.ts +11 -0
- package/dist/kernel/proc-layer.js +501 -0
- package/dist/kernel/process-table.d.ts +124 -0
- package/dist/kernel/process-table.js +631 -0
- package/dist/kernel/pty.d.ts +108 -0
- package/dist/kernel/pty.js +541 -0
- package/dist/kernel/socket-table.d.ts +305 -0
- package/dist/kernel/socket-table.js +1124 -0
- package/dist/kernel/timer-table.d.ts +54 -0
- package/dist/kernel/timer-table.js +108 -0
- package/dist/kernel/types.d.ts +500 -0
- package/dist/kernel/types.js +89 -0
- package/dist/kernel/user.d.ts +29 -0
- package/dist/kernel/user.js +35 -0
- package/dist/kernel/vfs.d.ts +54 -0
- package/dist/kernel/vfs.js +8 -0
- package/dist/kernel/wait.d.ts +45 -0
- package/dist/kernel/wait.js +112 -0
- package/dist/kernel/wstatus.d.ts +21 -0
- package/dist/kernel/wstatus.js +33 -0
- package/dist/module-resolver.d.ts +4 -0
- package/dist/module-resolver.js +4 -0
- package/dist/package-bundler.d.ts +6 -1
- package/dist/runtime-driver.d.ts +3 -1
- package/dist/shared/bridge-contract.d.ts +529 -94
- package/dist/shared/bridge-contract.js +86 -3
- package/dist/shared/console-formatter.js +4 -0
- package/dist/shared/global-exposure.js +345 -0
- package/dist/shared/in-memory-fs.d.ts +30 -11
- package/dist/shared/in-memory-fs.js +383 -109
- package/dist/shared/permissions.d.ts +4 -6
- package/dist/shared/permissions.js +24 -28
- package/dist/types.d.ts +20 -130
- package/dist/types.js +5 -0
- package/package.json +12 -22
- package/dist/bridge/active-handles.d.ts +0 -22
- package/dist/bridge/active-handles.js +0 -55
- package/dist/bridge/child-process.d.ts +0 -99
- package/dist/bridge/child-process.js +0 -656
- package/dist/bridge/fs.d.ts +0 -281
- package/dist/bridge/fs.js +0 -2231
- package/dist/bridge/index.d.ts +0 -10
- package/dist/bridge/index.js +0 -41
- package/dist/bridge/module.d.ts +0 -75
- package/dist/bridge/module.js +0 -299
- package/dist/bridge/network.d.ts +0 -250
- package/dist/bridge/network.js +0 -1433
- package/dist/bridge/os.d.ts +0 -13
- package/dist/bridge/os.js +0 -256
- package/dist/bridge/polyfills.d.ts +0 -2
- package/dist/bridge/polyfills.js +0 -11
- package/dist/bridge/process.d.ts +0 -89
- package/dist/bridge/process.js +0 -994
- package/dist/bridge.js +0 -11766
- package/dist/python-runtime.d.ts +0 -16
- package/dist/python-runtime.js +0 -45
- package/dist/runtime.d.ts +0 -31
- package/dist/runtime.js +0 -69
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kernel type definitions.
|
|
3
|
+
*
|
|
4
|
+
* The kernel is the shared OS layer. All runtimes make "syscalls" to the
|
|
5
|
+
* kernel for filesystem, process, pipe, and FD operations.
|
|
6
|
+
*/
|
|
7
|
+
// FD open flags
|
|
8
|
+
export const O_RDONLY = 0;
|
|
9
|
+
export const O_WRONLY = 1;
|
|
10
|
+
export const O_RDWR = 2;
|
|
11
|
+
export const O_CREAT = 0o100;
|
|
12
|
+
export const O_EXCL = 0o200;
|
|
13
|
+
export const O_TRUNC = 0o1000;
|
|
14
|
+
export const O_APPEND = 0o2000;
|
|
15
|
+
export const O_NONBLOCK = 0o4;
|
|
16
|
+
export const O_CLOEXEC = 0o2000000;
|
|
17
|
+
// fcntl commands
|
|
18
|
+
export const F_DUPFD = 0;
|
|
19
|
+
export const F_GETFD = 1;
|
|
20
|
+
export const F_SETFD = 2;
|
|
21
|
+
export const F_GETFL = 3;
|
|
22
|
+
export const F_DUPFD_CLOEXEC = 1030;
|
|
23
|
+
// FD flags (for F_GETFD / F_SETFD)
|
|
24
|
+
export const FD_CLOEXEC = 1;
|
|
25
|
+
// Seek whence
|
|
26
|
+
export const SEEK_SET = 0;
|
|
27
|
+
export const SEEK_CUR = 1;
|
|
28
|
+
export const SEEK_END = 2;
|
|
29
|
+
// File types
|
|
30
|
+
export const FILETYPE_UNKNOWN = 0;
|
|
31
|
+
export const FILETYPE_CHARACTER_DEVICE = 2;
|
|
32
|
+
export const FILETYPE_DIRECTORY = 3;
|
|
33
|
+
export const FILETYPE_REGULAR_FILE = 4;
|
|
34
|
+
export const FILETYPE_SYMBOLIC_LINK = 7;
|
|
35
|
+
export const FILETYPE_PIPE = 6;
|
|
36
|
+
/**
|
|
37
|
+
* Structured error for kernel operations.
|
|
38
|
+
* Carries a machine-readable `code` so callers can map to errno without
|
|
39
|
+
* string matching.
|
|
40
|
+
*/
|
|
41
|
+
export class KernelError extends Error {
|
|
42
|
+
code;
|
|
43
|
+
constructor(code, message) {
|
|
44
|
+
super(`${code}: ${message}`);
|
|
45
|
+
this.code = code;
|
|
46
|
+
this.name = "KernelError";
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** Returns the POSIX-standard default termios: canonical on, echo on, isig on, opost+onlcr on. */
|
|
50
|
+
export function defaultTermios() {
|
|
51
|
+
return {
|
|
52
|
+
icrnl: true,
|
|
53
|
+
opost: true,
|
|
54
|
+
onlcr: true,
|
|
55
|
+
icanon: true,
|
|
56
|
+
echo: true,
|
|
57
|
+
isig: true,
|
|
58
|
+
cc: {
|
|
59
|
+
vintr: 0x03, // ^C
|
|
60
|
+
vquit: 0x1c, // ^\
|
|
61
|
+
vsusp: 0x1a, // ^Z
|
|
62
|
+
veof: 0x04, // ^D
|
|
63
|
+
verase: 0x7f, // DEL
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
// Signals
|
|
68
|
+
export const SIGHUP = 1;
|
|
69
|
+
export const SIGINT = 2;
|
|
70
|
+
export const SIGQUIT = 3;
|
|
71
|
+
export const SIGKILL = 9;
|
|
72
|
+
export const SIGPIPE = 13;
|
|
73
|
+
export const SIGALRM = 14;
|
|
74
|
+
export const SIGTERM = 15;
|
|
75
|
+
export const SIGCHLD = 17;
|
|
76
|
+
export const SIGCONT = 18;
|
|
77
|
+
export const SIGSTOP = 19;
|
|
78
|
+
export const SIGTSTP = 20;
|
|
79
|
+
export const SIGWINCH = 28;
|
|
80
|
+
// sigaction flags
|
|
81
|
+
export const SA_RESTART = 0x10000000;
|
|
82
|
+
export const SA_RESETHAND = 0x80000000;
|
|
83
|
+
export const SA_NOCLDSTOP = 0x00000001;
|
|
84
|
+
// sigprocmask how values
|
|
85
|
+
export const SIG_BLOCK = 0;
|
|
86
|
+
export const SIG_UNBLOCK = 1;
|
|
87
|
+
export const SIG_SETMASK = 2;
|
|
88
|
+
// waitpid options (POSIX bitmask)
|
|
89
|
+
export const WNOHANG = 1;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User/group identity manager.
|
|
3
|
+
*
|
|
4
|
+
* Provides configurable uid/gid and passwd-entry generation for the kernel.
|
|
5
|
+
* OS-level concern — lives in the kernel so all runtimes share the same identity.
|
|
6
|
+
*/
|
|
7
|
+
export interface UserConfig {
|
|
8
|
+
uid?: number;
|
|
9
|
+
gid?: number;
|
|
10
|
+
euid?: number;
|
|
11
|
+
egid?: number;
|
|
12
|
+
username?: string;
|
|
13
|
+
homedir?: string;
|
|
14
|
+
shell?: string;
|
|
15
|
+
gecos?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class UserManager {
|
|
18
|
+
readonly uid: number;
|
|
19
|
+
readonly gid: number;
|
|
20
|
+
readonly euid: number;
|
|
21
|
+
readonly egid: number;
|
|
22
|
+
readonly username: string;
|
|
23
|
+
readonly homedir: string;
|
|
24
|
+
readonly shell: string;
|
|
25
|
+
readonly gecos: string;
|
|
26
|
+
constructor(config?: UserConfig);
|
|
27
|
+
/** Generate a passwd-format string for the given uid. */
|
|
28
|
+
getpwuid(uid: number): string;
|
|
29
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User/group identity manager.
|
|
3
|
+
*
|
|
4
|
+
* Provides configurable uid/gid and passwd-entry generation for the kernel.
|
|
5
|
+
* OS-level concern — lives in the kernel so all runtimes share the same identity.
|
|
6
|
+
*/
|
|
7
|
+
export class UserManager {
|
|
8
|
+
uid;
|
|
9
|
+
gid;
|
|
10
|
+
euid;
|
|
11
|
+
egid;
|
|
12
|
+
username;
|
|
13
|
+
homedir;
|
|
14
|
+
shell;
|
|
15
|
+
gecos;
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.uid = config?.uid ?? 1000;
|
|
18
|
+
this.gid = config?.gid ?? 1000;
|
|
19
|
+
this.euid = config?.euid ?? this.uid;
|
|
20
|
+
this.egid = config?.egid ?? this.gid;
|
|
21
|
+
this.username = config?.username ?? "user";
|
|
22
|
+
this.homedir = config?.homedir ?? "/home/user";
|
|
23
|
+
this.shell = config?.shell ?? "/bin/sh";
|
|
24
|
+
this.gecos = config?.gecos ?? "";
|
|
25
|
+
}
|
|
26
|
+
/** Generate a passwd-format string for the given uid. */
|
|
27
|
+
getpwuid(uid) {
|
|
28
|
+
if (uid === this.uid) {
|
|
29
|
+
return `${this.username}:x:${this.uid}:${this.gid}:${this.gecos}:${this.homedir}:${this.shell}`;
|
|
30
|
+
}
|
|
31
|
+
// Generic entry for unknown uids
|
|
32
|
+
const name = `user${uid}`;
|
|
33
|
+
return `${name}:x:${uid}:${uid}::/home/${name}:/bin/sh`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual Filesystem interface.
|
|
3
|
+
*
|
|
4
|
+
* POSIX-complete interface that all filesystem backends must implement.
|
|
5
|
+
* Extends the original secure-exec VirtualFileSystem with symlinks,
|
|
6
|
+
* links, permissions, and metadata operations needed by WasmVM's WASI polyfill.
|
|
7
|
+
*/
|
|
8
|
+
export interface VirtualDirEntry {
|
|
9
|
+
name: string;
|
|
10
|
+
isDirectory: boolean;
|
|
11
|
+
isSymbolicLink?: boolean;
|
|
12
|
+
ino?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface VirtualStat {
|
|
15
|
+
mode: number;
|
|
16
|
+
size: number;
|
|
17
|
+
isDirectory: boolean;
|
|
18
|
+
isSymbolicLink: boolean;
|
|
19
|
+
atimeMs: number;
|
|
20
|
+
mtimeMs: number;
|
|
21
|
+
ctimeMs: number;
|
|
22
|
+
birthtimeMs: number;
|
|
23
|
+
ino: number;
|
|
24
|
+
nlink: number;
|
|
25
|
+
uid: number;
|
|
26
|
+
gid: number;
|
|
27
|
+
}
|
|
28
|
+
export interface VirtualFileSystem {
|
|
29
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
30
|
+
readTextFile(path: string): Promise<string>;
|
|
31
|
+
readDir(path: string): Promise<string[]>;
|
|
32
|
+
readDirWithTypes(path: string): Promise<VirtualDirEntry[]>;
|
|
33
|
+
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
34
|
+
createDir(path: string): Promise<void>;
|
|
35
|
+
mkdir(path: string, options?: {
|
|
36
|
+
recursive?: boolean;
|
|
37
|
+
}): Promise<void>;
|
|
38
|
+
exists(path: string): Promise<boolean>;
|
|
39
|
+
stat(path: string): Promise<VirtualStat>;
|
|
40
|
+
removeFile(path: string): Promise<void>;
|
|
41
|
+
removeDir(path: string): Promise<void>;
|
|
42
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
43
|
+
realpath(path: string): Promise<string>;
|
|
44
|
+
symlink(target: string, linkPath: string): Promise<void>;
|
|
45
|
+
readlink(path: string): Promise<string>;
|
|
46
|
+
lstat(path: string): Promise<VirtualStat>;
|
|
47
|
+
link(oldPath: string, newPath: string): Promise<void>;
|
|
48
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
49
|
+
chown(path: string, uid: number, gid: number): Promise<void>;
|
|
50
|
+
utimes(path: string, atime: number, mtime: number): Promise<void>;
|
|
51
|
+
truncate(path: string, length: number): Promise<void>;
|
|
52
|
+
/** Read a range from a file without loading the entire file into memory. */
|
|
53
|
+
pread(path: string, offset: number, length: number): Promise<Uint8Array>;
|
|
54
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual Filesystem interface.
|
|
3
|
+
*
|
|
4
|
+
* POSIX-complete interface that all filesystem backends must implement.
|
|
5
|
+
* Extends the original secure-exec VirtualFileSystem with symlinks,
|
|
6
|
+
* links, permissions, and metadata operations needed by WasmVM's WASI polyfill.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified blocking I/O wait system.
|
|
3
|
+
*
|
|
4
|
+
* Provides WaitHandle and WaitQueue primitives for all kernel subsystems
|
|
5
|
+
* (pipes, sockets, flock, poll) to share the same wait/wake mechanism.
|
|
6
|
+
* Promise-based — no Atomics.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A single wait/wake handle. Callers await wait(), producers call wake().
|
|
10
|
+
* Each handle resolves exactly once (either by wake or timeout).
|
|
11
|
+
*/
|
|
12
|
+
export declare class WaitHandle {
|
|
13
|
+
private resolve;
|
|
14
|
+
private timer;
|
|
15
|
+
private settled;
|
|
16
|
+
readonly promise: Promise<void>;
|
|
17
|
+
/** True if the handle resolved via timeout rather than wake(). */
|
|
18
|
+
timedOut: boolean;
|
|
19
|
+
constructor(timeoutMs?: number);
|
|
20
|
+
/** Suspend until woken or timed out. */
|
|
21
|
+
wait(): Promise<void>;
|
|
22
|
+
/** Wake this handle. No-op if already settled. */
|
|
23
|
+
wake(): void;
|
|
24
|
+
/** Whether this handle has already been resolved. */
|
|
25
|
+
get isSettled(): boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A FIFO queue of WaitHandles. Subsystems enqueue waiters and producers
|
|
29
|
+
* wake them one-at-a-time or all-at-once.
|
|
30
|
+
*/
|
|
31
|
+
export declare class WaitQueue {
|
|
32
|
+
private waiters;
|
|
33
|
+
/** Create and enqueue a new WaitHandle. */
|
|
34
|
+
enqueue(timeoutMs?: number): WaitHandle;
|
|
35
|
+
/** Remove a waiter from the queue without waking it. */
|
|
36
|
+
remove(handle: WaitHandle): void;
|
|
37
|
+
/** Wake exactly one waiter (FIFO order). Returns true if a waiter was woken. */
|
|
38
|
+
wakeOne(): boolean;
|
|
39
|
+
/** Wake all enqueued waiters. Returns the number woken. */
|
|
40
|
+
wakeAll(): number;
|
|
41
|
+
/** Number of pending (unsettled) waiters. */
|
|
42
|
+
get pending(): number;
|
|
43
|
+
/** Remove all waiters without waking them. */
|
|
44
|
+
clear(): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified blocking I/O wait system.
|
|
3
|
+
*
|
|
4
|
+
* Provides WaitHandle and WaitQueue primitives for all kernel subsystems
|
|
5
|
+
* (pipes, sockets, flock, poll) to share the same wait/wake mechanism.
|
|
6
|
+
* Promise-based — no Atomics.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A single wait/wake handle. Callers await wait(), producers call wake().
|
|
10
|
+
* Each handle resolves exactly once (either by wake or timeout).
|
|
11
|
+
*/
|
|
12
|
+
export class WaitHandle {
|
|
13
|
+
resolve = null;
|
|
14
|
+
timer = null;
|
|
15
|
+
settled = false;
|
|
16
|
+
promise;
|
|
17
|
+
/** True if the handle resolved via timeout rather than wake(). */
|
|
18
|
+
timedOut = false;
|
|
19
|
+
constructor(timeoutMs) {
|
|
20
|
+
this.promise = new Promise((resolve) => {
|
|
21
|
+
this.resolve = resolve;
|
|
22
|
+
});
|
|
23
|
+
if (timeoutMs !== undefined && timeoutMs >= 0) {
|
|
24
|
+
this.timer = setTimeout(() => {
|
|
25
|
+
if (!this.settled) {
|
|
26
|
+
this.timedOut = true;
|
|
27
|
+
this.settled = true;
|
|
28
|
+
this.resolve();
|
|
29
|
+
this.resolve = null;
|
|
30
|
+
}
|
|
31
|
+
}, timeoutMs);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Suspend until woken or timed out. */
|
|
35
|
+
wait() {
|
|
36
|
+
return this.promise;
|
|
37
|
+
}
|
|
38
|
+
/** Wake this handle. No-op if already settled. */
|
|
39
|
+
wake() {
|
|
40
|
+
if (this.settled)
|
|
41
|
+
return;
|
|
42
|
+
this.settled = true;
|
|
43
|
+
if (this.timer !== null) {
|
|
44
|
+
clearTimeout(this.timer);
|
|
45
|
+
this.timer = null;
|
|
46
|
+
}
|
|
47
|
+
this.resolve();
|
|
48
|
+
this.resolve = null;
|
|
49
|
+
}
|
|
50
|
+
/** Whether this handle has already been resolved. */
|
|
51
|
+
get isSettled() {
|
|
52
|
+
return this.settled;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A FIFO queue of WaitHandles. Subsystems enqueue waiters and producers
|
|
57
|
+
* wake them one-at-a-time or all-at-once.
|
|
58
|
+
*/
|
|
59
|
+
export class WaitQueue {
|
|
60
|
+
waiters = [];
|
|
61
|
+
/** Create and enqueue a new WaitHandle. */
|
|
62
|
+
enqueue(timeoutMs) {
|
|
63
|
+
const handle = new WaitHandle(timeoutMs);
|
|
64
|
+
this.waiters.push(handle);
|
|
65
|
+
return handle;
|
|
66
|
+
}
|
|
67
|
+
/** Remove a waiter from the queue without waking it. */
|
|
68
|
+
remove(handle) {
|
|
69
|
+
const index = this.waiters.indexOf(handle);
|
|
70
|
+
if (index >= 0) {
|
|
71
|
+
this.waiters.splice(index, 1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Wake exactly one waiter (FIFO order). Returns true if a waiter was woken. */
|
|
75
|
+
wakeOne() {
|
|
76
|
+
while (this.waiters.length > 0) {
|
|
77
|
+
const handle = this.waiters.shift();
|
|
78
|
+
if (!handle.isSettled) {
|
|
79
|
+
handle.wake();
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
// Skip already-settled handles (timed out)
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
/** Wake all enqueued waiters. Returns the number woken. */
|
|
87
|
+
wakeAll() {
|
|
88
|
+
let count = 0;
|
|
89
|
+
for (const handle of this.waiters) {
|
|
90
|
+
if (!handle.isSettled) {
|
|
91
|
+
handle.wake();
|
|
92
|
+
count++;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
this.waiters.length = 0;
|
|
96
|
+
return count;
|
|
97
|
+
}
|
|
98
|
+
/** Number of pending (unsettled) waiters. */
|
|
99
|
+
get pending() {
|
|
100
|
+
// Compact settled handles while counting
|
|
101
|
+
let count = 0;
|
|
102
|
+
for (const handle of this.waiters) {
|
|
103
|
+
if (!handle.isSettled)
|
|
104
|
+
count++;
|
|
105
|
+
}
|
|
106
|
+
return count;
|
|
107
|
+
}
|
|
108
|
+
/** Remove all waiters without waking them. */
|
|
109
|
+
clear() {
|
|
110
|
+
this.waiters.length = 0;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POSIX wstatus encoding/decoding.
|
|
3
|
+
*
|
|
4
|
+
* Encodes how a process terminated into a single integer matching
|
|
5
|
+
* the layout expected by WIFEXITED / WEXITSTATUS / WIFSIGNALED / WTERMSIG.
|
|
6
|
+
*
|
|
7
|
+
* Normal exit: (exitCode & 0xFF) << 8 (bits 8-15 = exit code, bits 0-6 = 0)
|
|
8
|
+
* Signal death: signalNumber & 0x7F (bits 0-6 = signal, bits 8-15 = 0)
|
|
9
|
+
*/
|
|
10
|
+
/** Encode a normal exit into POSIX wstatus. */
|
|
11
|
+
export declare function encodeExitStatus(exitCode: number): number;
|
|
12
|
+
/** Encode a signal death into POSIX wstatus. */
|
|
13
|
+
export declare function encodeSignalStatus(signal: number): number;
|
|
14
|
+
/** True if process exited normally (not killed by a signal). */
|
|
15
|
+
export declare function WIFEXITED(status: number): boolean;
|
|
16
|
+
/** Extract exit code (only valid when WIFEXITED is true). */
|
|
17
|
+
export declare function WEXITSTATUS(status: number): number;
|
|
18
|
+
/** True if process was killed by a signal. */
|
|
19
|
+
export declare function WIFSIGNALED(status: number): boolean;
|
|
20
|
+
/** Extract signal number (only valid when WIFSIGNALED is true). */
|
|
21
|
+
export declare function WTERMSIG(status: number): number;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* POSIX wstatus encoding/decoding.
|
|
3
|
+
*
|
|
4
|
+
* Encodes how a process terminated into a single integer matching
|
|
5
|
+
* the layout expected by WIFEXITED / WEXITSTATUS / WIFSIGNALED / WTERMSIG.
|
|
6
|
+
*
|
|
7
|
+
* Normal exit: (exitCode & 0xFF) << 8 (bits 8-15 = exit code, bits 0-6 = 0)
|
|
8
|
+
* Signal death: signalNumber & 0x7F (bits 0-6 = signal, bits 8-15 = 0)
|
|
9
|
+
*/
|
|
10
|
+
/** Encode a normal exit into POSIX wstatus. */
|
|
11
|
+
export function encodeExitStatus(exitCode) {
|
|
12
|
+
return (exitCode & 0xff) << 8;
|
|
13
|
+
}
|
|
14
|
+
/** Encode a signal death into POSIX wstatus. */
|
|
15
|
+
export function encodeSignalStatus(signal) {
|
|
16
|
+
return signal & 0x7f;
|
|
17
|
+
}
|
|
18
|
+
/** True if process exited normally (not killed by a signal). */
|
|
19
|
+
export function WIFEXITED(status) {
|
|
20
|
+
return (status & 0x7f) === 0;
|
|
21
|
+
}
|
|
22
|
+
/** Extract exit code (only valid when WIFEXITED is true). */
|
|
23
|
+
export function WEXITSTATUS(status) {
|
|
24
|
+
return (status >> 8) & 0xff;
|
|
25
|
+
}
|
|
26
|
+
/** True if process was killed by a signal. */
|
|
27
|
+
export function WIFSIGNALED(status) {
|
|
28
|
+
return (status & 0x7f) !== 0;
|
|
29
|
+
}
|
|
30
|
+
/** Extract signal number (only valid when WIFSIGNALED is true). */
|
|
31
|
+
export function WTERMSIG(status) {
|
|
32
|
+
return status & 0x7f;
|
|
33
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @deprecated Canonical source moved to @secure-exec/nodejs (US-003).
|
|
3
|
+
* This copy is retained for backward compatibility during phased migration.
|
|
4
|
+
* Will be removed in US-005 when kernel merges into core.
|
|
5
|
+
*
|
|
2
6
|
* Module classification and resolution helpers.
|
|
3
7
|
*
|
|
4
8
|
* Node built-ins are split into three tiers:
|
package/dist/module-resolver.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @deprecated Canonical source moved to @secure-exec/nodejs (US-003).
|
|
3
|
+
* This copy is retained for backward compatibility during phased migration.
|
|
4
|
+
* Will be removed in US-005 when kernel merges into core.
|
|
5
|
+
*
|
|
2
6
|
* Module classification and resolution helpers.
|
|
3
7
|
*
|
|
4
8
|
* Node built-ins are split into three tiers:
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Canonical source moved to @secure-exec/nodejs (US-003).
|
|
3
|
+
* This copy is retained for backward compatibility during phased migration.
|
|
4
|
+
* Will be removed in US-005 when kernel merges into core.
|
|
5
|
+
*/
|
|
6
|
+
import type { VirtualFileSystem } from "./kernel/vfs.js";
|
|
2
7
|
type ResolveMode = "require" | "import";
|
|
3
8
|
interface PackageJson {
|
|
4
9
|
main?: string;
|
package/dist/runtime-driver.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { StdioHook, ExecOptions, ExecResult, OSConfig, PythonRunOptions, PythonRunResult, ProcessConfig, RunResult, TimingMitigation } from "./shared/api-types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Permissions } from "./kernel/types.js";
|
|
3
|
+
import type { VirtualFileSystem } from "./kernel/vfs.js";
|
|
4
|
+
import type { CommandExecutor, NetworkAdapter } from "./types.js";
|
|
3
5
|
export interface DriverRuntimeConfig {
|
|
4
6
|
process: ProcessConfig;
|
|
5
7
|
os: OSConfig;
|