ya-agent-environment
Environment abstractions for general agents.
ya-agent-environment provides the shared base interfaces used by YA agents:
EnvironmentFileOperatorShellResourceRegistry- resumable resources
- environment-owned temporary storage via
tmp_dirandresolve_tmp_path()
The Python import package is ya_agent_environment.
Environment and File Backend Contracts
Environment owns temporary-directory configuration and lifecycle. While entered,
env.tmp_dir exposes the agent-facing root (or None) and
env.resolve_tmp_path(relative_path) safely resolves a contained path, rejecting
absolute paths and parent traversal. Temporary paths are handled through the normal
FileOperator methods; there is no separate temporary-file operator or routing API.
Environment cleanup closes registered resources, the shell, and the file operator
before _teardown() releases backend/container and temporary-directory resources.
The same ordering is used after partial setup failures. The base class does not assume
a filesystem backing store and never deletes _tmp_dir itself: custom environments
must allocate their agent-facing temporary backend in _setup() and remove only owned
storage in _teardown().
A FileOperator implementation exposes one logical path space by implementing its
public abstract methods directly. read_bytes_stream() returns an AsyncIterator
directly, so consume the returned iterator without awaiting the method call.
Shell Backend Contract
Custom Shell backends implement _create_process() and return an ExecutionHandle with stream, wait, and kill callbacks. Shell.execute() is the final public foreground boundary and must not be overridden: the base class owns process creation, timeout, cancellation, foreground/background registration, and session-reset cleanup. The foreground timeout budget begins before process creation, but shell-owned creation still resolves and terminates any eventual handle before reporting timeout. Class creation raises TypeError when final MRO resolution replaces execute(), so direct and mixin-based legacy overrides fail fast instead of silently bypassing lifecycle ownership; migrate their process creation into _create_process(). A wait callback must not report natural completion while owned descendants remain, and a kill callback must not return until backend execution is confirmed terminated; raising preserves the handle for a later reset retry. Backends must retain a stable execution identity through termination: a POSIX numeric PGID is no longer an ownership handle after its leader is reaped, so residual-group cleanup requires a live guardian or an equivalent platform-owned primitive.
Development
This package is maintained as a workspace member in ya-mono.
uv run python -m pytest packages/ya-agent-environment/tests -vv
uv run python -m pyright
uv build --package ya-agent-environment -o dist
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ya_agent_environment-1.16.0.tar.gz.
File metadata
- Download URL: ya_agent_environment-1.16.0.tar.gz
- Upload date:
- Size: 55.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03c712036eb5e9d524e1c971dcaa0424e5ed0512a43e5184460362c49c0cb0fa
|
|
| MD5 |
3c3da22dead8946cb9715d71ca1de809
|
|
| BLAKE2b-256 |
933a18bc7f6312f61d8722ab13e6e102b2456fc1e4608543d992f3a4a7f83599
|
File details
Details for the file ya_agent_environment-1.16.0-py3-none-any.whl.
File metadata
- Download URL: ya_agent_environment-1.16.0-py3-none-any.whl
- Upload date:
- Size: 35.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc8168fb13db20eb7f28233e7947e78028b56420f3df8c001b95840aff1f7657
|
|
| MD5 |
9914896bf4c422975b91457a5f848444
|
|
| BLAKE2b-256 |
3a0b0e61c24e9ffd8e321bab752b05757517f454aad9837e4dc2e7d86d3b4790
|