Add Codex remote-control backend
This commit is contained in:
@@ -355,9 +355,29 @@ def start_agent(cfg, agent, *, force=False):
|
||||
parts.append(backend["flags"])
|
||||
parts.append(f"\"$(cat '{kf}')\"")
|
||||
cmd = " ".join(p for p in parts if p)
|
||||
# Some interactive CLIs need an idempotent service prepared before their TUI starts.
|
||||
# Codex Remote Control is one such service: `remote-control start` ensures the shared
|
||||
# app-server daemon is enrolled and connected, then the pane runs the ordinary Codex TUI.
|
||||
if backend.get("preamble"):
|
||||
preamble = _render_template(backend["preamble"], {
|
||||
"bin": backend["bin"], "session": session, "model": model,
|
||||
"dir": shlex.quote(cwd),
|
||||
})
|
||||
cmd = f"{preamble} && {cmd}"
|
||||
log(f"starting {session} ({agent['backend']}, kind={agent['kind']}, phase={pid}, "
|
||||
f"model={model or 'default'}{', resume' if rid else ''})")
|
||||
new_session(session, cwd, cmd, log_path)
|
||||
# An unattended TUI may present a deterministic first-run gate before it processes the
|
||||
# prompt already supplied on argv (Codex asks whether to trust a new project directory).
|
||||
# Backends opt in with both the screen regex and response; nothing is accepted implicitly.
|
||||
startup_re = backend.get("startup_prompt_re")
|
||||
if startup_re:
|
||||
time.sleep(int(backend.get("startup_prompt_delay", 2)))
|
||||
if re.search(startup_re, capture_pane(session, 40), re.I):
|
||||
_run(["tmux", "send-keys", "-t", TP(session), "-l", "--",
|
||||
str(backend.get("startup_prompt_response", ""))])
|
||||
_run(["tmux", "send-keys", "-t", TP(session),
|
||||
backend.get("submit_key", "Enter")])
|
||||
|
||||
def start_service(cfg, svc):
|
||||
session = svc["session"]
|
||||
|
||||
Reference in New Issue
Block a user