This repository has been archived on 2026-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
orchestrator/run.py

54 lines
1.5 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
"""CLI entry point for the orchestration graph.
Usage:
python3 run.py "Write a function that validates emails"
python3 run.py --route-only "Send a Slack message to #general"
"""
import sys
import os
import json
os.chdir(os.path.dirname(os.path.abspath(__file__)))
from dotenv import load_dotenv
load_dotenv(".env")
from graph import app
def main():
if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help"):
print("Usage: python3 run.py [--route-only] <task description>")
sys.exit(1)
route_only = "--route-only" in sys.argv
args = [a for a in sys.argv[1:] if a != "--route-only"]
task = " ".join(args)
if route_only:
from langchain_core.messages import SystemMessage, HumanMessage
from models import get_orchestrator
llm = get_orchestrator()
response = llm.invoke([
SystemMessage(content="You are a task router. Respond with ONLY the agent name.\n"
"Available: implementer, reviewer, researcher, cross_reviewer, scanner, fast_coder, connector, done"),
HumanMessage(content=task),
])
print(response.content.strip().lower())
return
result = app.invoke({"task": task, "messages": []})
print(f"[{result['route']}]")
print()
output = result.get("result", "")
if isinstance(output, list):
output = "\n".join(str(c) for c in output)
print(output)
if __name__ == "__main__":
main()