"""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, parse_exit class ShellExecutor(RunnerExecutor): stdout_name = "stdout.txt" @property def resume(self): return False COLLECT = [("read", "exit.txt"), ("read", "last.md"), ("read", "stdout.txt"), ("tail", "stderr.txt", 5)] def collect(self, handle): exit_text, last, stdout, tail = self.fetch(handle, self.COLLECT) # one remote call if last is None: last = (stdout or "")[-6000:] return ExecResult(last.strip(), parse_exit(exit_text), None, self.logs(handle, "stdout.txt", "stderr.txt"), tail)