@wjarka/cezarion 0.17.0-dev.3031 → 0.17.0-pr1973.3036

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.
Files changed (44) hide show
  1. package/dist/ci-wait/tools.d.ts +4 -4
  2. package/dist/delegation/destroy-holders.d.ts +2 -0
  3. package/dist/delegation/destroy-holders.js +167 -0
  4. package/dist/delegation/destroy-holders.js.map +1 -0
  5. package/dist/delegation/idle-test-app.js +58 -20
  6. package/dist/delegation/idle-test-app.js.map +1 -1
  7. package/dist/delegation/mount-boundary.d.ts +16 -0
  8. package/dist/delegation/mount-boundary.js +126 -0
  9. package/dist/delegation/mount-boundary.js.map +1 -0
  10. package/dist/delegation/process-liveness.d.ts +3 -0
  11. package/dist/delegation/process-liveness.js +5 -0
  12. package/dist/delegation/process-liveness.js.map +1 -1
  13. package/dist/delegation/service.d.ts +1 -3
  14. package/dist/delegation/service.js +117 -24
  15. package/dist/delegation/service.js.map +1 -1
  16. package/dist/delegation/windows-workspace-identity.d.ts +10 -0
  17. package/dist/delegation/windows-workspace-identity.js +37 -0
  18. package/dist/delegation/windows-workspace-identity.js.map +1 -1
  19. package/dist/delegation/workspace.d.ts +3 -1
  20. package/dist/delegation/workspace.js +324 -29
  21. package/dist/delegation/workspace.js.map +1 -1
  22. package/dist/git-worktree-release.d.ts +1 -1
  23. package/dist/git-worktree-release.js +2 -2
  24. package/dist/git-worktree-release.js.map +1 -1
  25. package/dist/runs/private-worker-file.d.ts +5 -0
  26. package/dist/runs/private-worker-file.js +51 -0
  27. package/dist/runs/private-worker-file.js.map +1 -0
  28. package/dist/runs/store.d.ts +48 -48
  29. package/dist/runs/store.js +47 -87
  30. package/dist/runs/store.js.map +1 -1
  31. package/dist/runs/windows-worker-evidence.d.ts +9 -0
  32. package/dist/runs/windows-worker-evidence.js +71 -0
  33. package/dist/runs/windows-worker-evidence.js.map +1 -0
  34. package/dist/runs/worker-execution.js +17 -1
  35. package/dist/runs/worker-execution.js.map +1 -1
  36. package/dist/server/server.d.ts +1200 -1200
  37. package/dist/workflows/continuation-admission.d.ts +48 -48
  38. package/dist/workflows/run.d.ts +1 -3
  39. package/dist/workflows/run.js +6 -7
  40. package/dist/workflows/run.js.map +1 -1
  41. package/package.json +3 -3
  42. package/scripts/test-fallback-sandbox.mjs +39 -0
  43. package/scripts/windows-workspace-identity.cs +219 -10
  44. package/scripts/windows-workspace-identity.ps1 +6 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wjarka/cezarion",
3
- "version": "0.17.0-dev.3031",
3
+ "version": "0.17.0-pr1973.3036",
4
4
  "description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -53,8 +53,8 @@
53
53
  "zod": "^4.4.3"
54
54
  },
55
55
  "devDependencies": {
56
- "@open-mercato/cezar-api-client": "0.17.0-dev.3031",
57
- "@open-mercato/cezar-contract": "0.17.0-dev.3031",
56
+ "@open-mercato/cezar-api-client": "0.17.0-pr1973.3036",
57
+ "@open-mercato/cezar-contract": "0.17.0-pr1973.3036",
58
58
  "@types/node": "^24.19.1",
59
59
  "@types/ws": "^8.18.1",
60
60
  "esbuild": "^0.28.1",
@@ -0,0 +1,39 @@
1
+ // Keep test startup sweeps inside directories created by this Vitest worker.
2
+ // The production sweep also reaps dead projects from the shared OS temp root.
3
+ import fs from 'node:fs';
4
+ import { syncBuiltinESMExports } from 'node:module';
5
+ import { basename, resolve } from 'node:path';
6
+
7
+ const owned = new Map();
8
+ const mkdir = fs.mkdirSync;
9
+ const readdir = fs.readdirSync;
10
+ const isFallback = name => /^cez-agent-[0-9a-f]{12}$/.test(name);
11
+
12
+ fs.mkdirSync = function (path, options) {
13
+ const name = String(path);
14
+ let existed = true;
15
+ try { fs.lstatSync(name); } catch (error) { if (error.code === 'ENOENT') existed = false; else throw error; }
16
+ const result = mkdir.call(fs, path, options);
17
+ // Recursive mkdir returns undefined when another actor created the entry.
18
+ // Do not claim it based on a stale pre-check.
19
+ const created = typeof options === 'object' && options?.recursive
20
+ ? typeof result === 'string' && resolve(result) === resolve(name)
21
+ : !existed;
22
+ if (created && isFallback(basename(name))) {
23
+ const info = fs.lstatSync(name);
24
+ owned.set(resolve(name), [info.dev, info.ino]);
25
+ }
26
+ return result;
27
+ };
28
+ fs.readdirSync = function (path, options) {
29
+ const entries = readdir.call(fs, path, options);
30
+ return entries.filter(entry => {
31
+ const name = typeof entry === 'string' ? entry : Buffer.isBuffer(entry) ? entry.toString() : entry.name;
32
+ if (!isFallback(name)) return true;
33
+ const full = resolve(String(path), name), identity = owned.get(full);
34
+ if (!identity) return false;
35
+ try { const info = fs.lstatSync(full); return info.dev === identity[0] && info.ino === identity[1]; }
36
+ catch { return false; }
37
+ });
38
+ };
39
+ syncBuiltinESMExports();
@@ -10,6 +10,68 @@ using System.Security.Principal;
10
10
  using System.Text;
11
11
  using Microsoft.Win32.SafeHandles;
12
12
 
13
+ // Mounted folders can share a device with their parent; enumerate volume
14
+ // mount paths rather than comparing file IDs or drive letters.
15
+ public static class CezMountBoundary {
16
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
17
+ static extern IntPtr FindFirstVolumeW(StringBuilder volume, uint length);
18
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
19
+ static extern bool FindNextVolumeW(IntPtr find, StringBuilder volume, uint length);
20
+ [DllImport("kernel32.dll", SetLastError = true)] static extern bool FindVolumeClose(IntPtr find);
21
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
22
+ static extern bool GetVolumePathNamesForVolumeNameW(string volume, [Out] char[] paths, uint length, out uint required);
23
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
24
+ static extern uint GetDriveTypeW(string root);
25
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
26
+ static extern uint QueryDosDeviceW(string device, StringBuilder target, uint length);
27
+
28
+ public static void Assert(string[] roots) {
29
+ var normalized = new List<string>();
30
+ foreach (string root in roots) {
31
+ string path = Path.GetFullPath(root).TrimEnd('\\');
32
+ if (path.Length < 2 || path[1] != ':') throw new IOException("Cannot verify mount boundaries for non-local resource");
33
+ string drive = path.Substring(0, 2);
34
+ uint type = GetDriveTypeW(drive + "\\");
35
+ var target = new StringBuilder(32768);
36
+ if ((type != 2 && type != 3) || QueryDosDeviceW(drive, target, (uint)target.Capacity) == 0 ||
37
+ !target.ToString().StartsWith("\\Device\\", StringComparison.OrdinalIgnoreCase) ||
38
+ target.ToString().StartsWith("\\Device\\Mup", StringComparison.OrdinalIgnoreCase))
39
+ throw new IOException("Cannot verify mount boundaries for mapped or aliased drive: " + drive);
40
+ normalized.Add(path);
41
+ }
42
+ var volume = new StringBuilder(1024);
43
+ IntPtr find = FindFirstVolumeW(volume, (uint)volume.Capacity);
44
+ if (find == new IntPtr(-1)) throw new Win32Exception(Marshal.GetLastWin32Error(), "Cannot enumerate volumes");
45
+ int count = 0;
46
+ var covered = new bool[normalized.Count];
47
+ try {
48
+ do {
49
+ uint required; var paths = new char[1024];
50
+ if (!GetVolumePathNamesForVolumeNameW(volume.ToString(), paths, (uint)paths.Length, out required)) {
51
+ int error = Marshal.GetLastWin32Error();
52
+ if (error != 234 || required == 0 || required > 1048576) throw new Win32Exception(error, "Cannot enumerate volume mount paths");
53
+ paths = new char[required];
54
+ if (!GetVolumePathNamesForVolumeNameW(volume.ToString(), paths, (uint)paths.Length, out required)) throw new Win32Exception(Marshal.GetLastWin32Error(), "Cannot enumerate volume mount paths");
55
+ }
56
+ foreach (string mount in new string(paths).Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries)) {
57
+ count++;
58
+ string path = Path.GetFullPath(mount).TrimEnd('\\');
59
+ for (int i = 0; i < normalized.Count; i++) {
60
+ string root = normalized[i];
61
+ if (String.Equals(path, root, StringComparison.OrdinalIgnoreCase) || path.StartsWith(root + "\\", StringComparison.OrdinalIgnoreCase))
62
+ throw new IOException("Mounted resource boundary prevents cleanup: " + root);
63
+ if (root.StartsWith(path + "\\", StringComparison.OrdinalIgnoreCase)) covered[i] = true;
64
+ }
65
+ }
66
+ } while (FindNextVolumeW(find, volume, (uint)volume.Capacity));
67
+ int last = Marshal.GetLastWin32Error();
68
+ if (last != 18) throw new Win32Exception(last, "Cannot enumerate volumes");
69
+ if (count == 0) throw new IOException("Volume mount path evidence is empty");
70
+ for (int i = 0; i < covered.Length; i++) if (!covered[i]) throw new IOException("Volume mount path evidence does not cover resource: " + normalized[i]);
71
+ } finally { FindVolumeClose(find); }
72
+ }
73
+ }
74
+
13
75
  public static class CezWorkspaceIdentity {
14
76
  const uint ReadControl = 0x20000, ReadAttributes = 0x80, GenericRead = 0x80000000, GenericWrite = 0x40000000, Delete = 0x10000;
15
77
  const uint OpenReparse = 0x200000, BackupSemantics = 0x2000000, ReparsePoint = 0x400, DirectoryAttribute = 0x10;
@@ -152,14 +214,48 @@ public static class CezWorkspaceIdentity {
152
214
  using (var parents = new Parents(path)) {
153
215
  if (privateParent) PrivateDirectory(Path.GetDirectoryName(path));
154
216
  using (var file = PrivateFile(path, false, ShareRead)) {
155
- var info = CheckObject(file, path, false);
156
- if (cap < 0 || cap > 16384 || info.SizeHigh != 0 || info.SizeLow > cap) throw new IOException("Oversized workspace identity");
157
- using (var stream = new FileStream(file, FileAccess.Read)) {
158
- byte[] bytes = new byte[cap + 1]; int count = 0, read;
159
- while (count < bytes.Length && (read = stream.Read(bytes, count, bytes.Length - count)) != 0) count += read;
160
- if (count > cap) throw new IOException("Oversized workspace identity");
161
- return Convert.ToBase64String(bytes, 0, count);
162
- }
217
+ return ReadFile(file, path, cap);
218
+ }
219
+ }
220
+ }
221
+ static string ReadFile(SafeFileHandle file, string path, int cap) {
222
+ var info = CheckObject(file, path, false);
223
+ if (cap < 0 || cap > 16384 || info.SizeHigh != 0 || info.SizeLow > cap) throw new IOException("Oversized workspace identity");
224
+ using (var stream = new FileStream(file, FileAccess.Read)) {
225
+ byte[] bytes = new byte[cap + 1]; int count = 0, read;
226
+ while (count < bytes.Length && (read = stream.Read(bytes, count, bytes.Length - count)) != 0) count += read;
227
+ if (count > cap) throw new IOException("Oversized workspace identity");
228
+ return Convert.ToBase64String(bytes, 0, count);
229
+ }
230
+ }
231
+ public static string ReadEither(string legacyInput, string currentInput, int cap) {
232
+ string legacy = Canonical(legacyInput), current = Canonical(currentInput);
233
+ string directory = Path.GetDirectoryName(current);
234
+ using (var legacyParents = new Parents(legacy))
235
+ using (var currentParents = new Parents(directory))
236
+ using (var dir = Open(directory, ReadAttributes | ReadControl, ShareRead | ShareWrite, true))
237
+ using (var old = PrivateFile(legacy, true, ShareRead)) {
238
+ if (dir != null) { CheckObject(dir, directory, true); CheckPrivate(dir); }
239
+ using (var modern = dir == null ? null : PrivateFile(current, true, ShareRead)) {
240
+ if (old != null && modern != null) throw new IOException("Duplicate worker evidence");
241
+ if (old != null) return ReadFile(old, legacy, cap);
242
+ if (modern != null) return ReadFile(modern, current, cap);
243
+ return "~";
244
+ }
245
+ }
246
+ }
247
+ public static void Remove(string input, bool privateParent) {
248
+ string path = Canonical(input);
249
+ using (var parents = new Parents(path)) {
250
+ if (privateParent) PrivateDirectory(Path.GetDirectoryName(path));
251
+ using (var file = Open(path, GenericRead | ReadControl | Delete, ShareRead, true)) {
252
+ if (file == null) return;
253
+ CheckObject(file, path, false); CheckPrivate(file);
254
+ IntPtr disposition = Marshal.AllocHGlobal(1);
255
+ try {
256
+ Marshal.WriteByte(disposition, 1);
257
+ if (!SetFileInformationByHandle(file, 4 /* FileDispositionInfo */, disposition, 1)) throw new Win32Exception();
258
+ } finally { Marshal.FreeHGlobal(disposition); }
163
259
  }
164
260
  }
165
261
  }
@@ -171,7 +267,7 @@ public static class CezWorkspaceIdentity {
171
267
  catch { file.Dispose(); throw; }
172
268
  }
173
269
  }
174
- static void Rename(SafeFileHandle file, string path) {
270
+ static void Rename(SafeFileHandle file, string path, bool replace = true) {
175
271
  byte[] name = Encoding.Unicode.GetBytes(path);
176
272
  int offset = (int)Marshal.OffsetOf(typeof(RenameInformation), "Name");
177
273
  // The Win32 path conversion needs a terminated string; Length excludes its NUL.
@@ -181,7 +277,7 @@ public static class CezWorkspaceIdentity {
181
277
  // Zero padding as well as RootDirectory; use the pinned absolute destination.
182
278
  // REPLACE_IF_EXISTS | POSIX_SEMANTICS permits replacing the destination while
183
279
  // its verified read handle stays open. Never close it to make rename work.
184
- Marshal.Copy(new byte[size], 0, memory, size); Marshal.WriteInt32(memory, 3);
280
+ Marshal.Copy(new byte[size], 0, memory, size); Marshal.WriteInt32(memory, replace ? 3 : 0);
185
281
  Marshal.WriteInt32(memory, (int)Marshal.OffsetOf(typeof(RenameInformation), "Length"), name.Length);
186
282
  Marshal.Copy(name, 0, IntPtr.Add(memory, offset), name.Length);
187
283
  if (!SetFileInformationByHandle(file, 22 /* FileRenameInfoEx */, memory, (uint)size)) {
@@ -189,6 +285,18 @@ public static class CezWorkspaceIdentity {
189
285
  }
190
286
  } finally { Marshal.FreeHGlobal(memory); }
191
287
  }
288
+ public static void Migrate(string input, string destination) {
289
+ string source = Canonical(input), target = Canonical(destination);
290
+ using (var sourceParents = new Parents(source))
291
+ using (var targetParents = new Parents(target)) {
292
+ PrivateDirectory(Path.GetDirectoryName(target));
293
+ using (var file = Open(source, GenericRead | ReadControl | Delete, ShareRead, false)) {
294
+ CheckObject(file, source, false); CheckPrivate(file);
295
+ // Rename the verified object itself. An existing destination is never replaced.
296
+ Rename(file, target, false);
297
+ }
298
+ }
299
+ }
192
300
  public static void Write(string input, string content, bool replace, bool privateParent) {
193
301
  string path = Canonical(input); byte[] bytes = Convert.FromBase64String(content);
194
302
  if (bytes.Length > 16384) throw new IOException("Oversized workspace identity");
@@ -206,3 +314,104 @@ public static class CezWorkspaceIdentity {
206
314
  }
207
315
  }
208
316
  }
317
+
318
+ // Destroy-only OS evidence. Each signal uses a process handle whose creation
319
+ // time was checked after a fresh handle scan; PIDs and lease files alone do not
320
+ // authorize termination. Handles for unrelated inaccessible processes are skipped.
321
+ public static class CezDestroyHolders {
322
+ const uint Query = 0x1000, Duplicate = 0x40, Terminate = 1, SameAccess = 2;
323
+ const int ExtendedHandles = 64;
324
+ const int LengthMismatch = unchecked((int)0xC0000004);
325
+ [StructLayout(LayoutKind.Sequential)] struct Entry {
326
+ public IntPtr Object, Pid, Handle;
327
+ public uint Access; public ushort Trace, Type; public uint Attributes, Reserved;
328
+ }
329
+ [DllImport("ntdll.dll")] static extern int NtQuerySystemInformation(int kind, IntPtr data, int size, out int needed);
330
+ [DllImport("kernel32.dll", SetLastError = true)] static extern IntPtr OpenProcess(uint access, bool inherit, int pid);
331
+ [DllImport("kernel32.dll")] static extern IntPtr GetCurrentProcess();
332
+ [DllImport("kernel32.dll")] static extern bool CloseHandle(IntPtr handle);
333
+ [DllImport("kernel32.dll", SetLastError = true)] static extern bool DuplicateHandle(IntPtr source, IntPtr handle, IntPtr target, out SafeFileHandle copy, uint access, bool inherit, uint flags);
334
+ [DllImport("kernel32.dll")] static extern uint GetFileType(SafeFileHandle handle);
335
+ [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] static extern uint GetFinalPathNameByHandleW(SafeFileHandle handle, StringBuilder path, uint size, uint flags);
336
+ [DllImport("kernel32.dll")] static extern bool GetProcessTimes(IntPtr process, out long creation, out long exit, out long kernel, out long user);
337
+ [DllImport("kernel32.dll", SetLastError = true)] static extern bool TerminateProcess(IntPtr process, uint code);
338
+
339
+ static string Token(IntPtr process) {
340
+ long creation, exit, kernel, user;
341
+ return GetProcessTimes(process, out creation, out exit, out kernel, out user) ? creation.ToString() : null;
342
+ }
343
+ static string Normalize(string path) {
344
+ if (path.StartsWith("\\\\?\\")) path = path.Substring(4);
345
+ return Path.GetFullPath(path).TrimEnd('\\');
346
+ }
347
+ static bool Under(string name, string[] roots) {
348
+ string path;
349
+ try { path = Normalize(name); } catch { return false; }
350
+ foreach (string root in roots) {
351
+ string canonical = Normalize(root);
352
+ if (String.Equals(path, canonical, StringComparison.OrdinalIgnoreCase) ||
353
+ path.StartsWith(canonical + "\\", StringComparison.OrdinalIgnoreCase)) return true;
354
+ }
355
+ return false;
356
+ }
357
+ public static string[] Find(string[] roots, int selectedPid) {
358
+ CezMountBoundary.Assert(roots);
359
+ int size = 1024 * 1024, needed, status; IntPtr data = IntPtr.Zero;
360
+ try {
361
+ do {
362
+ if (data != IntPtr.Zero) Marshal.FreeHGlobal(data);
363
+ if (size > 256 * 1024 * 1024) { data = IntPtr.Zero; throw new IOException("Windows handle scan exceeds limit"); }
364
+ data = Marshal.AllocHGlobal(size);
365
+ status = NtQuerySystemInformation(ExtendedHandles, data, size, out needed);
366
+ if (status == LengthMismatch) size = Math.Max(size * 2, needed);
367
+ } while (status == LengthMismatch);
368
+ if (status != 0) throw new IOException("Windows handle scan failed: " + status);
369
+ long count = Marshal.ReadIntPtr(data).ToInt64(); int entrySize = Marshal.SizeOf(typeof(Entry));
370
+ if (count < 0 || count > (size - IntPtr.Size * 2) / entrySize) throw new IOException("Invalid Windows handle scan");
371
+ var processes = new Dictionary<int, IntPtr>(); var found = new Dictionary<int, string>();
372
+ int self = System.Diagnostics.Process.GetCurrentProcess().Id;
373
+ try {
374
+ if (selectedPid != 0) {
375
+ IntPtr selected = OpenProcess(Query | Duplicate, false, selectedPid);
376
+ if (selected == IntPtr.Zero && Marshal.GetLastWin32Error() != 87) throw new Win32Exception(Marshal.GetLastWin32Error(), "Cannot inspect Windows holder " + selectedPid);
377
+ processes[selectedPid] = selected;
378
+ }
379
+ for (long i = 0; i < count; i++) {
380
+ var entry = (Entry)Marshal.PtrToStructure(IntPtr.Add(data, checked(IntPtr.Size * 2 + (int)i * entrySize)), typeof(Entry));
381
+ long value = entry.Pid.ToInt64(); if (value <= 1 || value > Int32.MaxValue) continue;
382
+ int pid = (int)value;
383
+ if (pid == self || (selectedPid != 0 && pid != selectedPid) || found.ContainsKey(pid)) continue;
384
+ IntPtr process;
385
+ if (!processes.TryGetValue(pid, out process)) { process = OpenProcess(Query | Duplicate, false, pid); processes[pid] = process; }
386
+ if (process == IntPtr.Zero) continue;
387
+ SafeFileHandle copy;
388
+ if (!DuplicateHandle(process, entry.Handle, GetCurrentProcess(), out copy, 0, false, SameAccess)) {
389
+ int error = Marshal.GetLastWin32Error();
390
+ if (selectedPid != 0 && error == 5) throw new Win32Exception(error, "Cannot inspect Windows holder handle " + pid);
391
+ continue;
392
+ }
393
+ using (copy) {
394
+ if (GetFileType(copy) != 1) continue;
395
+ var name = new StringBuilder(32768); uint length = GetFinalPathNameByHandleW(copy, name, (uint)name.Capacity, 0);
396
+ if (length == 0 || length >= name.Capacity) {
397
+ if (selectedPid != 0 && Marshal.GetLastWin32Error() == 5) throw new IOException("Cannot name Windows holder handle " + pid);
398
+ continue;
399
+ }
400
+ if (!Under(name.ToString(), roots)) continue;
401
+ string token = Token(process); if (token == null) throw new IOException("Cannot verify Windows holder " + pid);
402
+ found[pid] = token;
403
+ }
404
+ }
405
+ var result = new List<string>(); foreach (var item in found) result.Add(item.Key + ":" + item.Value); return result.ToArray();
406
+ } finally { foreach (IntPtr process in processes.Values) if (process != IntPtr.Zero) CloseHandle(process); }
407
+ } finally { if (data != IntPtr.Zero) Marshal.FreeHGlobal(data); }
408
+ }
409
+ public static void Stop(string[] roots, int pid, string token) {
410
+ IntPtr process = OpenProcess(Query | Terminate, false, pid);
411
+ if (process == IntPtr.Zero) throw new Win32Exception(Marshal.GetLastWin32Error(), "Cannot open Windows holder " + pid);
412
+ try {
413
+ if (Token(process) != token || Array.IndexOf(Find(roots, pid), pid + ":" + token) < 0 || Token(process) != token) return;
414
+ if (!TerminateProcess(process, 1)) throw new Win32Exception(Marshal.GetLastWin32Error(), "Cannot stop Windows holder " + pid);
415
+ } finally { CloseHandle(process); }
416
+ }
417
+ }
@@ -3,8 +3,14 @@ $ErrorActionPreference = 'Stop'
3
3
  Add-Type -Path (Join-Path $PSScriptRoot 'windows-workspace-identity.cs')
4
4
  $request = [Console]::In.ReadToEnd() | ConvertFrom-Json
5
5
  switch ($request.operation) {
6
+ 'mount-boundary' { [CezMountBoundary]::Assert([string[]]$request.paths) }
6
7
  'directory' { [CezWorkspaceIdentity]::Directory($request.path, [bool]$request.create) }
7
8
  'read' { [CezWorkspaceIdentity]::Read($request.path, [int]$request.cap, [bool]$request.privateParent) }
9
+ 'read-either' { [CezWorkspaceIdentity]::ReadEither($request.legacy, $request.current, [int]$request.cap) }
8
10
  'write' { [CezWorkspaceIdentity]::Write($request.path, $request.content, [bool]$request.replace, [bool]$request.privateParent) }
11
+ 'remove' { [CezWorkspaceIdentity]::Remove($request.path, [bool]$request.privateParent) }
12
+ 'migrate' { [CezWorkspaceIdentity]::Migrate($request.path, $request.destination) }
13
+ 'holders' { ConvertTo-Json -InputObject @([CezDestroyHolders]::Find([string[]]$request.paths, [int]$request.pid)) -Compress }
14
+ 'stop-holder' { [CezDestroyHolders]::Stop([string[]]$request.paths, [int]$request.pid, [string]$request.token) }
9
15
  default { throw 'Unknown workspace identity operation' }
10
16
  }