@ai-ecoverse/slicc-kernel 1.178.4 → 1.180.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.178.4" : "0.0.0-dev";
3183
+ KERNEL_VERSION = true ? "1.180.0" : "0.0.0-dev";
3184
3184
  OS_RELEASE = "6.0.0-slicc";
3185
3185
  }
3186
3186
  });
@@ -4,11 +4,13 @@ import type { FsStat, UsersMode } from '../fs/types.js';
4
4
  import type { WatchChange } from '../fs/watch.js';
5
5
  import { type EmbedderHook } from '../kernel/embedder.js';
6
6
  import type { RealmTransport, RealmTransportRequest, RealmTransportResponse, RealmTransportTraits } from '../kernel/net/transport.js';
7
+ import type { TraceEvent } from '../kernel/trace.js';
7
8
  import type { MountEntry, MountSpec } from '../mount/mount-fs.js';
8
9
  import { type DialledSocket, type DialOptions } from './dial-stream.js';
9
10
  import { type LoopbackFetchOptions } from './loopback-fetch.js';
10
11
  import { type LockManagerLike, type MessagePortLike, type ProcessEntry } from './protocol.js';
11
12
  export type { WatchChange } from '../fs/watch.js';
13
+ export type { TraceEvent, TraceExec, TraceExit, TraceFork } from '../kernel/trace.js';
12
14
  export type { ProcessEntry } from './protocol.js';
13
15
  export declare class KernelGoneError extends Error {
14
16
  constructor(message?: string);
@@ -24,12 +26,13 @@ export interface AttachOptions {
24
26
  }
25
27
  export interface SpawnOptions {
26
28
  cwd?: string;
29
+ cwdMissing?: 'create' | 'error';
27
30
  user?: string | number;
28
31
  env?: Record<string, string>;
29
32
  stdin?: string | Uint8Array;
30
33
  group?: 'new';
31
34
  pgid?: number;
32
- tag?: string;
35
+ tag?: string | readonly string[];
33
36
  onStdout?: (bytes: Uint8Array) => void;
34
37
  onStderr?: (bytes: Uint8Array) => void;
35
38
  }
@@ -46,10 +49,11 @@ export interface SpawnedProcess {
46
49
  }
47
50
  export interface ClientRunOptions {
48
51
  cwd?: string;
52
+ cwdMissing?: 'create' | 'error';
49
53
  user?: string | number;
50
54
  env?: Record<string, string>;
51
55
  stdin?: string | Uint8Array;
52
- tag?: string;
56
+ tag?: string | readonly string[];
53
57
  onStdout?: (text: string) => void;
54
58
  onStderr?: (text: string) => void;
55
59
  }
@@ -62,11 +66,12 @@ export interface ClientRunResult {
62
66
  }
63
67
  export interface ClientTerminalOptions {
64
68
  cwd?: string;
69
+ cwdMissing?: 'create' | 'error';
65
70
  user?: string | number;
66
71
  env?: Record<string, string>;
67
72
  cols?: number;
68
73
  rows?: number;
69
- tag?: string;
74
+ tag?: string | readonly string[];
70
75
  onData?: (bytes: Uint8Array) => void;
71
76
  }
72
77
  export interface ClientTerminal {
@@ -101,6 +106,13 @@ export interface ClientFs {
101
106
  close(): void;
102
107
  }>;
103
108
  }
109
+ export interface TraceBatch {
110
+ events: TraceEvent[];
111
+ dropped: number;
112
+ }
113
+ export interface TraceOptions {
114
+ limit?: number;
115
+ }
104
116
  export type ClientFetchRequest = Omit<RealmTransportRequest, 'signal'> & {
105
117
  signal?: AbortSignal;
106
118
  };
@@ -130,6 +142,9 @@ export interface KernelClient {
130
142
  close(): void;
131
143
  }>;
132
144
  onTraits(listener: (traits: RealmTransportTraits) => void): () => void;
145
+ trace(tag: string, onEvents: (batch: TraceBatch) => void | Promise<unknown>, options?: TraceOptions): Promise<{
146
+ close(): void;
147
+ }>;
133
148
  close(options?: {
134
149
  kill?: boolean;
135
150
  }): Promise<void>;
@@ -2,6 +2,7 @@ import type { UsersMode } from '../fs/types.js';
2
2
  import type { WatchChange } from '../fs/watch.js';
3
3
  import type { TransportCall, TransportReply } from '../kernel/net/remote-transport.js';
4
4
  import type { RealmTransportTraits } from '../kernel/net/transport.js';
5
+ import type { TraceEvent } from '../kernel/trace.js';
5
6
  import type { MountSpec } from '../mount/mount-fs.js';
6
7
  export declare const PROTOCOL: readonly [number, number];
7
8
  export interface ClientHello {
@@ -21,19 +22,21 @@ export interface KernelHello {
21
22
  }
22
23
  export interface SpawnRequestOptions {
23
24
  cwd?: string;
25
+ cwdMissing?: 'create' | 'error';
24
26
  user?: string | number;
25
27
  env?: Record<string, string>;
26
28
  stdin?: Uint8Array;
27
29
  pgid?: number;
28
- tag?: string;
30
+ tag?: string | readonly string[];
29
31
  }
30
32
  export interface TerminalRequestOptions {
31
33
  cwd?: string;
34
+ cwdMissing?: 'create' | 'error';
32
35
  user?: string | number;
33
36
  env?: Record<string, string>;
34
37
  cols?: number;
35
38
  rows?: number;
36
- tag?: string;
39
+ tag?: string | readonly string[];
37
40
  }
38
41
  export type TerminalAction = {
39
42
  action: 'write';
@@ -102,6 +105,13 @@ export type ClientCall = {
102
105
  } | {
103
106
  op: 'unserve-facade';
104
107
  registration: number;
108
+ } | {
109
+ op: 'trace';
110
+ tag: string;
111
+ limit?: number;
112
+ } | {
113
+ op: 'untrace';
114
+ trace: number;
105
115
  } | {
106
116
  op: 'detach';
107
117
  kill?: boolean;
@@ -119,16 +129,24 @@ export interface ClientReply {
119
129
  started?: number;
120
130
  signal?: string;
121
131
  }
132
+ export interface TraceAck {
133
+ traceAck: number;
134
+ }
122
135
  export type ClientMessage = {
123
136
  hello: ClientHello;
124
- } | ClientRequest | TransportCall;
137
+ } | ClientRequest | TransportCall | TraceAck;
125
138
  export interface WatchEvent {
126
139
  watch: number;
127
140
  change: WatchChange;
128
141
  }
142
+ export interface TraceMessage {
143
+ trace: number;
144
+ events: TraceEvent[];
145
+ dropped?: number;
146
+ }
129
147
  export type KernelMessage = {
130
148
  hello: KernelHello;
131
- } | ClientReply | WatchEvent | TransportReply;
149
+ } | ClientReply | WatchEvent | TraceMessage | TransportReply;
132
150
  export interface ProcessEntry {
133
151
  pid: number;
134
152
  ppid: number;
@@ -18,7 +18,7 @@ import type { ApproveHook } from './sudo.js';
18
18
  import { type NetworkTransport } from './transport.js';
19
19
  import type { Account, AddGroup, AddUser, Group, RemoveUser } from './users.js';
20
20
  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 WatchChange, } from './client/attach.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
22
  export type { DialledSocket, DialOptions } from './client/dial-stream.js';
23
23
  export type { LoopbackFetchOptions } from './client/loopback-fetch.js';
24
24
  export type { FacadeConnection, FacadeHook, FacadeInfo, FacadeSpec, FacadeSpecs, } from './facade/types.js';
@@ -86,8 +86,10 @@ export interface MountPending {
86
86
  source: string;
87
87
  insert(): Promise<void>;
88
88
  }
89
+ export type CwdMissing = 'create' | 'error';
89
90
  export interface RunOptions {
90
91
  cwd?: string;
92
+ cwdMissing?: CwdMissing;
91
93
  user?: string | number;
92
94
  tag?: string;
93
95
  env?: Record<string, string>;
@@ -150,6 +152,7 @@ export interface Kernel {
150
152
  }
151
153
  export interface TerminalOptions {
152
154
  cwd?: string;
155
+ cwdMissing?: CwdMissing;
153
156
  user?: string | number;
154
157
  tag?: string;
155
158
  env?: Record<string, string>;
@@ -29,7 +29,8 @@ export declare class JobTable {
29
29
  pgidOf(pid: number): number | undefined;
30
30
  sidOf(pid: number): number | undefined;
31
31
  private member;
32
- private idOf;
32
+ idOf(pid: number): number;
33
+ execParentOf(pid: number): number | undefined;
33
34
  private byId;
34
35
  setpgid(caller: number, pid: number, pgid: number): void;
35
36
  get handoffCount(): number;
@@ -0,0 +1,59 @@
1
+ import { type Cred } from './cred.js';
2
+ export interface TraceExec {
3
+ type: 'exec';
4
+ seq: number;
5
+ pid: number;
6
+ ppid: number;
7
+ pgid: number;
8
+ argv: string[];
9
+ exe?: string;
10
+ uid: number;
11
+ at: number;
12
+ replaced?: true;
13
+ }
14
+ export interface TraceFork {
15
+ type: 'fork';
16
+ seq: number;
17
+ pid: number;
18
+ ppid: number;
19
+ pgid: number;
20
+ argv: string[];
21
+ exe?: string;
22
+ uid: number;
23
+ at: number;
24
+ }
25
+ export interface TraceExit {
26
+ type: 'exit';
27
+ seq: number;
28
+ pid: number;
29
+ status: number;
30
+ signal?: string;
31
+ utime?: number;
32
+ stime?: number;
33
+ at: number;
34
+ }
35
+ export type TraceEvent = TraceExec | TraceFork | TraceExit;
36
+ type Unsequenced<T> = T extends unknown ? Omit<T, 'seq'> : never;
37
+ export type TraceDraft = Unsequenced<TraceEvent>;
38
+ export interface TraceBatch {
39
+ events: TraceEvent[];
40
+ dropped: number;
41
+ }
42
+ export declare const TRACE_LIMIT = 4096;
43
+ export declare const TRACE_LIMIT_MAX = 65536;
44
+ export declare function traceLimit(value: unknown): number;
45
+ export interface TraceSubscription {
46
+ ack(): void;
47
+ close(): void;
48
+ }
49
+ export declare class TraceHub {
50
+ private readonly subs;
51
+ private seq;
52
+ get idle(): boolean;
53
+ subscribe(tag: string, viewer: Readonly<Cred>, deliver: (batch: TraceBatch) => void, limit?: number): TraceSubscription;
54
+ wants(tags: readonly string[] | undefined, cred: Readonly<Cred>): boolean;
55
+ publish(tags: readonly string[] | undefined, cred: Readonly<Cred>, draft: TraceDraft): void;
56
+ private matches;
57
+ private schedule;
58
+ }
59
+ export {};
@@ -31,6 +31,7 @@ import { type ProcessInfo } from './kernel/proc-info.js';
31
31
  import { type SealedCaller, type SealedHook } from './kernel/sealed.js';
32
32
  import { type SigInfo } from './kernel/signals.js';
33
33
  import { LoopbackNet } from './kernel/socket.js';
34
+ import { TraceHub } from './kernel/trace.js';
34
35
  import { type MediumHandle } from './mount/fsa.js';
35
36
  import { type FstabResult } from './mount/fstab.js';
36
37
  import { type FetchLike, type HostfsGrantHook, type HostfsTiming } from './mount/hostfs.js';
@@ -116,9 +117,11 @@ export interface RunOptions {
116
117
  tagBase?: number;
117
118
  login?: boolean;
118
119
  session?: number;
120
+ cwdMissing?: CwdMissing;
119
121
  }
120
122
  export interface TerminalOptions {
121
123
  cwd?: string;
124
+ cwdMissing?: CwdMissing;
122
125
  env?: Record<string, string>;
123
126
  cols?: number;
124
127
  rows?: number;
@@ -162,6 +165,8 @@ interface Target {
162
165
  shim?: string;
163
166
  }
164
167
  export declare function tagOption(tag: unknown): void;
168
+ export type CwdMissing = 'create' | 'error';
169
+ export declare function cwdMissingOption(value: unknown): CwdMissing;
165
170
  export declare function withTag(tags: readonly string[] | undefined, tag: string | undefined): readonly string[] | undefined;
166
171
  export declare function cronPath(path: string): boolean;
167
172
  export declare function expandDefaults(defaults: Readonly<Record<string, string>> | undefined, env: Readonly<Record<string, string>>): Record<string, string>;
@@ -393,6 +398,14 @@ export declare class Launcher {
393
398
  private readonly imageTimes;
394
399
  private readonly childTimes;
395
400
  private readonly stopped;
401
+ readonly traces: TraceHub;
402
+ private readonly traceHeld;
403
+ private readonly replacedImages;
404
+ private traceStarted;
405
+ private traceEnded;
406
+ private traceEmit;
407
+ private traceAdmitted;
408
+ private chainTimes;
396
409
  private stateOf;
397
410
  private childrenOf;
398
411
  private timesAt;
@@ -20,11 +20,11 @@ import { memoryRoot } from './node/memory-root.js';
20
20
  import type { ApproveHook } from './sudo.js';
21
21
  import { type NetworkTransport } from './transport.js';
22
22
  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 WatchChange, } from './client/attach.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
24
  export type { FacadeConnection, FacadeHook, FacadeInfo, FacadeSpec, FacadeSpecs, } from './facade/types.js';
25
25
  export type { Attestation, AttestedDir, AttestOptions, AttestTombstone } from './fs/attest.js';
26
26
  export type { Denial, DenialHook } from './fs/dac.js';
27
- export type { ConnectOptions, Ended, KernelGroups, KernelIntegrity, KernelSealed, KernelUsers, NetworkUplink, ResolveAnswer, ResolveFamily, RouteTable, RunOptions, RunResult, Terminal, TerminalOptions, TerminalSignal, } from './index.js';
27
+ export type { ConnectOptions, CwdMissing, Ended, KernelGroups, KernelIntegrity, KernelSealed, KernelUsers, NetworkUplink, ResolveAnswer, ResolveFamily, RouteTable, RunOptions, RunResult, Terminal, TerminalOptions, TerminalSignal, } from './index.js';
28
28
  export type { ClipboardHook, ClipboardStamp } from './kernel/clipboard.js';
29
29
  export type { EmbedderHook, EmbedderKindPolicy, EmbedderReply, EmbedderRequest, EmbedderStamp, } from './kernel/embedder.js';
30
30
  export { SEALED_FETCH_VERSION, type SealedFetchHook, type SealedFetchRequest, type SealedOption, } from './kernel/net/sealed-fetch.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-kernel",
3
- "version": "1.178.4",
3
+ "version": "1.180.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",
@@ -70,7 +70,7 @@
70
70
  },
71
71
  "devDependencies": {
72
72
  "@ai-ecoverse/py-numpy": "2.5.4-4",
73
- "@ai-ecoverse/slicc-cdp": "1.47.5",
73
+ "@ai-ecoverse/slicc-cdp": "1.48.10",
74
74
  "@ai-ecoverse/slicc-scrub": "1.1.0",
75
75
  "@ai-ecoverse/slicc-shared-web": "2.14.2",
76
76
  "@ai-ecoverse/wasi-cargo": "0.99.0-6",