@agent-vm/gondolin-vm-adapter 0.0.124 → 0.0.126
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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -589,7 +589,7 @@ function toRelativeProviderPath(providerPath) {
|
|
|
589
589
|
return normalizedPath === "/" ? "" : normalizedPath.slice(1);
|
|
590
590
|
}
|
|
591
591
|
function isEqualOrDescendant(candidatePath, ancestorPath) {
|
|
592
|
-
return candidatePath === ancestorPath || candidatePath.startsWith(`${ancestorPath}/`);
|
|
592
|
+
return ancestorPath.length === 0 || candidatePath === ancestorPath || candidatePath.startsWith(`${ancestorPath}/`);
|
|
593
593
|
}
|
|
594
594
|
function pathsOverlap(firstPath, secondPath) {
|
|
595
595
|
return isEqualOrDescendant(firstPath, secondPath) || isEqualOrDescendant(secondPath, firstPath);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["isRecord","fs","net","createNativeManagedVm"],"sources":["../src/rootfs-init-extra.ts","../src/build-pipeline.ts","../src/exact-recorded-process-termination.ts","../src/gondolin-package.ts","../src/pinned-realfs.ts","../src/filtered-workspace-provider.ts","../src/host-network-defaults.ts","../src/vm-adapter.ts","../src/managed-vm-provider.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport type { BuildConfig } from '@earendil-works/gondolin';\n\nexport const agentVmRootfsInitExtraScript = `# Generated by agent-vm.\n# Gondolin mounts devtmpfs over /dev at boot, so Docker-image /dev symlinks are hidden.\nmkdir -p /dev\nln -sfn /proc/self/fd /dev/fd 2>/dev/null || true\nln -sfn /proc/self/fd/0 /dev/stdin 2>/dev/null || true\nln -sfn /proc/self/fd/1 /dev/stdout 2>/dev/null || true\nln -sfn /proc/self/fd/2 /dev/stderr 2>/dev/null || true\nif [ ! -e /dev/ptmx ] && [ -e /dev/pts/ptmx ]; then\n ln -sfn pts/ptmx /dev/ptmx 2>/dev/null || true\nfi\n`;\n\ninterface PrepareRootfsInitExtraOptions {\n\treadonly buildConfig: BuildConfig;\n\treadonly imagePath: string;\n\treadonly rootfsInitExtraContent: string;\n}\n\ninterface ResolveRootfsInitExtraOptions {\n\treadonly buildConfig: BuildConfig;\n\treadonly configDir?: string;\n\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n}\n\n/**\n * Backend projection of the domain-owned managed Gateway boot contract.\n *\n * The projection is deliberately closed: callers select the framework image\n * entry, while executable paths, arguments, environment-input paths, and log\n * identities remain adapter-owned image behavior.\n */\nexport interface GondolinManagedGatewayBootProjection {\n\treadonly frameworkBootEntry: 'hermes-framework-service' | 'openclaw-framework-service';\n\treadonly kind: 'managed-gateway-exact-two-role';\n}\n\nexport interface ResolvedRootfsInitExtra {\n\treadonly content: string;\n\treadonly fingerprintInput: {\n\t\treadonly agentVmRootfsInitExtra: string;\n\t\treadonly deploymentRootfsInitExtra?: string;\n\t\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n\t};\n}\n\nconst managedGatewayEnvironmentInputRoot = '/run/agent-vm/managed-gateway-environment';\nconst managedGatewayStructuredInputRoot = '/run/agent-vm/managed-gateway';\nconst managedGatewayRuntimeRoot = '/run/agent-vm/gateway-runtime';\nconst managedGatewayLogRoot = '/var/log/agent-vm';\n\nfunction frameworkBootCommand(\n\tframeworkBootEntry: GondolinManagedGatewayBootProjection['frameworkBootEntry'],\n): string {\n\tswitch (frameworkBootEntry) {\n\t\tcase 'hermes-framework-service':\n\t\t\treturn '/usr/local/bin/agent-vm-hermes-gateway';\n\t\tcase 'openclaw-framework-service':\n\t\t\treturn '/usr/local/bin/openclaw gateway --port 18789';\n\t}\n}\n\nfunction frameworkLogFileName(\n\tframeworkBootEntry: GondolinManagedGatewayBootProjection['frameworkBootEntry'],\n): string {\n\treturn frameworkBootEntry === 'openclaw-framework-service'\n\t\t? 'openclaw-service.log'\n\t\t: 'hermes-service.log';\n}\n\nexport function renderManagedGatewayRootfsInitScript(\n\tprojection: GondolinManagedGatewayBootProjection,\n): string {\n\tconst selectedFrameworkBootCommand = frameworkBootCommand(projection.frameworkBootEntry);\n\tconst selectedFrameworkLogPath = `${managedGatewayLogRoot}/${frameworkLogFileName(projection.frameworkBootEntry)}`;\n\tconst frameworkBootInputFileNames = 'framework-service.json';\n\tconst serviceEnvironmentIsolationPrefix =\n\t\tprojection.frameworkBootEntry === 'hermes-framework-service' ? '/usr/bin/env -i ' : '';\n\treturn `# Fixed managed Gateway sibling boot entries.\nmanaged_gateway_environment_input_root=${managedGatewayEnvironmentInputRoot}\nmanaged_gateway_structured_input_root=${managedGatewayStructuredInputRoot}\nmkdir -p ${managedGatewayLogRoot}\ninstall -d -m 0700 ${managedGatewayRuntimeRoot}\ninstall -m 0600 /dev/null ${managedGatewayLogRoot}/tool-portal-service.log\ninstall -m 0600 /dev/null ${selectedFrameworkLogPath}\n(\n if [ ! -f \"$managed_gateway_environment_input_root/tool-portal.environment.sh\" ]; then exit 78; fi\n for managed_gateway_input_name in tool-portal-service.json mcp.config.json; do\n if [ ! -f \"$managed_gateway_structured_input_root/$managed_gateway_input_name\" ]; then exit 78; fi\n done\n exec ${serviceEnvironmentIsolationPrefix}/bin/sh -c 'set -a; . ${managedGatewayEnvironmentInputRoot}/tool-portal.environment.sh || exit 78; set +a; rm -- ${managedGatewayEnvironmentInputRoot}/tool-portal.environment.sh || exit 78; exec /usr/local/bin/agent-vm-gateway-runtime --config ${managedGatewayStructuredInputRoot}/tool-portal-service.json'\n) >> ${managedGatewayLogRoot}/tool-portal-service.log 2>&1 &\n(\n if [ ! -f \"$managed_gateway_environment_input_root/framework.environment.sh\" ]; then exit 78; fi\n for managed_gateway_input_name in ${frameworkBootInputFileNames}; do\n if [ ! -f \"$managed_gateway_structured_input_root/$managed_gateway_input_name\" ]; then exit 78; fi\n done\n exec ${serviceEnvironmentIsolationPrefix}/bin/sh -c 'set -a; . ${managedGatewayEnvironmentInputRoot}/framework.environment.sh || exit 78; set +a; rm -- ${managedGatewayEnvironmentInputRoot}/framework.environment.sh || exit 78; exec ${selectedFrameworkBootCommand}'\n) >> ${selectedFrameworkLogPath} 2>&1 &\n`;\n}\n\nfunction resolveBuildConfigPath(filePath: string, configDir: string | undefined): string {\n\treturn path.isAbsolute(filePath) ? filePath : path.resolve(configDir ?? process.cwd(), filePath);\n}\n\nasync function readExistingRootfsInitExtra(\n\tbuildConfig: BuildConfig,\n\tconfigDir: string | undefined,\n): Promise<string | undefined> {\n\tconst existingRootfsInitExtra = buildConfig.init?.rootfsInitExtra;\n\tif (!existingRootfsInitExtra) {\n\t\treturn undefined;\n\t}\n\n\tconst resolvedRootfsInitExtra = resolveBuildConfigPath(existingRootfsInitExtra, configDir);\n\ttry {\n\t\treturn await fs.readFile(resolvedRootfsInitExtra, 'utf8');\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(\n\t\t\t`Failed to read Gondolin rootfs init extra '${resolvedRootfsInitExtra}': ${message}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n}\n\nfunction composeRootfsInitExtra(existingRootfsInitExtra: string | undefined): string {\n\treturn existingRootfsInitExtra\n\t\t? `${agentVmRootfsInitExtraScript.trimEnd()}\\n\\n${existingRootfsInitExtra}`\n\t\t: agentVmRootfsInitExtraScript;\n}\n\nexport async function resolveRootfsInitExtra(\n\toptions: ResolveRootfsInitExtraOptions,\n): Promise<ResolvedRootfsInitExtra> {\n\tif (options.managedGatewayBoot !== undefined && options.buildConfig.init?.rootfsInitExtra) {\n\t\tthrow new Error(\n\t\t\t'Managed Gateway images cannot compose deployment-authored rootfs init authority.',\n\t\t);\n\t}\n\tconst existingRootfsInitExtra = await readExistingRootfsInitExtra(\n\t\toptions.buildConfig,\n\t\toptions.configDir,\n\t);\n\tconst managedGatewayRootfsInitExtra =\n\t\toptions.managedGatewayBoot === undefined\n\t\t\t? undefined\n\t\t\t: renderManagedGatewayRootfsInitScript(options.managedGatewayBoot);\n\tconst composedRootfsInitExtra = composeRootfsInitExtra(existingRootfsInitExtra);\n\n\treturn {\n\t\tcontent:\n\t\t\tmanagedGatewayRootfsInitExtra === undefined\n\t\t\t\t? composedRootfsInitExtra\n\t\t\t\t: `${composedRootfsInitExtra.trimEnd()}\\n\\n${managedGatewayRootfsInitExtra}`,\n\t\tfingerprintInput: {\n\t\t\tagentVmRootfsInitExtra: agentVmRootfsInitExtraScript,\n\t\t\t...(existingRootfsInitExtra === undefined\n\t\t\t\t? {}\n\t\t\t\t: { deploymentRootfsInitExtra: existingRootfsInitExtra }),\n\t\t\t...(options.managedGatewayBoot === undefined\n\t\t\t\t? {}\n\t\t\t\t: { managedGatewayBoot: options.managedGatewayBoot }),\n\t\t},\n\t};\n}\n\nexport async function prepareBuildConfigWithAgentVmRootfsInitExtra(\n\toptions: PrepareRootfsInitExtraOptions,\n): Promise<BuildConfig> {\n\tconst rootfsInitExtraPath = path.join(options.imagePath, 'agent-vm-rootfs-init-extra.sh');\n\n\tawait fs.writeFile(rootfsInitExtraPath, options.rootfsInitExtraContent, {\n\t\tencoding: 'utf8',\n\t\tmode: 0o755,\n\t});\n\n\treturn {\n\t\t...options.buildConfig,\n\t\tinit: {\n\t\t\t...options.buildConfig.init,\n\t\t\trootfsInitExtra: rootfsInitExtraPath,\n\t\t},\n\t};\n}\n","import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport type { BuildConfig, BuildOptions } from '@earendil-works/gondolin';\nimport { validateBuildConfig } from '@earendil-works/gondolin';\n\nimport {\n\tprepareBuildConfigWithAgentVmRootfsInitExtra,\n\tresolveRootfsInitExtra,\n\ttype GondolinManagedGatewayBootProjection,\n} from './rootfs-init-extra.js';\n\nexport type { BuildConfig } from '@earendil-works/gondolin';\n\nexport interface BuildImageOptions {\n\treadonly buildConfig: BuildConfig;\n\treadonly cacheDir: string;\n\t/** Directory to resolve relative paths in buildConfig (e.g. postBuild.copy.src).\n\t * Defaults to process.cwd() if not provided. */\n\treadonly configDir?: string;\n\treadonly fullReset?: boolean;\n\treadonly fingerprintInput?: unknown;\n\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n\treadonly output?: BuildOutput;\n}\n\nexport interface BuildOutput {\n\twrite(chunk: string | Uint8Array): boolean;\n}\n\nexport interface BuildImageResult {\n\treadonly built: boolean;\n\treadonly fingerprint: string;\n\treadonly imagePath: string;\n}\n\nexport interface GondolinImageBuildToolingOptions {\n\treadonly buildConfig: unknown;\n\treadonly cacheDir: string;\n\treadonly configDir?: string;\n\treadonly fullReset?: boolean;\n\treadonly fingerprintInput?: unknown;\n\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n\treadonly output?: BuildOutput;\n}\n\nexport interface GondolinImageFingerprintOptions {\n\treadonly buildConfig: unknown;\n\treadonly configDir?: string;\n\treadonly fingerprintInput?: unknown;\n\treadonly gondolinVersion?: string;\n\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n}\n\nexport interface GondolinImageBuildTooling {\n\tbuildImage(\n\t\toptions: GondolinImageBuildToolingOptions,\n\t\tdependencies?: { readonly gondolinVersion?: string },\n\t): Promise<BuildImageResult>;\n\tcomputeFingerprint(options: GondolinImageFingerprintOptions): Promise<string>;\n}\n\nexport const buildImageAssetFileNames = [\n\t'manifest.json',\n\t'rootfs.ext4',\n\t'initramfs.cpio.lz4',\n\t'vmlinuz-virt',\n] as const;\n\nfunction requireValidBuildConfig(buildConfig: unknown): BuildConfig {\n\tif (!validateBuildConfig(buildConfig)) {\n\t\tthrow new Error('Managed VM image recipe has an invalid build shape.');\n\t}\n\treturn buildConfig;\n}\n\nexport function createGondolinImageBuildTooling(): GondolinImageBuildTooling {\n\treturn {\n\t\tasync buildImage(options, dependencies) {\n\t\t\treturn await buildImage(\n\t\t\t\t{\n\t\t\t\t\t...options,\n\t\t\t\t\tbuildConfig: requireValidBuildConfig(options.buildConfig),\n\t\t\t\t},\n\t\t\t\tdependencies,\n\t\t\t);\n\t\t},\n\t\tasync computeFingerprint(options) {\n\t\t\tconst result = await computeEffectiveBuildFingerprint({\n\t\t\t\t...options,\n\t\t\t\tbuildConfig: requireValidBuildConfig(options.buildConfig),\n\t\t\t});\n\t\t\treturn result.fingerprint;\n\t\t},\n\t};\n}\n\ninterface BuildPipelineDependencies {\n\treadonly buildAssets?: (\n\t\tbuildConfig: BuildConfig,\n\t\toutputDirectory: string,\n\t\tconfigDir?: string,\n\t\tworkDir?: string,\n\t\tverbose?: boolean,\n\t) => Promise<unknown>;\n\treadonly gondolinVersion?: string;\n}\n\nconst inFlightImageBuilds = new Map<string, Promise<BuildImageResult>>();\nconst gondolinWorkDirectoryName = '.agent-vm-gondolin-work';\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null;\n}\n\nfunction stableSerialize(value: unknown): string {\n\tif (Array.isArray(value)) {\n\t\treturn `[${value.map((entry) => stableSerialize(entry)).join(',')}]`;\n\t}\n\n\tif (isRecord(value)) {\n\t\tconst objectEntries = Object.entries(value)\n\t\t\t.filter(([, entryValue]) => entryValue !== undefined)\n\t\t\t.toSorted(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey));\n\t\treturn `{${objectEntries\n\t\t\t.map(([entryKey, entryValue]) => `${JSON.stringify(entryKey)}:${stableSerialize(entryValue)}`)\n\t\t\t.join(',')}}`;\n\t}\n\n\treturn JSON.stringify(value);\n}\n\nfunction isMissingPathError(error: unknown): boolean {\n\treturn typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';\n}\n\nasync function pathExists(filePath: string): Promise<boolean> {\n\ttry {\n\t\tawait fs.access(filePath);\n\t\treturn true;\n\t} catch (error) {\n\t\tif (!isMissingPathError(error)) {\n\t\t\tthrow error;\n\t\t}\n\t\treturn false;\n\t}\n}\n\nexport async function hasBuiltImageAssets(outputDirectoryPath: string): Promise<boolean> {\n\tfor (const fileName of buildImageAssetFileNames) {\n\t\t// oxlint-disable-next-line no-await-in-loop -- each missing file points at the same image generation\n\t\tif (!(await pathExists(path.join(outputDirectoryPath, fileName)))) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nasync function loadBuildAssets(): Promise<\n\t(\n\t\tbuildConfig: BuildConfig,\n\t\toutputDirectory: string,\n\t\tconfigDir?: string,\n\t\tworkDir?: string,\n\t\tverbose?: boolean,\n\t) => Promise<unknown>\n> {\n\tconst gondolinModule = await import('@earendil-works/gondolin');\n\treturn async (\n\t\tbuildConfig: BuildConfig,\n\t\toutputDirectory: string,\n\t\tconfigDir?: string,\n\t\tworkDir?: string,\n\t\tverbose?: boolean,\n\t): Promise<unknown> =>\n\t\tawait gondolinModule.buildAssets(buildConfig, {\n\t\t\toutputDir: outputDirectory,\n\t\t\tverbose: verbose ?? false,\n\t\t\t...(configDir ? { configDir } : {}),\n\t\t\t...(workDir ? { workDir } : {}),\n\t\t} satisfies BuildOptions);\n}\n\nfunction createRedirectedWrite(output: BuildOutput): typeof process.stderr.write {\n\treturn ((\n\t\tchunk: string | Uint8Array,\n\t\tencodingOrCallback?: BufferEncoding | ((error?: Error | null) => void),\n\t\tcallback?: (error?: Error | null) => void,\n\t): boolean => {\n\t\tconst writeCallback = typeof encodingOrCallback === 'function' ? encodingOrCallback : callback;\n\t\tconst wrote = output.write(chunk);\n\t\twriteCallback?.();\n\t\treturn wrote;\n\t}) as typeof process.stderr.write;\n}\n\nasync function withCapturedBuildOutput<TResult>(\n\toutput: BuildOutput | undefined,\n\tfn: () => Promise<TResult>,\n): Promise<TResult> {\n\tif (!output) {\n\t\treturn await fn();\n\t}\n\n\tconst originalStderrWrite = process.stderr.write.bind(process.stderr);\n\tconst originalStdoutWrite = process.stdout.write.bind(process.stdout);\n\tconst originalCi = process.env.CI;\n\tconst redirectedWrite = createRedirectedWrite(output);\n\n\tprocess.stderr.write = redirectedWrite;\n\tprocess.stdout.write = redirectedWrite;\n\tprocess.env.CI = 'true';\n\n\ttry {\n\t\treturn await fn();\n\t} finally {\n\t\tprocess.stderr.write = originalStderrWrite;\n\t\tprocess.stdout.write = originalStdoutWrite;\n\t\tif (originalCi === undefined) {\n\t\t\tdelete process.env.CI;\n\t\t} else {\n\t\t\tprocess.env.CI = originalCi;\n\t\t}\n\t}\n}\n\nexport function computeBuildFingerprint(\n\tbuildConfig: BuildConfig,\n\tgondolinVersion: string = 'unknown',\n\tfingerprintInput?: unknown,\n): string {\n\tconst payload =\n\t\tfingerprintInput === undefined\n\t\t\t? `${stableSerialize(buildConfig)}|${gondolinVersion}`\n\t\t\t: `${stableSerialize(buildConfig)}|${gondolinVersion}|${stableSerialize(fingerprintInput)}`;\n\n\treturn crypto.createHash('sha256').update(payload).digest('hex').slice(0, 16);\n}\n\nexport async function computeEffectiveBuildFingerprint(options: {\n\treadonly buildConfig: BuildConfig;\n\treadonly configDir?: string;\n\treadonly fingerprintInput?: unknown;\n\treadonly gondolinVersion?: string;\n\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n}): Promise<{\n\treadonly fingerprint: string;\n\treadonly rootfsInitExtraContent: string;\n}> {\n\tconst resolvedRootfsInitExtra = await resolveRootfsInitExtra({\n\t\tbuildConfig: options.buildConfig,\n\t\t...(options.configDir ? { configDir: options.configDir } : {}),\n\t\t...(options.managedGatewayBoot === undefined\n\t\t\t? {}\n\t\t\t: { managedGatewayBoot: options.managedGatewayBoot }),\n\t});\n\tconst fingerprint = computeBuildFingerprint(options.buildConfig, options.gondolinVersion, {\n\t\tagentVmRootfsInitExtra: resolvedRootfsInitExtra.fingerprintInput,\n\t\t...(options.fingerprintInput === undefined\n\t\t\t? {}\n\t\t\t: { callerFingerprintInput: options.fingerprintInput }),\n\t});\n\n\treturn {\n\t\tfingerprint,\n\t\trootfsInitExtraContent: resolvedRootfsInitExtra.content,\n\t};\n}\n\nexport async function buildImage(\n\toptions: BuildImageOptions,\n\tdependencies: BuildPipelineDependencies = {},\n): Promise<BuildImageResult> {\n\tconst effectiveBuildFingerprint = await computeEffectiveBuildFingerprint({\n\t\tbuildConfig: options.buildConfig,\n\t\t...(options.configDir ? { configDir: options.configDir } : {}),\n\t\t...(options.fingerprintInput === undefined\n\t\t\t? {}\n\t\t\t: { fingerprintInput: options.fingerprintInput }),\n\t\t...(options.managedGatewayBoot === undefined\n\t\t\t? {}\n\t\t\t: { managedGatewayBoot: options.managedGatewayBoot }),\n\t\t...(dependencies.gondolinVersion ? { gondolinVersion: dependencies.gondolinVersion } : {}),\n\t});\n\tconst fingerprint = effectiveBuildFingerprint.fingerprint;\n\tconst imagePath = path.join(options.cacheDir, fingerprint);\n\tconst buildImageForFingerprint = async (): Promise<BuildImageResult> => {\n\t\tif (options.fullReset) {\n\t\t\tawait fs.rm(imagePath, { recursive: true, force: true });\n\t\t}\n\n\t\tif (await hasBuiltImageAssets(imagePath)) {\n\t\t\treturn {\n\t\t\t\tbuilt: false,\n\t\t\t\tfingerprint,\n\t\t\t\timagePath,\n\t\t\t};\n\t\t}\n\n\t\tawait fs.mkdir(imagePath, { recursive: true });\n\t\tconst buildAssetsImplementation = dependencies.buildAssets ?? (await loadBuildAssets());\n\t\tconst effectiveBuildConfig = await prepareBuildConfigWithAgentVmRootfsInitExtra({\n\t\t\tbuildConfig: options.buildConfig,\n\t\t\timagePath,\n\t\t\trootfsInitExtraContent: effectiveBuildFingerprint.rootfsInitExtraContent,\n\t\t});\n\t\tconst gondolinWorkDir = path.join(imagePath, gondolinWorkDirectoryName);\n\t\tawait fs.rm(gondolinWorkDir, { recursive: true, force: true });\n\t\ttry {\n\t\t\tawait withCapturedBuildOutput(options.output, async () => {\n\t\t\t\tawait buildAssetsImplementation(\n\t\t\t\t\teffectiveBuildConfig,\n\t\t\t\t\timagePath,\n\t\t\t\t\toptions.configDir,\n\t\t\t\t\tgondolinWorkDir,\n\t\t\t\t\toptions.output !== undefined,\n\t\t\t\t);\n\t\t\t});\n\t\t} finally {\n\t\t\tawait fs.rm(gondolinWorkDir, { recursive: true, force: true });\n\t\t}\n\n\t\tif (!(await hasBuiltImageAssets(imagePath))) {\n\t\t\tthrow new Error(`Expected Gondolin assets to be written to ${imagePath}.`);\n\t\t}\n\n\t\treturn {\n\t\t\tbuilt: true,\n\t\t\tfingerprint,\n\t\t\timagePath,\n\t\t};\n\t};\n\n\tif (options.output) {\n\t\treturn await buildImageForFingerprint();\n\t}\n\n\tconst inFlightKey = path.resolve(imagePath);\n\tconst existingBuild = inFlightImageBuilds.get(inFlightKey);\n\tif (existingBuild) {\n\t\treturn await existingBuild;\n\t}\n\tconst buildPromise = buildImageForFingerprint();\n\tinFlightImageBuilds.set(inFlightKey, buildPromise);\n\ttry {\n\t\treturn await buildPromise;\n\t} finally {\n\t\tif (inFlightImageBuilds.get(inFlightKey) === buildPromise) {\n\t\t\tinFlightImageBuilds.delete(inFlightKey);\n\t\t}\n\t}\n}\n","import { execFile } from 'node:child_process';\nimport { basename } from 'node:path';\nimport { promisify } from 'node:util';\n\nimport type {\n\tManagedVmExactProcessTerminationCapability,\n\tManagedVmExactProcessTerminationOutcome,\n\tManagedVmHostProcessIdentity,\n} from '@agent-vm/managed-vm';\n\nconst execFileAsync = promisify(execFile);\nconst terminationStageTimeoutMs = 2_000;\nconst processIdentityPollIntervalMs = 100;\nconst darwinProcessCommandNameLimit = 16;\nconst linuxTaskCommandNameLimit = 15;\n\nexport interface GondolinHostProcessIdentity {\n\treadonly command: string;\n\treadonly processState: string;\n\treadonly processStartIdentity: string;\n}\n\nexport interface GondolinProcessTerminationDependencies {\n\treadonly now: () => number;\n\treadonly readProcessIdentity: (\n\t\thostProcessId: number,\n\t) => Promise<GondolinHostProcessIdentity | null>;\n\treadonly sendSignal: (hostProcessId: number, signal: NodeJS.Signals) => void;\n\treadonly sleep: (delayMs: number) => Promise<void>;\n}\n\ntype RecordedProcessObservation = 'absent' | 'exact';\ntype RecordedProcessObservationMode = 'after-signal' | 'before-signal';\n\nfunction processErrorCode(error: unknown): unknown {\n\treturn typeof error === 'object' && error !== null && 'code' in error ? error.code : undefined;\n}\n\nfunction isManagedVmHostCommand(command: string): boolean {\n\treturn /\\b(qemu-system|krun)\\b/u.test(command);\n}\n\nfunction isMatchingDarwinFallbackCommand(options: {\n\treadonly currentCommand: string;\n\treadonly recordedCommand: string;\n}): boolean {\n\tconst fallbackCommandMatch = /^\\(([^()]+)\\)$/u.exec(options.currentCommand);\n\tif (fallbackCommandMatch === null) {\n\t\treturn false;\n\t}\n\tconst recordedExecutable = options.recordedCommand.split(/[ \\t]/u, 1)[0];\n\tif (recordedExecutable === undefined || recordedExecutable.length === 0) {\n\t\treturn false;\n\t}\n\treturn (\n\t\tfallbackCommandMatch[1] === basename(recordedExecutable).slice(0, darwinProcessCommandNameLimit)\n\t);\n}\n\nfunction isMatchingLinuxTaskFallbackCommand(options: {\n\treadonly currentCommand: string;\n\treadonly recordedCommand: string;\n}): boolean {\n\tconst fallbackCommandMatch = /^\\[([^\\r\\n]+)\\]$/u.exec(options.currentCommand);\n\tif (fallbackCommandMatch === null) {\n\t\treturn false;\n\t}\n\tconst recordedExecutable = options.recordedCommand.split(/[ \\t]/u, 1)[0];\n\tif (recordedExecutable === undefined || recordedExecutable.length === 0) {\n\t\treturn false;\n\t}\n\treturn (\n\t\tfallbackCommandMatch[1] === basename(recordedExecutable).slice(0, linuxTaskCommandNameLimit)\n\t);\n}\n\nfunction findProcessCommandBoundary(processDescription: string): number | null {\n\tlet tokenCount = 0;\n\tlet insideToken = false;\n\tfor (let index = 0; index < processDescription.length; index += 1) {\n\t\tconst character = processDescription[index];\n\t\tconst isWhitespace = character === ' ' || character === '\\t';\n\t\tif (!isWhitespace && !insideToken) {\n\t\t\tinsideToken = true;\n\t\t} else if (isWhitespace && insideToken) {\n\t\t\tinsideToken = false;\n\t\t\ttokenCount += 1;\n\t\t\tif (tokenCount === 5) {\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\t}\n\treturn null;\n}\n\nfunction parseProcessIdentityOutput(\n\thostProcessId: number,\n\tprocessDescription: string,\n): GondolinHostProcessIdentity {\n\tconst trimmedDescription = processDescription.trim();\n\tconst processStateBoundary = trimmedDescription.search(/[ \\t]/u);\n\tif (processStateBoundary === -1) {\n\t\tthrow new Error(\n\t\t\t`Unable to confirm host process identity for pid ${String(hostProcessId)} because ps returned malformed identity output.`,\n\t\t);\n\t}\n\tconst processState = trimmedDescription.slice(0, processStateBoundary).trim();\n\tconst startAndCommandDescription = trimmedDescription.slice(processStateBoundary).trim();\n\tconst commandBoundary = findProcessCommandBoundary(startAndCommandDescription);\n\tif (commandBoundary === null) {\n\t\tthrow new Error(\n\t\t\t`Unable to confirm host process identity for pid ${String(hostProcessId)} because ps returned malformed identity output.`,\n\t\t);\n\t}\n\tconst processStartIdentity = startAndCommandDescription.slice(0, commandBoundary).trim();\n\tconst command = startAndCommandDescription.slice(commandBoundary).trim();\n\tif (processState.length === 0 || processStartIdentity.length === 0 || command.length === 0) {\n\t\tthrow new Error(\n\t\t\t`Unable to confirm host process identity for pid ${String(hostProcessId)} because ps omitted the process state, start, or command.`,\n\t\t);\n\t}\n\treturn { command, processStartIdentity, processState };\n}\n\nasync function readGondolinHostProcessIdentity(\n\thostProcessId: number,\n): Promise<GondolinHostProcessIdentity | null> {\n\ttry {\n\t\tconst { stdout } = await execFileAsync('ps', [\n\t\t\t'-p',\n\t\t\tString(hostProcessId),\n\t\t\t'-o',\n\t\t\t'state=',\n\t\t\t'-o',\n\t\t\t'lstart=',\n\t\t\t'-o',\n\t\t\t'command=',\n\t\t]);\n\t\tif (stdout.trim().length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unable to confirm host process identity for pid ${String(hostProcessId)} because ps returned empty output.`,\n\t\t\t);\n\t\t}\n\t\treturn parseProcessIdentityOutput(hostProcessId, stdout);\n\t} catch (error) {\n\t\tif (processErrorCode(error) === 1) {\n\t\t\treturn null;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nfunction sendHostProcessSignal(hostProcessId: number, signal: NodeJS.Signals): void {\n\tprocess.kill(hostProcessId, signal);\n}\n\nasync function sleep(delayMs: number): Promise<void> {\n\tawait new Promise((resolve) => setTimeout(resolve, delayMs));\n}\n\nconst defaultDependencies = {\n\tnow: Date.now,\n\treadProcessIdentity: readGondolinHostProcessIdentity,\n\tsendSignal: sendHostProcessSignal,\n\tsleep,\n} satisfies GondolinProcessTerminationDependencies;\n\nfunction assertTerminationRequest(request: {\n\treadonly contextLabel: string;\n\treadonly identity: ManagedVmHostProcessIdentity;\n}): void {\n\tif (request.contextLabel.trim().length === 0) {\n\t\tthrow new Error('Exact managed VM process termination requires a non-empty context label.');\n\t}\n\tif (\n\t\t!Number.isSafeInteger(request.identity.hostProcessId) ||\n\t\trequest.identity.hostProcessId <= 0\n\t) {\n\t\tthrow new Error('Exact managed VM process termination requires a positive safe host pid.');\n\t}\n\tif (\n\t\trequest.identity.vmId.length === 0 ||\n\t\trequest.identity.processStartIdentity.length === 0 ||\n\t\trequest.identity.command.length === 0\n\t) {\n\t\tthrow new Error('Exact managed VM process termination requires complete recorded identity.');\n\t}\n}\n\nasync function observeRecordedProcess(options: {\n\treadonly action: string;\n\treadonly contextLabel: string;\n\treadonly dependencies: GondolinProcessTerminationDependencies;\n\treadonly identity: ManagedVmHostProcessIdentity;\n\treadonly mode: RecordedProcessObservationMode;\n}): Promise<RecordedProcessObservation> {\n\tconst currentIdentity = await options.dependencies.readProcessIdentity(\n\t\toptions.identity.hostProcessId,\n\t);\n\tif (currentIdentity === null) {\n\t\treturn 'absent';\n\t}\n\tif (currentIdentity.processStartIdentity !== options.identity.processStartIdentity) {\n\t\treturn 'absent';\n\t}\n\tif (currentIdentity.processState.startsWith('Z')) {\n\t\treturn 'absent';\n\t}\n\tif (options.mode === 'after-signal' && currentIdentity.processState.includes('E')) {\n\t\treturn 'exact';\n\t}\n\tif (\n\t\toptions.mode === 'after-signal' &&\n\t\t(currentIdentity.processState.startsWith('U') ||\n\t\t\tcurrentIdentity.processState.startsWith('R')) &&\n\t\t(isMatchingDarwinFallbackCommand({\n\t\t\tcurrentCommand: currentIdentity.command,\n\t\t\trecordedCommand: options.identity.command,\n\t\t}) ||\n\t\t\tisMatchingLinuxTaskFallbackCommand({\n\t\t\t\tcurrentCommand: currentIdentity.command,\n\t\t\t\trecordedCommand: options.identity.command,\n\t\t\t}))\n\t) {\n\t\treturn 'exact';\n\t}\n\tif (currentIdentity.command !== options.identity.command) {\n\t\tthrow new Error(\n\t\t\t`${options.contextLabel} refusing ${options.action} pid ${String(options.identity.hostProcessId)}: same process start identity was observed with state ${JSON.stringify(currentIdentity.processState)} but command changed (recorded ${JSON.stringify(options.identity.command)}, current ${JSON.stringify(currentIdentity.command)}).`,\n\t\t);\n\t}\n\tif (!isManagedVmHostCommand(currentIdentity.command)) {\n\t\tthrow new Error(\n\t\t\t`${options.contextLabel} refusing ${options.action} pid ${String(options.identity.hostProcessId)} because the exact command is not a managed VM process.`,\n\t\t);\n\t}\n\treturn 'exact';\n}\n\nasync function waitForRecordedProcessAbsence(options: {\n\treadonly afterSignal: NodeJS.Signals;\n\treadonly contextLabel: string;\n\treadonly dependencies: GondolinProcessTerminationDependencies;\n\treadonly identity: ManagedVmHostProcessIdentity;\n}): Promise<boolean> {\n\tconst deadline = options.dependencies.now() + terminationStageTimeoutMs;\n\twhile (options.dependencies.now() < deadline) {\n\t\t// oxlint-disable-next-line no-await-in-loop -- exact identity observations must remain ordered\n\t\tconst observation = await observeRecordedProcess({\n\t\t\taction: `continued containment after ${options.afterSignal} for`,\n\t\t\tcontextLabel: options.contextLabel,\n\t\t\tdependencies: options.dependencies,\n\t\t\tidentity: options.identity,\n\t\t\tmode: 'after-signal',\n\t\t});\n\t\tif (observation === 'absent') {\n\t\t\treturn true;\n\t\t}\n\t\t// oxlint-disable-next-line no-await-in-loop -- bounded process identity polling is sequential\n\t\tawait options.dependencies.sleep(processIdentityPollIntervalMs);\n\t}\n\treturn (\n\t\t(await observeRecordedProcess({\n\t\t\taction: `continued containment after ${options.afterSignal} for`,\n\t\t\tcontextLabel: options.contextLabel,\n\t\t\tdependencies: options.dependencies,\n\t\t\tidentity: options.identity,\n\t\t\tmode: 'after-signal',\n\t\t})) === 'absent'\n\t);\n}\n\nfunction signalRecordedProcess(options: {\n\treadonly dependencies: GondolinProcessTerminationDependencies;\n\treadonly hostProcessId: number;\n\treadonly signal: NodeJS.Signals;\n}): void {\n\ttry {\n\t\toptions.dependencies.sendSignal(options.hostProcessId, options.signal);\n\t} catch (error) {\n\t\tif (processErrorCode(error) !== 'ESRCH') {\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\nexport async function terminateExactRecordedManagedVmHostProcess(options: {\n\treadonly contextLabel: string;\n\treadonly dependencies: GondolinProcessTerminationDependencies;\n\treadonly identity: ManagedVmHostProcessIdentity;\n}): Promise<ManagedVmExactProcessTerminationOutcome> {\n\tassertTerminationRequest(options);\n\tconst initialObservation = await observeRecordedProcess({\n\t\taction: 'SIGTERM to',\n\t\tcontextLabel: options.contextLabel,\n\t\tdependencies: options.dependencies,\n\t\tidentity: options.identity,\n\t\tmode: 'before-signal',\n\t});\n\tif (initialObservation === 'absent') {\n\t\treturn { hostProcessId: options.identity.hostProcessId, kind: 'already-absent' };\n\t}\n\n\tsignalRecordedProcess({\n\t\tdependencies: options.dependencies,\n\t\thostProcessId: options.identity.hostProcessId,\n\t\tsignal: 'SIGTERM',\n\t});\n\tif (\n\t\tawait waitForRecordedProcessAbsence({\n\t\t\tafterSignal: 'SIGTERM',\n\t\t\tcontextLabel: options.contextLabel,\n\t\t\tdependencies: options.dependencies,\n\t\t\tidentity: options.identity,\n\t\t})\n\t) {\n\t\treturn { hostProcessId: options.identity.hostProcessId, kind: 'terminated' };\n\t}\n\n\tconst beforeKillObservation = await observeRecordedProcess({\n\t\taction: 'SIGKILL to',\n\t\tcontextLabel: options.contextLabel,\n\t\tdependencies: options.dependencies,\n\t\tidentity: options.identity,\n\t\tmode: 'after-signal',\n\t});\n\tif (beforeKillObservation === 'absent') {\n\t\treturn { hostProcessId: options.identity.hostProcessId, kind: 'terminated' };\n\t}\n\tsignalRecordedProcess({\n\t\tdependencies: options.dependencies,\n\t\thostProcessId: options.identity.hostProcessId,\n\t\tsignal: 'SIGKILL',\n\t});\n\tif (\n\t\tawait waitForRecordedProcessAbsence({\n\t\t\tafterSignal: 'SIGKILL',\n\t\t\tcontextLabel: options.contextLabel,\n\t\t\tdependencies: options.dependencies,\n\t\t\tidentity: options.identity,\n\t\t})\n\t) {\n\t\treturn { hostProcessId: options.identity.hostProcessId, kind: 'terminated' };\n\t}\n\n\tthrow new Error(\n\t\t`Failed to terminate exact recorded managed VM process ${String(options.identity.hostProcessId)} (${options.contextLabel}).`,\n\t);\n}\n\nexport function createGondolinExactProcessTerminationCapability(\n\tdependencies: GondolinProcessTerminationDependencies = defaultDependencies,\n): ManagedVmExactProcessTerminationCapability {\n\treturn {\n\t\tasync terminateRecordedHostProcess(request): Promise<ManagedVmExactProcessTerminationOutcome> {\n\t\t\treturn await terminateExactRecordedManagedVmHostProcess({\n\t\t\t\tcontextLabel: request.contextLabel,\n\t\t\t\tdependencies,\n\t\t\t\tidentity: request.identity,\n\t\t\t});\n\t\t},\n\t};\n}\n","import fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport { z } from 'zod';\n\nconst requireFromHere = createRequire(import.meta.url);\n\nconst gondolinPackageJsonSchema = z.object({\n\tversion: z.string().min(1),\n});\n\nfunction isMissingFileError(error: unknown): boolean {\n\treturn typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';\n}\n\nfunction getErrorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nexport function parseMinimumZigVersion(rawContents: string): string {\n\tconst match = rawContents.match(/\\.minimum_zig_version\\s*=\\s*\"([^\"]*)\"/u);\n\tif (!match) {\n\t\tthrow new Error(\n\t\t\t'minimum_zig_version declaration not found. Expected a line like `.minimum_zig_version = \"0.15.2\"`.',\n\t\t);\n\t}\n\n\tconst version = match[1];\n\tif (!version) {\n\t\tthrow new Error('minimum_zig_version is empty.');\n\t}\n\treturn version;\n}\n\nexport function resolveGondolinPackageJsonPath(): string {\n\treturn requireFromHere.resolve('@earendil-works/gondolin/package.json');\n}\n\nexport async function resolveGondolinPackageSpec(): Promise<string> {\n\tconst packageJsonPath = resolveGondolinPackageJsonPath();\n\tconst parsed: unknown = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));\n\tconst packageJson = gondolinPackageJsonSchema.parse(parsed);\n\treturn `@earendil-works/gondolin@${packageJson.version}`;\n}\n\nexport interface ResolveGondolinMinimumZigVersionOptions {\n\treadonly buildZigZonPath?: string;\n}\n\nasync function resolveDefaultBuildZigZonPath(): Promise<string> {\n\tconst packageJsonPath = resolveGondolinPackageJsonPath();\n\treturn path.join(path.dirname(packageJsonPath), 'dist', 'guest', 'build.zig.zon');\n}\n\nexport async function resolveGondolinMinimumZigVersion(\n\toptions: ResolveGondolinMinimumZigVersionOptions = {},\n): Promise<string> {\n\tconst zonPath = options.buildZigZonPath ?? (await resolveDefaultBuildZigZonPath());\n\tlet rawContents: string;\n\ttry {\n\t\trawContents = await fs.readFile(zonPath, 'utf8');\n\t} catch (error) {\n\t\tif (isMissingFileError(error)) {\n\t\t\tthrow new Error(`Missing Gondolin build.zig.zon at '${zonPath}'.`, { cause: error });\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Failed to read Gondolin build.zig.zon at '${zonPath}': ${getErrorMessage(error)}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n\n\ttry {\n\t\treturn parseMinimumZigVersion(rawContents);\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse Gondolin build.zig.zon at '${zonPath}': ${getErrorMessage(error)}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { VirtualProvider } from '@earendil-works/gondolin';\n\nexport interface PinnedRealFsRoot {\n\treadonly hostPath: string;\n\treadonly realPath: string;\n\treadonly fd: number;\n\treadonly device: number;\n\treadonly inode: number;\n}\n\nexport interface CreatePinnedRealFsProviderOptions {\n\treadonly root: PinnedRealFsRoot;\n\treadonly createRealFsProvider: (hostPath: string) => VirtualProvider;\n}\n\nconst terminallyClosedPinnedRoots = new WeakSet<PinnedRealFsRoot>();\n\nfunction formatRootIdentity(root: PinnedRealFsRoot): string {\n\treturn `${root.device}:${root.inode}`;\n}\n\nfunction openDirectoryNoFollow(candidatePath: string): number {\n\treturn fs.openSync(\n\t\tcandidatePath,\n\t\tfs.constants.O_RDONLY | fs.constants.O_DIRECTORY | fs.constants.O_NOFOLLOW,\n\t);\n}\n\nexport function pinRealFsRoot(hostPath: string): PinnedRealFsRoot {\n\tif (!hostPath || !path.isAbsolute(hostPath)) {\n\t\tthrow new Error(`Pinned RealFS root must be a non-empty absolute path: ${hostPath}`);\n\t}\n\n\tconst resolvedHostPath = path.resolve(hostPath);\n\tconst fd = openDirectoryNoFollow(resolvedHostPath);\n\ttry {\n\t\tconst stats = fs.fstatSync(fd);\n\t\tif (!stats.isDirectory()) {\n\t\t\tthrow new Error(`Pinned RealFS root is not a directory: ${resolvedHostPath}`);\n\t\t}\n\t\tconst realPath = fs.realpathSync(resolvedHostPath);\n\t\tconst realPathStats = fs.statSync(realPath);\n\t\tif (realPathStats.dev !== stats.dev || realPathStats.ino !== stats.ino) {\n\t\t\tthrow new Error(\n\t\t\t\t`Pinned RealFS root changed while opening: ${resolvedHostPath} opened ${stats.dev}:${stats.ino} but resolved to ${realPathStats.dev}:${realPathStats.ino}`,\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tdevice: stats.dev,\n\t\t\tfd,\n\t\t\thostPath: resolvedHostPath,\n\t\t\tinode: stats.ino,\n\t\t\trealPath,\n\t\t};\n\t} catch (error) {\n\t\tfs.closeSync(fd);\n\t\tthrow error;\n\t}\n}\n\nexport function closePinnedRealFsRoot(root: PinnedRealFsRoot): void {\n\tif (terminallyClosedPinnedRoots.has(root)) {\n\t\treturn;\n\t}\n\tfs.closeSync(root.fd);\n\tterminallyClosedPinnedRoots.add(root);\n}\n\nexport function assertPinnedRealFsRoot(root: PinnedRealFsRoot): void {\n\tconst pinnedStats = fs.fstatSync(root.fd);\n\tconst currentStats = fs.statSync(root.realPath);\n\tif (\n\t\tpinnedStats.dev !== root.device ||\n\t\tpinnedStats.ino !== root.inode ||\n\t\tcurrentStats.dev !== root.device ||\n\t\tcurrentStats.ino !== root.inode\n\t) {\n\t\tthrow new Error(\n\t\t\t`Pinned RealFS root changed before mount access: ${root.realPath} expected ${formatRootIdentity(root)} got ${currentStats.dev}:${currentStats.ino}`,\n\t\t);\n\t}\n}\n\ntype ProviderMethod = (...args: unknown[]) => unknown;\n\n/* oxlint-disable typescript-eslint/no-unsafe-type-assertion -- Reflect.get()\n loses the method signature from Gondolin's VirtualProvider union. The proxy\n keeps the same provider object and only wraps callable properties with the\n pinned-root assertion. */\nexport function createPinnedRealFsProvider(\n\toptions: CreatePinnedRealFsProviderOptions,\n): VirtualProvider {\n\tassertPinnedRealFsRoot(options.root);\n\tconst provider = options.createRealFsProvider(options.root.realPath);\n\n\treturn new Proxy(provider, {\n\t\tget(target: VirtualProvider, property: string | symbol, receiver: unknown): unknown {\n\t\t\tconst value = Reflect.get(target, property, receiver) as unknown;\n\t\t\tif (typeof value !== 'function') {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\tassertPinnedRealFsRoot(options.root);\n\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t};\n\t\t},\n\t});\n}\n/* oxlint-enable typescript-eslint/no-unsafe-type-assertion */\n","import path from 'node:path';\n\nimport type { ManagedVmFilteredWorkspacePolicy } from '@agent-vm/managed-vm';\nimport {\n\tERRNO,\n\tVirtualDirent,\n\tcreateVirtualDirStats,\n\ttype ShadowPredicate,\n\ttype ShadowProviderOptions,\n\ttype VirtualProvider,\n} from '@earendil-works/gondolin';\n\nexport interface FilteredWorkspaceProviderDependencies {\n\tcreateMemoryProvider(): VirtualProvider;\n\tcreateReadonlyProvider(provider: VirtualProvider): VirtualProvider;\n\tcreateShadowPathPredicate(paths: readonly string[]): ShadowPredicate;\n\tcreateShadowProvider(provider: VirtualProvider, options: ShadowProviderOptions): VirtualProvider;\n}\n\nexport interface CreateFilteredWorkspaceProviderOptions {\n\treadonly baseProvider: VirtualProvider;\n\treadonly dependencies: FilteredWorkspaceProviderDependencies;\n\treadonly policy: ManagedVmFilteredWorkspacePolicy;\n}\n\ntype ProviderMethod = (...methodArguments: readonly unknown[]) => unknown;\n\nfunction toAbsoluteProviderPath(relativePath: string): string {\n\treturn `/${relativePath}`;\n}\n\nfunction normalizeProviderPath(providerPath: string): string {\n\tconst absolutePath = providerPath.startsWith('/') ? providerPath : `/${providerPath}`;\n\treturn path.posix.normalize(absolutePath);\n}\n\nfunction toRelativeProviderPath(providerPath: string): string {\n\tconst normalizedPath = normalizeProviderPath(providerPath);\n\treturn normalizedPath === '/' ? '' : normalizedPath.slice(1);\n}\n\nfunction isEqualOrDescendant(candidatePath: string, ancestorPath: string): boolean {\n\treturn candidatePath === ancestorPath || candidatePath.startsWith(`${ancestorPath}/`);\n}\n\nfunction pathsOverlap(firstPath: string, secondPath: string): boolean {\n\treturn isEqualOrDescendant(firstPath, secondPath) || isEqualOrDescendant(secondPath, firstPath);\n}\n\nfunction createFilesystemPolicyError(\n\tcode: 'EACCES' | 'ENOENT' | 'EROFS',\n\tsyscall: string,\n\tproviderPath: string,\n): Error & { readonly code: 'EACCES' | 'ENOENT' | 'EROFS'; readonly errno: number } {\n\treturn Object.assign(new Error(`${code}: ${syscall} '${providerPath}'`), {\n\t\tcode,\n\t\terrno: ERRNO[code],\n\t\tpath: providerPath,\n\t\tsyscall,\n\t});\n}\n\nfunction invokeProviderMethod(\n\tprovider: VirtualProvider,\n\tproperty: string | symbol,\n\tmethodArguments: readonly unknown[],\n): unknown {\n\tconst method = Reflect.get(provider, property, provider) as unknown;\n\tif (typeof method !== 'function') {\n\t\treturn method;\n\t}\n\treturn Reflect.apply(method as ProviderMethod, provider, methodArguments);\n}\n\nconst singlePathMutationMethods = new Set([\n\t'appendFile',\n\t'appendFileSync',\n\t'mkdir',\n\t'mkdirSync',\n\t'rmdir',\n\t'rmdirSync',\n\t'symlink',\n\t'symlinkSync',\n\t'truncate',\n\t'truncateSync',\n\t'unlink',\n\t'unlinkSync',\n\t'writeFile',\n\t'writeFileSync',\n]);\n\nfunction mutationPathArgumentIndex(property: string): number {\n\treturn property === 'symlink' || property === 'symlinkSync' ? 1 : 0;\n}\n\nfunction failProviderMutation(property: string, providerPath: string): unknown {\n\treturn failProviderOperation(property, providerPath, 'EROFS');\n}\n\nfunction failProviderOperation(\n\tproperty: string,\n\tproviderPath: string,\n\tcode: 'EACCES' | 'ENOENT' | 'EROFS',\n): unknown {\n\tconst operationError = createFilesystemPolicyError(code, property, providerPath);\n\tif (property.endsWith('Sync')) {\n\t\tthrow operationError;\n\t}\n\treturn Promise.reject(operationError);\n}\n\nfunction createRelativeRootProvider(\n\tprovider: VirtualProvider,\n\tsourceRelativePath: string,\n): VirtualProvider {\n\tconst sourceProviderPath = toAbsoluteProviderPath(sourceRelativePath);\n\tconst translatePath = (providerPath: string): string => {\n\t\tconst suffix = toRelativeProviderPath(providerPath);\n\t\treturn toAbsoluteProviderPath(\n\t\t\tsuffix.length === 0 ? sourceRelativePath : `${sourceRelativePath}/${suffix}`,\n\t\t);\n\t};\n\tconst translateArguments = (\n\t\tproperty: string,\n\t\tmethodArguments: readonly unknown[],\n\t): readonly unknown[] => {\n\t\tconst translatedArguments = [...methodArguments];\n\t\tif (\n\t\t\tproperty === 'rename' ||\n\t\t\tproperty === 'renameSync' ||\n\t\t\tproperty === 'link' ||\n\t\t\tproperty === 'linkSync' ||\n\t\t\tproperty === 'copyFile' ||\n\t\t\tproperty === 'copyFileSync'\n\t\t) {\n\t\t\ttranslatedArguments[0] = translatePath(String(methodArguments[0]));\n\t\t\ttranslatedArguments[1] = translatePath(String(methodArguments[1]));\n\t\t\treturn translatedArguments;\n\t\t}\n\t\ttranslatedArguments[mutationPathArgumentIndex(property)] = translatePath(\n\t\t\tString(methodArguments[mutationPathArgumentIndex(property)]),\n\t\t);\n\t\treturn translatedArguments;\n\t};\n\tconst assertResolvedPathWithinSource = (\n\t\tresolvedPath: string,\n\t\tcanonicalSourcePath: string,\n\t\tproperty: string,\n\t\tproviderPath: string,\n\t): void => {\n\t\tconst resolvedRelativePath = toRelativeProviderPath(resolvedPath);\n\t\tconst canonicalSourceRelativePath = toRelativeProviderPath(canonicalSourcePath);\n\t\tif (!isEqualOrDescendant(resolvedRelativePath, canonicalSourceRelativePath)) {\n\t\t\tthrow createFilesystemPolicyError('ENOENT', property, providerPath);\n\t\t}\n\t};\n\tconst resolveConfinedPath = async (\n\t\tproperty: string,\n\t\tproviderPath: string,\n\t\ttranslatedPath: string,\n\t): Promise<{ readonly canonicalSourcePath: string; readonly resolvedPath: string }> => {\n\t\tif (!provider.realpath) {\n\t\t\tthrow createFilesystemPolicyError('ENOENT', property, providerPath);\n\t\t}\n\t\tconst [canonicalSourcePath, resolvedPath] = await Promise.all([\n\t\t\tprovider.realpath(sourceProviderPath),\n\t\t\tprovider.realpath(translatedPath),\n\t\t]);\n\t\tassertResolvedPathWithinSource(resolvedPath, canonicalSourcePath, property, providerPath);\n\t\treturn { canonicalSourcePath, resolvedPath };\n\t};\n\tconst resolveConfinedPathSync = (\n\t\tproperty: string,\n\t\tproviderPath: string,\n\t\ttranslatedPath: string,\n\t): { readonly canonicalSourcePath: string; readonly resolvedPath: string } => {\n\t\tif (!provider.realpathSync) {\n\t\t\tthrow createFilesystemPolicyError('ENOENT', property, providerPath);\n\t\t}\n\t\tconst canonicalSourcePath = provider.realpathSync(sourceProviderPath);\n\t\tconst resolvedPath = provider.realpathSync(translatedPath);\n\t\tassertResolvedPathWithinSource(resolvedPath, canonicalSourcePath, property, providerPath);\n\t\treturn { canonicalSourcePath, resolvedPath };\n\t};\n\tconst parentProviderPath = (providerPath: string): string => {\n\t\tconst normalizedPath = normalizeProviderPath(providerPath);\n\t\treturn normalizedPath === '/' ? '/' : path.posix.dirname(normalizedPath);\n\t};\n\tconst remapResolvedPath = (resolvedPath: string, canonicalSourcePath: string): string => {\n\t\tconst resolvedRelativePath = toRelativeProviderPath(resolvedPath);\n\t\tconst canonicalSourceRelativePath = toRelativeProviderPath(canonicalSourcePath);\n\t\tif (resolvedRelativePath === canonicalSourceRelativePath) {\n\t\t\treturn '/';\n\t\t}\n\t\treturn toAbsoluteProviderPath(\n\t\t\tcanonicalSourceRelativePath.length === 0\n\t\t\t\t? resolvedRelativePath\n\t\t\t\t: resolvedRelativePath.slice(`${canonicalSourceRelativePath}/`.length),\n\t\t);\n\t};\n\tconst asyncFollowMethods = new Set(['access', 'open', 'readdir', 'readFile', 'stat', 'statfs']);\n\tconst syncFollowMethods = new Set([\n\t\t'accessSync',\n\t\t'openSync',\n\t\t'readdirSync',\n\t\t'readFileSync',\n\t\t'statSync',\n\t\t'watch',\n\t\t'watchAsync',\n\t\t'watchFile',\n\t\t'unwatchFile',\n\t]);\n\n\treturn new Proxy(provider, {\n\t\tget(target: VirtualProvider, property: string | symbol): unknown {\n\t\t\tconst value = Reflect.get(target, property, target) as unknown;\n\t\t\tif (typeof property !== 'string' || typeof value !== 'function') {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\tconst translatedArguments = translateArguments(property, methodArguments);\n\t\t\t\tif (property === 'realpath') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\treturn resolveConfinedPath(property, providerPath, String(translatedArguments[0])).then(\n\t\t\t\t\t\t({ canonicalSourcePath, resolvedPath }) =>\n\t\t\t\t\t\t\tremapResolvedPath(resolvedPath, canonicalSourcePath),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (property === 'realpathSync') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tconst { canonicalSourcePath, resolvedPath } = resolveConfinedPathSync(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tproviderPath,\n\t\t\t\t\t\tString(translatedArguments[0]),\n\t\t\t\t\t);\n\t\t\t\t\treturn remapResolvedPath(resolvedPath, canonicalSourcePath);\n\t\t\t\t}\n\t\t\t\tif (property === 'lstat' || property === 'readlink') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\treturn resolveConfinedPath(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tproviderPath,\n\t\t\t\t\t\ttranslatePath(parentProviderPath(providerPath)),\n\t\t\t\t\t).then(() => Reflect.apply(value as ProviderMethod, target, translatedArguments));\n\t\t\t\t}\n\t\t\t\tif (property === 'lstatSync' || property === 'readlinkSync') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tresolveConfinedPathSync(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tproviderPath,\n\t\t\t\t\t\ttranslatePath(parentProviderPath(providerPath)),\n\t\t\t\t\t);\n\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, translatedArguments);\n\t\t\t\t}\n\t\t\t\tif (property === 'exists') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\treturn resolveConfinedPath(property, providerPath, String(translatedArguments[0]))\n\t\t\t\t\t\t.then(() => Reflect.apply(value as ProviderMethod, target, translatedArguments))\n\t\t\t\t\t\t.catch(() => false);\n\t\t\t\t}\n\t\t\t\tif (property === 'existsSync' || property === 'internalModuleStat') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresolveConfinedPathSync(property, providerPath, String(translatedArguments[0]));\n\t\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, translatedArguments);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\treturn property === 'existsSync' ? false : -2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (asyncFollowMethods.has(property)) {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\treturn resolveConfinedPath(property, providerPath, String(translatedArguments[0])).then(\n\t\t\t\t\t\t() => Reflect.apply(value as ProviderMethod, target, translatedArguments),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (syncFollowMethods.has(property)) {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tresolveConfinedPathSync(property, providerPath, String(translatedArguments[0]));\n\t\t\t\t}\n\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, translatedArguments);\n\t\t\t};\n\t\t},\n\t});\n}\n\nfunction createPositiveWorkspaceProjectionProvider(\n\tprovider: VirtualProvider,\n\tpolicy: Extract<\n\t\tManagedVmFilteredWorkspacePolicy['visibility'],\n\t\t{ readonly kind: 'positive-paths' }\n\t>,\n\tdependencies: FilteredWorkspaceProviderDependencies,\n): VirtualProvider {\n\tconst isVisible = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn (\n\t\t\trelativePath.length === 0 ||\n\t\t\tpolicy.visiblePaths.some((visiblePath) => pathsOverlap(relativePath, visiblePath))\n\t\t);\n\t};\n\tconst isWritable = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn policy.writablePaths.some((writablePath) =>\n\t\t\tisEqualOrDescendant(relativePath, writablePath),\n\t\t);\n\t};\n\tconst projectedProvider = dependencies.createShadowProvider(provider, {\n\t\tshouldShadow: ({ path: providerPath }) => !isVisible(providerPath),\n\t\twriteMode: 'deny',\n\t});\n\tconst readonlyProvider = dependencies.createReadonlyProvider(projectedProvider);\n\n\treturn new Proxy(projectedProvider, {\n\t\tget(target: VirtualProvider, property: string | symbol): unknown {\n\t\t\tconst value = Reflect.get(target, property, target) as unknown;\n\t\t\tif (typeof property !== 'string' || typeof value !== 'function') {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (property === 'open' || property === 'openSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tconst selectedProvider =\n\t\t\t\t\t\tisVisible(providerPath) && !isWritable(providerPath) ? readonlyProvider : target;\n\t\t\t\t\treturn invokeProviderMethod(selectedProvider, property, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (singlePathMutationMethods.has(property)) {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst pathIndex = mutationPathArgumentIndex(property);\n\t\t\t\t\tconst providerPath = String(methodArguments[pathIndex]);\n\t\t\t\t\tconst selectedProvider =\n\t\t\t\t\t\tisVisible(providerPath) && !isWritable(providerPath) ? readonlyProvider : target;\n\t\t\t\t\treturn invokeProviderMethod(selectedProvider, property, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'rename' || property === 'renameSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst affectedPaths = [String(methodArguments[0]), String(methodArguments[1])];\n\t\t\t\t\tconst selectedProvider =\n\t\t\t\t\t\taffectedPaths.every(isVisible) &&\n\t\t\t\t\t\taffectedPaths.some((affectedPath) => !isWritable(affectedPath))\n\t\t\t\t\t\t\t? readonlyProvider\n\t\t\t\t\t\t\t: target;\n\t\t\t\t\treturn invokeProviderMethod(selectedProvider, property, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'copyFile' || property === 'copyFileSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst sourcePath = String(methodArguments[0]);\n\t\t\t\t\tconst destinationPath = String(methodArguments[1]);\n\t\t\t\t\tconst selectedProvider =\n\t\t\t\t\t\tisVisible(sourcePath) && isVisible(destinationPath) && !isWritable(destinationPath)\n\t\t\t\t\t\t\t? readonlyProvider\n\t\t\t\t\t\t\t: target;\n\t\t\t\t\treturn invokeProviderMethod(selectedProvider, property, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\tReflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t},\n\t});\n}\n\nfunction createWorkspaceHardlinkProvider(\n\tprovider: VirtualProvider,\n\tbaseProvider: VirtualProvider,\n\tpolicy: ManagedVmFilteredWorkspacePolicy,\n): VirtualProvider {\n\tconst hidden = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn policy.hiddenPaths.some((hiddenPath) => isEqualOrDescendant(relativePath, hiddenPath));\n\t};\n\tconst temporary = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn policy.temporaryPaths.some((temporaryPath) =>\n\t\t\tisEqualOrDescendant(relativePath, temporaryPath),\n\t\t);\n\t};\n\tconst visible = (providerPath: string): boolean => {\n\t\tif (policy.visibility.kind === 'whole-root-writable') {\n\t\t\treturn true;\n\t\t}\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn (\n\t\t\trelativePath.length === 0 ||\n\t\t\tpolicy.visibility.visiblePaths.some((visiblePath) => pathsOverlap(relativePath, visiblePath))\n\t\t);\n\t};\n\tconst writable = (providerPath: string): boolean => {\n\t\tif (temporary(providerPath)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (policy.visibility.kind === 'whole-root-writable') {\n\t\t\treturn true;\n\t\t}\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn policy.visibility.writablePaths.some((writablePath) =>\n\t\t\tisEqualOrDescendant(relativePath, writablePath),\n\t\t);\n\t};\n\n\treturn new Proxy(provider, {\n\t\tget(target: VirtualProvider, property: string | symbol): unknown {\n\t\t\tconst value = Reflect.get(target, property, target) as unknown;\n\t\t\tif (property !== 'link' && property !== 'linkSync') {\n\t\t\t\treturn typeof value === 'function'\n\t\t\t\t\t? (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\t\t\t\tReflect.apply(value as ProviderMethod, target, methodArguments)\n\t\t\t\t\t: value;\n\t\t\t}\n\t\t\tconst underlyingLinkMethod = Reflect.get(baseProvider, property, baseProvider) as unknown;\n\t\t\tif (typeof underlyingLinkMethod !== 'function') {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\tconst sourcePath = String(methodArguments[0]);\n\t\t\t\tconst destinationPath = String(methodArguments[1]);\n\t\t\t\tif (hidden(sourcePath) || !visible(sourcePath)) {\n\t\t\t\t\treturn failProviderOperation(property, sourcePath, 'ENOENT');\n\t\t\t\t}\n\t\t\t\tif (hidden(destinationPath) || !visible(destinationPath)) {\n\t\t\t\t\treturn failProviderOperation(property, destinationPath, 'EACCES');\n\t\t\t\t}\n\t\t\t\tif (!writable(sourcePath)) {\n\t\t\t\t\treturn failProviderOperation(property, sourcePath, 'EROFS');\n\t\t\t\t}\n\t\t\t\tif (!writable(destinationPath)) {\n\t\t\t\t\treturn failProviderOperation(property, destinationPath, 'EROFS');\n\t\t\t\t}\n\t\t\t\tif (property === 'link') {\n\t\t\t\t\tif (!provider.realpath) {\n\t\t\t\t\t\treturn failProviderOperation(property, sourcePath, 'ENOENT');\n\t\t\t\t\t}\n\t\t\t\t\treturn provider\n\t\t\t\t\t\t.realpath(sourcePath)\n\t\t\t\t\t\t.then(() =>\n\t\t\t\t\t\t\tReflect.apply(underlyingLinkMethod as ProviderMethod, baseProvider, methodArguments),\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!provider.realpathSync) {\n\t\t\t\t\treturn failProviderOperation(property, sourcePath, 'ENOENT');\n\t\t\t\t}\n\t\t\t\tprovider.realpathSync(sourcePath);\n\t\t\t\treturn Reflect.apply(underlyingLinkMethod as ProviderMethod, baseProvider, methodArguments);\n\t\t\t};\n\t\t},\n\t});\n}\n\ninterface ReadonlyInputProvider {\n\treadonly destinationRelativePath: string;\n\treadonly provider: VirtualProvider;\n}\n\nfunction directReadonlyDestinationChildren(\n\tproviderPath: string,\n\treadonlyInputs: readonly ReadonlyInputProvider[],\n): readonly string[] {\n\tconst relativePath = toRelativeProviderPath(providerPath);\n\tconst prefix = relativePath.length === 0 ? '' : `${relativePath}/`;\n\tconst children = new Set<string>();\n\tfor (const readonlyInput of readonlyInputs) {\n\t\tif (!readonlyInput.destinationRelativePath.startsWith(prefix)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst remainingPath = readonlyInput.destinationRelativePath.slice(prefix.length);\n\t\tconst childName = remainingPath.split('/')[0];\n\t\tif (childName) {\n\t\t\tchildren.add(childName);\n\t\t}\n\t}\n\treturn [...children].toSorted();\n}\n\nfunction entryName(entry: string | { readonly name: string }): string {\n\treturn typeof entry === 'string' ? entry : entry.name;\n}\n\nfunction mergeDirectoryEntries(\n\tentries: readonly (string | { readonly name: string })[],\n\tvirtualChildren: readonly string[],\n\twithFileTypes: boolean,\n): readonly (string | { readonly name: string })[] {\n\tconst presentNames = new Set(entries.map(entryName));\n\tconst missingChildren = virtualChildren.filter((childName) => !presentNames.has(childName));\n\treturn [\n\t\t...entries,\n\t\t...missingChildren.map((childName) =>\n\t\t\twithFileTypes ? new VirtualDirent(childName) : childName,\n\t\t),\n\t];\n}\n\nfunction isNoEntryError(error: unknown): boolean {\n\treturn (\n\t\ttypeof error === 'object' &&\n\t\terror !== null &&\n\t\t(('code' in error && (error.code === 'ENOENT' || error.code === 'ERRNO_2')) ||\n\t\t\t('errno' in error && (error.errno === ERRNO.ENOENT || error.errno === -ERRNO.ENOENT)))\n\t);\n}\n\nfunction createNestedReadonlyWorkspaceProvider(\n\tprovider: VirtualProvider,\n\tsourceProvider: VirtualProvider,\n\tpolicy: ManagedVmFilteredWorkspacePolicy,\n\tdependencies: FilteredWorkspaceProviderDependencies,\n): VirtualProvider {\n\tconst readonlyInputs: ReadonlyInputProvider[] = [];\n\tfor (const readonlyInput of policy.readonlyInputs) {\n\t\tif (\n\t\t\tpolicy.hiddenPaths.some((hiddenPath) =>\n\t\t\t\tisEqualOrDescendant(readonlyInput.destinationRelativePath, hiddenPath),\n\t\t\t)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tlet inputProvider = createRelativeRootProvider(\n\t\t\tsourceProvider,\n\t\t\treadonlyInput.sourceRelativePath,\n\t\t);\n\t\tconst nestedHiddenPaths = policy.hiddenPaths.flatMap((hiddenPath) => {\n\t\t\tconst destinationPrefix = `${readonlyInput.destinationRelativePath}/`;\n\t\t\treturn hiddenPath.startsWith(destinationPrefix)\n\t\t\t\t? [toAbsoluteProviderPath(hiddenPath.slice(destinationPrefix.length))]\n\t\t\t\t: [];\n\t\t});\n\t\tif (nestedHiddenPaths.length > 0) {\n\t\t\tinputProvider = dependencies.createShadowProvider(inputProvider, {\n\t\t\t\tshouldShadow: dependencies.createShadowPathPredicate(nestedHiddenPaths),\n\t\t\t\twriteMode: 'deny',\n\t\t\t});\n\t\t}\n\t\treadonlyInputs.push({\n\t\t\tdestinationRelativePath: readonlyInput.destinationRelativePath,\n\t\t\tprovider: dependencies.createReadonlyProvider(inputProvider),\n\t\t});\n\t}\n\n\tif (readonlyInputs.length === 0) {\n\t\treturn provider;\n\t}\n\n\tconst findInput = (providerPath: string): ReadonlyInputProvider | undefined => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn readonlyInputs.find((readonlyInput) =>\n\t\t\tisEqualOrDescendant(relativePath, readonlyInput.destinationRelativePath),\n\t\t);\n\t};\n\tconst mapInputPath = (providerPath: string, readonlyInput: ReadonlyInputProvider): string => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\tconst suffix = relativePath.slice(readonlyInput.destinationRelativePath.length);\n\t\treturn suffix.length === 0 ? '/' : suffix;\n\t};\n\tconst conflictsWithReadonlyInput = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn readonlyInputs.some((readonlyInput) =>\n\t\t\tpathsOverlap(relativePath, readonlyInput.destinationRelativePath),\n\t\t);\n\t};\n\tconst isHidden = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn policy.hiddenPaths.some((hiddenPath) => isEqualOrDescendant(relativePath, hiddenPath));\n\t};\n\n\treturn new Proxy(provider, {\n\t\tget(target: VirtualProvider, property: string | symbol): unknown {\n\t\t\tconst value = Reflect.get(target, property, target) as unknown;\n\t\t\tif (typeof property !== 'string' || typeof value !== 'function') {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (property === 'readdir' || property === 'readdirSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tconst readdirOptions = methodArguments[1];\n\t\t\t\t\tconst withFileTypes =\n\t\t\t\t\t\ttypeof readdirOptions === 'object' &&\n\t\t\t\t\t\treaddirOptions !== null &&\n\t\t\t\t\t\t'withFileTypes' in readdirOptions &&\n\t\t\t\t\t\treaddirOptions.withFileTypes === true;\n\t\t\t\t\tconst readonlyInput = findInput(providerPath);\n\t\t\t\t\tif (readonlyInput && !isHidden(providerPath)) {\n\t\t\t\t\t\treturn invokeProviderMethod(readonlyInput.provider, property, [\n\t\t\t\t\t\t\tmapInputPath(providerPath, readonlyInput),\n\t\t\t\t\t\t\t...methodArguments.slice(1),\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t\tconst virtualChildren = directReadonlyDestinationChildren(providerPath, readonlyInputs);\n\t\t\t\t\tif (virtualChildren.length === 0) {\n\t\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t\t}\n\t\t\t\t\tif (property === 'readdir') {\n\t\t\t\t\t\treturn Promise.resolve(Reflect.apply(value as ProviderMethod, target, methodArguments))\n\t\t\t\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\t\t\t\tif (isNoEntryError(error)) {\n\t\t\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.then((entries) =>\n\t\t\t\t\t\t\t\tmergeDirectoryEntries(\n\t\t\t\t\t\t\t\t\tentries as readonly (string | { readonly name: string })[],\n\t\t\t\t\t\t\t\t\tvirtualChildren,\n\t\t\t\t\t\t\t\t\twithFileTypes,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn mergeDirectoryEntries(\n\t\t\t\t\t\t\tReflect.apply(value as ProviderMethod, target, methodArguments) as readonly (\n\t\t\t\t\t\t\t\t| string\n\t\t\t\t\t\t\t\t| { readonly name: string }\n\t\t\t\t\t\t\t)[],\n\t\t\t\t\t\t\tvirtualChildren,\n\t\t\t\t\t\t\twithFileTypes,\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (isNoEntryError(error)) {\n\t\t\t\t\t\t\treturn virtualChildren;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'stat' ||\n\t\t\t\tproperty === 'statSync' ||\n\t\t\t\tproperty === 'lstat' ||\n\t\t\t\tproperty === 'lstatSync'\n\t\t\t) {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tconst readonlyInput = findInput(providerPath);\n\t\t\t\t\tif (readonlyInput && !isHidden(providerPath)) {\n\t\t\t\t\t\treturn invokeProviderMethod(readonlyInput.provider, property, [\n\t\t\t\t\t\t\tmapInputPath(providerPath, readonlyInput),\n\t\t\t\t\t\t\t...methodArguments.slice(1),\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t\tconst virtualChildren = directReadonlyDestinationChildren(providerPath, readonlyInputs);\n\t\t\t\t\tif (virtualChildren.length === 0) {\n\t\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t\t}\n\t\t\t\t\tif (property === 'stat' || property === 'lstat') {\n\t\t\t\t\t\treturn Promise.resolve(\n\t\t\t\t\t\t\tReflect.apply(value as ProviderMethod, target, methodArguments),\n\t\t\t\t\t\t).catch((error: unknown) => {\n\t\t\t\t\t\t\tif (isNoEntryError(error)) {\n\t\t\t\t\t\t\t\treturn createVirtualDirStats();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (isNoEntryError(error)) {\n\t\t\t\t\t\t\treturn createVirtualDirStats();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'open' || property === 'openSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tconst readonlyInput = findInput(providerPath);\n\t\t\t\t\treturn readonlyInput && !isHidden(providerPath)\n\t\t\t\t\t\t? invokeProviderMethod(readonlyInput.provider, property, [\n\t\t\t\t\t\t\t\tmapInputPath(providerPath, readonlyInput),\n\t\t\t\t\t\t\t\t...methodArguments.slice(1),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (singlePathMutationMethods.has(property)) {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst providerPath = String(methodArguments[mutationPathArgumentIndex(property)]);\n\t\t\t\t\tif (!isHidden(providerPath) && conflictsWithReadonlyInput(providerPath)) {\n\t\t\t\t\t\treturn failProviderMutation(property, providerPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'rename' ||\n\t\t\t\tproperty === 'renameSync' ||\n\t\t\t\tproperty === 'link' ||\n\t\t\t\tproperty === 'linkSync'\n\t\t\t) {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst affectedPaths = [String(methodArguments[0]), String(methodArguments[1])];\n\t\t\t\t\tconst conflictingPath = affectedPaths.find(\n\t\t\t\t\t\t(affectedPath) => !isHidden(affectedPath) && conflictsWithReadonlyInput(affectedPath),\n\t\t\t\t\t);\n\t\t\t\t\tif (conflictingPath) {\n\t\t\t\t\t\treturn failProviderMutation(property, conflictingPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'copyFile' || property === 'copyFileSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst sourcePath = String(methodArguments[0]);\n\t\t\t\t\tconst destinationPath = String(methodArguments[1]);\n\t\t\t\t\tif (!isHidden(destinationPath) && conflictsWithReadonlyInput(destinationPath)) {\n\t\t\t\t\t\treturn failProviderMutation(property, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t\tconst sourceInput = findInput(sourcePath);\n\t\t\t\t\tif (!sourceInput || isHidden(sourcePath)) {\n\t\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t\t}\n\t\t\t\t\tconst mappedSourcePath = mapInputPath(sourcePath, sourceInput);\n\t\t\t\t\tif (property === 'copyFile') {\n\t\t\t\t\t\treturn Promise.resolve(\n\t\t\t\t\t\t\tinvokeProviderMethod(sourceInput.provider, 'readFile', [mappedSourcePath]),\n\t\t\t\t\t\t).then((contents) =>\n\t\t\t\t\t\t\tinvokeProviderMethod(target, 'writeFile', [destinationPath, contents]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst contents = invokeProviderMethod(sourceInput.provider, 'readFileSync', [\n\t\t\t\t\t\tmappedSourcePath,\n\t\t\t\t\t]);\n\t\t\t\t\treturn invokeProviderMethod(target, 'writeFileSync', [destinationPath, contents]);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\tconst readonlyInput = findInput(providerPath);\n\t\t\t\tconst result =\n\t\t\t\t\treadonlyInput && !isHidden(providerPath)\n\t\t\t\t\t\t? invokeProviderMethod(readonlyInput.provider, property, [\n\t\t\t\t\t\t\t\tmapInputPath(providerPath, readonlyInput),\n\t\t\t\t\t\t\t\t...methodArguments.slice(1),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\tif (!readonlyInput || isHidden(providerPath)) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\tif (property === 'realpath') {\n\t\t\t\t\treturn Promise.resolve(result).then((resolvedPath) => {\n\t\t\t\t\t\tconst resolvedRelativePath = toRelativeProviderPath(String(resolvedPath));\n\t\t\t\t\t\treturn toAbsoluteProviderPath(\n\t\t\t\t\t\t\tresolvedRelativePath.length === 0\n\t\t\t\t\t\t\t\t? readonlyInput.destinationRelativePath\n\t\t\t\t\t\t\t\t: `${readonlyInput.destinationRelativePath}/${resolvedRelativePath}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (property === 'realpathSync') {\n\t\t\t\t\tconst resolvedRelativePath = toRelativeProviderPath(String(result));\n\t\t\t\t\treturn toAbsoluteProviderPath(\n\t\t\t\t\t\tresolvedRelativePath.length === 0\n\t\t\t\t\t\t\t? readonlyInput.destinationRelativePath\n\t\t\t\t\t\t\t: `${readonlyInput.destinationRelativePath}/${resolvedRelativePath}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t};\n\t\t},\n\t});\n}\n\nexport function createFilteredWorkspaceProvider(\n\toptions: CreateFilteredWorkspaceProviderOptions,\n): VirtualProvider {\n\tlet workspaceProvider = options.baseProvider;\n\tif (options.policy.visibility.kind === 'positive-paths') {\n\t\tworkspaceProvider = createPositiveWorkspaceProjectionProvider(\n\t\t\tworkspaceProvider,\n\t\t\toptions.policy.visibility,\n\t\t\toptions.dependencies,\n\t\t);\n\t}\n\n\tif (options.policy.hiddenPaths.length > 0) {\n\t\tworkspaceProvider = options.dependencies.createShadowProvider(workspaceProvider, {\n\t\t\tshouldShadow: options.dependencies.createShadowPathPredicate(\n\t\t\t\toptions.policy.hiddenPaths.map(toAbsoluteProviderPath),\n\t\t\t),\n\t\t\twriteMode: 'deny',\n\t\t});\n\t}\n\n\tif (options.policy.temporaryPaths.length > 0) {\n\t\tconst hiddenPredicate = options.dependencies.createShadowPathPredicate(\n\t\t\toptions.policy.hiddenPaths.map(toAbsoluteProviderPath),\n\t\t);\n\t\tconst temporaryPredicate = options.dependencies.createShadowPathPredicate(\n\t\t\toptions.policy.temporaryPaths.map(toAbsoluteProviderPath),\n\t\t);\n\t\tworkspaceProvider = options.dependencies.createShadowProvider(workspaceProvider, {\n\t\t\tshouldShadow: (context) => !hiddenPredicate(context) && temporaryPredicate(context),\n\t\t\ttmpfs: options.dependencies.createMemoryProvider(),\n\t\t\twriteMode: 'tmpfs',\n\t\t});\n\t}\n\tworkspaceProvider = createWorkspaceHardlinkProvider(\n\t\tworkspaceProvider,\n\t\toptions.baseProvider,\n\t\toptions.policy,\n\t);\n\n\treturn createNestedReadonlyWorkspaceProvider(\n\t\tworkspaceProvider,\n\t\toptions.baseProvider,\n\t\toptions.policy,\n\t\toptions.dependencies,\n\t);\n}\n","import * as dns from 'node:dns';\nimport * as net from 'node:net';\n\nexport interface HostNetworkDefaultsResult {\n\treadonly autoSelectFamily: false | 'unavailable';\n\treadonly dnsResultOrder: 'ipv4first' | 'unavailable';\n}\n\nexport interface HostNetworkDefaultsDependencies {\n\treadonly setDefaultAutoSelectFamily?: ((value: boolean) => void) | undefined;\n\treadonly setDefaultResultOrder?: ((order: 'ipv4first') => void) | undefined;\n}\n\n/**\n * Gondolin raw tcpHosts passthrough sockets are opened by the host-side Node\n * process, not by guest Node processes. VM NODE_OPTIONS cannot affect those\n * sockets, so host processes that create Gondolin VMs also force deterministic\n * IPv4-first behavior before network state is constructed.\n */\nexport function configureHostNetworkDefaults(\n\tdependencies: HostNetworkDefaultsDependencies = {},\n): HostNetworkDefaultsResult {\n\tconst setDefaultResultOrder =\n\t\t'setDefaultResultOrder' in dependencies\n\t\t\t? dependencies.setDefaultResultOrder\n\t\t\t: dns.setDefaultResultOrder;\n\tconst setDefaultAutoSelectFamily =\n\t\t'setDefaultAutoSelectFamily' in dependencies\n\t\t\t? dependencies.setDefaultAutoSelectFamily\n\t\t\t: net.setDefaultAutoSelectFamily;\n\n\tlet dnsResultOrder: HostNetworkDefaultsResult['dnsResultOrder'] = 'unavailable';\n\tif (typeof setDefaultResultOrder === 'function') {\n\t\tsetDefaultResultOrder('ipv4first');\n\t\tdnsResultOrder = 'ipv4first';\n\t}\n\n\tlet autoSelectFamily: HostNetworkDefaultsResult['autoSelectFamily'] = 'unavailable';\n\tif (typeof setDefaultAutoSelectFamily === 'function') {\n\t\tsetDefaultAutoSelectFamily(false);\n\t\tautoSelectFamily = false;\n\t}\n\n\treturn {\n\t\tautoSelectFamily,\n\t\tdnsResultOrder,\n\t};\n}\n","import type { Stats } from 'node:fs';\nimport net from 'node:net';\n\nimport {\n\tvalidateManagedVmFinalizeMemoryMountRequest,\n\ttype ManagedVmFilteredWorkspacePolicy,\n\ttype ManagedVmFinalizeMemoryMountRequest,\n} from '@agent-vm/managed-vm';\nimport {\n\tMemoryProvider,\n\tReadonlyProvider,\n\tRealFSProvider,\n\tShadowProvider,\n\tVM,\n\tcreateHttpHooks,\n\tcreateShadowPathPredicate,\n\ttype CreateHttpHooksResult,\n\ttype EnableIngressOptions,\n\ttype EnableSshOptions,\n\ttype ExecOptions as GondolinExecOptions,\n\ttype ExecProcess as GondolinExecProcess,\n\ttype ExecResult as GondolinExecResult,\n\ttype HttpHooks,\n\ttype IngressRoute as GondolinIngressRoute,\n\ttype ShadowPredicate,\n\ttype ShadowProviderOptions,\n\ttype SshOptions,\n\ttype VMOptions,\n\ttype VmFs as GondolinVmFs,\n\ttype VirtualFileHandle,\n\ttype VirtualProvider,\n\tERRNO,\n\tgetInfoFromSshExecRequest,\n\tisWriteFlag,\n} from '@earendil-works/gondolin';\n\nimport { createFilteredWorkspaceProvider } from './filtered-workspace-provider.js';\nimport {\n\tconfigureHostNetworkDefaults,\n\ttype HostNetworkDefaultsResult,\n} from './host-network-defaults.js';\nimport {\n\tclosePinnedRealFsRoot,\n\tcreatePinnedRealFsProvider,\n\ttype PinnedRealFsRoot,\n} from './pinned-realfs.js';\n\nexport const SYNTHETIC_DNS_IPV4_BENCHMARK = '198.18.0.1';\nexport const SYNTHETIC_DNS_IPV6_IPV4_MAPPED_BENCHMARK = '::ffff:198.18.0.1';\nexport const MANAGED_VM_DEFAULT_INGRESS_MAX_BUFFERED_RESPONSE_BODY_BYTES = 512 * 1024 * 1024;\nexport const MANAGED_VM_DEFAULT_INGRESS_UPSTREAM_HEADER_TIMEOUT_MS = 120_000;\nexport const MANAGED_VM_DEFAULT_INGRESS_UPSTREAM_RESPONSE_TIMEOUT_MS = 120_000;\n\nexport const MANAGED_VM_DEFAULT_INGRESS_OPTIONS = {\n\tallowWebSockets: true,\n\tbufferResponseBody: false,\n\tmaxBufferedResponseBodyBytes: MANAGED_VM_DEFAULT_INGRESS_MAX_BUFFERED_RESPONSE_BODY_BYTES,\n\tupstreamHeaderTimeoutMs: MANAGED_VM_DEFAULT_INGRESS_UPSTREAM_HEADER_TIMEOUT_MS,\n\tupstreamResponseTimeoutMs: MANAGED_VM_DEFAULT_INGRESS_UPSTREAM_RESPONSE_TIMEOUT_MS,\n} satisfies EnableIngressOptions;\n\nexport type ManagedExecInput = string | readonly string[];\nexport type ManagedExecOptions = GondolinExecOptions;\nexport type ManagedExecProcess = GondolinExecProcess;\nexport type ManagedExecResult = GondolinExecResult;\nexport type ManagedVmFs = GondolinVmFs;\nexport type ManagedSshEgressOptions = SshOptions;\n\nexport type IngressRoute = GondolinIngressRoute;\n\ntype VirtualProviderMethod = (...methodArguments: readonly unknown[]) => unknown;\n\nfunction createGuestRootOwnedStats(stats: Stats): Stats {\n\treturn new Proxy(stats, {\n\t\tget(target: Stats, property: string | symbol, receiver: unknown): unknown {\n\t\t\tif (property === 'gid' || property === 'uid') {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn Reflect.get(target, property, receiver);\n\t\t},\n\t});\n}\n\nfunction createGuestRootOwnedFileHandle(handle: VirtualFileHandle): VirtualFileHandle {\n\treturn new Proxy(handle, {\n\t\tget(target: VirtualFileHandle, property: string | symbol, receiver: unknown): unknown {\n\t\t\tconst value = Reflect.get(target, property, receiver) as unknown;\n\t\t\tif (property === 'stat') {\n\t\t\t\treturn async (options?: object): Promise<Stats> =>\n\t\t\t\t\tcreateGuestRootOwnedStats(await target.stat(options));\n\t\t\t}\n\t\t\tif (property === 'statSync') {\n\t\t\t\treturn (options?: object): Stats => createGuestRootOwnedStats(target.statSync(options));\n\t\t\t}\n\t\t\treturn typeof value === 'function'\n\t\t\t\t? (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\t\t\tReflect.apply(value as VirtualProviderMethod, target, methodArguments)\n\t\t\t\t: value;\n\t\t},\n\t});\n}\n\nfunction createGuestRootOwnedProvider(provider: VirtualProvider): VirtualProvider {\n\treturn new Proxy(provider, {\n\t\tget(target: VirtualProvider, property: string | symbol, receiver: unknown): unknown {\n\t\t\tconst value = Reflect.get(target, property, receiver) as unknown;\n\t\t\tif (property === 'open') {\n\t\t\t\treturn async (\n\t\t\t\t\tentryPath: string,\n\t\t\t\t\tflags: string,\n\t\t\t\t\tmode?: number,\n\t\t\t\t): Promise<VirtualFileHandle> =>\n\t\t\t\t\tcreateGuestRootOwnedFileHandle(await target.open(entryPath, flags, mode));\n\t\t\t}\n\t\t\tif (property === 'openSync') {\n\t\t\t\treturn (entryPath: string, flags: string, mode?: number): VirtualFileHandle =>\n\t\t\t\t\tcreateGuestRootOwnedFileHandle(target.openSync(entryPath, flags, mode));\n\t\t\t}\n\t\t\tif (property === 'stat') {\n\t\t\t\treturn async (entryPath: string, options?: object): Promise<Stats> =>\n\t\t\t\t\tcreateGuestRootOwnedStats(await target.stat(entryPath, options));\n\t\t\t}\n\t\t\tif (property === 'statSync') {\n\t\t\t\treturn (entryPath: string, options?: object): Stats =>\n\t\t\t\t\tcreateGuestRootOwnedStats(target.statSync(entryPath, options));\n\t\t\t}\n\t\t\tif (property === 'lstat') {\n\t\t\t\treturn async (entryPath: string, options?: object): Promise<Stats> =>\n\t\t\t\t\tcreateGuestRootOwnedStats(await target.lstat(entryPath, options));\n\t\t\t}\n\t\t\tif (property === 'lstatSync') {\n\t\t\t\treturn (entryPath: string, options?: object): Stats =>\n\t\t\t\t\tcreateGuestRootOwnedStats(target.lstatSync(entryPath, options));\n\t\t\t}\n\t\t\treturn typeof value === 'function'\n\t\t\t\t? (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\t\t\tReflect.apply(value as VirtualProviderMethod, target, methodArguments)\n\t\t\t\t: value;\n\t\t},\n\t});\n}\n\nfunction createReadonlyMutationError(\n\tsyscall: string,\n\tfilePath: string | undefined,\n): Error & {\n\treadonly code: 'EROFS';\n\treadonly errno: number;\n\treadonly path?: string;\n\treadonly syscall: string;\n} {\n\tconst pathSuffix = filePath === undefined ? '' : ` '${filePath}'`;\n\treturn Object.assign(new Error(`EROFS: ${syscall}${pathSuffix}`), {\n\t\tcode: 'EROFS' as const,\n\t\terrno: ERRNO.EROFS,\n\t\t...(filePath === undefined ? {} : { path: filePath }),\n\t\tsyscall,\n\t});\n}\n\nfunction createHardenedReadonlyFileHandle(handle: VirtualFileHandle): VirtualFileHandle {\n\treturn new Proxy(handle, {\n\t\tget(target: VirtualFileHandle, property: string | symbol, receiver: unknown): unknown {\n\t\t\tconst value = Reflect.get(target, property, receiver) as unknown;\n\t\t\tif (property === 'write' || property === 'writeFile' || property === 'truncate') {\n\t\t\t\treturn async (): Promise<never> => {\n\t\t\t\t\tthrow createReadonlyMutationError(String(property), target.path);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'writeSync' || property === 'writeFileSync' || property === 'truncateSync') {\n\t\t\t\treturn (): never => {\n\t\t\t\t\tthrow createReadonlyMutationError(String(property), target.path);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn typeof value === 'function'\n\t\t\t\t? (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\t\t\tReflect.apply(value as VirtualProviderMethod, target, methodArguments)\n\t\t\t\t: value;\n\t\t},\n\t});\n}\n\nexport function createHardenedReadonlyProvider(provider: VirtualProvider): VirtualProvider {\n\tconst readonlyProvider = new ReadonlyProvider(provider);\n\treturn new Proxy(readonlyProvider, {\n\t\tget(target: VirtualProvider, property: string | symbol, receiver: unknown): unknown {\n\t\t\tconst value = Reflect.get(target, property, receiver) as unknown;\n\t\t\tif (property === 'open') {\n\t\t\t\treturn async (\n\t\t\t\t\tentryPath: string,\n\t\t\t\t\tflags: string,\n\t\t\t\t\tmode?: number,\n\t\t\t\t): Promise<VirtualFileHandle> => {\n\t\t\t\t\tif (isWriteFlag(flags)) {\n\t\t\t\t\t\tthrow createReadonlyMutationError('open', entryPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn createHardenedReadonlyFileHandle(await target.open(entryPath, flags, mode));\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'openSync') {\n\t\t\t\treturn (entryPath: string, flags: string, mode?: number): VirtualFileHandle => {\n\t\t\t\t\tif (isWriteFlag(flags)) {\n\t\t\t\t\t\tthrow createReadonlyMutationError('openSync', entryPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn createHardenedReadonlyFileHandle(target.openSync(entryPath, flags, mode));\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'mkdir' ||\n\t\t\t\tproperty === 'rmdir' ||\n\t\t\t\tproperty === 'unlink' ||\n\t\t\t\tproperty === 'rename' ||\n\t\t\t\tproperty === 'link' ||\n\t\t\t\tproperty === 'writeFile' ||\n\t\t\t\tproperty === 'appendFile' ||\n\t\t\t\tproperty === 'copyFile' ||\n\t\t\t\tproperty === 'symlink'\n\t\t\t) {\n\t\t\t\treturn async (entryPath: string): Promise<never> => {\n\t\t\t\t\tthrow createReadonlyMutationError(String(property), entryPath);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'mkdirSync' ||\n\t\t\t\tproperty === 'rmdirSync' ||\n\t\t\t\tproperty === 'unlinkSync' ||\n\t\t\t\tproperty === 'renameSync' ||\n\t\t\t\tproperty === 'linkSync' ||\n\t\t\t\tproperty === 'writeFileSync' ||\n\t\t\t\tproperty === 'appendFileSync' ||\n\t\t\t\tproperty === 'copyFileSync' ||\n\t\t\t\tproperty === 'symlinkSync'\n\t\t\t) {\n\t\t\t\treturn (entryPath: string): never => {\n\t\t\t\t\tthrow createReadonlyMutationError(String(property), entryPath);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn typeof value === 'function'\n\t\t\t\t? (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\t\t\tReflect.apply(value as VirtualProviderMethod, target, methodArguments)\n\t\t\t\t: value;\n\t\t},\n\t});\n}\n\nexport interface GitReadOnlySshEgressOptions {\n\treadonly allowedHosts: readonly string[];\n\treadonly allowedRepos?: readonly string[];\n\treadonly agent?: string;\n\treadonly knownHostsFile?: SshOptions['knownHostsFile'];\n}\n\nexport interface SshAccess {\n\tclose(): Promise<void>;\n\treadonly host: string;\n\treadonly command?: string;\n\treadonly identityFile?: string;\n\treadonly port: number;\n\treadonly serverHostKey: SshServerHostKey;\n\treadonly user?: string;\n}\n\nexport interface ManagedVmSshAccess {\n\tclose(): Promise<void>;\n\treadonly command: string;\n\treadonly host: string;\n\treadonly identityFile: string;\n\treadonly port: number;\n\treadonly user: string;\n}\n\nexport interface SshServerHostKey {\n\treadonly algorithm: 'ssh-ed25519';\n\treadonly publicKeyBase64: string;\n}\n\nexport function isSshServerHostKey(value: unknown): value is SshServerHostKey {\n\tif (typeof value !== 'object' || value === null) {\n\t\treturn false;\n\t}\n\tif (!('algorithm' in value) || !('publicKeyBase64' in value)) {\n\t\treturn false;\n\t}\n\tconst algorithm = value.algorithm;\n\tconst publicKeyBase64 = value.publicKeyBase64;\n\tif (\n\t\talgorithm !== 'ssh-ed25519' ||\n\t\ttypeof publicKeyBase64 !== 'string' ||\n\t\t!/^[A-Za-z0-9+/]+={0,2}$/u.test(publicKeyBase64)\n\t) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tconst decodedPublicKey = Buffer.from(publicKeyBase64, 'base64');\n\t\tif (decodedPublicKey.toString('base64') !== publicKeyBase64 || decodedPublicKey.length < 4) {\n\t\t\treturn false;\n\t\t}\n\t\tconst algorithmLength = decodedPublicKey.readUInt32BE(0);\n\t\tconst algorithmStart = 4;\n\t\tconst algorithmEnd = algorithmStart + algorithmLength;\n\t\tconst publicKeyLengthOffset = algorithmEnd;\n\t\tconst publicKeyStart = publicKeyLengthOffset + 4;\n\t\treturn (\n\t\t\talgorithmEnd + 4 <= decodedPublicKey.length &&\n\t\t\tdecodedPublicKey.subarray(algorithmStart, algorithmEnd).toString('utf8') === 'ssh-ed25519' &&\n\t\t\tdecodedPublicKey.readUInt32BE(publicKeyLengthOffset) === 32 &&\n\t\t\tdecodedPublicKey.length === publicKeyStart + 32\n\t\t);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function parseSshServerHostKey(publicKeyText: string): SshServerHostKey {\n\tconst publicKeyLines = publicKeyText\n\t\t.split('\\n')\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line.length > 0);\n\tif (publicKeyLines.length !== 1) {\n\t\tthrow new Error('Tool VM did not expose exactly one ssh-ed25519 server host key.');\n\t}\n\tconst publicKeyFields = publicKeyLines[0]?.split(/\\s+/u);\n\tconst serverHostKey = {\n\t\talgorithm: publicKeyFields?.[0],\n\t\tpublicKeyBase64: publicKeyFields?.[1],\n\t};\n\tif (!isSshServerHostKey(serverHostKey)) {\n\t\tthrow new Error('Tool VM did not expose a valid ssh-ed25519 server host key.');\n\t}\n\treturn serverHostKey;\n}\n\nasync function readSshServerHostKey(vmInstance: ManagedVmInstance): Promise<SshServerHostKey> {\n\tconst publicKeyResult = await vmInstance.exec(['/bin/cat', '/etc/ssh/ssh_host_ed25519_key.pub']);\n\tif (publicKeyResult.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`Tool VM server host key read failed with exit ${String(publicKeyResult.exitCode)}.`,\n\t\t);\n\t}\n\treturn parseSshServerHostKey(publicKeyResult.stdout);\n}\n\nasync function closeSshAccessAfterIdentityFailure(\n\tsshAccess: Awaited<ReturnType<ManagedVmInstance['enableSsh']>>,\n\tidentityError: unknown,\n): Promise<never> {\n\ttry {\n\t\tawait sshAccess.close();\n\t} catch (closeError) {\n\t\t// oxlint-disable-next-line preserve-caught-error -- AggregateError.errors preserves closeError while cause retains the primary identity failure.\n\t\tthrow new AggregateError(\n\t\t\t[identityError, closeError],\n\t\t\t'Tool VM SSH server identity validation and SSH access cleanup both failed.',\n\t\t\t{ cause: identityError },\n\t\t);\n\t}\n\tthrow identityError;\n}\n\nexport interface IngressAccess {\n\tclose(): Promise<void>;\n\treadonly host: string;\n\treadonly port: number;\n}\n\nexport interface ManagedVmInstance {\n\treadonly fs: ManagedVmFs;\n\treadonly id: string;\n\texec(command: string | string[], options?: ManagedExecOptions): ManagedExecProcess;\n\tenableSsh(options?: EnableSshOptions): Promise<ManagedVmSshAccess>;\n\tenableIngress(options?: EnableIngressOptions): Promise<IngressAccess>;\n\tgetHostPid?(): number | null;\n\tsetIngressRoutes(routes: readonly IngressRoute[]): void;\n\tstart(): Promise<void>;\n\tclose(): Promise<void>;\n}\n\nexport interface ManagedVmDependencies {\n\tconfigureHostNetworkDefaults?: () => HostNetworkDefaultsResult;\n\tcreateVm(vmOptions: VMOptions): Promise<ManagedVmInstance>;\n\tcreateHttpHooks(options: {\n\t\treadonly allowedHosts: readonly string[];\n\t\treadonly allowedInternalHosts?: readonly string[];\n\t\treadonly isIpAllowed?: HttpHooks['isIpAllowed'];\n\t\treadonly secrets: Record<string, ManagedHttpMediatedSecretSpec>;\n\t\treadonly onRequest?: (request: Request) => Promise<Request | Response | void>;\n\t\treadonly onResponse?: (response: Response) => Promise<Response | void>;\n\t}): Pick<CreateHttpHooksResult, 'env' | 'httpHooks'>;\n\tclosePinnedRealFsRoot(root: PinnedRealFsRoot): void;\n\tcreatePinnedRealFsProvider(root: PinnedRealFsRoot): VirtualProvider;\n\tcreateRealFsProvider(hostPath: string): VirtualProvider;\n\tcreateReadonlyProvider(provider: VirtualProvider): VirtualProvider;\n\tcreateMemoryProvider(): VirtualProvider;\n\tcreateShadowProvider(provider: VirtualProvider, options: ShadowProviderOptions): VirtualProvider;\n\tcreateShadowPathPredicate(paths: readonly string[]): ShadowPredicate;\n}\n\ninterface ManagedHttpMediatedSecretSpec {\n\treadonly hosts: readonly string[];\n\treadonly placeholder?: string;\n\treadonly value: string;\n}\n\ntype RealFsVfsMountSpec = {\n\treadonly hostPath?: string;\n\treadonly kind: 'realfs' | 'realfs-readonly';\n\treadonly pinnedHostRoot?: PinnedRealFsRoot;\n};\n\nexport type VfsMountSpec =\n\t| RealFsVfsMountSpec\n\t| {\n\t\t\treadonly access: 'read-only' | 'read-write';\n\t\t\treadonly kind: 'finalizable-memory';\n\t }\n\t| {\n\t\t\treadonly kind: 'filtered-workspace';\n\t\t\treadonly pinnedHostRoot: PinnedRealFsRoot;\n\t\t\treadonly policy: ManagedVmFilteredWorkspacePolicy;\n\t }\n\t| { readonly kind: 'memory' }\n\t| {\n\t\t\treadonly hostPath?: string;\n\t\t\treadonly kind: 'shadow';\n\t\t\treadonly pinnedHostRoot?: PinnedRealFsRoot;\n\t\t\treadonly shadowConfig?: {\n\t\t\t\treadonly deny: readonly string[];\n\t\t\t\treadonly tmpfs: readonly string[];\n\t\t\t};\n\t };\n\nexport interface CreateVmOptions {\n\treadonly imagePath: string;\n\treadonly memory: string;\n\treadonly cpus: number;\n\treadonly rootfsMode: 'readonly' | 'memory' | 'cow';\n\treadonly runtimeRootfsSize?: string;\n\treadonly allowedHosts: readonly string[];\n\treadonly secrets: Record<string, ManagedHttpMediatedSecretSpec>;\n\treadonly vfsMounts: Record<string, VfsMountSpec>;\n\treadonly tcpHosts?: Record<string, string>;\n\treadonly sshEgress?: ManagedSshEgressOptions;\n\treadonly env?: Record<string, string>;\n\treadonly sessionLabel?: string;\n\treadonly onRequest?: (request: Request) => Promise<Request | Response | void>;\n\treadonly onResponse?: (response: Response) => Promise<Response | void>;\n}\n\nexport interface ManagedVm {\n\treadonly fs: ManagedVmFs;\n\treadonly id: string;\n\texec(command: ManagedExecInput, options?: ManagedExecOptions): ManagedExecProcess;\n\tenableSsh(options?: EnableSshOptions): Promise<SshAccess>;\n\tenableIngress(options?: EnableIngressOptions): Promise<IngressAccess>;\n\tfinalizeMemoryMount(request: ManagedVmFinalizeMemoryMountRequest): Promise<void>;\n\tgetHostPid(): number | null;\n\tgetVmInstance(): ManagedVmInstance;\n\tsetIngressRoutes(routes: readonly IngressRoute[]): void;\n\tstart(): Promise<void>;\n\tclose(): Promise<void>;\n}\n\n/* oxlint-disable typescript-eslint/no-unsafe-type-assertion -- VM.create() returns\n Gondolin's concrete VM class; this adapter exposes only the narrower\n ManagedVmInstance interface used by agent-vm. */\nfunction createDefaultDependencies(): ManagedVmDependencies {\n\tconst createDefaultRealFsProvider = (hostPath: string): VirtualProvider =>\n\t\tnew RealFSProvider(hostPath);\n\treturn {\n\t\tconfigureHostNetworkDefaults,\n\t\tcreateVm: async (vmOptions: VMOptions): Promise<ManagedVmInstance> =>\n\t\t\t(await VM.create(vmOptions)) as unknown as ManagedVmInstance,\n\t\tcreateHttpHooks: (hookOptions) =>\n\t\t\tcreateHttpHooks({\n\t\t\t\tallowedHosts: [...hookOptions.allowedHosts],\n\t\t\t\t...(hookOptions.allowedInternalHosts === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { allowedInternalHosts: [...hookOptions.allowedInternalHosts] }),\n\t\t\t\t...(hookOptions.isIpAllowed ? { isIpAllowed: hookOptions.isIpAllowed } : {}),\n\t\t\t\tsecrets: Object.fromEntries(\n\t\t\t\t\tObject.entries(hookOptions.secrets).map(([secretName, secretSpec]) => [\n\t\t\t\t\t\tsecretName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thosts: [...secretSpec.hosts],\n\t\t\t\t\t\t\t...(secretSpec.placeholder === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: { placeholder: secretSpec.placeholder }),\n\t\t\t\t\t\t\tvalue: secretSpec.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t\t...(hookOptions.onRequest ? { onRequest: hookOptions.onRequest } : {}),\n\t\t\t\t...(hookOptions.onResponse ? { onResponse: hookOptions.onResponse } : {}),\n\t\t\t}),\n\t\tclosePinnedRealFsRoot,\n\t\tcreatePinnedRealFsProvider: (root: PinnedRealFsRoot): VirtualProvider =>\n\t\t\tcreatePinnedRealFsProvider({\n\t\t\t\tcreateRealFsProvider: createDefaultRealFsProvider,\n\t\t\t\troot,\n\t\t\t}),\n\t\tcreateRealFsProvider: createDefaultRealFsProvider,\n\t\tcreateReadonlyProvider: createHardenedReadonlyProvider,\n\t\tcreateMemoryProvider: (): VirtualProvider => new MemoryProvider(),\n\t\tcreateShadowProvider: (\n\t\t\tprovider: VirtualProvider,\n\t\t\tshadowOptions: ShadowProviderOptions,\n\t\t): VirtualProvider => new ShadowProvider(provider, shadowOptions),\n\t\tcreateShadowPathPredicate: (paths: readonly string[]): ShadowPredicate =>\n\t\t\tcreateShadowPathPredicate([...paths]),\n\t};\n}\n/* oxlint-enable typescript-eslint/no-unsafe-type-assertion */\n\nfunction normalizeShadowPath(pathValue: string): string {\n\tconst trimmedPath = pathValue.trim();\n\tif (trimmedPath.startsWith('/')) {\n\t\treturn trimmedPath;\n\t}\n\n\tconst relativePath = trimmedPath.startsWith('./') ? trimmedPath.slice('./'.length) : trimmedPath;\n\treturn `/${relativePath}`;\n}\n\nfunction createRealFsProviderForSpec(\n\tmountSpec: RealFsVfsMountSpec | Extract<VfsMountSpec, { readonly kind: 'shadow' }>,\n\tdependencies: ManagedVmDependencies,\n\tmountKind: string,\n): VirtualProvider {\n\tif (mountSpec.pinnedHostRoot) {\n\t\treturn dependencies.createPinnedRealFsProvider(mountSpec.pinnedHostRoot);\n\t}\n\tif (mountSpec.hostPath) {\n\t\treturn dependencies.createRealFsProvider(mountSpec.hostPath);\n\t}\n\n\tthrow new Error(`${mountKind} mounts require hostPath or pinnedHostRoot`);\n}\n\nfunction createProviderFromSpec(\n\tmountSpec: VfsMountSpec,\n\tdependencies: ManagedVmDependencies,\n): VirtualProvider {\n\tswitch (mountSpec.kind) {\n\t\tcase 'finalizable-memory':\n\t\t\tthrow new Error('Finalizable memory mounts require retained provider construction.');\n\t\tcase 'memory':\n\t\t\treturn dependencies.createMemoryProvider();\n\t\tcase 'realfs': {\n\t\t\treturn createRealFsProviderForSpec(mountSpec, dependencies, 'realfs');\n\t\t}\n\t\tcase 'realfs-readonly': {\n\t\t\treturn dependencies.createReadonlyProvider(\n\t\t\t\tcreateRealFsProviderForSpec(mountSpec, dependencies, 'realfs-readonly'),\n\t\t\t);\n\t\t}\n\t\tcase 'filtered-workspace': {\n\t\t\treturn createFilteredWorkspaceProvider({\n\t\t\t\tbaseProvider: dependencies.createPinnedRealFsProvider(mountSpec.pinnedHostRoot),\n\t\t\t\tdependencies,\n\t\t\t\tpolicy: mountSpec.policy,\n\t\t\t});\n\t\t}\n\t\tcase 'shadow': {\n\t\t\tconst baseProvider =\n\t\t\t\tmountSpec.hostPath || mountSpec.pinnedHostRoot\n\t\t\t\t\t? createRealFsProviderForSpec(mountSpec, dependencies, 'shadow')\n\t\t\t\t\t: dependencies.createMemoryProvider();\n\n\t\t\tlet shadowProvider = baseProvider;\n\t\t\tconst shadowConfig = mountSpec.shadowConfig;\n\n\t\t\tif (shadowConfig?.deny.length) {\n\t\t\t\tshadowProvider = dependencies.createShadowProvider(shadowProvider, {\n\t\t\t\t\tshouldShadow: dependencies.createShadowPathPredicate(\n\t\t\t\t\t\tshadowConfig.deny.map((shadowPath) => normalizeShadowPath(shadowPath)),\n\t\t\t\t\t),\n\t\t\t\t\twriteMode: 'deny',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (shadowConfig?.tmpfs.length) {\n\t\t\t\tshadowProvider = dependencies.createShadowProvider(shadowProvider, {\n\t\t\t\t\tshouldShadow: dependencies.createShadowPathPredicate(\n\t\t\t\t\t\tshadowConfig.tmpfs.map((shadowPath) => normalizeShadowPath(shadowPath)),\n\t\t\t\t\t),\n\t\t\t\t\twriteMode: 'tmpfs',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn shadowProvider;\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new Error('Unsupported VFS mount kind.');\n\t\t}\n\t}\n}\n\ninterface FinalizableMemoryMount {\n\treadonly provider: VirtualProvider;\n\tstate: 'failed' | 'finalized' | 'finalizing' | 'pending';\n}\n\ninterface CreatedVfsMounts {\n\treadonly finalizableMemoryMounts: Map<string, FinalizableMemoryMount>;\n\treadonly mounts: Record<string, VirtualProvider>;\n}\n\nfunction createVfsMounts(\n\tvfsMounts: Record<string, VfsMountSpec>,\n\tdependencies: ManagedVmDependencies,\n): CreatedVfsMounts {\n\tconst mountMap: Record<string, VirtualProvider> = {};\n\tconst finalizableMemoryMounts = new Map<string, FinalizableMemoryMount>();\n\n\tfor (const [guestPath, mountSpec] of Object.entries(vfsMounts)) {\n\t\tif (mountSpec.kind === 'finalizable-memory') {\n\t\t\tconst provider = dependencies.createMemoryProvider();\n\t\t\tfinalizableMemoryMounts.set(guestPath, { provider, state: 'pending' });\n\t\t\tconst guestProvider = createGuestRootOwnedProvider(provider);\n\t\t\tmountMap[guestPath] =\n\t\t\t\tmountSpec.access === 'read-only'\n\t\t\t\t\t? dependencies.createReadonlyProvider(guestProvider)\n\t\t\t\t\t: guestProvider;\n\t\t\tcontinue;\n\t\t}\n\t\tmountMap[guestPath] = createProviderFromSpec(mountSpec, dependencies);\n\t}\n\n\treturn { finalizableMemoryMounts, mounts: mountMap };\n}\n\nfunction collectPinnedRealFsRoots(\n\tvfsMounts: Record<string, VfsMountSpec>,\n): readonly PinnedRealFsRoot[] {\n\tconst roots = new Map<number, PinnedRealFsRoot>();\n\tfor (const mountSpec of Object.values(vfsMounts)) {\n\t\tif ('pinnedHostRoot' in mountSpec && mountSpec.pinnedHostRoot) {\n\t\t\troots.set(mountSpec.pinnedHostRoot.fd, mountSpec.pinnedHostRoot);\n\t\t}\n\t}\n\treturn [...roots.values()];\n}\n\nfunction closePinnedRealFsRoots(\n\troots: readonly PinnedRealFsRoot[],\n\tdependencies: ManagedVmDependencies,\n): void {\n\tconst closeErrors: unknown[] = [];\n\tfor (const root of roots) {\n\t\ttry {\n\t\t\tdependencies.closePinnedRealFsRoot(root);\n\t\t} catch (error) {\n\t\t\tcloseErrors.push(error);\n\t\t}\n\t}\n\tif (closeErrors.length === 1) {\n\t\tthrow closeErrors[0];\n\t}\n\tif (closeErrors.length > 1) {\n\t\tthrow new AggregateError(closeErrors, 'Multiple pinned RealFS roots failed to close.');\n\t}\n}\n\nfunction closePinnedRealFsRootsAfterFailure(\n\troots: readonly PinnedRealFsRoot[],\n\tdependencies: ManagedVmDependencies,\n): void {\n\ttry {\n\t\tclosePinnedRealFsRoots(roots, dependencies);\n\t} catch {\n\t\t// Preserve the VM creation failure; leaked-fd risk is lower than hiding\n\t\t// the root cause of a failed lease.\n\t}\n}\n\nfunction resolveManagedVmIngressOptions(\n\tingressOptions: EnableIngressOptions = {},\n): EnableIngressOptions {\n\tconst resolvedOptions: EnableIngressOptions = {\n\t\t...MANAGED_VM_DEFAULT_INGRESS_OPTIONS,\n\t};\n\n\tif (ingressOptions.listenHost !== undefined) {\n\t\tresolvedOptions.listenHost = ingressOptions.listenHost;\n\t}\n\tif (ingressOptions.listenPort !== undefined) {\n\t\tresolvedOptions.listenPort = ingressOptions.listenPort;\n\t}\n\tif (ingressOptions.allowWebSockets !== undefined) {\n\t\tresolvedOptions.allowWebSockets = ingressOptions.allowWebSockets;\n\t}\n\tif (ingressOptions.hooks !== undefined) {\n\t\tresolvedOptions.hooks = ingressOptions.hooks;\n\t}\n\tif (ingressOptions.bufferResponseBody !== undefined) {\n\t\tresolvedOptions.bufferResponseBody = ingressOptions.bufferResponseBody;\n\t}\n\tif (ingressOptions.maxBufferedResponseBodyBytes !== undefined) {\n\t\tresolvedOptions.maxBufferedResponseBodyBytes = ingressOptions.maxBufferedResponseBodyBytes;\n\t}\n\tif (ingressOptions.upstreamHeaderTimeoutMs !== undefined) {\n\t\tresolvedOptions.upstreamHeaderTimeoutMs = ingressOptions.upstreamHeaderTimeoutMs;\n\t}\n\tif (ingressOptions.upstreamResponseTimeoutMs !== undefined) {\n\t\tresolvedOptions.upstreamResponseTimeoutMs = ingressOptions.upstreamResponseTimeoutMs;\n\t}\n\n\treturn resolvedOptions;\n}\n\ninterface TcpHostEndpoint {\n\treadonly hostname: string;\n\treadonly port: number;\n}\n\ninterface InternalTcpHostRule extends TcpHostEndpoint {}\n\nfunction normalizePolicyHostname(hostname: string): string {\n\treturn hostname.toLowerCase();\n}\n\nfunction parseTcpHostEndpoint(endpoint: string): TcpHostEndpoint | undefined {\n\tif (endpoint.startsWith('[')) {\n\t\tconst closingBracketIndex = endpoint.indexOf(']');\n\t\tif (closingBracketIndex > 1) {\n\t\t\tconst portValue = Number.parseInt(endpoint.slice(closingBracketIndex + 2), 10);\n\t\t\tif (!Number.isFinite(portValue)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\thostname: normalizePolicyHostname(endpoint.slice(1, closingBracketIndex)),\n\t\t\t\tport: portValue,\n\t\t\t};\n\t\t}\n\t}\n\n\tconst portSeparatorIndex = endpoint.lastIndexOf(':');\n\tif (portSeparatorIndex <= 0) {\n\t\treturn undefined;\n\t}\n\tconst portValue = Number.parseInt(endpoint.slice(portSeparatorIndex + 1), 10);\n\tif (!Number.isFinite(portValue)) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\thostname: normalizePolicyHostname(endpoint.slice(0, portSeparatorIndex)),\n\t\tport: portValue,\n\t};\n}\n\nfunction ipv4AddressIsInternal(ipAddress: string): boolean {\n\tconst octets = ipAddress.split('.').map((segment) => Number.parseInt(segment, 10));\n\tif (octets.length !== 4 || octets.some((octet) => !Number.isInteger(octet))) {\n\t\treturn false;\n\t}\n\tconst firstOctet = octets[0];\n\tconst secondOctet = octets[1];\n\tif (firstOctet === undefined || secondOctet === undefined) {\n\t\treturn false;\n\t}\n\treturn (\n\t\tfirstOctet === 10 ||\n\t\tfirstOctet === 127 ||\n\t\t(firstOctet === 169 && secondOctet === 254) ||\n\t\t(firstOctet === 172 && secondOctet >= 16 && secondOctet <= 31) ||\n\t\t(firstOctet === 192 && secondOctet === 168) ||\n\t\t(firstOctet === 100 && secondOctet >= 64 && secondOctet <= 127)\n\t);\n}\n\nfunction ipAddressIsInternal(ipAddress: string): boolean {\n\tif (net.isIP(ipAddress) === 4) {\n\t\treturn ipv4AddressIsInternal(ipAddress);\n\t}\n\tconst normalizedIpAddress = ipAddress.toLowerCase();\n\tif (normalizedIpAddress.startsWith('::ffff:')) {\n\t\treturn ipv4AddressIsInternal(normalizedIpAddress.slice('::ffff:'.length));\n\t}\n\treturn (\n\t\tnormalizedIpAddress === '::1' ||\n\t\tnormalizedIpAddress.startsWith('fc') ||\n\t\tnormalizedIpAddress.startsWith('fd') ||\n\t\tnormalizedIpAddress.startsWith('fe80:')\n\t);\n}\n\nfunction endpointHostnameIsInternal(hostname: string): boolean {\n\tconst normalizedHostname = normalizePolicyHostname(hostname);\n\treturn (\n\t\tnormalizedHostname === 'localhost' ||\n\t\tnormalizedHostname === 'host.docker.internal' ||\n\t\tipAddressIsInternal(normalizedHostname)\n\t);\n}\n\nfunction deriveInternalTcpHostRules(\n\ttcpHosts: Record<string, string> | undefined,\n): readonly InternalTcpHostRule[] {\n\tif (!tcpHosts) {\n\t\treturn [];\n\t}\n\n\tconst rules: InternalTcpHostRule[] = [];\n\tfor (const [tcpHostKey, tcpHostTarget] of Object.entries(tcpHosts)) {\n\t\tconst exposedEndpoint = parseTcpHostEndpoint(tcpHostKey);\n\t\tconst targetEndpoint = parseTcpHostEndpoint(tcpHostTarget);\n\t\tif (\n\t\t\t!exposedEndpoint ||\n\t\t\t!targetEndpoint ||\n\t\t\t!endpointHostnameIsInternal(targetEndpoint.hostname)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\t!rules.some(\n\t\t\t\t(rule) => rule.hostname === exposedEndpoint.hostname && rule.port === exposedEndpoint.port,\n\t\t\t)\n\t\t) {\n\t\t\trules.push(exposedEndpoint);\n\t\t}\n\t}\n\treturn rules;\n}\n\nfunction mergeUniqueHosts(\n\thosts: readonly string[],\n\tadditionalHosts: readonly string[],\n): readonly string[] {\n\tconst mergedHosts = [...hosts];\n\tfor (const host of additionalHosts) {\n\t\tif (!mergedHosts.includes(host)) {\n\t\t\tmergedHosts.push(host);\n\t\t}\n\t}\n\treturn mergedHosts;\n}\n\nfunction normalizeGitRepoPath(repoPath: string): string {\n\treturn repoPath.replace(/^\\/+/u, '').replace(/\\.git$/u, '');\n}\n\nexport function createGitReadOnlySshEgressOptions(\n\toptions: GitReadOnlySshEgressOptions,\n): ManagedSshEgressOptions {\n\tconst allowedRepos =\n\t\toptions.allowedRepos === undefined\n\t\t\t? undefined\n\t\t\t: new Set(options.allowedRepos.map((repoPath) => normalizeGitRepoPath(repoPath)));\n\n\treturn {\n\t\tallowedHosts: [...options.allowedHosts],\n\t\t...(options.agent ? { agent: options.agent } : {}),\n\t\t...(options.knownHostsFile ? { knownHostsFile: options.knownHostsFile } : {}),\n\t\texecPolicy: (request) => {\n\t\t\tconst gitExec = getInfoFromSshExecRequest(request);\n\t\t\tif (!gitExec) {\n\t\t\t\treturn {\n\t\t\t\t\tallow: false,\n\t\t\t\t\tmessage: 'agent-vm: non-git SSH exec is denied',\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (gitExec.service === 'git-receive-pack') {\n\t\t\t\treturn {\n\t\t\t\t\tallow: false,\n\t\t\t\t\tmessage: 'agent-vm: git push over guest SSH is denied',\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (gitExec.service !== 'git-upload-pack') {\n\t\t\t\treturn {\n\t\t\t\t\tallow: false,\n\t\t\t\t\tmessage: 'agent-vm: unsupported git SSH service is denied',\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (allowedRepos && !allowedRepos.has(normalizeGitRepoPath(gitExec.repo))) {\n\t\t\t\treturn {\n\t\t\t\t\tallow: false,\n\t\t\t\t\tmessage: 'agent-vm: git repository is not allowlisted for guest SSH reads',\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { allow: true };\n\t\t},\n\t};\n}\n\nfunction createInternalTcpHostPolicy(\n\trules: readonly InternalTcpHostRule[],\n): HttpHooks['isIpAllowed'] | undefined {\n\tif (rules.length === 0) {\n\t\treturn undefined;\n\t}\n\tconst ruleHostnames = new Set(rules.map((rule) => rule.hostname));\n\treturn (info) => {\n\t\tconst hostname = normalizePolicyHostname(info.hostname);\n\t\tconst exactRuleMatched = rules.some(\n\t\t\t(rule) => rule.hostname === hostname && rule.port === info.port,\n\t\t);\n\t\tif (ruleHostnames.has(hostname)) {\n\t\t\treturn exactRuleMatched;\n\t\t}\n\t\tif (ipAddressIsInternal(info.ip)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t};\n}\n\nexport async function createManagedVm(\n\toptions: CreateVmOptions,\n\tdependencies: ManagedVmDependencies = createDefaultDependencies(),\n): Promise<ManagedVm> {\n\tdependencies.configureHostNetworkDefaults?.();\n\tconst hasTcpHosts = options.tcpHosts && Object.keys(options.tcpHosts).length > 0;\n\tconst hasSshEgress = options.sshEgress !== undefined && options.sshEgress.allowedHosts.length > 0;\n\tconst internalTcpHostRules = deriveInternalTcpHostRules(options.tcpHosts);\n\tconst allowedInternalHosts = mergeUniqueHosts(\n\t\t[],\n\t\tinternalTcpHostRules.map((rule) => rule.hostname),\n\t);\n\tconst isIpAllowed = createInternalTcpHostPolicy(internalTcpHostRules);\n\tconst pinnedRealFsRoots = collectPinnedRealFsRoots(options.vfsMounts);\n\tlet createdVfsMounts: CreatedVfsMounts;\n\tlet vmInstance: ManagedVmInstance;\n\ttry {\n\t\tcreatedVfsMounts = createVfsMounts(options.vfsMounts, dependencies);\n\t\tconst hookBundle = dependencies.createHttpHooks({\n\t\t\tallowedHosts: options.allowedHosts,\n\t\t\t...(allowedInternalHosts.length > 0 ? { allowedInternalHosts } : {}),\n\t\t\t...(isIpAllowed ? { isIpAllowed } : {}),\n\t\t\tsecrets: options.secrets,\n\t\t\t...(options.onRequest ? { onRequest: options.onRequest } : {}),\n\t\t\t...(options.onResponse ? { onResponse: options.onResponse } : {}),\n\t\t});\n\t\tvmInstance = await dependencies.createVm({\n\t\t\t...(options.imagePath.length > 0 ? { sandbox: { imagePath: options.imagePath } } : {}),\n\t\t\t...(options.sessionLabel ? { sessionLabel: options.sessionLabel } : {}),\n\t\t\trootfs: {\n\t\t\t\tmode: options.rootfsMode,\n\t\t\t\t...(options.runtimeRootfsSize === undefined ? {} : { size: options.runtimeRootfsSize }),\n\t\t\t},\n\t\t\tmemory: options.memory,\n\t\t\tcpus: options.cpus,\n\t\t\tenv: {\n\t\t\t\t...hookBundle.env,\n\t\t\t\t...options.env,\n\t\t\t},\n\t\t\thttpHooks: hookBundle.httpHooks,\n\t\t\tvfs: {\n\t\t\t\tfuseMount: '/data',\n\t\t\t\tmounts: createdVfsMounts.mounts,\n\t\t\t},\n\t\t\t...(hasTcpHosts || hasSshEgress\n\t\t\t\t? {\n\t\t\t\t\t\tdns: {\n\t\t\t\t\t\t\tmode: 'synthetic',\n\t\t\t\t\t\t\tsyntheticIPv4: SYNTHETIC_DNS_IPV4_BENCHMARK,\n\t\t\t\t\t\t\tsyntheticIPv6: SYNTHETIC_DNS_IPV6_IPV4_MAPPED_BENCHMARK,\n\t\t\t\t\t\t\tsyntheticHostMapping: 'per-host',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...(hasSshEgress ? { ssh: options.sshEgress } : {}),\n\t\t\t\t\t\t...(hasTcpHosts\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\ttcp: {\n\t\t\t\t\t\t\t\t\t\thosts: options.tcpHosts,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t});\n\t} catch (error) {\n\t\tclosePinnedRealFsRootsAfterFailure(pinnedRealFsRoots, dependencies);\n\t\tthrow error;\n\t}\n\n\tlet finalizationPoison: unknown;\n\tlet lifecycleState: 'closed' | 'created' | 'started' = 'created';\n\tconst poisonFinalization = (error: unknown): void => {\n\t\tfinalizationPoison ??= error;\n\t};\n\treturn {\n\t\tfs: vmInstance.fs,\n\t\tid: vmInstance.id,\n\t\texec(command: ManagedExecInput, execOptions?: ManagedExecOptions): ManagedExecProcess {\n\t\t\tconst normalizedCommand = typeof command === 'string' ? command : [...command];\n\t\t\treturn vmInstance.exec(normalizedCommand, execOptions);\n\t\t},\n\t\tasync enableSsh(sshOptions?: EnableSshOptions): Promise<SshAccess> {\n\t\t\tconst sshAccess = await vmInstance.enableSsh(sshOptions);\n\t\t\tlet serverHostKey: SshServerHostKey;\n\t\t\ttry {\n\t\t\t\tserverHostKey = await readSshServerHostKey(vmInstance);\n\t\t\t} catch (identityError) {\n\t\t\t\treturn await closeSshAccessAfterIdentityFailure(sshAccess, identityError);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tclose: async (): Promise<void> => await sshAccess.close(),\n\t\t\t\tcommand: sshAccess.command,\n\t\t\t\thost: sshAccess.host,\n\t\t\t\tidentityFile: sshAccess.identityFile,\n\t\t\t\tport: sshAccess.port,\n\t\t\t\tserverHostKey,\n\t\t\t\tuser: sshAccess.user,\n\t\t\t};\n\t\t},\n\t\tasync enableIngress(ingressOptions?: EnableIngressOptions): Promise<IngressAccess> {\n\t\t\treturn await vmInstance.enableIngress(resolveManagedVmIngressOptions(ingressOptions));\n\t\t},\n\t\tasync finalizeMemoryMount(request: ManagedVmFinalizeMemoryMountRequest): Promise<void> {\n\t\t\tif (lifecycleState === 'closed') {\n\t\t\t\tthrow new Error('Managed Gondolin VM memory mounts cannot be finalized after close.');\n\t\t\t}\n\t\t\tif (lifecycleState === 'started') {\n\t\t\t\tthrow new Error('Managed Gondolin VM memory mounts cannot be finalized after start.');\n\t\t\t}\n\t\t\tif (finalizationPoison !== undefined) {\n\t\t\t\tthrow new Error('Managed Gondolin VM memory mount finalization is poisoned.', {\n\t\t\t\t\tcause: finalizationPoison,\n\t\t\t\t});\n\t\t\t}\n\t\t\tlet validatedRequest: ManagedVmFinalizeMemoryMountRequest;\n\t\t\ttry {\n\t\t\t\tvalidatedRequest = validateManagedVmFinalizeMemoryMountRequest(request);\n\t\t\t\tconst mount = createdVfsMounts.finalizableMemoryMounts.get(validatedRequest.guestPath);\n\t\t\t\tif (mount === undefined) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Managed Gondolin VM has no declared finalizable memory mount at '${validatedRequest.guestPath}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (mount.state !== 'pending') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Managed Gondolin VM memory mount '${validatedRequest.guestPath}' must be finalized exactly once.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tmount.state = 'finalizing';\n\t\t\t\tif (mount.provider.writeFile === undefined) {\n\t\t\t\t\tthrow new Error('Gondolin memory provider does not support file writes.');\n\t\t\t\t}\n\t\t\t\tfor (const file of validatedRequest.files) {\n\t\t\t\t\t// oxlint-disable-next-line no-await-in-loop -- one-shot inventory publication is intentionally ordered.\n\t\t\t\t\tawait mount.provider.writeFile(`/${file.relativePath}`, Buffer.from(file.contents), {\n\t\t\t\t\t\tmode: file.mode,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tmount.state = 'finalized';\n\t\t\t} catch (error) {\n\t\t\t\tconst mount = createdVfsMounts.finalizableMemoryMounts.get(request.guestPath);\n\t\t\t\tif (mount !== undefined) mount.state = 'failed';\n\t\t\t\tpoisonFinalization(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tgetHostPid(): number | null {\n\t\t\treturn vmInstance.getHostPid?.() ?? null;\n\t\t},\n\t\tgetVmInstance(): ManagedVmInstance {\n\t\t\treturn vmInstance;\n\t\t},\n\t\tsetIngressRoutes(routes: readonly IngressRoute[]): void {\n\t\t\tvmInstance.setIngressRoutes(routes);\n\t\t},\n\t\tasync start(): Promise<void> {\n\t\t\tif (finalizationPoison !== undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Managed Gondolin VM cannot start after memory finalization was poisoned.',\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: finalizationPoison,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst incompleteMount = [...createdVfsMounts.finalizableMemoryMounts].find(\n\t\t\t\t([, mount]) => mount.state !== 'finalized',\n\t\t\t);\n\t\t\tif (incompleteMount !== undefined) {\n\t\t\t\tconst error = new Error(\n\t\t\t\t\t`Managed Gondolin VM memory mount '${incompleteMount[0]}' must be finalized before start.`,\n\t\t\t\t);\n\t\t\t\tpoisonFinalization(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tawait vmInstance.start();\n\t\t\tlifecycleState = 'started';\n\t\t},\n\t\tasync close(): Promise<void> {\n\t\t\tconst closeErrors: unknown[] = [];\n\t\t\ttry {\n\t\t\t\tawait vmInstance.close();\n\t\t\t} catch (error) {\n\t\t\t\tcloseErrors.push(error);\n\t\t\t}\n\t\t\tlifecycleState = 'closed';\n\t\t\tcreatedVfsMounts.finalizableMemoryMounts.clear();\n\t\t\ttry {\n\t\t\t\tclosePinnedRealFsRoots(pinnedRealFsRoots, dependencies);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof AggregateError) {\n\t\t\t\t\tcloseErrors.push(...error.errors);\n\t\t\t\t} else {\n\t\t\t\t\tcloseErrors.push(error);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (closeErrors.length === 1) {\n\t\t\t\tthrow closeErrors[0];\n\t\t\t}\n\t\t\tif (closeErrors.length > 1) {\n\t\t\t\tthrow new AggregateError(closeErrors, 'Managed Gondolin VM cleanup failed.');\n\t\t\t}\n\t\t},\n\t};\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport {\n\tcreateOwnedHostDirectoryController,\n\tassertPositiveHostProcessId,\n\tvalidateManagedVmFilteredWorkspacePolicy,\n\ttype ManagedVm,\n\ttype ManagedVmAccessHandle,\n\ttype ManagedVmCreateRequest,\n\ttype ManagedVmExecCommand,\n\ttype ManagedVmExecOptions,\n\ttype ManagedVmExecOutputChunk,\n\ttype ManagedVmExecProcess,\n\ttype ManagedVmExecResult,\n\ttype ManagedVmExecStreamMode,\n\ttype ManagedVmIngressOptions,\n\ttype ManagedVmIngressRoute,\n\ttype ManagedVmProvider,\n\ttype ManagedVmSshAccess,\n\ttype OwnedHostDirectory,\n\ttype OwnedHostDirectoryTransfer,\n} from '@agent-vm/managed-vm';\nimport { validateBuildConfig } from '@earendil-works/gondolin';\nimport { parse, printParseErrorCode, type ParseError } from 'jsonc-parser';\n\nimport { buildImage } from './build-pipeline.js';\nimport { createGondolinExactProcessTerminationCapability } from './exact-recorded-process-termination.js';\nimport {\n\tresolveGondolinMinimumZigVersion,\n\tresolveGondolinPackageSpec,\n} from './gondolin-package.js';\nimport {\n\tassertPinnedRealFsRoot,\n\tclosePinnedRealFsRoot,\n\tpinRealFsRoot,\n\ttype PinnedRealFsRoot,\n} from './pinned-realfs.js';\nimport {\n\tcreateGitReadOnlySshEgressOptions,\n\tcreateManagedVm as createNativeManagedVm,\n\ttype ManagedExecOptions as NativeManagedExecOptions,\n\ttype ManagedVm as NativeManagedVm,\n\ttype VfsMountSpec,\n} from './vm-adapter.js';\n\ntype OwnedDirectoryProvenance = WeakMap<OwnedHostDirectory, PinnedRealFsRoot>;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction formatUnknownValue(value: unknown): string {\n\treturn typeof value === 'string' ? value : JSON.stringify(value);\n}\n\nfunction assertCreateRequestSupported(request: ManagedVmCreateRequest): void {\n\tif (!['readonly', 'memory', 'cow'].includes(request.rootfsMode)) {\n\t\tthrow new Error(\n\t\t\t`Unsupported managed VM rootfs mode: ${formatUnknownValue(request.rootfsMode)}`,\n\t\t);\n\t}\n\tif (!Number.isSafeInteger(request.resources.cpuCount) || request.resources.cpuCount <= 0) {\n\t\tthrow new Error('Managed VM CPU count must be a positive safe integer.');\n\t}\n\tif (request.imageReference.length === 0 || request.resources.memory.length === 0) {\n\t\tthrow new Error('Managed VM image reference and memory must be non-empty.');\n\t}\n\tif (request.sshEgress !== undefined && request.sshEgress.kind !== 'git-read-only') {\n\t\tthrow new Error(\n\t\t\t`Unsupported managed VM SSH egress kind: ${formatUnknownValue(request.sshEgress.kind)}`,\n\t\t);\n\t}\n\tfor (const [guestPath, mount] of Object.entries(request.mounts)) {\n\t\tif (!guestPath.startsWith('/')) {\n\t\t\tthrow new Error(`Managed VM mount path must be absolute: ${guestPath}`);\n\t\t}\n\t\tif (\n\t\t\t![\n\t\t\t\t'host-directory',\n\t\t\t\t'finalizable-memory',\n\t\t\t\t'owned-host-directory',\n\t\t\t\t'owned-filtered-workspace',\n\t\t\t\t'memory',\n\t\t\t\t'shadow',\n\t\t\t].includes(mount.kind)\n\t\t) {\n\t\t\tthrow new Error(`Unsupported managed VM mount kind: ${formatUnknownValue(mount.kind)}`);\n\t\t}\n\t}\n\tconst mediatedSecretNames = new Set<string>();\n\tfor (const secret of request.mediatedSecrets) {\n\t\tif (mediatedSecretNames.has(secret.environmentVariable)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Duplicate managed VM mediated-secret environment variable: ${secret.environmentVariable}`,\n\t\t\t);\n\t\t}\n\t\tmediatedSecretNames.add(secret.environmentVariable);\n\t}\n\tconst tcpGuestHosts = new Set<string>();\n\tfor (const mapping of request.tcpHosts) {\n\t\tif (tcpGuestHosts.has(mapping.guestHost)) {\n\t\t\tthrow new Error(`Duplicate managed VM TCP guest host: ${mapping.guestHost}`);\n\t\t}\n\t\ttcpGuestHosts.add(mapping.guestHost);\n\t}\n}\n\ninterface TranslatedMounts {\n\treadonly mounts: Record<string, VfsMountSpec>;\n\treadonly transfers: readonly OwnedHostDirectoryTransfer[];\n}\n\nfunction closeOwnedDirectoryTransfers(\n\ttransfers: readonly OwnedHostDirectoryTransfer[],\n): readonly unknown[] {\n\tconst closeErrors: unknown[] = [];\n\tfor (const transfer of transfers) {\n\t\ttry {\n\t\t\ttransfer.close();\n\t\t} catch (error) {\n\t\t\tcloseErrors.push(error);\n\t\t}\n\t}\n\treturn closeErrors;\n}\n\nfunction isReadonlyStringArray(\n\tvalue: readonly string[] | Readonly<Record<string, string>>,\n): value is readonly string[] {\n\treturn Array.isArray(value);\n}\n\nfunction translateExecEnvironment(\n\tenvironment: readonly string[] | Readonly<Record<string, string>>,\n): string[] | Record<string, string> {\n\treturn isReadonlyStringArray(environment) ? [...environment] : { ...environment };\n}\n\nfunction translateExecStdin(\n\tstdin: string | Uint8Array | AsyncIterable<Uint8Array>,\n): string | Buffer | AsyncIterable<Buffer> {\n\tif (typeof stdin === 'string') {\n\t\treturn stdin;\n\t}\n\tif (stdin instanceof Uint8Array) {\n\t\treturn Buffer.from(stdin);\n\t}\n\treturn (async function* (): AsyncIterable<Buffer> {\n\t\tfor await (const chunk of stdin) {\n\t\t\tyield Buffer.from(chunk);\n\t\t}\n\t})();\n}\n\nconst MANAGED_VM_EXEC_OUTPUT_WINDOW_MIN_BYTES = 4 * 1024;\nconst MANAGED_VM_EXEC_OUTPUT_WINDOW_MAX_BYTES = 16 * 1024 * 1024;\n\nfunction translateExecStreamMode(mode: ManagedVmExecStreamMode): 'ignore' | 'pipe' {\n\tif (typeof mode !== 'object' || mode === null || !('kind' in mode)) {\n\t\tthrow new Error('Unsupported managed VM exec output mode.');\n\t}\n\tif (mode.kind === 'pipe') {\n\t\treturn 'pipe';\n\t}\n\tif (mode.kind === 'discard') {\n\t\treturn 'ignore';\n\t}\n\tthrow new Error('Unsupported managed VM exec output mode.');\n}\n\nfunction translateExecStreamingOptions(\n\toutput: NonNullable<ManagedVmExecOptions['output']>,\n): Pick<NativeManagedExecOptions, 'stderr' | 'stdout' | 'windowBytes'> {\n\tif (\n\t\t!Number.isInteger(output.windowBytes) ||\n\t\toutput.windowBytes < MANAGED_VM_EXEC_OUTPUT_WINDOW_MIN_BYTES ||\n\t\toutput.windowBytes > MANAGED_VM_EXEC_OUTPUT_WINDOW_MAX_BYTES\n\t) {\n\t\tthrow new Error(\n\t\t\t`Managed VM exec output window must be an integer between ${String(MANAGED_VM_EXEC_OUTPUT_WINDOW_MIN_BYTES)} and ${String(MANAGED_VM_EXEC_OUTPUT_WINDOW_MAX_BYTES)} bytes.`,\n\t\t);\n\t}\n\treturn {\n\t\tstderr: translateExecStreamMode(output.stderr),\n\t\tstdout: translateExecStreamMode(output.stdout),\n\t\twindowBytes: output.windowBytes,\n\t};\n}\n\nfunction translateExecOptions(options: ManagedVmExecOptions): NativeManagedExecOptions {\n\treturn {\n\t\t...(options.argv ? { argv: [...options.argv] } : {}),\n\t\t...(options.cwd ? { cwd: options.cwd } : {}),\n\t\t...(options.env ? { env: translateExecEnvironment(options.env) } : {}),\n\t\t...(options.output === undefined ? {} : translateExecStreamingOptions(options.output)),\n\t\t...(options.pty === undefined ? {} : { pty: options.pty }),\n\t\t...(options.signal ? { signal: options.signal } : {}),\n\t\t...(options.stdin === undefined ? {} : { stdin: translateExecStdin(options.stdin) }),\n\t};\n}\n\nfunction wrapExecProcess(nativeProcess: ReturnType<NativeManagedVm['exec']>): ManagedVmExecProcess {\n\tconst result: Promise<ManagedVmExecResult> = nativeProcess.result;\n\treturn Object.assign(result, {\n\t\t[Symbol.asyncIterator](): AsyncIterator<string> {\n\t\t\treturn nativeProcess[Symbol.asyncIterator]();\n\t\t},\n\t\tend(): void {\n\t\t\tnativeProcess.end();\n\t\t},\n\t\tlines(): AsyncIterable<string> {\n\t\t\treturn nativeProcess.lines();\n\t\t},\n\t\toutput(): AsyncIterable<ManagedVmExecOutputChunk> {\n\t\t\treturn nativeProcess.output();\n\t\t},\n\t\tresize(rows: number, columns: number): void {\n\t\t\tnativeProcess.resize(rows, columns);\n\t\t},\n\t\tresult,\n\t\twrite(data: string | Uint8Array): void {\n\t\t\tnativeProcess.write(typeof data === 'string' ? data : Buffer.from(data));\n\t\t},\n\t}) satisfies ManagedVmExecProcess;\n}\n\nasync function assertReadonlyInputSourcesStayWithinOwnedRoot(\n\tpinnedRoot: PinnedRealFsRoot,\n\tpolicy: ReturnType<typeof validateManagedVmFilteredWorkspacePolicy>,\n): Promise<void> {\n\tconst canonicalRootPrefix = pinnedRoot.realPath.endsWith(path.sep)\n\t\t? pinnedRoot.realPath\n\t\t: `${pinnedRoot.realPath}${path.sep}`;\n\tawait Promise.all(\n\t\tpolicy.readonlyInputs.map(async (readonlyInput) => {\n\t\t\tconst sourcePath = path.join(\n\t\t\t\tpinnedRoot.realPath,\n\t\t\t\t...readonlyInput.sourceRelativePath.split('/'),\n\t\t\t);\n\t\t\tconst canonicalSourcePath = await fs.realpath(sourcePath);\n\t\t\tif (\n\t\t\t\tcanonicalSourcePath !== pinnedRoot.realPath &&\n\t\t\t\t!canonicalSourcePath.startsWith(canonicalRootPrefix)\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Managed filtered workspace read-only source crosses the owned root boundary: ${readonlyInput.sourceRelativePath}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}),\n\t);\n}\n\nasync function translateMounts(\n\tmounts: ManagedVmCreateRequest['mounts'],\n\townedDirectoryRoots: OwnedDirectoryProvenance,\n): Promise<TranslatedMounts> {\n\tconst translatedMounts: Record<string, VfsMountSpec> = {};\n\tconst transfers: OwnedHostDirectoryTransfer[] = [];\n\tconst sourceValidations: {\n\t\treadonly pinnedRoot: PinnedRealFsRoot;\n\t\treadonly policy: ReturnType<typeof validateManagedVmFilteredWorkspacePolicy>;\n\t}[] = [];\n\ttry {\n\t\tfor (const [guestPath, mount] of Object.entries(mounts)) {\n\t\t\tswitch (mount.kind) {\n\t\t\t\tcase 'finalizable-memory':\n\t\t\t\t\ttranslatedMounts[guestPath] = {\n\t\t\t\t\t\taccess: mount.access,\n\t\t\t\t\t\tkind: 'finalizable-memory',\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'host-directory':\n\t\t\t\t\ttranslatedMounts[guestPath] = {\n\t\t\t\t\t\thostPath: mount.hostPath,\n\t\t\t\t\t\tkind: mount.access === 'read-only' ? 'realfs-readonly' : 'realfs',\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'owned-host-directory': {\n\t\t\t\t\tconst pinnedRoot = ownedDirectoryRoots.get(mount.directory);\n\t\t\t\t\tif (!pinnedRoot) {\n\t\t\t\t\t\tthrow new Error('Owned host directory was not acquired by this Gondolin provider.');\n\t\t\t\t\t}\n\t\t\t\t\tassertPinnedRealFsRoot(pinnedRoot);\n\t\t\t\t\ttransfers.push(mount.directory.consume());\n\t\t\t\t\townedDirectoryRoots.delete(mount.directory);\n\t\t\t\t\ttranslatedMounts[guestPath] = {\n\t\t\t\t\t\tkind: mount.access === 'read-only' ? 'realfs-readonly' : 'realfs',\n\t\t\t\t\t\tpinnedHostRoot: pinnedRoot,\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'owned-filtered-workspace': {\n\t\t\t\t\tconst pinnedRoot = ownedDirectoryRoots.get(mount.directory);\n\t\t\t\t\tif (!pinnedRoot) {\n\t\t\t\t\t\tthrow new Error('Owned host directory was not acquired by this Gondolin provider.');\n\t\t\t\t\t}\n\t\t\t\t\tassertPinnedRealFsRoot(pinnedRoot);\n\t\t\t\t\ttransfers.push(mount.directory.consume());\n\t\t\t\t\townedDirectoryRoots.delete(mount.directory);\n\t\t\t\t\tconst policy = validateManagedVmFilteredWorkspacePolicy(mount.policy);\n\t\t\t\t\tsourceValidations.push({ pinnedRoot, policy });\n\t\t\t\t\ttranslatedMounts[guestPath] = {\n\t\t\t\t\t\tkind: 'filtered-workspace',\n\t\t\t\t\t\tpinnedHostRoot: pinnedRoot,\n\t\t\t\t\t\tpolicy,\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'memory':\n\t\t\t\t\ttranslatedMounts[guestPath] = { kind: 'memory' };\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'shadow':\n\t\t\t\t\ttranslatedMounts[guestPath] = {\n\t\t\t\t\t\thostPath: mount.hostPath,\n\t\t\t\t\t\tkind: 'shadow',\n\t\t\t\t\t\tshadowConfig: {\n\t\t\t\t\t\t\tdeny: mount.deny,\n\t\t\t\t\t\t\ttmpfs: mount.temporaryFilesystems,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tawait Promise.all(\n\t\t\tsourceValidations.map(({ pinnedRoot, policy }) =>\n\t\t\t\tassertReadonlyInputSourcesStayWithinOwnedRoot(pinnedRoot, policy),\n\t\t\t),\n\t\t);\n\t} catch (error) {\n\t\tconst closeErrors = closeOwnedDirectoryTransfers(transfers);\n\t\tif (closeErrors.length > 0) {\n\t\t\t// oxlint-disable-next-line preserve-caught-error -- AggregateError cause and errors both retain the primary translation failure.\n\t\t\tthrow new AggregateError(\n\t\t\t\t[error, ...closeErrors],\n\t\t\t\t'Managed VM mount translation and owned-directory cleanup both failed.',\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t\tthrow error;\n\t}\n\treturn { mounts: translatedMounts, transfers };\n}\n\nfunction wrapManagedVm(\n\tnativeVm: NativeManagedVm,\n\townedDirectoryTransfers: readonly OwnedHostDirectoryTransfer[],\n): ManagedVm {\n\ttype ManagedVmLifecycleState =\n\t\t| 'created'\n\t\t| 'starting'\n\t\t| 'started'\n\t\t| 'start-failed'\n\t\t| 'closing'\n\t\t| 'closed';\n\tlet closePromise: Promise<void> | undefined;\n\tlet hostProcessId: number | null = null;\n\tlet lifecycleState: ManagedVmLifecycleState = 'created';\n\tlet startPromise: Promise<void> | undefined;\n\tconst closeOnce = async (): Promise<void> => {\n\t\tif (startPromise) {\n\t\t\ttry {\n\t\t\t\tawait startPromise;\n\t\t\t} catch {\n\t\t\t\t// Mechanical close must continue after either start success or failure.\n\t\t\t}\n\t\t}\n\t\tconst closeErrors: unknown[] = [];\n\t\ttry {\n\t\t\tawait nativeVm.close();\n\t\t} catch (error) {\n\t\t\tcloseErrors.push(error);\n\t\t}\n\t\tcloseErrors.push(...closeOwnedDirectoryTransfers(ownedDirectoryTransfers));\n\t\ttry {\n\t\t\tif (closeErrors.length === 1) {\n\t\t\t\tthrow closeErrors[0];\n\t\t\t}\n\t\t\tif (closeErrors.length > 1) {\n\t\t\t\tthrow new AggregateError(closeErrors, 'Managed VM cleanup failed.');\n\t\t\t}\n\t\t} finally {\n\t\t\thostProcessId = null;\n\t\t\tlifecycleState = 'closed';\n\t\t}\n\t};\n\treturn {\n\t\tasync close(): Promise<void> {\n\t\t\tif (!closePromise) {\n\t\t\t\tlifecycleState = 'closing';\n\t\t\t\tclosePromise = closeOnce();\n\t\t\t}\n\t\t\tawait closePromise;\n\t\t},\n\t\tconfigureIngressRoutes(routes: readonly ManagedVmIngressRoute[]): void {\n\t\t\tnativeVm.setIngressRoutes(\n\t\t\t\troutes.map((route) => ({\n\t\t\t\t\tport: route.port,\n\t\t\t\t\tprefix: route.prefix,\n\t\t\t\t\tstripPrefix: route.stripPrefix,\n\t\t\t\t})),\n\t\t\t);\n\t\t},\n\t\tasync enableIngress(options?: ManagedVmIngressOptions): Promise<ManagedVmAccessHandle> {\n\t\t\treturn await nativeVm.enableIngress(options);\n\t\t},\n\t\tasync enableSsh(options): Promise<ManagedVmSshAccess> {\n\t\t\tconst access = await nativeVm.enableSsh(options);\n\t\t\tif (!access.command || !access.identityFile || !access.user) {\n\t\t\t\tawait access.close();\n\t\t\t\tthrow new Error('Gondolin SSH access omitted required neutral connection fields.');\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tclose: async (): Promise<void> => await access.close(),\n\t\t\t\tcommand: access.command,\n\t\t\t\thost: access.host,\n\t\t\t\tidentityFile: access.identityFile,\n\t\t\t\tport: access.port,\n\t\t\t\tserverHostKey: access.serverHostKey,\n\t\t\t\tuser: access.user,\n\t\t\t};\n\t\t},\n\t\tasync finalizeMemoryMount(request): Promise<void> {\n\t\t\tawait nativeVm.finalizeMemoryMount(request);\n\t\t},\n\t\texec(command: ManagedVmExecCommand, options?: ManagedVmExecOptions): ManagedVmExecProcess {\n\t\t\tconst normalizedCommand = typeof command === 'string' ? command : [...command];\n\t\t\tconst nativeProcess = nativeVm.exec(\n\t\t\t\tnormalizedCommand,\n\t\t\t\toptions ? translateExecOptions(options) : undefined,\n\t\t\t);\n\t\t\treturn wrapExecProcess(nativeProcess);\n\t\t},\n\t\tgetHostProcessId(): number | null {\n\t\t\tif (hostProcessId === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst currentHostProcessId = nativeVm.getHostPid();\n\t\t\tif (currentHostProcessId === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (currentHostProcessId !== hostProcessId) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Gondolin runner identity changed for managed VM '${nativeVm.id}': expected pid ${String(hostProcessId)}, observed ${String(currentHostProcessId)}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn hostProcessId;\n\t\t},\n\t\tid: nativeVm.id,\n\t\tasync start(): Promise<void> {\n\t\t\tif (lifecycleState === 'closing' || lifecycleState === 'closed') {\n\t\t\t\tthrow new Error('Managed VM cannot start after close has been requested.');\n\t\t\t}\n\t\t\tif (lifecycleState === 'started') {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!startPromise) {\n\t\t\t\tlifecycleState = 'starting';\n\t\t\t\tstartPromise = (async (): Promise<void> => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait nativeVm.start();\n\t\t\t\t\t\tconst startedHostProcessId = assertPositiveHostProcessId(nativeVm.getHostPid());\n\t\t\t\t\t\tif (lifecycleState !== 'starting') {\n\t\t\t\t\t\t\tthrow new Error('Managed VM closed while startup was settling.');\n\t\t\t\t\t\t}\n\t\t\t\t\t\thostProcessId = startedHostProcessId;\n\t\t\t\t\t\tlifecycleState = 'started';\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (lifecycleState === 'starting') {\n\t\t\t\t\t\t\tlifecycleState = 'start-failed';\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t}\n\t\t\tawait startPromise;\n\t\t},\n\t};\n}\n\nfunction openOwnedHostDirectory(\n\thostPath: string,\n\townedDirectoryRoots: OwnedDirectoryProvenance,\n): OwnedHostDirectory {\n\tconst pinnedRoot = pinRealFsRoot(hostPath);\n\tconst directory = createOwnedHostDirectoryController({\n\t\tidentity: {\n\t\t\tcanonicalPath: pinnedRoot.realPath,\n\t\t\tdevice: pinnedRoot.device,\n\t\t\tinode: pinnedRoot.inode,\n\t\t},\n\t\tonClose: () => closePinnedRealFsRoot(pinnedRoot),\n\t\tonConsume: () => assertPinnedRealFsRoot(pinnedRoot),\n\t});\n\townedDirectoryRoots.set(directory, pinnedRoot);\n\treturn directory;\n}\n\nexport function createGondolinManagedVmProvider(): ManagedVmProvider {\n\tconst ownedDirectoryRoots: OwnedDirectoryProvenance = new WeakMap();\n\treturn {\n\t\tdiagnostics: {\n\t\t\tasync checkCompatibility() {\n\t\t\t\tconst diagnostics = [];\n\t\t\t\ttry {\n\t\t\t\t\tawait Promise.all([resolveGondolinPackageSpec(), resolveGondolinMinimumZigVersion()]);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tdiagnostics.push({\n\t\t\t\t\t\tcode: 'gondolin-toolchain-unavailable',\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\tseverity: 'error' as const,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn diagnostics;\n\t\t\t},\n\t\t},\n\t\texactProcessTermination: createGondolinExactProcessTerminationCapability(),\n\t\tfactory: {\n\t\t\tasync createManagedVm(request: ManagedVmCreateRequest): Promise<ManagedVm> {\n\t\t\t\tassertCreateRequestSupported(request);\n\t\t\t\tconst secrets = Object.fromEntries(\n\t\t\t\t\trequest.mediatedSecrets.map((secret) => [\n\t\t\t\t\t\tsecret.environmentVariable,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thosts: [...secret.allowedHosts],\n\t\t\t\t\t\t\t...(secret.guestPlaceholder === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: { placeholder: secret.guestPlaceholder }),\n\t\t\t\t\t\t\tvalue: secret.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t\t);\n\t\t\t\tconst tcpHosts = Object.fromEntries(\n\t\t\t\t\trequest.tcpHosts.map((mapping) => [mapping.guestHost, mapping.target]),\n\t\t\t\t);\n\t\t\t\tconst translatedMounts = await translateMounts(request.mounts, ownedDirectoryRoots);\n\t\t\t\tlet nativeVm: NativeManagedVm;\n\t\t\t\ttry {\n\t\t\t\t\tnativeVm = await createNativeManagedVm({\n\t\t\t\t\t\tallowedHosts: [...request.allowedHosts],\n\t\t\t\t\t\tcpus: request.resources.cpuCount,\n\t\t\t\t\t\tenv: { ...request.environment },\n\t\t\t\t\t\timagePath: request.imageReference,\n\t\t\t\t\t\tmemory: request.resources.memory,\n\t\t\t\t\t\t...(request.mediation?.onRequest ? { onRequest: request.mediation.onRequest } : {}),\n\t\t\t\t\t\t...(request.mediation?.onResponse ? { onResponse: request.mediation.onResponse } : {}),\n\t\t\t\t\t\trootfsMode: request.rootfsMode,\n\t\t\t\t\t\t...(request.runtimeRootfsSize ? { runtimeRootfsSize: request.runtimeRootfsSize } : {}),\n\t\t\t\t\t\tsecrets,\n\t\t\t\t\t\tsessionLabel: request.sessionLabel,\n\t\t\t\t\t\t...(request.sshEgress\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tsshEgress: createGitReadOnlySshEgressOptions({\n\t\t\t\t\t\t\t\t\t\tallowedHosts: request.sshEgress.allowedHosts,\n\t\t\t\t\t\t\t\t\t\t...(request.sshEgress.agentSocket\n\t\t\t\t\t\t\t\t\t\t\t? { agent: request.sshEgress.agentSocket }\n\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t\t...(request.sshEgress.allowedRepositories\n\t\t\t\t\t\t\t\t\t\t\t? { allowedRepos: request.sshEgress.allowedRepositories }\n\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t\t...(request.sshEgress.knownHostsFile\n\t\t\t\t\t\t\t\t\t\t\t? { knownHostsFile: request.sshEgress.knownHostsFile }\n\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\ttcpHosts,\n\t\t\t\t\t\tvfsMounts: translatedMounts.mounts,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst closeErrors = closeOwnedDirectoryTransfers(translatedMounts.transfers);\n\t\t\t\t\tif (closeErrors.length > 0) {\n\t\t\t\t\t\t// oxlint-disable-next-line preserve-caught-error -- AggregateError cause and errors both retain the primary construction failure.\n\t\t\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t\t\t[error, ...closeErrors],\n\t\t\t\t\t\t\t'Managed VM construction and owned-directory cleanup both failed.',\n\t\t\t\t\t\t\t{ cause: error },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\treturn wrapManagedVm(nativeVm, translatedMounts.transfers);\n\t\t\t},\n\t\t},\n\t\timages: {\n\t\t\tasync prepareImage(request) {\n\t\t\t\tconst parseErrors: ParseError[] = [];\n\t\t\t\tconst parsedRecipe: unknown = parse(\n\t\t\t\t\tawait fs.readFile(request.recipePath, 'utf8'),\n\t\t\t\t\tparseErrors,\n\t\t\t\t\t{ allowTrailingComma: true },\n\t\t\t\t);\n\t\t\t\tif (parseErrors.length > 0) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Invalid managed VM image recipe '${request.recipePath}': ${parseErrors\n\t\t\t\t\t\t\t.map((parseError) => printParseErrorCode(parseError.error))\n\t\t\t\t\t\t\t.join(', ')}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!isRecord(parsedRecipe) || !validateBuildConfig(parsedRecipe)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Managed VM image recipe has an invalid build shape: ${request.recipePath}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst result = await buildImage({\n\t\t\t\t\tbuildConfig: parsedRecipe,\n\t\t\t\t\tcacheDir: request.cacheDirectory,\n\t\t\t\t\tconfigDir: path.dirname(request.recipePath),\n\t\t\t\t\t...(request.forceRebuild === undefined ? {} : { fullReset: request.forceRebuild }),\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tbuilt: result.built,\n\t\t\t\t\tfingerprint: result.fingerprint,\n\t\t\t\t\timageReference: result.imagePath,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\townedDirectories: {\n\t\t\topenHostDirectory: (hostPath: string): OwnedHostDirectory =>\n\t\t\t\topenOwnedHostDirectory(hostPath, ownedDirectoryRoots),\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;AAKA,MAAa,+BAA+B;;;;;;;;;;;AA6C5C,MAAM,qCAAqC;AAC3C,MAAM,oCAAoC;AAC1C,MAAM,4BAA4B;AAClC,MAAM,wBAAwB;AAE9B,SAAS,qBACR,oBACS;CACT,QAAQ,oBAAR;EACC,KAAK,4BACJ,OAAO;EACR,KAAK,8BACJ,OAAO;;;AAIV,SAAS,qBACR,oBACS;CACT,OAAO,uBAAuB,+BAC3B,yBACA;;AAGJ,SAAgB,qCACf,YACS;CACT,MAAM,+BAA+B,qBAAqB,WAAW,mBAAmB;CACxF,MAAM,2BAA2B,GAAG,sBAAsB,GAAG,qBAAqB,WAAW,mBAAmB;CAChH,MAAM,8BAA8B;CACpC,MAAM,oCACL,WAAW,uBAAuB,6BAA6B,qBAAqB;CACrF,OAAO;yCACiC,mCAAmC;wCACpC,kCAAkC;WAC/D,sBAAsB;qBACZ,0BAA0B;4BACnB,sBAAsB;4BACtB,yBAAyB;;;;;;SAM5C,kCAAkC,wBAAwB,mCAAmC,wDAAwD,mCAAmC,gGAAgG,kCAAkC;OAC5T,sBAAsB;;;sCAGS,4BAA4B;;;SAGzD,kCAAkC,wBAAwB,mCAAmC,sDAAsD,mCAAmC,6CAA6C,6BAA6B;OAClQ,yBAAyB;;;AAIhC,SAAS,uBAAuB,UAAkB,WAAuC;CACxF,OAAO,KAAK,WAAW,SAAS,GAAG,WAAW,KAAK,QAAQ,aAAa,QA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,SAAS;GAC3B,MAAM,cAA4B,EAAE;GACpC,MAAM,eAAwB,MAC7B,MAAM,GAAG,SAAS,QAAQ,YAAY,OAAO,EAC7C,aACA,EAAE,oBAAoB,MAAM,CAC5B;GACD,IAAI,YAAY,SAAS,GACxB,MAAM,IAAI,MACT,oCAAoC,QAAQ,WAAW,KAAK,YAC1D,KAAK,eAAe,oBAAoB,WAAW,MAAM,CAAC,CAC1D,KAAK,KAAK,GACZ;GAEF,IAAI,CAAC,SAAS,aAAa,IAAI,CAAC,oBAAoB,aAAa,EAChE,MAAM,IAAI,MACT,uDAAuD,QAAQ,aAC/D;GAEF,MAAM,SAAS,MAAM,WAAW;IAC/B,aAAa;IACb,UAAU,QAAQ;IAClB,WAAW,KAAK,QAAQ,QAAQ,WAAW;IAC3C,GAAI,QAAQ,iBAAiB,KAAA,IAAY,EAAE,GAAG,EAAE,WAAW,QAAQ,cAAc;IACjF,CAAC;GACF,OAAO;IACN,OAAO,OAAO;IACd,aAAa,OAAO;IACpB,gBAAgB,OAAO;IACvB;KAEF;EACD,kBAAkB,EACjB,oBAAoB,aACnB,uBAAuB,UAAU,oBAAoB,EACtD;EACD"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["isRecord","fs","net","createNativeManagedVm"],"sources":["../src/rootfs-init-extra.ts","../src/build-pipeline.ts","../src/exact-recorded-process-termination.ts","../src/gondolin-package.ts","../src/pinned-realfs.ts","../src/filtered-workspace-provider.ts","../src/host-network-defaults.ts","../src/vm-adapter.ts","../src/managed-vm-provider.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport type { BuildConfig } from '@earendil-works/gondolin';\n\nexport const agentVmRootfsInitExtraScript = `# Generated by agent-vm.\n# Gondolin mounts devtmpfs over /dev at boot, so Docker-image /dev symlinks are hidden.\nmkdir -p /dev\nln -sfn /proc/self/fd /dev/fd 2>/dev/null || true\nln -sfn /proc/self/fd/0 /dev/stdin 2>/dev/null || true\nln -sfn /proc/self/fd/1 /dev/stdout 2>/dev/null || true\nln -sfn /proc/self/fd/2 /dev/stderr 2>/dev/null || true\nif [ ! -e /dev/ptmx ] && [ -e /dev/pts/ptmx ]; then\n ln -sfn pts/ptmx /dev/ptmx 2>/dev/null || true\nfi\n`;\n\ninterface PrepareRootfsInitExtraOptions {\n\treadonly buildConfig: BuildConfig;\n\treadonly imagePath: string;\n\treadonly rootfsInitExtraContent: string;\n}\n\ninterface ResolveRootfsInitExtraOptions {\n\treadonly buildConfig: BuildConfig;\n\treadonly configDir?: string;\n\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n}\n\n/**\n * Backend projection of the domain-owned managed Gateway boot contract.\n *\n * The projection is deliberately closed: callers select the framework image\n * entry, while executable paths, arguments, environment-input paths, and log\n * identities remain adapter-owned image behavior.\n */\nexport interface GondolinManagedGatewayBootProjection {\n\treadonly frameworkBootEntry: 'hermes-framework-service' | 'openclaw-framework-service';\n\treadonly kind: 'managed-gateway-exact-two-role';\n}\n\nexport interface ResolvedRootfsInitExtra {\n\treadonly content: string;\n\treadonly fingerprintInput: {\n\t\treadonly agentVmRootfsInitExtra: string;\n\t\treadonly deploymentRootfsInitExtra?: string;\n\t\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n\t};\n}\n\nconst managedGatewayEnvironmentInputRoot = '/run/agent-vm/managed-gateway-environment';\nconst managedGatewayStructuredInputRoot = '/run/agent-vm/managed-gateway';\nconst managedGatewayRuntimeRoot = '/run/agent-vm/gateway-runtime';\nconst managedGatewayLogRoot = '/var/log/agent-vm';\n\nfunction frameworkBootCommand(\n\tframeworkBootEntry: GondolinManagedGatewayBootProjection['frameworkBootEntry'],\n): string {\n\tswitch (frameworkBootEntry) {\n\t\tcase 'hermes-framework-service':\n\t\t\treturn '/usr/local/bin/agent-vm-hermes-gateway';\n\t\tcase 'openclaw-framework-service':\n\t\t\treturn '/usr/local/bin/openclaw gateway --port 18789';\n\t}\n}\n\nfunction frameworkLogFileName(\n\tframeworkBootEntry: GondolinManagedGatewayBootProjection['frameworkBootEntry'],\n): string {\n\treturn frameworkBootEntry === 'openclaw-framework-service'\n\t\t? 'openclaw-service.log'\n\t\t: 'hermes-service.log';\n}\n\nexport function renderManagedGatewayRootfsInitScript(\n\tprojection: GondolinManagedGatewayBootProjection,\n): string {\n\tconst selectedFrameworkBootCommand = frameworkBootCommand(projection.frameworkBootEntry);\n\tconst selectedFrameworkLogPath = `${managedGatewayLogRoot}/${frameworkLogFileName(projection.frameworkBootEntry)}`;\n\tconst frameworkBootInputFileNames = 'framework-service.json';\n\tconst serviceEnvironmentIsolationPrefix =\n\t\tprojection.frameworkBootEntry === 'hermes-framework-service' ? '/usr/bin/env -i ' : '';\n\treturn `# Fixed managed Gateway sibling boot entries.\nmanaged_gateway_environment_input_root=${managedGatewayEnvironmentInputRoot}\nmanaged_gateway_structured_input_root=${managedGatewayStructuredInputRoot}\nmkdir -p ${managedGatewayLogRoot}\ninstall -d -m 0700 ${managedGatewayRuntimeRoot}\ninstall -m 0600 /dev/null ${managedGatewayLogRoot}/tool-portal-service.log\ninstall -m 0600 /dev/null ${selectedFrameworkLogPath}\n(\n if [ ! -f \"$managed_gateway_environment_input_root/tool-portal.environment.sh\" ]; then exit 78; fi\n for managed_gateway_input_name in tool-portal-service.json mcp.config.json; do\n if [ ! -f \"$managed_gateway_structured_input_root/$managed_gateway_input_name\" ]; then exit 78; fi\n done\n exec ${serviceEnvironmentIsolationPrefix}/bin/sh -c 'set -a; . ${managedGatewayEnvironmentInputRoot}/tool-portal.environment.sh || exit 78; set +a; rm -- ${managedGatewayEnvironmentInputRoot}/tool-portal.environment.sh || exit 78; exec /usr/local/bin/agent-vm-gateway-runtime --config ${managedGatewayStructuredInputRoot}/tool-portal-service.json'\n) >> ${managedGatewayLogRoot}/tool-portal-service.log 2>&1 &\n(\n if [ ! -f \"$managed_gateway_environment_input_root/framework.environment.sh\" ]; then exit 78; fi\n for managed_gateway_input_name in ${frameworkBootInputFileNames}; do\n if [ ! -f \"$managed_gateway_structured_input_root/$managed_gateway_input_name\" ]; then exit 78; fi\n done\n exec ${serviceEnvironmentIsolationPrefix}/bin/sh -c 'set -a; . ${managedGatewayEnvironmentInputRoot}/framework.environment.sh || exit 78; set +a; rm -- ${managedGatewayEnvironmentInputRoot}/framework.environment.sh || exit 78; exec ${selectedFrameworkBootCommand}'\n) >> ${selectedFrameworkLogPath} 2>&1 &\n`;\n}\n\nfunction resolveBuildConfigPath(filePath: string, configDir: string | undefined): string {\n\treturn path.isAbsolute(filePath) ? filePath : path.resolve(configDir ?? process.cwd(), filePath);\n}\n\nasync function readExistingRootfsInitExtra(\n\tbuildConfig: BuildConfig,\n\tconfigDir: string | undefined,\n): Promise<string | undefined> {\n\tconst existingRootfsInitExtra = buildConfig.init?.rootfsInitExtra;\n\tif (!existingRootfsInitExtra) {\n\t\treturn undefined;\n\t}\n\n\tconst resolvedRootfsInitExtra = resolveBuildConfigPath(existingRootfsInitExtra, configDir);\n\ttry {\n\t\treturn await fs.readFile(resolvedRootfsInitExtra, 'utf8');\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(\n\t\t\t`Failed to read Gondolin rootfs init extra '${resolvedRootfsInitExtra}': ${message}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n}\n\nfunction composeRootfsInitExtra(existingRootfsInitExtra: string | undefined): string {\n\treturn existingRootfsInitExtra\n\t\t? `${agentVmRootfsInitExtraScript.trimEnd()}\\n\\n${existingRootfsInitExtra}`\n\t\t: agentVmRootfsInitExtraScript;\n}\n\nexport async function resolveRootfsInitExtra(\n\toptions: ResolveRootfsInitExtraOptions,\n): Promise<ResolvedRootfsInitExtra> {\n\tif (options.managedGatewayBoot !== undefined && options.buildConfig.init?.rootfsInitExtra) {\n\t\tthrow new Error(\n\t\t\t'Managed Gateway images cannot compose deployment-authored rootfs init authority.',\n\t\t);\n\t}\n\tconst existingRootfsInitExtra = await readExistingRootfsInitExtra(\n\t\toptions.buildConfig,\n\t\toptions.configDir,\n\t);\n\tconst managedGatewayRootfsInitExtra =\n\t\toptions.managedGatewayBoot === undefined\n\t\t\t? undefined\n\t\t\t: renderManagedGatewayRootfsInitScript(options.managedGatewayBoot);\n\tconst composedRootfsInitExtra = composeRootfsInitExtra(existingRootfsInitExtra);\n\n\treturn {\n\t\tcontent:\n\t\t\tmanagedGatewayRootfsInitExtra === undefined\n\t\t\t\t? composedRootfsInitExtra\n\t\t\t\t: `${composedRootfsInitExtra.trimEnd()}\\n\\n${managedGatewayRootfsInitExtra}`,\n\t\tfingerprintInput: {\n\t\t\tagentVmRootfsInitExtra: agentVmRootfsInitExtraScript,\n\t\t\t...(existingRootfsInitExtra === undefined\n\t\t\t\t? {}\n\t\t\t\t: { deploymentRootfsInitExtra: existingRootfsInitExtra }),\n\t\t\t...(options.managedGatewayBoot === undefined\n\t\t\t\t? {}\n\t\t\t\t: { managedGatewayBoot: options.managedGatewayBoot }),\n\t\t},\n\t};\n}\n\nexport async function prepareBuildConfigWithAgentVmRootfsInitExtra(\n\toptions: PrepareRootfsInitExtraOptions,\n): Promise<BuildConfig> {\n\tconst rootfsInitExtraPath = path.join(options.imagePath, 'agent-vm-rootfs-init-extra.sh');\n\n\tawait fs.writeFile(rootfsInitExtraPath, options.rootfsInitExtraContent, {\n\t\tencoding: 'utf8',\n\t\tmode: 0o755,\n\t});\n\n\treturn {\n\t\t...options.buildConfig,\n\t\tinit: {\n\t\t\t...options.buildConfig.init,\n\t\t\trootfsInitExtra: rootfsInitExtraPath,\n\t\t},\n\t};\n}\n","import crypto from 'node:crypto';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport type { BuildConfig, BuildOptions } from '@earendil-works/gondolin';\nimport { validateBuildConfig } from '@earendil-works/gondolin';\n\nimport {\n\tprepareBuildConfigWithAgentVmRootfsInitExtra,\n\tresolveRootfsInitExtra,\n\ttype GondolinManagedGatewayBootProjection,\n} from './rootfs-init-extra.js';\n\nexport type { BuildConfig } from '@earendil-works/gondolin';\n\nexport interface BuildImageOptions {\n\treadonly buildConfig: BuildConfig;\n\treadonly cacheDir: string;\n\t/** Directory to resolve relative paths in buildConfig (e.g. postBuild.copy.src).\n\t * Defaults to process.cwd() if not provided. */\n\treadonly configDir?: string;\n\treadonly fullReset?: boolean;\n\treadonly fingerprintInput?: unknown;\n\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n\treadonly output?: BuildOutput;\n}\n\nexport interface BuildOutput {\n\twrite(chunk: string | Uint8Array): boolean;\n}\n\nexport interface BuildImageResult {\n\treadonly built: boolean;\n\treadonly fingerprint: string;\n\treadonly imagePath: string;\n}\n\nexport interface GondolinImageBuildToolingOptions {\n\treadonly buildConfig: unknown;\n\treadonly cacheDir: string;\n\treadonly configDir?: string;\n\treadonly fullReset?: boolean;\n\treadonly fingerprintInput?: unknown;\n\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n\treadonly output?: BuildOutput;\n}\n\nexport interface GondolinImageFingerprintOptions {\n\treadonly buildConfig: unknown;\n\treadonly configDir?: string;\n\treadonly fingerprintInput?: unknown;\n\treadonly gondolinVersion?: string;\n\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n}\n\nexport interface GondolinImageBuildTooling {\n\tbuildImage(\n\t\toptions: GondolinImageBuildToolingOptions,\n\t\tdependencies?: { readonly gondolinVersion?: string },\n\t): Promise<BuildImageResult>;\n\tcomputeFingerprint(options: GondolinImageFingerprintOptions): Promise<string>;\n}\n\nexport const buildImageAssetFileNames = [\n\t'manifest.json',\n\t'rootfs.ext4',\n\t'initramfs.cpio.lz4',\n\t'vmlinuz-virt',\n] as const;\n\nfunction requireValidBuildConfig(buildConfig: unknown): BuildConfig {\n\tif (!validateBuildConfig(buildConfig)) {\n\t\tthrow new Error('Managed VM image recipe has an invalid build shape.');\n\t}\n\treturn buildConfig;\n}\n\nexport function createGondolinImageBuildTooling(): GondolinImageBuildTooling {\n\treturn {\n\t\tasync buildImage(options, dependencies) {\n\t\t\treturn await buildImage(\n\t\t\t\t{\n\t\t\t\t\t...options,\n\t\t\t\t\tbuildConfig: requireValidBuildConfig(options.buildConfig),\n\t\t\t\t},\n\t\t\t\tdependencies,\n\t\t\t);\n\t\t},\n\t\tasync computeFingerprint(options) {\n\t\t\tconst result = await computeEffectiveBuildFingerprint({\n\t\t\t\t...options,\n\t\t\t\tbuildConfig: requireValidBuildConfig(options.buildConfig),\n\t\t\t});\n\t\t\treturn result.fingerprint;\n\t\t},\n\t};\n}\n\ninterface BuildPipelineDependencies {\n\treadonly buildAssets?: (\n\t\tbuildConfig: BuildConfig,\n\t\toutputDirectory: string,\n\t\tconfigDir?: string,\n\t\tworkDir?: string,\n\t\tverbose?: boolean,\n\t) => Promise<unknown>;\n\treadonly gondolinVersion?: string;\n}\n\nconst inFlightImageBuilds = new Map<string, Promise<BuildImageResult>>();\nconst gondolinWorkDirectoryName = '.agent-vm-gondolin-work';\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null;\n}\n\nfunction stableSerialize(value: unknown): string {\n\tif (Array.isArray(value)) {\n\t\treturn `[${value.map((entry) => stableSerialize(entry)).join(',')}]`;\n\t}\n\n\tif (isRecord(value)) {\n\t\tconst objectEntries = Object.entries(value)\n\t\t\t.filter(([, entryValue]) => entryValue !== undefined)\n\t\t\t.toSorted(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey));\n\t\treturn `{${objectEntries\n\t\t\t.map(([entryKey, entryValue]) => `${JSON.stringify(entryKey)}:${stableSerialize(entryValue)}`)\n\t\t\t.join(',')}}`;\n\t}\n\n\treturn JSON.stringify(value);\n}\n\nfunction isMissingPathError(error: unknown): boolean {\n\treturn typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';\n}\n\nasync function pathExists(filePath: string): Promise<boolean> {\n\ttry {\n\t\tawait fs.access(filePath);\n\t\treturn true;\n\t} catch (error) {\n\t\tif (!isMissingPathError(error)) {\n\t\t\tthrow error;\n\t\t}\n\t\treturn false;\n\t}\n}\n\nexport async function hasBuiltImageAssets(outputDirectoryPath: string): Promise<boolean> {\n\tfor (const fileName of buildImageAssetFileNames) {\n\t\t// oxlint-disable-next-line no-await-in-loop -- each missing file points at the same image generation\n\t\tif (!(await pathExists(path.join(outputDirectoryPath, fileName)))) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nasync function loadBuildAssets(): Promise<\n\t(\n\t\tbuildConfig: BuildConfig,\n\t\toutputDirectory: string,\n\t\tconfigDir?: string,\n\t\tworkDir?: string,\n\t\tverbose?: boolean,\n\t) => Promise<unknown>\n> {\n\tconst gondolinModule = await import('@earendil-works/gondolin');\n\treturn async (\n\t\tbuildConfig: BuildConfig,\n\t\toutputDirectory: string,\n\t\tconfigDir?: string,\n\t\tworkDir?: string,\n\t\tverbose?: boolean,\n\t): Promise<unknown> =>\n\t\tawait gondolinModule.buildAssets(buildConfig, {\n\t\t\toutputDir: outputDirectory,\n\t\t\tverbose: verbose ?? false,\n\t\t\t...(configDir ? { configDir } : {}),\n\t\t\t...(workDir ? { workDir } : {}),\n\t\t} satisfies BuildOptions);\n}\n\nfunction createRedirectedWrite(output: BuildOutput): typeof process.stderr.write {\n\treturn ((\n\t\tchunk: string | Uint8Array,\n\t\tencodingOrCallback?: BufferEncoding | ((error?: Error | null) => void),\n\t\tcallback?: (error?: Error | null) => void,\n\t): boolean => {\n\t\tconst writeCallback = typeof encodingOrCallback === 'function' ? encodingOrCallback : callback;\n\t\tconst wrote = output.write(chunk);\n\t\twriteCallback?.();\n\t\treturn wrote;\n\t}) as typeof process.stderr.write;\n}\n\nasync function withCapturedBuildOutput<TResult>(\n\toutput: BuildOutput | undefined,\n\tfn: () => Promise<TResult>,\n): Promise<TResult> {\n\tif (!output) {\n\t\treturn await fn();\n\t}\n\n\tconst originalStderrWrite = process.stderr.write.bind(process.stderr);\n\tconst originalStdoutWrite = process.stdout.write.bind(process.stdout);\n\tconst originalCi = process.env.CI;\n\tconst redirectedWrite = createRedirectedWrite(output);\n\n\tprocess.stderr.write = redirectedWrite;\n\tprocess.stdout.write = redirectedWrite;\n\tprocess.env.CI = 'true';\n\n\ttry {\n\t\treturn await fn();\n\t} finally {\n\t\tprocess.stderr.write = originalStderrWrite;\n\t\tprocess.stdout.write = originalStdoutWrite;\n\t\tif (originalCi === undefined) {\n\t\t\tdelete process.env.CI;\n\t\t} else {\n\t\t\tprocess.env.CI = originalCi;\n\t\t}\n\t}\n}\n\nexport function computeBuildFingerprint(\n\tbuildConfig: BuildConfig,\n\tgondolinVersion: string = 'unknown',\n\tfingerprintInput?: unknown,\n): string {\n\tconst payload =\n\t\tfingerprintInput === undefined\n\t\t\t? `${stableSerialize(buildConfig)}|${gondolinVersion}`\n\t\t\t: `${stableSerialize(buildConfig)}|${gondolinVersion}|${stableSerialize(fingerprintInput)}`;\n\n\treturn crypto.createHash('sha256').update(payload).digest('hex').slice(0, 16);\n}\n\nexport async function computeEffectiveBuildFingerprint(options: {\n\treadonly buildConfig: BuildConfig;\n\treadonly configDir?: string;\n\treadonly fingerprintInput?: unknown;\n\treadonly gondolinVersion?: string;\n\treadonly managedGatewayBoot?: GondolinManagedGatewayBootProjection;\n}): Promise<{\n\treadonly fingerprint: string;\n\treadonly rootfsInitExtraContent: string;\n}> {\n\tconst resolvedRootfsInitExtra = await resolveRootfsInitExtra({\n\t\tbuildConfig: options.buildConfig,\n\t\t...(options.configDir ? { configDir: options.configDir } : {}),\n\t\t...(options.managedGatewayBoot === undefined\n\t\t\t? {}\n\t\t\t: { managedGatewayBoot: options.managedGatewayBoot }),\n\t});\n\tconst fingerprint = computeBuildFingerprint(options.buildConfig, options.gondolinVersion, {\n\t\tagentVmRootfsInitExtra: resolvedRootfsInitExtra.fingerprintInput,\n\t\t...(options.fingerprintInput === undefined\n\t\t\t? {}\n\t\t\t: { callerFingerprintInput: options.fingerprintInput }),\n\t});\n\n\treturn {\n\t\tfingerprint,\n\t\trootfsInitExtraContent: resolvedRootfsInitExtra.content,\n\t};\n}\n\nexport async function buildImage(\n\toptions: BuildImageOptions,\n\tdependencies: BuildPipelineDependencies = {},\n): Promise<BuildImageResult> {\n\tconst effectiveBuildFingerprint = await computeEffectiveBuildFingerprint({\n\t\tbuildConfig: options.buildConfig,\n\t\t...(options.configDir ? { configDir: options.configDir } : {}),\n\t\t...(options.fingerprintInput === undefined\n\t\t\t? {}\n\t\t\t: { fingerprintInput: options.fingerprintInput }),\n\t\t...(options.managedGatewayBoot === undefined\n\t\t\t? {}\n\t\t\t: { managedGatewayBoot: options.managedGatewayBoot }),\n\t\t...(dependencies.gondolinVersion ? { gondolinVersion: dependencies.gondolinVersion } : {}),\n\t});\n\tconst fingerprint = effectiveBuildFingerprint.fingerprint;\n\tconst imagePath = path.join(options.cacheDir, fingerprint);\n\tconst buildImageForFingerprint = async (): Promise<BuildImageResult> => {\n\t\tif (options.fullReset) {\n\t\t\tawait fs.rm(imagePath, { recursive: true, force: true });\n\t\t}\n\n\t\tif (await hasBuiltImageAssets(imagePath)) {\n\t\t\treturn {\n\t\t\t\tbuilt: false,\n\t\t\t\tfingerprint,\n\t\t\t\timagePath,\n\t\t\t};\n\t\t}\n\n\t\tawait fs.mkdir(imagePath, { recursive: true });\n\t\tconst buildAssetsImplementation = dependencies.buildAssets ?? (await loadBuildAssets());\n\t\tconst effectiveBuildConfig = await prepareBuildConfigWithAgentVmRootfsInitExtra({\n\t\t\tbuildConfig: options.buildConfig,\n\t\t\timagePath,\n\t\t\trootfsInitExtraContent: effectiveBuildFingerprint.rootfsInitExtraContent,\n\t\t});\n\t\tconst gondolinWorkDir = path.join(imagePath, gondolinWorkDirectoryName);\n\t\tawait fs.rm(gondolinWorkDir, { recursive: true, force: true });\n\t\ttry {\n\t\t\tawait withCapturedBuildOutput(options.output, async () => {\n\t\t\t\tawait buildAssetsImplementation(\n\t\t\t\t\teffectiveBuildConfig,\n\t\t\t\t\timagePath,\n\t\t\t\t\toptions.configDir,\n\t\t\t\t\tgondolinWorkDir,\n\t\t\t\t\toptions.output !== undefined,\n\t\t\t\t);\n\t\t\t});\n\t\t} finally {\n\t\t\tawait fs.rm(gondolinWorkDir, { recursive: true, force: true });\n\t\t}\n\n\t\tif (!(await hasBuiltImageAssets(imagePath))) {\n\t\t\tthrow new Error(`Expected Gondolin assets to be written to ${imagePath}.`);\n\t\t}\n\n\t\treturn {\n\t\t\tbuilt: true,\n\t\t\tfingerprint,\n\t\t\timagePath,\n\t\t};\n\t};\n\n\tif (options.output) {\n\t\treturn await buildImageForFingerprint();\n\t}\n\n\tconst inFlightKey = path.resolve(imagePath);\n\tconst existingBuild = inFlightImageBuilds.get(inFlightKey);\n\tif (existingBuild) {\n\t\treturn await existingBuild;\n\t}\n\tconst buildPromise = buildImageForFingerprint();\n\tinFlightImageBuilds.set(inFlightKey, buildPromise);\n\ttry {\n\t\treturn await buildPromise;\n\t} finally {\n\t\tif (inFlightImageBuilds.get(inFlightKey) === buildPromise) {\n\t\t\tinFlightImageBuilds.delete(inFlightKey);\n\t\t}\n\t}\n}\n","import { execFile } from 'node:child_process';\nimport { basename } from 'node:path';\nimport { promisify } from 'node:util';\n\nimport type {\n\tManagedVmExactProcessTerminationCapability,\n\tManagedVmExactProcessTerminationOutcome,\n\tManagedVmHostProcessIdentity,\n} from '@agent-vm/managed-vm';\n\nconst execFileAsync = promisify(execFile);\nconst terminationStageTimeoutMs = 2_000;\nconst processIdentityPollIntervalMs = 100;\nconst darwinProcessCommandNameLimit = 16;\nconst linuxTaskCommandNameLimit = 15;\n\nexport interface GondolinHostProcessIdentity {\n\treadonly command: string;\n\treadonly processState: string;\n\treadonly processStartIdentity: string;\n}\n\nexport interface GondolinProcessTerminationDependencies {\n\treadonly now: () => number;\n\treadonly readProcessIdentity: (\n\t\thostProcessId: number,\n\t) => Promise<GondolinHostProcessIdentity | null>;\n\treadonly sendSignal: (hostProcessId: number, signal: NodeJS.Signals) => void;\n\treadonly sleep: (delayMs: number) => Promise<void>;\n}\n\ntype RecordedProcessObservation = 'absent' | 'exact';\ntype RecordedProcessObservationMode = 'after-signal' | 'before-signal';\n\nfunction processErrorCode(error: unknown): unknown {\n\treturn typeof error === 'object' && error !== null && 'code' in error ? error.code : undefined;\n}\n\nfunction isManagedVmHostCommand(command: string): boolean {\n\treturn /\\b(qemu-system|krun)\\b/u.test(command);\n}\n\nfunction isMatchingDarwinFallbackCommand(options: {\n\treadonly currentCommand: string;\n\treadonly recordedCommand: string;\n}): boolean {\n\tconst fallbackCommandMatch = /^\\(([^()]+)\\)$/u.exec(options.currentCommand);\n\tif (fallbackCommandMatch === null) {\n\t\treturn false;\n\t}\n\tconst recordedExecutable = options.recordedCommand.split(/[ \\t]/u, 1)[0];\n\tif (recordedExecutable === undefined || recordedExecutable.length === 0) {\n\t\treturn false;\n\t}\n\treturn (\n\t\tfallbackCommandMatch[1] === basename(recordedExecutable).slice(0, darwinProcessCommandNameLimit)\n\t);\n}\n\nfunction isMatchingLinuxTaskFallbackCommand(options: {\n\treadonly currentCommand: string;\n\treadonly recordedCommand: string;\n}): boolean {\n\tconst fallbackCommandMatch = /^\\[([^\\r\\n]+)\\]$/u.exec(options.currentCommand);\n\tif (fallbackCommandMatch === null) {\n\t\treturn false;\n\t}\n\tconst recordedExecutable = options.recordedCommand.split(/[ \\t]/u, 1)[0];\n\tif (recordedExecutable === undefined || recordedExecutable.length === 0) {\n\t\treturn false;\n\t}\n\treturn (\n\t\tfallbackCommandMatch[1] === basename(recordedExecutable).slice(0, linuxTaskCommandNameLimit)\n\t);\n}\n\nfunction findProcessCommandBoundary(processDescription: string): number | null {\n\tlet tokenCount = 0;\n\tlet insideToken = false;\n\tfor (let index = 0; index < processDescription.length; index += 1) {\n\t\tconst character = processDescription[index];\n\t\tconst isWhitespace = character === ' ' || character === '\\t';\n\t\tif (!isWhitespace && !insideToken) {\n\t\t\tinsideToken = true;\n\t\t} else if (isWhitespace && insideToken) {\n\t\t\tinsideToken = false;\n\t\t\ttokenCount += 1;\n\t\t\tif (tokenCount === 5) {\n\t\t\t\treturn index;\n\t\t\t}\n\t\t}\n\t}\n\treturn null;\n}\n\nfunction parseProcessIdentityOutput(\n\thostProcessId: number,\n\tprocessDescription: string,\n): GondolinHostProcessIdentity {\n\tconst trimmedDescription = processDescription.trim();\n\tconst processStateBoundary = trimmedDescription.search(/[ \\t]/u);\n\tif (processStateBoundary === -1) {\n\t\tthrow new Error(\n\t\t\t`Unable to confirm host process identity for pid ${String(hostProcessId)} because ps returned malformed identity output.`,\n\t\t);\n\t}\n\tconst processState = trimmedDescription.slice(0, processStateBoundary).trim();\n\tconst startAndCommandDescription = trimmedDescription.slice(processStateBoundary).trim();\n\tconst commandBoundary = findProcessCommandBoundary(startAndCommandDescription);\n\tif (commandBoundary === null) {\n\t\tthrow new Error(\n\t\t\t`Unable to confirm host process identity for pid ${String(hostProcessId)} because ps returned malformed identity output.`,\n\t\t);\n\t}\n\tconst processStartIdentity = startAndCommandDescription.slice(0, commandBoundary).trim();\n\tconst command = startAndCommandDescription.slice(commandBoundary).trim();\n\tif (processState.length === 0 || processStartIdentity.length === 0 || command.length === 0) {\n\t\tthrow new Error(\n\t\t\t`Unable to confirm host process identity for pid ${String(hostProcessId)} because ps omitted the process state, start, or command.`,\n\t\t);\n\t}\n\treturn { command, processStartIdentity, processState };\n}\n\nasync function readGondolinHostProcessIdentity(\n\thostProcessId: number,\n): Promise<GondolinHostProcessIdentity | null> {\n\ttry {\n\t\tconst { stdout } = await execFileAsync('ps', [\n\t\t\t'-p',\n\t\t\tString(hostProcessId),\n\t\t\t'-o',\n\t\t\t'state=',\n\t\t\t'-o',\n\t\t\t'lstart=',\n\t\t\t'-o',\n\t\t\t'command=',\n\t\t]);\n\t\tif (stdout.trim().length === 0) {\n\t\t\tthrow new Error(\n\t\t\t\t`Unable to confirm host process identity for pid ${String(hostProcessId)} because ps returned empty output.`,\n\t\t\t);\n\t\t}\n\t\treturn parseProcessIdentityOutput(hostProcessId, stdout);\n\t} catch (error) {\n\t\tif (processErrorCode(error) === 1) {\n\t\t\treturn null;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nfunction sendHostProcessSignal(hostProcessId: number, signal: NodeJS.Signals): void {\n\tprocess.kill(hostProcessId, signal);\n}\n\nasync function sleep(delayMs: number): Promise<void> {\n\tawait new Promise((resolve) => setTimeout(resolve, delayMs));\n}\n\nconst defaultDependencies = {\n\tnow: Date.now,\n\treadProcessIdentity: readGondolinHostProcessIdentity,\n\tsendSignal: sendHostProcessSignal,\n\tsleep,\n} satisfies GondolinProcessTerminationDependencies;\n\nfunction assertTerminationRequest(request: {\n\treadonly contextLabel: string;\n\treadonly identity: ManagedVmHostProcessIdentity;\n}): void {\n\tif (request.contextLabel.trim().length === 0) {\n\t\tthrow new Error('Exact managed VM process termination requires a non-empty context label.');\n\t}\n\tif (\n\t\t!Number.isSafeInteger(request.identity.hostProcessId) ||\n\t\trequest.identity.hostProcessId <= 0\n\t) {\n\t\tthrow new Error('Exact managed VM process termination requires a positive safe host pid.');\n\t}\n\tif (\n\t\trequest.identity.vmId.length === 0 ||\n\t\trequest.identity.processStartIdentity.length === 0 ||\n\t\trequest.identity.command.length === 0\n\t) {\n\t\tthrow new Error('Exact managed VM process termination requires complete recorded identity.');\n\t}\n}\n\nasync function observeRecordedProcess(options: {\n\treadonly action: string;\n\treadonly contextLabel: string;\n\treadonly dependencies: GondolinProcessTerminationDependencies;\n\treadonly identity: ManagedVmHostProcessIdentity;\n\treadonly mode: RecordedProcessObservationMode;\n}): Promise<RecordedProcessObservation> {\n\tconst currentIdentity = await options.dependencies.readProcessIdentity(\n\t\toptions.identity.hostProcessId,\n\t);\n\tif (currentIdentity === null) {\n\t\treturn 'absent';\n\t}\n\tif (currentIdentity.processStartIdentity !== options.identity.processStartIdentity) {\n\t\treturn 'absent';\n\t}\n\tif (currentIdentity.processState.startsWith('Z')) {\n\t\treturn 'absent';\n\t}\n\tif (options.mode === 'after-signal' && currentIdentity.processState.includes('E')) {\n\t\treturn 'exact';\n\t}\n\tif (\n\t\toptions.mode === 'after-signal' &&\n\t\t(currentIdentity.processState.startsWith('U') ||\n\t\t\tcurrentIdentity.processState.startsWith('R')) &&\n\t\t(isMatchingDarwinFallbackCommand({\n\t\t\tcurrentCommand: currentIdentity.command,\n\t\t\trecordedCommand: options.identity.command,\n\t\t}) ||\n\t\t\tisMatchingLinuxTaskFallbackCommand({\n\t\t\t\tcurrentCommand: currentIdentity.command,\n\t\t\t\trecordedCommand: options.identity.command,\n\t\t\t}))\n\t) {\n\t\treturn 'exact';\n\t}\n\tif (currentIdentity.command !== options.identity.command) {\n\t\tthrow new Error(\n\t\t\t`${options.contextLabel} refusing ${options.action} pid ${String(options.identity.hostProcessId)}: same process start identity was observed with state ${JSON.stringify(currentIdentity.processState)} but command changed (recorded ${JSON.stringify(options.identity.command)}, current ${JSON.stringify(currentIdentity.command)}).`,\n\t\t);\n\t}\n\tif (!isManagedVmHostCommand(currentIdentity.command)) {\n\t\tthrow new Error(\n\t\t\t`${options.contextLabel} refusing ${options.action} pid ${String(options.identity.hostProcessId)} because the exact command is not a managed VM process.`,\n\t\t);\n\t}\n\treturn 'exact';\n}\n\nasync function waitForRecordedProcessAbsence(options: {\n\treadonly afterSignal: NodeJS.Signals;\n\treadonly contextLabel: string;\n\treadonly dependencies: GondolinProcessTerminationDependencies;\n\treadonly identity: ManagedVmHostProcessIdentity;\n}): Promise<boolean> {\n\tconst deadline = options.dependencies.now() + terminationStageTimeoutMs;\n\twhile (options.dependencies.now() < deadline) {\n\t\t// oxlint-disable-next-line no-await-in-loop -- exact identity observations must remain ordered\n\t\tconst observation = await observeRecordedProcess({\n\t\t\taction: `continued containment after ${options.afterSignal} for`,\n\t\t\tcontextLabel: options.contextLabel,\n\t\t\tdependencies: options.dependencies,\n\t\t\tidentity: options.identity,\n\t\t\tmode: 'after-signal',\n\t\t});\n\t\tif (observation === 'absent') {\n\t\t\treturn true;\n\t\t}\n\t\t// oxlint-disable-next-line no-await-in-loop -- bounded process identity polling is sequential\n\t\tawait options.dependencies.sleep(processIdentityPollIntervalMs);\n\t}\n\treturn (\n\t\t(await observeRecordedProcess({\n\t\t\taction: `continued containment after ${options.afterSignal} for`,\n\t\t\tcontextLabel: options.contextLabel,\n\t\t\tdependencies: options.dependencies,\n\t\t\tidentity: options.identity,\n\t\t\tmode: 'after-signal',\n\t\t})) === 'absent'\n\t);\n}\n\nfunction signalRecordedProcess(options: {\n\treadonly dependencies: GondolinProcessTerminationDependencies;\n\treadonly hostProcessId: number;\n\treadonly signal: NodeJS.Signals;\n}): void {\n\ttry {\n\t\toptions.dependencies.sendSignal(options.hostProcessId, options.signal);\n\t} catch (error) {\n\t\tif (processErrorCode(error) !== 'ESRCH') {\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\nexport async function terminateExactRecordedManagedVmHostProcess(options: {\n\treadonly contextLabel: string;\n\treadonly dependencies: GondolinProcessTerminationDependencies;\n\treadonly identity: ManagedVmHostProcessIdentity;\n}): Promise<ManagedVmExactProcessTerminationOutcome> {\n\tassertTerminationRequest(options);\n\tconst initialObservation = await observeRecordedProcess({\n\t\taction: 'SIGTERM to',\n\t\tcontextLabel: options.contextLabel,\n\t\tdependencies: options.dependencies,\n\t\tidentity: options.identity,\n\t\tmode: 'before-signal',\n\t});\n\tif (initialObservation === 'absent') {\n\t\treturn { hostProcessId: options.identity.hostProcessId, kind: 'already-absent' };\n\t}\n\n\tsignalRecordedProcess({\n\t\tdependencies: options.dependencies,\n\t\thostProcessId: options.identity.hostProcessId,\n\t\tsignal: 'SIGTERM',\n\t});\n\tif (\n\t\tawait waitForRecordedProcessAbsence({\n\t\t\tafterSignal: 'SIGTERM',\n\t\t\tcontextLabel: options.contextLabel,\n\t\t\tdependencies: options.dependencies,\n\t\t\tidentity: options.identity,\n\t\t})\n\t) {\n\t\treturn { hostProcessId: options.identity.hostProcessId, kind: 'terminated' };\n\t}\n\n\tconst beforeKillObservation = await observeRecordedProcess({\n\t\taction: 'SIGKILL to',\n\t\tcontextLabel: options.contextLabel,\n\t\tdependencies: options.dependencies,\n\t\tidentity: options.identity,\n\t\tmode: 'after-signal',\n\t});\n\tif (beforeKillObservation === 'absent') {\n\t\treturn { hostProcessId: options.identity.hostProcessId, kind: 'terminated' };\n\t}\n\tsignalRecordedProcess({\n\t\tdependencies: options.dependencies,\n\t\thostProcessId: options.identity.hostProcessId,\n\t\tsignal: 'SIGKILL',\n\t});\n\tif (\n\t\tawait waitForRecordedProcessAbsence({\n\t\t\tafterSignal: 'SIGKILL',\n\t\t\tcontextLabel: options.contextLabel,\n\t\t\tdependencies: options.dependencies,\n\t\t\tidentity: options.identity,\n\t\t})\n\t) {\n\t\treturn { hostProcessId: options.identity.hostProcessId, kind: 'terminated' };\n\t}\n\n\tthrow new Error(\n\t\t`Failed to terminate exact recorded managed VM process ${String(options.identity.hostProcessId)} (${options.contextLabel}).`,\n\t);\n}\n\nexport function createGondolinExactProcessTerminationCapability(\n\tdependencies: GondolinProcessTerminationDependencies = defaultDependencies,\n): ManagedVmExactProcessTerminationCapability {\n\treturn {\n\t\tasync terminateRecordedHostProcess(request): Promise<ManagedVmExactProcessTerminationOutcome> {\n\t\t\treturn await terminateExactRecordedManagedVmHostProcess({\n\t\t\t\tcontextLabel: request.contextLabel,\n\t\t\t\tdependencies,\n\t\t\t\tidentity: request.identity,\n\t\t\t});\n\t\t},\n\t};\n}\n","import fs from 'node:fs/promises';\nimport { createRequire } from 'node:module';\nimport path from 'node:path';\n\nimport { z } from 'zod';\n\nconst requireFromHere = createRequire(import.meta.url);\n\nconst gondolinPackageJsonSchema = z.object({\n\tversion: z.string().min(1),\n});\n\nfunction isMissingFileError(error: unknown): boolean {\n\treturn typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT';\n}\n\nfunction getErrorMessage(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\nexport function parseMinimumZigVersion(rawContents: string): string {\n\tconst match = rawContents.match(/\\.minimum_zig_version\\s*=\\s*\"([^\"]*)\"/u);\n\tif (!match) {\n\t\tthrow new Error(\n\t\t\t'minimum_zig_version declaration not found. Expected a line like `.minimum_zig_version = \"0.15.2\"`.',\n\t\t);\n\t}\n\n\tconst version = match[1];\n\tif (!version) {\n\t\tthrow new Error('minimum_zig_version is empty.');\n\t}\n\treturn version;\n}\n\nexport function resolveGondolinPackageJsonPath(): string {\n\treturn requireFromHere.resolve('@earendil-works/gondolin/package.json');\n}\n\nexport async function resolveGondolinPackageSpec(): Promise<string> {\n\tconst packageJsonPath = resolveGondolinPackageJsonPath();\n\tconst parsed: unknown = JSON.parse(await fs.readFile(packageJsonPath, 'utf8'));\n\tconst packageJson = gondolinPackageJsonSchema.parse(parsed);\n\treturn `@earendil-works/gondolin@${packageJson.version}`;\n}\n\nexport interface ResolveGondolinMinimumZigVersionOptions {\n\treadonly buildZigZonPath?: string;\n}\n\nasync function resolveDefaultBuildZigZonPath(): Promise<string> {\n\tconst packageJsonPath = resolveGondolinPackageJsonPath();\n\treturn path.join(path.dirname(packageJsonPath), 'dist', 'guest', 'build.zig.zon');\n}\n\nexport async function resolveGondolinMinimumZigVersion(\n\toptions: ResolveGondolinMinimumZigVersionOptions = {},\n): Promise<string> {\n\tconst zonPath = options.buildZigZonPath ?? (await resolveDefaultBuildZigZonPath());\n\tlet rawContents: string;\n\ttry {\n\t\trawContents = await fs.readFile(zonPath, 'utf8');\n\t} catch (error) {\n\t\tif (isMissingFileError(error)) {\n\t\t\tthrow new Error(`Missing Gondolin build.zig.zon at '${zonPath}'.`, { cause: error });\n\t\t}\n\t\tthrow new Error(\n\t\t\t`Failed to read Gondolin build.zig.zon at '${zonPath}': ${getErrorMessage(error)}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n\n\ttry {\n\t\treturn parseMinimumZigVersion(rawContents);\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Failed to parse Gondolin build.zig.zon at '${zonPath}': ${getErrorMessage(error)}`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { VirtualProvider } from '@earendil-works/gondolin';\n\nexport interface PinnedRealFsRoot {\n\treadonly hostPath: string;\n\treadonly realPath: string;\n\treadonly fd: number;\n\treadonly device: number;\n\treadonly inode: number;\n}\n\nexport interface CreatePinnedRealFsProviderOptions {\n\treadonly root: PinnedRealFsRoot;\n\treadonly createRealFsProvider: (hostPath: string) => VirtualProvider;\n}\n\nconst terminallyClosedPinnedRoots = new WeakSet<PinnedRealFsRoot>();\n\nfunction formatRootIdentity(root: PinnedRealFsRoot): string {\n\treturn `${root.device}:${root.inode}`;\n}\n\nfunction openDirectoryNoFollow(candidatePath: string): number {\n\treturn fs.openSync(\n\t\tcandidatePath,\n\t\tfs.constants.O_RDONLY | fs.constants.O_DIRECTORY | fs.constants.O_NOFOLLOW,\n\t);\n}\n\nexport function pinRealFsRoot(hostPath: string): PinnedRealFsRoot {\n\tif (!hostPath || !path.isAbsolute(hostPath)) {\n\t\tthrow new Error(`Pinned RealFS root must be a non-empty absolute path: ${hostPath}`);\n\t}\n\n\tconst resolvedHostPath = path.resolve(hostPath);\n\tconst fd = openDirectoryNoFollow(resolvedHostPath);\n\ttry {\n\t\tconst stats = fs.fstatSync(fd);\n\t\tif (!stats.isDirectory()) {\n\t\t\tthrow new Error(`Pinned RealFS root is not a directory: ${resolvedHostPath}`);\n\t\t}\n\t\tconst realPath = fs.realpathSync(resolvedHostPath);\n\t\tconst realPathStats = fs.statSync(realPath);\n\t\tif (realPathStats.dev !== stats.dev || realPathStats.ino !== stats.ino) {\n\t\t\tthrow new Error(\n\t\t\t\t`Pinned RealFS root changed while opening: ${resolvedHostPath} opened ${stats.dev}:${stats.ino} but resolved to ${realPathStats.dev}:${realPathStats.ino}`,\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tdevice: stats.dev,\n\t\t\tfd,\n\t\t\thostPath: resolvedHostPath,\n\t\t\tinode: stats.ino,\n\t\t\trealPath,\n\t\t};\n\t} catch (error) {\n\t\tfs.closeSync(fd);\n\t\tthrow error;\n\t}\n}\n\nexport function closePinnedRealFsRoot(root: PinnedRealFsRoot): void {\n\tif (terminallyClosedPinnedRoots.has(root)) {\n\t\treturn;\n\t}\n\tfs.closeSync(root.fd);\n\tterminallyClosedPinnedRoots.add(root);\n}\n\nexport function assertPinnedRealFsRoot(root: PinnedRealFsRoot): void {\n\tconst pinnedStats = fs.fstatSync(root.fd);\n\tconst currentStats = fs.statSync(root.realPath);\n\tif (\n\t\tpinnedStats.dev !== root.device ||\n\t\tpinnedStats.ino !== root.inode ||\n\t\tcurrentStats.dev !== root.device ||\n\t\tcurrentStats.ino !== root.inode\n\t) {\n\t\tthrow new Error(\n\t\t\t`Pinned RealFS root changed before mount access: ${root.realPath} expected ${formatRootIdentity(root)} got ${currentStats.dev}:${currentStats.ino}`,\n\t\t);\n\t}\n}\n\ntype ProviderMethod = (...args: unknown[]) => unknown;\n\n/* oxlint-disable typescript-eslint/no-unsafe-type-assertion -- Reflect.get()\n loses the method signature from Gondolin's VirtualProvider union. The proxy\n keeps the same provider object and only wraps callable properties with the\n pinned-root assertion. */\nexport function createPinnedRealFsProvider(\n\toptions: CreatePinnedRealFsProviderOptions,\n): VirtualProvider {\n\tassertPinnedRealFsRoot(options.root);\n\tconst provider = options.createRealFsProvider(options.root.realPath);\n\n\treturn new Proxy(provider, {\n\t\tget(target: VirtualProvider, property: string | symbol, receiver: unknown): unknown {\n\t\t\tconst value = Reflect.get(target, property, receiver) as unknown;\n\t\t\tif (typeof value !== 'function') {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\tassertPinnedRealFsRoot(options.root);\n\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t};\n\t\t},\n\t});\n}\n/* oxlint-enable typescript-eslint/no-unsafe-type-assertion */\n","import path from 'node:path';\n\nimport type { ManagedVmFilteredWorkspacePolicy } from '@agent-vm/managed-vm';\nimport {\n\tERRNO,\n\tVirtualDirent,\n\tcreateVirtualDirStats,\n\ttype ShadowPredicate,\n\ttype ShadowProviderOptions,\n\ttype VirtualProvider,\n} from '@earendil-works/gondolin';\n\nexport interface FilteredWorkspaceProviderDependencies {\n\tcreateMemoryProvider(): VirtualProvider;\n\tcreateReadonlyProvider(provider: VirtualProvider): VirtualProvider;\n\tcreateShadowPathPredicate(paths: readonly string[]): ShadowPredicate;\n\tcreateShadowProvider(provider: VirtualProvider, options: ShadowProviderOptions): VirtualProvider;\n}\n\nexport interface CreateFilteredWorkspaceProviderOptions {\n\treadonly baseProvider: VirtualProvider;\n\treadonly dependencies: FilteredWorkspaceProviderDependencies;\n\treadonly policy: ManagedVmFilteredWorkspacePolicy;\n}\n\ntype ProviderMethod = (...methodArguments: readonly unknown[]) => unknown;\n\nfunction toAbsoluteProviderPath(relativePath: string): string {\n\treturn `/${relativePath}`;\n}\n\nfunction normalizeProviderPath(providerPath: string): string {\n\tconst absolutePath = providerPath.startsWith('/') ? providerPath : `/${providerPath}`;\n\treturn path.posix.normalize(absolutePath);\n}\n\nfunction toRelativeProviderPath(providerPath: string): string {\n\tconst normalizedPath = normalizeProviderPath(providerPath);\n\treturn normalizedPath === '/' ? '' : normalizedPath.slice(1);\n}\n\nfunction isEqualOrDescendant(candidatePath: string, ancestorPath: string): boolean {\n\treturn (\n\t\tancestorPath.length === 0 ||\n\t\tcandidatePath === ancestorPath ||\n\t\tcandidatePath.startsWith(`${ancestorPath}/`)\n\t);\n}\n\nfunction pathsOverlap(firstPath: string, secondPath: string): boolean {\n\treturn isEqualOrDescendant(firstPath, secondPath) || isEqualOrDescendant(secondPath, firstPath);\n}\n\nfunction createFilesystemPolicyError(\n\tcode: 'EACCES' | 'ENOENT' | 'EROFS',\n\tsyscall: string,\n\tproviderPath: string,\n): Error & { readonly code: 'EACCES' | 'ENOENT' | 'EROFS'; readonly errno: number } {\n\treturn Object.assign(new Error(`${code}: ${syscall} '${providerPath}'`), {\n\t\tcode,\n\t\terrno: ERRNO[code],\n\t\tpath: providerPath,\n\t\tsyscall,\n\t});\n}\n\nfunction invokeProviderMethod(\n\tprovider: VirtualProvider,\n\tproperty: string | symbol,\n\tmethodArguments: readonly unknown[],\n): unknown {\n\tconst method = Reflect.get(provider, property, provider) as unknown;\n\tif (typeof method !== 'function') {\n\t\treturn method;\n\t}\n\treturn Reflect.apply(method as ProviderMethod, provider, methodArguments);\n}\n\nconst singlePathMutationMethods = new Set([\n\t'appendFile',\n\t'appendFileSync',\n\t'mkdir',\n\t'mkdirSync',\n\t'rmdir',\n\t'rmdirSync',\n\t'symlink',\n\t'symlinkSync',\n\t'truncate',\n\t'truncateSync',\n\t'unlink',\n\t'unlinkSync',\n\t'writeFile',\n\t'writeFileSync',\n]);\n\nfunction mutationPathArgumentIndex(property: string): number {\n\treturn property === 'symlink' || property === 'symlinkSync' ? 1 : 0;\n}\n\nfunction failProviderMutation(property: string, providerPath: string): unknown {\n\treturn failProviderOperation(property, providerPath, 'EROFS');\n}\n\nfunction failProviderOperation(\n\tproperty: string,\n\tproviderPath: string,\n\tcode: 'EACCES' | 'ENOENT' | 'EROFS',\n): unknown {\n\tconst operationError = createFilesystemPolicyError(code, property, providerPath);\n\tif (property.endsWith('Sync')) {\n\t\tthrow operationError;\n\t}\n\treturn Promise.reject(operationError);\n}\n\nfunction createRelativeRootProvider(\n\tprovider: VirtualProvider,\n\tsourceRelativePath: string,\n): VirtualProvider {\n\tconst sourceProviderPath = toAbsoluteProviderPath(sourceRelativePath);\n\tconst translatePath = (providerPath: string): string => {\n\t\tconst suffix = toRelativeProviderPath(providerPath);\n\t\treturn toAbsoluteProviderPath(\n\t\t\tsuffix.length === 0 ? sourceRelativePath : `${sourceRelativePath}/${suffix}`,\n\t\t);\n\t};\n\tconst translateArguments = (\n\t\tproperty: string,\n\t\tmethodArguments: readonly unknown[],\n\t): readonly unknown[] => {\n\t\tconst translatedArguments = [...methodArguments];\n\t\tif (\n\t\t\tproperty === 'rename' ||\n\t\t\tproperty === 'renameSync' ||\n\t\t\tproperty === 'link' ||\n\t\t\tproperty === 'linkSync' ||\n\t\t\tproperty === 'copyFile' ||\n\t\t\tproperty === 'copyFileSync'\n\t\t) {\n\t\t\ttranslatedArguments[0] = translatePath(String(methodArguments[0]));\n\t\t\ttranslatedArguments[1] = translatePath(String(methodArguments[1]));\n\t\t\treturn translatedArguments;\n\t\t}\n\t\ttranslatedArguments[mutationPathArgumentIndex(property)] = translatePath(\n\t\t\tString(methodArguments[mutationPathArgumentIndex(property)]),\n\t\t);\n\t\treturn translatedArguments;\n\t};\n\tconst assertResolvedPathWithinSource = (\n\t\tresolvedPath: string,\n\t\tcanonicalSourcePath: string,\n\t\tproperty: string,\n\t\tproviderPath: string,\n\t): void => {\n\t\tconst resolvedRelativePath = toRelativeProviderPath(resolvedPath);\n\t\tconst canonicalSourceRelativePath = toRelativeProviderPath(canonicalSourcePath);\n\t\tif (!isEqualOrDescendant(resolvedRelativePath, canonicalSourceRelativePath)) {\n\t\t\tthrow createFilesystemPolicyError('ENOENT', property, providerPath);\n\t\t}\n\t};\n\tconst resolveConfinedPath = async (\n\t\tproperty: string,\n\t\tproviderPath: string,\n\t\ttranslatedPath: string,\n\t): Promise<{ readonly canonicalSourcePath: string; readonly resolvedPath: string }> => {\n\t\tif (!provider.realpath) {\n\t\t\tthrow createFilesystemPolicyError('ENOENT', property, providerPath);\n\t\t}\n\t\tconst [canonicalSourcePath, resolvedPath] = await Promise.all([\n\t\t\tprovider.realpath(sourceProviderPath),\n\t\t\tprovider.realpath(translatedPath),\n\t\t]);\n\t\tassertResolvedPathWithinSource(resolvedPath, canonicalSourcePath, property, providerPath);\n\t\treturn { canonicalSourcePath, resolvedPath };\n\t};\n\tconst resolveConfinedPathSync = (\n\t\tproperty: string,\n\t\tproviderPath: string,\n\t\ttranslatedPath: string,\n\t): { readonly canonicalSourcePath: string; readonly resolvedPath: string } => {\n\t\tif (!provider.realpathSync) {\n\t\t\tthrow createFilesystemPolicyError('ENOENT', property, providerPath);\n\t\t}\n\t\tconst canonicalSourcePath = provider.realpathSync(sourceProviderPath);\n\t\tconst resolvedPath = provider.realpathSync(translatedPath);\n\t\tassertResolvedPathWithinSource(resolvedPath, canonicalSourcePath, property, providerPath);\n\t\treturn { canonicalSourcePath, resolvedPath };\n\t};\n\tconst parentProviderPath = (providerPath: string): string => {\n\t\tconst normalizedPath = normalizeProviderPath(providerPath);\n\t\treturn normalizedPath === '/' ? '/' : path.posix.dirname(normalizedPath);\n\t};\n\tconst remapResolvedPath = (resolvedPath: string, canonicalSourcePath: string): string => {\n\t\tconst resolvedRelativePath = toRelativeProviderPath(resolvedPath);\n\t\tconst canonicalSourceRelativePath = toRelativeProviderPath(canonicalSourcePath);\n\t\tif (resolvedRelativePath === canonicalSourceRelativePath) {\n\t\t\treturn '/';\n\t\t}\n\t\treturn toAbsoluteProviderPath(\n\t\t\tcanonicalSourceRelativePath.length === 0\n\t\t\t\t? resolvedRelativePath\n\t\t\t\t: resolvedRelativePath.slice(`${canonicalSourceRelativePath}/`.length),\n\t\t);\n\t};\n\tconst asyncFollowMethods = new Set(['access', 'open', 'readdir', 'readFile', 'stat', 'statfs']);\n\tconst syncFollowMethods = new Set([\n\t\t'accessSync',\n\t\t'openSync',\n\t\t'readdirSync',\n\t\t'readFileSync',\n\t\t'statSync',\n\t\t'watch',\n\t\t'watchAsync',\n\t\t'watchFile',\n\t\t'unwatchFile',\n\t]);\n\n\treturn new Proxy(provider, {\n\t\tget(target: VirtualProvider, property: string | symbol): unknown {\n\t\t\tconst value = Reflect.get(target, property, target) as unknown;\n\t\t\tif (typeof property !== 'string' || typeof value !== 'function') {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\tconst translatedArguments = translateArguments(property, methodArguments);\n\t\t\t\tif (property === 'realpath') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\treturn resolveConfinedPath(property, providerPath, String(translatedArguments[0])).then(\n\t\t\t\t\t\t({ canonicalSourcePath, resolvedPath }) =>\n\t\t\t\t\t\t\tremapResolvedPath(resolvedPath, canonicalSourcePath),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (property === 'realpathSync') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tconst { canonicalSourcePath, resolvedPath } = resolveConfinedPathSync(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tproviderPath,\n\t\t\t\t\t\tString(translatedArguments[0]),\n\t\t\t\t\t);\n\t\t\t\t\treturn remapResolvedPath(resolvedPath, canonicalSourcePath);\n\t\t\t\t}\n\t\t\t\tif (property === 'lstat' || property === 'readlink') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\treturn resolveConfinedPath(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tproviderPath,\n\t\t\t\t\t\ttranslatePath(parentProviderPath(providerPath)),\n\t\t\t\t\t).then(() => Reflect.apply(value as ProviderMethod, target, translatedArguments));\n\t\t\t\t}\n\t\t\t\tif (property === 'lstatSync' || property === 'readlinkSync') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tresolveConfinedPathSync(\n\t\t\t\t\t\tproperty,\n\t\t\t\t\t\tproviderPath,\n\t\t\t\t\t\ttranslatePath(parentProviderPath(providerPath)),\n\t\t\t\t\t);\n\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, translatedArguments);\n\t\t\t\t}\n\t\t\t\tif (property === 'exists') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\treturn resolveConfinedPath(property, providerPath, String(translatedArguments[0]))\n\t\t\t\t\t\t.then(() => Reflect.apply(value as ProviderMethod, target, translatedArguments))\n\t\t\t\t\t\t.catch(() => false);\n\t\t\t\t}\n\t\t\t\tif (property === 'existsSync' || property === 'internalModuleStat') {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresolveConfinedPathSync(property, providerPath, String(translatedArguments[0]));\n\t\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, translatedArguments);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\treturn property === 'existsSync' ? false : -2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (asyncFollowMethods.has(property)) {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\treturn resolveConfinedPath(property, providerPath, String(translatedArguments[0])).then(\n\t\t\t\t\t\t() => Reflect.apply(value as ProviderMethod, target, translatedArguments),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (syncFollowMethods.has(property)) {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tresolveConfinedPathSync(property, providerPath, String(translatedArguments[0]));\n\t\t\t\t}\n\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, translatedArguments);\n\t\t\t};\n\t\t},\n\t});\n}\n\nfunction createPositiveWorkspaceProjectionProvider(\n\tprovider: VirtualProvider,\n\tpolicy: Extract<\n\t\tManagedVmFilteredWorkspacePolicy['visibility'],\n\t\t{ readonly kind: 'positive-paths' }\n\t>,\n\tdependencies: FilteredWorkspaceProviderDependencies,\n): VirtualProvider {\n\tconst isVisible = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn (\n\t\t\trelativePath.length === 0 ||\n\t\t\tpolicy.visiblePaths.some((visiblePath) => pathsOverlap(relativePath, visiblePath))\n\t\t);\n\t};\n\tconst isWritable = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn policy.writablePaths.some((writablePath) =>\n\t\t\tisEqualOrDescendant(relativePath, writablePath),\n\t\t);\n\t};\n\tconst projectedProvider = dependencies.createShadowProvider(provider, {\n\t\tshouldShadow: ({ path: providerPath }) => !isVisible(providerPath),\n\t\twriteMode: 'deny',\n\t});\n\tconst readonlyProvider = dependencies.createReadonlyProvider(projectedProvider);\n\n\treturn new Proxy(projectedProvider, {\n\t\tget(target: VirtualProvider, property: string | symbol): unknown {\n\t\t\tconst value = Reflect.get(target, property, target) as unknown;\n\t\t\tif (typeof property !== 'string' || typeof value !== 'function') {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (property === 'open' || property === 'openSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tconst selectedProvider =\n\t\t\t\t\t\tisVisible(providerPath) && !isWritable(providerPath) ? readonlyProvider : target;\n\t\t\t\t\treturn invokeProviderMethod(selectedProvider, property, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (singlePathMutationMethods.has(property)) {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst pathIndex = mutationPathArgumentIndex(property);\n\t\t\t\t\tconst providerPath = String(methodArguments[pathIndex]);\n\t\t\t\t\tconst selectedProvider =\n\t\t\t\t\t\tisVisible(providerPath) && !isWritable(providerPath) ? readonlyProvider : target;\n\t\t\t\t\treturn invokeProviderMethod(selectedProvider, property, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'rename' || property === 'renameSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst affectedPaths = [String(methodArguments[0]), String(methodArguments[1])];\n\t\t\t\t\tconst selectedProvider =\n\t\t\t\t\t\taffectedPaths.every(isVisible) &&\n\t\t\t\t\t\taffectedPaths.some((affectedPath) => !isWritable(affectedPath))\n\t\t\t\t\t\t\t? readonlyProvider\n\t\t\t\t\t\t\t: target;\n\t\t\t\t\treturn invokeProviderMethod(selectedProvider, property, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'copyFile' || property === 'copyFileSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst sourcePath = String(methodArguments[0]);\n\t\t\t\t\tconst destinationPath = String(methodArguments[1]);\n\t\t\t\t\tconst selectedProvider =\n\t\t\t\t\t\tisVisible(sourcePath) && isVisible(destinationPath) && !isWritable(destinationPath)\n\t\t\t\t\t\t\t? readonlyProvider\n\t\t\t\t\t\t\t: target;\n\t\t\t\t\treturn invokeProviderMethod(selectedProvider, property, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\tReflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t},\n\t});\n}\n\nfunction createWorkspaceHardlinkProvider(\n\tprovider: VirtualProvider,\n\tbaseProvider: VirtualProvider,\n\tpolicy: ManagedVmFilteredWorkspacePolicy,\n): VirtualProvider {\n\tconst hidden = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn policy.hiddenPaths.some((hiddenPath) => isEqualOrDescendant(relativePath, hiddenPath));\n\t};\n\tconst temporary = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn policy.temporaryPaths.some((temporaryPath) =>\n\t\t\tisEqualOrDescendant(relativePath, temporaryPath),\n\t\t);\n\t};\n\tconst visible = (providerPath: string): boolean => {\n\t\tif (policy.visibility.kind === 'whole-root-writable') {\n\t\t\treturn true;\n\t\t}\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn (\n\t\t\trelativePath.length === 0 ||\n\t\t\tpolicy.visibility.visiblePaths.some((visiblePath) => pathsOverlap(relativePath, visiblePath))\n\t\t);\n\t};\n\tconst writable = (providerPath: string): boolean => {\n\t\tif (temporary(providerPath)) {\n\t\t\treturn false;\n\t\t}\n\t\tif (policy.visibility.kind === 'whole-root-writable') {\n\t\t\treturn true;\n\t\t}\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn policy.visibility.writablePaths.some((writablePath) =>\n\t\t\tisEqualOrDescendant(relativePath, writablePath),\n\t\t);\n\t};\n\n\treturn new Proxy(provider, {\n\t\tget(target: VirtualProvider, property: string | symbol): unknown {\n\t\t\tconst value = Reflect.get(target, property, target) as unknown;\n\t\t\tif (property !== 'link' && property !== 'linkSync') {\n\t\t\t\treturn typeof value === 'function'\n\t\t\t\t\t? (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\t\t\t\tReflect.apply(value as ProviderMethod, target, methodArguments)\n\t\t\t\t\t: value;\n\t\t\t}\n\t\t\tconst underlyingLinkMethod = Reflect.get(baseProvider, property, baseProvider) as unknown;\n\t\t\tif (typeof underlyingLinkMethod !== 'function') {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\tconst sourcePath = String(methodArguments[0]);\n\t\t\t\tconst destinationPath = String(methodArguments[1]);\n\t\t\t\tif (hidden(sourcePath) || !visible(sourcePath)) {\n\t\t\t\t\treturn failProviderOperation(property, sourcePath, 'ENOENT');\n\t\t\t\t}\n\t\t\t\tif (hidden(destinationPath) || !visible(destinationPath)) {\n\t\t\t\t\treturn failProviderOperation(property, destinationPath, 'EACCES');\n\t\t\t\t}\n\t\t\t\tif (!writable(sourcePath)) {\n\t\t\t\t\treturn failProviderOperation(property, sourcePath, 'EROFS');\n\t\t\t\t}\n\t\t\t\tif (!writable(destinationPath)) {\n\t\t\t\t\treturn failProviderOperation(property, destinationPath, 'EROFS');\n\t\t\t\t}\n\t\t\t\tif (property === 'link') {\n\t\t\t\t\tif (!provider.realpath) {\n\t\t\t\t\t\treturn failProviderOperation(property, sourcePath, 'ENOENT');\n\t\t\t\t\t}\n\t\t\t\t\treturn provider\n\t\t\t\t\t\t.realpath(sourcePath)\n\t\t\t\t\t\t.then(() =>\n\t\t\t\t\t\t\tReflect.apply(underlyingLinkMethod as ProviderMethod, baseProvider, methodArguments),\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!provider.realpathSync) {\n\t\t\t\t\treturn failProviderOperation(property, sourcePath, 'ENOENT');\n\t\t\t\t}\n\t\t\t\tprovider.realpathSync(sourcePath);\n\t\t\t\treturn Reflect.apply(underlyingLinkMethod as ProviderMethod, baseProvider, methodArguments);\n\t\t\t};\n\t\t},\n\t});\n}\n\ninterface ReadonlyInputProvider {\n\treadonly destinationRelativePath: string;\n\treadonly provider: VirtualProvider;\n}\n\nfunction directReadonlyDestinationChildren(\n\tproviderPath: string,\n\treadonlyInputs: readonly ReadonlyInputProvider[],\n): readonly string[] {\n\tconst relativePath = toRelativeProviderPath(providerPath);\n\tconst prefix = relativePath.length === 0 ? '' : `${relativePath}/`;\n\tconst children = new Set<string>();\n\tfor (const readonlyInput of readonlyInputs) {\n\t\tif (!readonlyInput.destinationRelativePath.startsWith(prefix)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst remainingPath = readonlyInput.destinationRelativePath.slice(prefix.length);\n\t\tconst childName = remainingPath.split('/')[0];\n\t\tif (childName) {\n\t\t\tchildren.add(childName);\n\t\t}\n\t}\n\treturn [...children].toSorted();\n}\n\nfunction entryName(entry: string | { readonly name: string }): string {\n\treturn typeof entry === 'string' ? entry : entry.name;\n}\n\nfunction mergeDirectoryEntries(\n\tentries: readonly (string | { readonly name: string })[],\n\tvirtualChildren: readonly string[],\n\twithFileTypes: boolean,\n): readonly (string | { readonly name: string })[] {\n\tconst presentNames = new Set(entries.map(entryName));\n\tconst missingChildren = virtualChildren.filter((childName) => !presentNames.has(childName));\n\treturn [\n\t\t...entries,\n\t\t...missingChildren.map((childName) =>\n\t\t\twithFileTypes ? new VirtualDirent(childName) : childName,\n\t\t),\n\t];\n}\n\nfunction isNoEntryError(error: unknown): boolean {\n\treturn (\n\t\ttypeof error === 'object' &&\n\t\terror !== null &&\n\t\t(('code' in error && (error.code === 'ENOENT' || error.code === 'ERRNO_2')) ||\n\t\t\t('errno' in error && (error.errno === ERRNO.ENOENT || error.errno === -ERRNO.ENOENT)))\n\t);\n}\n\nfunction createNestedReadonlyWorkspaceProvider(\n\tprovider: VirtualProvider,\n\tsourceProvider: VirtualProvider,\n\tpolicy: ManagedVmFilteredWorkspacePolicy,\n\tdependencies: FilteredWorkspaceProviderDependencies,\n): VirtualProvider {\n\tconst readonlyInputs: ReadonlyInputProvider[] = [];\n\tfor (const readonlyInput of policy.readonlyInputs) {\n\t\tif (\n\t\t\tpolicy.hiddenPaths.some((hiddenPath) =>\n\t\t\t\tisEqualOrDescendant(readonlyInput.destinationRelativePath, hiddenPath),\n\t\t\t)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tlet inputProvider = createRelativeRootProvider(\n\t\t\tsourceProvider,\n\t\t\treadonlyInput.sourceRelativePath,\n\t\t);\n\t\tconst nestedHiddenPaths = policy.hiddenPaths.flatMap((hiddenPath) => {\n\t\t\tconst destinationPrefix = `${readonlyInput.destinationRelativePath}/`;\n\t\t\treturn hiddenPath.startsWith(destinationPrefix)\n\t\t\t\t? [toAbsoluteProviderPath(hiddenPath.slice(destinationPrefix.length))]\n\t\t\t\t: [];\n\t\t});\n\t\tif (nestedHiddenPaths.length > 0) {\n\t\t\tinputProvider = dependencies.createShadowProvider(inputProvider, {\n\t\t\t\tshouldShadow: dependencies.createShadowPathPredicate(nestedHiddenPaths),\n\t\t\t\twriteMode: 'deny',\n\t\t\t});\n\t\t}\n\t\treadonlyInputs.push({\n\t\t\tdestinationRelativePath: readonlyInput.destinationRelativePath,\n\t\t\tprovider: dependencies.createReadonlyProvider(inputProvider),\n\t\t});\n\t}\n\n\tif (readonlyInputs.length === 0) {\n\t\treturn provider;\n\t}\n\n\tconst findInput = (providerPath: string): ReadonlyInputProvider | undefined => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn readonlyInputs.find((readonlyInput) =>\n\t\t\tisEqualOrDescendant(relativePath, readonlyInput.destinationRelativePath),\n\t\t);\n\t};\n\tconst mapInputPath = (providerPath: string, readonlyInput: ReadonlyInputProvider): string => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\tconst suffix = relativePath.slice(readonlyInput.destinationRelativePath.length);\n\t\treturn suffix.length === 0 ? '/' : suffix;\n\t};\n\tconst conflictsWithReadonlyInput = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn readonlyInputs.some((readonlyInput) =>\n\t\t\tpathsOverlap(relativePath, readonlyInput.destinationRelativePath),\n\t\t);\n\t};\n\tconst isHidden = (providerPath: string): boolean => {\n\t\tconst relativePath = toRelativeProviderPath(providerPath);\n\t\treturn policy.hiddenPaths.some((hiddenPath) => isEqualOrDescendant(relativePath, hiddenPath));\n\t};\n\n\treturn new Proxy(provider, {\n\t\tget(target: VirtualProvider, property: string | symbol): unknown {\n\t\t\tconst value = Reflect.get(target, property, target) as unknown;\n\t\t\tif (typeof property !== 'string' || typeof value !== 'function') {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (property === 'readdir' || property === 'readdirSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tconst readdirOptions = methodArguments[1];\n\t\t\t\t\tconst withFileTypes =\n\t\t\t\t\t\ttypeof readdirOptions === 'object' &&\n\t\t\t\t\t\treaddirOptions !== null &&\n\t\t\t\t\t\t'withFileTypes' in readdirOptions &&\n\t\t\t\t\t\treaddirOptions.withFileTypes === true;\n\t\t\t\t\tconst readonlyInput = findInput(providerPath);\n\t\t\t\t\tif (readonlyInput && !isHidden(providerPath)) {\n\t\t\t\t\t\treturn invokeProviderMethod(readonlyInput.provider, property, [\n\t\t\t\t\t\t\tmapInputPath(providerPath, readonlyInput),\n\t\t\t\t\t\t\t...methodArguments.slice(1),\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t\tconst virtualChildren = directReadonlyDestinationChildren(providerPath, readonlyInputs);\n\t\t\t\t\tif (virtualChildren.length === 0) {\n\t\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t\t}\n\t\t\t\t\tif (property === 'readdir') {\n\t\t\t\t\t\treturn Promise.resolve(Reflect.apply(value as ProviderMethod, target, methodArguments))\n\t\t\t\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\t\t\t\tif (isNoEntryError(error)) {\n\t\t\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.then((entries) =>\n\t\t\t\t\t\t\t\tmergeDirectoryEntries(\n\t\t\t\t\t\t\t\t\tentries as readonly (string | { readonly name: string })[],\n\t\t\t\t\t\t\t\t\tvirtualChildren,\n\t\t\t\t\t\t\t\t\twithFileTypes,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn mergeDirectoryEntries(\n\t\t\t\t\t\t\tReflect.apply(value as ProviderMethod, target, methodArguments) as readonly (\n\t\t\t\t\t\t\t\t| string\n\t\t\t\t\t\t\t\t| { readonly name: string }\n\t\t\t\t\t\t\t)[],\n\t\t\t\t\t\t\tvirtualChildren,\n\t\t\t\t\t\t\twithFileTypes,\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (isNoEntryError(error)) {\n\t\t\t\t\t\t\treturn virtualChildren;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'stat' ||\n\t\t\t\tproperty === 'statSync' ||\n\t\t\t\tproperty === 'lstat' ||\n\t\t\t\tproperty === 'lstatSync'\n\t\t\t) {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tconst readonlyInput = findInput(providerPath);\n\t\t\t\t\tif (readonlyInput && !isHidden(providerPath)) {\n\t\t\t\t\t\treturn invokeProviderMethod(readonlyInput.provider, property, [\n\t\t\t\t\t\t\tmapInputPath(providerPath, readonlyInput),\n\t\t\t\t\t\t\t...methodArguments.slice(1),\n\t\t\t\t\t\t]);\n\t\t\t\t\t}\n\t\t\t\t\tconst virtualChildren = directReadonlyDestinationChildren(providerPath, readonlyInputs);\n\t\t\t\t\tif (virtualChildren.length === 0) {\n\t\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t\t}\n\t\t\t\t\tif (property === 'stat' || property === 'lstat') {\n\t\t\t\t\t\treturn Promise.resolve(\n\t\t\t\t\t\t\tReflect.apply(value as ProviderMethod, target, methodArguments),\n\t\t\t\t\t\t).catch((error: unknown) => {\n\t\t\t\t\t\t\tif (isNoEntryError(error)) {\n\t\t\t\t\t\t\t\treturn createVirtualDirStats();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (isNoEntryError(error)) {\n\t\t\t\t\t\t\treturn createVirtualDirStats();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'open' || property === 'openSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\t\tconst readonlyInput = findInput(providerPath);\n\t\t\t\t\treturn readonlyInput && !isHidden(providerPath)\n\t\t\t\t\t\t? invokeProviderMethod(readonlyInput.provider, property, [\n\t\t\t\t\t\t\t\tmapInputPath(providerPath, readonlyInput),\n\t\t\t\t\t\t\t\t...methodArguments.slice(1),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (singlePathMutationMethods.has(property)) {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst providerPath = String(methodArguments[mutationPathArgumentIndex(property)]);\n\t\t\t\t\tif (!isHidden(providerPath) && conflictsWithReadonlyInput(providerPath)) {\n\t\t\t\t\t\treturn failProviderMutation(property, providerPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'rename' ||\n\t\t\t\tproperty === 'renameSync' ||\n\t\t\t\tproperty === 'link' ||\n\t\t\t\tproperty === 'linkSync'\n\t\t\t) {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst affectedPaths = [String(methodArguments[0]), String(methodArguments[1])];\n\t\t\t\t\tconst conflictingPath = affectedPaths.find(\n\t\t\t\t\t\t(affectedPath) => !isHidden(affectedPath) && conflictsWithReadonlyInput(affectedPath),\n\t\t\t\t\t);\n\t\t\t\t\tif (conflictingPath) {\n\t\t\t\t\t\treturn failProviderMutation(property, conflictingPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'copyFile' || property === 'copyFileSync') {\n\t\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\t\tconst sourcePath = String(methodArguments[0]);\n\t\t\t\t\tconst destinationPath = String(methodArguments[1]);\n\t\t\t\t\tif (!isHidden(destinationPath) && conflictsWithReadonlyInput(destinationPath)) {\n\t\t\t\t\t\treturn failProviderMutation(property, destinationPath);\n\t\t\t\t\t}\n\t\t\t\t\tconst sourceInput = findInput(sourcePath);\n\t\t\t\t\tif (!sourceInput || isHidden(sourcePath)) {\n\t\t\t\t\t\treturn Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\t\t}\n\t\t\t\t\tconst mappedSourcePath = mapInputPath(sourcePath, sourceInput);\n\t\t\t\t\tif (property === 'copyFile') {\n\t\t\t\t\t\treturn Promise.resolve(\n\t\t\t\t\t\t\tinvokeProviderMethod(sourceInput.provider, 'readFile', [mappedSourcePath]),\n\t\t\t\t\t\t).then((contents) =>\n\t\t\t\t\t\t\tinvokeProviderMethod(target, 'writeFile', [destinationPath, contents]),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tconst contents = invokeProviderMethod(sourceInput.provider, 'readFileSync', [\n\t\t\t\t\t\tmappedSourcePath,\n\t\t\t\t\t]);\n\t\t\t\t\treturn invokeProviderMethod(target, 'writeFileSync', [destinationPath, contents]);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn (...methodArguments: readonly unknown[]): unknown => {\n\t\t\t\tconst providerPath = String(methodArguments[0]);\n\t\t\t\tconst readonlyInput = findInput(providerPath);\n\t\t\t\tconst result =\n\t\t\t\t\treadonlyInput && !isHidden(providerPath)\n\t\t\t\t\t\t? invokeProviderMethod(readonlyInput.provider, property, [\n\t\t\t\t\t\t\t\tmapInputPath(providerPath, readonlyInput),\n\t\t\t\t\t\t\t\t...methodArguments.slice(1),\n\t\t\t\t\t\t\t])\n\t\t\t\t\t\t: Reflect.apply(value as ProviderMethod, target, methodArguments);\n\t\t\t\tif (!readonlyInput || isHidden(providerPath)) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t\tif (property === 'realpath') {\n\t\t\t\t\treturn Promise.resolve(result).then((resolvedPath) => {\n\t\t\t\t\t\tconst resolvedRelativePath = toRelativeProviderPath(String(resolvedPath));\n\t\t\t\t\t\treturn toAbsoluteProviderPath(\n\t\t\t\t\t\t\tresolvedRelativePath.length === 0\n\t\t\t\t\t\t\t\t? readonlyInput.destinationRelativePath\n\t\t\t\t\t\t\t\t: `${readonlyInput.destinationRelativePath}/${resolvedRelativePath}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (property === 'realpathSync') {\n\t\t\t\t\tconst resolvedRelativePath = toRelativeProviderPath(String(result));\n\t\t\t\t\treturn toAbsoluteProviderPath(\n\t\t\t\t\t\tresolvedRelativePath.length === 0\n\t\t\t\t\t\t\t? readonlyInput.destinationRelativePath\n\t\t\t\t\t\t\t: `${readonlyInput.destinationRelativePath}/${resolvedRelativePath}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t};\n\t\t},\n\t});\n}\n\nexport function createFilteredWorkspaceProvider(\n\toptions: CreateFilteredWorkspaceProviderOptions,\n): VirtualProvider {\n\tlet workspaceProvider = options.baseProvider;\n\tif (options.policy.visibility.kind === 'positive-paths') {\n\t\tworkspaceProvider = createPositiveWorkspaceProjectionProvider(\n\t\t\tworkspaceProvider,\n\t\t\toptions.policy.visibility,\n\t\t\toptions.dependencies,\n\t\t);\n\t}\n\n\tif (options.policy.hiddenPaths.length > 0) {\n\t\tworkspaceProvider = options.dependencies.createShadowProvider(workspaceProvider, {\n\t\t\tshouldShadow: options.dependencies.createShadowPathPredicate(\n\t\t\t\toptions.policy.hiddenPaths.map(toAbsoluteProviderPath),\n\t\t\t),\n\t\t\twriteMode: 'deny',\n\t\t});\n\t}\n\n\tif (options.policy.temporaryPaths.length > 0) {\n\t\tconst hiddenPredicate = options.dependencies.createShadowPathPredicate(\n\t\t\toptions.policy.hiddenPaths.map(toAbsoluteProviderPath),\n\t\t);\n\t\tconst temporaryPredicate = options.dependencies.createShadowPathPredicate(\n\t\t\toptions.policy.temporaryPaths.map(toAbsoluteProviderPath),\n\t\t);\n\t\tworkspaceProvider = options.dependencies.createShadowProvider(workspaceProvider, {\n\t\t\tshouldShadow: (context) => !hiddenPredicate(context) && temporaryPredicate(context),\n\t\t\ttmpfs: options.dependencies.createMemoryProvider(),\n\t\t\twriteMode: 'tmpfs',\n\t\t});\n\t}\n\tworkspaceProvider = createWorkspaceHardlinkProvider(\n\t\tworkspaceProvider,\n\t\toptions.baseProvider,\n\t\toptions.policy,\n\t);\n\n\treturn createNestedReadonlyWorkspaceProvider(\n\t\tworkspaceProvider,\n\t\toptions.baseProvider,\n\t\toptions.policy,\n\t\toptions.dependencies,\n\t);\n}\n","import * as dns from 'node:dns';\nimport * as net from 'node:net';\n\nexport interface HostNetworkDefaultsResult {\n\treadonly autoSelectFamily: false | 'unavailable';\n\treadonly dnsResultOrder: 'ipv4first' | 'unavailable';\n}\n\nexport interface HostNetworkDefaultsDependencies {\n\treadonly setDefaultAutoSelectFamily?: ((value: boolean) => void) | undefined;\n\treadonly setDefaultResultOrder?: ((order: 'ipv4first') => void) | undefined;\n}\n\n/**\n * Gondolin raw tcpHosts passthrough sockets are opened by the host-side Node\n * process, not by guest Node processes. VM NODE_OPTIONS cannot affect those\n * sockets, so host processes that create Gondolin VMs also force deterministic\n * IPv4-first behavior before network state is constructed.\n */\nexport function configureHostNetworkDefaults(\n\tdependencies: HostNetworkDefaultsDependencies = {},\n): HostNetworkDefaultsResult {\n\tconst setDefaultResultOrder =\n\t\t'setDefaultResultOrder' in dependencies\n\t\t\t? dependencies.setDefaultResultOrder\n\t\t\t: dns.setDefaultResultOrder;\n\tconst setDefaultAutoSelectFamily =\n\t\t'setDefaultAutoSelectFamily' in dependencies\n\t\t\t? dependencies.setDefaultAutoSelectFamily\n\t\t\t: net.setDefaultAutoSelectFamily;\n\n\tlet dnsResultOrder: HostNetworkDefaultsResult['dnsResultOrder'] = 'unavailable';\n\tif (typeof setDefaultResultOrder === 'function') {\n\t\tsetDefaultResultOrder('ipv4first');\n\t\tdnsResultOrder = 'ipv4first';\n\t}\n\n\tlet autoSelectFamily: HostNetworkDefaultsResult['autoSelectFamily'] = 'unavailable';\n\tif (typeof setDefaultAutoSelectFamily === 'function') {\n\t\tsetDefaultAutoSelectFamily(false);\n\t\tautoSelectFamily = false;\n\t}\n\n\treturn {\n\t\tautoSelectFamily,\n\t\tdnsResultOrder,\n\t};\n}\n","import type { Stats } from 'node:fs';\nimport net from 'node:net';\n\nimport {\n\tvalidateManagedVmFinalizeMemoryMountRequest,\n\ttype ManagedVmFilteredWorkspacePolicy,\n\ttype ManagedVmFinalizeMemoryMountRequest,\n} from '@agent-vm/managed-vm';\nimport {\n\tMemoryProvider,\n\tReadonlyProvider,\n\tRealFSProvider,\n\tShadowProvider,\n\tVM,\n\tcreateHttpHooks,\n\tcreateShadowPathPredicate,\n\ttype CreateHttpHooksResult,\n\ttype EnableIngressOptions,\n\ttype EnableSshOptions,\n\ttype ExecOptions as GondolinExecOptions,\n\ttype ExecProcess as GondolinExecProcess,\n\ttype ExecResult as GondolinExecResult,\n\ttype HttpHooks,\n\ttype IngressRoute as GondolinIngressRoute,\n\ttype ShadowPredicate,\n\ttype ShadowProviderOptions,\n\ttype SshOptions,\n\ttype VMOptions,\n\ttype VmFs as GondolinVmFs,\n\ttype VirtualFileHandle,\n\ttype VirtualProvider,\n\tERRNO,\n\tgetInfoFromSshExecRequest,\n\tisWriteFlag,\n} from '@earendil-works/gondolin';\n\nimport { createFilteredWorkspaceProvider } from './filtered-workspace-provider.js';\nimport {\n\tconfigureHostNetworkDefaults,\n\ttype HostNetworkDefaultsResult,\n} from './host-network-defaults.js';\nimport {\n\tclosePinnedRealFsRoot,\n\tcreatePinnedRealFsProvider,\n\ttype PinnedRealFsRoot,\n} from './pinned-realfs.js';\n\nexport const SYNTHETIC_DNS_IPV4_BENCHMARK = '198.18.0.1';\nexport const SYNTHETIC_DNS_IPV6_IPV4_MAPPED_BENCHMARK = '::ffff:198.18.0.1';\nexport const MANAGED_VM_DEFAULT_INGRESS_MAX_BUFFERED_RESPONSE_BODY_BYTES = 512 * 1024 * 1024;\nexport const MANAGED_VM_DEFAULT_INGRESS_UPSTREAM_HEADER_TIMEOUT_MS = 120_000;\nexport const MANAGED_VM_DEFAULT_INGRESS_UPSTREAM_RESPONSE_TIMEOUT_MS = 120_000;\n\nexport const MANAGED_VM_DEFAULT_INGRESS_OPTIONS = {\n\tallowWebSockets: true,\n\tbufferResponseBody: false,\n\tmaxBufferedResponseBodyBytes: MANAGED_VM_DEFAULT_INGRESS_MAX_BUFFERED_RESPONSE_BODY_BYTES,\n\tupstreamHeaderTimeoutMs: MANAGED_VM_DEFAULT_INGRESS_UPSTREAM_HEADER_TIMEOUT_MS,\n\tupstreamResponseTimeoutMs: MANAGED_VM_DEFAULT_INGRESS_UPSTREAM_RESPONSE_TIMEOUT_MS,\n} satisfies EnableIngressOptions;\n\nexport type ManagedExecInput = string | readonly string[];\nexport type ManagedExecOptions = GondolinExecOptions;\nexport type ManagedExecProcess = GondolinExecProcess;\nexport type ManagedExecResult = GondolinExecResult;\nexport type ManagedVmFs = GondolinVmFs;\nexport type ManagedSshEgressOptions = SshOptions;\n\nexport type IngressRoute = GondolinIngressRoute;\n\ntype VirtualProviderMethod = (...methodArguments: readonly unknown[]) => unknown;\n\nfunction createGuestRootOwnedStats(stats: Stats): Stats {\n\treturn new Proxy(stats, {\n\t\tget(target: Stats, property: string | symbol, receiver: unknown): unknown {\n\t\t\tif (property === 'gid' || property === 'uid') {\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\treturn Reflect.get(target, property, receiver);\n\t\t},\n\t});\n}\n\nfunction createGuestRootOwnedFileHandle(handle: VirtualFileHandle): VirtualFileHandle {\n\treturn new Proxy(handle, {\n\t\tget(target: VirtualFileHandle, property: string | symbol, receiver: unknown): unknown {\n\t\t\tconst value = Reflect.get(target, property, receiver) as unknown;\n\t\t\tif (property === 'stat') {\n\t\t\t\treturn async (options?: object): Promise<Stats> =>\n\t\t\t\t\tcreateGuestRootOwnedStats(await target.stat(options));\n\t\t\t}\n\t\t\tif (property === 'statSync') {\n\t\t\t\treturn (options?: object): Stats => createGuestRootOwnedStats(target.statSync(options));\n\t\t\t}\n\t\t\treturn typeof value === 'function'\n\t\t\t\t? (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\t\t\tReflect.apply(value as VirtualProviderMethod, target, methodArguments)\n\t\t\t\t: value;\n\t\t},\n\t});\n}\n\nfunction createGuestRootOwnedProvider(provider: VirtualProvider): VirtualProvider {\n\treturn new Proxy(provider, {\n\t\tget(target: VirtualProvider, property: string | symbol, receiver: unknown): unknown {\n\t\t\tconst value = Reflect.get(target, property, receiver) as unknown;\n\t\t\tif (property === 'open') {\n\t\t\t\treturn async (\n\t\t\t\t\tentryPath: string,\n\t\t\t\t\tflags: string,\n\t\t\t\t\tmode?: number,\n\t\t\t\t): Promise<VirtualFileHandle> =>\n\t\t\t\t\tcreateGuestRootOwnedFileHandle(await target.open(entryPath, flags, mode));\n\t\t\t}\n\t\t\tif (property === 'openSync') {\n\t\t\t\treturn (entryPath: string, flags: string, mode?: number): VirtualFileHandle =>\n\t\t\t\t\tcreateGuestRootOwnedFileHandle(target.openSync(entryPath, flags, mode));\n\t\t\t}\n\t\t\tif (property === 'stat') {\n\t\t\t\treturn async (entryPath: string, options?: object): Promise<Stats> =>\n\t\t\t\t\tcreateGuestRootOwnedStats(await target.stat(entryPath, options));\n\t\t\t}\n\t\t\tif (property === 'statSync') {\n\t\t\t\treturn (entryPath: string, options?: object): Stats =>\n\t\t\t\t\tcreateGuestRootOwnedStats(target.statSync(entryPath, options));\n\t\t\t}\n\t\t\tif (property === 'lstat') {\n\t\t\t\treturn async (entryPath: string, options?: object): Promise<Stats> =>\n\t\t\t\t\tcreateGuestRootOwnedStats(await target.lstat(entryPath, options));\n\t\t\t}\n\t\t\tif (property === 'lstatSync') {\n\t\t\t\treturn (entryPath: string, options?: object): Stats =>\n\t\t\t\t\tcreateGuestRootOwnedStats(target.lstatSync(entryPath, options));\n\t\t\t}\n\t\t\treturn typeof value === 'function'\n\t\t\t\t? (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\t\t\tReflect.apply(value as VirtualProviderMethod, target, methodArguments)\n\t\t\t\t: value;\n\t\t},\n\t});\n}\n\nfunction createReadonlyMutationError(\n\tsyscall: string,\n\tfilePath: string | undefined,\n): Error & {\n\treadonly code: 'EROFS';\n\treadonly errno: number;\n\treadonly path?: string;\n\treadonly syscall: string;\n} {\n\tconst pathSuffix = filePath === undefined ? '' : ` '${filePath}'`;\n\treturn Object.assign(new Error(`EROFS: ${syscall}${pathSuffix}`), {\n\t\tcode: 'EROFS' as const,\n\t\terrno: ERRNO.EROFS,\n\t\t...(filePath === undefined ? {} : { path: filePath }),\n\t\tsyscall,\n\t});\n}\n\nfunction createHardenedReadonlyFileHandle(handle: VirtualFileHandle): VirtualFileHandle {\n\treturn new Proxy(handle, {\n\t\tget(target: VirtualFileHandle, property: string | symbol, receiver: unknown): unknown {\n\t\t\tconst value = Reflect.get(target, property, receiver) as unknown;\n\t\t\tif (property === 'write' || property === 'writeFile' || property === 'truncate') {\n\t\t\t\treturn async (): Promise<never> => {\n\t\t\t\t\tthrow createReadonlyMutationError(String(property), target.path);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'writeSync' || property === 'writeFileSync' || property === 'truncateSync') {\n\t\t\t\treturn (): never => {\n\t\t\t\t\tthrow createReadonlyMutationError(String(property), target.path);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn typeof value === 'function'\n\t\t\t\t? (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\t\t\tReflect.apply(value as VirtualProviderMethod, target, methodArguments)\n\t\t\t\t: value;\n\t\t},\n\t});\n}\n\nexport function createHardenedReadonlyProvider(provider: VirtualProvider): VirtualProvider {\n\tconst readonlyProvider = new ReadonlyProvider(provider);\n\treturn new Proxy(readonlyProvider, {\n\t\tget(target: VirtualProvider, property: string | symbol, receiver: unknown): unknown {\n\t\t\tconst value = Reflect.get(target, property, receiver) as unknown;\n\t\t\tif (property === 'open') {\n\t\t\t\treturn async (\n\t\t\t\t\tentryPath: string,\n\t\t\t\t\tflags: string,\n\t\t\t\t\tmode?: number,\n\t\t\t\t): Promise<VirtualFileHandle> => {\n\t\t\t\t\tif (isWriteFlag(flags)) {\n\t\t\t\t\t\tthrow createReadonlyMutationError('open', entryPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn createHardenedReadonlyFileHandle(await target.open(entryPath, flags, mode));\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (property === 'openSync') {\n\t\t\t\treturn (entryPath: string, flags: string, mode?: number): VirtualFileHandle => {\n\t\t\t\t\tif (isWriteFlag(flags)) {\n\t\t\t\t\t\tthrow createReadonlyMutationError('openSync', entryPath);\n\t\t\t\t\t}\n\t\t\t\t\treturn createHardenedReadonlyFileHandle(target.openSync(entryPath, flags, mode));\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'mkdir' ||\n\t\t\t\tproperty === 'rmdir' ||\n\t\t\t\tproperty === 'unlink' ||\n\t\t\t\tproperty === 'rename' ||\n\t\t\t\tproperty === 'link' ||\n\t\t\t\tproperty === 'writeFile' ||\n\t\t\t\tproperty === 'appendFile' ||\n\t\t\t\tproperty === 'copyFile' ||\n\t\t\t\tproperty === 'symlink'\n\t\t\t) {\n\t\t\t\treturn async (entryPath: string): Promise<never> => {\n\t\t\t\t\tthrow createReadonlyMutationError(String(property), entryPath);\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (\n\t\t\t\tproperty === 'mkdirSync' ||\n\t\t\t\tproperty === 'rmdirSync' ||\n\t\t\t\tproperty === 'unlinkSync' ||\n\t\t\t\tproperty === 'renameSync' ||\n\t\t\t\tproperty === 'linkSync' ||\n\t\t\t\tproperty === 'writeFileSync' ||\n\t\t\t\tproperty === 'appendFileSync' ||\n\t\t\t\tproperty === 'copyFileSync' ||\n\t\t\t\tproperty === 'symlinkSync'\n\t\t\t) {\n\t\t\t\treturn (entryPath: string): never => {\n\t\t\t\t\tthrow createReadonlyMutationError(String(property), entryPath);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn typeof value === 'function'\n\t\t\t\t? (...methodArguments: readonly unknown[]): unknown =>\n\t\t\t\t\t\tReflect.apply(value as VirtualProviderMethod, target, methodArguments)\n\t\t\t\t: value;\n\t\t},\n\t});\n}\n\nexport interface GitReadOnlySshEgressOptions {\n\treadonly allowedHosts: readonly string[];\n\treadonly allowedRepos?: readonly string[];\n\treadonly agent?: string;\n\treadonly knownHostsFile?: SshOptions['knownHostsFile'];\n}\n\nexport interface SshAccess {\n\tclose(): Promise<void>;\n\treadonly host: string;\n\treadonly command?: string;\n\treadonly identityFile?: string;\n\treadonly port: number;\n\treadonly serverHostKey: SshServerHostKey;\n\treadonly user?: string;\n}\n\nexport interface ManagedVmSshAccess {\n\tclose(): Promise<void>;\n\treadonly command: string;\n\treadonly host: string;\n\treadonly identityFile: string;\n\treadonly port: number;\n\treadonly user: string;\n}\n\nexport interface SshServerHostKey {\n\treadonly algorithm: 'ssh-ed25519';\n\treadonly publicKeyBase64: string;\n}\n\nexport function isSshServerHostKey(value: unknown): value is SshServerHostKey {\n\tif (typeof value !== 'object' || value === null) {\n\t\treturn false;\n\t}\n\tif (!('algorithm' in value) || !('publicKeyBase64' in value)) {\n\t\treturn false;\n\t}\n\tconst algorithm = value.algorithm;\n\tconst publicKeyBase64 = value.publicKeyBase64;\n\tif (\n\t\talgorithm !== 'ssh-ed25519' ||\n\t\ttypeof publicKeyBase64 !== 'string' ||\n\t\t!/^[A-Za-z0-9+/]+={0,2}$/u.test(publicKeyBase64)\n\t) {\n\t\treturn false;\n\t}\n\n\ttry {\n\t\tconst decodedPublicKey = Buffer.from(publicKeyBase64, 'base64');\n\t\tif (decodedPublicKey.toString('base64') !== publicKeyBase64 || decodedPublicKey.length < 4) {\n\t\t\treturn false;\n\t\t}\n\t\tconst algorithmLength = decodedPublicKey.readUInt32BE(0);\n\t\tconst algorithmStart = 4;\n\t\tconst algorithmEnd = algorithmStart + algorithmLength;\n\t\tconst publicKeyLengthOffset = algorithmEnd;\n\t\tconst publicKeyStart = publicKeyLengthOffset + 4;\n\t\treturn (\n\t\t\talgorithmEnd + 4 <= decodedPublicKey.length &&\n\t\t\tdecodedPublicKey.subarray(algorithmStart, algorithmEnd).toString('utf8') === 'ssh-ed25519' &&\n\t\t\tdecodedPublicKey.readUInt32BE(publicKeyLengthOffset) === 32 &&\n\t\t\tdecodedPublicKey.length === publicKeyStart + 32\n\t\t);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function parseSshServerHostKey(publicKeyText: string): SshServerHostKey {\n\tconst publicKeyLines = publicKeyText\n\t\t.split('\\n')\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line.length > 0);\n\tif (publicKeyLines.length !== 1) {\n\t\tthrow new Error('Tool VM did not expose exactly one ssh-ed25519 server host key.');\n\t}\n\tconst publicKeyFields = publicKeyLines[0]?.split(/\\s+/u);\n\tconst serverHostKey = {\n\t\talgorithm: publicKeyFields?.[0],\n\t\tpublicKeyBase64: publicKeyFields?.[1],\n\t};\n\tif (!isSshServerHostKey(serverHostKey)) {\n\t\tthrow new Error('Tool VM did not expose a valid ssh-ed25519 server host key.');\n\t}\n\treturn serverHostKey;\n}\n\nasync function readSshServerHostKey(vmInstance: ManagedVmInstance): Promise<SshServerHostKey> {\n\tconst publicKeyResult = await vmInstance.exec(['/bin/cat', '/etc/ssh/ssh_host_ed25519_key.pub']);\n\tif (publicKeyResult.exitCode !== 0) {\n\t\tthrow new Error(\n\t\t\t`Tool VM server host key read failed with exit ${String(publicKeyResult.exitCode)}.`,\n\t\t);\n\t}\n\treturn parseSshServerHostKey(publicKeyResult.stdout);\n}\n\nasync function closeSshAccessAfterIdentityFailure(\n\tsshAccess: Awaited<ReturnType<ManagedVmInstance['enableSsh']>>,\n\tidentityError: unknown,\n): Promise<never> {\n\ttry {\n\t\tawait sshAccess.close();\n\t} catch (closeError) {\n\t\t// oxlint-disable-next-line preserve-caught-error -- AggregateError.errors preserves closeError while cause retains the primary identity failure.\n\t\tthrow new AggregateError(\n\t\t\t[identityError, closeError],\n\t\t\t'Tool VM SSH server identity validation and SSH access cleanup both failed.',\n\t\t\t{ cause: identityError },\n\t\t);\n\t}\n\tthrow identityError;\n}\n\nexport interface IngressAccess {\n\tclose(): Promise<void>;\n\treadonly host: string;\n\treadonly port: number;\n}\n\nexport interface ManagedVmInstance {\n\treadonly fs: ManagedVmFs;\n\treadonly id: string;\n\texec(command: string | string[], options?: ManagedExecOptions): ManagedExecProcess;\n\tenableSsh(options?: EnableSshOptions): Promise<ManagedVmSshAccess>;\n\tenableIngress(options?: EnableIngressOptions): Promise<IngressAccess>;\n\tgetHostPid?(): number | null;\n\tsetIngressRoutes(routes: readonly IngressRoute[]): void;\n\tstart(): Promise<void>;\n\tclose(): Promise<void>;\n}\n\nexport interface ManagedVmDependencies {\n\tconfigureHostNetworkDefaults?: () => HostNetworkDefaultsResult;\n\tcreateVm(vmOptions: VMOptions): Promise<ManagedVmInstance>;\n\tcreateHttpHooks(options: {\n\t\treadonly allowedHosts: readonly string[];\n\t\treadonly allowedInternalHosts?: readonly string[];\n\t\treadonly isIpAllowed?: HttpHooks['isIpAllowed'];\n\t\treadonly secrets: Record<string, ManagedHttpMediatedSecretSpec>;\n\t\treadonly onRequest?: (request: Request) => Promise<Request | Response | void>;\n\t\treadonly onResponse?: (response: Response) => Promise<Response | void>;\n\t}): Pick<CreateHttpHooksResult, 'env' | 'httpHooks'>;\n\tclosePinnedRealFsRoot(root: PinnedRealFsRoot): void;\n\tcreatePinnedRealFsProvider(root: PinnedRealFsRoot): VirtualProvider;\n\tcreateRealFsProvider(hostPath: string): VirtualProvider;\n\tcreateReadonlyProvider(provider: VirtualProvider): VirtualProvider;\n\tcreateMemoryProvider(): VirtualProvider;\n\tcreateShadowProvider(provider: VirtualProvider, options: ShadowProviderOptions): VirtualProvider;\n\tcreateShadowPathPredicate(paths: readonly string[]): ShadowPredicate;\n}\n\ninterface ManagedHttpMediatedSecretSpec {\n\treadonly hosts: readonly string[];\n\treadonly placeholder?: string;\n\treadonly value: string;\n}\n\ntype RealFsVfsMountSpec = {\n\treadonly hostPath?: string;\n\treadonly kind: 'realfs' | 'realfs-readonly';\n\treadonly pinnedHostRoot?: PinnedRealFsRoot;\n};\n\nexport type VfsMountSpec =\n\t| RealFsVfsMountSpec\n\t| {\n\t\t\treadonly access: 'read-only' | 'read-write';\n\t\t\treadonly kind: 'finalizable-memory';\n\t }\n\t| {\n\t\t\treadonly kind: 'filtered-workspace';\n\t\t\treadonly pinnedHostRoot: PinnedRealFsRoot;\n\t\t\treadonly policy: ManagedVmFilteredWorkspacePolicy;\n\t }\n\t| { readonly kind: 'memory' }\n\t| {\n\t\t\treadonly hostPath?: string;\n\t\t\treadonly kind: 'shadow';\n\t\t\treadonly pinnedHostRoot?: PinnedRealFsRoot;\n\t\t\treadonly shadowConfig?: {\n\t\t\t\treadonly deny: readonly string[];\n\t\t\t\treadonly tmpfs: readonly string[];\n\t\t\t};\n\t };\n\nexport interface CreateVmOptions {\n\treadonly imagePath: string;\n\treadonly memory: string;\n\treadonly cpus: number;\n\treadonly rootfsMode: 'readonly' | 'memory' | 'cow';\n\treadonly runtimeRootfsSize?: string;\n\treadonly allowedHosts: readonly string[];\n\treadonly secrets: Record<string, ManagedHttpMediatedSecretSpec>;\n\treadonly vfsMounts: Record<string, VfsMountSpec>;\n\treadonly tcpHosts?: Record<string, string>;\n\treadonly sshEgress?: ManagedSshEgressOptions;\n\treadonly env?: Record<string, string>;\n\treadonly sessionLabel?: string;\n\treadonly onRequest?: (request: Request) => Promise<Request | Response | void>;\n\treadonly onResponse?: (response: Response) => Promise<Response | void>;\n}\n\nexport interface ManagedVm {\n\treadonly fs: ManagedVmFs;\n\treadonly id: string;\n\texec(command: ManagedExecInput, options?: ManagedExecOptions): ManagedExecProcess;\n\tenableSsh(options?: EnableSshOptions): Promise<SshAccess>;\n\tenableIngress(options?: EnableIngressOptions): Promise<IngressAccess>;\n\tfinalizeMemoryMount(request: ManagedVmFinalizeMemoryMountRequest): Promise<void>;\n\tgetHostPid(): number | null;\n\tgetVmInstance(): ManagedVmInstance;\n\tsetIngressRoutes(routes: readonly IngressRoute[]): void;\n\tstart(): Promise<void>;\n\tclose(): Promise<void>;\n}\n\n/* oxlint-disable typescript-eslint/no-unsafe-type-assertion -- VM.create() returns\n Gondolin's concrete VM class; this adapter exposes only the narrower\n ManagedVmInstance interface used by agent-vm. */\nfunction createDefaultDependencies(): ManagedVmDependencies {\n\tconst createDefaultRealFsProvider = (hostPath: string): VirtualProvider =>\n\t\tnew RealFSProvider(hostPath);\n\treturn {\n\t\tconfigureHostNetworkDefaults,\n\t\tcreateVm: async (vmOptions: VMOptions): Promise<ManagedVmInstance> =>\n\t\t\t(await VM.create(vmOptions)) as unknown as ManagedVmInstance,\n\t\tcreateHttpHooks: (hookOptions) =>\n\t\t\tcreateHttpHooks({\n\t\t\t\tallowedHosts: [...hookOptions.allowedHosts],\n\t\t\t\t...(hookOptions.allowedInternalHosts === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { allowedInternalHosts: [...hookOptions.allowedInternalHosts] }),\n\t\t\t\t...(hookOptions.isIpAllowed ? { isIpAllowed: hookOptions.isIpAllowed } : {}),\n\t\t\t\tsecrets: Object.fromEntries(\n\t\t\t\t\tObject.entries(hookOptions.secrets).map(([secretName, secretSpec]) => [\n\t\t\t\t\t\tsecretName,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thosts: [...secretSpec.hosts],\n\t\t\t\t\t\t\t...(secretSpec.placeholder === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: { placeholder: secretSpec.placeholder }),\n\t\t\t\t\t\t\tvalue: secretSpec.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t\t...(hookOptions.onRequest ? { onRequest: hookOptions.onRequest } : {}),\n\t\t\t\t...(hookOptions.onResponse ? { onResponse: hookOptions.onResponse } : {}),\n\t\t\t}),\n\t\tclosePinnedRealFsRoot,\n\t\tcreatePinnedRealFsProvider: (root: PinnedRealFsRoot): VirtualProvider =>\n\t\t\tcreatePinnedRealFsProvider({\n\t\t\t\tcreateRealFsProvider: createDefaultRealFsProvider,\n\t\t\t\troot,\n\t\t\t}),\n\t\tcreateRealFsProvider: createDefaultRealFsProvider,\n\t\tcreateReadonlyProvider: createHardenedReadonlyProvider,\n\t\tcreateMemoryProvider: (): VirtualProvider => new MemoryProvider(),\n\t\tcreateShadowProvider: (\n\t\t\tprovider: VirtualProvider,\n\t\t\tshadowOptions: ShadowProviderOptions,\n\t\t): VirtualProvider => new ShadowProvider(provider, shadowOptions),\n\t\tcreateShadowPathPredicate: (paths: readonly string[]): ShadowPredicate =>\n\t\t\tcreateShadowPathPredicate([...paths]),\n\t};\n}\n/* oxlint-enable typescript-eslint/no-unsafe-type-assertion */\n\nfunction normalizeShadowPath(pathValue: string): string {\n\tconst trimmedPath = pathValue.trim();\n\tif (trimmedPath.startsWith('/')) {\n\t\treturn trimmedPath;\n\t}\n\n\tconst relativePath = trimmedPath.startsWith('./') ? trimmedPath.slice('./'.length) : trimmedPath;\n\treturn `/${relativePath}`;\n}\n\nfunction createRealFsProviderForSpec(\n\tmountSpec: RealFsVfsMountSpec | Extract<VfsMountSpec, { readonly kind: 'shadow' }>,\n\tdependencies: ManagedVmDependencies,\n\tmountKind: string,\n): VirtualProvider {\n\tif (mountSpec.pinnedHostRoot) {\n\t\treturn dependencies.createPinnedRealFsProvider(mountSpec.pinnedHostRoot);\n\t}\n\tif (mountSpec.hostPath) {\n\t\treturn dependencies.createRealFsProvider(mountSpec.hostPath);\n\t}\n\n\tthrow new Error(`${mountKind} mounts require hostPath or pinnedHostRoot`);\n}\n\nfunction createProviderFromSpec(\n\tmountSpec: VfsMountSpec,\n\tdependencies: ManagedVmDependencies,\n): VirtualProvider {\n\tswitch (mountSpec.kind) {\n\t\tcase 'finalizable-memory':\n\t\t\tthrow new Error('Finalizable memory mounts require retained provider construction.');\n\t\tcase 'memory':\n\t\t\treturn dependencies.createMemoryProvider();\n\t\tcase 'realfs': {\n\t\t\treturn createRealFsProviderForSpec(mountSpec, dependencies, 'realfs');\n\t\t}\n\t\tcase 'realfs-readonly': {\n\t\t\treturn dependencies.createReadonlyProvider(\n\t\t\t\tcreateRealFsProviderForSpec(mountSpec, dependencies, 'realfs-readonly'),\n\t\t\t);\n\t\t}\n\t\tcase 'filtered-workspace': {\n\t\t\treturn createFilteredWorkspaceProvider({\n\t\t\t\tbaseProvider: dependencies.createPinnedRealFsProvider(mountSpec.pinnedHostRoot),\n\t\t\t\tdependencies,\n\t\t\t\tpolicy: mountSpec.policy,\n\t\t\t});\n\t\t}\n\t\tcase 'shadow': {\n\t\t\tconst baseProvider =\n\t\t\t\tmountSpec.hostPath || mountSpec.pinnedHostRoot\n\t\t\t\t\t? createRealFsProviderForSpec(mountSpec, dependencies, 'shadow')\n\t\t\t\t\t: dependencies.createMemoryProvider();\n\n\t\t\tlet shadowProvider = baseProvider;\n\t\t\tconst shadowConfig = mountSpec.shadowConfig;\n\n\t\t\tif (shadowConfig?.deny.length) {\n\t\t\t\tshadowProvider = dependencies.createShadowProvider(shadowProvider, {\n\t\t\t\t\tshouldShadow: dependencies.createShadowPathPredicate(\n\t\t\t\t\t\tshadowConfig.deny.map((shadowPath) => normalizeShadowPath(shadowPath)),\n\t\t\t\t\t),\n\t\t\t\t\twriteMode: 'deny',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (shadowConfig?.tmpfs.length) {\n\t\t\t\tshadowProvider = dependencies.createShadowProvider(shadowProvider, {\n\t\t\t\t\tshouldShadow: dependencies.createShadowPathPredicate(\n\t\t\t\t\t\tshadowConfig.tmpfs.map((shadowPath) => normalizeShadowPath(shadowPath)),\n\t\t\t\t\t),\n\t\t\t\t\twriteMode: 'tmpfs',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn shadowProvider;\n\t\t}\n\t\tdefault: {\n\t\t\tthrow new Error('Unsupported VFS mount kind.');\n\t\t}\n\t}\n}\n\ninterface FinalizableMemoryMount {\n\treadonly provider: VirtualProvider;\n\tstate: 'failed' | 'finalized' | 'finalizing' | 'pending';\n}\n\ninterface CreatedVfsMounts {\n\treadonly finalizableMemoryMounts: Map<string, FinalizableMemoryMount>;\n\treadonly mounts: Record<string, VirtualProvider>;\n}\n\nfunction createVfsMounts(\n\tvfsMounts: Record<string, VfsMountSpec>,\n\tdependencies: ManagedVmDependencies,\n): CreatedVfsMounts {\n\tconst mountMap: Record<string, VirtualProvider> = {};\n\tconst finalizableMemoryMounts = new Map<string, FinalizableMemoryMount>();\n\n\tfor (const [guestPath, mountSpec] of Object.entries(vfsMounts)) {\n\t\tif (mountSpec.kind === 'finalizable-memory') {\n\t\t\tconst provider = dependencies.createMemoryProvider();\n\t\t\tfinalizableMemoryMounts.set(guestPath, { provider, state: 'pending' });\n\t\t\tconst guestProvider = createGuestRootOwnedProvider(provider);\n\t\t\tmountMap[guestPath] =\n\t\t\t\tmountSpec.access === 'read-only'\n\t\t\t\t\t? dependencies.createReadonlyProvider(guestProvider)\n\t\t\t\t\t: guestProvider;\n\t\t\tcontinue;\n\t\t}\n\t\tmountMap[guestPath] = createProviderFromSpec(mountSpec, dependencies);\n\t}\n\n\treturn { finalizableMemoryMounts, mounts: mountMap };\n}\n\nfunction collectPinnedRealFsRoots(\n\tvfsMounts: Record<string, VfsMountSpec>,\n): readonly PinnedRealFsRoot[] {\n\tconst roots = new Map<number, PinnedRealFsRoot>();\n\tfor (const mountSpec of Object.values(vfsMounts)) {\n\t\tif ('pinnedHostRoot' in mountSpec && mountSpec.pinnedHostRoot) {\n\t\t\troots.set(mountSpec.pinnedHostRoot.fd, mountSpec.pinnedHostRoot);\n\t\t}\n\t}\n\treturn [...roots.values()];\n}\n\nfunction closePinnedRealFsRoots(\n\troots: readonly PinnedRealFsRoot[],\n\tdependencies: ManagedVmDependencies,\n): void {\n\tconst closeErrors: unknown[] = [];\n\tfor (const root of roots) {\n\t\ttry {\n\t\t\tdependencies.closePinnedRealFsRoot(root);\n\t\t} catch (error) {\n\t\t\tcloseErrors.push(error);\n\t\t}\n\t}\n\tif (closeErrors.length === 1) {\n\t\tthrow closeErrors[0];\n\t}\n\tif (closeErrors.length > 1) {\n\t\tthrow new AggregateError(closeErrors, 'Multiple pinned RealFS roots failed to close.');\n\t}\n}\n\nfunction closePinnedRealFsRootsAfterFailure(\n\troots: readonly PinnedRealFsRoot[],\n\tdependencies: ManagedVmDependencies,\n): void {\n\ttry {\n\t\tclosePinnedRealFsRoots(roots, dependencies);\n\t} catch {\n\t\t// Preserve the VM creation failure; leaked-fd risk is lower than hiding\n\t\t// the root cause of a failed lease.\n\t}\n}\n\nfunction resolveManagedVmIngressOptions(\n\tingressOptions: EnableIngressOptions = {},\n): EnableIngressOptions {\n\tconst resolvedOptions: EnableIngressOptions = {\n\t\t...MANAGED_VM_DEFAULT_INGRESS_OPTIONS,\n\t};\n\n\tif (ingressOptions.listenHost !== undefined) {\n\t\tresolvedOptions.listenHost = ingressOptions.listenHost;\n\t}\n\tif (ingressOptions.listenPort !== undefined) {\n\t\tresolvedOptions.listenPort = ingressOptions.listenPort;\n\t}\n\tif (ingressOptions.allowWebSockets !== undefined) {\n\t\tresolvedOptions.allowWebSockets = ingressOptions.allowWebSockets;\n\t}\n\tif (ingressOptions.hooks !== undefined) {\n\t\tresolvedOptions.hooks = ingressOptions.hooks;\n\t}\n\tif (ingressOptions.bufferResponseBody !== undefined) {\n\t\tresolvedOptions.bufferResponseBody = ingressOptions.bufferResponseBody;\n\t}\n\tif (ingressOptions.maxBufferedResponseBodyBytes !== undefined) {\n\t\tresolvedOptions.maxBufferedResponseBodyBytes = ingressOptions.maxBufferedResponseBodyBytes;\n\t}\n\tif (ingressOptions.upstreamHeaderTimeoutMs !== undefined) {\n\t\tresolvedOptions.upstreamHeaderTimeoutMs = ingressOptions.upstreamHeaderTimeoutMs;\n\t}\n\tif (ingressOptions.upstreamResponseTimeoutMs !== undefined) {\n\t\tresolvedOptions.upstreamResponseTimeoutMs = ingressOptions.upstreamResponseTimeoutMs;\n\t}\n\n\treturn resolvedOptions;\n}\n\ninterface TcpHostEndpoint {\n\treadonly hostname: string;\n\treadonly port: number;\n}\n\ninterface InternalTcpHostRule extends TcpHostEndpoint {}\n\nfunction normalizePolicyHostname(hostname: string): string {\n\treturn hostname.toLowerCase();\n}\n\nfunction parseTcpHostEndpoint(endpoint: string): TcpHostEndpoint | undefined {\n\tif (endpoint.startsWith('[')) {\n\t\tconst closingBracketIndex = endpoint.indexOf(']');\n\t\tif (closingBracketIndex > 1) {\n\t\t\tconst portValue = Number.parseInt(endpoint.slice(closingBracketIndex + 2), 10);\n\t\t\tif (!Number.isFinite(portValue)) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\thostname: normalizePolicyHostname(endpoint.slice(1, closingBracketIndex)),\n\t\t\t\tport: portValue,\n\t\t\t};\n\t\t}\n\t}\n\n\tconst portSeparatorIndex = endpoint.lastIndexOf(':');\n\tif (portSeparatorIndex <= 0) {\n\t\treturn undefined;\n\t}\n\tconst portValue = Number.parseInt(endpoint.slice(portSeparatorIndex + 1), 10);\n\tif (!Number.isFinite(portValue)) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\thostname: normalizePolicyHostname(endpoint.slice(0, portSeparatorIndex)),\n\t\tport: portValue,\n\t};\n}\n\nfunction ipv4AddressIsInternal(ipAddress: string): boolean {\n\tconst octets = ipAddress.split('.').map((segment) => Number.parseInt(segment, 10));\n\tif (octets.length !== 4 || octets.some((octet) => !Number.isInteger(octet))) {\n\t\treturn false;\n\t}\n\tconst firstOctet = octets[0];\n\tconst secondOctet = octets[1];\n\tif (firstOctet === undefined || secondOctet === undefined) {\n\t\treturn false;\n\t}\n\treturn (\n\t\tfirstOctet === 10 ||\n\t\tfirstOctet === 127 ||\n\t\t(firstOctet === 169 && secondOctet === 254) ||\n\t\t(firstOctet === 172 && secondOctet >= 16 && secondOctet <= 31) ||\n\t\t(firstOctet === 192 && secondOctet === 168) ||\n\t\t(firstOctet === 100 && secondOctet >= 64 && secondOctet <= 127)\n\t);\n}\n\nfunction ipAddressIsInternal(ipAddress: string): boolean {\n\tif (net.isIP(ipAddress) === 4) {\n\t\treturn ipv4AddressIsInternal(ipAddress);\n\t}\n\tconst normalizedIpAddress = ipAddress.toLowerCase();\n\tif (normalizedIpAddress.startsWith('::ffff:')) {\n\t\treturn ipv4AddressIsInternal(normalizedIpAddress.slice('::ffff:'.length));\n\t}\n\treturn (\n\t\tnormalizedIpAddress === '::1' ||\n\t\tnormalizedIpAddress.startsWith('fc') ||\n\t\tnormalizedIpAddress.startsWith('fd') ||\n\t\tnormalizedIpAddress.startsWith('fe80:')\n\t);\n}\n\nfunction endpointHostnameIsInternal(hostname: string): boolean {\n\tconst normalizedHostname = normalizePolicyHostname(hostname);\n\treturn (\n\t\tnormalizedHostname === 'localhost' ||\n\t\tnormalizedHostname === 'host.docker.internal' ||\n\t\tipAddressIsInternal(normalizedHostname)\n\t);\n}\n\nfunction deriveInternalTcpHostRules(\n\ttcpHosts: Record<string, string> | undefined,\n): readonly InternalTcpHostRule[] {\n\tif (!tcpHosts) {\n\t\treturn [];\n\t}\n\n\tconst rules: InternalTcpHostRule[] = [];\n\tfor (const [tcpHostKey, tcpHostTarget] of Object.entries(tcpHosts)) {\n\t\tconst exposedEndpoint = parseTcpHostEndpoint(tcpHostKey);\n\t\tconst targetEndpoint = parseTcpHostEndpoint(tcpHostTarget);\n\t\tif (\n\t\t\t!exposedEndpoint ||\n\t\t\t!targetEndpoint ||\n\t\t\t!endpointHostnameIsInternal(targetEndpoint.hostname)\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\t!rules.some(\n\t\t\t\t(rule) => rule.hostname === exposedEndpoint.hostname && rule.port === exposedEndpoint.port,\n\t\t\t)\n\t\t) {\n\t\t\trules.push(exposedEndpoint);\n\t\t}\n\t}\n\treturn rules;\n}\n\nfunction mergeUniqueHosts(\n\thosts: readonly string[],\n\tadditionalHosts: readonly string[],\n): readonly string[] {\n\tconst mergedHosts = [...hosts];\n\tfor (const host of additionalHosts) {\n\t\tif (!mergedHosts.includes(host)) {\n\t\t\tmergedHosts.push(host);\n\t\t}\n\t}\n\treturn mergedHosts;\n}\n\nfunction normalizeGitRepoPath(repoPath: string): string {\n\treturn repoPath.replace(/^\\/+/u, '').replace(/\\.git$/u, '');\n}\n\nexport function createGitReadOnlySshEgressOptions(\n\toptions: GitReadOnlySshEgressOptions,\n): ManagedSshEgressOptions {\n\tconst allowedRepos =\n\t\toptions.allowedRepos === undefined\n\t\t\t? undefined\n\t\t\t: new Set(options.allowedRepos.map((repoPath) => normalizeGitRepoPath(repoPath)));\n\n\treturn {\n\t\tallowedHosts: [...options.allowedHosts],\n\t\t...(options.agent ? { agent: options.agent } : {}),\n\t\t...(options.knownHostsFile ? { knownHostsFile: options.knownHostsFile } : {}),\n\t\texecPolicy: (request) => {\n\t\t\tconst gitExec = getInfoFromSshExecRequest(request);\n\t\t\tif (!gitExec) {\n\t\t\t\treturn {\n\t\t\t\t\tallow: false,\n\t\t\t\t\tmessage: 'agent-vm: non-git SSH exec is denied',\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (gitExec.service === 'git-receive-pack') {\n\t\t\t\treturn {\n\t\t\t\t\tallow: false,\n\t\t\t\t\tmessage: 'agent-vm: git push over guest SSH is denied',\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (gitExec.service !== 'git-upload-pack') {\n\t\t\t\treturn {\n\t\t\t\t\tallow: false,\n\t\t\t\t\tmessage: 'agent-vm: unsupported git SSH service is denied',\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (allowedRepos && !allowedRepos.has(normalizeGitRepoPath(gitExec.repo))) {\n\t\t\t\treturn {\n\t\t\t\t\tallow: false,\n\t\t\t\t\tmessage: 'agent-vm: git repository is not allowlisted for guest SSH reads',\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn { allow: true };\n\t\t},\n\t};\n}\n\nfunction createInternalTcpHostPolicy(\n\trules: readonly InternalTcpHostRule[],\n): HttpHooks['isIpAllowed'] | undefined {\n\tif (rules.length === 0) {\n\t\treturn undefined;\n\t}\n\tconst ruleHostnames = new Set(rules.map((rule) => rule.hostname));\n\treturn (info) => {\n\t\tconst hostname = normalizePolicyHostname(info.hostname);\n\t\tconst exactRuleMatched = rules.some(\n\t\t\t(rule) => rule.hostname === hostname && rule.port === info.port,\n\t\t);\n\t\tif (ruleHostnames.has(hostname)) {\n\t\t\treturn exactRuleMatched;\n\t\t}\n\t\tif (ipAddressIsInternal(info.ip)) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t};\n}\n\nexport async function createManagedVm(\n\toptions: CreateVmOptions,\n\tdependencies: ManagedVmDependencies = createDefaultDependencies(),\n): Promise<ManagedVm> {\n\tdependencies.configureHostNetworkDefaults?.();\n\tconst hasTcpHosts = options.tcpHosts && Object.keys(options.tcpHosts).length > 0;\n\tconst hasSshEgress = options.sshEgress !== undefined && options.sshEgress.allowedHosts.length > 0;\n\tconst internalTcpHostRules = deriveInternalTcpHostRules(options.tcpHosts);\n\tconst allowedInternalHosts = mergeUniqueHosts(\n\t\t[],\n\t\tinternalTcpHostRules.map((rule) => rule.hostname),\n\t);\n\tconst isIpAllowed = createInternalTcpHostPolicy(internalTcpHostRules);\n\tconst pinnedRealFsRoots = collectPinnedRealFsRoots(options.vfsMounts);\n\tlet createdVfsMounts: CreatedVfsMounts;\n\tlet vmInstance: ManagedVmInstance;\n\ttry {\n\t\tcreatedVfsMounts = createVfsMounts(options.vfsMounts, dependencies);\n\t\tconst hookBundle = dependencies.createHttpHooks({\n\t\t\tallowedHosts: options.allowedHosts,\n\t\t\t...(allowedInternalHosts.length > 0 ? { allowedInternalHosts } : {}),\n\t\t\t...(isIpAllowed ? { isIpAllowed } : {}),\n\t\t\tsecrets: options.secrets,\n\t\t\t...(options.onRequest ? { onRequest: options.onRequest } : {}),\n\t\t\t...(options.onResponse ? { onResponse: options.onResponse } : {}),\n\t\t});\n\t\tvmInstance = await dependencies.createVm({\n\t\t\t...(options.imagePath.length > 0 ? { sandbox: { imagePath: options.imagePath } } : {}),\n\t\t\t...(options.sessionLabel ? { sessionLabel: options.sessionLabel } : {}),\n\t\t\trootfs: {\n\t\t\t\tmode: options.rootfsMode,\n\t\t\t\t...(options.runtimeRootfsSize === undefined ? {} : { size: options.runtimeRootfsSize }),\n\t\t\t},\n\t\t\tmemory: options.memory,\n\t\t\tcpus: options.cpus,\n\t\t\tenv: {\n\t\t\t\t...hookBundle.env,\n\t\t\t\t...options.env,\n\t\t\t},\n\t\t\thttpHooks: hookBundle.httpHooks,\n\t\t\tvfs: {\n\t\t\t\tfuseMount: '/data',\n\t\t\t\tmounts: createdVfsMounts.mounts,\n\t\t\t},\n\t\t\t...(hasTcpHosts || hasSshEgress\n\t\t\t\t? {\n\t\t\t\t\t\tdns: {\n\t\t\t\t\t\t\tmode: 'synthetic',\n\t\t\t\t\t\t\tsyntheticIPv4: SYNTHETIC_DNS_IPV4_BENCHMARK,\n\t\t\t\t\t\t\tsyntheticIPv6: SYNTHETIC_DNS_IPV6_IPV4_MAPPED_BENCHMARK,\n\t\t\t\t\t\t\tsyntheticHostMapping: 'per-host',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t...(hasSshEgress ? { ssh: options.sshEgress } : {}),\n\t\t\t\t\t\t...(hasTcpHosts\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\ttcp: {\n\t\t\t\t\t\t\t\t\t\thosts: options.tcpHosts,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t});\n\t} catch (error) {\n\t\tclosePinnedRealFsRootsAfterFailure(pinnedRealFsRoots, dependencies);\n\t\tthrow error;\n\t}\n\n\tlet finalizationPoison: unknown;\n\tlet lifecycleState: 'closed' | 'created' | 'started' = 'created';\n\tconst poisonFinalization = (error: unknown): void => {\n\t\tfinalizationPoison ??= error;\n\t};\n\treturn {\n\t\tfs: vmInstance.fs,\n\t\tid: vmInstance.id,\n\t\texec(command: ManagedExecInput, execOptions?: ManagedExecOptions): ManagedExecProcess {\n\t\t\tconst normalizedCommand = typeof command === 'string' ? command : [...command];\n\t\t\treturn vmInstance.exec(normalizedCommand, execOptions);\n\t\t},\n\t\tasync enableSsh(sshOptions?: EnableSshOptions): Promise<SshAccess> {\n\t\t\tconst sshAccess = await vmInstance.enableSsh(sshOptions);\n\t\t\tlet serverHostKey: SshServerHostKey;\n\t\t\ttry {\n\t\t\t\tserverHostKey = await readSshServerHostKey(vmInstance);\n\t\t\t} catch (identityError) {\n\t\t\t\treturn await closeSshAccessAfterIdentityFailure(sshAccess, identityError);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tclose: async (): Promise<void> => await sshAccess.close(),\n\t\t\t\tcommand: sshAccess.command,\n\t\t\t\thost: sshAccess.host,\n\t\t\t\tidentityFile: sshAccess.identityFile,\n\t\t\t\tport: sshAccess.port,\n\t\t\t\tserverHostKey,\n\t\t\t\tuser: sshAccess.user,\n\t\t\t};\n\t\t},\n\t\tasync enableIngress(ingressOptions?: EnableIngressOptions): Promise<IngressAccess> {\n\t\t\treturn await vmInstance.enableIngress(resolveManagedVmIngressOptions(ingressOptions));\n\t\t},\n\t\tasync finalizeMemoryMount(request: ManagedVmFinalizeMemoryMountRequest): Promise<void> {\n\t\t\tif (lifecycleState === 'closed') {\n\t\t\t\tthrow new Error('Managed Gondolin VM memory mounts cannot be finalized after close.');\n\t\t\t}\n\t\t\tif (lifecycleState === 'started') {\n\t\t\t\tthrow new Error('Managed Gondolin VM memory mounts cannot be finalized after start.');\n\t\t\t}\n\t\t\tif (finalizationPoison !== undefined) {\n\t\t\t\tthrow new Error('Managed Gondolin VM memory mount finalization is poisoned.', {\n\t\t\t\t\tcause: finalizationPoison,\n\t\t\t\t});\n\t\t\t}\n\t\t\tlet validatedRequest: ManagedVmFinalizeMemoryMountRequest;\n\t\t\ttry {\n\t\t\t\tvalidatedRequest = validateManagedVmFinalizeMemoryMountRequest(request);\n\t\t\t\tconst mount = createdVfsMounts.finalizableMemoryMounts.get(validatedRequest.guestPath);\n\t\t\t\tif (mount === undefined) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Managed Gondolin VM has no declared finalizable memory mount at '${validatedRequest.guestPath}'.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (mount.state !== 'pending') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Managed Gondolin VM memory mount '${validatedRequest.guestPath}' must be finalized exactly once.`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tmount.state = 'finalizing';\n\t\t\t\tif (mount.provider.writeFile === undefined) {\n\t\t\t\t\tthrow new Error('Gondolin memory provider does not support file writes.');\n\t\t\t\t}\n\t\t\t\tfor (const file of validatedRequest.files) {\n\t\t\t\t\t// oxlint-disable-next-line no-await-in-loop -- one-shot inventory publication is intentionally ordered.\n\t\t\t\t\tawait mount.provider.writeFile(`/${file.relativePath}`, Buffer.from(file.contents), {\n\t\t\t\t\t\tmode: file.mode,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tmount.state = 'finalized';\n\t\t\t} catch (error) {\n\t\t\t\tconst mount = createdVfsMounts.finalizableMemoryMounts.get(request.guestPath);\n\t\t\t\tif (mount !== undefined) mount.state = 'failed';\n\t\t\t\tpoisonFinalization(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tgetHostPid(): number | null {\n\t\t\treturn vmInstance.getHostPid?.() ?? null;\n\t\t},\n\t\tgetVmInstance(): ManagedVmInstance {\n\t\t\treturn vmInstance;\n\t\t},\n\t\tsetIngressRoutes(routes: readonly IngressRoute[]): void {\n\t\t\tvmInstance.setIngressRoutes(routes);\n\t\t},\n\t\tasync start(): Promise<void> {\n\t\t\tif (finalizationPoison !== undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Managed Gondolin VM cannot start after memory finalization was poisoned.',\n\t\t\t\t\t{\n\t\t\t\t\t\tcause: finalizationPoison,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst incompleteMount = [...createdVfsMounts.finalizableMemoryMounts].find(\n\t\t\t\t([, mount]) => mount.state !== 'finalized',\n\t\t\t);\n\t\t\tif (incompleteMount !== undefined) {\n\t\t\t\tconst error = new Error(\n\t\t\t\t\t`Managed Gondolin VM memory mount '${incompleteMount[0]}' must be finalized before start.`,\n\t\t\t\t);\n\t\t\t\tpoisonFinalization(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tawait vmInstance.start();\n\t\t\tlifecycleState = 'started';\n\t\t},\n\t\tasync close(): Promise<void> {\n\t\t\tconst closeErrors: unknown[] = [];\n\t\t\ttry {\n\t\t\t\tawait vmInstance.close();\n\t\t\t} catch (error) {\n\t\t\t\tcloseErrors.push(error);\n\t\t\t}\n\t\t\tlifecycleState = 'closed';\n\t\t\tcreatedVfsMounts.finalizableMemoryMounts.clear();\n\t\t\ttry {\n\t\t\t\tclosePinnedRealFsRoots(pinnedRealFsRoots, dependencies);\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof AggregateError) {\n\t\t\t\t\tcloseErrors.push(...error.errors);\n\t\t\t\t} else {\n\t\t\t\t\tcloseErrors.push(error);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (closeErrors.length === 1) {\n\t\t\t\tthrow closeErrors[0];\n\t\t\t}\n\t\t\tif (closeErrors.length > 1) {\n\t\t\t\tthrow new AggregateError(closeErrors, 'Managed Gondolin VM cleanup failed.');\n\t\t\t}\n\t\t},\n\t};\n}\n","import fs from 'node:fs/promises';\nimport path from 'node:path';\n\nimport {\n\tcreateOwnedHostDirectoryController,\n\tassertPositiveHostProcessId,\n\tvalidateManagedVmFilteredWorkspacePolicy,\n\ttype ManagedVm,\n\ttype ManagedVmAccessHandle,\n\ttype ManagedVmCreateRequest,\n\ttype ManagedVmExecCommand,\n\ttype ManagedVmExecOptions,\n\ttype ManagedVmExecOutputChunk,\n\ttype ManagedVmExecProcess,\n\ttype ManagedVmExecResult,\n\ttype ManagedVmExecStreamMode,\n\ttype ManagedVmIngressOptions,\n\ttype ManagedVmIngressRoute,\n\ttype ManagedVmProvider,\n\ttype ManagedVmSshAccess,\n\ttype OwnedHostDirectory,\n\ttype OwnedHostDirectoryTransfer,\n} from '@agent-vm/managed-vm';\nimport { validateBuildConfig } from '@earendil-works/gondolin';\nimport { parse, printParseErrorCode, type ParseError } from 'jsonc-parser';\n\nimport { buildImage } from './build-pipeline.js';\nimport { createGondolinExactProcessTerminationCapability } from './exact-recorded-process-termination.js';\nimport {\n\tresolveGondolinMinimumZigVersion,\n\tresolveGondolinPackageSpec,\n} from './gondolin-package.js';\nimport {\n\tassertPinnedRealFsRoot,\n\tclosePinnedRealFsRoot,\n\tpinRealFsRoot,\n\ttype PinnedRealFsRoot,\n} from './pinned-realfs.js';\nimport {\n\tcreateGitReadOnlySshEgressOptions,\n\tcreateManagedVm as createNativeManagedVm,\n\ttype ManagedExecOptions as NativeManagedExecOptions,\n\ttype ManagedVm as NativeManagedVm,\n\ttype VfsMountSpec,\n} from './vm-adapter.js';\n\ntype OwnedDirectoryProvenance = WeakMap<OwnedHostDirectory, PinnedRealFsRoot>;\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction formatUnknownValue(value: unknown): string {\n\treturn typeof value === 'string' ? value : JSON.stringify(value);\n}\n\nfunction assertCreateRequestSupported(request: ManagedVmCreateRequest): void {\n\tif (!['readonly', 'memory', 'cow'].includes(request.rootfsMode)) {\n\t\tthrow new Error(\n\t\t\t`Unsupported managed VM rootfs mode: ${formatUnknownValue(request.rootfsMode)}`,\n\t\t);\n\t}\n\tif (!Number.isSafeInteger(request.resources.cpuCount) || request.resources.cpuCount <= 0) {\n\t\tthrow new Error('Managed VM CPU count must be a positive safe integer.');\n\t}\n\tif (request.imageReference.length === 0 || request.resources.memory.length === 0) {\n\t\tthrow new Error('Managed VM image reference and memory must be non-empty.');\n\t}\n\tif (request.sshEgress !== undefined && request.sshEgress.kind !== 'git-read-only') {\n\t\tthrow new Error(\n\t\t\t`Unsupported managed VM SSH egress kind: ${formatUnknownValue(request.sshEgress.kind)}`,\n\t\t);\n\t}\n\tfor (const [guestPath, mount] of Object.entries(request.mounts)) {\n\t\tif (!guestPath.startsWith('/')) {\n\t\t\tthrow new Error(`Managed VM mount path must be absolute: ${guestPath}`);\n\t\t}\n\t\tif (\n\t\t\t![\n\t\t\t\t'host-directory',\n\t\t\t\t'finalizable-memory',\n\t\t\t\t'owned-host-directory',\n\t\t\t\t'owned-filtered-workspace',\n\t\t\t\t'memory',\n\t\t\t\t'shadow',\n\t\t\t].includes(mount.kind)\n\t\t) {\n\t\t\tthrow new Error(`Unsupported managed VM mount kind: ${formatUnknownValue(mount.kind)}`);\n\t\t}\n\t}\n\tconst mediatedSecretNames = new Set<string>();\n\tfor (const secret of request.mediatedSecrets) {\n\t\tif (mediatedSecretNames.has(secret.environmentVariable)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Duplicate managed VM mediated-secret environment variable: ${secret.environmentVariable}`,\n\t\t\t);\n\t\t}\n\t\tmediatedSecretNames.add(secret.environmentVariable);\n\t}\n\tconst tcpGuestHosts = new Set<string>();\n\tfor (const mapping of request.tcpHosts) {\n\t\tif (tcpGuestHosts.has(mapping.guestHost)) {\n\t\t\tthrow new Error(`Duplicate managed VM TCP guest host: ${mapping.guestHost}`);\n\t\t}\n\t\ttcpGuestHosts.add(mapping.guestHost);\n\t}\n}\n\ninterface TranslatedMounts {\n\treadonly mounts: Record<string, VfsMountSpec>;\n\treadonly transfers: readonly OwnedHostDirectoryTransfer[];\n}\n\nfunction closeOwnedDirectoryTransfers(\n\ttransfers: readonly OwnedHostDirectoryTransfer[],\n): readonly unknown[] {\n\tconst closeErrors: unknown[] = [];\n\tfor (const transfer of transfers) {\n\t\ttry {\n\t\t\ttransfer.close();\n\t\t} catch (error) {\n\t\t\tcloseErrors.push(error);\n\t\t}\n\t}\n\treturn closeErrors;\n}\n\nfunction isReadonlyStringArray(\n\tvalue: readonly string[] | Readonly<Record<string, string>>,\n): value is readonly string[] {\n\treturn Array.isArray(value);\n}\n\nfunction translateExecEnvironment(\n\tenvironment: readonly string[] | Readonly<Record<string, string>>,\n): string[] | Record<string, string> {\n\treturn isReadonlyStringArray(environment) ? [...environment] : { ...environment };\n}\n\nfunction translateExecStdin(\n\tstdin: string | Uint8Array | AsyncIterable<Uint8Array>,\n): string | Buffer | AsyncIterable<Buffer> {\n\tif (typeof stdin === 'string') {\n\t\treturn stdin;\n\t}\n\tif (stdin instanceof Uint8Array) {\n\t\treturn Buffer.from(stdin);\n\t}\n\treturn (async function* (): AsyncIterable<Buffer> {\n\t\tfor await (const chunk of stdin) {\n\t\t\tyield Buffer.from(chunk);\n\t\t}\n\t})();\n}\n\nconst MANAGED_VM_EXEC_OUTPUT_WINDOW_MIN_BYTES = 4 * 1024;\nconst MANAGED_VM_EXEC_OUTPUT_WINDOW_MAX_BYTES = 16 * 1024 * 1024;\n\nfunction translateExecStreamMode(mode: ManagedVmExecStreamMode): 'ignore' | 'pipe' {\n\tif (typeof mode !== 'object' || mode === null || !('kind' in mode)) {\n\t\tthrow new Error('Unsupported managed VM exec output mode.');\n\t}\n\tif (mode.kind === 'pipe') {\n\t\treturn 'pipe';\n\t}\n\tif (mode.kind === 'discard') {\n\t\treturn 'ignore';\n\t}\n\tthrow new Error('Unsupported managed VM exec output mode.');\n}\n\nfunction translateExecStreamingOptions(\n\toutput: NonNullable<ManagedVmExecOptions['output']>,\n): Pick<NativeManagedExecOptions, 'stderr' | 'stdout' | 'windowBytes'> {\n\tif (\n\t\t!Number.isInteger(output.windowBytes) ||\n\t\toutput.windowBytes < MANAGED_VM_EXEC_OUTPUT_WINDOW_MIN_BYTES ||\n\t\toutput.windowBytes > MANAGED_VM_EXEC_OUTPUT_WINDOW_MAX_BYTES\n\t) {\n\t\tthrow new Error(\n\t\t\t`Managed VM exec output window must be an integer between ${String(MANAGED_VM_EXEC_OUTPUT_WINDOW_MIN_BYTES)} and ${String(MANAGED_VM_EXEC_OUTPUT_WINDOW_MAX_BYTES)} bytes.`,\n\t\t);\n\t}\n\treturn {\n\t\tstderr: translateExecStreamMode(output.stderr),\n\t\tstdout: translateExecStreamMode(output.stdout),\n\t\twindowBytes: output.windowBytes,\n\t};\n}\n\nfunction translateExecOptions(options: ManagedVmExecOptions): NativeManagedExecOptions {\n\treturn {\n\t\t...(options.argv ? { argv: [...options.argv] } : {}),\n\t\t...(options.cwd ? { cwd: options.cwd } : {}),\n\t\t...(options.env ? { env: translateExecEnvironment(options.env) } : {}),\n\t\t...(options.output === undefined ? {} : translateExecStreamingOptions(options.output)),\n\t\t...(options.pty === undefined ? {} : { pty: options.pty }),\n\t\t...(options.signal ? { signal: options.signal } : {}),\n\t\t...(options.stdin === undefined ? {} : { stdin: translateExecStdin(options.stdin) }),\n\t};\n}\n\nfunction wrapExecProcess(nativeProcess: ReturnType<NativeManagedVm['exec']>): ManagedVmExecProcess {\n\tconst result: Promise<ManagedVmExecResult> = nativeProcess.result;\n\treturn Object.assign(result, {\n\t\t[Symbol.asyncIterator](): AsyncIterator<string> {\n\t\t\treturn nativeProcess[Symbol.asyncIterator]();\n\t\t},\n\t\tend(): void {\n\t\t\tnativeProcess.end();\n\t\t},\n\t\tlines(): AsyncIterable<string> {\n\t\t\treturn nativeProcess.lines();\n\t\t},\n\t\toutput(): AsyncIterable<ManagedVmExecOutputChunk> {\n\t\t\treturn nativeProcess.output();\n\t\t},\n\t\tresize(rows: number, columns: number): void {\n\t\t\tnativeProcess.resize(rows, columns);\n\t\t},\n\t\tresult,\n\t\twrite(data: string | Uint8Array): void {\n\t\t\tnativeProcess.write(typeof data === 'string' ? data : Buffer.from(data));\n\t\t},\n\t}) satisfies ManagedVmExecProcess;\n}\n\nasync function assertReadonlyInputSourcesStayWithinOwnedRoot(\n\tpinnedRoot: PinnedRealFsRoot,\n\tpolicy: ReturnType<typeof validateManagedVmFilteredWorkspacePolicy>,\n): Promise<void> {\n\tconst canonicalRootPrefix = pinnedRoot.realPath.endsWith(path.sep)\n\t\t? pinnedRoot.realPath\n\t\t: `${pinnedRoot.realPath}${path.sep}`;\n\tawait Promise.all(\n\t\tpolicy.readonlyInputs.map(async (readonlyInput) => {\n\t\t\tconst sourcePath = path.join(\n\t\t\t\tpinnedRoot.realPath,\n\t\t\t\t...readonlyInput.sourceRelativePath.split('/'),\n\t\t\t);\n\t\t\tconst canonicalSourcePath = await fs.realpath(sourcePath);\n\t\t\tif (\n\t\t\t\tcanonicalSourcePath !== pinnedRoot.realPath &&\n\t\t\t\t!canonicalSourcePath.startsWith(canonicalRootPrefix)\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Managed filtered workspace read-only source crosses the owned root boundary: ${readonlyInput.sourceRelativePath}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}),\n\t);\n}\n\nasync function translateMounts(\n\tmounts: ManagedVmCreateRequest['mounts'],\n\townedDirectoryRoots: OwnedDirectoryProvenance,\n): Promise<TranslatedMounts> {\n\tconst translatedMounts: Record<string, VfsMountSpec> = {};\n\tconst transfers: OwnedHostDirectoryTransfer[] = [];\n\tconst sourceValidations: {\n\t\treadonly pinnedRoot: PinnedRealFsRoot;\n\t\treadonly policy: ReturnType<typeof validateManagedVmFilteredWorkspacePolicy>;\n\t}[] = [];\n\ttry {\n\t\tfor (const [guestPath, mount] of Object.entries(mounts)) {\n\t\t\tswitch (mount.kind) {\n\t\t\t\tcase 'finalizable-memory':\n\t\t\t\t\ttranslatedMounts[guestPath] = {\n\t\t\t\t\t\taccess: mount.access,\n\t\t\t\t\t\tkind: 'finalizable-memory',\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'host-directory':\n\t\t\t\t\ttranslatedMounts[guestPath] = {\n\t\t\t\t\t\thostPath: mount.hostPath,\n\t\t\t\t\t\tkind: mount.access === 'read-only' ? 'realfs-readonly' : 'realfs',\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'owned-host-directory': {\n\t\t\t\t\tconst pinnedRoot = ownedDirectoryRoots.get(mount.directory);\n\t\t\t\t\tif (!pinnedRoot) {\n\t\t\t\t\t\tthrow new Error('Owned host directory was not acquired by this Gondolin provider.');\n\t\t\t\t\t}\n\t\t\t\t\tassertPinnedRealFsRoot(pinnedRoot);\n\t\t\t\t\ttransfers.push(mount.directory.consume());\n\t\t\t\t\townedDirectoryRoots.delete(mount.directory);\n\t\t\t\t\ttranslatedMounts[guestPath] = {\n\t\t\t\t\t\tkind: mount.access === 'read-only' ? 'realfs-readonly' : 'realfs',\n\t\t\t\t\t\tpinnedHostRoot: pinnedRoot,\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'owned-filtered-workspace': {\n\t\t\t\t\tconst pinnedRoot = ownedDirectoryRoots.get(mount.directory);\n\t\t\t\t\tif (!pinnedRoot) {\n\t\t\t\t\t\tthrow new Error('Owned host directory was not acquired by this Gondolin provider.');\n\t\t\t\t\t}\n\t\t\t\t\tassertPinnedRealFsRoot(pinnedRoot);\n\t\t\t\t\ttransfers.push(mount.directory.consume());\n\t\t\t\t\townedDirectoryRoots.delete(mount.directory);\n\t\t\t\t\tconst policy = validateManagedVmFilteredWorkspacePolicy(mount.policy);\n\t\t\t\t\tsourceValidations.push({ pinnedRoot, policy });\n\t\t\t\t\ttranslatedMounts[guestPath] = {\n\t\t\t\t\t\tkind: 'filtered-workspace',\n\t\t\t\t\t\tpinnedHostRoot: pinnedRoot,\n\t\t\t\t\t\tpolicy,\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase 'memory':\n\t\t\t\t\ttranslatedMounts[guestPath] = { kind: 'memory' };\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'shadow':\n\t\t\t\t\ttranslatedMounts[guestPath] = {\n\t\t\t\t\t\thostPath: mount.hostPath,\n\t\t\t\t\t\tkind: 'shadow',\n\t\t\t\t\t\tshadowConfig: {\n\t\t\t\t\t\t\tdeny: mount.deny,\n\t\t\t\t\t\t\ttmpfs: mount.temporaryFilesystems,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tawait Promise.all(\n\t\t\tsourceValidations.map(({ pinnedRoot, policy }) =>\n\t\t\t\tassertReadonlyInputSourcesStayWithinOwnedRoot(pinnedRoot, policy),\n\t\t\t),\n\t\t);\n\t} catch (error) {\n\t\tconst closeErrors = closeOwnedDirectoryTransfers(transfers);\n\t\tif (closeErrors.length > 0) {\n\t\t\t// oxlint-disable-next-line preserve-caught-error -- AggregateError cause and errors both retain the primary translation failure.\n\t\t\tthrow new AggregateError(\n\t\t\t\t[error, ...closeErrors],\n\t\t\t\t'Managed VM mount translation and owned-directory cleanup both failed.',\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t\tthrow error;\n\t}\n\treturn { mounts: translatedMounts, transfers };\n}\n\nfunction wrapManagedVm(\n\tnativeVm: NativeManagedVm,\n\townedDirectoryTransfers: readonly OwnedHostDirectoryTransfer[],\n): ManagedVm {\n\ttype ManagedVmLifecycleState =\n\t\t| 'created'\n\t\t| 'starting'\n\t\t| 'started'\n\t\t| 'start-failed'\n\t\t| 'closing'\n\t\t| 'closed';\n\tlet closePromise: Promise<void> | undefined;\n\tlet hostProcessId: number | null = null;\n\tlet lifecycleState: ManagedVmLifecycleState = 'created';\n\tlet startPromise: Promise<void> | undefined;\n\tconst closeOnce = async (): Promise<void> => {\n\t\tif (startPromise) {\n\t\t\ttry {\n\t\t\t\tawait startPromise;\n\t\t\t} catch {\n\t\t\t\t// Mechanical close must continue after either start success or failure.\n\t\t\t}\n\t\t}\n\t\tconst closeErrors: unknown[] = [];\n\t\ttry {\n\t\t\tawait nativeVm.close();\n\t\t} catch (error) {\n\t\t\tcloseErrors.push(error);\n\t\t}\n\t\tcloseErrors.push(...closeOwnedDirectoryTransfers(ownedDirectoryTransfers));\n\t\ttry {\n\t\t\tif (closeErrors.length === 1) {\n\t\t\t\tthrow closeErrors[0];\n\t\t\t}\n\t\t\tif (closeErrors.length > 1) {\n\t\t\t\tthrow new AggregateError(closeErrors, 'Managed VM cleanup failed.');\n\t\t\t}\n\t\t} finally {\n\t\t\thostProcessId = null;\n\t\t\tlifecycleState = 'closed';\n\t\t}\n\t};\n\treturn {\n\t\tasync close(): Promise<void> {\n\t\t\tif (!closePromise) {\n\t\t\t\tlifecycleState = 'closing';\n\t\t\t\tclosePromise = closeOnce();\n\t\t\t}\n\t\t\tawait closePromise;\n\t\t},\n\t\tconfigureIngressRoutes(routes: readonly ManagedVmIngressRoute[]): void {\n\t\t\tnativeVm.setIngressRoutes(\n\t\t\t\troutes.map((route) => ({\n\t\t\t\t\tport: route.port,\n\t\t\t\t\tprefix: route.prefix,\n\t\t\t\t\tstripPrefix: route.stripPrefix,\n\t\t\t\t})),\n\t\t\t);\n\t\t},\n\t\tasync enableIngress(options?: ManagedVmIngressOptions): Promise<ManagedVmAccessHandle> {\n\t\t\treturn await nativeVm.enableIngress(options);\n\t\t},\n\t\tasync enableSsh(options): Promise<ManagedVmSshAccess> {\n\t\t\tconst access = await nativeVm.enableSsh(options);\n\t\t\tif (!access.command || !access.identityFile || !access.user) {\n\t\t\t\tawait access.close();\n\t\t\t\tthrow new Error('Gondolin SSH access omitted required neutral connection fields.');\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tclose: async (): Promise<void> => await access.close(),\n\t\t\t\tcommand: access.command,\n\t\t\t\thost: access.host,\n\t\t\t\tidentityFile: access.identityFile,\n\t\t\t\tport: access.port,\n\t\t\t\tserverHostKey: access.serverHostKey,\n\t\t\t\tuser: access.user,\n\t\t\t};\n\t\t},\n\t\tasync finalizeMemoryMount(request): Promise<void> {\n\t\t\tawait nativeVm.finalizeMemoryMount(request);\n\t\t},\n\t\texec(command: ManagedVmExecCommand, options?: ManagedVmExecOptions): ManagedVmExecProcess {\n\t\t\tconst normalizedCommand = typeof command === 'string' ? command : [...command];\n\t\t\tconst nativeProcess = nativeVm.exec(\n\t\t\t\tnormalizedCommand,\n\t\t\t\toptions ? translateExecOptions(options) : undefined,\n\t\t\t);\n\t\t\treturn wrapExecProcess(nativeProcess);\n\t\t},\n\t\tgetHostProcessId(): number | null {\n\t\t\tif (hostProcessId === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst currentHostProcessId = nativeVm.getHostPid();\n\t\t\tif (currentHostProcessId === null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tif (currentHostProcessId !== hostProcessId) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Gondolin runner identity changed for managed VM '${nativeVm.id}': expected pid ${String(hostProcessId)}, observed ${String(currentHostProcessId)}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn hostProcessId;\n\t\t},\n\t\tid: nativeVm.id,\n\t\tasync start(): Promise<void> {\n\t\t\tif (lifecycleState === 'closing' || lifecycleState === 'closed') {\n\t\t\t\tthrow new Error('Managed VM cannot start after close has been requested.');\n\t\t\t}\n\t\t\tif (lifecycleState === 'started') {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!startPromise) {\n\t\t\t\tlifecycleState = 'starting';\n\t\t\t\tstartPromise = (async (): Promise<void> => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait nativeVm.start();\n\t\t\t\t\t\tconst startedHostProcessId = assertPositiveHostProcessId(nativeVm.getHostPid());\n\t\t\t\t\t\tif (lifecycleState !== 'starting') {\n\t\t\t\t\t\t\tthrow new Error('Managed VM closed while startup was settling.');\n\t\t\t\t\t\t}\n\t\t\t\t\t\thostProcessId = startedHostProcessId;\n\t\t\t\t\t\tlifecycleState = 'started';\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tif (lifecycleState === 'starting') {\n\t\t\t\t\t\t\tlifecycleState = 'start-failed';\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t})();\n\t\t\t}\n\t\t\tawait startPromise;\n\t\t},\n\t};\n}\n\nfunction openOwnedHostDirectory(\n\thostPath: string,\n\townedDirectoryRoots: OwnedDirectoryProvenance,\n): OwnedHostDirectory {\n\tconst pinnedRoot = pinRealFsRoot(hostPath);\n\tconst directory = createOwnedHostDirectoryController({\n\t\tidentity: {\n\t\t\tcanonicalPath: pinnedRoot.realPath,\n\t\t\tdevice: pinnedRoot.device,\n\t\t\tinode: pinnedRoot.inode,\n\t\t},\n\t\tonClose: () => closePinnedRealFsRoot(pinnedRoot),\n\t\tonConsume: () => assertPinnedRealFsRoot(pinnedRoot),\n\t});\n\townedDirectoryRoots.set(directory, pinnedRoot);\n\treturn directory;\n}\n\nexport function createGondolinManagedVmProvider(): ManagedVmProvider {\n\tconst ownedDirectoryRoots: OwnedDirectoryProvenance = new WeakMap();\n\treturn {\n\t\tdiagnostics: {\n\t\t\tasync checkCompatibility() {\n\t\t\t\tconst diagnostics = [];\n\t\t\t\ttry {\n\t\t\t\t\tawait Promise.all([resolveGondolinPackageSpec(), resolveGondolinMinimumZigVersion()]);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tdiagnostics.push({\n\t\t\t\t\t\tcode: 'gondolin-toolchain-unavailable',\n\t\t\t\t\t\tmessage: error instanceof Error ? error.message : String(error),\n\t\t\t\t\t\tseverity: 'error' as const,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn diagnostics;\n\t\t\t},\n\t\t},\n\t\texactProcessTermination: createGondolinExactProcessTerminationCapability(),\n\t\tfactory: {\n\t\t\tasync createManagedVm(request: ManagedVmCreateRequest): Promise<ManagedVm> {\n\t\t\t\tassertCreateRequestSupported(request);\n\t\t\t\tconst secrets = Object.fromEntries(\n\t\t\t\t\trequest.mediatedSecrets.map((secret) => [\n\t\t\t\t\t\tsecret.environmentVariable,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\thosts: [...secret.allowedHosts],\n\t\t\t\t\t\t\t...(secret.guestPlaceholder === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: { placeholder: secret.guestPlaceholder }),\n\t\t\t\t\t\t\tvalue: secret.value,\n\t\t\t\t\t\t},\n\t\t\t\t\t]),\n\t\t\t\t);\n\t\t\t\tconst tcpHosts = Object.fromEntries(\n\t\t\t\t\trequest.tcpHosts.map((mapping) => [mapping.guestHost, mapping.target]),\n\t\t\t\t);\n\t\t\t\tconst translatedMounts = await translateMounts(request.mounts, ownedDirectoryRoots);\n\t\t\t\tlet nativeVm: NativeManagedVm;\n\t\t\t\ttry {\n\t\t\t\t\tnativeVm = await createNativeManagedVm({\n\t\t\t\t\t\tallowedHosts: [...request.allowedHosts],\n\t\t\t\t\t\tcpus: request.resources.cpuCount,\n\t\t\t\t\t\tenv: { ...request.environment },\n\t\t\t\t\t\timagePath: request.imageReference,\n\t\t\t\t\t\tmemory: request.resources.memory,\n\t\t\t\t\t\t...(request.mediation?.onRequest ? { onRequest: request.mediation.onRequest } : {}),\n\t\t\t\t\t\t...(request.mediation?.onResponse ? { onResponse: request.mediation.onResponse } : {}),\n\t\t\t\t\t\trootfsMode: request.rootfsMode,\n\t\t\t\t\t\t...(request.runtimeRootfsSize ? { runtimeRootfsSize: request.runtimeRootfsSize } : {}),\n\t\t\t\t\t\tsecrets,\n\t\t\t\t\t\tsessionLabel: request.sessionLabel,\n\t\t\t\t\t\t...(request.sshEgress\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tsshEgress: createGitReadOnlySshEgressOptions({\n\t\t\t\t\t\t\t\t\t\tallowedHosts: request.sshEgress.allowedHosts,\n\t\t\t\t\t\t\t\t\t\t...(request.sshEgress.agentSocket\n\t\t\t\t\t\t\t\t\t\t\t? { agent: request.sshEgress.agentSocket }\n\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t\t...(request.sshEgress.allowedRepositories\n\t\t\t\t\t\t\t\t\t\t\t? { allowedRepos: request.sshEgress.allowedRepositories }\n\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t\t...(request.sshEgress.knownHostsFile\n\t\t\t\t\t\t\t\t\t\t\t? { knownHostsFile: request.sshEgress.knownHostsFile }\n\t\t\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\ttcpHosts,\n\t\t\t\t\t\tvfsMounts: translatedMounts.mounts,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tconst closeErrors = closeOwnedDirectoryTransfers(translatedMounts.transfers);\n\t\t\t\t\tif (closeErrors.length > 0) {\n\t\t\t\t\t\t// oxlint-disable-next-line preserve-caught-error -- AggregateError cause and errors both retain the primary construction failure.\n\t\t\t\t\t\tthrow new AggregateError(\n\t\t\t\t\t\t\t[error, ...closeErrors],\n\t\t\t\t\t\t\t'Managed VM construction and owned-directory cleanup both failed.',\n\t\t\t\t\t\t\t{ cause: error },\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\treturn wrapManagedVm(nativeVm, translatedMounts.transfers);\n\t\t\t},\n\t\t},\n\t\timages: {\n\t\t\tasync prepareImage(request) {\n\t\t\t\tconst parseErrors: ParseError[] = [];\n\t\t\t\tconst parsedRecipe: unknown = parse(\n\t\t\t\t\tawait fs.readFile(request.recipePath, 'utf8'),\n\t\t\t\t\tparseErrors,\n\t\t\t\t\t{ allowTrailingComma: true },\n\t\t\t\t);\n\t\t\t\tif (parseErrors.length > 0) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Invalid managed VM image recipe '${request.recipePath}': ${parseErrors\n\t\t\t\t\t\t\t.map((parseError) => printParseErrorCode(parseError.error))\n\t\t\t\t\t\t\t.join(', ')}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (!isRecord(parsedRecipe) || !validateBuildConfig(parsedRecipe)) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Managed VM image recipe has an invalid build shape: ${request.recipePath}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst result = await buildImage({\n\t\t\t\t\tbuildConfig: parsedRecipe,\n\t\t\t\t\tcacheDir: request.cacheDirectory,\n\t\t\t\t\tconfigDir: path.dirname(request.recipePath),\n\t\t\t\t\t...(request.forceRebuild === undefined ? {} : { fullReset: request.forceRebuild }),\n\t\t\t\t});\n\t\t\t\treturn {\n\t\t\t\t\tbuilt: result.built,\n\t\t\t\t\tfingerprint: result.fingerprint,\n\t\t\t\t\timageReference: result.imagePath,\n\t\t\t\t};\n\t\t\t},\n\t\t},\n\t\townedDirectories: {\n\t\t\topenHostDirectory: (hostPath: string): OwnedHostDirectory =>\n\t\t\t\topenOwnedHostDirectory(hostPath, ownedDirectoryRoots),\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;AAKA,MAAa,+BAA+B;;;;;;;;;;;AA6C5C,MAAM,qCAAqC;AAC3C,MAAM,oCAAoC;AAC1C,MAAM,4BAA4B;AAClC,MAAM,wBAAwB;AAE9B,SAAS,qBACR,oBACS;CACT,QAAQ,oBAAR;EACC,KAAK,4BACJ,OAAO;EACR,KAAK,8BACJ,OAAO;;;AAIV,SAAS,qBACR,oBACS;CACT,OAAO,uBAAuB,+BAC3B,yBACA;;AAGJ,SAAgB,qCACf,YACS;CACT,MAAM,+BAA+B,qBAAqB,WAAW,mBAAmB;CACxF,MAAM,2BAA2B,GAAG,sBAAsB,GAAG,qBAAqB,WAAW,mBAAmB;CAChH,MAAM,8BAA8B;CACpC,MAAM,oCACL,WAAW,uBAAuB,6BAA6B,qBAAqB;CACrF,OAAO;yCACiC,mCAAmC;wCACpC,kCAAkC;WAC/D,sBAAsB;qBACZ,0BAA0B;4BACnB,sBAAsB;4BACtB,yBAAyB;;;;;;SAM5C,kCAAkC,wBAAwB,mCAAmC,wDAAwD,mCAAmC,gGAAgG,kCAAkC;OAC5T,sBAAsB;;;sCAGS,4BAA4B;;;SAGzD,kCAAkC,wBAAwB,mCAAmC,sDAAsD,mCAAmC,6CA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CAAC,OAAO,GAAG,YAAY,EACvB,oEACA,EAAE,OAAO,OAAO,CAChB;IAEF,MAAM;;GAEP,OAAO,cAAc,UAAU,iBAAiB,UAAU;KAE3D;EACD,QAAQ,EACP,MAAM,aAAa,SAAS;GAC3B,MAAM,cAA4B,EAAE;GACpC,MAAM,eAAwB,MAC7B,MAAM,GAAG,SAAS,QAAQ,YAAY,OAAO,EAC7C,aACA,EAAE,oBAAoB,MAAM,CAC5B;GACD,IAAI,YAAY,SAAS,GACxB,MAAM,IAAI,MACT,oCAAoC,QAAQ,WAAW,KAAK,YAC1D,KAAK,eAAe,oBAAoB,WAAW,MAAM,CAAC,CAC1D,KAAK,KAAK,GACZ;GAEF,IAAI,CAAC,SAAS,aAAa,IAAI,CAAC,oBAAoB,aAAa,EAChE,MAAM,IAAI,MACT,uDAAuD,QAAQ,aAC/D;GAEF,MAAM,SAAS,MAAM,WAAW;IAC/B,aAAa;IACb,UAAU,QAAQ;IAClB,WAAW,KAAK,QAAQ,QAAQ,WAAW;IAC3C,GAAI,QAAQ,iBAAiB,KAAA,IAAY,EAAE,GAAG,EAAE,WAAW,QAAQ,cAAc;IACjF,CAAC;GACF,OAAO;IACN,OAAO,OAAO;IACd,aAAa,OAAO;IACpB,gBAAgB,OAAO;IACvB;KAEF;EACD,kBAAkB,EACjB,oBAAoB,aACnB,uBAAuB,UAAU,oBAAoB,EACtD;EACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-vm/gondolin-vm-adapter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.126",
|
|
4
4
|
"description": "Gondolin implementation of the backend-neutral @agent-vm/managed-vm contracts.",
|
|
5
5
|
"homepage": "https://github.com/ShravanSunder/agent-vm#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@earendil-works/gondolin": "0.12.0",
|
|
33
33
|
"jsonc-parser": "^3.3.1",
|
|
34
34
|
"zod": "^4.4.3",
|
|
35
|
-
"@agent-vm/managed-vm": "0.0.
|
|
36
|
-
"@agent-vm/secret-management": "0.0.
|
|
35
|
+
"@agent-vm/managed-vm": "0.0.126",
|
|
36
|
+
"@agent-vm/secret-management": "0.0.126"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsdown",
|