@ricsam/r5d-worker 0.0.137 → 0.0.139

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 (236) hide show
  1. package/README.md +4 -94
  2. package/dist/cjs/package.json +1 -1
  3. package/dist/mjs/main.mjs +46 -7543
  4. package/dist/mjs/package.json +1 -1
  5. package/dist/mjs/personal/action-scheduler.mjs +31 -0
  6. package/dist/mjs/personal/client.mjs +215 -0
  7. package/dist/mjs/personal/runtime.mjs +359 -0
  8. package/dist/mjs/personal/tcp.mjs +217 -0
  9. package/dist/mjs/runtime/adapter.mjs +42 -0
  10. package/dist/mjs/runtime/client.mjs +95 -0
  11. package/dist/mjs/runtime/daemon.mjs +131 -0
  12. package/dist/mjs/runtime/executor.mjs +436 -0
  13. package/dist/mjs/runtime/index.mjs +15 -0
  14. package/dist/mjs/runtime/protocol.mjs +139 -0
  15. package/dist/mjs/runtime/pty-host.mjs +156 -0
  16. package/dist/mjs/runtime/pty.mjs +127 -0
  17. package/dist/mjs/runtime/releases/artifacts.mjs +201 -0
  18. package/dist/mjs/runtime/releases/grants.mjs +93 -0
  19. package/dist/mjs/runtime/releases/main.mjs +101 -0
  20. package/dist/mjs/runtime/releases/manager.mjs +541 -0
  21. package/dist/mjs/runtime/releases/process.mjs +88 -0
  22. package/dist/mjs/runtime/releases/retirement.mjs +18 -0
  23. package/dist/mjs/runtime/releases/rpc-client.mjs +184 -0
  24. package/dist/mjs/runtime/releases/rpc-main.mjs +213 -0
  25. package/dist/mjs/runtime/releases/rpc-protocol.mjs +103 -0
  26. package/dist/mjs/runtime/storage.mjs +156 -0
  27. package/dist/mjs/runtime/workspace/artifacts.mjs +121 -0
  28. package/dist/mjs/runtime/workspace/authority.mjs +1355 -0
  29. package/dist/mjs/runtime/workspace/contracts.mjs +60 -0
  30. package/dist/mjs/runtime/workspace/file-write.mjs +23 -0
  31. package/dist/mjs/runtime/workspace/files.mjs +308 -0
  32. package/dist/mjs/runtime/workspace/http-body.mjs +45 -0
  33. package/dist/mjs/runtime/workspace/storage-client.mjs +59 -0
  34. package/dist/mjs/runtime/workspace/storage-wire.mjs +53 -0
  35. package/dist/types/main.d.ts +0 -1167
  36. package/dist/types/personal/action-scheduler.d.ts +23 -0
  37. package/dist/types/personal/client.d.ts +14 -0
  38. package/dist/types/personal/runtime.d.ts +121 -0
  39. package/dist/types/personal/tcp.d.ts +14 -0
  40. package/dist/types/runtime/client.d.ts +3 -1
  41. package/dist/types/runtime/executor.d.ts +6 -1
  42. package/dist/types/runtime/protocol.d.ts +176 -4
  43. package/dist/types/runtime/pty.d.ts +1 -0
  44. package/dist/types/runtime/releases/artifacts.d.ts +51 -0
  45. package/dist/types/runtime/releases/grants.d.ts +16 -0
  46. package/dist/types/runtime/releases/manager.d.ts +145 -0
  47. package/dist/types/runtime/releases/process.d.ts +14 -0
  48. package/dist/types/runtime/releases/retirement.d.ts +15 -0
  49. package/dist/types/runtime/releases/rpc-client.d.ts +52 -0
  50. package/dist/types/runtime/releases/rpc-main.d.ts +10 -0
  51. package/dist/types/runtime/releases/rpc-protocol.d.ts +1139 -0
  52. package/dist/types/runtime/workspace/artifacts.d.ts +30 -0
  53. package/dist/types/runtime/workspace/authority.d.ts +338 -0
  54. package/dist/types/runtime/workspace/contracts.d.ts +86 -0
  55. package/dist/types/runtime/workspace/file-write.d.ts +14 -0
  56. package/dist/types/runtime/workspace/files.d.ts +21 -0
  57. package/dist/types/runtime/workspace/http-body.d.ts +9 -0
  58. package/dist/types/runtime/workspace/storage-client.d.ts +23 -0
  59. package/dist/types/runtime/workspace/storage-wire.d.ts +138 -0
  60. package/package.json +8 -6
  61. package/dist/cjs/atomic-rename.cjs +0 -303
  62. package/dist/cjs/browser-upload.cjs +0 -73
  63. package/dist/cjs/cli-update.cjs +0 -108
  64. package/dist/cjs/command-launcher.cjs +0 -423
  65. package/dist/cjs/control-command-policy.cjs +0 -177
  66. package/dist/cjs/git-blob-hash.cjs +0 -41
  67. package/dist/cjs/git-identity.cjs +0 -39
  68. package/dist/cjs/git-process-environment.cjs +0 -133
  69. package/dist/cjs/inline-output.cjs +0 -62
  70. package/dist/cjs/main.cjs +0 -7517
  71. package/dist/cjs/managed-paths.cjs +0 -215
  72. package/dist/cjs/plan-lint.cjs +0 -165
  73. package/dist/cjs/plan-parser.cjs +0 -127
  74. package/dist/cjs/plan-paths.cjs +0 -53
  75. package/dist/cjs/port-forward-client.cjs +0 -206
  76. package/dist/cjs/process-tree.cjs +0 -117
  77. package/dist/cjs/project-checkout-garbage.cjs +0 -219
  78. package/dist/cjs/project-mirror-fetch-policy.cjs +0 -82
  79. package/dist/cjs/project-mirror-refs-token.cjs +0 -85
  80. package/dist/cjs/project-workspace-state.cjs +0 -972
  81. package/dist/cjs/project-worktrees.cjs +0 -1713
  82. package/dist/cjs/pty-output-coalescer.cjs +0 -87
  83. package/dist/cjs/recovery-journal-protocol.cjs +0 -56
  84. package/dist/cjs/recovery-journal-runtime.cjs +0 -133
  85. package/dist/cjs/recovery-journal-thread.cjs +0 -9
  86. package/dist/cjs/recovery-journal.cjs +0 -742
  87. package/dist/cjs/recovery-output-window.cjs +0 -77
  88. package/dist/cjs/recovery-protocol.cjs +0 -31
  89. package/dist/cjs/recovery-store.cjs +0 -252
  90. package/dist/cjs/registry-auth.cjs +0 -310
  91. package/dist/cjs/repository-transition-policy.cjs +0 -49
  92. package/dist/cjs/runtime-version.cjs +0 -88
  93. package/dist/cjs/session-file-mutations.cjs +0 -61
  94. package/dist/cjs/supervisor.cjs +0 -147
  95. package/dist/cjs/three-way-merge.cjs +0 -346
  96. package/dist/cjs/working-tree-mirror.cjs +0 -1872
  97. package/dist/cjs/workspace-automatic-sync-policy.cjs +0 -79
  98. package/dist/cjs/workspace-branch-incarnation-policy.cjs +0 -37
  99. package/dist/cjs/workspace-command-sync-policy.cjs +0 -112
  100. package/dist/cjs/workspace-command-targets.cjs +0 -63
  101. package/dist/cjs/workspace-filesystem-executor-thread.cjs +0 -36
  102. package/dist/cjs/workspace-filesystem-executor.cjs +0 -327
  103. package/dist/cjs/workspace-filesystem-job-types.cjs +0 -144
  104. package/dist/cjs/workspace-filesystem-jobs.cjs +0 -59
  105. package/dist/cjs/workspace-git-sync.cjs +0 -3595
  106. package/dist/cjs/workspace-hydration-ledger.cjs +0 -83
  107. package/dist/cjs/workspace-hydration-merge.cjs +0 -448
  108. package/dist/cjs/workspace-hydration-recovery-state.cjs +0 -53
  109. package/dist/cjs/workspace-incident-state.cjs +0 -37
  110. package/dist/cjs/workspace-merge-projection.cjs +0 -628
  111. package/dist/cjs/workspace-mount-boundary.cjs +0 -71
  112. package/dist/cjs/workspace-mount-hold-fence.cjs +0 -120
  113. package/dist/cjs/workspace-mutation-gate.cjs +0 -127
  114. package/dist/cjs/workspace-path-move.cjs +0 -195
  115. package/dist/cjs/workspace-preserve-only-policy.cjs +0 -36
  116. package/dist/cjs/workspace-project-config-policy.cjs +0 -53
  117. package/dist/cjs/workspace-projection-ledger.cjs +0 -81
  118. package/dist/cjs/workspace-publication-evidence.cjs +0 -46
  119. package/dist/cjs/workspace-sync-coalescer.cjs +0 -58
  120. package/dist/mjs/atomic-rename.mjs +0 -261
  121. package/dist/mjs/browser-upload.mjs +0 -42
  122. package/dist/mjs/command-launcher.mjs +0 -393
  123. package/dist/mjs/control-command-policy.mjs +0 -146
  124. package/dist/mjs/git-blob-hash.mjs +0 -16
  125. package/dist/mjs/git-identity.mjs +0 -15
  126. package/dist/mjs/git-process-environment.mjs +0 -105
  127. package/dist/mjs/inline-output.mjs +0 -37
  128. package/dist/mjs/managed-paths.mjs +0 -174
  129. package/dist/mjs/plan-lint.mjs +0 -129
  130. package/dist/mjs/plan-parser.mjs +0 -94
  131. package/dist/mjs/plan-paths.mjs +0 -25
  132. package/dist/mjs/port-forward-client.mjs +0 -172
  133. package/dist/mjs/project-checkout-garbage.mjs +0 -178
  134. package/dist/mjs/project-mirror-fetch-policy.mjs +0 -56
  135. package/dist/mjs/project-mirror-refs-token.mjs +0 -53
  136. package/dist/mjs/project-workspace-state.mjs +0 -937
  137. package/dist/mjs/project-worktrees.mjs +0 -1657
  138. package/dist/mjs/pty-output-coalescer.mjs +0 -61
  139. package/dist/mjs/recovery-journal-protocol.mjs +0 -30
  140. package/dist/mjs/recovery-journal-runtime.mjs +0 -112
  141. package/dist/mjs/recovery-journal-thread.mjs +0 -8
  142. package/dist/mjs/recovery-journal.mjs +0 -694
  143. package/dist/mjs/recovery-output-window.mjs +0 -53
  144. package/dist/mjs/recovery-protocol.mjs +0 -6
  145. package/dist/mjs/recovery-store.mjs +0 -217
  146. package/dist/mjs/registry-auth.mjs +0 -269
  147. package/dist/mjs/repository-transition-policy.mjs +0 -22
  148. package/dist/mjs/runtime-version.mjs +0 -54
  149. package/dist/mjs/session-file-mutations.mjs +0 -37
  150. package/dist/mjs/supervisor.mjs +0 -114
  151. package/dist/mjs/three-way-merge.mjs +0 -318
  152. package/dist/mjs/working-tree-mirror.mjs +0 -1817
  153. package/dist/mjs/workspace-automatic-sync-policy.mjs +0 -48
  154. package/dist/mjs/workspace-branch-incarnation-policy.mjs +0 -13
  155. package/dist/mjs/workspace-command-sync-policy.mjs +0 -84
  156. package/dist/mjs/workspace-command-targets.mjs +0 -37
  157. package/dist/mjs/workspace-filesystem-executor-thread.mjs +0 -38
  158. package/dist/mjs/workspace-filesystem-executor.mjs +0 -287
  159. package/dist/mjs/workspace-filesystem-job-types.mjs +0 -116
  160. package/dist/mjs/workspace-filesystem-jobs.mjs +0 -55
  161. package/dist/mjs/workspace-git-sync.mjs +0 -3553
  162. package/dist/mjs/workspace-hydration-ledger.mjs +0 -58
  163. package/dist/mjs/workspace-hydration-merge.mjs +0 -414
  164. package/dist/mjs/workspace-hydration-recovery-state.mjs +0 -29
  165. package/dist/mjs/workspace-incident-state.mjs +0 -12
  166. package/dist/mjs/workspace-merge-projection.mjs +0 -594
  167. package/dist/mjs/workspace-mount-boundary.mjs +0 -37
  168. package/dist/mjs/workspace-mount-hold-fence.mjs +0 -95
  169. package/dist/mjs/workspace-mutation-gate.mjs +0 -103
  170. package/dist/mjs/workspace-path-move.mjs +0 -160
  171. package/dist/mjs/workspace-preserve-only-policy.mjs +0 -11
  172. package/dist/mjs/workspace-project-config-policy.mjs +0 -27
  173. package/dist/mjs/workspace-projection-ledger.mjs +0 -57
  174. package/dist/mjs/workspace-publication-evidence.mjs +0 -21
  175. package/dist/mjs/workspace-sync-coalescer.mjs +0 -34
  176. package/dist/types/atomic-rename.d.ts +0 -78
  177. package/dist/types/browser-upload.d.ts +0 -7
  178. package/dist/types/command-launcher.d.ts +0 -104
  179. package/dist/types/control-command-policy.d.ts +0 -53
  180. package/dist/types/git-blob-hash.d.ts +0 -10
  181. package/dist/types/git-identity.d.ts +0 -9
  182. package/dist/types/git-process-environment.d.ts +0 -9
  183. package/dist/types/inline-output.d.ts +0 -3
  184. package/dist/types/managed-paths.d.ts +0 -19
  185. package/dist/types/plan-lint.d.ts +0 -16
  186. package/dist/types/plan-parser.d.ts +0 -38
  187. package/dist/types/plan-paths.d.ts +0 -36
  188. package/dist/types/port-forward-client.d.ts +0 -8
  189. package/dist/types/project-checkout-garbage.d.ts +0 -86
  190. package/dist/types/project-mirror-fetch-policy.d.ts +0 -84
  191. package/dist/types/project-mirror-refs-token.d.ts +0 -53
  192. package/dist/types/project-workspace-state.d.ts +0 -188
  193. package/dist/types/project-worktrees.d.ts +0 -397
  194. package/dist/types/pty-output-coalescer.d.ts +0 -20
  195. package/dist/types/recovery-journal-protocol.d.ts +0 -35
  196. package/dist/types/recovery-journal-runtime.d.ts +0 -12
  197. package/dist/types/recovery-journal-stall-fixture.d.ts +0 -1
  198. package/dist/types/recovery-journal-thread.d.ts +0 -1
  199. package/dist/types/recovery-journal.d.ts +0 -248
  200. package/dist/types/recovery-output-window.d.ts +0 -19
  201. package/dist/types/recovery-protocol.d.ts +0 -59
  202. package/dist/types/recovery-store.d.ts +0 -52
  203. package/dist/types/registry-auth.d.ts +0 -47
  204. package/dist/types/repository-transition-policy.d.ts +0 -26
  205. package/dist/types/runtime-version.d.ts +0 -1
  206. package/dist/types/session-file-mutations.d.ts +0 -22
  207. package/dist/types/supervisor-daemonized-fixture.d.ts +0 -1
  208. package/dist/types/supervisor-launcher-cleanup-fixture.d.ts +0 -1
  209. package/dist/types/supervisor-signal-fixture.d.ts +0 -1
  210. package/dist/types/supervisor.d.ts +0 -23
  211. package/dist/types/three-way-merge.d.ts +0 -77
  212. package/dist/types/working-tree-mirror.d.ts +0 -424
  213. package/dist/types/workspace-automatic-sync-policy.d.ts +0 -57
  214. package/dist/types/workspace-branch-incarnation-policy.d.ts +0 -14
  215. package/dist/types/workspace-command-sync-policy.d.ts +0 -57
  216. package/dist/types/workspace-command-targets.d.ts +0 -37
  217. package/dist/types/workspace-filesystem-executor-thread.d.ts +0 -1
  218. package/dist/types/workspace-filesystem-executor.d.ts +0 -123
  219. package/dist/types/workspace-filesystem-job-types.d.ts +0 -302
  220. package/dist/types/workspace-filesystem-jobs.d.ts +0 -7
  221. package/dist/types/workspace-git-sync.d.ts +0 -514
  222. package/dist/types/workspace-hydration-ledger.d.ts +0 -76
  223. package/dist/types/workspace-hydration-merge.d.ts +0 -103
  224. package/dist/types/workspace-hydration-recovery-state.d.ts +0 -10
  225. package/dist/types/workspace-incident-state.d.ts +0 -19
  226. package/dist/types/workspace-merge-projection.d.ts +0 -69
  227. package/dist/types/workspace-mount-boundary.d.ts +0 -10
  228. package/dist/types/workspace-mount-hold-fence.d.ts +0 -42
  229. package/dist/types/workspace-mutation-gate.d.ts +0 -42
  230. package/dist/types/workspace-path-move.d.ts +0 -21
  231. package/dist/types/workspace-preserve-only-policy.d.ts +0 -15
  232. package/dist/types/workspace-project-config-policy.d.ts +0 -48
  233. package/dist/types/workspace-projection-ledger.d.ts +0 -59
  234. package/dist/types/workspace-publication-evidence.d.ts +0 -17
  235. package/dist/types/workspace-sync-coalescer.d.ts +0 -28
  236. /package/dist/types/{credential-authority-lock-fixture.d.ts → runtime/releases/main.d.ts} +0 -0
@@ -1,71 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var workspace_mount_boundary_exports = {};
30
- __export(workspace_mount_boundary_exports, {
31
- assertManagedDirectoryPath: () => assertManagedDirectoryPath
32
- });
33
- module.exports = __toCommonJS(workspace_mount_boundary_exports);
34
- var import_node_fs = __toESM(require("node:fs"), 1);
35
- var import_node_path = __toESM(require("node:path"), 1);
36
- function containedRelative(root, candidate) {
37
- const relative = import_node_path.default.relative(root, candidate);
38
- if (!relative || relative === ".." || relative.startsWith(`..${import_node_path.default.sep}`) || import_node_path.default.isAbsolute(relative)) {
39
- throw new Error(`Managed directory path escapes its trusted root: ${candidate}`);
40
- }
41
- return relative;
42
- }
43
- function assertManagedDirectoryPath(input) {
44
- const trustedRoot = import_node_path.default.resolve(input.trustedRoot);
45
- const candidate = import_node_path.default.resolve(input.candidate);
46
- const relative = containedRelative(trustedRoot, candidate);
47
- const rootStatus = import_node_fs.default.lstatSync(trustedRoot);
48
- if (!rootStatus.isDirectory() || rootStatus.isSymbolicLink()) {
49
- throw new Error(`${input.label} trusted root is not a regular directory: ${trustedRoot}`);
50
- }
51
- const realRoot = import_node_fs.default.realpathSync(trustedRoot);
52
- let current = trustedRoot;
53
- for (const segment of relative.split(import_node_path.default.sep)) {
54
- current = import_node_path.default.join(current, segment);
55
- let status;
56
- try {
57
- status = import_node_fs.default.lstatSync(current);
58
- } catch (error) {
59
- if (error.code === "ENOENT") return;
60
- throw error;
61
- }
62
- if (!status.isDirectory() || status.isSymbolicLink()) {
63
- throw new Error(`${input.label} contains a symlink or non-directory component: ${current}`);
64
- }
65
- containedRelative(realRoot, import_node_fs.default.realpathSync(current));
66
- }
67
- }
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- assertManagedDirectoryPath
71
- });
@@ -1,120 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var workspace_mount_hold_fence_exports = {};
20
- __export(workspace_mount_hold_fence_exports, {
21
- WorkspaceMountHoldAbortedError: () => WorkspaceMountHoldAbortedError,
22
- WorkspaceMountHoldFence: () => WorkspaceMountHoldFence
23
- });
24
- module.exports = __toCommonJS(workspace_mount_hold_fence_exports);
25
- class WorkspaceMountHoldAbortedError extends Error {
26
- constructor(reason) {
27
- super(reason);
28
- this.name = "WorkspaceMountHoldAbortedError";
29
- }
30
- }
31
- class WorkspaceMountHoldFence {
32
- holds = /* @__PURE__ */ new Map();
33
- waiters = /* @__PURE__ */ new Set();
34
- now;
35
- constructor(options = {}) {
36
- this.now = options.now ?? (() => Date.now());
37
- }
38
- /** Take one hold on every listed mount; the returned release is idempotent. */
39
- hold(mountIds, description) {
40
- const ids = [...new Set(mountIds)];
41
- for (const id of ids) {
42
- const existing = this.holds.get(id);
43
- if (existing) {
44
- existing.count += 1;
45
- continue;
46
- }
47
- this.holds.set(id, { count: 1, description, sinceMs: this.now() });
48
- }
49
- let released = false;
50
- return () => {
51
- if (released) return;
52
- released = true;
53
- for (const id of ids) {
54
- const existing = this.holds.get(id);
55
- if (!existing) continue;
56
- existing.count -= 1;
57
- if (existing.count === 0) this.holds.delete(id);
58
- }
59
- this.wake();
60
- };
61
- }
62
- isHeld(mountIds) {
63
- return mountIds.some((id) => this.holds.has(id));
64
- }
65
- /** Human-readable holder of the first held mount among `mountIds`, for diagnostics. */
66
- describeHold(mountIds) {
67
- for (const id of mountIds) {
68
- const hold = this.holds.get(id);
69
- if (hold) return `${hold.description} (held for ${Math.round((this.now() - hold.sinceMs) / 1e3)}s)`;
70
- }
71
- return null;
72
- }
73
- /** Every held mount id, sorted, for status reporting. */
74
- heldMountIds() {
75
- return [...this.holds.keys()].sort();
76
- }
77
- /**
78
- * Resolves in the same turn as the release that leaves none of `mountIds`
79
- * held, so the caller can re-check and reserve without an interleaving
80
- * hold. Resolves immediately when nothing is held. Rejects with
81
- * WorkspaceMountHoldAbortedError when `signal` aborts first.
82
- */
83
- waitForRelease(mountIds, options = {}) {
84
- if (options.signal?.aborted) {
85
- return Promise.reject(new WorkspaceMountHoldAbortedError(abortReason(options.signal)));
86
- }
87
- if (!this.isHeld(mountIds)) return Promise.resolve();
88
- return new Promise((resolve, reject) => {
89
- const waiter = { mountIds, resolve, reject, signal: options.signal };
90
- if (options.signal) {
91
- const signal = options.signal;
92
- waiter.onAbort = () => {
93
- this.waiters.delete(waiter);
94
- reject(new WorkspaceMountHoldAbortedError(abortReason(signal)));
95
- };
96
- signal.addEventListener("abort", waiter.onAbort, { once: true });
97
- }
98
- this.waiters.add(waiter);
99
- });
100
- }
101
- wake() {
102
- for (const waiter of [...this.waiters]) {
103
- if (this.isHeld(waiter.mountIds)) continue;
104
- this.waiters.delete(waiter);
105
- if (waiter.signal && waiter.onAbort) waiter.signal.removeEventListener("abort", waiter.onAbort);
106
- waiter.resolve();
107
- }
108
- }
109
- }
110
- function abortReason(signal) {
111
- const reason = signal.reason;
112
- if (reason instanceof Error) return reason.message;
113
- if (typeof reason === "string" && reason) return reason;
114
- return "Workspace mount reservation was aborted";
115
- }
116
- // Annotate the CommonJS export names for ESM import in node:
117
- 0 && (module.exports = {
118
- WorkspaceMountHoldAbortedError,
119
- WorkspaceMountHoldFence
120
- });
@@ -1,127 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var workspace_mutation_gate_exports = {};
20
- __export(workspace_mutation_gate_exports, {
21
- WorkspaceMutationGate: () => WorkspaceMutationGate
22
- });
23
- module.exports = __toCommonJS(workspace_mutation_gate_exports);
24
- class WorkspaceMutationGate {
25
- activeMutations = 0;
26
- syncActive = false;
27
- waiters = [];
28
- acquireMutation() {
29
- return new Promise((resolve) => {
30
- this.waiters.push({ kind: "mutation", resolve });
31
- this.drain();
32
- });
33
- }
34
- async runMutation(operation) {
35
- const release = await this.acquireMutation();
36
- try {
37
- return await operation();
38
- } finally {
39
- release();
40
- }
41
- }
42
- async runSync(operation) {
43
- const release = await new Promise((resolve) => {
44
- this.waiters.push({ kind: "sync", resolve });
45
- this.drain();
46
- });
47
- try {
48
- return await operation();
49
- } finally {
50
- release();
51
- }
52
- }
53
- /** A worktree create/delete lease; see the branch lane in the class comment. */
54
- acquireBranchMutation() {
55
- return new Promise((resolve) => {
56
- this.waiters.push({ kind: "branch", resolve });
57
- this.drain();
58
- });
59
- }
60
- async runBranchMutation(operation) {
61
- const release = await this.acquireBranchMutation();
62
- try {
63
- return await operation();
64
- } finally {
65
- release();
66
- }
67
- }
68
- /**
69
- * Operations a branch mutation requested now would wait for: the running
70
- * sync, if any, plus branch mutations queued behind it. Zero means it runs
71
- * at once. Ordinary waiters are not counted because the branch lane admits
72
- * ahead of them.
73
- */
74
- branchMutationQueuePosition() {
75
- if (!this.syncActive) return 0;
76
- return 1 + this.waiters.filter((waiter) => waiter.kind === "branch").length;
77
- }
78
- drain() {
79
- if (this.syncActive || this.waiters.length === 0) return;
80
- for (let index = 0; index < this.waiters.length; ) {
81
- const waiter = this.waiters[index];
82
- if (waiter?.kind !== "branch") {
83
- index += 1;
84
- continue;
85
- }
86
- this.waiters.splice(index, 1);
87
- this.activeMutations += 1;
88
- waiter.resolve(this.releaseMutation());
89
- }
90
- const first = this.waiters[0];
91
- if (first?.kind === "sync") {
92
- if (this.activeMutations > 0) return;
93
- this.waiters.shift();
94
- this.syncActive = true;
95
- first.resolve(this.releaseSync());
96
- return;
97
- }
98
- while (this.waiters[0]?.kind === "mutation") {
99
- const waiter = this.waiters.shift();
100
- if (!waiter || waiter.kind !== "mutation") break;
101
- this.activeMutations += 1;
102
- waiter.resolve(this.releaseMutation());
103
- }
104
- }
105
- releaseMutation() {
106
- let released = false;
107
- return () => {
108
- if (released) return;
109
- released = true;
110
- this.activeMutations -= 1;
111
- this.drain();
112
- };
113
- }
114
- releaseSync() {
115
- let released = false;
116
- return () => {
117
- if (released) return;
118
- released = true;
119
- this.syncActive = false;
120
- this.drain();
121
- };
122
- }
123
- }
124
- // Annotate the CommonJS export names for ESM import in node:
125
- 0 && (module.exports = {
126
- WorkspaceMutationGate
127
- });
@@ -1,195 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var workspace_path_move_exports = {};
30
- __export(workspace_path_move_exports, {
31
- checkoutPathMovePublicationComplete: () => checkoutPathMovePublicationComplete,
32
- preserveProjectCheckoutPathMove: () => preserveProjectCheckoutPathMove
33
- });
34
- module.exports = __toCommonJS(workspace_path_move_exports);
35
- var import_node_fs = __toESM(require("node:fs"), 1);
36
- var import_node_path = __toESM(require("node:path"), 1);
37
- var import_node_crypto = require("node:crypto");
38
- var import_project_worktrees = require("./project-worktrees.cjs");
39
- var import_managed_paths = require("./managed-paths.cjs");
40
- var import_working_tree_mirror = require("./working-tree-mirror.cjs");
41
- var import_workspace_mount_boundary = require("./workspace-mount-boundary.cjs");
42
- function checkoutPathMovePublicationComplete(requiredMountIds, activeMountIds) {
43
- return requiredMountIds.length > 0 && requiredMountIds.every((mountId) => activeMountIds.has(mountId));
44
- }
45
- function pathIsInside(root, candidate) {
46
- const relative = import_node_path.default.relative(import_node_path.default.resolve(root), import_node_path.default.resolve(candidate));
47
- return relative !== "" && relative !== ".." && !relative.startsWith(`..${import_node_path.default.sep}`) && !import_node_path.default.isAbsolute(relative);
48
- }
49
- function fsyncTree(targetPath) {
50
- const stat = import_node_fs.default.lstatSync(targetPath);
51
- if (stat.isSymbolicLink()) return;
52
- if (stat.isDirectory()) {
53
- for (const entry of import_node_fs.default.readdirSync(targetPath).sort()) fsyncTree(import_node_path.default.join(targetPath, entry));
54
- }
55
- if (!stat.isDirectory() && !stat.isFile()) return;
56
- const descriptor = import_node_fs.default.openSync(targetPath, "r");
57
- try {
58
- import_node_fs.default.fsyncSync(descriptor);
59
- } finally {
60
- import_node_fs.default.closeSync(descriptor);
61
- }
62
- }
63
- function fsyncDirectory(directoryPath) {
64
- const descriptor = import_node_fs.default.openSync(directoryPath, "r");
65
- try {
66
- import_node_fs.default.fsyncSync(descriptor);
67
- } finally {
68
- import_node_fs.default.closeSync(descriptor);
69
- }
70
- }
71
- function fsyncAncestorsToRoot(targetPath, durabilityRoot) {
72
- const root = import_node_path.default.resolve(durabilityRoot);
73
- let current = import_node_path.default.dirname(import_node_path.default.resolve(targetPath));
74
- while (true) {
75
- if (import_node_fs.default.existsSync(current)) {
76
- const status = import_node_fs.default.lstatSync(current);
77
- if (!status.isDirectory() || status.isSymbolicLink()) {
78
- throw new Error(`Project checkout path move durability boundary is not a regular directory: ${current}`);
79
- }
80
- fsyncDirectory(current);
81
- }
82
- if (current === root) return;
83
- const parent = import_node_path.default.dirname(current);
84
- if (parent === current) throw new Error(`Project checkout path move escapes durability root ${root}`);
85
- current = parent;
86
- }
87
- }
88
- function stableTree(targetPath, durabilityRoot) {
89
- fsyncTree(targetPath);
90
- fsyncAncestorsToRoot(targetPath, durabilityRoot);
91
- }
92
- function directoryEntryExists(targetPath) {
93
- try {
94
- import_node_fs.default.lstatSync(targetPath);
95
- return true;
96
- } catch (error) {
97
- if (error.code === "ENOENT") return false;
98
- throw error;
99
- }
100
- }
101
- function retiredCheckoutPath(projectsDurabilityRoot, oldProjectRoot) {
102
- const storageRoot = import_node_path.default.join(projectsDurabilityRoot, ".r5d-retired-checkouts");
103
- const digest = (0, import_node_crypto.createHash)("sha256").update(oldProjectRoot).digest("hex");
104
- return { storageRoot, retiredRoot: import_node_path.default.join(storageRoot, digest) };
105
- }
106
- function removeRetiredCheckout(retiredRoot, storageRoot) {
107
- if (!directoryEntryExists(retiredRoot)) return;
108
- import_node_fs.default.rmSync(retiredRoot, { recursive: true, force: true });
109
- fsyncDirectory(storageRoot);
110
- }
111
- function preserveProjectCheckoutPathMove(input) {
112
- const oldProjectRoot = import_node_path.default.resolve(input.oldProjectRoot);
113
- const newProjectRoot = import_node_path.default.resolve(input.newProjectRoot);
114
- const projectsDurabilityRoot = import_node_path.default.resolve(input.projectsDurabilityRoot);
115
- const outerWorkspaceRoot = import_node_path.default.resolve(input.outerWorkspaceRoot);
116
- if (oldProjectRoot === newProjectRoot || pathIsInside(oldProjectRoot, newProjectRoot) || pathIsInside(newProjectRoot, oldProjectRoot)) {
117
- throw new Error("Project checkout path move roots overlap");
118
- }
119
- const branchNames = input.branches.map(({ branchName }) => branchName);
120
- if (branchNames.length === 0 || new Set(branchNames).size !== branchNames.length) {
121
- throw new Error("Project checkout path move requires unique branches");
122
- }
123
- (0, import_workspace_mount_boundary.assertManagedDirectoryPath)({
124
- trustedRoot: projectsDurabilityRoot,
125
- candidate: oldProjectRoot,
126
- label: "Old project checkout root"
127
- });
128
- (0, import_workspace_mount_boundary.assertManagedDirectoryPath)({
129
- trustedRoot: projectsDurabilityRoot,
130
- candidate: newProjectRoot,
131
- label: "New project checkout root"
132
- });
133
- for (const branchName of branchNames) (0, import_managed_paths.validateManagedBranchName)(branchName);
134
- if (directoryEntryExists(oldProjectRoot)) {
135
- (0, import_working_tree_mirror.assertWorkingTreeHasNoPortableGitMetadataAliases)(oldProjectRoot);
136
- }
137
- const { storageRoot: retirementStorageRoot, retiredRoot } = retiredCheckoutPath(projectsDurabilityRoot, oldProjectRoot);
138
- (0, import_workspace_mount_boundary.assertManagedDirectoryPath)({
139
- trustedRoot: projectsDurabilityRoot,
140
- candidate: retirementStorageRoot,
141
- label: "Retired project checkout storage"
142
- });
143
- import_node_fs.default.mkdirSync(retirementStorageRoot, { recursive: true, mode: 448 });
144
- (0, import_workspace_mount_boundary.assertManagedDirectoryPath)({
145
- trustedRoot: projectsDurabilityRoot,
146
- candidate: retirementStorageRoot,
147
- label: "Retired project checkout storage"
148
- });
149
- fsyncDirectory(retirementStorageRoot);
150
- fsyncDirectory(projectsDurabilityRoot);
151
- (0, import_workspace_mount_boundary.assertManagedDirectoryPath)({
152
- trustedRoot: projectsDurabilityRoot,
153
- candidate: retiredRoot,
154
- label: "Retired project checkout"
155
- });
156
- removeRetiredCheckout(retiredRoot, retirementStorageRoot);
157
- if (!directoryEntryExists(oldProjectRoot)) return { preservedBranchNames: [] };
158
- const preservedBranchNames = [];
159
- for (const branch of input.branches) {
160
- (0, import_managed_paths.validateManagedBranchName)(branch.branchName);
161
- const oldBranchPath = import_node_path.default.join(oldProjectRoot, ...branch.branchName.split("/"));
162
- if (!import_node_fs.default.existsSync(oldBranchPath)) continue;
163
- const newBranchPath = import_node_path.default.join(newProjectRoot, ...branch.branchName.split("/"));
164
- const outerBranchPath = import_node_path.default.resolve(outerWorkspaceRoot, ...branch.outerWorkspaceRelativePath.replace(/\\/g, "/").split("/"));
165
- if (!pathIsInside(outerWorkspaceRoot, outerBranchPath)) {
166
- throw new Error(`Project checkout path move escapes the outer workspace: ${branch.outerWorkspaceRelativePath}`);
167
- }
168
- (0, import_workspace_mount_boundary.assertManagedDirectoryPath)({ trustedRoot: projectsDurabilityRoot, candidate: oldBranchPath, label: "Old project checkout branch" });
169
- (0, import_workspace_mount_boundary.assertManagedDirectoryPath)({ trustedRoot: projectsDurabilityRoot, candidate: newBranchPath, label: "New project checkout branch" });
170
- (0, import_workspace_mount_boundary.assertManagedDirectoryPath)({ trustedRoot: outerWorkspaceRoot, candidate: outerBranchPath, label: "Outer workspace branch" });
171
- (0, import_working_tree_mirror.mirrorWorkingTree)({ sourceRoot: oldBranchPath, targetRoot: outerBranchPath, sourceMode: "git", deletionMode: "all" });
172
- (0, import_working_tree_mirror.mirrorWorkingTree)({ sourceRoot: oldBranchPath, targetRoot: newBranchPath, sourceMode: "all", deletionMode: "all" });
173
- (0, import_workspace_mount_boundary.assertManagedDirectoryPath)({ trustedRoot: projectsDurabilityRoot, candidate: newBranchPath, label: "New project checkout branch" });
174
- (0, import_workspace_mount_boundary.assertManagedDirectoryPath)({ trustedRoot: outerWorkspaceRoot, candidate: outerBranchPath, label: "Outer workspace branch" });
175
- stableTree(outerBranchPath, outerWorkspaceRoot);
176
- stableTree(newBranchPath, projectsDurabilityRoot);
177
- preservedBranchNames.push(branch.branchName);
178
- }
179
- for (const branchName of branchNames) {
180
- const checkoutPath = import_node_path.default.join(oldProjectRoot, ...branchName.split("/"));
181
- if (import_node_fs.default.existsSync(checkoutPath) && (0, import_project_worktrees.projectWorktreeOperationInProgress)(checkoutPath)) {
182
- throw new Error(`Project branch ${branchName} has an in-progress Git operation`);
183
- }
184
- }
185
- import_node_fs.default.renameSync(oldProjectRoot, retiredRoot);
186
- fsyncAncestorsToRoot(oldProjectRoot, projectsDurabilityRoot);
187
- fsyncDirectory(retirementStorageRoot);
188
- removeRetiredCheckout(retiredRoot, retirementStorageRoot);
189
- return { preservedBranchNames: preservedBranchNames.sort() };
190
- }
191
- // Annotate the CommonJS export names for ESM import in node:
192
- 0 && (module.exports = {
193
- checkoutPathMovePublicationComplete,
194
- preserveProjectCheckoutPathMove
195
- });
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var workspace_preserve_only_policy_exports = {};
20
- __export(workspace_preserve_only_policy_exports, {
21
- creatorLocalProjectBranchIsAuthorized: () => creatorLocalProjectBranchIsAuthorized,
22
- workerProjectBranchDisposition: () => workerProjectBranchDisposition
23
- });
24
- module.exports = __toCommonJS(workspace_preserve_only_policy_exports);
25
- function creatorLocalProjectBranchIsAuthorized(input) {
26
- return Boolean(input.pendingBranchId && (!input.preserveOnlyBranchId || input.pendingBranchId === input.preserveOnlyBranchId));
27
- }
28
- function workerProjectBranchDisposition(input) {
29
- if (input.activeConfigured) return "active";
30
- return input.locallyPendingCreated ? "creator_local" : "preserve_only";
31
- }
32
- // Annotate the CommonJS export names for ESM import in node:
33
- 0 && (module.exports = {
34
- creatorLocalProjectBranchIsAuthorized,
35
- workerProjectBranchDisposition
36
- });
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var workspace_project_config_policy_exports = {};
20
- __export(workspace_project_config_policy_exports, {
21
- busyProjectConfigurationChanges: () => busyProjectConfigurationChanges,
22
- deferredProjectConfigurationPendingBranches: () => deferredProjectConfigurationPendingBranches,
23
- describeBusyProjectConfigurationChanges: () => describeBusyProjectConfigurationChanges
24
- });
25
- module.exports = __toCommonJS(workspace_project_config_policy_exports);
26
- function deferredProjectConfigurationPendingBranches(projects) {
27
- return projects.filter((project) => !project.executionDisabled).flatMap((project) => project.branches.map(({ branchName }) => ({ projectId: project.projectId, branchName }))).sort((left, right) => left.projectId.localeCompare(right.projectId) || left.branchName.localeCompare(right.branchName));
28
- }
29
- function busyProjectConfigurationChanges(input) {
30
- const currentById = new Map(input.currentProjects.map((project) => [project.projectId, project]));
31
- const incomingById = new Map(input.incomingProjects.map((project) => [project.projectId, project]));
32
- const targets = [...input.activeTargets];
33
- const busyProjectIds = targets.some((target) => target.type === "workspace" && target.rootProfile === "visible_projects") ? /* @__PURE__ */ new Set([...currentById.keys(), ...incomingById.keys()]) : new Set(targets.flatMap((target) => target.type === "project" ? [target.projectId] : []));
34
- return [...busyProjectIds].flatMap((projectId) => {
35
- const current = currentById.get(projectId);
36
- const incoming = incomingById.get(projectId);
37
- if (!current && !incoming) return [];
38
- if (!current) return [{ projectId, reason: "added" }];
39
- if (!incoming) return [{ projectId, reason: "removed" }];
40
- if (!input.currentProjectReady(current)) return [{ projectId, reason: "initializing" }];
41
- if (input.currentFingerprint(current) !== input.incomingFingerprint(incoming)) return [{ projectId, reason: "changed" }];
42
- return [];
43
- }).sort((left, right) => left.projectId.localeCompare(right.projectId));
44
- }
45
- function describeBusyProjectConfigurationChanges(changes) {
46
- return changes.map(({ projectId, reason }) => `${projectId} (${reason})`).join(", ");
47
- }
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {
50
- busyProjectConfigurationChanges,
51
- deferredProjectConfigurationPendingBranches,
52
- describeBusyProjectConfigurationChanges
53
- });