feat: add pyproject.toml and inline log_setup for standalone installation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,9 +15,7 @@ import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Make kvm_common importable when running as `python -m kvm_agent`
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
from kvm_common.log_setup import add_debug_flag, setup_logging
|
||||
from .log_setup import add_debug_flag, setup_logging
|
||||
|
||||
from .agent import KVMAgent
|
||||
from .config import AgentConfig
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
"""KVM-Privacy unified logging configuration.
|
||||
|
||||
Provides consistent --debug flag and log formatting across all services.
|
||||
Auto-detects TTY vs journald to choose appropriate format.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
_FMT_JOURNAL = "[%(name)s] %(levelname)s: %(message)s"
|
||||
_FMT_CLI = "%(asctime)s [%(name)s] %(levelname)s: %(message)s"
|
||||
|
||||
|
||||
def setup_logging(*, service_name: str = "", debug: bool = False) -> None:
|
||||
"""Configure root logger with appropriate format and level.
|
||||
|
||||
Args:
|
||||
service_name: Used for context (currently informational).
|
||||
debug: If True, set DEBUG level; otherwise INFO.
|
||||
"""
|
||||
level = logging.DEBUG if debug else logging.INFO
|
||||
is_tty = sys.stderr.isatty()
|
||||
logging.basicConfig(
|
||||
level=level,
|
||||
format=_FMT_CLI if is_tty else _FMT_JOURNAL,
|
||||
datefmt="%H:%M:%S" if is_tty else None,
|
||||
)
|
||||
if debug:
|
||||
# Suppress noisy HTTP client debug logs
|
||||
logging.getLogger("httpx").setLevel(logging.WARNING)
|
||||
logging.getLogger("httpcore").setLevel(logging.WARNING)
|
||||
|
||||
|
||||
def add_debug_flag(parser) -> None:
|
||||
"""Add standardised --debug flag to an argparse parser.
|
||||
|
||||
Supports KVM_DEBUG=1 environment variable for systemd services.
|
||||
"""
|
||||
parser.add_argument(
|
||||
"--debug",
|
||||
action="store_true",
|
||||
default=os.environ.get("KVM_DEBUG", "").lower() in ("1", "true"),
|
||||
help="Enable debug logging (env: KVM_DEBUG=1)",
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=45"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "kvm-agent"
|
||||
version = "2.0.0"
|
||||
description = "Autonomous KVM computer-use agent with vision planning"
|
||||
requires-python = ">=3.9"
|
||||
dependencies = [
|
||||
"httpx>=0.25.0",
|
||||
"openai>=1.12.0",
|
||||
"pyyaml>=6.0",
|
||||
"aiohttp>=3.8.0",
|
||||
"pymysql>=1.0.0",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = ["pytest>=7.0", "pytest-asyncio>=0.21", "respx>=0.20"]
|
||||
|
||||
[project.scripts]
|
||||
kvm-agent = "kvm_agent.__main__:main"
|
||||
@@ -1,3 +1,5 @@
|
||||
httpx>=0.25.0
|
||||
openai>=1.12.0
|
||||
pyyaml>=6.0
|
||||
aiohttp>=3.8.0
|
||||
pymysql>=1.0.0
|
||||
|
||||
Reference in New Issue
Block a user