"""Entry point for the dev agent. Loads configuration, builds the agent, and stays up until told to stop. Shutdown is deliberate rather than abrupt: L8's durability guarantees assume the process may die at any moment, but a clean stop still beats relying on them. """ import os import signal import sys from pathlib import Path from types import FrameType from nisse_core.config import ConfigError from nisse_core.envfile import load_env_file from nisse_dev.config import AgentConfig from nisse_dev.loop.build import build_loop_agent def main() -> int: load_env_file(Path(os.environ.get("NISSE_ENV", ".env")).expanduser()) try: config = AgentConfig.load() except ConfigError as exc: # Fail here rather than twenty minutes into a milestone on the one # call that needed the missing value. print(f"nisse-dev: {exc}", file=sys.stderr) return 2 agent = build_loop_agent(config) def shutdown(_signum: int, _frame: FrameType | None) -> None: print("nisse-dev: stopping", file=sys.stderr) agent.stop() signal.signal(signal.SIGINT, shutdown) signal.signal(signal.SIGTERM, shutdown) agent.start() names = ", ".join(p.name for p in config.projects) print(f"nisse-dev: ready as {agent.account} on {names}", file=sys.stderr) agent.wait() return 0 if __name__ == "__main__": raise SystemExit(main())