-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
57 lines (45 loc) · 1.9 KB
/
Copy pathcli.py
File metadata and controls
57 lines (45 loc) · 1.9 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
"""AgentSandbox CLI."""
import argparse
import asyncio
import os
import sys
ROOT = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, ROOT)
from dotenv import load_dotenv
load_dotenv(os.path.join(ROOT, ".env"))
from src.db import AgentSandboxDB, Job, JobStatus
from src.flow import AgentSandboxFlow
from src.workspace import ensure_workspace_repo
async def main():
parser = argparse.ArgumentParser(description="AgentSandbox CLI")
parser.add_argument("objective", nargs="?", help="Objective to execute")
parser.add_argument("--status", help="Filter jobs by status (pending/running/completed/failed)")
parser.add_argument("--list", action="store_true", help="List all jobs")
args = parser.parse_args()
DB_PATH = os.environ.get("SQLITE_DB", os.path.join(ROOT, "data", "agentsandbox.db"))
WS_ROOT = os.environ.get("WORKSPACE_REPO", os.path.join(ROOT, "workspace"))
os.makedirs(os.path.dirname(DB_PATH), exist_ok=True)
ensure_workspace_repo(WS_ROOT)
db = AgentSandboxDB(DB_PATH)
await db.start()
if args.list or args.status:
s = JobStatus(args.status) if args.status else None
jobs = await db.list_jobs(status=s)
for j in jobs:
print(f"[{j.status.value.upper():10}] {j.id[:8]} | {j.objective[:60]} | created={j.created_at[:19]}")
return
if not args.objective:
print("Usage: python cli.py \"your objective here\" OR python cli.py --list")
return
job = Job(objective=args.objective)
await db.insert_job(job)
print(f"Job submitted: {job.id}")
print("Running manager → specialist → reviewer pipeline...")
flow = AgentSandboxFlow(db=db, job=job)
result = await flow.run()
print(f"\nJob {result.status.value}: {result.id}")
if result.final_output:
print("\n--- Final Output ---")
print(result.final_output[:2000])
if __name__ == "__main__":
asyncio.run(main())