feat(autonomy): add followup.create primitive and tool-continuation directives to enforce silence-kills-work

This commit is contained in:
operator
2026-10-05 05:24:45 +00:00
parent 03374795d8
commit c90e096192
5 changed files with 172 additions and 16 deletions
+40
View File
@@ -130,6 +130,44 @@ def op_service_restart(unit):
"error": r.stderr.strip() if r.returncode != 0 else None
}
def op_followup_schedule(args):
agent = args.get("agent")
if agent not in ("muse", "pip", "646", "opm", "dev", "def"):
return {"ok": False, "error": f"Invalid agent: {agent}"}
sender = args.get("sender") or agent
if sender not in ("muse", "pip", "646", "opm", "dev", "def"):
sender = agent
try:
in_m = float(args.get("in_m", 1))
except (TypeError, ValueError):
return {"ok": False, "error": "in_m must be a number"}
sec = max(5, int(in_m * 60))
prompt = args.get("prompt", "")
if not prompt or not isinstance(prompt, str):
return {"ok": False, "error": "prompt must be a non-empty string"}
if len(prompt) > 1000:
return {"ok": False, "error": "prompt exceeds 1000 characters"}
sidechat = args.get("thread") or args.get("sidechat")
cmd = [
"systemd-run", "--user", f"--on-active={sec}s",
sys.executable, str(REPO_ROOT / "bin" / "box-ctl.py"),
"notify", agent, prompt, "--sender", sender
]
if sidechat and isinstance(sidechat, str) and len(sidechat) <= 64:
cmd.extend(["--sidechat", sidechat])
r = subprocess.run(cmd, capture_output=True, text=True, timeout=15)
if r.returncode != 0:
return {"ok": False, "error": r.stderr.strip() or r.stdout.strip()}
return {
"ok": True,
"agent": agent,
"in_seconds": sec,
"sidechat": sidechat,
"timer_info": (r.stderr or r.stdout).strip()
}
def main():
if len(sys.argv) < 2:
print(json.dumps({"ok": False, "error": "missing operation"}))
@@ -153,6 +191,8 @@ def main():
res = op_service_status(args.get("unit", args.get("name", "")))
elif op == "service.restart":
res = op_service_restart(args.get("unit", args.get("name", "")))
elif op in ("followup.create", "followup.schedule"):
res = op_followup_schedule(args)
else:
res = {"ok": False, "error": f"unknown operation: {op}"}
except Exception as e: