Skip to content

Add sandbox file transfer API#13

Merged
Yunnglin merged 2 commits into
mainfrom
add-sandbox-file-transfer-api
Jul 7, 2026
Merged

Add sandbox file transfer API#13
Yunnglin merged 2 commits into
mainfrom
add-sandbox-file-transfer-api

Conversation

@Yunnglin

@Yunnglin Yunnglin commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add sandbox-level put_archive, put_dir, and put_file APIs
  • expose manager-level local and HTTP directory transfer through the same archive path
  • reuse sandbox put_file in existing tool implementations instead of duplicating tar upload logic
  • add real local and HTTP Docker file-transfer tests

Validation

  • PATH=/Users/yunlin/miniconda3/envs/eval/bin:$PATH pre-commit run --all-files
  • DOCKER_HOST=unix:///Users/yunlin/.colima/default/docker.sock /Users/yunlin/miniconda3/envs/eval/bin/python -m pytest tests/test_manager.py::TestSandboxFileTransfer -q -s
  • DOCKER_HOST=unix:///Users/yunlin/.colima/default/docker.sock /Users/yunlin/miniconda3/envs/eval/bin/python -m pytest tests/test_manager.py::TestLocalSandboxManager tests/test_manager.py::TestSandboxFileTransfer -q -s

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces native file and directory transfer capabilities (put_archive, put_dir, and put_file) across the sandbox interface, Docker sandbox, and sandbox managers, replacing custom in-memory tar implementations in various execution tools. The review feedback suggests several key improvements: allowing active statuses like IDLE and BUSY in sandbox state checks, offloading synchronous archiving operations to a separate thread to avoid blocking the asyncio event loop, validating absolute file paths, securing the mkdir command against option injection, setting explicit modification times on tar files, and refining HTTP error mapping to distinguish validation errors from resource-not-found errors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread ms_enclave/sandbox/manager/local_manager.py
Comment thread ms_enclave/sandbox/boxes/base.py Outdated
Comment thread ms_enclave/sandbox/manager/http_manager.py Outdated
Comment thread ms_enclave/sandbox/boxes/base.py
Comment thread ms_enclave/sandbox/boxes/docker_sandbox.py Outdated
Comment thread ms_enclave/sandbox/utils/archive.py
Comment thread ms_enclave/sandbox/server/server.py
@Yunnglin Yunnglin marked this pull request as ready for review July 7, 2026 03:49
Copilot AI review requested due to automatic review settings July 7, 2026 03:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds first-class sandbox file-transfer APIs (put_archive, put_dir, put_file) to the sandbox abstraction and exposes archive upload through both local and HTTP managers, then refactors existing tools to reuse the new put_file path and adds real Docker-backed file-transfer tests.

Changes:

  • Add tar archive helpers and sandbox-level file transfer APIs (put_archive / put_dir / put_file).
  • Expose archive upload via FastAPI (POST /sandbox/{id}/archive) and add corresponding HTTP/local manager methods.
  • Refactor tool implementations to use sandbox_context.put_file(...) and add local + HTTP Docker integration tests for put_dir.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_manager.py Adds real local/HTTP Docker integration tests for manager-level directory transfer.
ms_enclave/sandbox/utils/archive.py Introduces in-memory tar helpers used by put_dir / put_file.
ms_enclave/sandbox/utils/init.py Adds utils package initializer.
ms_enclave/sandbox/tools/sandbox_tools/python_executor.py Switches to sandbox put_file instead of bespoke tar upload.
ms_enclave/sandbox/tools/sandbox_tools/multi_code_executor.py Switches to sandbox put_file instead of bespoke tar upload.
ms_enclave/sandbox/tools/sandbox_tools/file_operation.py Switches to sandbox put_file for temp writes instead of bespoke tar upload.
ms_enclave/sandbox/server/server.py Adds HTTP endpoint to upload/extract tar archives into a sandbox.
ms_enclave/sandbox/manager/local_manager.py Adds local manager put_archive / put_dir forwarding to sandbox implementations.
ms_enclave/sandbox/manager/http_manager.py Adds HTTP manager put_archive / put_dir implemented via the new server route.
ms_enclave/sandbox/manager/base.py Adds default (unsupported) manager API surface for put_archive / put_dir.
ms_enclave/sandbox/boxes/docker_sandbox.py Implements Docker-backed put_archive with mkdir -p + container.put_archive.
ms_enclave/sandbox/boxes/base.py Adds sandbox-level put_archive / put_dir / put_file APIs and shared tar-based implementations.

Comment thread ms_enclave/sandbox/utils/archive.py
Comment thread tests/test_manager.py
@Yunnglin Yunnglin merged commit e36d8d1 into main Jul 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants