-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
88 lines (73 loc) · 2.65 KB
/
cli.py
File metadata and controls
88 lines (73 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python3
import sys
from rich.console import Console
from rich.table import Table
from rich.panel import Panel
from app.runtime import run_objective
console = Console()
def main():
if len(sys.argv) < 2:
console.print(
"[red]Usage:[/red] python cli.py \"<your research objective>\"",
style="bold",
)
console.print(
"\n[yellow]Example:[/yellow] python cli.py \"Research quantum computing applications and risks\"",
)
sys.exit(1)
objective = " ".join(sys.argv[1:])
console.print(
Panel(
f"[bold cyan]Objective:[/bold cyan] {objective}",
title="🧠 MCA Research System",
border_style="cyan",
)
)
with console.status("[bold green]Running multi-agent workflow...", spinner="dots"):
trace = run_objective(objective)
table = Table(title="Message Trace", show_lines=True)
table.add_column("Time", style="dim")
table.add_column("Type", style="cyan")
table.add_column("From → To", style="magenta")
table.add_column("Confidence", justify="right", style="green")
table.add_column("State", style="yellow")
for env in trace:
msg_type_style = {
"goal_directive": "[bold blue]",
"status_update": "[green]",
"help_request": "[yellow]",
"goal_complete": "[bold green]",
"error_signal": "[red]",
}.get(env.message_type, "")
conf = env.payload.confidence
conf_str = f"{conf:.2f}"
if conf >= 0.70:
conf_str = f"[green]{conf_str}[/green]"
elif conf >= 0.40:
conf_str = f"[yellow]{conf_str}[/yellow]"
else:
conf_str = f"[red]{conf_str}[/red]"
table.add_row(
env.timestamp[11:19],
f"{msg_type_style}{env.message_type}",
f"{env.sender_agent} → {env.recipient_agent}",
conf_str,
env.payload.current_state[:40],
)
console.print(table)
final_confidence = 0.0
for env in reversed(trace):
if env.message_type == "goal_complete":
final_confidence = env.payload.confidence
break
console.print(
Panel(
f"[bold]Total Messages:[/bold] {len(trace)}\n"
f"[bold]Final Confidence:[/bold] {final_confidence:.2f}\n"
f"[bold]Status:[/bold] {'✅ Complete' if final_confidence >= 0.75 else '⚠️ Needs Review'}",
title="Summary",
border_style="green" if final_confidence >= 0.75 else "yellow",
)
)
if __name__ == "__main__":
main()