@ai-ecoverse/slicc-kernel 1.161.0 → 1.162.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.
@@ -1,6 +1,6 @@
1
1
  import { type MetaStore } from './meta.js';
2
- import { type LockManagerLike, type RemoteListener } from './remote.js';
3
- import { type CopyOptions, type FsStat, type KernelFs, type NewOwner, type OwnerChange, type Peers, type Perm, type PwriteOptions } from './types.js';
2
+ import { type KeepHandlers, type LockManagerLike, type RemoteListener } from './remote.js';
3
+ import { type CopyOptions, type FsStat, type KernelFs, type NewOwner, type OwnerChange, type PeerKeeps, type Peers, type Perm, type PwriteOptions } from './types.js';
4
4
  export type OpfsOp = 'lookup' | 'read' | 'write' | 'commit' | 'sidecar';
5
5
  export declare function translate(err: unknown, path: string, op?: OpfsOp, mapped?: boolean): Error;
6
6
  export interface WriteSession {
@@ -40,6 +40,8 @@ export declare class OpfsFs implements KernelFs {
40
40
  });
41
41
  private changed;
42
42
  fileId(path: string): Promise<string>;
43
+ bindId(path: string): Promise<string | undefined>;
44
+ private assignId;
43
45
  private heldUnder;
44
46
  heldBy(held: (dir: string) => readonly string[]): void;
45
47
  private pinHeld;
@@ -51,6 +53,8 @@ export declare class OpfsFs implements KernelFs {
51
53
  sent: number;
52
54
  held: string[];
53
55
  } | undefined;
56
+ peerKeeps(): PeerKeeps | undefined;
57
+ servePeerKeeps(instance: string, handlers: KeepHandlers): void;
54
58
  rehold(from: string, to: string): void;
55
59
  announceWatch(paths: readonly string[]): Promise<void>;
56
60
  private committed;
@@ -19,6 +19,52 @@ export declare const MOURN_TRIES = 5;
19
19
  export declare const MOURN_RETRY_MS = 100;
20
20
  export declare const RENAME_ACK_MAX_MS = 10000;
21
21
  export declare const ANNOUNCE_POLL_MS = 20;
22
+ interface WatchMessage {
23
+ hello?: string;
24
+ here?: string;
25
+ to?: string;
26
+ tab?: string;
27
+ seq?: number;
28
+ paths?: string[];
29
+ ack?: number;
30
+ from?: string;
31
+ changed?: string[];
32
+ renames?: true;
33
+ keeps?: true;
34
+ renaming?: PeerRename;
35
+ renamed?: string;
36
+ flushing?: string;
37
+ holds?: {
38
+ add: Array<[string, string | undefined]>;
39
+ drop: string[];
40
+ instance?: string;
41
+ };
42
+ keeping?: {
43
+ paths: string[];
44
+ };
45
+ kept?: {
46
+ items: PeerKept[];
47
+ paths?: string[];
48
+ };
49
+ instance?: string;
50
+ }
51
+ export interface PeerKept {
52
+ path: string;
53
+ hidden: string | undefined;
54
+ fid: string | undefined;
55
+ undo?: string;
56
+ }
57
+ export interface PeerHolder {
58
+ tab: string;
59
+ path: string;
60
+ fid: string | undefined;
61
+ instance: string | undefined;
62
+ }
63
+ export interface KeepHandlers {
64
+ keeping(tab: string, paths: readonly string[]): Promise<void>;
65
+ kept(tab: string, items: readonly PeerKept[], paths: readonly string[]): Promise<void>;
66
+ left(tab: string): void;
67
+ }
22
68
  export interface LockManagerLike {
23
69
  request(name: string, callback: () => Promise<void>): Promise<unknown>;
24
70
  query(): Promise<{
@@ -44,6 +90,9 @@ export declare class RemoteWatch {
44
90
  private holdsSent;
45
91
  private readonly silent;
46
92
  private readonly holders;
93
+ private readonly instances;
94
+ instance: string | undefined;
95
+ keeps: KeepHandlers | undefined;
47
96
  private readonly listeners;
48
97
  private readonly waiting;
49
98
  private readonly locks;
@@ -80,10 +129,16 @@ export declare class RemoteWatch {
80
129
  private greeted;
81
130
  private heard;
82
131
  private announced;
132
+ private holdsHeard;
133
+ private readonly keepChains;
134
+ private keepAsked;
135
+ private keepOne;
83
136
  private heldBy;
84
137
  hold(add: ReadonlyArray<[string, string | undefined]>, drop: readonly string[], wait: boolean): Promise<void>;
85
138
  rehold(from: string, to: string): void;
86
139
  private sendHolds;
140
+ heldWithin(target: string): PeerHolder[];
141
+ ask(to: string, body: Pick<WatchMessage, 'keeping' | 'kept'>, cap: number): Promise<boolean>;
87
142
  peerHeld(path: string): Array<{
88
143
  tab: string;
89
144
  fid: string | undefined;
@@ -106,3 +161,4 @@ export declare class RemoteWatch {
106
161
  emit(change: RemoteChange): void;
107
162
  listen(listener: RemoteListener): () => void;
108
163
  }
164
+ export {};
@@ -38,6 +38,7 @@ export interface NewOwner extends Owner {
38
38
  parents?: number;
39
39
  socket?: boolean;
40
40
  fifo?: boolean;
41
+ existing?: true;
41
42
  }
42
43
  export interface CopyOptions {
43
44
  exclusive: boolean;
@@ -94,6 +95,7 @@ export interface KernelFs {
94
95
  onPeer?(settle: () => Promise<void>): void;
95
96
  heldBy?(held: (dir: string) => readonly string[]): void;
96
97
  fileId?(path: string): Promise<string>;
98
+ bindId?(path: string): Promise<string | undefined>;
97
99
  remoteChanges?(listener: (change: {
98
100
  paths: readonly string[];
99
101
  trees?: readonly string[];
@@ -142,6 +144,40 @@ export interface KernelFs {
142
144
  held: string[];
143
145
  } | undefined;
144
146
  rehold?(from: string, to: string): void;
147
+ peerKeeps?(): PeerKeeps | undefined;
148
+ servePeerKeeps?(instance: string, handlers: {
149
+ keeping(tab: string, paths: readonly string[]): Promise<void>;
150
+ kept(tab: string, items: ReadonlyArray<{
151
+ path: string;
152
+ hidden: string | undefined;
153
+ fid: string | undefined;
154
+ undo?: string;
155
+ }>, paths: readonly string[]): Promise<void>;
156
+ left(tab: string): void;
157
+ }): void;
158
+ }
159
+ export interface PeerKeeps {
160
+ shared(): boolean;
161
+ heldWithin(path: string): Array<{
162
+ tab: string;
163
+ path: string;
164
+ fid: string | undefined;
165
+ instance: string | undefined;
166
+ }>;
167
+ ask(to: string, body: {
168
+ keeping?: {
169
+ paths: string[];
170
+ };
171
+ kept?: {
172
+ items: Array<{
173
+ path: string;
174
+ hidden: string | undefined;
175
+ fid: string | undefined;
176
+ undo?: string;
177
+ }>;
178
+ paths?: string[];
179
+ };
180
+ }, cap: number): Promise<boolean>;
145
181
  }
146
182
  export interface PwriteOptions {
147
183
  create?: false;
@@ -1,4 +1,4 @@
1
- import { type KernelFs, type NewOwner } from './types.js';
1
+ import { type KernelFs, type NewOwner, type PeerKeeps } from './types.js';
2
2
  export declare const UNLINKED_DIR = ".slicc-unlinked";
3
3
  export interface Replacements {
4
4
  settled(path: string): Promise<void>;
@@ -50,6 +50,13 @@ export declare function pidOwner(proc: {
50
50
  kill(pid: number, signal: number): unknown;
51
51
  }): UnlinkOwner;
52
52
  export declare function webLocks(): UnlinkLocks | undefined;
53
+ export interface PeerKept {
54
+ whole: boolean;
55
+ undoing<T>(op: () => Promise<T>): Promise<T>;
56
+ }
57
+ export declare const PEER_RM_MS = 1000;
58
+ export declare const PEER_RENAME_MS = 10000;
59
+ export declare const PEER_GATE_MS: number;
53
60
  export declare class PathGate {
54
61
  private readonly tails;
55
62
  acquire(path: string): Promise<() => void>;
@@ -78,12 +85,14 @@ export declare class UnlinkedKeeper {
78
85
  private readonly links;
79
86
  private readonly linked;
80
87
  private readonly dirOwner;
88
+ private readonly peers;
81
89
  constructor(fs: KernelFs, holders: Iterable<UnlinkHolder>, rootOf: (path: string) => string, options?: {
82
90
  locks?: UnlinkLocks | undefined;
83
91
  busy?: (path: string) => boolean;
84
92
  owner?: UnlinkOwner | undefined;
85
93
  dirOwner?: NewOwner;
86
94
  marks?: PathMarks;
95
+ peers?: PeerKeeps | undefined;
87
96
  });
88
97
  private serial;
89
98
  wrap(fs?: KernelFs): KernelFs;
@@ -98,6 +107,17 @@ export declare class UnlinkedKeeper {
98
107
  pin(target: string, gated?: () => void, sealed?: () => void): Promise<Pinned>;
99
108
  private keepAside;
100
109
  private present;
110
+ get id(): string;
111
+ adopt(hidden: string, refs: number): KeptFile;
112
+ peerKeep(target: string, over: boolean, valid?: () => Promise<boolean>): Promise<PeerKept>;
113
+ private setAside;
114
+ private undoing;
115
+ removable(target: string, options?: {
116
+ recursive?: boolean;
117
+ }): Promise<boolean>;
118
+ renamable(source: string, target: string): Promise<boolean>;
119
+ private asideFor;
120
+ private hideFor;
101
121
  private keptFile;
102
122
  private hide;
103
123
  closed(path: string): void;
@@ -101,7 +101,7 @@ export interface SpawnWasmOptions {
101
101
  now: number;
102
102
  renames: Array<[string, string]>;
103
103
  };
104
- fileId?: (path: string) => Promise<string> | undefined;
104
+ fileId?: (path: string) => Promise<string | undefined> | undefined;
105
105
  announceHold?: (path: string, fid: string | undefined, created: boolean) => Promise<void> | undefined;
106
106
  renameSeq?: (from: string, to: string) => number | undefined;
107
107
  mounts?: () => MountLine[];
@@ -436,6 +436,11 @@ export declare class Launcher {
436
436
  fsFor(tag: string | undefined): KernelFs;
437
437
  isWriter(tags: readonly string[] | undefined, base?: number): boolean;
438
438
  private stackFor;
439
+ private readonly peerGates;
440
+ private peerOptions;
441
+ private peerKept;
442
+ private unadopt;
443
+ private adoptKept;
439
444
  private rootFileId;
440
445
  private flushingPeers;
441
446
  private rewritten;
@@ -55,7 +55,7 @@ export declare class HeldSet extends Set<HeldPaths> {
55
55
  constructor(idle: (path: string) => void, moved?: (from: string, to: string) => void);
56
56
  add(holds: HeldPaths): this;
57
57
  doubt(paths: readonly string[], over?: string): void;
58
- bindIds(id: (path: string) => Promise<string> | undefined): Promise<void>;
58
+ bindIds(id: (path: string) => Promise<string | undefined> | undefined): Promise<void>;
59
59
  delete(holds: HeldPaths): boolean;
60
60
  }
61
61
  export declare function heldUnder(held: Iterable<Map<string, number>>, target: string): boolean;
@@ -86,13 +86,16 @@ export declare class HeldPaths extends Map<string, number> implements UnlinkHold
86
86
  fid?: string;
87
87
  doubt: number;
88
88
  } | undefined;
89
- bindIds(id: (path: string) => Promise<string> | undefined): Promise<void>;
89
+ bindIds(id: (path: string) => Promise<string | undefined> | undefined): Promise<void>;
90
90
  trust(handle: number, doubt: number): void;
91
91
  pathOf(handle: number): string | undefined;
92
92
  keptFor(handle: number): KeptFile | undefined;
93
93
  holdsHandle(handle: number): boolean;
94
94
  keeps(hidden: string): boolean;
95
+ boundAt(path: string, fid: string | undefined): number[];
96
+ keepBound(ids: readonly number[], path: string, file: KeptFile): void;
95
97
  keep(path: string, file: KeptFile): void;
98
+ unkeepAt(path: string, hidden: string): void;
96
99
  unkeep(path: string, file: KeptFile): void;
97
100
  private letGo;
98
101
  releaseAll(): void;
@@ -118,7 +118,7 @@ declare function ownCacheDir(make?: () => string): {
118
118
  own: boolean;
119
119
  } | undefined;
120
120
  export { ownCacheDir };
121
- export declare function privateCacheDir(base?: string, alive?: typeof pidAlive): string;
122
- export declare function sweepCacheDirs(base: string, alive?: (pid: number) => boolean, uid?: number | undefined): void;
121
+ export declare function privateCacheDir(base?: string, alive?: typeof pidAlive, uid?: number | undefined): string;
122
+ export declare function sweepCacheDirs(parent: string, alive?: (pid: number) => boolean, uid?: number | undefined): void;
123
123
  declare function pidAlive(pid: number): boolean;
124
124
  export declare function createNodeKernel(options?: NodeKernelOptions): Promise<NodeKernel>;
@@ -18,7 +18,7 @@ export interface SyncFsTokenEntry {
18
18
  fid?: string;
19
19
  doubt: number;
20
20
  } | undefined;
21
- fileId?: (path: string) => Promise<string> | undefined;
21
+ fileId?: (path: string) => Promise<string | undefined> | undefined;
22
22
  announceHold?: (path: string, fid: string | undefined, created: boolean) => Promise<void> | undefined;
23
23
  trust?: (handle: number, doubt: number) => void;
24
24
  gate?: <T>(path: string, op: () => Promise<T>) => Promise<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-kernel",
3
- "version": "1.161.0",
3
+ "version": "1.162.1",
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",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "devDependencies": {
66
66
  "@ai-ecoverse/py-numpy": "2.5.4-4",
67
- "@ai-ecoverse/slicc-cdp": "1.41.6",
67
+ "@ai-ecoverse/slicc-cdp": "1.41.8",
68
68
  "@ai-ecoverse/slicc-node": "2.5.2",
69
69
  "@ai-ecoverse/slicc-scrub": "1.1.0",
70
70
  "@ai-ecoverse/slicc-shared-web": "2.12.1",