From 2bf658dc5fcb92ce4b4fc477eb3cb9d862744ff5 Mon Sep 17 00:00:00 2001 From: mikael-lovqvists-claude-agent Date: Sat, 7 Mar 2026 20:27:17 +0000 Subject: [PATCH] Implement resolve_path using VOLUME_MAPPING array Co-Authored-By: Claude Sonnet 4.6 --- server/helpers.mjs | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/server/helpers.mjs b/server/helpers.mjs index d890088..2fcf345 100644 --- a/server/helpers.mjs +++ b/server/helpers.mjs @@ -1,30 +1,23 @@ import { spawnSync } from "child_process"; 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: -// ./workspace -> /workspace -// ./claude-home -> /home/claude -// Override host paths via env vars when running outside the default layout. -const VOLUME_MAP = { - "/workspace": process.env.CONDUIT_HOST_WORKSPACE || CONTAINER_PATH, - "/home/claude": process.env.CONDUIT_HOST_HOME || "/home/claude", -}; + +// Docker image → host conversation +const VOLUME_MAPPING = [ + ['/home/claude', path.resolve(CONTAINER_PATH, 'claude-home')], + ['/workspace', path.resolve(CONTAINER_PATH, 'workspace')], +]; // 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. export function resolve_path(user_path) { - const abs = path.isAbsolute(user_path) - ? user_path - : path.join(CONTAINER_PATH, user_path); + const abs = path.resolve(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 + "/")) { - const relative = abs.slice(container_prefix.length); - return host_prefix + relative; + return host_prefix + abs.slice(container_prefix.length); } }