INNER CODE UNIT · Python
main
i3T4AN/KADATH · kadath/cli.py:51
def main(argv: list[str] | None = None) -> None:
args = parser().parse_args(argv); kernel = Kernel(args.root)
try:
if args.command in {"init", "start"}:
if args.executor in {"command", "docker"} and not args.agent_command:
raise RunError("--executor command/docker requires --command")
if args.executor == "docker" and not args.image:
raise RunError("--executor docker requires --image")
agent_env = {}
reserved = {"KADATH_DATABASE_URL", "LITELLM_API_KEY", "LITELLM_MASTER_KEY", "LITELLM_API_BASE", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "DOCKER_HOST", "KADATH_WORKER_TOKEN", "KADATH_WORKER_BROKER_URL"}
for item in args.agent_env:
if "=" not in item or not item.split("=", 1)[0]:
raise RunError("--agent-env must use KEY=VALUE")
key, value = item.split("=", 1); agent_env[key] = value
if key in reserved: raise RunError(f"--agent-env cannot override reserved control variable {key}")
run_id = kernel.init(args.goal, args.criterion, args.epochs, args.population, args.epoch_seconds, args.executor, args.agent_command, agent_env=agent_env)
if args.executor == "docker":
runtime = kernel._run_dir(run_id) / "runtime.json"