@ricsam/r5d-worker 0.0.136 → 0.0.138

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 (240) hide show
  1. package/README.md +4 -94
  2. package/dist/cjs/package.json +1 -1
  3. package/dist/mjs/main.mjs +46 -7537
  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 +328 -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 +17 -0
  41. package/dist/types/runtime/daemon.d.ts +8 -0
  42. package/dist/types/runtime/executor.d.ts +35 -0
  43. package/dist/types/runtime/index.d.ts +5 -0
  44. package/dist/types/runtime/protocol.d.ts +544 -0
  45. package/dist/types/runtime/pty.d.ts +30 -0
  46. package/dist/types/runtime/releases/artifacts.d.ts +51 -0
  47. package/dist/types/runtime/releases/grants.d.ts +16 -0
  48. package/dist/types/runtime/releases/manager.d.ts +145 -0
  49. package/dist/types/runtime/releases/process.d.ts +14 -0
  50. package/dist/types/runtime/releases/retirement.d.ts +15 -0
  51. package/dist/types/runtime/releases/rpc-client.d.ts +52 -0
  52. package/dist/types/runtime/releases/rpc-main.d.ts +10 -0
  53. package/dist/types/runtime/releases/rpc-protocol.d.ts +1139 -0
  54. package/dist/types/runtime/storage.d.ts +21 -0
  55. package/dist/types/runtime/test-harness.d.ts +53 -0
  56. package/dist/types/runtime/workspace/artifacts.d.ts +30 -0
  57. package/dist/types/runtime/workspace/authority.d.ts +338 -0
  58. package/dist/types/runtime/workspace/contracts.d.ts +86 -0
  59. package/dist/types/runtime/workspace/file-write.d.ts +14 -0
  60. package/dist/types/runtime/workspace/files.d.ts +21 -0
  61. package/dist/types/runtime/workspace/http-body.d.ts +9 -0
  62. package/dist/types/runtime/workspace/storage-client.d.ts +23 -0
  63. package/dist/types/runtime/workspace/storage-wire.d.ts +138 -0
  64. package/package.json +8 -6
  65. package/dist/cjs/atomic-rename.cjs +0 -303
  66. package/dist/cjs/browser-upload.cjs +0 -73
  67. package/dist/cjs/cli-update.cjs +0 -108
  68. package/dist/cjs/command-launcher.cjs +0 -423
  69. package/dist/cjs/control-command-policy.cjs +0 -177
  70. package/dist/cjs/git-blob-hash.cjs +0 -41
  71. package/dist/cjs/git-identity.cjs +0 -39
  72. package/dist/cjs/git-process-environment.cjs +0 -133
  73. package/dist/cjs/inline-output.cjs +0 -62
  74. package/dist/cjs/main.cjs +0 -7511
  75. package/dist/cjs/managed-paths.cjs +0 -215
  76. package/dist/cjs/plan-lint.cjs +0 -165
  77. package/dist/cjs/plan-parser.cjs +0 -127
  78. package/dist/cjs/plan-paths.cjs +0 -53
  79. package/dist/cjs/port-forward-client.cjs +0 -206
  80. package/dist/cjs/process-tree.cjs +0 -117
  81. package/dist/cjs/project-checkout-garbage.cjs +0 -219
  82. package/dist/cjs/project-mirror-fetch-policy.cjs +0 -82
  83. package/dist/cjs/project-mirror-refs-token.cjs +0 -85
  84. package/dist/cjs/project-workspace-state.cjs +0 -972
  85. package/dist/cjs/project-worktrees.cjs +0 -1713
  86. package/dist/cjs/pty-output-coalescer.cjs +0 -87
  87. package/dist/cjs/recovery-journal-protocol.cjs +0 -56
  88. package/dist/cjs/recovery-journal-runtime.cjs +0 -133
  89. package/dist/cjs/recovery-journal-thread.cjs +0 -9
  90. package/dist/cjs/recovery-journal.cjs +0 -742
  91. package/dist/cjs/recovery-output-window.cjs +0 -77
  92. package/dist/cjs/recovery-protocol.cjs +0 -31
  93. package/dist/cjs/recovery-store.cjs +0 -252
  94. package/dist/cjs/registry-auth.cjs +0 -310
  95. package/dist/cjs/repository-transition-policy.cjs +0 -49
  96. package/dist/cjs/runtime-version.cjs +0 -88
  97. package/dist/cjs/session-file-mutations.cjs +0 -61
  98. package/dist/cjs/supervisor.cjs +0 -147
  99. package/dist/cjs/three-way-merge.cjs +0 -346
  100. package/dist/cjs/working-tree-mirror.cjs +0 -1872
  101. package/dist/cjs/workspace-automatic-sync-policy.cjs +0 -79
  102. package/dist/cjs/workspace-branch-incarnation-policy.cjs +0 -37
  103. package/dist/cjs/workspace-command-sync-policy.cjs +0 -112
  104. package/dist/cjs/workspace-command-targets.cjs +0 -63
  105. package/dist/cjs/workspace-filesystem-executor-thread.cjs +0 -36
  106. package/dist/cjs/workspace-filesystem-executor.cjs +0 -327
  107. package/dist/cjs/workspace-filesystem-job-types.cjs +0 -144
  108. package/dist/cjs/workspace-filesystem-jobs.cjs +0 -59
  109. package/dist/cjs/workspace-git-sync.cjs +0 -3450
  110. package/dist/cjs/workspace-hydration-ledger.cjs +0 -66
  111. package/dist/cjs/workspace-hydration-merge.cjs +0 -433
  112. package/dist/cjs/workspace-hydration-recovery-state.cjs +0 -53
  113. package/dist/cjs/workspace-incident-state.cjs +0 -37
  114. package/dist/cjs/workspace-merge-projection.cjs +0 -467
  115. package/dist/cjs/workspace-mount-boundary.cjs +0 -71
  116. package/dist/cjs/workspace-mount-hold-fence.cjs +0 -120
  117. package/dist/cjs/workspace-mutation-gate.cjs +0 -127
  118. package/dist/cjs/workspace-path-move.cjs +0 -195
  119. package/dist/cjs/workspace-preserve-only-policy.cjs +0 -36
  120. package/dist/cjs/workspace-project-config-policy.cjs +0 -53
  121. package/dist/cjs/workspace-projection-ledger.cjs +0 -81
  122. package/dist/cjs/workspace-publication-evidence.cjs +0 -46
  123. package/dist/cjs/workspace-sync-coalescer.cjs +0 -58
  124. package/dist/mjs/atomic-rename.mjs +0 -261
  125. package/dist/mjs/browser-upload.mjs +0 -42
  126. package/dist/mjs/command-launcher.mjs +0 -393
  127. package/dist/mjs/control-command-policy.mjs +0 -146
  128. package/dist/mjs/git-blob-hash.mjs +0 -16
  129. package/dist/mjs/git-identity.mjs +0 -15
  130. package/dist/mjs/git-process-environment.mjs +0 -105
  131. package/dist/mjs/inline-output.mjs +0 -37
  132. package/dist/mjs/managed-paths.mjs +0 -174
  133. package/dist/mjs/plan-lint.mjs +0 -129
  134. package/dist/mjs/plan-parser.mjs +0 -94
  135. package/dist/mjs/plan-paths.mjs +0 -25
  136. package/dist/mjs/port-forward-client.mjs +0 -172
  137. package/dist/mjs/project-checkout-garbage.mjs +0 -178
  138. package/dist/mjs/project-mirror-fetch-policy.mjs +0 -56
  139. package/dist/mjs/project-mirror-refs-token.mjs +0 -53
  140. package/dist/mjs/project-workspace-state.mjs +0 -937
  141. package/dist/mjs/project-worktrees.mjs +0 -1657
  142. package/dist/mjs/pty-output-coalescer.mjs +0 -61
  143. package/dist/mjs/recovery-journal-protocol.mjs +0 -30
  144. package/dist/mjs/recovery-journal-runtime.mjs +0 -112
  145. package/dist/mjs/recovery-journal-thread.mjs +0 -8
  146. package/dist/mjs/recovery-journal.mjs +0 -694
  147. package/dist/mjs/recovery-output-window.mjs +0 -53
  148. package/dist/mjs/recovery-protocol.mjs +0 -6
  149. package/dist/mjs/recovery-store.mjs +0 -217
  150. package/dist/mjs/registry-auth.mjs +0 -269
  151. package/dist/mjs/repository-transition-policy.mjs +0 -22
  152. package/dist/mjs/runtime-version.mjs +0 -54
  153. package/dist/mjs/session-file-mutations.mjs +0 -37
  154. package/dist/mjs/supervisor.mjs +0 -114
  155. package/dist/mjs/three-way-merge.mjs +0 -318
  156. package/dist/mjs/working-tree-mirror.mjs +0 -1817
  157. package/dist/mjs/workspace-automatic-sync-policy.mjs +0 -48
  158. package/dist/mjs/workspace-branch-incarnation-policy.mjs +0 -13
  159. package/dist/mjs/workspace-command-sync-policy.mjs +0 -84
  160. package/dist/mjs/workspace-command-targets.mjs +0 -37
  161. package/dist/mjs/workspace-filesystem-executor-thread.mjs +0 -38
  162. package/dist/mjs/workspace-filesystem-executor.mjs +0 -287
  163. package/dist/mjs/workspace-filesystem-job-types.mjs +0 -116
  164. package/dist/mjs/workspace-filesystem-jobs.mjs +0 -55
  165. package/dist/mjs/workspace-git-sync.mjs +0 -3407
  166. package/dist/mjs/workspace-hydration-ledger.mjs +0 -42
  167. package/dist/mjs/workspace-hydration-merge.mjs +0 -399
  168. package/dist/mjs/workspace-hydration-recovery-state.mjs +0 -29
  169. package/dist/mjs/workspace-incident-state.mjs +0 -12
  170. package/dist/mjs/workspace-merge-projection.mjs +0 -433
  171. package/dist/mjs/workspace-mount-boundary.mjs +0 -37
  172. package/dist/mjs/workspace-mount-hold-fence.mjs +0 -95
  173. package/dist/mjs/workspace-mutation-gate.mjs +0 -103
  174. package/dist/mjs/workspace-path-move.mjs +0 -160
  175. package/dist/mjs/workspace-preserve-only-policy.mjs +0 -11
  176. package/dist/mjs/workspace-project-config-policy.mjs +0 -27
  177. package/dist/mjs/workspace-projection-ledger.mjs +0 -57
  178. package/dist/mjs/workspace-publication-evidence.mjs +0 -21
  179. package/dist/mjs/workspace-sync-coalescer.mjs +0 -34
  180. package/dist/types/atomic-rename.d.ts +0 -78
  181. package/dist/types/browser-upload.d.ts +0 -7
  182. package/dist/types/command-launcher.d.ts +0 -104
  183. package/dist/types/control-command-policy.d.ts +0 -53
  184. package/dist/types/git-blob-hash.d.ts +0 -10
  185. package/dist/types/git-identity.d.ts +0 -9
  186. package/dist/types/git-process-environment.d.ts +0 -9
  187. package/dist/types/inline-output.d.ts +0 -3
  188. package/dist/types/managed-paths.d.ts +0 -19
  189. package/dist/types/plan-lint.d.ts +0 -16
  190. package/dist/types/plan-parser.d.ts +0 -38
  191. package/dist/types/plan-paths.d.ts +0 -36
  192. package/dist/types/port-forward-client.d.ts +0 -8
  193. package/dist/types/project-checkout-garbage.d.ts +0 -86
  194. package/dist/types/project-mirror-fetch-policy.d.ts +0 -84
  195. package/dist/types/project-mirror-refs-token.d.ts +0 -53
  196. package/dist/types/project-workspace-state.d.ts +0 -188
  197. package/dist/types/project-worktrees.d.ts +0 -397
  198. package/dist/types/pty-output-coalescer.d.ts +0 -20
  199. package/dist/types/recovery-journal-protocol.d.ts +0 -35
  200. package/dist/types/recovery-journal-runtime.d.ts +0 -12
  201. package/dist/types/recovery-journal-thread.d.ts +0 -1
  202. package/dist/types/recovery-journal.d.ts +0 -248
  203. package/dist/types/recovery-output-window.d.ts +0 -19
  204. package/dist/types/recovery-protocol.d.ts +0 -59
  205. package/dist/types/recovery-store.d.ts +0 -52
  206. package/dist/types/registry-auth.d.ts +0 -47
  207. package/dist/types/repository-transition-policy.d.ts +0 -26
  208. package/dist/types/runtime-version.d.ts +0 -1
  209. package/dist/types/session-file-mutations.d.ts +0 -22
  210. package/dist/types/supervisor-daemonized-fixture.d.ts +0 -1
  211. package/dist/types/supervisor-launcher-cleanup-fixture.d.ts +0 -1
  212. package/dist/types/supervisor-signal-fixture.d.ts +0 -1
  213. package/dist/types/supervisor.d.ts +0 -23
  214. package/dist/types/three-way-merge.d.ts +0 -77
  215. package/dist/types/working-tree-mirror.d.ts +0 -424
  216. package/dist/types/workspace-automatic-sync-policy.d.ts +0 -57
  217. package/dist/types/workspace-branch-incarnation-policy.d.ts +0 -14
  218. package/dist/types/workspace-command-sync-policy.d.ts +0 -57
  219. package/dist/types/workspace-command-targets.d.ts +0 -37
  220. package/dist/types/workspace-filesystem-executor-thread.d.ts +0 -1
  221. package/dist/types/workspace-filesystem-executor.d.ts +0 -123
  222. package/dist/types/workspace-filesystem-job-types.d.ts +0 -288
  223. package/dist/types/workspace-filesystem-jobs.d.ts +0 -7
  224. package/dist/types/workspace-git-sync.d.ts +0 -495
  225. package/dist/types/workspace-hydration-ledger.d.ts +0 -43
  226. package/dist/types/workspace-hydration-merge.d.ts +0 -95
  227. package/dist/types/workspace-hydration-recovery-state.d.ts +0 -10
  228. package/dist/types/workspace-incident-state.d.ts +0 -19
  229. package/dist/types/workspace-merge-projection.d.ts +0 -60
  230. package/dist/types/workspace-mount-boundary.d.ts +0 -10
  231. package/dist/types/workspace-mount-hold-fence.d.ts +0 -42
  232. package/dist/types/workspace-mutation-gate.d.ts +0 -42
  233. package/dist/types/workspace-path-move.d.ts +0 -21
  234. package/dist/types/workspace-preserve-only-policy.d.ts +0 -15
  235. package/dist/types/workspace-project-config-policy.d.ts +0 -48
  236. package/dist/types/workspace-projection-ledger.d.ts +0 -59
  237. package/dist/types/workspace-publication-evidence.d.ts +0 -17
  238. package/dist/types/workspace-sync-coalescer.d.ts +0 -28
  239. /package/dist/types/{credential-authority-lock-fixture.d.ts → runtime/adapter.d.ts} +0 -0
  240. /package/dist/types/{recovery-journal-stall-fixture.d.ts → runtime/releases/main.d.ts} +0 -0
@@ -1,66 +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_hydration_ledger_exports = {};
20
- __export(workspace_hydration_ledger_exports, {
21
- WorkspaceHydrationPreBlobLedger: () => WorkspaceHydrationPreBlobLedger
22
- });
23
- module.exports = __toCommonJS(workspace_hydration_ledger_exports);
24
- class WorkspaceHydrationPreBlobLedger {
25
- mounts = /* @__PURE__ */ new Map();
26
- static key(mount) {
27
- return `${mount.hydrationIncarnationKey}\0${mount.id}`;
28
- }
29
- /** Blob ids by mount-relative path for the mount, or an empty map. */
30
- preBlobs(mount) {
31
- return this.mounts.get(WorkspaceHydrationPreBlobLedger.key(mount)) ?? /* @__PURE__ */ new Map();
32
- }
33
- /** Record the pre-hydration blob of every path a merge hydration replaced; earlier entries for other paths are kept. */
34
- record(mount, preBlobs) {
35
- const entries = preBlobs instanceof Map ? [...preBlobs] : Object.entries(preBlobs);
36
- if (entries.length === 0) return;
37
- const key = WorkspaceHydrationPreBlobLedger.key(mount);
38
- const current = this.mounts.get(key) ?? /* @__PURE__ */ new Map();
39
- for (const [relativePath, blob] of entries) current.set(relativePath, blob);
40
- this.mounts.set(key, current);
41
- }
42
- /** Forget the mount: its checkout was rewritten by something this ledger did not observe. */
43
- clearMount(mount) {
44
- this.mounts.delete(WorkspaceHydrationPreBlobLedger.key(mount));
45
- }
46
- /** Forget paths whose checkout content moved on from the hydrated bytes: a later return to the old bytes is a deliberate edit. */
47
- forget(mount, paths) {
48
- const key = WorkspaceHydrationPreBlobLedger.key(mount);
49
- const current = this.mounts.get(key);
50
- if (!current) return;
51
- for (const relativePath of paths) current.delete(relativePath);
52
- if (current.size === 0) this.mounts.delete(key);
53
- }
54
- clear() {
55
- this.mounts.clear();
56
- }
57
- get size() {
58
- let total = 0;
59
- for (const entries of this.mounts.values()) total += entries.size;
60
- return total;
61
- }
62
- }
63
- // Annotate the CommonJS export names for ESM import in node:
64
- 0 && (module.exports = {
65
- WorkspaceHydrationPreBlobLedger
66
- });
@@ -1,433 +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_hydration_merge_exports = {};
30
- __export(workspace_hydration_merge_exports, {
31
- RACY_PROJECTION_WINDOW_MS: () => RACY_PROJECTION_WINDOW_MS,
32
- decideWorkspaceHydrationMerge: () => decideWorkspaceHydrationMerge,
33
- describeHydrationSkipPaths: () => describeHydrationSkipPaths,
34
- parseWorkspaceSubtreeChanges: () => parseWorkspaceSubtreeChanges,
35
- readHydrationBinaryPaths: () => readHydrationBinaryPaths
36
- });
37
- module.exports = __toCommonJS(workspace_hydration_merge_exports);
38
- var import_node_fs = __toESM(require("node:fs"), 1);
39
- var import_node_path = __toESM(require("node:path"), 1);
40
- var import_git_process_environment = require("./git-process-environment.cjs");
41
- var import_git_blob_hash = require("./git-blob-hash.cjs");
42
- var import_three_way_merge = require("./three-way-merge.cjs");
43
- var import_working_tree_mirror = require("./working-tree-mirror.cjs");
44
- const RACY_PROJECTION_WINDOW_MS = 2e3;
45
- class TargetChanged extends Error {
46
- constructor(relativePath) {
47
- super(`Working-tree target changed while merge hydration inspected it: ${relativePath}`);
48
- this.relativePath = relativePath;
49
- }
50
- relativePath;
51
- }
52
- function isBlobMode(mode) {
53
- return mode === "100644" || mode === "100755";
54
- }
55
- function executableBit(mode) {
56
- return (mode & 73) !== 0;
57
- }
58
- function resolveExecutable(base, ours, theirs) {
59
- if (ours === base) return theirs;
60
- if (theirs === base) return ours;
61
- return ours === theirs ? ours : null;
62
- }
63
- function withExecutable(mode, executable) {
64
- const bits = mode & 511;
65
- return executable ? bits | 73 : bits & ~73;
66
- }
67
- function readOwnedFile(root, relativePath, expected) {
68
- const inspected = (0, import_working_tree_mirror.inspectWorkingTreePath)(root, relativePath);
69
- if (inspected.kind !== "entry" || !(0, import_working_tree_mirror.workingTreeStatsMatch)(expected, inspected.stat)) throw new TargetChanged(relativePath);
70
- const descriptor = import_node_fs.default.openSync(inspected.absolutePath, import_node_fs.default.constants.O_RDONLY | import_node_fs.default.constants.O_NOFOLLOW);
71
- try {
72
- const before = import_node_fs.default.fstatSync(descriptor);
73
- if (!(0, import_working_tree_mirror.workingTreeStatsMatch)(expected, before)) throw new TargetChanged(relativePath);
74
- const content = Buffer.allocUnsafe(before.size);
75
- let offset = 0;
76
- while (offset < before.size) {
77
- const bytesRead = import_node_fs.default.readSync(descriptor, content, offset, before.size - offset, offset);
78
- if (bytesRead <= 0) throw new TargetChanged(relativePath);
79
- offset += bytesRead;
80
- }
81
- if (!(0, import_working_tree_mirror.workingTreeStatsMatch)(expected, import_node_fs.default.fstatSync(descriptor))) throw new TargetChanged(relativePath);
82
- return content;
83
- } finally {
84
- import_node_fs.default.closeSync(descriptor);
85
- }
86
- }
87
- function readOuterFile(root, relativePath) {
88
- const inspected = (0, import_working_tree_mirror.inspectWorkingTreePath)(root, relativePath);
89
- if (inspected.kind !== "entry" || !inspected.stat.isFile())
90
- throw new Error(`Outer worktree does not hold a regular file at ${relativePath}`);
91
- return import_node_fs.default.readFileSync(inspected.absolutePath);
92
- }
93
- function currentTargetStat(root, relativePath) {
94
- const inspected = (0, import_working_tree_mirror.inspectWorkingTreePath)(root, relativePath);
95
- return inspected.kind === "entry" ? inspected.stat : null;
96
- }
97
- function directoryHoldsOnlyVisibleEntries(root, relativePath, existing) {
98
- const inspected = (0, import_working_tree_mirror.inspectWorkingTreePath)(root, relativePath);
99
- if (inspected.kind !== "entry" || !inspected.stat.isDirectory()) return true;
100
- const pending = [{ absolutePath: inspected.absolutePath, relativePath }];
101
- while (pending.length > 0) {
102
- const directory = pending.pop();
103
- for (const name of import_node_fs.default.readdirSync(directory.absolutePath)) {
104
- const childRelative = `${directory.relativePath}/${name}`;
105
- if (!existing.has(childRelative)) return false;
106
- const child = import_node_fs.default.lstatSync(import_node_path.default.join(directory.absolutePath, name));
107
- if (child.isDirectory() && !child.isSymbolicLink())
108
- pending.push({ absolutePath: import_node_path.default.join(directory.absolutePath, name), relativePath: childRelative });
109
- }
110
- }
111
- return true;
112
- }
113
- function decideWorkspaceHydrationMerge(input) {
114
- const { prepared, changes, projectedFiles } = input;
115
- const trustedProjection = (projected, stat) => (0, import_working_tree_mirror.projectedFileEntryMatches)(projected, stat) && (input.readAtMs === void 0 || projected.mtimeMs < input.readAtMs - RACY_PROJECTION_WINDOW_MS && projected.ctimeMs < input.readAtMs - RACY_PROJECTION_WINDOW_MS);
116
- const { desired, existing, existingStats, shielded, sourceRoot, targetRoot } = prepared;
117
- const conflicts = /* @__PURE__ */ new Set();
118
- const write = /* @__PURE__ */ new Set();
119
- const remove = /* @__PURE__ */ new Set();
120
- const overrides = /* @__PURE__ */ new Map();
121
- const expectations = /* @__PURE__ */ new Map();
122
- const preBlobs = /* @__PURE__ */ new Map();
123
- const mergedPaths = [];
124
- const keptPaths = /* @__PURE__ */ new Set();
125
- const desiredForIndex = new Map(desired);
126
- let algorithm = "sha1";
127
- for (const change of changes.values()) {
128
- const detected = (0, import_git_blob_hash.gitObjectHashAlgorithmFor)(change.base?.objectId ?? change.theirs?.objectId ?? "");
129
- if (detected) {
130
- algorithm = detected;
131
- break;
132
- }
133
- }
134
- const hashOf = (content) => (0, import_git_blob_hash.gitBlobHash)(content, algorithm);
135
- const mergeCandidates = [];
136
- const directoryReplacements = [];
137
- const oursState = (relativePath, change) => {
138
- const ours = existing.get(relativePath);
139
- const oursStat = existingStats.get(relativePath);
140
- if (!ours || !oursStat) return change.base ? "deleted" : "absent";
141
- if (!change.base) return "added";
142
- const base = change.base;
143
- if (ours.kind === "file" && isBlobMode(base.mode)) {
144
- if (executableBit(ours.mode) !== (base.mode === "100755")) return "changed";
145
- const projected = projectedFiles?.[relativePath];
146
- if (projected?.kind === "file" && trustedProjection(projected, oursStat)) return "base";
147
- if (projectedFiles !== null && projected === void 0) return "changed";
148
- return hashOf(readOwnedFile(targetRoot, relativePath, oursStat)) === base.objectId ? "base" : "changed";
149
- }
150
- if (ours.kind === "symlink" && base.mode === "120000") return hashOf(Buffer.from(ours.target)) === base.objectId ? "base" : "changed";
151
- if (ours.kind === "gitlink" && base.mode === "160000") return ours.objectId === base.objectId ? "base" : "changed";
152
- return "changed";
153
- };
154
- try {
155
- for (const [relativePath, change] of [...changes].sort(([left], [right]) => left.localeCompare(right))) {
156
- if (shielded.has(relativePath)) continue;
157
- const ours = existing.get(relativePath);
158
- const oursStat = existingStats.get(relativePath);
159
- const theirsEntry = desired.get(relativePath);
160
- if (change.theirs && (!theirsEntry || theirsEntry.kind === "directory")) {
161
- conflicts.add(relativePath);
162
- continue;
163
- }
164
- if (ours?.kind === "directory" && !change.base && change.theirs) {
165
- directoryReplacements.push(relativePath);
166
- continue;
167
- }
168
- const state = oursState(relativePath, change);
169
- if (state === "base" || state === "absent") {
170
- if (!change.theirs) {
171
- if (ours && oursStat) {
172
- remove.add(relativePath);
173
- expectations.set(relativePath, oursStat);
174
- }
175
- if (change.base && isBlobMode(change.base.mode)) preBlobs.set(relativePath, change.base.objectId);
176
- continue;
177
- }
178
- write.add(relativePath);
179
- expectations.set(relativePath, oursStat ?? currentTargetStat(targetRoot, relativePath));
180
- if (change.base && isBlobMode(change.base.mode) && change.base.objectId !== change.theirs.objectId) {
181
- preBlobs.set(relativePath, change.base.objectId);
182
- }
183
- continue;
184
- }
185
- if (state === "deleted") {
186
- if (change.theirs) conflicts.add(relativePath);
187
- continue;
188
- }
189
- if (!change.theirs) {
190
- conflicts.add(relativePath);
191
- continue;
192
- }
193
- const theirs = change.theirs;
194
- if (ours.kind === "file" && isBlobMode(theirs.mode)) {
195
- const oursBytes = readOwnedFile(targetRoot, relativePath, oursStat);
196
- const theirsBytes = readOuterFile(sourceRoot, relativePath);
197
- const oursExecutable = executableBit(ours.mode);
198
- const theirsExecutable = theirs.mode === "100755";
199
- if (oursBytes.equals(theirsBytes)) {
200
- if (oursExecutable === theirsExecutable) {
201
- keptPaths.add(relativePath);
202
- continue;
203
- }
204
- const baseExecutable = change.base ? change.base.mode === "100755" : null;
205
- const resolved = baseExecutable === null ? null : resolveExecutable(baseExecutable, oursExecutable, theirsExecutable);
206
- if (resolved === null) {
207
- conflicts.add(relativePath);
208
- continue;
209
- }
210
- overrides.set(relativePath, { content: theirsBytes, mode: withExecutable(oursStat.mode, resolved) });
211
- write.add(relativePath);
212
- expectations.set(relativePath, oursStat);
213
- mergedPaths.push(relativePath);
214
- continue;
215
- }
216
- if (!change.base || !isBlobMode(change.base.mode)) {
217
- conflicts.add(relativePath);
218
- continue;
219
- }
220
- mergeCandidates.push({
221
- relativePath,
222
- ours,
223
- oursStat,
224
- base: change.base.objectId,
225
- baseExecutable: change.base.mode === "100755",
226
- theirs
227
- });
228
- continue;
229
- }
230
- if (ours.kind === "symlink" && theirs.mode === "120000" && theirsEntry?.kind === "symlink") {
231
- if (ours.target === theirsEntry.target) keptPaths.add(relativePath);
232
- else conflicts.add(relativePath);
233
- continue;
234
- }
235
- if (ours.kind === "gitlink" && theirs.mode === "160000") {
236
- if (ours.objectId === theirs.objectId) keptPaths.add(relativePath);
237
- else conflicts.add(relativePath);
238
- continue;
239
- }
240
- conflicts.add(relativePath);
241
- }
242
- for (const relativePath of directoryReplacements) {
243
- const prefix = `${relativePath}/`;
244
- let container = true;
245
- for (const candidate of existing.keys()) {
246
- if (candidate.startsWith(prefix) && !remove.has(candidate)) {
247
- container = false;
248
- break;
249
- }
250
- }
251
- if (container && !directoryHoldsOnlyVisibleEntries(targetRoot, relativePath, existing)) container = false;
252
- if (!container) {
253
- conflicts.add(relativePath);
254
- continue;
255
- }
256
- write.add(relativePath);
257
- expectations.set(relativePath, existingStats.get(relativePath) ?? null);
258
- }
259
- if (mergeCandidates.length > 0) {
260
- const binaryPaths = input.readBinaryPaths?.(mergeCandidates.map(({ relativePath }) => relativePath));
261
- const baseBlobs = input.readBaseBlobs([...new Set(mergeCandidates.map(({ base }) => base))]);
262
- for (const candidate of mergeCandidates) {
263
- const { relativePath } = candidate;
264
- const baseBytes = baseBlobs.get(candidate.base);
265
- if (!baseBytes) throw new Error(`Projected blob ${candidate.base} for ${relativePath} is missing from the workspace clone`);
266
- const oursBytes = readOwnedFile(targetRoot, relativePath, candidate.oursStat);
267
- const theirsBytes = readOuterFile(sourceRoot, relativePath);
268
- if (binaryPaths?.has(relativePath) || (0, import_three_way_merge.isBinaryContent)(baseBytes) || (0, import_three_way_merge.isBinaryContent)(oursBytes) || (0, import_three_way_merge.isBinaryContent)(theirsBytes)) {
269
- conflicts.add(relativePath);
270
- continue;
271
- }
272
- const merged = (0, import_three_way_merge.mergeThreeWay)(baseBytes, oursBytes, theirsBytes);
273
- if (merged.kind === "conflict") {
274
- conflicts.add(relativePath);
275
- continue;
276
- }
277
- const resolved = resolveExecutable(
278
- candidate.baseExecutable,
279
- executableBit(candidate.ours.mode),
280
- candidate.theirs.mode === "100755"
281
- );
282
- if (resolved === null) {
283
- conflicts.add(relativePath);
284
- continue;
285
- }
286
- const mode = withExecutable(candidate.oursStat.mode, resolved);
287
- const contentUnchanged = merged.content.equals(oursBytes);
288
- if (contentUnchanged && mode === (candidate.oursStat.mode & 511)) {
289
- keptPaths.add(relativePath);
290
- continue;
291
- }
292
- overrides.set(relativePath, { content: merged.content, mode });
293
- write.add(relativePath);
294
- expectations.set(relativePath, candidate.oursStat);
295
- if (!contentUnchanged) preBlobs.set(relativePath, hashOf(oursBytes));
296
- mergedPaths.push(relativePath);
297
- }
298
- }
299
- const neededDirectories = /* @__PURE__ */ new Set();
300
- for (const relativePath of write) {
301
- let parent = import_node_path.default.posix.dirname(relativePath);
302
- while (parent !== ".") {
303
- neededDirectories.add(parent);
304
- parent = import_node_path.default.posix.dirname(parent);
305
- }
306
- }
307
- for (const [relativePath, entry] of desired) {
308
- if (shielded.has(relativePath) || changes.has(relativePath)) continue;
309
- const current = existing.get(relativePath);
310
- if (entry.kind === "directory") {
311
- if (!neededDirectories.has(relativePath)) continue;
312
- if (current && current.kind !== "directory") {
313
- if (!remove.has(relativePath)) conflicts.add(relativePath);
314
- continue;
315
- }
316
- expectations.set(relativePath, currentTargetStat(targetRoot, relativePath));
317
- continue;
318
- }
319
- if (entry.kind === "gitlink") {
320
- if (current?.kind === "gitlink") desiredForIndex.set(relativePath, current);
321
- else {
322
- const record = prepared.git?.indexRecords.find((candidate) => candidate.relativePath === relativePath && candidate.stage === 0);
323
- if (record?.mode === "160000") desiredForIndex.set(relativePath, { kind: "gitlink", objectId: record.objectId });
324
- else desiredForIndex.delete(relativePath);
325
- }
326
- }
327
- if (!current || current.kind !== entry.kind) {
328
- keptPaths.add(relativePath);
329
- continue;
330
- }
331
- if (current.kind === "file") {
332
- const stat = existingStats.get(relativePath);
333
- const projected = projectedFiles?.[relativePath];
334
- const unchanged = projected?.kind === "file" && stat ? trustedProjection(projected, stat) : projectedFiles === null || projected !== void 0;
335
- if (!unchanged) keptPaths.add(relativePath);
336
- }
337
- }
338
- for (const [relativePath, entry] of existing) {
339
- if (desired.has(relativePath) || changes.has(relativePath) || entry.kind === "directory" || shielded.has(relativePath)) continue;
340
- keptPaths.add(relativePath);
341
- }
342
- const blockedDirectories = /* @__PURE__ */ new Set();
343
- for (const [relativePath, entry] of existing) {
344
- if (entry.kind === "directory" || remove.has(relativePath)) continue;
345
- let parent = import_node_path.default.posix.dirname(relativePath);
346
- while (parent !== ".") {
347
- blockedDirectories.add(parent);
348
- parent = import_node_path.default.posix.dirname(parent);
349
- }
350
- }
351
- for (const [relativePath, entry] of existing) {
352
- if (entry.kind !== "directory" || desired.has(relativePath) || blockedDirectories.has(relativePath)) continue;
353
- remove.add(relativePath);
354
- }
355
- } catch (error) {
356
- if (error instanceof TargetChanged) return { kind: "target_changed", paths: [error.relativePath] };
357
- throw error;
358
- }
359
- if (conflicts.size > 0) return { kind: "conflict", paths: [...conflicts].sort() };
360
- for (const relativePath of [...write, ...overrides.keys()]) {
361
- if (!expectations.has(relativePath)) expectations.set(relativePath, currentTargetStat(targetRoot, relativePath));
362
- }
363
- return {
364
- kind: "apply",
365
- selection: { write, remove, desiredForIndex },
366
- overrides,
367
- expectations,
368
- preBlobs,
369
- mergedPaths: mergedPaths.sort(),
370
- keptPaths: [...keptPaths].sort()
371
- };
372
- }
373
- function readHydrationBinaryPaths(input) {
374
- const binary = /* @__PURE__ */ new Set();
375
- if (!input.relativePaths.length) return binary;
376
- const requested = new Set(input.relativePaths);
377
- for (const cwd of [input.checkoutRoot, input.outerRoot]) {
378
- const result = Bun.spawnSync(["git", "check-attr", "-z", "--stdin", "diff"], {
379
- cwd,
380
- env: (0, import_git_process_environment.workerGitProcessEnvironment)(),
381
- stdin: Buffer.from(`${input.relativePaths.join("\0")}\0`),
382
- stdout: "pipe",
383
- stderr: "pipe"
384
- });
385
- if (result.exitCode !== 0) throw new Error(`Cannot inspect hydration binary attributes: ${result.stderr.toString().trim()}`);
386
- const records = result.stdout.toString().split("\0");
387
- if (records.pop() !== "" || records.length !== requested.size * 3) throw new Error("Invalid hydration attribute response");
388
- const seen = /* @__PURE__ */ new Set();
389
- for (let index = 0; index < records.length; index += 3) {
390
- const relativePath = records[index];
391
- if (!requested.has(relativePath) || seen.has(relativePath) || records[index + 1] !== "diff")
392
- throw new Error("Invalid hydration attribute path");
393
- seen.add(relativePath);
394
- if (records[index + 2] === "unset") binary.add(relativePath);
395
- }
396
- }
397
- return binary;
398
- }
399
- function parseWorkspaceSubtreeChanges(raw) {
400
- const changes = /* @__PURE__ */ new Map();
401
- const records = [];
402
- let start = 0;
403
- for (let index = 0; index < raw.length; index += 1) {
404
- if (raw[index] !== 0) continue;
405
- if (index > start) records.push(raw.subarray(start, index));
406
- start = index + 1;
407
- }
408
- if (start < raw.length) records.push(raw.subarray(start));
409
- for (let index = 0; index + 1 < records.length; index += 2) {
410
- const match = /^:([0-7]{6}) ([0-7]{6}) ([0-9a-f]{40,64}) ([0-9a-f]{40,64}) ([A-Z])/u.exec(records[index].toString());
411
- if (!match) throw new Error(`Unexpected diff-tree record: ${records[index].toString()}`);
412
- const relativePath = records[index + 1].toString();
413
- if (relativePath.split("/").some((segment) => segment === ".." || segment === "" || segment === ".git")) {
414
- throw new Error(`Unsafe path in workspace subtree diff: ${relativePath}`);
415
- }
416
- const base = match[1] === "000000" ? null : { mode: match[1], objectId: match[3] };
417
- const theirs = match[2] === "000000" ? null : { mode: match[2], objectId: match[4] };
418
- changes.set(relativePath, { base, theirs });
419
- }
420
- return changes;
421
- }
422
- function describeHydrationSkipPaths(mountSourcePath, paths) {
423
- const shown = paths.slice(0, 5).map((relativePath) => import_node_path.default.join(mountSourcePath, ...relativePath.split("/")));
424
- return paths.length > 5 ? `${shown.join(", ")} and ${paths.length - 5} more` : shown.join(", ");
425
- }
426
- // Annotate the CommonJS export names for ESM import in node:
427
- 0 && (module.exports = {
428
- RACY_PROJECTION_WINDOW_MS,
429
- decideWorkspaceHydrationMerge,
430
- describeHydrationSkipPaths,
431
- parseWorkspaceSubtreeChanges,
432
- readHydrationBinaryPaths
433
- });
@@ -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_hydration_recovery_state_exports = {};
20
- __export(workspace_hydration_recovery_state_exports, {
21
- findHydrationRecovery: () => findHydrationRecovery
22
- });
23
- module.exports = __toCommonJS(workspace_hydration_recovery_state_exports);
24
- function findHydrationRecovery(error) {
25
- const pending = [error];
26
- const seen = /* @__PURE__ */ new Set();
27
- while (pending.length) {
28
- const candidate = pending.pop();
29
- if (!candidate || typeof candidate !== "object" || seen.has(candidate)) continue;
30
- seen.add(candidate);
31
- const record = candidate;
32
- if (record.code === "hydration_recovery_required" && record.hydrationRecovery && typeof record.hydrationRecovery === "object") {
33
- const evidence = record.hydrationRecovery;
34
- if (typeof evidence.transactionId === "string" && typeof evidence.transactionPath === "string" && Array.isArray(evidence.mounts)) {
35
- const retainedPaths = [...new Set(evidence.mounts.flatMap((mount) => mount.retainedPaths ?? []))];
36
- return {
37
- transactionId: evidence.transactionId,
38
- transactionPath: evidence.transactionPath,
39
- mountIds: evidence.mounts.map(({ id }) => id),
40
- previousHeads: Object.fromEntries((evidence.receiptBefore?.mounts ?? []).map(({ id, head }) => [id, head])),
41
- ...retainedPaths.length > 0 ? { retainedPaths } : {}
42
- };
43
- }
44
- }
45
- pending.push(record.cause);
46
- if (Array.isArray(record.errors)) pending.push(...record.errors);
47
- }
48
- return void 0;
49
- }
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 && (module.exports = {
52
- findHydrationRecovery
53
- });
@@ -1,37 +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_incident_state_exports = {};
20
- __export(workspace_incident_state_exports, {
21
- applyWorkspaceIncidentUpdate: () => applyWorkspaceIncidentUpdate,
22
- workspaceConfigurationRefreshesDeferredConfiguration: () => workspaceConfigurationRefreshesDeferredConfiguration
23
- });
24
- module.exports = __toCommonJS(workspace_incident_state_exports);
25
- function applyWorkspaceIncidentUpdate(currentIncidentId, update) {
26
- if (update.status === "remediating" || update.status === "waiting_for_worker") return update.incidentId;
27
- if (currentIncidentId && update.incidentId && update.incidentId !== currentIncidentId) return currentIncidentId;
28
- return null;
29
- }
30
- function workspaceConfigurationRefreshesDeferredConfiguration(input) {
31
- return input.deferredIncidentId !== null && input.activeIncidentId === null && input.requestedDeferredIncidentId === void 0;
32
- }
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- applyWorkspaceIncidentUpdate,
36
- workspaceConfigurationRefreshesDeferredConfiguration
37
- });