#!/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 os import sys from dotenv import load_dotenv os.chdir(os.path.dirname(os.path.abspath(__file__))) load_dotenv(".env") from graph import app, router_node # noqa: E402 (env must be loaded before graph imports composio) def main(): if len(sys.argv) < 2 or sys.argv[1] in ("-h", "--help"): print("Usage: python3 run.py [--route-only] ") 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: out = router_node({"task": task, "messages": []}) print(out["route"]) 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()