Choose which components the canvas in codeagent_app() offers and how
strictly model-authored text is checked. Components are the same objects
shinygenui uses (shinygenui::genui_component()); build your own with
canvas_component_output() or canvas_component_widget(), or pass any
existing genui_component.
Arguments
- components
A list of
genui_componentobjects supplied by the host.- starter
Which of shinygenui's own components to offer:
TRUE(all of them, the default),FALSE(none), or a character vector of their names ("value_box","data_table","scatter_plot","histogram","markdown_card","card_row").- data_env
Environment in which
datasetnames are looked up.- csp
Content Security Policy for the page while the canvas is available:
TRUE(default; images, media, frames and plugins only from the app itself),FALSE(none), or a policy string of your own – for example when a component loads map tiles from another origin. The policy applies to the whole host page, including the host's own content.- validate_text
If
TRUE(default), every string the model passes to a canvas tool is refused when it contains markup, links, URLs or control characters, before anything reaches the browser. This guards against the model (or a prompt injection) placing data in a URL the browser would fetch. SetFALSEwhen your components need the model to supply URLs.
Details
Host components are trusted code: codeagent registers them as canvas tools (read-only, behind the central permission gate), runs them through the same transactional executor, Data Shield scanning and strict session restore as the built-in ones, and leaves what they render to you.
Examples
if (FALSE) { # \dontrun{
boxplot_card <- canvas_component_output(
"boxplot", "Box plot of a numeric column by group.",
args = list(y = ellmer::type_string("Numeric column."),
by = ellmer::type_string("Grouping column.")),
output = shiny::plotOutput,
render = function(args, data) shiny::renderPlot(
boxplot(reformulate(args$by, args$y), data = data())))
codeagent_app(chat, canvas = canvas_options(
components = list(boxplot_card), starter = c("data_table", "histogram")))
} # }