dify/api/core/sandbox
Harry a0c388f283 refactor(sandbox): extract connection helpers and move run_command to helper module
- Add helpers.py with connection management utilities:
    - with_connection: context manager for connection lifecycle
    - submit_command: execute command and return CommandFuture
    - execute: run command with auto connection, raise on failure
    - try_execute: run command with auto connection, return result

  - Add CommandExecutionError to exec.py for typed error handling
    with access to exit_code, stderr, and full result

  - Remove run_command method from VirtualEnvironment base class
    (now available as submit_command helper)

  - Update all call sites to use new helper functions:
    - sandbox/session.py
    - sandbox/storage/archive_storage.py
    - sandbox/bash/bash_tool.py
    - workflow/nodes/command/node.py

  - Add comprehensive unit tests for helpers with connection reuse
2026-01-15 00:13:52 +08:00
..
bash refactor(sandbox): extract connection helpers and move run_command to helper module 2026-01-15 00:13:52 +08:00
initializer refactor(sandbox): extract connection helpers and move run_command to helper module 2026-01-15 00:13:52 +08:00
storage refactor(sandbox): extract connection helpers and move run_command to helper module 2026-01-15 00:13:52 +08:00
utils refactor(sandbox): extract connection helpers and move run_command to helper module 2026-01-15 00:13:52 +08:00
__init__.py refactor(sandbox): extract connection helpers and move run_command to helper module 2026-01-15 00:13:52 +08:00
constants.py refactor(sandbox): remove unused SANDBOX_WORK_DIR constant and update bash command descriptions for clarity 2026-01-12 15:02:30 +08:00
factory.py refactor: using initializer to replace hardcoded dify cli initialization 2026-01-12 12:13:56 +08:00
manager.py refactor(sandbox): reorganize sandbox-related imports and rename SandboxFactory to VMFactory for clarity 2026-01-12 02:07:31 +08:00
session.py refactor(sandbox): extract connection helpers and move run_command to helper module 2026-01-15 00:13:52 +08:00