devarshia5 commited on
Commit
0ef6f6b
·
verified ·
1 Parent(s): 62b83b2

Upload 15 files

Browse files
app/__pycache__/agy_server.cpython-313.pyc CHANGED
Binary files a/app/__pycache__/agy_server.cpython-313.pyc and b/app/__pycache__/agy_server.cpython-313.pyc differ
 
app/agy_server.py CHANGED
@@ -496,6 +496,51 @@ async def delete_key(key_id: int, _: dict = Depends(require_superadmin)):
496
  return {"revoked": db.revoke_api_key(key_id)}
497
 
498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  @app.get("/admin/system-prompt")
500
  async def get_sys_prompt(_: dict = Depends(require_superadmin)):
501
  custom = db.get_setting("system_prompt")
 
496
  return {"revoked": db.revoke_api_key(key_id)}
497
 
498
 
499
+ @app.get("/admin/agy-health")
500
+ async def agy_health(_: dict = Depends(require_superadmin)):
501
+ """Diagnose agy on this host: binary, creds file, and a live `agy -p` run + log."""
502
+ import subprocess
503
+ import tempfile
504
+ from . import agy_bridge as ab
505
+
506
+ info: dict = {"agy_bin": ab.AGY_BIN, "agy_bin_exists": Path(ab.AGY_BIN).is_file(),
507
+ "AGY_CREDS_JSON_set": bool(ab._CREDS_JSON), "creds_filename": ab._CREDS_FILENAME}
508
+ home = key_home(None)
509
+ try:
510
+ ab.ensure_home(home)
511
+ cred = ab.agy_dir(home) / ab._CREDS_FILENAME
512
+ info["injected_creds_path"] = str(cred)
513
+ info["injected_creds_exists"] = cred.is_file()
514
+ except Exception as e:
515
+ info["ensure_home_err"] = str(e)[:200]
516
+ try:
517
+ v = subprocess.run([ab.AGY_BIN, "--version"], capture_output=True, text=True,
518
+ timeout=20, env=ab._child_env(home))
519
+ info["version"] = ((v.stdout or v.stderr) or "").strip()[:120]
520
+ except Exception as e:
521
+ info["version_err"] = str(e)[:200]
522
+ d = Path(tempfile.mkdtemp())
523
+ log = d / "agy.log"
524
+ try:
525
+ p = subprocess.run([ab.AGY_BIN, "-p", "hi", "--log-file", str(log)], cwd=str(d),
526
+ capture_output=True, text=True, timeout=60, env=ab._child_env(home))
527
+ info["run_exit"] = p.returncode
528
+ info["run_stdout"] = (p.stdout or "")[:300]
529
+ info["run_stderr"] = (p.stderr or "")[:400]
530
+ info["log_tail"] = (log.read_text(errors="replace")[-2000:] if log.is_file() else "no log file")
531
+ except Exception as e:
532
+ info["run_err"] = str(e)[:300]
533
+ # list what agy actually created under HOME (to find the real creds location)
534
+ try:
535
+ found = []
536
+ for pat in ("*.json", "credentials*", "oauth*"):
537
+ found += [str(x) for x in Path(home).rglob(pat)][:20]
538
+ info["home_json_files"] = found[:30]
539
+ except Exception:
540
+ pass
541
+ return info
542
+
543
+
544
  @app.get("/admin/system-prompt")
545
  async def get_sys_prompt(_: dict = Depends(require_superadmin)):
546
  custom = db.get_setting("system_prompt")