Skip to content

Feat/export file#3

Merged
Coooolfan merged 14 commits intomainfrom
feat/export_file
Apr 1, 2026
Merged

Feat/export file#3
Coooolfan merged 14 commits intomainfrom
feat/export_file

Conversation

@Coooolfan
Copy link
Copy Markdown
Owner

No description provided.

…egration

Introduce exportFile MCP tool for exporting files from Docker-backed terminal sessions to S3-compatible storage. Requires all 6 env vars (CONSOLE_EXPORT_FILE_ENDPOINT, CONSOLE_EXPORT_FILE_REGION, CONSOLE_EXPORT_FILE_BUCKET_NAME, CONSOLE_EXPORT_FILE_EXPORT_PREFIX, CONSOLE_EXPORT_FILE_AK, CONSOLE_EXPORT_FILE_SK) to enable. Tool generates presigned upload URL, dispatches terminalResource action="export" to worker-docker, then
…figuration

Add exportFile to CONSOLE_HIDDEN_TOOLS list, document six required env vars (CONSOLE_EXPORT_FILE_ENDPOINT, CONSOLE_EXPORT_FILE_REGION, CONSOLE_EXPORT_FILE_BUCKET_NAME, CONSOLE_EXPORT_FILE_EXPORT_PREFIX, CONSOLE_EXPORT_FILE_AK, CONSOLE_EXPORT_FILE_SK) in console-config.mdx. Update mcp-tools.mdx to describe exportFile input/output schema, routing to terminalResource action="export", docker exec probe behavior, and pres
…nload URLs

Add CONSOLE_EXPORT_FILE_UPLOAD_PRESIGN_TTL_SEC and CONSOLE_EXPORT_FILE_DOWNLOAD_PRESIGN_TTL_SEC environment variables with defaults of 900s and 3600s respectively. Thread TTL values through config, handler, and MCP tool layers. Update docs to document new variables and their defaults.
…ge capability

Remove computerUse session rejection from exportFile tool. When session_id is "computerUse", route to readImage capability instead of terminalResource. Add copy_out_file method to TerminalBackend trait for exporting files from boxlite containers. Update tool description and docs to reflect computerUse support. Add test coverage for computerUse routing to readImage capability.
Copilot AI review requested due to automatic review settings March 31, 2026 15:14
@Coooolfan
Copy link
Copy Markdown
Owner Author

@codex review it

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an exportFile flow that lets clients export files from worker sessions to an S3-compatible object store using presigned URLs. This introduces a new export action in underlying worker capabilities (readImage for computerUse / worker-sys, and terminalResource for terminal sessions), plus console-side presigning/config and documentation updates.

Changes:

  • Add export action + signed_url plumbing to worker capabilities (readImage, terminalResource) and implement HTTP PUT uploads.
  • Introduce console-side objectstore presigning and a new MCP tool exportFile with env-based enablement.
  • Update docs/READMEs and add test coverage across Go/Rust workers and console MCP handlers.

Reviewed changes

Copilot reviewed 35 out of 37 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
worker/worker-sys/internal/runner/read_image.go Adds export action to upload a file to a provided presigned URL.
worker/worker-sys/internal/runner/read_image_test.go Tests readImage export behavior, allowlist enforcement, and error propagation.
worker/worker-sys/internal/runner/capability_executor.go Passes signed_url through to the readImage executor.
worker/worker-docker/README/overview.md Documents terminalResource export behavior and python3 probe requirement.
worker/worker-docker/internal/runner/terminal_resource.go Adds export action: probe, docker cp out, then HTTP PUT upload; improves exec error reporting.
worker/worker-docker/internal/runner/terminal_resource_test.go Adds tests for export success/failure and improved docker exec failure messages; updates python3 expectation.
worker/worker-docker/internal/runner/session_client.go Extends log summary to include export and signed_url_present.
worker/worker-docker/internal/runner/session_client_test.go Updates expected log summaries and adds export coverage.
worker/worker-docker/internal/runner/capability_executor.go Validates/passes through signed_url for terminalResource export.
worker/worker-boxlite/src/runner/terminal_session_manager.rs Adds export support for boxlite terminal sessions: copy-out + HTTP PUT upload, plus new error code and tests.
worker/worker-boxlite/src/runner/session_client.rs Formatting-only test code changes.
worker/worker-boxlite/src/runner/capability_executor.rs Adds signed_url field to payload parsing/dispatch and export validation.
worker/worker-boxlite/src/boxlite_runtime.rs Adds runtime support to copy a file out of the terminal box.
worker/worker-boxlite/Cargo.toml Adds reqwest dependency for HTTP PUT uploads.
worker/worker-boxlite/Cargo.lock Updates lockfile for reqwest.
website/src/docs/zh-CN/worker-docker.mdx Documents terminalResource export behavior and python3 probe requirement.
website/src/docs/zh-CN/mcp-tools.mdx Adds exportFile tool docs (inputs/outputs/routing).
website/src/docs/zh-CN/console-config.mdx Documents console env vars for enabling/configuring exportFile.
website/src/docs/en/worker-docker.mdx Documents terminalResource export behavior and python3 probe requirement.
website/src/docs/en/mcp-tools.mdx Adds exportFile tool docs (inputs/outputs/routing).
website/src/docs/en/console-config.mdx Documents console env vars for enabling/configuring exportFile.
console/README/overview.md Documents new exportFile tool and related env/config behavior.
console/internal/objectstore/objectstore.go Adds S3-compatible presigning helper (upload/download).
console/internal/objectstore/objectstore_test.go Tests objectstore config validation + presign URL shape.
console/internal/httpapi/worker_handler.go Wires objectstore + TTL config into MCP handler creation.
console/internal/httpapi/mcp_tool_specs.go Defines MCP schemas/types for exportFile.
console/internal/httpapi/mcp_resource_registry.go Extends resource payload schema with signed_url.
console/internal/httpapi/mcp_handler.go Conditionally registers exportFile tool when objectstore config is present.
console/internal/httpapi/mcp_handler_test.go Adds MCP tests for tools/list and tools/call for exportFile, including TTL customization and computerUse routing.
console/internal/httpapi/mcp_export_file.go Implements exportFile tool: presign upload, dispatch export to worker, presign download.
console/internal/httpapi/mcp_export_file_test.go Tests object key generation/sanitization for exports.
console/internal/grpcserver/task_owner_scope.go Adds signed_url to scoped terminalResource payload.
console/internal/config/config.go Adds env/config fields and enablement logic for exportFile + TTLs.
console/internal/config/config_test.go Adds config tests for exportFile enablement and TTL parsing/defaults.
console/go.mod Adds AWS SDK v2 deps required for presigning.
console/go.sum Adds checksums for new AWS SDK v2 deps.
console/cmd/console/main.go Initializes objectstore and wires it into HTTP handler when export is enabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread console/README/overview.md Outdated
Comment thread website/src/docs/en/mcp-tools.mdx Outdated
Comment thread website/src/docs/zh-CN/mcp-tools.mdx Outdated
Comment thread worker/worker-boxlite/src/runner/terminal_session_manager.rs
Comment thread worker/worker-boxlite/src/runner/terminal_session_manager.rs
Coooolfan and others added 10 commits March 31, 2026 23:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add object_key and filename fields to mcpExportFileToolOutput struct and schema. Update tool description to document new return fields. Update tests to verify object_key and filename presence in responses. Remove UsePathStyle from S3 client config and adjust test assertions to expect virtual-hosted-style URLs.
… tools

Set readOnlyHint=true and idempotentHint=true for readImage tool. Set readOnlyHint=true and idempotentHint=false for exportFile tool. Set readOnlyHint=false and idempotentHint=false for pythonExec, terminalExec, and computerUse tools. Update readImage and exportFile OpenWorldHint from true to false. Add test assertions for readImage annotations. Clarify exportFile description to document session_id and timeout_ms parameters
…c session_id behavior in tool descriptions

Expand pythonExec description to emphasize each invocation runs in a fresh, isolated environment destroyed immediately upon completion with no persistence across calls. Direct users to terminalExec for retaining files or sharing state. Update terminalExec description to clarify omitting session_id creates new session per call with no state carryover, and document create_if_missing default
… output fields

Introduces a new config option with three modes:
- ALL (default): returns signed_url, object_key, and filename
- SIGNED_URL: returns only signed_url
- OBJECTKEY: returns only object_key and filename, skips presigned download URL generation

Output schema advertised via MCP tools/list is also mode-specific.
Add configurable file size limit for exportFile MCP tool on worker-docker
and worker-boxlite. New environment variable WORKER_TERMINAL_EXPORT_MAX_BYTES
controls maximum file size allowed for export operations; 0 disables the limit
(default).

Changes:
- worker-docker: Add TerminalExportMaxBytes config field, pass through
  terminalSessionManager, check size in resolveResourceInSession before
  calling exportTerminalResource. Return file_too_large error code if
  file exceeds limit.
- worker-boxlite: Add terminal_export_max_bytes config field, pass through
  TerminalSessionManager, check size in resolve_resource before export
  action. Return file_too_large error code if file exceeds limit.
- Add comprehensive tests in both workers validating oversized files are
  rejected before docker cp/copy_out operations commence.
- Update worker-docker documentation (README, website en/zh-CN) to document
  new environment variable and export action behavior.
- worker-sys unaffected (host filesystem, operator responsibility).

Tests pass: worker-docker Go tests and worker-boxlite Rust tests.
…xportFile tool

Add documentation for WORKER_TERMINAL_EXPORT_MAX_BYTES environment variable in worker-boxlite configuration tables (en/zh-CN). Add exportFile tool to overview feature lists (en/zh-CN) describing export of session files to configured object store.
@Coooolfan Coooolfan merged commit 41efde9 into main Apr 1, 2026
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