UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

659 lines (658 loc) • 23 kB
import { createRequire } from "node:module"; //#region src/node-host/node-worker-workspace-manifest.generated.worker.mjs const require = createRequire(import.meta.url); process.argv.splice(1, 1); const childProcess = require("node:child_process"); const MAX_WORKSPACE_HASH_MEMO_BYTES = 8388608; const crypto = require("node:crypto"); const fs = require("node:fs"); const path = require("node:path"); const STAGED_INPUT_DIRECTORY_PREFIX = "media/inbound/openclaw-staged-"; const STAGED_INPUT_GITIGNORE = "# Raw task inputs remain private; copy outputs into the project to publish.\n*\n"; const STAGED_INPUT_GITIGNORE_SHA256 = "c2ae48852cf5745c7dcbcdfa46b0141497cb37fda5b011164f75dd3c08358e6f"; function stagedInputPathDirectory(e) { if (!e.startsWith(STAGED_INPUT_DIRECTORY_PREFIX)) return; const t = e.slice(30).split("/")[0]; return /^(?:[a-f0-9]{64}|[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12})$/u.exec(t)?.[0] === t ? STAGED_INPUT_DIRECTORY_PREFIX + t : void 0; } function isStagedInputPath(e, t) { const n = stagedInputPathDirectory(e); return n !== void 0 && t.has(n); } function stagedInputDirectoriesFromEntries(e) { const t = /* @__PURE__ */ new Set(); for (const n of e) { const e = stagedInputPathDirectory(n.path); if (e && n.path === e + "/.gitignore" && n.type === "file" && n.size === 78 && n.sha256 === STAGED_INPUT_GITIGNORE_SHA256) t.add(e); } return t; } const MATERIALIZED_SANDBOX_SKILLS_WORKSPACE = ".openclaw/sandbox-skills"; function isManagedSandboxSkillsPath(e) { return e === MATERIALIZED_SANDBOX_SKILLS_WORKSPACE || e.startsWith(".openclaw/sandbox-skills/"); } const DERIVED_WORKSPACE_ROOT_PATHS = [ ".cache/vitest", ".cache/bun-transpiler", ".cache/openclaw/bun", ".cache/ms-playwright", ".cache/convex/binaries", ".local/share/NuGet/http-cache", ".local/share/NuGet/v3-cache", ".nuget/packages", ".local/share/pnpm/store", ".openclaw/.pnpm-store", ".artifacts/vitest-workers", ".artifacts/vitest-worker-cache", ".artifacts/vitest-shard-timings.json" ]; const PNPM_FALLBACK_STORE_ROOT_PATH = ".openclaw/.pnpm-store"; const BUILD_CACHE_ROOT_PATHS = [".artifacts/build-all-cache", ".artifacts/build-cache-inputs"]; function isBuildCacheWorkspacePath(e) { return BUILD_CACHE_ROOT_PATHS.some((t) => e === t || e.startsWith(t + "/")); } function buildCacheInputPaths(e = []) { const t = /* @__PURE__ */ new Set(); for (const n of e) { if (!isBuildCacheWorkspacePath(n)) continue; const e = n.split("/"); for (let n = 1; n <= e.length; n++) t.add(e.slice(0, n).join("/")); } return t; } const RUNTIME_WORKSPACE_ROOT_PATHS = [".artifacts/dist-artifacts.lock", ".openclaw/tmp"]; const DERIVED_WORKSPACE_SEGMENT_RE = /* @__PURE__ */ new RegExp("(?:^|/)(?:__pycache__|\\.pytest_cache|\\.mypy_cache|\\.ruff_cache|node_modules|\\.DS_Store|[^/]*\\.pyc|[^/]*\\.pyo|openclaw-inbound-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f]-4[0-9a-f][0-9a-f][0-9a-f]-[89ab][0-9a-f][0-9a-f][0-9a-f]-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])(?![^/])"); function isRuntimeOwnedWorkspacePath(e) { return e === ".git" || e.startsWith(".git/") || e.endsWith("/.git") || e.includes("/.git/") || isManagedSandboxSkillsPath(e) || RUNTIME_WORKSPACE_ROOT_PATHS.some((t) => e === t || e.startsWith(t + "/")); } function isDerivedWorkspacePath(e, t = false, n = false, r = false) { if (isRuntimeOwnedWorkspacePath(e)) return true; if (t) return false; if (n && isBuildCacheWorkspacePath(e)) return true; if (DERIVED_WORKSPACE_ROOT_PATHS.some((t) => (!r || t !== PNPM_FALLBACK_STORE_ROOT_PATH) && (e === t || e.startsWith(t + "/")))) return true; return DERIVED_WORKSPACE_SEGMENT_RE.test(e); } function projectWorkspaceEntries(e, t, n = false) { const r = /* @__PURE__ */ new Set(); const i = /* @__PURE__ */ new Set(); const parent = (e) => e.slice(0, Math.max(0, e.lastIndexOf("/"))); for (const t of e) r.add(parent(t.path)); const a = []; for (let o = e.length - 1; o >= 0; o -= 1) { const s = e[o]; if (isDerivedWorkspacePath(s.path, t(s.path), n) || s.type === "directory" && r.has(s.path) && !i.has(s.path)) continue; a.push(s); i.add(parent(s.path)); } return a.toReversed(); } const WORKSPACE_CTIME_SAFETY_MARGIN_MS = 2e3; function workspaceCtimeIsReusable(e, t) { return e >= 0n && e < BigInt(t - WORKSPACE_CTIME_SAFETY_MARGIN_MS) * 1000000n; } function workspaceStatIdentity(e, t) { return [ e, t.dev, t.ino, t.size, t.mtimeNs, t.ctimeNs ].join(":"); } function selectWorkerWorkspaceHashMemoEntries(e, t, n) { const compareIdentity = ([e], [t]) => e < t ? -1 : e > t ? 1 : 0; const r = [...e].filter(([e]) => e.startsWith("worker:")).map((e) => ({ entry: e, size: Number(e[0].split(":")[3]) })).toSorted((e, t) => t.size - e.size || compareIdentity(e.entry, t.entry)); const i = []; let a = 2; for (const { entry: e } of r) { if (i.length === t) break; const r = Buffer.byteLength(JSON.stringify(e)) + (i.length > 0 ? 1 : 0); if (a + r <= n) { i.push(e); a += r; } } return i.toSorted(compareIdentity); } const MAX_WORKSPACE_HASH_MEMO_ENTRIES = 25e3; const root = fs.realpathSync(process.argv[1]); const stagedInputOwnership = /* @__PURE__ */ new Map(); function isStagedInput(e) { const t = stagedInputPathDirectory(e); if (!t) return false; if (stagedInputOwnership.has(t)) return stagedInputOwnership.get(t); let n = false; let r; try { let e = root; for (const n of t.split("/")) { e = path.join(e, n); const t = fs.lstatSync(e); if (!t.isDirectory() || t.isSymbolicLink()) return false; } const i = path.join(e, ".gitignore"); const a = fs.lstatSync(i); if (!a.isFile() || a.nlink !== 1 || a.size !== 78) return false; r = fs.openSync(i, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW | fs.constants.O_NONBLOCK); const o = fs.fstatSync(r); if (!o.isFile() || o.nlink !== 1 || o.dev !== a.dev || o.ino !== a.ino) return false; const s = Buffer.alloc(79); const c = fs.readSync(r, s, 0, s.length, 0); const l = fs.lstatSync(i); n = l.isFile() && l.nlink === 1 && l.dev === o.dev && l.ino === o.ino && l.mtimeMs === o.mtimeMs && l.ctimeMs === o.ctimeMs && fs.realpathSync(i) === i && c === 78 && s.subarray(0, c).toString("utf8") === STAGED_INPUT_GITIGNORE; } catch {} finally { if (r !== void 0) fs.closeSync(r); stagedInputOwnership.set(t, n); } return n; } const requestedBaseCommit = process.argv[2] || null; const eligibleOnly = process.argv[3] === "eligible"; const requestedManifestDigest = process.argv[3] === "resolve" ? process.argv[4] : null; const publishedManifestDigest = process.argv[3] === "publish" ? process.argv[4] : null; const memoMode = process.argv.at(-1) === "memo-v1"; const priorManifestDigests = [...new Set(process.argv.slice(4).filter((e) => e && e !== "memo-v1"))]; const MAX_WORKSPACE_GIT_CANDIDATES = 1e6; const MAX_WORKSPACE_INVENTORY_ENTRIES = 25e4; const MAX_WORKSPACE_INVENTORY_PATH_BYTES = 67108864; const MAX_WORKSPACE_INVENTORY_TOTAL_BYTES = 4294967296; const MAX_WORKSPACE_MANIFEST_BYTES = 67108864; const entriesByPath = /* @__PURE__ */ new Map(); let inventoryPathBytes = 0; let eligibleBytes = 0; const usedHashMemo = /* @__PURE__ */ new Map(); const metrics = { contentHashCount: 0, memoHitCount: 0, memoTruncatedCount: 0 }; /** @returns {never} */ function fail(e) { throw new Error(e); } function readHashMemo() { if (!memoMode) return /* @__PURE__ */ new Map(); const e = readManifestInput(); if (Buffer.byteLength(e) > MAX_WORKSPACE_HASH_MEMO_BYTES) fail("workspace hash memo exceeds its byte limit"); let t; try { t = JSON.parse(e); } catch { fail("invalid workspace hash memo"); } if (!Array.isArray(t) || t.length > MAX_WORKSPACE_HASH_MEMO_ENTRIES) fail("invalid workspace hash memo"); return new Map(t); } const hashMemo = readHashMemo(); function canonicalMode(e, t) { if (e === "directory") return 448; if (e === "symlink") return 511; return (t & 73) === 0 ? 420 : 493; } function canonicalEntry(e) { if (![ "directory", "file", "symlink" ].includes(e.type)) fail("unsupported worker workspace manifest entry"); const t = { path: e.path, type: e.type, mode: canonicalMode(e.type, e.mode) }; if (e.type === "file") return { ...t, size: e.size, sha256: e.sha256 }; if (e.type === "symlink") return { ...t, target: e.target }; return t; } function compareManifestPaths(e, t) { return e.path < t.path ? -1 : e.path > t.path ? 1 : 0; } function serializeManifest(e, t) { const n = stagedInputDirectoriesFromEntries(t); return JSON.stringify({ version: 1, baseCommit: e, entries: projectWorkspaceEntries(t.map(canonicalEntry).toSorted(compareManifestPaths), (e) => isStagedInputPath(e, n)) }); } const excludeBuildCaches = Boolean(requestedBaseCommit); const retainedBuildCacheInputs = /* @__PURE__ */ new Set(); function retainBuildCacheInput(e) { for (const t of buildCacheInputPaths([e])) retainedBuildCacheInputs.add(t); } function isRetainedWorkspaceInput(e) { return isStagedInput(e) || retainedBuildCacheInputs.has(e); } function isExcludedWorkspacePath(e) { return isDerivedWorkspacePath(e, isRetainedWorkspaceInput(e), excludeBuildCaches); } function recordEntry(e, t) { if (entriesByPath.has(e)) return; if (entriesByPath.size + 1 > MAX_WORKSPACE_INVENTORY_ENTRIES) fail("worker workspace manifest has too many entries"); inventoryPathBytes += Buffer.byteLength(e); if (inventoryPathBytes > MAX_WORKSPACE_INVENTORY_PATH_BYTES) fail("worker workspace manifest paths exceed their byte limit"); eligibleBytes += t.type === "file" ? t.size : t.type === "symlink" ? Buffer.byteLength(t.target) : 0; if (eligibleBytes > MAX_WORKSPACE_INVENTORY_TOTAL_BYTES) fail("worker workspace manifest exceeds its eligible byte limit"); entriesByPath.set(e, t); } function addEntry(e) { if (!e || path.posix.isAbsolute(e) || path.posix.normalize(e) !== e || e === ".." || e.startsWith("../")) fail("unsafe worker workspace path: " + e); if (isExcludedWorkspacePath(e)) return; if (entriesByPath.has(e)) return; const t = path.join(root, e); let n; try { n = fs.lstatSync(t); } catch (e) { if (e && (e.code === "ENOENT" || e.code === "ENOTDIR")) return; throw e; } recordNode(e, t, n); } function recordNode(e, t, n) { const r = n.mode & 511; if (n.isDirectory()) recordEntry(e, { path: e, type: "directory", mode: r }); else if (n.isFile()) recordEntry(e, { path: e, type: "file", mode: r, size: n.size, sha256: null }); else if (n.isSymbolicLink()) { const n = fs.readlinkSync(t); if (n.includes("\\") || path.posix.isAbsolute(n) || path.win32.parse(n).root) fail("worker workspace symlink must be portable and relative: " + e); const i = path.resolve(path.dirname(t), n); if (i !== root && !i.startsWith(root + path.sep)) fail("worker workspace symlink escapes the sync root: " + e); recordEntry(e, { path: e, type: "symlink", mode: r, target: n }); } else fail("unsupported worker workspace entry: " + e); } function addWithParents(e) { if (isExcludedWorkspacePath(e)) return; const t = e.split("/"); for (let e = 1; e < t.length; e += 1) addEntry(t.slice(0, e).join("/")); addEntry(e); } function walk(e) { const t = e ? path.join(root, e) : root; const n = []; let r = false; let i = false; const a = fs.opendirSync(t); try { for (;;) { const t = a.readSync(); if (!t) break; const i = e ? e + "/" + t.name : t.name; if (!e && t.name === ".git") continue; if (isExcludedWorkspacePath(i)) { r = true; continue; } n.push(t.name); if (n.length > MAX_WORKSPACE_INVENTORY_ENTRIES) fail("worker workspace directory has too many entries"); } } finally { a.closeSync(); } for (const t of n.toSorted(comparePathNames)) { const n = e ? e + "/" + t : t; const a = path.join(root, n); const o = fs.lstatSync(a); if (o.isDirectory()) { if (!walk(n)) { r = true; continue; } } recordNode(n, a, o); i = true; } return i || !r; } function comparePathNames(e, t) { return e < t ? -1 : e > t ? 1 : 0; } async function nulPaths(e) { const t = (await readManifestGit(root, [ "ls-files", "-z", ...e ], MAX_WORKSPACE_INVENTORY_PATH_BYTES)).toString("utf8").split("\0").filter(Boolean); if (t.length > MAX_WORKSPACE_GIT_CANDIDATES) fail("worker workspace has too many Git path candidates"); return t; } function readPriorManifestEntries(e, t) { if (!/^[a-f0-9]{64}$/.test(t)) fail("invalid prior workspace manifest digest"); const n = readManifestFile(path.join(e, t + ".json")); if (crypto.createHash("sha256").update(n).digest("hex") !== t) fail("prior workspace manifest digest mismatch"); const r = JSON.parse(n); if (!r || r.version !== 1 || !Array.isArray(r.entries) || r.entries.length > MAX_WORKSPACE_INVENTORY_ENTRIES) fail("invalid prior workspace manifest"); return r.entries; } async function readIgnoredWorkspacePaths() { const e = path.join(root, ".worktreeinclude"); const t = fs.existsSync(e) && fs.lstatSync(e).isFile(); const n = new Set(await nulPaths([ "--full-name", "--others", "--ignored", "--exclude-standard", ...t ? [] : ["--", ":(glob)media/inbound/openclaw-staged-*/**"] ])); const r = []; if (t) { for (const t of await nulPaths([ "--full-name", "--others", "--ignored", "--exclude-from=" + e ])) if (n.has(t)) r.push(t); } return { ignored: n, included: r }; } async function initializeBuildCacheInputs() { if (!excludeBuildCaches) return void 0; for (const e of await nulPaths(["--full-name", "--cached"])) retainBuildCacheInput(e); const e = path.join(process.env.HOME, ".openclaw-worker", "manifests"); for (const t of priorManifestDigests) for (const n of readPriorManifestEntries(e, t)) { if (!n || typeof n.path !== "string") fail("invalid prior workspace manifest entry"); retainBuildCacheInput(n.path); } const t = await readIgnoredWorkspacePaths(); for (const e of t.included) retainBuildCacheInput(e); return t; } async function eligiblePaths(e) { const t = /* @__PURE__ */ new Set(); let n = 0; function addSelected(e) { if (e === ".openclaw-base.pack" || t.has(e)) return; if (t.size + 1 > MAX_WORKSPACE_GIT_CANDIDATES) fail("worker workspace has too many Git path candidates"); n += Buffer.byteLength(e) + 1; if (n > MAX_WORKSPACE_INVENTORY_PATH_BYTES) fail("worker workspace Git path candidates exceed their byte limit"); t.add(e); if (excludeBuildCaches && priorManifestDigests.length === 0) retainBuildCacheInput(e); } for (const e of await nulPaths([ "--full-name", "--cached", "--others", "--exclude-standard" ])) addSelected(e); const { ignored: r, included: i } = e ?? await readIgnoredWorkspacePaths(); for (const e of r) if (isStagedInput(e)) addSelected(e); for (const e of i) addSelected(e); for (const e of priorManifestDigests) { const t = readPriorManifestEntries(path.join(process.env.HOME, ".openclaw-worker", "manifests"), e); for (const e of t) if (!e || typeof e.path !== "string") fail("invalid prior workspace manifest entry"); for (const e of projectWorkspaceEntries(t.toSorted(compareManifestPaths), isRetainedWorkspaceInput, excludeBuildCaches)) addSelected(e.path); } return [...t].filter((e) => !isExcludedWorkspacePath(e)).toSorted(comparePathNames); } function assertSerializedManifestBudget(e, t) { let n = Buffer.byteLength(JSON.stringify({ version: 1, baseCommit: e, entries: [] })); for (const [e, r] of t.entries()) { const t = r.type === "file" ? { ...r, sha256: "0".repeat(64) } : r; n += Buffer.byteLength(JSON.stringify(canonicalEntry(t))); if (e > 0) n += 1; if (n > MAX_WORKSPACE_MANIFEST_BYTES) fail("worker workspace manifest exceeds its serialized byte limit"); } } async function hashFiles(e) { let t = e.reduce((e, t) => e + (t.type === "symlink" ? Buffer.byteLength(t.target) : 0), 0); let n = 0; let r; const i = new AbortController(); const stop = (e) => { if (!r) { r = { error: e }; i.abort(e); } }; async function worker() { while (n < e.length) { if (r) return; const a = e[n++]; if (a.type !== "file") continue; const o = path.join(root, a.path); const s = Date.now(); let c; try { c = await fs.promises.open(o, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW | fs.constants.O_NONBLOCK); i.signal.throwIfAborted(); const e = await c.stat({ bigint: true }); i.signal.throwIfAborted(); if (!e.isFile()) fail("worker workspace file changed while it was being read"); const n = Number(e.size); t += n; if (t > MAX_WORKSPACE_INVENTORY_TOTAL_BYTES) fail("worker workspace manifest exceeds its eligible byte limit"); const r = workspaceStatIdentity("worker", e); const l = workspaceCtimeIsReusable(e.ctimeNs, s); let u = l ? hashMemo.get(r) : void 0; if (u) metrics.memoHitCount += 1; else { const e = crypto.createHash("sha256"); const t = c.createReadStream({ autoClose: false, signal: i.signal }); let r = 0; for await (const i of t) { r += i.length; if (r > n) fail("worker workspace file changed while it was being read"); e.update(i); } u = e.digest("hex"); metrics.contentHashCount += 1; } const d = await c.stat({ bigint: true }); if (workspaceStatIdentity("worker", d) !== r) fail("worker workspace file changed while it was being read"); a.mode = Number(d.mode & 511n); a.size = Number(d.size); a.sha256 = u; if (l) usedHashMemo.set(r, u); } catch (e) { stop(e); } finally { try { await c?.close(); } catch (e) { stop(e); } } } } await Promise.all(Array.from({ length: Math.min(4, e.length) }, worker)); if (r) throw r.error; } function ensurePrivateDirectory(e) { try { const t = fs.lstatSync(e); if (t.isSymbolicLink() || !t.isDirectory()) fail("unsafe worker manifest directory"); } catch (t) { if (t && t.code === "ENOENT") fs.mkdirSync(e, { mode: 448 }); else throw t; } fs.chmodSync(e, 448); } function publishManifest(e, t) { if (Buffer.byteLength(t) > MAX_WORKSPACE_MANIFEST_BYTES) fail("worker workspace manifest exceeds its serialized byte limit"); const n = crypto.createHash("sha256").update(t).digest("hex"); const r = path.join(e, n + ".json"); const i = r + "." + process.pid + "." + crypto.randomBytes(4).toString("hex"); fs.writeFileSync(i, t, { encoding: "utf8", flag: "wx", mode: 384 }); try { fs.linkSync(i, r); } catch (e) { const n = e && e.code === "EEXIST" ? fs.lstatSync(r) : null; if (!n || n.isSymbolicLink() || !n.isFile() || fs.readFileSync(r, "utf8") !== t) throw e; } finally { fs.rmSync(i, { force: true }); } return n; } function readManifestFile(e) { const t = fs.openSync(e, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW); try { const e = fs.fstatSync(t); if (!e.isFile() || e.size > MAX_WORKSPACE_MANIFEST_BYTES) fail("unsafe worker workspace manifest file"); return fs.readFileSync(t, "utf8"); } finally { fs.closeSync(t); } } function resolveManifest(e, t) { if (!/^[a-f0-9]{64}$/.test(t || "")) fail("invalid workspace manifest digest"); const n = path.join(e, t + ".json"); try { fs.lstatSync(n); return t; } catch (e) { if (!e || e.code !== "ENOENT") throw e; } const r = fs.readdirSync(e).filter((e) => /^[a-f0-9]{64}\.json$/.test(e)).map((t) => { try { return { name: t, mtimeMs: fs.lstatSync(path.join(e, t)).mtimeMs }; } catch { return null; } }).filter(Boolean).toSorted((e, t) => t.mtimeMs - e.mtimeMs || (e.name < t.name ? -1 : e.name > t.name ? 1 : 0)).slice(0, 256); let i = 0; for (const { name: n } of r) { const r = path.join(e, n); let a; try { const e = readManifestFile(r); i += Buffer.byteLength(e); if (i > 268435456) break; if (crypto.createHash("sha256").update(e).digest("hex") !== n.slice(0, -5)) continue; const t = JSON.parse(e); if (!t || t.version !== 1 || !Array.isArray(t.entries)) continue; a = serializeManifest(t.baseCommit ?? null, t.entries); } catch { continue; } if (crypto.createHash("sha256").update(a).digest("hex") !== t) continue; publishManifest(e, a); return t; } return fail("worker workspace manifest is unavailable: " + t); } async function readPublishedManifest() { const e = []; let t = 0; for await (const n of process.stdin) { const r = Buffer.isBuffer(n) ? n : Buffer.from(n); t += r.byteLength; if (t > MAX_WORKSPACE_MANIFEST_BYTES) fail("published workspace manifest exceeds its byte limit"); e.push(r); } return Buffer.concat(e).toString("utf8"); } function preserveWindowsFileModes(e, t) { if (process.platform !== "win32" || priorManifestDigests.length === 0) return; const n = /* @__PURE__ */ new Map(); for (const e of priorManifestDigests) for (const r of readPriorManifestEntries(t, e)) if (r.type === "file" && !n.has(r.path)) { if (r.mode !== 420 && r.mode !== 493) fail("invalid prior workspace file mode"); n.set(r.path, r.mode); } for (const t of e) if (t.type === "file" && n.has(t.path)) t.mode = n.get(t.path); } async function main() { const e = path.join(process.env.HOME, ".openclaw-worker"); const t = path.join(e, "manifests"); ensurePrivateDirectory(e); ensurePrivateDirectory(t); if (publishedManifestDigest) { const e = await readPublishedManifest(); if (crypto.createHash("sha256").update(e).digest("hex") !== publishedManifestDigest) fail("published workspace manifest digest mismatch"); publishManifest(t, e); process.stdout.write("sha256:" + publishedManifestDigest + "\n"); return; } if (requestedManifestDigest) { process.stdout.write("sha256:" + resolveManifest(t, requestedManifestDigest) + "\n"); return; } const n = await initializeBuildCacheInputs(); if (eligibleOnly) for (const e of await eligiblePaths(n)) addWithParents(e); else walk(""); const r = [...entriesByPath.values()]; assertSerializedManifestBudget(requestedBaseCommit, r); await hashFiles(r); preserveWindowsFileModes(r, t); const i = "sha256:" + publishManifest(t, serializeManifest(requestedBaseCommit, r)); if (memoMode) { const e = selectWorkerWorkspaceHashMemoEntries(usedHashMemo, MAX_WORKSPACE_HASH_MEMO_ENTRIES, MAX_WORKSPACE_HASH_MEMO_BYTES); metrics.memoTruncatedCount = usedHashMemo.size - e.length; process.stdout.write(JSON.stringify({ version: 1, manifestRef: i, memo: e, metrics }) + "\n"); } else process.stdout.write(i + "\n"); } function readManifestInput() { return fs.readFileSync(0, "utf8"); } async function readManifestGit(e, t, n) { return childProcess.execFileSync("git", [ "-C", e, ...t ], { encoding: "buffer", maxBuffer: n, env: { ...process.env, GIT_NO_LAZY_FETCH: "1" } }); } /** @param {unknown} error */ function reportFailure(e) { process.stderr.write(String(e instanceof Error ? e.stack ?? e.message : e) + "\n"); process.exitCode = 1; } main().catch(reportFailure); //#endregion export {};