fix: reduce e2b uname calls

This commit is contained in:
Yeuoly 2026-01-21 16:07:12 +08:00
parent 1c90c729bc
commit 699650565e
2 changed files with 19 additions and 4 deletions

View File

@ -0,0 +1,16 @@
# E2B Sandbox Provider Notes
## Purpose
- Implements the E2B-backed `VirtualEnvironment` provider and bootstraps sandbox metadata, file I/O, and command execution.
## Key Decisions
- Sandbox metadata is gathered during `_construct_environment` using the E2B SDK before returning `Metadata`.
- Architecture/OS detection uses a single `uname -m -s` call split into two lines to reduce round-trips.
- Command execution streams stdout/stderr through `QueueTransportReadCloser`; stdin is unsupported.
## Edge Cases
- `release_environment` raises when sandbox termination fails.
- `execute_command` runs in a background thread; consumers must read stdout/stderr until EOF.
## Tests/Verification
- None yet. Add targeted service tests when behavior changes.

View File

@ -132,13 +132,12 @@ class E2BEnvironment(VirtualEnvironment):
envs=dict(environments),
)
info = sandbox.get_info(api_key=options.get(self.OptionsKey.API_KEY, ""))
arch_output = sandbox.commands.run("uname -m").stdout.strip()
os_output = sandbox.commands.run("uname -s").stdout.strip()
system_info = sandbox.commands.run("uname -m -s").stdout.splitlines()
return Metadata(
id=info.sandbox_id,
arch=self._convert_architecture(arch_output),
os=self._convert_operating_system(os_output),
arch=self._convert_architecture(system_info[0].strip()),
os=self._convert_operating_system(system_info[1].strip()),
store={
self.StoreKey.SANDBOX: sandbox,
},