@ai-ecoverse/slicc-kernel 1.180.0 → 1.181.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.
@@ -3180,7 +3180,7 @@ var init_version = __esm({
3180
3180
  "src/version.ts"() {
3181
3181
  "use strict";
3182
3182
  init_captured_globals();
3183
- KERNEL_VERSION = true ? "1.180.0" : "0.0.0-dev";
3183
+ KERNEL_VERSION = true ? "1.181.0" : "0.0.0-dev";
3184
3184
  OS_RELEASE = "6.0.0-slicc";
3185
3185
  }
3186
3186
  });
@@ -6,6 +6,7 @@ import { type EmbedderHook } from '../kernel/embedder.js';
6
6
  import type { RealmTransport, RealmTransportRequest, RealmTransportResponse, RealmTransportTraits } from '../kernel/net/transport.js';
7
7
  import type { TraceEvent } from '../kernel/trace.js';
8
8
  import type { MountEntry, MountSpec } from '../mount/mount-fs.js';
9
+ import type { SudoReplay } from '../sudo.js';
9
10
  import { type DialledSocket, type DialOptions } from './dial-stream.js';
10
11
  import { type LoopbackFetchOptions } from './loopback-fetch.js';
11
12
  import { type LockManagerLike, type MessagePortLike, type ProcessEntry } from './protocol.js';
@@ -47,6 +48,16 @@ export interface SpawnedProcess {
47
48
  readonly ended: Promise<ClientEnded>;
48
49
  signal(name?: string): Promise<void>;
49
50
  }
51
+ export interface SudoRunOptions {
52
+ stdout?: string;
53
+ stderr?: string;
54
+ tag?: string | readonly string[];
55
+ }
56
+ export interface SudoRun {
57
+ readonly pid: number;
58
+ readonly pgid: number;
59
+ readonly ended: Promise<ClientEnded>;
60
+ }
50
61
  export interface ClientRunOptions {
51
62
  cwd?: string;
52
63
  cwdMissing?: 'create' | 'error';
@@ -145,6 +156,7 @@ export interface KernelClient {
145
156
  trace(tag: string, onEvents: (batch: TraceBatch) => void | Promise<unknown>, options?: TraceOptions): Promise<{
146
157
  close(): void;
147
158
  }>;
159
+ sudoRun(request: SudoReplay, options?: SudoRunOptions): Promise<SudoRun>;
148
160
  close(options?: {
149
161
  kill?: boolean;
150
162
  }): Promise<void>;
@@ -38,6 +38,11 @@ export interface TerminalRequestOptions {
38
38
  rows?: number;
39
39
  tag?: string | readonly string[];
40
40
  }
41
+ export interface SudoRunRequestOptions {
42
+ stdout?: string;
43
+ stderr?: string;
44
+ tag?: string | readonly string[];
45
+ }
41
46
  export type TerminalAction = {
42
47
  action: 'write';
43
48
  bytes: Uint8Array;
@@ -112,6 +117,10 @@ export type ClientCall = {
112
117
  } | {
113
118
  op: 'untrace';
114
119
  trace: number;
120
+ } | {
121
+ op: 'sudo-run';
122
+ replay: unknown;
123
+ options: SudoRunRequestOptions;
115
124
  } | {
116
125
  op: 'detach';
117
126
  kill?: boolean;
@@ -1,4 +1,5 @@
1
1
  import type { CdpHook } from './cdp/types.js';
2
+ import type { SudoRun, SudoRunOptions } from './client/attach.js';
2
3
  import { type DialledSocket, type DialOptions } from './client/dial-stream.js';
3
4
  import { type LoopbackFetchOptions } from './client/loopback-fetch.js';
4
5
  import type { FacadeSpecs } from './facade/types.js';
@@ -14,11 +15,11 @@ import { type NetworkUplink } from './kernel/net/uplink.js';
14
15
  import type { HostfsGrantHook } from './mount/hostfs.js';
15
16
  import type { MountEntry, MountSpec } from './mount/mount-fs.js';
16
17
  import type { ProcessMountPolicy } from './mount/syscall.js';
17
- import type { ApproveHook } from './sudo.js';
18
+ import type { ApproveHook, SudoReplay } from './sudo.js';
18
19
  import { type NetworkTransport } from './transport.js';
19
20
  import type { Account, AddGroup, AddUser, Group, RemoveUser } from './users.js';
20
21
  export type { CdpConnection, CdpHook, CdpRequest } from './cdp/types.js';
21
- export { type AttachOptions, attachKernel, type ClientEnded, type ClientFetchRequest, type ClientFs, type ClientRunOptions, type ClientRunResult, type ClientTerminal, type ClientTerminalOptions, KernelCallError, type KernelClient, KernelGoneError, type ProcessEntry, type SpawnedProcess, type SpawnOptions, type TraceBatch, type TraceEvent, type TraceExec, type TraceExit, type TraceFork, type TraceOptions, type WatchChange, } from './client/attach.js';
22
+ export { type AttachOptions, attachKernel, type ClientEnded, type ClientFetchRequest, type ClientFs, type ClientRunOptions, type ClientRunResult, type ClientTerminal, type ClientTerminalOptions, KernelCallError, type KernelClient, KernelGoneError, type ProcessEntry, type SpawnedProcess, type SpawnOptions, type SudoRun, type SudoRunOptions, type TraceBatch, type TraceEvent, type TraceExec, type TraceExit, type TraceFork, type TraceOptions, type WatchChange, } from './client/attach.js';
22
23
  export type { DialledSocket, DialOptions } from './client/dial-stream.js';
23
24
  export type { LoopbackFetchOptions } from './client/loopback-fetch.js';
24
25
  export type { FacadeConnection, FacadeHook, FacadeInfo, FacadeSpec, FacadeSpecs, } from './facade/types.js';
@@ -45,7 +46,7 @@ export type { JsCred, JsSyncContext, JsSyncFile } from './process/js/js-sync.js'
45
46
  export type { JsThread, JsThreadContext, JsThreadSpawnOptions } from './process/js/js-thread.js';
46
47
  export type { JsTermios, JsTty, JsTtySize } from './process/js/js-tty.js';
47
48
  export type { JsWebSocket, JsWebSocketClose, JsWebSocketMessage, JsWebSocketOptions, } from './process/js/js-websocket.js';
48
- export type { ApproveHook, SudoAnswer, SudoApproval, SudoDenial, SudoFile, SudoReply, SudoRequest, SudoStdin, } from './sudo.js';
49
+ export type { ApproveHook, SudoAnswer, SudoApproval, SudoDenial, SudoFile, SudoReplay, SudoReply, SudoRequest, SudoStdin, } from './sudo.js';
49
50
  export { type FetchTransportOptions, fetchTransport, type HeaderList, type NetworkExit, type NetworkRedirectPolicy, type NetworkRequest, type NetworkResponse, type NetworkTraits, type NetworkTransport, type NetworkWebSocket, type NetworkWebSocketRequest, } from './transport.js';
50
51
  export type { Account, AddGroup, AddUser, Group, RemoveUser } from './users.js';
51
52
  export interface NetworkOptions {
@@ -130,6 +131,7 @@ export interface Kernel {
130
131
  run(argv: string[], options?: RunOptions): Promise<RunResult>;
131
132
  openTerminal(argv: string[], options?: TerminalOptions): Promise<Terminal>;
132
133
  connect(options?: ConnectOptions): Promise<MessagePort>;
134
+ sudoRun(request: SudoReplay, options?: SudoRunOptions): Promise<SudoRun>;
133
135
  readonly users: KernelUsers;
134
136
  readonly groups: KernelGroups;
135
137
  setRoutes(routes: RouteTable): Promise<void>;
@@ -67,7 +67,8 @@ export declare class SpawnError extends Error {
67
67
  }
68
68
  export declare class ChangedError extends SpawnError {
69
69
  readonly notice: string;
70
- constructor(notice: string);
70
+ readonly file: string;
71
+ constructor(notice: string, file: string);
71
72
  }
72
73
  export interface SpawnGrant {
73
74
  cred: Cred;
@@ -164,6 +164,25 @@ interface Target {
164
164
  copy?: string;
165
165
  shim?: string;
166
166
  }
167
+ export declare function sudoFailure(errno: string, message: string): Error & {
168
+ code: string;
169
+ };
170
+ export interface SudoRunRequest {
171
+ stdout?: unknown;
172
+ stderr?: unknown;
173
+ tag?: unknown;
174
+ base?: string | undefined;
175
+ session?: number | undefined;
176
+ }
177
+ export interface SudoRunning {
178
+ pid: number;
179
+ ended: Promise<{
180
+ status: number;
181
+ signal?: number;
182
+ }>;
183
+ }
184
+ export declare const MAX_SPAWN_TAGS = 8;
185
+ export declare function tagList(value: unknown): readonly string[];
167
186
  export declare function tagOption(tag: unknown): void;
168
187
  export type CwdMissing = 'create' | 'error';
169
188
  export declare function cwdMissingOption(value: unknown): CwdMissing;
@@ -512,5 +531,8 @@ export declare class Launcher {
512
531
  private starting;
513
532
  openTerminal(argv: string[], options: TerminalOptions): Promise<TerminalSession>;
514
533
  run(argv: string[], options?: RunOptions): Promise<RunResult>;
534
+ sudoRun(replay: unknown, options?: SudoRunRequest): Promise<SudoRunning>;
535
+ private sudoOutputs;
536
+ private sudoOutput;
515
537
  }
516
538
  export type { ProcessInfo, ProcessListing } from './kernel/proc-info.js';
@@ -1,5 +1,6 @@
1
1
  import { type MessagePort, type Worker } from 'node:worker_threads';
2
2
  import type { CdpHook } from './cdp/types.js';
3
+ import type { SudoRun, SudoRunOptions } from './client/attach.js';
3
4
  import { type CronClock } from './cron/clock.js';
4
5
  import type { FacadeSpecs } from './facade/types.js';
5
6
  import type { Attestation, AttestTombstone } from './fs/attest.js';
@@ -17,10 +18,10 @@ import type { MountEntry, MountSpec } from './mount/mount-fs.js';
17
18
  import type { ProcessMountPolicy } from './mount/syscall.js';
18
19
  import { type HostLoopback } from './node/loopback.js';
19
20
  import { memoryRoot } from './node/memory-root.js';
20
- import type { ApproveHook } from './sudo.js';
21
+ import type { ApproveHook, SudoReplay } from './sudo.js';
21
22
  import { type NetworkTransport } from './transport.js';
22
23
  export type { CdpConnection, CdpHook, CdpRequest } from './cdp/types.js';
23
- export { type AttachOptions, attachKernel, type ClientEnded, type ClientFetchRequest, type ClientFs, type ClientRunOptions, type ClientRunResult, type ClientTerminal, type ClientTerminalOptions, KernelCallError, type KernelClient, KernelGoneError, type ProcessEntry, type SpawnedProcess, type SpawnOptions, type TraceBatch, type TraceEvent, type TraceExec, type TraceExit, type TraceFork, type TraceOptions, type WatchChange, } from './client/attach.js';
24
+ export { type AttachOptions, attachKernel, type ClientEnded, type ClientFetchRequest, type ClientFs, type ClientRunOptions, type ClientRunResult, type ClientTerminal, type ClientTerminalOptions, KernelCallError, type KernelClient, KernelGoneError, type ProcessEntry, type SpawnedProcess, type SpawnOptions, type SudoRun, type SudoRunOptions, type TraceBatch, type TraceEvent, type TraceExec, type TraceExit, type TraceFork, type TraceOptions, type WatchChange, } from './client/attach.js';
24
25
  export type { FacadeConnection, FacadeHook, FacadeInfo, FacadeSpec, FacadeSpecs, } from './facade/types.js';
25
26
  export type { Attestation, AttestedDir, AttestOptions, AttestTombstone } from './fs/attest.js';
26
27
  export type { Denial, DenialHook } from './fs/dac.js';
@@ -34,7 +35,7 @@ export type { ConnectorStamp } from './kernel/socket.js';
34
35
  export type { HostfsEvent, HostfsGrant, HostfsGrantHook, HostfsPortGrant, HostfsTransport, } from './mount/hostfs.js';
35
36
  export { serveHostfsPort } from './mount/hostfs.js';
36
37
  export type { MountEntry, MountSpec } from './mount/mount-fs.js';
37
- export type { ApproveHook, SudoAnswer, SudoApproval, SudoDenial, SudoFile, SudoReply, SudoRequest, SudoStdin, } from './sudo.js';
38
+ export type { ApproveHook, SudoAnswer, SudoApproval, SudoDenial, SudoFile, SudoReplay, SudoReply, SudoRequest, SudoStdin, } from './sudo.js';
38
39
  export type { NetworkRedirectPolicy } from './transport.js';
39
40
  export { fetchTransport, type NetworkTransport } from './transport.js';
40
41
  export { memoryRoot };
@@ -100,6 +101,7 @@ export interface NodeKernel {
100
101
  absent: 'allow';
101
102
  }): Promise<Attestation | AttestTombstone>;
102
103
  connect(options?: ConnectOptions): Promise<MessagePort>;
104
+ sudoRun(request: SudoReplay, options?: SudoRunOptions): Promise<SudoRun>;
103
105
  readonly users: KernelUsers;
104
106
  readonly groups: KernelGroups;
105
107
  setRoutes(routes: RouteTable): Promise<void>;
@@ -69,6 +69,16 @@ export interface OpenTerminalRequest {
69
69
  argv: string[];
70
70
  options: Omit<TerminalOptions, 'onData'>;
71
71
  }
72
+ export interface SudoRunKernelRequest {
73
+ id: number;
74
+ op: 'sudo-run';
75
+ replay: unknown;
76
+ options: {
77
+ stdout?: string;
78
+ stderr?: string;
79
+ tag?: string | readonly string[];
80
+ };
81
+ }
72
82
  export type TerminalAction = {
73
83
  action: 'write';
74
84
  bytes: Uint8Array;
@@ -186,7 +196,7 @@ export type KernelRequest = {
186
196
  id: number;
187
197
  op: 'sealed-placeholders';
188
198
  list: readonly string[];
189
- } | AttestRequest | InitRequest | RunRequest | OpenTerminalRequest | TerminalRequest | ConnectRequest | UsersRequest | MountRequest | DialRequest | RoutesRequest | TraitsRequest;
199
+ } | AttestRequest | InitRequest | RunRequest | OpenTerminalRequest | SudoRunKernelRequest | TerminalRequest | ConnectRequest | UsersRequest | MountRequest | DialRequest | RoutesRequest | TraitsRequest;
190
200
  type WithoutId<T> = T extends unknown ? Omit<T, 'id'> : never;
191
201
  export type KernelCall = WithoutId<KernelRequest>;
192
202
  export declare function inOpfs(deps: ServeDeps, root: FileSystemDirectoryHandle): Promise<boolean>;
@@ -1,12 +1,13 @@
1
1
  import type { KernelFs, UsersMode } from './fs/types.js';
2
2
  import type { Cred } from './kernel/cred.js';
3
3
  import { type TimestampOwner } from './sudo-timestamp.js';
4
- import { type UserDb } from './users.js';
4
+ import { type Account, type UserDb } from './users.js';
5
5
  export { SUDOERS, SUDOERS_D } from './sudoers.js';
6
6
  export declare const SECURE_PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
7
7
  export declare const DEFAULT_SUDOERS = "%sudo Cmnd *\n";
8
8
  export declare const SUDO_TIMEOUT_MS = 300000;
9
9
  export declare function changedText(file: string): string;
10
+ export declare function requestedText(file: string): string;
10
11
  export declare function changedFile(approved: Readonly<Record<string, string>>, now: Readonly<Record<string, string>>): string | undefined;
11
12
  export interface SudoRequest {
12
13
  id: string;
@@ -34,6 +35,13 @@ export interface SudoFile {
34
35
  path: string;
35
36
  sha256: string;
36
37
  }
38
+ export type SudoReplay = Pick<SudoRequest, 'id' | 'user' | 'uid' | 'target' | 'argv' | 'path' | 'cwd' | 'stdin' | 'rootOnly' | 'userWritable' | 'tag' | 'tags' | 'validate'>;
39
+ export interface SudoReplayed {
40
+ grant: SudoGrant;
41
+ caller: Account;
42
+ target: Account;
43
+ tags: readonly string[];
44
+ }
37
45
  export type SudoStdin = 'tty' | 'none' | 'pipe' | 'file';
38
46
  export type SudoAnswer = 'once' | 'always' | 'deny';
39
47
  export interface SudoDenial {
@@ -98,6 +106,10 @@ export interface VisudoResult {
98
106
  ok: boolean;
99
107
  }
100
108
  export declare function visudoCall(req: Partial<VisudoCall>): VisudoCall | undefined;
109
+ type Failure = {
110
+ error: string;
111
+ errno: string;
112
+ };
101
113
  export interface SudoOptions {
102
114
  fs: KernelFs;
103
115
  users: UserDb;
@@ -139,6 +151,8 @@ export declare class Sudo {
139
151
  private writable;
140
152
  private locate;
141
153
  request(caller: SudoCaller, call: SudoCall, signal: AbortSignal): Promise<SudoResult>;
154
+ replay(value: unknown): Promise<SudoReplayed | Failure>;
155
+ private mayAsk;
142
156
  private command;
143
157
  private validate;
144
158
  private pendingFor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-kernel",
3
- "version": "1.180.0",
3
+ "version": "1.181.0",
4
4
  "description": "SLICC's wasm-realm kernel: run Emscripten programs in the browser against OPFS, with fork, spawn, pipes and waitpid",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",