Implement resolve_path using VOLUME_MAPPING array

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 20:27:17 +00:00
parent ac82501b48
commit 2bf658dc5f

View File

@@ -1,30 +1,23 @@
import { spawnSync } from "child_process"; import { spawnSync } from "child_process";
import path from "path"; import path from "path";
const CONTAINER_PATH = "/workspace"; const CONTAINER_PATH = "/home/devilholk/Projekt/claude-docker/";
// Maps container path prefixes to host paths.
// Derived from docker-compose.yml volumes: // Docker image → host conversation
// ./workspace -> /workspace const VOLUME_MAPPING = [
// ./claude-home -> /home/claude ['/home/claude', path.resolve(CONTAINER_PATH, 'claude-home')],
// Override host paths via env vars when running outside the default layout. ['/workspace', path.resolve(CONTAINER_PATH, 'workspace')],
const VOLUME_MAP = { ];
"/workspace": process.env.CONDUIT_HOST_WORKSPACE || CONTAINER_PATH,
"/home/claude": process.env.CONDUIT_HOST_HOME || "/home/claude",
};
// Translate a container-side path to its host-side equivalent using VOLUME_MAP. // Translate a container-side path to its host-side equivalent using VOLUME_MAP.
// Relative paths are resolved against CONTAINER_PATH first.
// Throws if the path escapes all known volumes. // Throws if the path escapes all known volumes.
export function resolve_path(user_path) { export function resolve_path(user_path) {
const abs = path.isAbsolute(user_path) const abs = path.resolve(user_path);
? user_path
: path.join(CONTAINER_PATH, user_path);
for (const [container_prefix, host_prefix] of Object.entries(VOLUME_MAP)) { for (const [container_prefix, host_prefix] of VOLUME_MAPPING) {
if (abs === container_prefix || abs.startsWith(container_prefix + "/")) { if (abs === container_prefix || abs.startsWith(container_prefix + "/")) {
const relative = abs.slice(container_prefix.length); return host_prefix + abs.slice(container_prefix.length);
return host_prefix + relative;
} }
} }