"""Shell/script executor: runs `{script}` with the prompt on stdin. The last message is `last.md` in the run directory if the script wrote it (its path is passed as {out}), else the tail of stdout. No threads.""" from .base import ExecResult, RunnerExecutor class ShellExecutor(RunnerExecutor): stdout_name = "stdout.txt" @property def resume(self): return False def collect(self, handle): t, d = self.transport, handle["run_dir"] last = t.read_text(t.join(d, "last.md")) if last is None: last = (t.read_text(t.join(d, "stdout.txt")) or "")[-6000:] return ExecResult(last.strip(), self.exit_code(handle), None, self.logs(handle, "stdout.txt", "stderr.txt"), self.stderr_tail(handle))