@secure-exec/core 0.2.1 → 0.3.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/README.md +5 -5
- package/dist/binary.d.ts +4 -0
- package/dist/binary.js +25 -0
- package/dist/bytes.d.ts +2 -0
- package/dist/bytes.js +6 -0
- package/dist/callbacks.d.ts +41 -0
- package/dist/callbacks.js +94 -0
- package/dist/cargo.d.ts +2 -0
- package/dist/cargo.js +142 -0
- package/dist/correlation.d.ts +10 -0
- package/dist/correlation.js +49 -0
- package/dist/descriptors.d.ts +34 -0
- package/dist/descriptors.js +37 -0
- package/dist/event-buffer.d.ts +90 -0
- package/dist/event-buffer.js +313 -0
- package/dist/ext.d.ts +7 -0
- package/dist/ext.js +13 -0
- package/dist/filesystem.d.ts +41 -0
- package/dist/filesystem.js +70 -0
- package/dist/frame-payload-codec.d.ts +8 -0
- package/dist/frame-payload-codec.js +14 -0
- package/dist/frame-rpc.d.ts +38 -0
- package/dist/frame-rpc.js +73 -0
- package/dist/frame-stream.d.ts +27 -0
- package/dist/frame-stream.js +99 -0
- package/dist/framing.d.ts +7 -0
- package/dist/framing.js +22 -0
- package/dist/generated/AcpLimitsConfig.d.ts +4 -0
- package/dist/generated/AcpLimitsConfig.js +2 -0
- package/dist/generated/CreateVmConfig.d.ts +19 -0
- package/dist/generated/FsPermissionRule.d.ts +6 -0
- package/dist/generated/FsPermissionRuleSet.d.ts +6 -0
- package/dist/generated/FsPermissionRuleSet.js +1 -0
- package/dist/generated/FsPermissionScope.d.ts +3 -0
- package/dist/generated/FsPermissionScope.js +1 -0
- package/dist/generated/HttpLimitsConfig.d.ts +3 -0
- package/dist/generated/HttpLimitsConfig.js +2 -0
- package/dist/generated/JsModuleResolution.d.ts +1 -0
- package/dist/generated/JsModuleResolution.js +2 -0
- package/dist/generated/JsRuntimeConfig.d.ts +26 -0
- package/dist/generated/JsRuntimeConfig.js +1 -0
- package/dist/generated/JsRuntimeLimitsConfig.d.ts +7 -0
- package/dist/generated/JsRuntimeLimitsConfig.js +2 -0
- package/dist/generated/JsRuntimePlatform.d.ts +1 -0
- package/dist/generated/JsRuntimePlatform.js +2 -0
- package/dist/generated/MountPluginDescriptor.d.ts +4 -0
- package/dist/generated/MountPluginDescriptor.js +2 -0
- package/dist/generated/NativeRootFilesystemConfig.d.ts +5 -0
- package/dist/generated/NativeRootFilesystemConfig.js +1 -0
- package/dist/generated/PatternPermissionRule.d.ts +6 -0
- package/dist/generated/PatternPermissionRule.js +1 -0
- package/dist/generated/PatternPermissionRuleSet.d.ts +6 -0
- package/dist/generated/PatternPermissionRuleSet.js +1 -0
- package/dist/generated/PatternPermissionScope.d.ts +3 -0
- package/dist/generated/PatternPermissionScope.js +1 -0
- package/dist/generated/PermissionMode.d.ts +1 -0
- package/dist/generated/PermissionMode.js +2 -0
- package/dist/generated/PermissionsPolicy.d.ts +10 -0
- package/dist/generated/PermissionsPolicy.js +1 -0
- package/dist/generated/PluginLimitsConfig.d.ts +4 -0
- package/dist/generated/PluginLimitsConfig.js +2 -0
- package/dist/generated/PythonLimitsConfig.d.ts +5 -0
- package/dist/generated/PythonLimitsConfig.js +2 -0
- package/dist/generated/ResourceLimitsConfig.d.ts +22 -0
- package/dist/generated/ResourceLimitsConfig.js +2 -0
- package/dist/generated/RootFilesystemConfig.d.ts +9 -0
- package/dist/generated/RootFilesystemConfig.js +1 -0
- package/dist/generated/RootFilesystemEntry.d.ts +13 -0
- package/dist/generated/RootFilesystemEntry.js +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryEncoding.js +2 -0
- package/dist/generated/RootFilesystemEntryKind.d.ts +1 -0
- package/dist/generated/RootFilesystemEntryKind.js +2 -0
- package/dist/generated/RootFilesystemLowerDescriptor.d.ts +7 -0
- package/dist/generated/RootFilesystemLowerDescriptor.js +1 -0
- package/dist/generated/RootFilesystemMode.d.ts +1 -0
- package/dist/generated/RootFilesystemMode.js +2 -0
- package/dist/generated/ToolLimitsConfig.d.ts +10 -0
- package/dist/generated/ToolLimitsConfig.js +2 -0
- package/dist/generated/VmDnsConfig.d.ts +6 -0
- package/dist/generated/VmDnsConfig.js +2 -0
- package/dist/generated/VmLimitsConfig.d.ts +18 -0
- package/dist/generated/VmLimitsConfig.js +1 -0
- package/dist/generated/VmListenPolicyConfig.d.ts +5 -0
- package/dist/generated/VmListenPolicyConfig.js +2 -0
- package/dist/generated/WasmLimitsConfig.d.ts +5 -0
- package/dist/generated/WasmLimitsConfig.js +2 -0
- package/dist/generated-protocol.d.ts +1037 -0
- package/dist/generated-protocol.js +2887 -0
- package/dist/index.d.ts +24 -62
- package/dist/index.js +24 -53
- package/dist/json.d.ts +2 -0
- package/dist/json.js +20 -0
- package/dist/kernel-proxy.d.ts +149 -0
- package/dist/kernel-proxy.js +1733 -0
- package/dist/native-client.d.ts +41 -0
- package/dist/native-client.js +124 -0
- package/dist/node-runtime.d.ts +443 -0
- package/dist/node-runtime.js +569 -0
- package/dist/numbers.d.ts +1 -0
- package/dist/numbers.js +8 -0
- package/dist/ownership.d.ts +18 -0
- package/dist/ownership.js +77 -0
- package/dist/permissions.d.ts +29 -0
- package/dist/permissions.js +68 -0
- package/dist/process.d.ts +35 -0
- package/dist/process.js +125 -0
- package/dist/protocol-client.d.ts +46 -0
- package/dist/protocol-client.js +180 -0
- package/dist/protocol-frames.d.ts +68 -0
- package/dist/protocol-frames.js +139 -0
- package/dist/protocol-maps.d.ts +28 -0
- package/dist/protocol-maps.js +217 -0
- package/dist/protocol-schema.d.ts +10 -0
- package/dist/protocol-schema.js +11 -0
- package/dist/request-payloads.d.ts +137 -0
- package/dist/request-payloads.js +210 -0
- package/dist/response-payloads.d.ts +107 -0
- package/dist/response-payloads.js +161 -0
- package/dist/sidecar-client.d.ts +242 -0
- package/dist/sidecar-client.js +797 -0
- package/dist/state.d.ts +40 -0
- package/dist/state.js +44 -0
- package/dist/test-runtime.d.ts +526 -0
- package/dist/test-runtime.js +2119 -0
- package/dist/vm-config.d.ts +31 -0
- package/dist/vm-config.js +1 -0
- package/fixtures/alpine-defaults.json +520 -0
- package/fixtures/base-filesystem.json +528 -0
- package/package.json +193 -115
- package/LICENSE +0 -191
- package/dist/bridge-setup.d.ts +0 -6
- package/dist/bridge-setup.js +0 -9
- package/dist/esm-compiler.d.ts +0 -18
- package/dist/esm-compiler.js +0 -72
- package/dist/fs-helpers.d.ts +0 -23
- package/dist/fs-helpers.js +0 -41
- package/dist/generated/isolate-runtime.d.ts +0 -19
- package/dist/generated/isolate-runtime.js +0 -21
- package/dist/generated/polyfills.d.ts +0 -82
- package/dist/generated/polyfills.js +0 -82
- package/dist/isolate-runtime/apply-custom-global-policy.js +0 -53
- package/dist/isolate-runtime/apply-timing-mitigation-freeze.js +0 -130
- package/dist/isolate-runtime/apply-timing-mitigation-off.js +0 -14
- package/dist/isolate-runtime/bridge-attach.js +0 -29
- package/dist/isolate-runtime/bridge-initial-globals.js +0 -385
- package/dist/isolate-runtime/eval-script-result.js +0 -8
- package/dist/isolate-runtime/global-exposure-helpers.js +0 -36
- package/dist/isolate-runtime/init-commonjs-module-globals.js +0 -28
- package/dist/isolate-runtime/override-process-cwd.js +0 -8
- package/dist/isolate-runtime/override-process-env.js +0 -8
- package/dist/isolate-runtime/require-setup.js +0 -4153
- package/dist/isolate-runtime/set-commonjs-file-globals.js +0 -36
- package/dist/isolate-runtime/set-stdin-data.js +0 -10
- package/dist/isolate-runtime/setup-dynamic-import.js +0 -123
- package/dist/isolate-runtime/setup-fs-facade.js +0 -87
- package/dist/kernel/command-registry.d.ts +0 -44
- package/dist/kernel/command-registry.js +0 -114
- package/dist/kernel/device-backend.d.ts +0 -14
- package/dist/kernel/device-backend.js +0 -251
- package/dist/kernel/device-layer.d.ts +0 -12
- package/dist/kernel/device-layer.js +0 -271
- package/dist/kernel/dns-cache.d.ts +0 -29
- package/dist/kernel/dns-cache.js +0 -52
- package/dist/kernel/fd-table.d.ts +0 -84
- package/dist/kernel/fd-table.js +0 -278
- package/dist/kernel/file-lock.d.ts +0 -34
- package/dist/kernel/file-lock.js +0 -122
- package/dist/kernel/host-adapter.d.ts +0 -50
- package/dist/kernel/host-adapter.js +0 -8
- package/dist/kernel/index.d.ts +0 -36
- package/dist/kernel/index.js +0 -34
- package/dist/kernel/kernel.d.ts +0 -9
- package/dist/kernel/kernel.js +0 -1415
- package/dist/kernel/mount-table.d.ts +0 -75
- package/dist/kernel/mount-table.js +0 -353
- package/dist/kernel/permissions.d.ts +0 -36
- package/dist/kernel/permissions.js +0 -150
- package/dist/kernel/pipe-manager.d.ts +0 -64
- package/dist/kernel/pipe-manager.js +0 -267
- package/dist/kernel/proc-backend.d.ts +0 -30
- package/dist/kernel/proc-backend.js +0 -428
- package/dist/kernel/proc-layer.d.ts +0 -11
- package/dist/kernel/proc-layer.js +0 -507
- package/dist/kernel/process-table.d.ts +0 -126
- package/dist/kernel/process-table.js +0 -651
- package/dist/kernel/pty.d.ts +0 -109
- package/dist/kernel/pty.js +0 -552
- package/dist/kernel/socket-table.d.ts +0 -312
- package/dist/kernel/socket-table.js +0 -1188
- package/dist/kernel/timer-table.d.ts +0 -54
- package/dist/kernel/timer-table.js +0 -108
- package/dist/kernel/types.d.ts +0 -541
- package/dist/kernel/types.js +0 -98
- package/dist/kernel/user.d.ts +0 -29
- package/dist/kernel/user.js +0 -35
- package/dist/kernel/vfs.d.ts +0 -82
- package/dist/kernel/vfs.js +0 -25
- package/dist/kernel/wait.d.ts +0 -45
- package/dist/kernel/wait.js +0 -112
- package/dist/kernel/wstatus.d.ts +0 -21
- package/dist/kernel/wstatus.js +0 -33
- package/dist/module-resolver.d.ts +0 -29
- package/dist/module-resolver.js +0 -314
- package/dist/package-bundler.d.ts +0 -41
- package/dist/package-bundler.js +0 -497
- package/dist/runtime-driver.d.ts +0 -66
- package/dist/shared/api-types.d.ts +0 -83
- package/dist/shared/bridge-contract.d.ts +0 -772
- package/dist/shared/bridge-contract.js +0 -169
- package/dist/shared/console-formatter.d.ts +0 -22
- package/dist/shared/console-formatter.js +0 -161
- package/dist/shared/constants.d.ts +0 -3
- package/dist/shared/constants.js +0 -3
- package/dist/shared/errors.d.ts +0 -16
- package/dist/shared/errors.js +0 -21
- package/dist/shared/esm-utils.d.ts +0 -28
- package/dist/shared/esm-utils.js +0 -97
- package/dist/shared/global-exposure.d.ts +0 -38
- package/dist/shared/global-exposure.js +0 -876
- package/dist/shared/in-memory-fs.d.ts +0 -16
- package/dist/shared/in-memory-fs.js +0 -115
- package/dist/shared/permissions.d.ts +0 -36
- package/dist/shared/permissions.js +0 -314
- package/dist/shared/require-setup.d.ts +0 -6
- package/dist/shared/require-setup.js +0 -9
- package/dist/test/block-store-conformance.d.ts +0 -34
- package/dist/test/block-store-conformance.js +0 -251
- package/dist/test/metadata-store-conformance.d.ts +0 -37
- package/dist/test/metadata-store-conformance.js +0 -646
- package/dist/test/vfs-conformance.d.ts +0 -65
- package/dist/test/vfs-conformance.js +0 -842
- package/dist/types.d.ts +0 -98
- package/dist/types.js +0 -6
- package/dist/vfs/chunked-vfs.d.ts +0 -66
- package/dist/vfs/chunked-vfs.js +0 -1290
- package/dist/vfs/host-block-store.d.ts +0 -19
- package/dist/vfs/host-block-store.js +0 -97
- package/dist/vfs/memory-block-store.d.ts +0 -16
- package/dist/vfs/memory-block-store.js +0 -45
- package/dist/vfs/memory-metadata.d.ts +0 -75
- package/dist/vfs/memory-metadata.js +0 -528
- package/dist/vfs/sqlite-metadata.d.ts +0 -91
- package/dist/vfs/sqlite-metadata.js +0 -582
- package/dist/vfs/types.d.ts +0 -210
- package/dist/vfs/types.js +0 -8
- /package/dist/{runtime-driver.js → generated/CreateVmConfig.js} +0 -0
- /package/dist/{shared/api-types.js → generated/FsPermissionRule.js} +0 -0
package/dist/kernel/types.d.ts
DELETED
|
@@ -1,541 +0,0 @@
|
|
|
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
|
-
import type { WaitQueue } from "./wait.js";
|
|
8
|
-
export type { VirtualFileSystem, VirtualDirEntry, VirtualStat, } from "./vfs.js";
|
|
9
|
-
/**
|
|
10
|
-
* Minimal structured logger interface for kernel diagnostics.
|
|
11
|
-
* Compatible with pino and any logger that supports child loggers.
|
|
12
|
-
* The kernel never depends on pino directly — embedders pass their own logger.
|
|
13
|
-
*/
|
|
14
|
-
export interface KernelLogger {
|
|
15
|
-
trace(obj: Record<string, unknown>, msg?: string): void;
|
|
16
|
-
debug(obj: Record<string, unknown>, msg?: string): void;
|
|
17
|
-
info(obj: Record<string, unknown>, msg?: string): void;
|
|
18
|
-
warn(obj: Record<string, unknown>, msg?: string): void;
|
|
19
|
-
error(obj: Record<string, unknown>, msg?: string): void;
|
|
20
|
-
child(bindings: Record<string, unknown>): KernelLogger;
|
|
21
|
-
}
|
|
22
|
-
/** No-op logger that discards all records. */
|
|
23
|
-
export declare const noopKernelLogger: KernelLogger;
|
|
24
|
-
/** A filesystem to mount at a specific path inside the kernel VFS. */
|
|
25
|
-
export interface FsMount {
|
|
26
|
-
path: string;
|
|
27
|
-
fs: import("./vfs.js").VirtualFileSystem;
|
|
28
|
-
readOnly?: boolean;
|
|
29
|
-
}
|
|
30
|
-
export interface KernelOptions {
|
|
31
|
-
filesystem: import("./vfs.js").VirtualFileSystem;
|
|
32
|
-
permissions?: Permissions;
|
|
33
|
-
env?: Record<string, string>;
|
|
34
|
-
cwd?: string;
|
|
35
|
-
/** Maximum number of concurrent processes. Spawn beyond this limit throws EAGAIN. */
|
|
36
|
-
maxProcesses?: number;
|
|
37
|
-
/** Host network adapter for external socket routing (TCP, UDP, DNS). */
|
|
38
|
-
hostNetworkAdapter?: import("./host-adapter.js").HostNetworkAdapter;
|
|
39
|
-
/** Structured debug logger for kernel diagnostics. Defaults to silent no-op. */
|
|
40
|
-
logger?: KernelLogger;
|
|
41
|
-
/** Additional filesystems to mount at boot (after /dev and /proc). */
|
|
42
|
-
mounts?: FsMount[];
|
|
43
|
-
}
|
|
44
|
-
export interface Kernel {
|
|
45
|
-
/** Mount a runtime driver. Calls driver.init() and registers its commands. */
|
|
46
|
-
mount(driver: RuntimeDriver): Promise<void>;
|
|
47
|
-
/** Dispose the kernel and all mounted drivers. */
|
|
48
|
-
dispose(): Promise<void>;
|
|
49
|
-
/**
|
|
50
|
-
* Execute a command string through the shell.
|
|
51
|
-
* Equivalent to: spawn('sh', ['-c', command])
|
|
52
|
-
* Throws if no shell is mounted (e.g. no WasmVM runtime).
|
|
53
|
-
*/
|
|
54
|
-
exec(command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
55
|
-
/**
|
|
56
|
-
* Spawn a process directly (no shell interpretation).
|
|
57
|
-
* The kernel resolves the command via the command registry and delegates
|
|
58
|
-
* to the appropriate runtime driver.
|
|
59
|
-
*/
|
|
60
|
-
spawn(command: string, args: string[], options?: SpawnOptions): ManagedProcess;
|
|
61
|
-
/**
|
|
62
|
-
* Flush pending /bin stub entries created by on-demand command discovery.
|
|
63
|
-
* Ensures VFS is consistent before shell PATH lookups.
|
|
64
|
-
*/
|
|
65
|
-
flushPendingBinEntries(): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Open an interactive shell on a PTY.
|
|
68
|
-
* Wires PTY + process groups + termios for terminal use.
|
|
69
|
-
*/
|
|
70
|
-
openShell(options?: OpenShellOptions): ShellHandle;
|
|
71
|
-
/**
|
|
72
|
-
* Wire openShell() to process.stdin/stdout for an interactive terminal session.
|
|
73
|
-
* Sets raw mode, forwards input/output, handles resize, restores terminal on exit.
|
|
74
|
-
* Returns the shell exit code.
|
|
75
|
-
*/
|
|
76
|
-
connectTerminal(options?: ConnectTerminalOptions): Promise<number>;
|
|
77
|
-
/** Mount a filesystem at the given path. */
|
|
78
|
-
mountFs(path: string, fs: import("./vfs.js").VirtualFileSystem, options?: {
|
|
79
|
-
readOnly?: boolean;
|
|
80
|
-
}): void;
|
|
81
|
-
/** Unmount the filesystem at the given path. */
|
|
82
|
-
unmountFs(path: string): void;
|
|
83
|
-
readFile(path: string): Promise<Uint8Array>;
|
|
84
|
-
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
85
|
-
mkdir(path: string): Promise<void>;
|
|
86
|
-
readdir(path: string): Promise<string[]>;
|
|
87
|
-
stat(path: string): Promise<import("./vfs.js").VirtualStat>;
|
|
88
|
-
exists(path: string): Promise<boolean>;
|
|
89
|
-
removeFile(path: string): Promise<void>;
|
|
90
|
-
removeDir(path: string): Promise<void>;
|
|
91
|
-
rename(oldPath: string, newPath: string): Promise<void>;
|
|
92
|
-
readonly socketTable: import("./socket-table.js").SocketTable;
|
|
93
|
-
readonly timerTable: import("./timer-table.js").TimerTable;
|
|
94
|
-
readonly commands: ReadonlyMap<string, string>;
|
|
95
|
-
readonly processes: ReadonlyMap<number, ProcessInfo>;
|
|
96
|
-
/** Number of pending zombie cleanup timers (test observability). */
|
|
97
|
-
readonly zombieTimerCount: number;
|
|
98
|
-
}
|
|
99
|
-
export interface ExecOptions {
|
|
100
|
-
env?: Record<string, string>;
|
|
101
|
-
cwd?: string;
|
|
102
|
-
stdin?: string | Uint8Array;
|
|
103
|
-
timeout?: number;
|
|
104
|
-
onStdout?: (data: Uint8Array) => void;
|
|
105
|
-
onStderr?: (data: Uint8Array) => void;
|
|
106
|
-
}
|
|
107
|
-
export interface ExecResult {
|
|
108
|
-
exitCode: number;
|
|
109
|
-
stdout: string;
|
|
110
|
-
stderr: string;
|
|
111
|
-
}
|
|
112
|
-
export interface SpawnOptions extends ExecOptions {
|
|
113
|
-
stdio?: "pipe" | "inherit";
|
|
114
|
-
/** FD in caller's table to wire as child's stdin (pipe read end). */
|
|
115
|
-
stdinFd?: number;
|
|
116
|
-
/** FD in caller's table to wire as child's stdout (pipe write end). */
|
|
117
|
-
stdoutFd?: number;
|
|
118
|
-
/** FD in caller's table to wire as child's stderr (pipe write end). */
|
|
119
|
-
stderrFd?: number;
|
|
120
|
-
/** Enable streaming stdin: writeStdin() delivers data immediately instead of buffering until closeStdin(). */
|
|
121
|
-
streamStdin?: boolean;
|
|
122
|
-
}
|
|
123
|
-
export interface ManagedProcess {
|
|
124
|
-
pid: number;
|
|
125
|
-
writeStdin(data: Uint8Array | string): void;
|
|
126
|
-
closeStdin(): void;
|
|
127
|
-
kill(signal?: number): void;
|
|
128
|
-
wait(): Promise<number>;
|
|
129
|
-
readonly exitCode: number | null;
|
|
130
|
-
}
|
|
131
|
-
export interface OpenShellOptions {
|
|
132
|
-
/** Shell command to run (default: "sh"). */
|
|
133
|
-
command?: string;
|
|
134
|
-
/** Arguments to pass to the shell command. */
|
|
135
|
-
args?: string[];
|
|
136
|
-
/** Environment variables for the shell process. */
|
|
137
|
-
env?: Record<string, string>;
|
|
138
|
-
/** Working directory for the shell process. */
|
|
139
|
-
cwd?: string;
|
|
140
|
-
/** Initial terminal columns. */
|
|
141
|
-
cols?: number;
|
|
142
|
-
/** Initial terminal rows. */
|
|
143
|
-
rows?: number;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Handle returned by kernel.openShell().
|
|
147
|
-
* Provides write/onData/resize/kill/wait for interactive shell use.
|
|
148
|
-
*/
|
|
149
|
-
export interface ShellHandle {
|
|
150
|
-
/** PID of the shell process. */
|
|
151
|
-
pid: number;
|
|
152
|
-
/** Write data to the shell (goes through PTY line discipline). */
|
|
153
|
-
write(data: Uint8Array | string): void;
|
|
154
|
-
/** Callback for data produced by the shell (program output). */
|
|
155
|
-
onData: ((data: Uint8Array) => void) | null;
|
|
156
|
-
/** Notify terminal resize — delivers SIGWINCH to foreground process group. */
|
|
157
|
-
resize(cols: number, rows: number): void;
|
|
158
|
-
/** Kill the shell process. */
|
|
159
|
-
kill(signal?: number): void;
|
|
160
|
-
/** Wait for the shell to exit. Returns exit code. */
|
|
161
|
-
wait(): Promise<number>;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Options for connectTerminal().
|
|
165
|
-
* Extends OpenShellOptions with an optional output handler override.
|
|
166
|
-
*/
|
|
167
|
-
export interface ConnectTerminalOptions extends OpenShellOptions {
|
|
168
|
-
/** Custom output handler. Defaults to writing to process.stdout. */
|
|
169
|
-
onData?: (data: Uint8Array) => void;
|
|
170
|
-
}
|
|
171
|
-
export interface RuntimeDriver {
|
|
172
|
-
/** Driver name (e.g. 'wasmvm', 'node', 'python') */
|
|
173
|
-
name: string;
|
|
174
|
-
/** Commands this driver handles */
|
|
175
|
-
commands: string[];
|
|
176
|
-
/**
|
|
177
|
-
* Called when the driver is mounted to the kernel.
|
|
178
|
-
* Use this to initialize resources (compile WASM, load Pyodide, etc.)
|
|
179
|
-
*/
|
|
180
|
-
init(kernel: KernelInterface): Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* Spawn a process for the given command.
|
|
183
|
-
* The kernel has already resolved the command to this driver.
|
|
184
|
-
*/
|
|
185
|
-
spawn(command: string, args: string[], ctx: ProcessContext): DriverProcess;
|
|
186
|
-
/**
|
|
187
|
-
* On-demand command discovery. Called by the kernel when a command is not
|
|
188
|
-
* found in the registry. Returns true if this driver can handle the command
|
|
189
|
-
* (e.g. found a matching WASM binary on disk). The kernel then registers
|
|
190
|
-
* the command and retries the spawn.
|
|
191
|
-
*/
|
|
192
|
-
tryResolve?(command: string): boolean;
|
|
193
|
-
/** Cleanup resources */
|
|
194
|
-
dispose(): Promise<void>;
|
|
195
|
-
}
|
|
196
|
-
export interface ProcessContext {
|
|
197
|
-
pid: number;
|
|
198
|
-
ppid: number;
|
|
199
|
-
env: Record<string, string>;
|
|
200
|
-
cwd: string;
|
|
201
|
-
fds: {
|
|
202
|
-
stdin: number;
|
|
203
|
-
stdout: number;
|
|
204
|
-
stderr: number;
|
|
205
|
-
};
|
|
206
|
-
/** Whether stdin/stdout/stderr are connected to a PTY slave. */
|
|
207
|
-
stdinIsTTY?: boolean;
|
|
208
|
-
stdoutIsTTY?: boolean;
|
|
209
|
-
stderrIsTTY?: boolean;
|
|
210
|
-
/** Enable streaming stdin delivery (writeStdin data arrives immediately). */
|
|
211
|
-
streamStdin?: boolean;
|
|
212
|
-
/** Kernel-provided callback for stdout data emitted during spawn. */
|
|
213
|
-
onStdout?: (data: Uint8Array) => void;
|
|
214
|
-
/** Kernel-provided callback for stderr data emitted during spawn. */
|
|
215
|
-
onStderr?: (data: Uint8Array) => void;
|
|
216
|
-
}
|
|
217
|
-
export interface DriverProcess {
|
|
218
|
-
/** Called by kernel when data is written to this process's stdin FD */
|
|
219
|
-
writeStdin(data: Uint8Array): void;
|
|
220
|
-
closeStdin(): void;
|
|
221
|
-
/** Called by kernel to terminate the process */
|
|
222
|
-
kill(signal: number): void;
|
|
223
|
-
/** Resolves with exit code when process completes */
|
|
224
|
-
wait(): Promise<number>;
|
|
225
|
-
/** Callbacks for the driver to push data to the kernel */
|
|
226
|
-
onStdout: ((data: Uint8Array) => void) | null;
|
|
227
|
-
onStderr: ((data: Uint8Array) => void) | null;
|
|
228
|
-
onExit: ((code: number) => void) | null;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Interface the kernel exposes TO drivers.
|
|
232
|
-
* Drivers call these methods for kernel services.
|
|
233
|
-
*/
|
|
234
|
-
export interface KernelInterface {
|
|
235
|
-
vfs: import("./vfs.js").VirtualFileSystem;
|
|
236
|
-
fdOpen(pid: number, path: string, flags: number, mode?: number): number;
|
|
237
|
-
fdRead(pid: number, fd: number, length: number): Promise<Uint8Array>;
|
|
238
|
-
fdWrite(pid: number, fd: number, data: Uint8Array): number | Promise<number>;
|
|
239
|
-
fdClose(pid: number, fd: number): void;
|
|
240
|
-
fdSeek(pid: number, fd: number, offset: bigint, whence: number): Promise<bigint>;
|
|
241
|
-
fdPread(pid: number, fd: number, length: number, offset: bigint): Promise<Uint8Array>;
|
|
242
|
-
fdPwrite(pid: number, fd: number, data: Uint8Array, offset: bigint): Promise<number>;
|
|
243
|
-
fdDup(pid: number, fd: number): number;
|
|
244
|
-
fdDup2(pid: number, oldFd: number, newFd: number): void;
|
|
245
|
-
fdDupMin(pid: number, fd: number, minFd: number): number;
|
|
246
|
-
fdStat(pid: number, fd: number): FDStat;
|
|
247
|
-
/** Query poll state for a file descriptor (pipe, PTY, or regular file). */
|
|
248
|
-
fdPoll(pid: number, fd: number): {
|
|
249
|
-
readable: boolean;
|
|
250
|
-
writable: boolean;
|
|
251
|
-
hangup: boolean;
|
|
252
|
-
invalid: boolean;
|
|
253
|
-
};
|
|
254
|
-
fdSetCloexec(pid: number, fd: number, value: boolean): void;
|
|
255
|
-
fdGetCloexec(pid: number, fd: number): boolean;
|
|
256
|
-
fcntl(pid: number, fd: number, cmd: number, arg?: number): number;
|
|
257
|
-
/** Apply or remove an advisory lock on the file referenced by fd. */
|
|
258
|
-
flock(pid: number, fd: number, operation: number): Promise<void>;
|
|
259
|
-
spawn(command: string, args: string[], ctx: Partial<ProcessContext> & {
|
|
260
|
-
stdinFd?: number;
|
|
261
|
-
stdoutFd?: number;
|
|
262
|
-
stderrFd?: number;
|
|
263
|
-
}): ManagedProcess;
|
|
264
|
-
waitpid(pid: number, options?: number): Promise<{
|
|
265
|
-
pid: number;
|
|
266
|
-
status: number;
|
|
267
|
-
termSignal: number;
|
|
268
|
-
} | null>;
|
|
269
|
-
kill(pid: number, signal: number): void;
|
|
270
|
-
getpid(pid: number): number;
|
|
271
|
-
getppid(pid: number): number;
|
|
272
|
-
setpgid(pid: number, pgid: number): void;
|
|
273
|
-
getpgid(pid: number): number;
|
|
274
|
-
setsid(pid: number): number;
|
|
275
|
-
getsid(pid: number): number;
|
|
276
|
-
/** Create a pipe and install both ends in the given process's FD table. */
|
|
277
|
-
pipe(pid: number): {
|
|
278
|
-
readFd: number;
|
|
279
|
-
writeFd: number;
|
|
280
|
-
};
|
|
281
|
-
/** Allocate a PTY master/slave pair and install FDs in the process's table. */
|
|
282
|
-
openpty(pid: number): {
|
|
283
|
-
masterFd: number;
|
|
284
|
-
slaveFd: number;
|
|
285
|
-
path: string;
|
|
286
|
-
};
|
|
287
|
-
/** Check if an FD refers to a terminal (PTY slave). */
|
|
288
|
-
isatty(pid: number, fd: number): boolean;
|
|
289
|
-
/** Set line discipline configuration on the PTY associated with the given FD. */
|
|
290
|
-
ptySetDiscipline(pid: number, fd: number, config: {
|
|
291
|
-
canonical?: boolean;
|
|
292
|
-
echo?: boolean;
|
|
293
|
-
isig?: boolean;
|
|
294
|
-
}): void;
|
|
295
|
-
/** Set the foreground process group for signal delivery on the PTY. */
|
|
296
|
-
ptySetForegroundPgid(pid: number, fd: number, pgid: number): void;
|
|
297
|
-
/** Get terminal attributes for the PTY associated with the given FD. */
|
|
298
|
-
tcgetattr(pid: number, fd: number): Termios;
|
|
299
|
-
/** Set terminal attributes for the PTY associated with the given FD. */
|
|
300
|
-
tcsetattr(pid: number, fd: number, termios: Partial<Termios>): void;
|
|
301
|
-
/** Set the foreground process group for the terminal. */
|
|
302
|
-
tcsetpgrp(pid: number, fd: number, pgid: number): void;
|
|
303
|
-
/** Get the foreground process group for the terminal. */
|
|
304
|
-
tcgetpgrp(pid: number, fd: number): number;
|
|
305
|
-
/** List open FD numbers for a process (readDir /dev/fd). */
|
|
306
|
-
devFdReadDir(pid: number): string[];
|
|
307
|
-
/** Stat the underlying file for /dev/fd/N. */
|
|
308
|
-
devFdStat(pid: number, fd: number): Promise<import("./vfs.js").VirtualStat>;
|
|
309
|
-
getenv(pid: number): Record<string, string>;
|
|
310
|
-
setenv(pid: number, key: string, value: string): void;
|
|
311
|
-
unsetenv(pid: number, key: string): void;
|
|
312
|
-
getcwd(pid: number): string;
|
|
313
|
-
chdir(pid: number, path: string): Promise<void>;
|
|
314
|
-
/** Schedule SIGALRM delivery after `seconds`. Returns previous alarm remaining (0 if none). alarm(pid, 0) cancels. */
|
|
315
|
-
alarm(pid: number, seconds: number): number;
|
|
316
|
-
/** Get/set the process's umask. Returns the previous mask. If newMask is omitted, mask is unchanged. */
|
|
317
|
-
umask(pid: number, newMask?: number): number;
|
|
318
|
-
/** Create a directory, applying the process's umask to the given mode. */
|
|
319
|
-
mkdir(pid: number, path: string, mode?: number): Promise<void>;
|
|
320
|
-
readonly socketTable: import("./socket-table.js").SocketTable;
|
|
321
|
-
readonly timerTable: import("./timer-table.js").TimerTable;
|
|
322
|
-
readonly processTable: import("./process-table.js").ProcessTable;
|
|
323
|
-
}
|
|
324
|
-
export interface FDStat {
|
|
325
|
-
filetype: number;
|
|
326
|
-
flags: number;
|
|
327
|
-
rights: bigint;
|
|
328
|
-
}
|
|
329
|
-
export interface FileDescription {
|
|
330
|
-
id: number;
|
|
331
|
-
path: string;
|
|
332
|
-
cursor: bigint;
|
|
333
|
-
flags: number;
|
|
334
|
-
refCount: number;
|
|
335
|
-
/** Mode to apply when the file is first created (set by O_CREAT with umask). */
|
|
336
|
-
creationMode?: number;
|
|
337
|
-
}
|
|
338
|
-
export interface FDEntry {
|
|
339
|
-
fd: number;
|
|
340
|
-
description: FileDescription;
|
|
341
|
-
rights: bigint;
|
|
342
|
-
filetype: number;
|
|
343
|
-
/** Close-on-exec flag (FD_CLOEXEC). Per-FD, not per-description. */
|
|
344
|
-
cloexec: boolean;
|
|
345
|
-
}
|
|
346
|
-
export declare const O_RDONLY = 0;
|
|
347
|
-
export declare const O_WRONLY = 1;
|
|
348
|
-
export declare const O_RDWR = 2;
|
|
349
|
-
export declare const O_CREAT = 64;
|
|
350
|
-
export declare const O_EXCL = 128;
|
|
351
|
-
export declare const O_TRUNC = 512;
|
|
352
|
-
export declare const O_APPEND = 1024;
|
|
353
|
-
export declare const O_NONBLOCK = 4;
|
|
354
|
-
export declare const O_CLOEXEC = 524288;
|
|
355
|
-
export declare const F_DUPFD = 0;
|
|
356
|
-
export declare const F_GETFD = 1;
|
|
357
|
-
export declare const F_SETFD = 2;
|
|
358
|
-
export declare const F_GETFL = 3;
|
|
359
|
-
export declare const F_DUPFD_CLOEXEC = 1030;
|
|
360
|
-
export declare const FD_CLOEXEC = 1;
|
|
361
|
-
export declare const SEEK_SET = 0;
|
|
362
|
-
export declare const SEEK_CUR = 1;
|
|
363
|
-
export declare const SEEK_END = 2;
|
|
364
|
-
export declare const FILETYPE_UNKNOWN = 0;
|
|
365
|
-
export declare const FILETYPE_CHARACTER_DEVICE = 2;
|
|
366
|
-
export declare const FILETYPE_DIRECTORY = 3;
|
|
367
|
-
export declare const FILETYPE_REGULAR_FILE = 4;
|
|
368
|
-
export declare const FILETYPE_SYMBOLIC_LINK = 7;
|
|
369
|
-
export declare const FILETYPE_PIPE = 6;
|
|
370
|
-
export interface ProcessEntry {
|
|
371
|
-
pid: number;
|
|
372
|
-
ppid: number;
|
|
373
|
-
/** Process group ID. Defaults to parent's pgid, or pid for session leaders. */
|
|
374
|
-
pgid: number;
|
|
375
|
-
/** Session ID. Defaults to parent's sid, or pid for session leaders. */
|
|
376
|
-
sid: number;
|
|
377
|
-
driver: string;
|
|
378
|
-
command: string;
|
|
379
|
-
args: string[];
|
|
380
|
-
status: "running" | "stopped" | "exited";
|
|
381
|
-
exitCode: number | null;
|
|
382
|
-
/** How the process terminated: 'normal' for exit(), 'signal' for kill(). */
|
|
383
|
-
exitReason: "normal" | "signal" | null;
|
|
384
|
-
/** Signal that killed the process (0 = normal exit). */
|
|
385
|
-
termSignal: number;
|
|
386
|
-
/** Epoch ms when the process was registered. */
|
|
387
|
-
startTime: number;
|
|
388
|
-
exitTime: number | null;
|
|
389
|
-
env: Record<string, string>;
|
|
390
|
-
cwd: string;
|
|
391
|
-
/** File mode creation mask (POSIX umask). Inherited from parent, default 0o022. */
|
|
392
|
-
umask: number;
|
|
393
|
-
/** Active handles tracked for this process (id → description). */
|
|
394
|
-
activeHandles: Map<string, string>;
|
|
395
|
-
/** Maximum number of active handles allowed for this process. 0 = unlimited. */
|
|
396
|
-
handleLimit: number;
|
|
397
|
-
/** Signal handling state: registered handlers, blocked signals, pending signals. */
|
|
398
|
-
signalState: ProcessSignalState;
|
|
399
|
-
driverProcess: DriverProcess;
|
|
400
|
-
}
|
|
401
|
-
export interface ProcessInfo {
|
|
402
|
-
pid: number;
|
|
403
|
-
ppid: number;
|
|
404
|
-
pgid: number;
|
|
405
|
-
sid: number;
|
|
406
|
-
driver: string;
|
|
407
|
-
command: string;
|
|
408
|
-
args: string[];
|
|
409
|
-
cwd: string;
|
|
410
|
-
status: "running" | "stopped" | "exited";
|
|
411
|
-
exitCode: number | null;
|
|
412
|
-
startTime: number;
|
|
413
|
-
exitTime: number | null;
|
|
414
|
-
}
|
|
415
|
-
/** POSIX error codes used by the kernel. */
|
|
416
|
-
export type KernelErrorCode = "EACCES" | "EADDRINUSE" | "EAGAIN" | "EBADF" | "ECONNREFUSED" | "EINPROGRESS" | "EINTR" | "EEXIST" | "EINVAL" | "ELOOP" | "EIO" | "EISDIR" | "EMFILE" | "EMSGSIZE" | "ENOENT" | "ENOSPC" | "ENOSYS" | "ENOTCONN" | "ENOTEMPTY" | "ENOTDIR" | "EPERM" | "EPIPE" | "EROFS" | "ESPIPE" | "ESRCH" | "ETIMEDOUT" | "EXDEV";
|
|
417
|
-
/**
|
|
418
|
-
* Structured error for kernel operations.
|
|
419
|
-
* Carries a machine-readable `code` so callers can map to errno without
|
|
420
|
-
* string matching.
|
|
421
|
-
*/
|
|
422
|
-
export declare class KernelError extends Error {
|
|
423
|
-
readonly code: KernelErrorCode;
|
|
424
|
-
constructor(code: KernelErrorCode, message: string);
|
|
425
|
-
}
|
|
426
|
-
/** Terminal attributes — controls line discipline behavior on a PTY. */
|
|
427
|
-
export interface Termios {
|
|
428
|
-
/** Map CR (0x0d) to NL (0x0a) on input (POSIX ICRNL). */
|
|
429
|
-
icrnl: boolean;
|
|
430
|
-
/** Post-process output (master for ONLCR, etc.). */
|
|
431
|
-
opost: boolean;
|
|
432
|
-
/** Map NL to CR-NL on output (requires opost). */
|
|
433
|
-
onlcr: boolean;
|
|
434
|
-
/** Canonical mode: buffer input until newline, handle backspace. */
|
|
435
|
-
icanon: boolean;
|
|
436
|
-
/** Echo input bytes back through output (master reads them). */
|
|
437
|
-
echo: boolean;
|
|
438
|
-
/** Enable signal generation from control characters (^C, ^Z, ^\). */
|
|
439
|
-
isig: boolean;
|
|
440
|
-
/** Control characters. */
|
|
441
|
-
cc: TermiosCC;
|
|
442
|
-
}
|
|
443
|
-
export interface TermiosCC {
|
|
444
|
-
vintr: number;
|
|
445
|
-
vquit: number;
|
|
446
|
-
vsusp: number;
|
|
447
|
-
veof: number;
|
|
448
|
-
verase: number;
|
|
449
|
-
}
|
|
450
|
-
/** Returns the POSIX-standard default termios: canonical on, echo on, isig on, opost+onlcr on. */
|
|
451
|
-
export declare function defaultTermios(): Termios;
|
|
452
|
-
export declare const SIGHUP = 1;
|
|
453
|
-
export declare const SIGINT = 2;
|
|
454
|
-
export declare const SIGQUIT = 3;
|
|
455
|
-
export declare const SIGKILL = 9;
|
|
456
|
-
export declare const SIGPIPE = 13;
|
|
457
|
-
export declare const SIGALRM = 14;
|
|
458
|
-
export declare const SIGTERM = 15;
|
|
459
|
-
export declare const SIGCHLD = 17;
|
|
460
|
-
export declare const SIGCONT = 18;
|
|
461
|
-
export declare const SIGSTOP = 19;
|
|
462
|
-
export declare const SIGTSTP = 20;
|
|
463
|
-
export declare const SIGWINCH = 28;
|
|
464
|
-
export declare const SA_RESTART = 268435456;
|
|
465
|
-
export declare const SA_RESETHAND = 2147483648;
|
|
466
|
-
export declare const SA_NOCLDSTOP = 1;
|
|
467
|
-
export declare const SIG_BLOCK = 0;
|
|
468
|
-
export declare const SIG_UNBLOCK = 1;
|
|
469
|
-
export declare const SIG_SETMASK = 2;
|
|
470
|
-
export declare const WNOHANG = 1;
|
|
471
|
-
/** Signal disposition: default kernel action, ignore, or user-defined handler. */
|
|
472
|
-
export type SignalDisposition = "default" | "ignore" | ((signal: number) => void);
|
|
473
|
-
/** Per-signal handler registration (matches POSIX struct sigaction). */
|
|
474
|
-
export interface SignalHandler {
|
|
475
|
-
handler: SignalDisposition;
|
|
476
|
-
/** Signals to block during handler execution (sa_mask). */
|
|
477
|
-
mask: Set<number>;
|
|
478
|
-
/** Flags (SA_RESTART, SA_RESETHAND, SA_NOCLDSTOP, etc.). */
|
|
479
|
-
flags: number;
|
|
480
|
-
}
|
|
481
|
-
/** Per-process signal state. */
|
|
482
|
-
export interface ProcessSignalState {
|
|
483
|
-
/** Signal number → registered handler. */
|
|
484
|
-
handlers: Map<number, SignalHandler>;
|
|
485
|
-
/** Currently blocked signals (sigprocmask). */
|
|
486
|
-
blockedSignals: Set<number>;
|
|
487
|
-
/** Signals queued while blocked. Standard signals (1-31) coalesce to max 1. */
|
|
488
|
-
pendingSignals: Set<number>;
|
|
489
|
-
/** Waiters blocked on signal-aware syscalls for this process. */
|
|
490
|
-
signalWaiters: WaitQueue;
|
|
491
|
-
/** Monotonic counter for delivered signals. */
|
|
492
|
-
deliverySeq: number;
|
|
493
|
-
/** Most recently delivered signal number, or null if none. */
|
|
494
|
-
lastDeliveredSignal: number | null;
|
|
495
|
-
/** Flags from the most recently delivered handler registration. */
|
|
496
|
-
lastDeliveredFlags: number;
|
|
497
|
-
}
|
|
498
|
-
export interface Pipe {
|
|
499
|
-
id: number;
|
|
500
|
-
readFd: number;
|
|
501
|
-
writeFd: number;
|
|
502
|
-
readerPid: number;
|
|
503
|
-
writerPid: number;
|
|
504
|
-
buffer: Uint8Array[];
|
|
505
|
-
closed: {
|
|
506
|
-
read: boolean;
|
|
507
|
-
write: boolean;
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
|
-
export interface PermissionDecision {
|
|
511
|
-
allow: boolean;
|
|
512
|
-
reason?: string;
|
|
513
|
-
}
|
|
514
|
-
export type PermissionCheck<T> = (request: T) => PermissionDecision;
|
|
515
|
-
export interface FsAccessRequest {
|
|
516
|
-
op: "read" | "write" | "mkdir" | "createDir" | "readdir" | "stat" | "rm" | "rename" | "exists" | "symlink" | "readlink" | "link" | "chmod" | "chown" | "utimes" | "truncate";
|
|
517
|
-
path: string;
|
|
518
|
-
}
|
|
519
|
-
export interface NetworkAccessRequest {
|
|
520
|
-
op: "fetch" | "http" | "dns" | "listen" | "connect";
|
|
521
|
-
url?: string;
|
|
522
|
-
method?: string;
|
|
523
|
-
hostname?: string;
|
|
524
|
-
}
|
|
525
|
-
export interface ChildProcessAccessRequest {
|
|
526
|
-
command: string;
|
|
527
|
-
args: string[];
|
|
528
|
-
cwd?: string;
|
|
529
|
-
env?: Record<string, string>;
|
|
530
|
-
}
|
|
531
|
-
export interface EnvAccessRequest {
|
|
532
|
-
op: "read" | "write";
|
|
533
|
-
key: string;
|
|
534
|
-
value?: string;
|
|
535
|
-
}
|
|
536
|
-
export interface Permissions {
|
|
537
|
-
fs?: PermissionCheck<FsAccessRequest>;
|
|
538
|
-
network?: PermissionCheck<NetworkAccessRequest>;
|
|
539
|
-
childProcess?: PermissionCheck<ChildProcessAccessRequest>;
|
|
540
|
-
env?: PermissionCheck<EnvAccessRequest>;
|
|
541
|
-
}
|
package/dist/kernel/types.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
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
|
-
/** No-op logger that discards all records. */
|
|
8
|
-
export const noopKernelLogger = {
|
|
9
|
-
trace() { },
|
|
10
|
-
debug() { },
|
|
11
|
-
info() { },
|
|
12
|
-
warn() { },
|
|
13
|
-
error() { },
|
|
14
|
-
child() { return noopKernelLogger; },
|
|
15
|
-
};
|
|
16
|
-
// FD open flags
|
|
17
|
-
export const O_RDONLY = 0;
|
|
18
|
-
export const O_WRONLY = 1;
|
|
19
|
-
export const O_RDWR = 2;
|
|
20
|
-
export const O_CREAT = 0o100;
|
|
21
|
-
export const O_EXCL = 0o200;
|
|
22
|
-
export const O_TRUNC = 0o1000;
|
|
23
|
-
export const O_APPEND = 0o2000;
|
|
24
|
-
export const O_NONBLOCK = 0o4;
|
|
25
|
-
export const O_CLOEXEC = 0o2000000;
|
|
26
|
-
// fcntl commands
|
|
27
|
-
export const F_DUPFD = 0;
|
|
28
|
-
export const F_GETFD = 1;
|
|
29
|
-
export const F_SETFD = 2;
|
|
30
|
-
export const F_GETFL = 3;
|
|
31
|
-
export const F_DUPFD_CLOEXEC = 1030;
|
|
32
|
-
// FD flags (for F_GETFD / F_SETFD)
|
|
33
|
-
export const FD_CLOEXEC = 1;
|
|
34
|
-
// Seek whence
|
|
35
|
-
export const SEEK_SET = 0;
|
|
36
|
-
export const SEEK_CUR = 1;
|
|
37
|
-
export const SEEK_END = 2;
|
|
38
|
-
// File types
|
|
39
|
-
export const FILETYPE_UNKNOWN = 0;
|
|
40
|
-
export const FILETYPE_CHARACTER_DEVICE = 2;
|
|
41
|
-
export const FILETYPE_DIRECTORY = 3;
|
|
42
|
-
export const FILETYPE_REGULAR_FILE = 4;
|
|
43
|
-
export const FILETYPE_SYMBOLIC_LINK = 7;
|
|
44
|
-
export const FILETYPE_PIPE = 6;
|
|
45
|
-
/**
|
|
46
|
-
* Structured error for kernel operations.
|
|
47
|
-
* Carries a machine-readable `code` so callers can map to errno without
|
|
48
|
-
* string matching.
|
|
49
|
-
*/
|
|
50
|
-
export class KernelError extends Error {
|
|
51
|
-
code;
|
|
52
|
-
constructor(code, message) {
|
|
53
|
-
super(`${code}: ${message}`);
|
|
54
|
-
this.code = code;
|
|
55
|
-
this.name = "KernelError";
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
/** Returns the POSIX-standard default termios: canonical on, echo on, isig on, opost+onlcr on. */
|
|
59
|
-
export function defaultTermios() {
|
|
60
|
-
return {
|
|
61
|
-
icrnl: true,
|
|
62
|
-
opost: true,
|
|
63
|
-
onlcr: true,
|
|
64
|
-
icanon: true,
|
|
65
|
-
echo: true,
|
|
66
|
-
isig: true,
|
|
67
|
-
cc: {
|
|
68
|
-
vintr: 0x03, // ^C
|
|
69
|
-
vquit: 0x1c, // ^\
|
|
70
|
-
vsusp: 0x1a, // ^Z
|
|
71
|
-
veof: 0x04, // ^D
|
|
72
|
-
verase: 0x7f, // DEL
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
// Signals
|
|
77
|
-
export const SIGHUP = 1;
|
|
78
|
-
export const SIGINT = 2;
|
|
79
|
-
export const SIGQUIT = 3;
|
|
80
|
-
export const SIGKILL = 9;
|
|
81
|
-
export const SIGPIPE = 13;
|
|
82
|
-
export const SIGALRM = 14;
|
|
83
|
-
export const SIGTERM = 15;
|
|
84
|
-
export const SIGCHLD = 17;
|
|
85
|
-
export const SIGCONT = 18;
|
|
86
|
-
export const SIGSTOP = 19;
|
|
87
|
-
export const SIGTSTP = 20;
|
|
88
|
-
export const SIGWINCH = 28;
|
|
89
|
-
// sigaction flags
|
|
90
|
-
export const SA_RESTART = 0x10000000;
|
|
91
|
-
export const SA_RESETHAND = 0x80000000;
|
|
92
|
-
export const SA_NOCLDSTOP = 0x00000001;
|
|
93
|
-
// sigprocmask how values
|
|
94
|
-
export const SIG_BLOCK = 0;
|
|
95
|
-
export const SIG_UNBLOCK = 1;
|
|
96
|
-
export const SIG_SETMASK = 2;
|
|
97
|
-
// waitpid options (POSIX bitmask)
|
|
98
|
-
export const WNOHANG = 1;
|
package/dist/kernel/user.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
}
|