fix(modal): pipe stdin to avoid ARG_MAX, clean up review findings

- Modal bulk upload: stream base64 payload through proc.stdin in 1MB
  chunks instead of embedding in command string (Modal SDK enforces
  64KB ARG_MAX_BYTES — typical payloads are ~4.3MB)
- Modal single-file upload: same stdin fix, add exit code checking
- Remove what-narrating comments in ssh.py and modal.py (keep WHY
  comments: symlink staging rationale, SIGPIPE, deadlock avoidance)
- Remove unnecessary `sandbox = self._sandbox` alias in modal bulk
- Daytona: use shared helpers (unique_parent_dirs, quoted_mkdir_command)
  instead of inlined duplicates
This commit is contained in:
alt-glitch 2026-04-11 17:21:34 -07:00
parent 04d4f41e77
commit 9000d3163a
4 changed files with 137 additions and 50 deletions

View file

@ -152,7 +152,6 @@ class SSHEnvironment(BaseEnvironment):
if not files:
return
# Pre-create all unique parent directories in one SSH call
parents = unique_parent_dirs(files)
if parents:
cmd = self._build_ssh_command()
@ -164,18 +163,11 @@ class SSHEnvironment(BaseEnvironment):
# Symlink staging avoids fragile GNU tar --transform rules.
with tempfile.TemporaryDirectory(prefix="hermes-ssh-bulk-") as staging:
for host_path, remote_path in files:
# remote_path is absolute (e.g. /home/user/.hermes/skills/foo.md)
# Create the directory structure under staging
staged = os.path.join(staging, remote_path.lstrip("/"))
os.makedirs(os.path.dirname(staged), exist_ok=True)
# Symlink to the actual file (avoid copying)
os.symlink(os.path.abspath(host_path), staged)
# tar: dereference symlinks (-h), create archive from staging root
# The archive paths are relative to staging, which mirrors / on remote
tar_cmd = ["tar", "-chf", "-", "-C", staging, "."]
# ssh: extract on remote at /
ssh_cmd = self._build_ssh_command()
ssh_cmd.append("tar xf - -C /")