diff --git a/agent-node/VERSION b/agent-node/VERSION index 21e8796..ee90284 100644 --- a/agent-node/VERSION +++ b/agent-node/VERSION @@ -1 +1 @@ -1.0.3 +1.0.4 diff --git a/agent-node/bootstrap_installer.py b/agent-node/bootstrap_installer.py index f680e0f..2d6f922 100644 --- a/agent-node/bootstrap_installer.py +++ b/agent-node/bootstrap_installer.py @@ -80,13 +80,12 @@ os.makedirs(install_dir, exist_ok=True) with tarfile.open(tarball, "r:gz") as tar: - # Strip the top-level 'agent-node/' prefix from paths - for member in tar.getmembers(): - parts = member.name.split("/", 1) - if len(parts) > 1: - member.name = parts[1] - else: - member.name = parts[0] + # Safely strip the top-level 'agent-node/' prefix only if it exists + members = tar.getmembers() + for member in members: + if member.name.startswith("agent-node/"): + member.name = member.name.replace("agent-node/", "", 1) + if member.name: tar.extract(member, install_dir) diff --git a/ai-hub/app/api/routes/agent_update.py b/ai-hub/app/api/routes/agent_update.py index 64b2165..3da1d79 100644 --- a/ai-hub/app/api/routes/agent_update.py +++ b/ai-hub/app/api/routes/agent_update.py @@ -73,24 +73,27 @@ """ buf = io.BytesIO() with tarfile.open(fileobj=buf, mode="w:gz") as tar: - # 1. Add agent-node files (Flat Root) + # Wrap everything in a top-level 'agent-node/' directory + # so bootstrap_installer can strip it consistently. + ROOT_PREFIX = "agent-node" + + # 1. Add agent-node files if os.path.exists(_AGENT_NODE_DIR): for root, dirs, files in os.walk(_AGENT_NODE_DIR): dirs[:] = [d for d in dirs if not _should_exclude(os.path.join(root, d))] for filename in files: abs_path = os.path.join(root, filename) - rel_path = os.path.relpath(abs_path, _AGENT_NODE_DIR) + rel_path = os.path.join(ROOT_PREFIX, os.path.relpath(abs_path, _AGENT_NODE_DIR)) if not _should_exclude(rel_path): tar.add(abs_path, arcname=rel_path) - # 2. Add skills directory (as 'skills/') + # 2. Add skills directory if os.path.exists(_SKILLS_DIR): for root, dirs, files in os.walk(_SKILLS_DIR): dirs[:] = [d for d in dirs if not _should_exclude(os.path.join(root, d))] for filename in files: abs_path = os.path.join(root, filename) - # Skills should be in a 'skills/' folder in the tarball - rel_path = os.path.join("skills", os.path.relpath(abs_path, _SKILLS_DIR)) + rel_path = os.path.join(ROOT_PREFIX, "skills", os.path.relpath(abs_path, _SKILLS_DIR)) if not _should_exclude(rel_path): tar.add(abs_path, arcname=rel_path)