PAD-12: per-terminal transport (direct Tailscale SSH or Warpgate, pre-session fallback, pinned host keys, agent key from Vault), one-call win10 launch and one-call collect, remote call timings, agentd ping
This commit is contained in:
@@ -6,6 +6,8 @@ import re
|
||||
from dataclasses import dataclass, field
|
||||
from typing import List, Optional
|
||||
|
||||
from ..transports import fetch_each
|
||||
|
||||
|
||||
@dataclass
|
||||
class Run:
|
||||
@@ -55,6 +57,11 @@ class Executor:
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
def parse_exit(text):
|
||||
m = re.search(r"exit=(-?\d+)", text or "")
|
||||
return int(m.group(1)) if m else None
|
||||
|
||||
|
||||
def fill(template, params):
|
||||
"""Replace {name} placeholders that exist in params; leave anything else untouched."""
|
||||
return re.sub(r"\{(\w+)\}", lambda m: str(params[m.group(1)]) if m.group(1) in params else m.group(0), template)
|
||||
@@ -101,7 +108,7 @@ class RunnerExecutor(Executor):
|
||||
run_dir, task = h["run_dir"], h["task"]
|
||||
script_name, script = t.runner(run_dir, run.repo, self.command(run, run_dir), self.stdout_name)
|
||||
files = {"prompt.md": run.prompt, script_name: script}
|
||||
if hasattr(t, "start_run"): # remote POSIX: stage + launch in one relay round trip
|
||||
if hasattr(t, "start_run"): # remote: stage + launch in one call (direct-ssh; POSIX also on the relay)
|
||||
t.start_run(task, run_dir, files, script_name)
|
||||
else:
|
||||
t.mkdir(run_dir, clean=True)
|
||||
@@ -121,9 +128,14 @@ class RunnerExecutor(Executor):
|
||||
return "finished" if text and "exit=" in text else "running"
|
||||
|
||||
def exit_code(self, handle):
|
||||
text = self.transport.read_text(self.transport.join(handle["run_dir"], "exit.txt")) or ""
|
||||
m = re.search(r"exit=(-?\d+)", text)
|
||||
return int(m.group(1)) if m else None
|
||||
return parse_exit(self.transport.read_text(self.transport.join(handle["run_dir"], "exit.txt")))
|
||||
|
||||
def fetch(self, handle, ops):
|
||||
"""Reads of the run directory for `collect`: one call on remote transports (see transports.fetch)."""
|
||||
t = self.transport
|
||||
if hasattr(t, "fetch"):
|
||||
return t.fetch(handle["run_dir"], ops)
|
||||
return fetch_each(t, handle["run_dir"], ops)
|
||||
|
||||
def kill(self, handle):
|
||||
self.transport.kill(handle["task"], handle["run_dir"])
|
||||
|
||||
Reference in New Issue
Block a user