@ai-ecoverse/slicc-kernel 1.179.0 → 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.179.0" : "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);
@@ -30,7 +32,7 @@ export interface SpawnOptions {
30
32
  stdin?: string | Uint8Array;
31
33
  group?: 'new';
32
34
  pgid?: number;
33
- tag?: string;
35
+ tag?: string | readonly string[];
34
36
  onStdout?: (bytes: Uint8Array) => void;
35
37
  onStderr?: (bytes: Uint8Array) => void;
36
38
  }
@@ -51,7 +53,7 @@ export interface ClientRunOptions {
51
53
  user?: string | number;
52
54
  env?: Record<string, string>;
53
55
  stdin?: string | Uint8Array;
54
- tag?: string;
56
+ tag?: string | readonly string[];
55
57
  onStdout?: (text: string) => void;
56
58
  onStderr?: (text: string) => void;
57
59
  }
@@ -69,7 +71,7 @@ export interface ClientTerminalOptions {
69
71
  env?: Record<string, string>;
70
72
  cols?: number;
71
73
  rows?: number;
72
- tag?: string;
74
+ tag?: string | readonly string[];
73
75
  onData?: (bytes: Uint8Array) => void;
74
76
  }
75
77
  export interface ClientTerminal {
@@ -104,6 +106,13 @@ export interface ClientFs {
104
106
  close(): void;
105
107
  }>;
106
108
  }
109
+ export interface TraceBatch {
110
+ events: TraceEvent[];
111
+ dropped: number;
112
+ }
113
+ export interface TraceOptions {
114
+ limit?: number;
115
+ }
107
116
  export type ClientFetchRequest = Omit<RealmTransportRequest, 'signal'> & {
108
117
  signal?: AbortSignal;
109
118
  };
@@ -133,6 +142,9 @@ export interface KernelClient {
133
142
  close(): void;
134
143
  }>;
135
144
  onTraits(listener: (traits: RealmTransportTraits) => void): () => void;
145
+ trace(tag: string, onEvents: (batch: TraceBatch) => void | Promise<unknown>, options?: TraceOptions): Promise<{
146
+ close(): void;
147
+ }>;
136
148
  close(options?: {
137
149
  kill?: boolean;
138
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 {
@@ -26,7 +27,7 @@ export interface SpawnRequestOptions {
26
27
  env?: Record<string, string>;
27
28
  stdin?: Uint8Array;
28
29
  pgid?: number;
29
- tag?: string;
30
+ tag?: string | readonly string[];
30
31
  }
31
32
  export interface TerminalRequestOptions {
32
33
  cwd?: string;
@@ -35,7 +36,7 @@ export interface TerminalRequestOptions {
35
36
  env?: Record<string, string>;
36
37
  cols?: number;
37
38
  rows?: number;
38
- tag?: string;
39
+ tag?: string | readonly string[];
39
40
  }
40
41
  export type TerminalAction = {
41
42
  action: 'write';
@@ -104,6 +105,13 @@ export type ClientCall = {
104
105
  } | {
105
106
  op: 'unserve-facade';
106
107
  registration: number;
108
+ } | {
109
+ op: 'trace';
110
+ tag: string;
111
+ limit?: number;
112
+ } | {
113
+ op: 'untrace';
114
+ trace: number;
107
115
  } | {
108
116
  op: 'detach';
109
117
  kill?: boolean;
@@ -121,16 +129,24 @@ export interface ClientReply {
121
129
  started?: number;
122
130
  signal?: string;
123
131
  }
132
+ export interface TraceAck {
133
+ traceAck: number;
134
+ }
124
135
  export type ClientMessage = {
125
136
  hello: ClientHello;
126
- } | ClientRequest | TransportCall;
137
+ } | ClientRequest | TransportCall | TraceAck;
127
138
  export interface WatchEvent {
128
139
  watch: number;
129
140
  change: WatchChange;
130
141
  }
142
+ export interface TraceMessage {
143
+ trace: number;
144
+ events: TraceEvent[];
145
+ dropped?: number;
146
+ }
131
147
  export type KernelMessage = {
132
148
  hello: KernelHello;
133
- } | ClientReply | WatchEvent | TransportReply;
149
+ } | ClientReply | WatchEvent | TraceMessage | TransportReply;
134
150
  export interface ProcessEntry {
135
151
  pid: number;
136
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';
@@ -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';
@@ -397,6 +398,14 @@ export declare class Launcher {
397
398
  private readonly imageTimes;
398
399
  private readonly childTimes;
399
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;
400
409
  private stateOf;
401
410
  private childrenOf;
402
411
  private timesAt;
@@ -20,7 +20,7 @@ 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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-kernel",
3
- "version": "1.179.0",
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.48.2",
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",