Stage the mux payload before installing it in the task environment.
(self, environment: BaseEnvironment)
| 285 | ) |
| 286 | |
| 287 | async def setup(self, environment: BaseEnvironment) -> None: |
| 288 | """Stage the mux payload before installing it in the task environment.""" |
| 289 | env = self._env |
| 290 | |
| 291 | # Harbor no longer renders installed-agent templates for custom agents. |
| 292 | # Stage the rendered script ourselves so scheduled tbench runs are not |
| 293 | # coupled to Harbor internals that have changed over time. |
| 294 | await environment.exec(command="mkdir -p /installed-agent", user="root") |
| 295 | |
| 296 | if not self._archive_bytes: |
| 297 | self._archive_bytes = build_app_archive( |
| 298 | self._repo_root, self._INCLUDE_PATHS |
| 299 | ) |
| 300 | |
| 301 | archive_path = self.logs_dir / self._ARCHIVE_NAME |
| 302 | archive_path.write_bytes(self._archive_bytes) |
| 303 | await environment.upload_file( |
| 304 | source_path=archive_path, |
| 305 | target_path=f"/installed-agent/{self._ARCHIVE_NAME}", |
| 306 | ) |
| 307 | |
| 308 | await environment.upload_file( |
| 309 | source_path=self._runner_path, |
| 310 | target_path=f"/installed-agent/{self._RUNNER_NAME}", |
| 311 | ) |
| 312 | |
| 313 | await environment.upload_file( |
| 314 | source_path=self._write_setup_script(), |
| 315 | target_path=f"/installed-agent/{self._SETUP_SCRIPT_NAME}", |
| 316 | ) |
| 317 | |
| 318 | await self.install(environment) |
| 319 | |
| 320 | # Optionally seed the sandbox with providers.jsonc from the host machine. |
| 321 | # This is required for OAuth-only configs where env var API keys are absent. |
| 322 | await self._stage_providers_config(environment, env) |
| 323 | |
| 324 | # Store environment reference for token extraction later. |
| 325 | self._last_environment = environment |
| 326 | |
| 327 | def create_run_agent_commands(self, instruction: str) -> list[_AgentCommand]: |
| 328 | escaped = shlex.quote(instruction) |