% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/daemon.R
\name{with_lms_daemon}
\alias{with_lms_daemon}
\title{Run code with the LM Studio daemon active}
\usage{
with_lms_daemon(code)
}
\arguments{
\item{code}{An R expression to execute while the daemon is running.}
}
\value{
The result of the evaluated code.
}
\description{
Temporarily starts the LM Studio headless daemon, executes the provided
R expression, and then gracefully shuts the daemon and any active servers
down. This is ideal for automated scripts and pipelines.
}
\section{Desktop Users}{

Be cautious using this wrapper if you already have the LM Studio GUI open.
While the setup phase (\code{lms_daemon_start}) will succeed, the teardown phase
(\code{lms_daemon_stop}) will fail because the CLI prevents programmatic shutdowns
of the graphical interface. This wrapper is best reserved for strictly
headless environments or fully automated scripts.
}

\examples{
\dontrun{
result <- with_lms_daemon({
  lms_load("llama-3.1-8b")
  lms_chat("llama-3.1-8b", input = "Hello world!")
})
}
}
