riprap-nyc / agent.py
seriffic's picture
Backend evolution: Phases 1-10 specialists + agentic FSM + Mellea + LiteLLM router
6a82282
"""Riprap agent CLI β€” address β†’ cited briefing via the Burr FSM.
Usage:
python agent.py "180 Beach 35 St, Queens"
python agent.py "280 Broome St, Manhattan" --json
"""
from __future__ import annotations
import argparse
import json
import sys
import warnings
warnings.filterwarnings("ignore")
from app.fsm import run # noqa: E402
def main() -> int:
ap = argparse.ArgumentParser()
ap.add_argument("query", help="NYC address or natural-language location")
ap.add_argument("--json", action="store_true", help="emit full JSON state")
args = ap.parse_args()
print(f"\n query: {args.query}", file=sys.stderr)
print(" running FSM... (Granite 4.1 + open data, all local)\n", file=sys.stderr)
result = run(args.query)
if args.json:
print(json.dumps(result, indent=2, default=str))
return 0
print("─── trace " + "─" * 56)
for step in result["trace"]:
ok = "βœ“" if step["ok"] else "βœ—"
line = f" {ok} {step['step']:22s} {step.get('elapsed_s', 0):>5.2f}s"
if step.get("result"):
line += " " + json.dumps(step["result"], default=str)
elif step.get("err"):
line += " ERR: " + step["err"]
print(line)
print("\n─── cited report " + "─" * 49)
print()
print(result["paragraph"])
print()
return 0
if __name__ == "__main__":
sys.exit(main())