| Metadata-Version: 2.4 |
| Name: trenches-openenv |
| Version: 0.1.0 |
| Summary: Python scaffolding for the Trenches OpenEnv crisis simulator |
| Requires-Python: >=3.12 |
| Description-Content-Type: text/markdown |
| Requires-Dist: fastapi<1.0.0,>=0.115.0 |
| Requires-Dist: httpx<1.0.0,>=0.27.0 |
| Requires-Dist: numpy<3.0.0,>=1.26.0 |
| Requires-Dist: openenv-core[core]<0.3.0,>=0.2.1 |
| Requires-Dist: pydantic<3.0.0,>=2.8.0 |
| Requires-Dist: uvicorn[standard]<1.0.0,>=0.30.0 |
| Provides-Extra: dev |
| Requires-Dist: pytest<9.0.0,>=8.3.0; extra == "dev" |
| Provides-Extra: train |
| Requires-Dist: accelerate<2.0.0,>=1.0.0; extra == "train" |
| Requires-Dist: bitsandbytes>=0.43.0; extra == "train" |
| Requires-Dist: datasets<4.0.0,>=3.0.0; extra == "train" |
| Requires-Dist: transformers<5.0.0,>=4.55.0; extra == "train" |
| Requires-Dist: trl<0.26.0,>=0.25.0; extra == "train" |
|
|
| |
|
|
| This directory contains the Python backend for the Trenches simulator. |
|
|
| It now exposes two layers: |
|
|
| - the existing session-oriented FastAPI API used by the React dashboard |
| - a native OpenEnv-compatible environment mounted under `/openenv` when `openenv-core` is installed |
|
|
| The backend does not serve frontend assets and is intended to stay frontend-stack agnostic. Any web client |
| (Next.js, Vite, Bun, mobile, or a thin dashboard proxy) should be able to consume the same HTTP contract. |
|
|
| CORS is configurable so frontend migrations do not require backend code changes: |
|
|
| - `TRENCHES_CORS_ALLOW_ORIGINS=https://app.example.com,https://ops.example.com` |
| - `TRENCHES_CORS_ALLOW_ORIGIN_REGEX=https://.*\\.example\\.com` |
| - `TRENCHES_CORS_ALLOW_CREDENTIALS=true|false` |
|
|
| If no CORS env vars are set, the backend allows local development origins on `localhost` / `127.0.0.1` for any port. |
|
|
| Entity-model provider bindings are also configurable per agent. The backend does not fake provider readiness: |
| if a provider/model is not configured, the runtime reports `heuristic_fallback` explicitly in session state and |
| `/capabilities`. |
|
|
| Supported env patterns: |
|
|
| - `TRENCHES_MODEL_PROVIDER=openai|anthropic|openrouter|ollama|vllm|custom` |
| - `TRENCHES_MODEL_NAME=<provider model id>` |
| - `TRENCHES_MODEL_BASE_URL=<custom base url>` |
| - `TRENCHES_MODEL_API_KEY_ENV=<name of env var holding the secret>` |
| - `TRENCHES_MODEL_SUPPORTS_TOOL_CALLS=true|false` |
| - `TRENCHES_MODEL_SUPPORTS_STRUCTURED_OUTPUT=true|false` |
|
|
| Per-entity overrides use the uppercase agent suffix, for example: |
|
|
| - `TRENCHES_MODEL_PROVIDER_US=openai` |
| - `TRENCHES_MODEL_NAME_US=gpt-4.1` |
| - `TRENCHES_MODEL_API_KEY_ENV_US=OPENAI_API_KEY` |
|
|
| Relevant OpenEnv pieces in this package: |
|
|
| - `trenches_env.openenv_adapter.TrenchesOpenEnvEnvironment` |
| - `trenches_env.openenv_adapter.TrenchesOpenEnvAction` |
| - `trenches_env.openenv_adapter.TrenchesOpenEnvObservation` |
| - `trenches_env.openenv_adapter.TrenchesOpenEnvState` |
| - `trenches_env.openenv_client.TrenchesEnvClient` |
|
|
| Historical replay training pieces: |
|
|
| - `trenches_env.models.Prediction` |
| - `trenches_env.models.HistoricalEvent` |
| - `trenches_env.models.HistoricalReplayState` |
| - `trenches_env.training_cli` |
|
|
| The backend now supports replay-aware forecast training: |
|
|
| - `reset(..., replay_id=...)` starts from a visible historical context event |
| - `step(...)` accepts separate `action` and `prediction` |
| - the next ground-truth event is revealed on the same OpenEnv step |
| - reward blends the entity action reward with forecast scoring terms |
|
|
| Bundled bootstrap replay (⚠️ **all replays are synthetic seed data** — replace with curated truth sets for production): |
|
|
| - `us_synthetic_seed_2025_2026` |
|
|
| CLI training entrypoint: |
|
|
| ```bash |
| trenches-train \ |
| |
| |
| |
| ``` |
|
|
| The CLI supports two rollout backends: |
|
|
| - `transformers` for portable local smoke runs |
| - `vllm` for the documented colocated OpenEnv + TRL path on a GPU box |
|
|
| Planned responsibilities: |
|
|
| - Hold in-memory crisis sessions. |
| - Expose `create`, `reset`, `step`, and `state` HTTP endpoints. |
| - Model the fog-of-war world state and per-agent observations. |
| - Provide a native OpenEnv boundary with scalar rewards for one active training agent while retaining full per-agent state internally. |
| - Provide extension points for World Monitor ingestion and RL training hooks. |
|
|