Skip to contents

Construct configuration from named fields or one named list using the same field names and nesting as config.yaml. Construction validates the supplied values without reading files, finding executables, or starting a process. Nested lists are converted to typed configuration objects; edit properties with @, including replacing a nested object with another named list.

Usage

ConsoleConfig(
  ...,
  r = NULL,
  python = NULL,
  resolver = NULL,
  sandbox = NULL,
  languages = NULL,
  cache = NULL,
  environment = NULL,
  inherit_environment = NULL,
  tool = NULL,
  startup = NULL,
  sessions = NULL
)

Arguments

...

A single unnamed list of configuration fields, instead of named arguments. All other arguments must be supplied by their full names.

r

An R executable path, or a list with executable, packages, resolution, and vanilla. Resolution is "implicit" (prepare packages as needed), "explicit" (only on request), "fixed" (startup packages only), or "disabled" (use installed packages). vanilla = TRUE skips native R startup files.

python

An existing environment path, list(existing = path), or list(managed = list(version = "3.13", packages = "pandas", resolution = "fixed")). Managed Python supports "implicit", "explicit", and "fixed". list(first_available = list(...)) tries existing paths, "active_venv", and an optional managed choice, last, in order.

resolver

A list with environment, inherit_environment, and sandbox, controlling package preparation separately from executed code.

sandbox

A permission list with profile, filesystem, network, and tempdir, or FALSE for host execution. Profiles are "read_only" (the default), "workspace" (project writes with metadata protection), and "inherit_codex" (client permissions). Filesystem entries are read_only, read_write, and deny path vectors. Temporary storage is "managed" (the default), "read_write", or "read_only".

languages

A character vector selecting "r", "python", and/or "sql". By default all three are visible to the model.

cache

"managed", "host", or list(directory = "/path/to/cache") for package caches. Defaults to managed caches with sandboxing and host caches with sandbox = FALSE.

environment

Named character vector or list of string environment values shared by workers and package preparation.

inherit_environment

Whether child processes inherit the launch environment, TRUE by default.

tool

A list with description, instructions, and parameters. Each named parameter accepts enabled, description, and nested parameters; for example, list(parameters = list(timeout_ms = list(enabled = FALSE))) hides the timeout argument.

startup

A list with language ("r" or "python") and code that creates and selects a SQL connection before the first cell in each session.

sessions

A list with max, a positive whole number limiting concurrent sessions. By default there is no limit.

Value

An S7 configuration object.

Details

Use load_console_config() to read configuration files once. Both constructors return the same class, and passing either result to console_tools() disables further file discovery. Unspecified R selection uses the calling R installation at load or launch, below explicit configuration.

NULL fields are omitted. Empty mappings and character vectors are retained. as.list() returns JSON-ready application settings; the launch-only choice sandbox = FALSE is not included in that document. A loaded R executable reset is retained as an explicit JSON null, so saving and reloading the settings preserves native R discovery.

For worker or resolver network settings, TRUE enables direct networking and FALSE restricts it. The scalar strings "enabled" and "restricted" select the same modes; other strings are allowed proxy patterns. Character vectors and unnamed lists supply allowed patterns, including an empty vector or list for an explicit empty allow list. Named mappings use proxy = list(domains = list(allow = ..., deny = ...)) for explicit rules. YAML accepts the same boolean, string, and sequence forms. A YAML network: null is omitted when files merge, preserving an earlier network field. R network = NULL is omitted from the constructed settings.

See also

console_tools() to launch with this configuration; load_console_config() to read configuration files; vignette("configuration", package = "mcp.console") for settings and examples.

Examples

ConsoleConfig()
ConsoleConfig(r = list(packages = c("dplyr", "ggplot2")))
ConsoleConfig(sandbox = list(network = c("api.example.com", "*.example.org")))
ConsoleConfig(list(
  python = ".venv",
  sandbox = list(filesystem = list(read_write = "./output"))
))