% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/chatbot.R
\name{chatbot_server}
\alias{chatbot_server}
\title{Chat-bot server logic (per-module)}
\usage{
chatbot_server(
  input,
  output,
  session,
  id = "shidashi-chatbot",
  drawer_id = "shidashi_drawer",
  agent_conf = NULL
)
}
\arguments{
\item{input, output, session}{Standard Shiny server arguments
(typically module-scoped when inside \code{moduleServer}).}

\item{id}{character; must match the \code{id} used in
\code{chatbot_ui()}. Default \code{"shidashi-chatbot"}.}

\item{drawer_id}{character; the output ID of the drawer's
\code{uiOutput} placeholder (from \code{\link{module_drawer}()}).
Default \code{"shidashi_drawer"}.}

\item{agent_conf}{list; parsed \code{agents.yaml} content. Used
for the system prompt and tool configuration.}
}
\value{
Called for side effects (sets up observers). Returns
  \code{invisible(NULL)}.
}
\description{
Sets up the chat server for a single module.
Creates its own \code{\link[ellmer]{Chat}} object, binds tools from
the \verb{MCP} session registry, and manages per-module conversation
history.

The function renders \code{\link{chatbot_ui}()} into the drawer's
\code{uiOutput} via \code{shiny::renderUI}, and opens the drawer
when a \code{"button.click"} shidashi-event with
\code{type = "open_drawer"} is received.
Any element with \code{data-shidashi-action="shidashi-button"}
\code{data-shidashi-type="open_drawer"} can trigger the drawer.

This function is injected into each module's server function by
\code{modules.R} when \code{agents.yaml} has \code{enabled: yes}.
It is called inside \code{shiny::moduleServer()}, so \code{session}
is module-scoped.  \pkg{shinychat} operations use the scoped
\code{session}; only drawer and event operations use
\code{session$rootScope()}.
}
\keyword{internal}
