| 443 | f"If a task has a worktree, work in that directory.") |
| 444 | |
| 445 | def handle_inbox_message(name: str, msg: dict, messages: list): |
| 446 | msg_type = msg.get("type", "message") |
| 447 | meta = msg.get("metadata", {}) |
| 448 | req_id = meta.get("request_id", "") |
| 449 | if msg_type == "shutdown_request": |
| 450 | BUS.send(name, "lead", "Shutting down.", |
| 451 | "shutdown_response", |
| 452 | {"request_id": req_id, "approve": True}) |
| 453 | return True |
| 454 | if msg_type == "plan_approval_response": |
| 455 | approve = meta.get("approve", False) |
| 456 | messages.append({"role": "user", |
| 457 | "content": "[Plan approved]" if approve |
| 458 | else f"[Plan rejected] {msg['content']}"}) |
| 459 | return False |
| 460 | |
| 461 | def run(): |
| 462 | wt_ctx = {"path": None} |