feat: file logging on client, logs command to fetch last N lines

This commit is contained in:
Helios Agent 2026-03-03 17:09:23 +01:00
parent 23bbb5b603
commit db3fa9f416
No known key found for this signature in database
GPG key ID: C8259547CD8309B5
6 changed files with 130 additions and 9 deletions

View file

@ -236,6 +236,17 @@ def cmd_maximize(args):
print(f"Window {wid} maximized on session {sid!r}.")
def cmd_logs(args):
"""Fetch the last N lines of the client log file."""
sid = resolve_session(args.session_id)
resp = _req("GET", f"/sessions/{sid}/logs", params={"lines": args.lines})
data = resp.json()
if "error" in data:
sys.exit(f"[helios-remote] {data['error']}")
print(f"# {data.get('log_path', '?')} (last {args.lines} lines)")
print(data.get("content", ""))
def cmd_screenshot_window(args):
"""Capture a specific window by ID or title substring → /tmp/helios-remote-screenshot.png"""
sid = resolve_session(args.session_id)
@ -484,6 +495,10 @@ def build_parser() -> argparse.ArgumentParser:
stp = sub.add_parser("status", help="Show relay + client commit and sync status")
stp.add_argument("session_id")
lgp = sub.add_parser("logs", help="Fetch last N lines of client log file")
lgp.add_argument("session_id")
lgp.add_argument("--lines", type=int, default=100, metavar="N", help="Number of lines (default: 100)")
sub.add_parser("server-version", help="Get server version (no auth required)")
vp = sub.add_parser("version", help="Get client version for a session")
@ -550,6 +565,7 @@ def main():
"upload": cmd_upload,
"download": cmd_download,
"status": cmd_status,
"logs": cmd_logs,
"screenshot-window": cmd_screenshot_window,
"find-window": cmd_find_window,
"wait-for-window": cmd_wait_for_window,