@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.
- package/README.md +4 -94
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/main.mjs +46 -7537
- package/dist/mjs/package.json +1 -1
- package/dist/mjs/personal/action-scheduler.mjs +31 -0
- package/dist/mjs/personal/client.mjs +215 -0
- package/dist/mjs/personal/runtime.mjs +328 -0
- package/dist/mjs/personal/tcp.mjs +217 -0
- package/dist/mjs/runtime/adapter.mjs +42 -0
- package/dist/mjs/runtime/client.mjs +95 -0
- package/dist/mjs/runtime/daemon.mjs +131 -0
- package/dist/mjs/runtime/executor.mjs +436 -0
- package/dist/mjs/runtime/index.mjs +15 -0
- package/dist/mjs/runtime/protocol.mjs +139 -0
- package/dist/mjs/runtime/pty-host.mjs +156 -0
- package/dist/mjs/runtime/pty.mjs +127 -0
- package/dist/mjs/runtime/releases/artifacts.mjs +201 -0
- package/dist/mjs/runtime/releases/grants.mjs +93 -0
- package/dist/mjs/runtime/releases/main.mjs +101 -0
- package/dist/mjs/runtime/releases/manager.mjs +541 -0
- package/dist/mjs/runtime/releases/process.mjs +88 -0
- package/dist/mjs/runtime/releases/retirement.mjs +18 -0
- package/dist/mjs/runtime/releases/rpc-client.mjs +184 -0
- package/dist/mjs/runtime/releases/rpc-main.mjs +213 -0
- package/dist/mjs/runtime/releases/rpc-protocol.mjs +103 -0
- package/dist/mjs/runtime/storage.mjs +156 -0
- package/dist/mjs/runtime/workspace/artifacts.mjs +121 -0
- package/dist/mjs/runtime/workspace/authority.mjs +1355 -0
- package/dist/mjs/runtime/workspace/contracts.mjs +60 -0
- package/dist/mjs/runtime/workspace/file-write.mjs +23 -0
- package/dist/mjs/runtime/workspace/files.mjs +308 -0
- package/dist/mjs/runtime/workspace/http-body.mjs +45 -0
- package/dist/mjs/runtime/workspace/storage-client.mjs +59 -0
- package/dist/mjs/runtime/workspace/storage-wire.mjs +53 -0
- package/dist/types/main.d.ts +0 -1167
- package/dist/types/personal/action-scheduler.d.ts +23 -0
- package/dist/types/personal/client.d.ts +14 -0
- package/dist/types/personal/runtime.d.ts +121 -0
- package/dist/types/personal/tcp.d.ts +14 -0
- package/dist/types/runtime/client.d.ts +17 -0
- package/dist/types/runtime/daemon.d.ts +8 -0
- package/dist/types/runtime/executor.d.ts +35 -0
- package/dist/types/runtime/index.d.ts +5 -0
- package/dist/types/runtime/protocol.d.ts +544 -0
- package/dist/types/runtime/pty.d.ts +30 -0
- package/dist/types/runtime/releases/artifacts.d.ts +51 -0
- package/dist/types/runtime/releases/grants.d.ts +16 -0
- package/dist/types/runtime/releases/manager.d.ts +145 -0
- package/dist/types/runtime/releases/process.d.ts +14 -0
- package/dist/types/runtime/releases/retirement.d.ts +15 -0
- package/dist/types/runtime/releases/rpc-client.d.ts +52 -0
- package/dist/types/runtime/releases/rpc-main.d.ts +10 -0
- package/dist/types/runtime/releases/rpc-protocol.d.ts +1139 -0
- package/dist/types/runtime/storage.d.ts +21 -0
- package/dist/types/runtime/test-harness.d.ts +53 -0
- package/dist/types/runtime/workspace/artifacts.d.ts +30 -0
- package/dist/types/runtime/workspace/authority.d.ts +338 -0
- package/dist/types/runtime/workspace/contracts.d.ts +86 -0
- package/dist/types/runtime/workspace/file-write.d.ts +14 -0
- package/dist/types/runtime/workspace/files.d.ts +21 -0
- package/dist/types/runtime/workspace/http-body.d.ts +9 -0
- package/dist/types/runtime/workspace/storage-client.d.ts +23 -0
- package/dist/types/runtime/workspace/storage-wire.d.ts +138 -0
- package/package.json +8 -6
- package/dist/cjs/atomic-rename.cjs +0 -303
- package/dist/cjs/browser-upload.cjs +0 -73
- package/dist/cjs/cli-update.cjs +0 -108
- package/dist/cjs/command-launcher.cjs +0 -423
- package/dist/cjs/control-command-policy.cjs +0 -177
- package/dist/cjs/git-blob-hash.cjs +0 -41
- package/dist/cjs/git-identity.cjs +0 -39
- package/dist/cjs/git-process-environment.cjs +0 -133
- package/dist/cjs/inline-output.cjs +0 -62
- package/dist/cjs/main.cjs +0 -7511
- package/dist/cjs/managed-paths.cjs +0 -215
- package/dist/cjs/plan-lint.cjs +0 -165
- package/dist/cjs/plan-parser.cjs +0 -127
- package/dist/cjs/plan-paths.cjs +0 -53
- package/dist/cjs/port-forward-client.cjs +0 -206
- package/dist/cjs/process-tree.cjs +0 -117
- package/dist/cjs/project-checkout-garbage.cjs +0 -219
- package/dist/cjs/project-mirror-fetch-policy.cjs +0 -82
- package/dist/cjs/project-mirror-refs-token.cjs +0 -85
- package/dist/cjs/project-workspace-state.cjs +0 -972
- package/dist/cjs/project-worktrees.cjs +0 -1713
- package/dist/cjs/pty-output-coalescer.cjs +0 -87
- package/dist/cjs/recovery-journal-protocol.cjs +0 -56
- package/dist/cjs/recovery-journal-runtime.cjs +0 -133
- package/dist/cjs/recovery-journal-thread.cjs +0 -9
- package/dist/cjs/recovery-journal.cjs +0 -742
- package/dist/cjs/recovery-output-window.cjs +0 -77
- package/dist/cjs/recovery-protocol.cjs +0 -31
- package/dist/cjs/recovery-store.cjs +0 -252
- package/dist/cjs/registry-auth.cjs +0 -310
- package/dist/cjs/repository-transition-policy.cjs +0 -49
- package/dist/cjs/runtime-version.cjs +0 -88
- package/dist/cjs/session-file-mutations.cjs +0 -61
- package/dist/cjs/supervisor.cjs +0 -147
- package/dist/cjs/three-way-merge.cjs +0 -346
- package/dist/cjs/working-tree-mirror.cjs +0 -1872
- package/dist/cjs/workspace-automatic-sync-policy.cjs +0 -79
- package/dist/cjs/workspace-branch-incarnation-policy.cjs +0 -37
- package/dist/cjs/workspace-command-sync-policy.cjs +0 -112
- package/dist/cjs/workspace-command-targets.cjs +0 -63
- package/dist/cjs/workspace-filesystem-executor-thread.cjs +0 -36
- package/dist/cjs/workspace-filesystem-executor.cjs +0 -327
- package/dist/cjs/workspace-filesystem-job-types.cjs +0 -144
- package/dist/cjs/workspace-filesystem-jobs.cjs +0 -59
- package/dist/cjs/workspace-git-sync.cjs +0 -3450
- package/dist/cjs/workspace-hydration-ledger.cjs +0 -66
- package/dist/cjs/workspace-hydration-merge.cjs +0 -433
- package/dist/cjs/workspace-hydration-recovery-state.cjs +0 -53
- package/dist/cjs/workspace-incident-state.cjs +0 -37
- package/dist/cjs/workspace-merge-projection.cjs +0 -467
- package/dist/cjs/workspace-mount-boundary.cjs +0 -71
- package/dist/cjs/workspace-mount-hold-fence.cjs +0 -120
- package/dist/cjs/workspace-mutation-gate.cjs +0 -127
- package/dist/cjs/workspace-path-move.cjs +0 -195
- package/dist/cjs/workspace-preserve-only-policy.cjs +0 -36
- package/dist/cjs/workspace-project-config-policy.cjs +0 -53
- package/dist/cjs/workspace-projection-ledger.cjs +0 -81
- package/dist/cjs/workspace-publication-evidence.cjs +0 -46
- package/dist/cjs/workspace-sync-coalescer.cjs +0 -58
- package/dist/mjs/atomic-rename.mjs +0 -261
- package/dist/mjs/browser-upload.mjs +0 -42
- package/dist/mjs/command-launcher.mjs +0 -393
- package/dist/mjs/control-command-policy.mjs +0 -146
- package/dist/mjs/git-blob-hash.mjs +0 -16
- package/dist/mjs/git-identity.mjs +0 -15
- package/dist/mjs/git-process-environment.mjs +0 -105
- package/dist/mjs/inline-output.mjs +0 -37
- package/dist/mjs/managed-paths.mjs +0 -174
- package/dist/mjs/plan-lint.mjs +0 -129
- package/dist/mjs/plan-parser.mjs +0 -94
- package/dist/mjs/plan-paths.mjs +0 -25
- package/dist/mjs/port-forward-client.mjs +0 -172
- package/dist/mjs/project-checkout-garbage.mjs +0 -178
- package/dist/mjs/project-mirror-fetch-policy.mjs +0 -56
- package/dist/mjs/project-mirror-refs-token.mjs +0 -53
- package/dist/mjs/project-workspace-state.mjs +0 -937
- package/dist/mjs/project-worktrees.mjs +0 -1657
- package/dist/mjs/pty-output-coalescer.mjs +0 -61
- package/dist/mjs/recovery-journal-protocol.mjs +0 -30
- package/dist/mjs/recovery-journal-runtime.mjs +0 -112
- package/dist/mjs/recovery-journal-thread.mjs +0 -8
- package/dist/mjs/recovery-journal.mjs +0 -694
- package/dist/mjs/recovery-output-window.mjs +0 -53
- package/dist/mjs/recovery-protocol.mjs +0 -6
- package/dist/mjs/recovery-store.mjs +0 -217
- package/dist/mjs/registry-auth.mjs +0 -269
- package/dist/mjs/repository-transition-policy.mjs +0 -22
- package/dist/mjs/runtime-version.mjs +0 -54
- package/dist/mjs/session-file-mutations.mjs +0 -37
- package/dist/mjs/supervisor.mjs +0 -114
- package/dist/mjs/three-way-merge.mjs +0 -318
- package/dist/mjs/working-tree-mirror.mjs +0 -1817
- package/dist/mjs/workspace-automatic-sync-policy.mjs +0 -48
- package/dist/mjs/workspace-branch-incarnation-policy.mjs +0 -13
- package/dist/mjs/workspace-command-sync-policy.mjs +0 -84
- package/dist/mjs/workspace-command-targets.mjs +0 -37
- package/dist/mjs/workspace-filesystem-executor-thread.mjs +0 -38
- package/dist/mjs/workspace-filesystem-executor.mjs +0 -287
- package/dist/mjs/workspace-filesystem-job-types.mjs +0 -116
- package/dist/mjs/workspace-filesystem-jobs.mjs +0 -55
- package/dist/mjs/workspace-git-sync.mjs +0 -3407
- package/dist/mjs/workspace-hydration-ledger.mjs +0 -42
- package/dist/mjs/workspace-hydration-merge.mjs +0 -399
- package/dist/mjs/workspace-hydration-recovery-state.mjs +0 -29
- package/dist/mjs/workspace-incident-state.mjs +0 -12
- package/dist/mjs/workspace-merge-projection.mjs +0 -433
- package/dist/mjs/workspace-mount-boundary.mjs +0 -37
- package/dist/mjs/workspace-mount-hold-fence.mjs +0 -95
- package/dist/mjs/workspace-mutation-gate.mjs +0 -103
- package/dist/mjs/workspace-path-move.mjs +0 -160
- package/dist/mjs/workspace-preserve-only-policy.mjs +0 -11
- package/dist/mjs/workspace-project-config-policy.mjs +0 -27
- package/dist/mjs/workspace-projection-ledger.mjs +0 -57
- package/dist/mjs/workspace-publication-evidence.mjs +0 -21
- package/dist/mjs/workspace-sync-coalescer.mjs +0 -34
- package/dist/types/atomic-rename.d.ts +0 -78
- package/dist/types/browser-upload.d.ts +0 -7
- package/dist/types/command-launcher.d.ts +0 -104
- package/dist/types/control-command-policy.d.ts +0 -53
- package/dist/types/git-blob-hash.d.ts +0 -10
- package/dist/types/git-identity.d.ts +0 -9
- package/dist/types/git-process-environment.d.ts +0 -9
- package/dist/types/inline-output.d.ts +0 -3
- package/dist/types/managed-paths.d.ts +0 -19
- package/dist/types/plan-lint.d.ts +0 -16
- package/dist/types/plan-parser.d.ts +0 -38
- package/dist/types/plan-paths.d.ts +0 -36
- package/dist/types/port-forward-client.d.ts +0 -8
- package/dist/types/project-checkout-garbage.d.ts +0 -86
- package/dist/types/project-mirror-fetch-policy.d.ts +0 -84
- package/dist/types/project-mirror-refs-token.d.ts +0 -53
- package/dist/types/project-workspace-state.d.ts +0 -188
- package/dist/types/project-worktrees.d.ts +0 -397
- package/dist/types/pty-output-coalescer.d.ts +0 -20
- package/dist/types/recovery-journal-protocol.d.ts +0 -35
- package/dist/types/recovery-journal-runtime.d.ts +0 -12
- package/dist/types/recovery-journal-thread.d.ts +0 -1
- package/dist/types/recovery-journal.d.ts +0 -248
- package/dist/types/recovery-output-window.d.ts +0 -19
- package/dist/types/recovery-protocol.d.ts +0 -59
- package/dist/types/recovery-store.d.ts +0 -52
- package/dist/types/registry-auth.d.ts +0 -47
- package/dist/types/repository-transition-policy.d.ts +0 -26
- package/dist/types/runtime-version.d.ts +0 -1
- package/dist/types/session-file-mutations.d.ts +0 -22
- package/dist/types/supervisor-daemonized-fixture.d.ts +0 -1
- package/dist/types/supervisor-launcher-cleanup-fixture.d.ts +0 -1
- package/dist/types/supervisor-signal-fixture.d.ts +0 -1
- package/dist/types/supervisor.d.ts +0 -23
- package/dist/types/three-way-merge.d.ts +0 -77
- package/dist/types/working-tree-mirror.d.ts +0 -424
- package/dist/types/workspace-automatic-sync-policy.d.ts +0 -57
- package/dist/types/workspace-branch-incarnation-policy.d.ts +0 -14
- package/dist/types/workspace-command-sync-policy.d.ts +0 -57
- package/dist/types/workspace-command-targets.d.ts +0 -37
- package/dist/types/workspace-filesystem-executor-thread.d.ts +0 -1
- package/dist/types/workspace-filesystem-executor.d.ts +0 -123
- package/dist/types/workspace-filesystem-job-types.d.ts +0 -288
- package/dist/types/workspace-filesystem-jobs.d.ts +0 -7
- package/dist/types/workspace-git-sync.d.ts +0 -495
- package/dist/types/workspace-hydration-ledger.d.ts +0 -43
- package/dist/types/workspace-hydration-merge.d.ts +0 -95
- package/dist/types/workspace-hydration-recovery-state.d.ts +0 -10
- package/dist/types/workspace-incident-state.d.ts +0 -19
- package/dist/types/workspace-merge-projection.d.ts +0 -60
- package/dist/types/workspace-mount-boundary.d.ts +0 -10
- package/dist/types/workspace-mount-hold-fence.d.ts +0 -42
- package/dist/types/workspace-mutation-gate.d.ts +0 -42
- package/dist/types/workspace-path-move.d.ts +0 -21
- package/dist/types/workspace-preserve-only-policy.d.ts +0 -15
- package/dist/types/workspace-project-config-policy.d.ts +0 -48
- package/dist/types/workspace-projection-ledger.d.ts +0 -59
- package/dist/types/workspace-publication-evidence.d.ts +0 -17
- package/dist/types/workspace-sync-coalescer.d.ts +0 -28
- /package/dist/types/{credential-authority-lock-fixture.d.ts → runtime/adapter.d.ts} +0 -0
- /package/dist/types/{recovery-journal-stall-fixture.d.ts → runtime/releases/main.d.ts} +0 -0
|
@@ -1,467 +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_merge_projection_exports = {};
|
|
30
|
-
__export(workspace_merge_projection_exports, {
|
|
31
|
-
materializeWorkspaceProjectionTree: () => materializeWorkspaceProjectionTree,
|
|
32
|
-
mergeWorkspaceProjectionMount: () => mergeWorkspaceProjectionMount,
|
|
33
|
-
workspaceMergeProjectionSupport: () => workspaceMergeProjectionSupport,
|
|
34
|
-
workspaceMergeProjectionTestHarness: () => workspaceMergeProjectionTestHarness
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(workspace_merge_projection_exports);
|
|
37
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
38
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
39
|
-
var import_git_process_environment = require("./git-process-environment.cjs");
|
|
40
|
-
var import_working_tree_mirror = require("./working-tree-mirror.cjs");
|
|
41
|
-
var import_workspace_mount_boundary = require("./workspace-mount-boundary.cjs");
|
|
42
|
-
const MINIMUM_MERGE_TREE_GIT_VERSION = { major: 2, minor: 40 };
|
|
43
|
-
const NON_RECURSIVE_GIT_CONFIG = [
|
|
44
|
-
"-c",
|
|
45
|
-
"submodule.recurse=false",
|
|
46
|
-
"-c",
|
|
47
|
-
"fetch.recurseSubmodules=false",
|
|
48
|
-
"-c",
|
|
49
|
-
"push.recurseSubmodules=false"
|
|
50
|
-
];
|
|
51
|
-
let cachedWorkspaceMergeProjectionSupport = null;
|
|
52
|
-
function gitCommandArgs(args) {
|
|
53
|
-
return ["git", ...NON_RECURSIVE_GIT_CONFIG, ...args];
|
|
54
|
-
}
|
|
55
|
-
function gitResult(cwd, args, options = {}) {
|
|
56
|
-
const result = Bun.spawnSync(gitCommandArgs(args), {
|
|
57
|
-
cwd,
|
|
58
|
-
...options.stdin !== void 0 ? { stdin: options.stdin } : {},
|
|
59
|
-
stdout: "pipe",
|
|
60
|
-
stderr: "pipe",
|
|
61
|
-
env: options.environment ?? (0, import_git_process_environment.workerGitProcessEnvironment)()
|
|
62
|
-
});
|
|
63
|
-
return { exitCode: result.exitCode, stdout: Buffer.from(result.stdout), stderr: Buffer.from(result.stderr) };
|
|
64
|
-
}
|
|
65
|
-
function git(cwd, args, action, options = {}) {
|
|
66
|
-
const result = gitResult(cwd, args, options);
|
|
67
|
-
if (result.exitCode !== 0) {
|
|
68
|
-
const detail = result.stderr.toString().trim() || result.stdout.toString().trim() || `git exited ${result.exitCode}`;
|
|
69
|
-
throw new Error(`${action}: ${detail}`);
|
|
70
|
-
}
|
|
71
|
-
return result.stdout;
|
|
72
|
-
}
|
|
73
|
-
function gitText(cwd, args, action, options = {}) {
|
|
74
|
-
return git(cwd, args, action, options).toString().trim();
|
|
75
|
-
}
|
|
76
|
-
function gitVersionIsSupported(version) {
|
|
77
|
-
const match = /(?:^|\s)(\d+)\.(\d+)(?:\.\d+)?(?:\s|$)/u.exec(version);
|
|
78
|
-
if (!match) return false;
|
|
79
|
-
const major = Number(match[1]);
|
|
80
|
-
const minor = Number(match[2]);
|
|
81
|
-
return major > MINIMUM_MERGE_TREE_GIT_VERSION.major || major === MINIMUM_MERGE_TREE_GIT_VERSION.major && minor >= MINIMUM_MERGE_TREE_GIT_VERSION.minor;
|
|
82
|
-
}
|
|
83
|
-
function workspaceMergeProjectionSupport() {
|
|
84
|
-
if (cachedWorkspaceMergeProjectionSupport) return cachedWorkspaceMergeProjectionSupport;
|
|
85
|
-
if (process.env.R5D_WORKSPACE_MERGE_PROJECTION === "0") {
|
|
86
|
-
cachedWorkspaceMergeProjectionSupport = {
|
|
87
|
-
supported: false,
|
|
88
|
-
error: "Workspace merge projection is disabled by R5D_WORKSPACE_MERGE_PROJECTION=0; stale mounts will remain pinned until it is enabled"
|
|
89
|
-
};
|
|
90
|
-
return cachedWorkspaceMergeProjectionSupport;
|
|
91
|
-
}
|
|
92
|
-
const version = gitResult(void 0, ["--version"]);
|
|
93
|
-
const versionText = version.stdout.toString().trim();
|
|
94
|
-
if (version.exitCode !== 0 || !gitVersionIsSupported(versionText)) {
|
|
95
|
-
const observed = versionText || version.stderr.toString().trim() || `git exited ${version.exitCode}`;
|
|
96
|
-
cachedWorkspaceMergeProjectionSupport = {
|
|
97
|
-
supported: false,
|
|
98
|
-
error: `Workspace merge projection requires Git 2.40 or newer (found ${observed}); upgrade Git before synchronizing stale mounts`
|
|
99
|
-
};
|
|
100
|
-
return cachedWorkspaceMergeProjectionSupport;
|
|
101
|
-
}
|
|
102
|
-
cachedWorkspaceMergeProjectionSupport = { supported: true };
|
|
103
|
-
return cachedWorkspaceMergeProjectionSupport;
|
|
104
|
-
}
|
|
105
|
-
function normalizeWorkspaceRelativePath(value) {
|
|
106
|
-
const normalized = value.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
|
|
107
|
-
if (!normalized || normalized === "." || normalized.includes("\0") || normalized.split("/").some((segment) => segment === ".." || segment === ".git")) {
|
|
108
|
-
throw new Error(`Invalid workspace merge-projection path: ${value}`);
|
|
109
|
-
}
|
|
110
|
-
return normalized;
|
|
111
|
-
}
|
|
112
|
-
function requireObjectId(value, label) {
|
|
113
|
-
if (!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(value)) throw new Error(`${label} is not a Git object id: ${value}`);
|
|
114
|
-
return value;
|
|
115
|
-
}
|
|
116
|
-
function requireCommit(workspacePath, revision, label) {
|
|
117
|
-
const head = gitText(workspacePath, ["rev-parse", "--verify", `${revision}^{commit}`], `resolve ${label}`);
|
|
118
|
-
return requireObjectId(head, label);
|
|
119
|
-
}
|
|
120
|
-
function workspacePrivateStateDirectory(workspacePath) {
|
|
121
|
-
const gitDirectory = import_node_path.default.join(workspacePath, ".git");
|
|
122
|
-
const gitStatus = import_node_fs.default.lstatSync(gitDirectory);
|
|
123
|
-
if (!gitStatus.isDirectory() || gitStatus.isSymbolicLink()) {
|
|
124
|
-
throw new Error(`Workspace Git directory is not a regular directory: ${gitDirectory}`);
|
|
125
|
-
}
|
|
126
|
-
const stateDirectory = import_node_path.default.join(gitDirectory, "r5d");
|
|
127
|
-
let stateStatus = null;
|
|
128
|
-
try {
|
|
129
|
-
stateStatus = import_node_fs.default.lstatSync(stateDirectory);
|
|
130
|
-
} catch (error) {
|
|
131
|
-
if (error.code !== "ENOENT") throw error;
|
|
132
|
-
}
|
|
133
|
-
if (!stateStatus) import_node_fs.default.mkdirSync(stateDirectory, { mode: 448 });
|
|
134
|
-
else if (!stateStatus.isDirectory() || stateStatus.isSymbolicLink()) {
|
|
135
|
-
throw new Error(`Workspace Git private state is not a regular directory: ${stateDirectory}`);
|
|
136
|
-
}
|
|
137
|
-
return stateDirectory;
|
|
138
|
-
}
|
|
139
|
-
function temporaryIndexPath(workspacePath) {
|
|
140
|
-
return import_node_path.default.join(workspacePrivateStateDirectory(workspacePath), `tmp-index-${crypto.randomUUID()}`);
|
|
141
|
-
}
|
|
142
|
-
function temporaryIndexEnvironment(indexPath) {
|
|
143
|
-
return { ...(0, import_git_process_environment.workerGitProcessEnvironment)(), GIT_INDEX_FILE: indexPath };
|
|
144
|
-
}
|
|
145
|
-
function removeTemporaryIndex(indexPath) {
|
|
146
|
-
import_node_fs.default.rmSync(indexPath, { force: true });
|
|
147
|
-
import_node_fs.default.rmSync(`${indexPath}.lock`, { force: true });
|
|
148
|
-
}
|
|
149
|
-
function sourceEntryPath(sourceRoot, relativePath) {
|
|
150
|
-
const candidate = import_node_path.default.resolve(sourceRoot, ...relativePath.split("/"));
|
|
151
|
-
const relative = import_node_path.default.relative(sourceRoot, candidate);
|
|
152
|
-
if (relative === ".." || relative.startsWith(`..${import_node_path.default.sep}`) || import_node_path.default.isAbsolute(relative)) {
|
|
153
|
-
throw new Error(`Workspace merge-projection source escapes its root: ${relativePath}`);
|
|
154
|
-
}
|
|
155
|
-
return candidate;
|
|
156
|
-
}
|
|
157
|
-
function assertSameOpenFile(before, after, sourcePath) {
|
|
158
|
-
if (!after.isFile() || before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mode !== after.mode || before.mtimeMs !== after.mtimeMs || before.ctimeMs !== after.ctimeMs) {
|
|
159
|
-
throw new Error(`Working-tree source changed while its merge projection was being synthesized: ${sourcePath}`);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function hashRegularFile(workspacePath, sourcePath, entry) {
|
|
163
|
-
const descriptor = import_node_fs.default.openSync(sourcePath, import_node_fs.default.constants.O_RDONLY | import_node_fs.default.constants.O_NOFOLLOW);
|
|
164
|
-
try {
|
|
165
|
-
const before = import_node_fs.default.fstatSync(descriptor);
|
|
166
|
-
if (!before.isFile() || before.size !== entry.size || (before.mode & 511) !== (entry.mode & 511)) {
|
|
167
|
-
throw new Error(`Working-tree source changed while its merge projection was being synthesized: ${sourcePath}`);
|
|
168
|
-
}
|
|
169
|
-
const objectId = requireObjectId(
|
|
170
|
-
gitText(workspacePath, ["hash-object", "-w", "--stdin"], `hash workspace projection file ${sourcePath}`, {
|
|
171
|
-
stdin: descriptor
|
|
172
|
-
}),
|
|
173
|
-
`Workspace projection blob for ${sourcePath}`
|
|
174
|
-
);
|
|
175
|
-
const after = import_node_fs.default.fstatSync(descriptor);
|
|
176
|
-
assertSameOpenFile(before, after, sourcePath);
|
|
177
|
-
const pathStatus = import_node_fs.default.lstatSync(sourcePath);
|
|
178
|
-
if (pathStatus.dev !== after.dev || pathStatus.ino !== after.ino || !pathStatus.isFile() || pathStatus.isSymbolicLink()) {
|
|
179
|
-
throw new Error(`Working-tree source changed while its merge projection was being synthesized: ${sourcePath}`);
|
|
180
|
-
}
|
|
181
|
-
return { objectId, projected: (0, import_working_tree_mirror.projectedFileEntry)(after) };
|
|
182
|
-
} finally {
|
|
183
|
-
import_node_fs.default.closeSync(descriptor);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function hashSymlink(workspacePath, sourcePath, entry) {
|
|
187
|
-
const status = import_node_fs.default.lstatSync(sourcePath);
|
|
188
|
-
if (!status.isSymbolicLink() || import_node_fs.default.readlinkSync(sourcePath) !== entry.target) {
|
|
189
|
-
throw new Error(`Working-tree source changed while its merge projection was being synthesized: ${sourcePath}`);
|
|
190
|
-
}
|
|
191
|
-
const objectId = requireObjectId(
|
|
192
|
-
gitText(workspacePath, ["hash-object", "-w", "--stdin"], `hash workspace projection symlink ${sourcePath}`, {
|
|
193
|
-
stdin: Buffer.from(entry.target)
|
|
194
|
-
}),
|
|
195
|
-
`Workspace projection symlink blob for ${sourcePath}`
|
|
196
|
-
);
|
|
197
|
-
if (!import_node_fs.default.lstatSync(sourcePath).isSymbolicLink() || import_node_fs.default.readlinkSync(sourcePath) !== entry.target) {
|
|
198
|
-
throw new Error(`Working-tree source changed while its merge projection was being synthesized: ${sourcePath}`);
|
|
199
|
-
}
|
|
200
|
-
return objectId;
|
|
201
|
-
}
|
|
202
|
-
function indexMode(entry) {
|
|
203
|
-
if (entry.kind === "symlink") return "120000";
|
|
204
|
-
return (entry.mode & 73) !== 0 ? "100755" : "100644";
|
|
205
|
-
}
|
|
206
|
-
function indexInfoRecord(mode, objectId, relativePath) {
|
|
207
|
-
return Buffer.concat([Buffer.from(`${mode} ${objectId} `), Buffer.from(relativePath), Buffer.from([0])]);
|
|
208
|
-
}
|
|
209
|
-
function synthesizeMountTree(input) {
|
|
210
|
-
const sourceRoot = import_node_path.default.resolve(input.sourcePath);
|
|
211
|
-
const entries = (0, import_working_tree_mirror.inspectWorkingTree)(sourceRoot, input.sourceMode);
|
|
212
|
-
const indexPath = temporaryIndexPath(input.workspacePath);
|
|
213
|
-
const environment = temporaryIndexEnvironment(indexPath);
|
|
214
|
-
const projectedFiles = {};
|
|
215
|
-
const blobs = /* @__PURE__ */ new Map();
|
|
216
|
-
try {
|
|
217
|
-
git(input.workspacePath, ["read-tree", "--empty"], "initialize workspace projection index", { environment });
|
|
218
|
-
const records = [];
|
|
219
|
-
for (const [relativePath, entry] of [...entries.entries()].sort(([left], [right]) => left.localeCompare(right))) {
|
|
220
|
-
if (entry.kind === "directory") continue;
|
|
221
|
-
if (entry.kind === "gitlink") {
|
|
222
|
-
records.push(indexInfoRecord("160000", entry.objectId, relativePath));
|
|
223
|
-
projectedFiles[relativePath] = { kind: "gitlink", objectId: entry.objectId };
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
const sourcePath = sourceEntryPath(sourceRoot, relativePath);
|
|
227
|
-
let objectId;
|
|
228
|
-
if (entry.kind === "file") {
|
|
229
|
-
const hashed = hashRegularFile(input.workspacePath, sourcePath, entry);
|
|
230
|
-
objectId = hashed.objectId;
|
|
231
|
-
projectedFiles[relativePath] = hashed.projected;
|
|
232
|
-
} else {
|
|
233
|
-
objectId = hashSymlink(input.workspacePath, sourcePath, entry);
|
|
234
|
-
projectedFiles[relativePath] = { kind: "symlink", target: entry.target };
|
|
235
|
-
}
|
|
236
|
-
blobs.set(relativePath, objectId);
|
|
237
|
-
records.push(indexInfoRecord(indexMode(entry), objectId, relativePath));
|
|
238
|
-
}
|
|
239
|
-
if (records.length > 0) {
|
|
240
|
-
git(input.workspacePath, ["update-index", "-z", "--index-info"], "populate workspace projection index", {
|
|
241
|
-
environment,
|
|
242
|
-
stdin: Buffer.concat(records)
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
const tree = requireObjectId(
|
|
246
|
-
gitText(input.workspacePath, ["write-tree"], "write workspace projection mount tree", { environment }),
|
|
247
|
-
"Workspace projection mount tree"
|
|
248
|
-
);
|
|
249
|
-
return { tree, projectedFiles, blobs };
|
|
250
|
-
} finally {
|
|
251
|
-
removeTemporaryIndex(indexPath);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
function staleRewritePaths(input) {
|
|
255
|
-
const entries = Object.entries(input.staleRewriteBlobs ?? {});
|
|
256
|
-
if (entries.length === 0) return { stale: [], cleared: [] };
|
|
257
|
-
const probed = gitText(input.workspacePath, ["cat-file", "--batch-check"], "resolve workspace projection basis subtree", {
|
|
258
|
-
stdin: Buffer.from(`${input.basisHead}:${input.workspaceRelativePath}
|
|
259
|
-
`)
|
|
260
|
-
});
|
|
261
|
-
const basisSubtree = /^([0-9a-f]{40,64}) tree \d+$/u.exec(probed);
|
|
262
|
-
if (!basisSubtree && !/ missing$/u.test(probed))
|
|
263
|
-
throw new Error(`Resolve workspace projection basis subtree: unexpected answer ${probed}`);
|
|
264
|
-
const changed = /* @__PURE__ */ new Set();
|
|
265
|
-
if (!basisSubtree) {
|
|
266
|
-
for (const relativePath of input.blobs.keys()) changed.add(relativePath);
|
|
267
|
-
} else {
|
|
268
|
-
const listing = git(
|
|
269
|
-
input.workspacePath,
|
|
270
|
-
["diff-tree", "-r", "-z", "--no-renames", "--raw", basisSubtree[1], input.mountTree],
|
|
271
|
-
"compare workspace projection with its basis"
|
|
272
|
-
);
|
|
273
|
-
const records = nulRecords(listing);
|
|
274
|
-
for (let index = 0; index + 1 < records.length; index += 2) changed.add(records[index + 1].toString());
|
|
275
|
-
}
|
|
276
|
-
const stale = [];
|
|
277
|
-
const cleared = [];
|
|
278
|
-
for (const [relativePath, blob] of entries) {
|
|
279
|
-
const synthesized = input.blobs.get(relativePath);
|
|
280
|
-
if (synthesized === void 0) {
|
|
281
|
-
cleared.push(relativePath);
|
|
282
|
-
continue;
|
|
283
|
-
}
|
|
284
|
-
if (synthesized === blob) {
|
|
285
|
-
if (changed.has(relativePath)) stale.push(relativePath);
|
|
286
|
-
else cleared.push(relativePath);
|
|
287
|
-
continue;
|
|
288
|
-
}
|
|
289
|
-
if (changed.has(relativePath)) cleared.push(relativePath);
|
|
290
|
-
}
|
|
291
|
-
return { stale: stale.sort(), cleared: cleared.sort() };
|
|
292
|
-
}
|
|
293
|
-
function nulRecords(content) {
|
|
294
|
-
const records = [];
|
|
295
|
-
let start = 0;
|
|
296
|
-
for (let index = 0; index < content.length; index += 1) {
|
|
297
|
-
if (content[index] !== 0) continue;
|
|
298
|
-
if (index > start) records.push(content.subarray(start, index));
|
|
299
|
-
start = index + 1;
|
|
300
|
-
}
|
|
301
|
-
if (start < content.length) records.push(content.subarray(start));
|
|
302
|
-
return records;
|
|
303
|
-
}
|
|
304
|
-
function indexedSubtreePaths(content, workspaceRelativePath) {
|
|
305
|
-
const prefix = Buffer.from(workspaceRelativePath);
|
|
306
|
-
const descendantPrefix = Buffer.from(`${workspaceRelativePath}/`);
|
|
307
|
-
const records = nulRecords(content).filter(
|
|
308
|
-
(record) => record.equals(prefix) || record.length > descendantPrefix.length && record.subarray(0, descendantPrefix.length).equals(descendantPrefix)
|
|
309
|
-
);
|
|
310
|
-
return records.length > 0 ? Buffer.concat(records.flatMap((record) => [record, Buffer.from([0])])) : Buffer.alloc(0);
|
|
311
|
-
}
|
|
312
|
-
function graftMountTree(input) {
|
|
313
|
-
const indexPath = temporaryIndexPath(input.workspacePath);
|
|
314
|
-
const environment = temporaryIndexEnvironment(indexPath);
|
|
315
|
-
try {
|
|
316
|
-
git(input.workspacePath, ["read-tree", input.basisHead], "read workspace projection basis", { environment });
|
|
317
|
-
const indexedPaths = git(input.workspacePath, ["ls-files", "-z"], "enumerate workspace projection basis", { environment });
|
|
318
|
-
const removedPaths = indexedSubtreePaths(indexedPaths, input.workspaceRelativePath);
|
|
319
|
-
if (removedPaths.length > 0) {
|
|
320
|
-
git(input.workspacePath, ["update-index", "--force-remove", "-z", "--stdin"], "remove prior workspace projection subtree", {
|
|
321
|
-
environment,
|
|
322
|
-
stdin: removedPaths
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
git(
|
|
326
|
-
input.workspacePath,
|
|
327
|
-
["read-tree", "-i", `--prefix=${input.workspaceRelativePath}/`, input.mountTree],
|
|
328
|
-
"graft workspace projection mount tree",
|
|
329
|
-
{ environment }
|
|
330
|
-
);
|
|
331
|
-
return requireObjectId(
|
|
332
|
-
gitText(input.workspacePath, ["write-tree"], "write grafted workspace projection tree", { environment }),
|
|
333
|
-
"Grafted workspace projection tree"
|
|
334
|
-
);
|
|
335
|
-
} finally {
|
|
336
|
-
removeTemporaryIndex(indexPath);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
function synthesizeOursCommit(input) {
|
|
340
|
-
const synthesized = synthesizeMountTree({
|
|
341
|
-
workspacePath: input.workspacePath,
|
|
342
|
-
sourcePath: input.mount.sourcePath,
|
|
343
|
-
sourceMode: input.mount.sourceMode
|
|
344
|
-
});
|
|
345
|
-
const detected = staleRewritePaths({
|
|
346
|
-
workspacePath: input.workspacePath,
|
|
347
|
-
workspaceRelativePath: input.workspaceRelativePath,
|
|
348
|
-
basisHead: input.basisHead,
|
|
349
|
-
mountTree: synthesized.tree,
|
|
350
|
-
blobs: synthesized.blobs,
|
|
351
|
-
staleRewriteBlobs: input.staleRewriteBlobs
|
|
352
|
-
});
|
|
353
|
-
if (detected.stale.length > 0) return { staleRewritePaths: detected.stale, staleRewriteCleared: detected.cleared };
|
|
354
|
-
const rootTree = graftMountTree({
|
|
355
|
-
workspacePath: input.workspacePath,
|
|
356
|
-
workspaceRelativePath: input.workspaceRelativePath,
|
|
357
|
-
basisHead: input.basisHead,
|
|
358
|
-
mountTree: synthesized.tree
|
|
359
|
-
});
|
|
360
|
-
const message = JSON.stringify({
|
|
361
|
-
type: "workspace_projection_basis",
|
|
362
|
-
mountId: input.mount.id,
|
|
363
|
-
attemptId: input.attemptId
|
|
364
|
-
});
|
|
365
|
-
const oursCommit = requireObjectId(
|
|
366
|
-
gitText(
|
|
367
|
-
input.workspacePath,
|
|
368
|
-
["commit-tree", rootTree, "-p", input.basisHead, "-m", message],
|
|
369
|
-
`commit synthesized workspace projection for mount ${input.mount.id}`
|
|
370
|
-
),
|
|
371
|
-
`Synthesized workspace projection commit for mount ${input.mount.id}`
|
|
372
|
-
);
|
|
373
|
-
return { oursCommit, projectedFiles: synthesized.projectedFiles, staleRewriteCleared: detected.cleared };
|
|
374
|
-
}
|
|
375
|
-
function mergeWorkspaceProjectionMount(input) {
|
|
376
|
-
const support = workspaceMergeProjectionSupport();
|
|
377
|
-
if (!support.supported) throw new Error(support.error);
|
|
378
|
-
const workspacePath = import_node_path.default.resolve(input.workspacePath);
|
|
379
|
-
const workspaceRelativePath = normalizeWorkspaceRelativePath(input.mount.workspaceRelativePath);
|
|
380
|
-
const basisHead = requireCommit(workspacePath, input.basisHead, `workspace projection basis for mount ${input.mount.id}`);
|
|
381
|
-
const currentHead = requireCommit(workspacePath, input.currentHead, "current workspace projection head");
|
|
382
|
-
const synthesized = synthesizeOursCommit({
|
|
383
|
-
workspacePath,
|
|
384
|
-
mount: input.mount,
|
|
385
|
-
workspaceRelativePath,
|
|
386
|
-
basisHead,
|
|
387
|
-
attemptId: input.attemptId,
|
|
388
|
-
...input.staleRewriteBlobs ? { staleRewriteBlobs: input.staleRewriteBlobs } : {}
|
|
389
|
-
});
|
|
390
|
-
if ("staleRewritePaths" in synthesized) {
|
|
391
|
-
return { kind: "stale_rewrite", paths: synthesized.staleRewritePaths, staleRewriteCleared: synthesized.staleRewriteCleared };
|
|
392
|
-
}
|
|
393
|
-
const { oursCommit, projectedFiles, staleRewriteCleared } = synthesized;
|
|
394
|
-
const readAtMs = Date.now();
|
|
395
|
-
const merged = gitResult(workspacePath, [
|
|
396
|
-
"merge-tree",
|
|
397
|
-
"--write-tree",
|
|
398
|
-
`--merge-base=${basisHead}`,
|
|
399
|
-
"--name-only",
|
|
400
|
-
"-z",
|
|
401
|
-
"--no-messages",
|
|
402
|
-
oursCommit,
|
|
403
|
-
currentHead
|
|
404
|
-
]);
|
|
405
|
-
if (merged.exitCode !== 0 && merged.exitCode !== 1) {
|
|
406
|
-
const detail = merged.stderr.toString().trim() || merged.stdout.toString().trim() || `git exited ${merged.exitCode}`;
|
|
407
|
-
throw new Error(`Merge workspace projection for mount ${input.mount.id}: ${detail}`);
|
|
408
|
-
}
|
|
409
|
-
const records = nulRecords(merged.stdout);
|
|
410
|
-
const resultTree = records.shift()?.toString() ?? "";
|
|
411
|
-
requireObjectId(resultTree, `Merged workspace projection tree for mount ${input.mount.id}`);
|
|
412
|
-
if (merged.exitCode === 0) return { kind: "clean", resultTree, oursCommit, projectedFiles, readAtMs, staleRewriteCleared };
|
|
413
|
-
const conflictPaths = records.map((record) => record.toString()).sort();
|
|
414
|
-
return {
|
|
415
|
-
kind: "conflict",
|
|
416
|
-
oursCommit,
|
|
417
|
-
conflictPaths,
|
|
418
|
-
error: `Workspace projection for mount ${input.mount.id} conflicted with the current workspace head`,
|
|
419
|
-
projectedFiles,
|
|
420
|
-
readAtMs,
|
|
421
|
-
staleRewriteCleared
|
|
422
|
-
};
|
|
423
|
-
}
|
|
424
|
-
function materializeWorkspaceProjectionTree(input) {
|
|
425
|
-
const workspacePath = import_node_path.default.resolve(input.workspacePath);
|
|
426
|
-
const workspaceRelativePath = normalizeWorkspaceRelativePath(input.workspaceRelativePath);
|
|
427
|
-
const resultTree = requireObjectId(input.resultTree, "Workspace projection result tree");
|
|
428
|
-
const targetPath = import_node_path.default.join(workspacePath, ...workspaceRelativePath.split("/"));
|
|
429
|
-
(0, import_workspace_mount_boundary.assertManagedDirectoryPath)({
|
|
430
|
-
trustedRoot: workspacePath,
|
|
431
|
-
candidate: targetPath,
|
|
432
|
-
label: "Workspace merge-projection target"
|
|
433
|
-
});
|
|
434
|
-
git(workspacePath, ["cat-file", "-e", `${resultTree}^{tree}`], "resolve workspace merge-projection result tree");
|
|
435
|
-
const subtree = gitResult(workspacePath, ["cat-file", "-e", `${resultTree}:${workspaceRelativePath}`]);
|
|
436
|
-
if (subtree.exitCode !== 0) {
|
|
437
|
-
import_node_fs.default.rmSync(targetPath, { recursive: true, force: true });
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
const subtreeType = gitText(
|
|
441
|
-
workspacePath,
|
|
442
|
-
["cat-file", "-t", `${resultTree}:${workspaceRelativePath}`],
|
|
443
|
-
"inspect workspace merge-projection result subtree"
|
|
444
|
-
);
|
|
445
|
-
if (subtreeType !== "tree") {
|
|
446
|
-
throw new Error(`Workspace merge-projection result is not a directory at ${workspaceRelativePath}`);
|
|
447
|
-
}
|
|
448
|
-
import_node_fs.default.rmSync(targetPath, { recursive: true, force: true });
|
|
449
|
-
git(
|
|
450
|
-
workspacePath,
|
|
451
|
-
["checkout", "--no-recurse-submodules", resultTree, "--", `:(literal)${workspaceRelativePath}`],
|
|
452
|
-
"materialize merged workspace projection subtree"
|
|
453
|
-
);
|
|
454
|
-
}
|
|
455
|
-
const workspaceMergeProjectionTestHarness = {
|
|
456
|
-
gitVersionIsSupported,
|
|
457
|
-
resetSupportProbe() {
|
|
458
|
-
cachedWorkspaceMergeProjectionSupport = null;
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
462
|
-
0 && (module.exports = {
|
|
463
|
-
materializeWorkspaceProjectionTree,
|
|
464
|
-
mergeWorkspaceProjectionMount,
|
|
465
|
-
workspaceMergeProjectionSupport,
|
|
466
|
-
workspaceMergeProjectionTestHarness
|
|
467
|
-
});
|
|
@@ -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
|
-
});
|