Type: Package
Title: AI Coding Agent for 'RStudio'
Version: 0.1.0
Maintainer: Juan Cruz Rodriguez <jcrodriguez@unc.edu.ar>
Description: Provides an 'RStudio' extension with a chat interface for an AI coding agent to help users with R programming tasks.
License: MIT + file LICENSE
URL: https://myownrobs.github.io/myownrobs/, https://github.com/MyOwnRobs/myownrobs
BugReports: https://github.com/MyOwnRobs/myownrobs/issues
Encoding: UTF-8
RoxygenNote: 7.3.2
Imports: fs, gargle, glue, httr2, jsonlite, mirai, rstudio.prefs, rstudioapi, shiny, tools, uuid, yaml
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
NeedsCompilation: no
Packaged: 2025-09-22 23:25:27 UTC; jcrodriguez
Author: Juan Cruz Rodriguez [aut, cre]
Repository: CRAN
Date/Publication: 2025-09-30 07:30:02 UTC

Debug Print Function

Description

Prints a value to the console with a timestamp if the 'DEBUG' environment variable is set. This function is useful for conditional debugging output in R projects.

Usage

debug_print(value)

Arguments

value

The R object to be printed.


Execute LLM tools

Description

Execute LLM tools

Usage

execute_llm_tools(tools, mode)

Arguments

tools

A list of tools to execute

mode

The mode of operation, one of "agent" or "ask".


Get API Key

Description

Retrieves the API key for MyOwnRobs from the internal state environment.

Usage

get_api_key()

Get a Configuration Value

Description

Get a Configuration Value

Usage

get_config(config)

Arguments

config

The name of the configuration value to obtain.


Get Project Context Information

Description

Gathers various pieces of context information about the current R session and project. It includes details about the working directory, RStudio project, source editor context, and operating system.

Usage

get_project_context()

Launch MyOwnRobs

Description

Open the RStudio addin with the chat interface.

Usage

myownrobs(
  api_url = paste0("https://myownhadley.com/api/v", packageVersion("myownrobs")$major)
)

Arguments

api_url

The API URL to use for requests. This parameter is for advanced users who want to specify an alternative backend URL and is rarely needed.

Value

No return value. Called for its side effects to launch the MyOwnRobs RStudio addin.

Examples

if (interactive()) {
  myownrobs()
  # Specify the API URL.
  myownrobs("https://myownhadley.com/api/v0")
}


MyOwnRobs Shiny Server

Description

MyOwnRobs Shiny Server

Usage

myownrobs_server(api_url)

Arguments

api_url

The API URL to use for requests.


MyOwnRobs Shiny UI

Description

MyOwnRobs Shiny UI

Usage

myownrobs_ui()

Parse Agent Response

Description

This function parses the raw text response from an AI agent, expecting a JSON string potentially wrapped in markdown code fences. It extracts the JSON part and attempts to parse it.

Usage

parse_agent_response(response_text)

Arguments

response_text

The raw text response received from the AI agent.


Policy Acceptance Shiny Server

Description

Policy Acceptance Shiny Server

Usage

policy_server(policy)

Arguments

policy

A list with the policy.


Policy Acceptance Shiny UI

Description

Policy Acceptance Shiny UI

Usage

policy_ui(policy)

Arguments

policy

A list with the policy.


Save MyOwnRobs Credentials Locally

Description

Save MyOwnRobs Credentials Locally

Usage

save_api_key(api_key)

Arguments

api_key

The MyOwnRobs API key to save locally.


Save Run MyOwnRobs At Startup

Description

Save Run MyOwnRobs At Startup

Usage

save_run_at_startup()

Send Prompt to the LLM

Description

Send Prompt to the LLM

Usage

send_prompt(
  chat_id,
  prompt,
  role,
  mode,
  model,
  project_context,
  api_url,
  api_key
)

Arguments

chat_id

The ID of the chat session.

prompt

The prompt to send.

role

The role of the entity sending the prompt, one of "user" or "tool_runner".

mode

The mode of operation, one of "agent" or "ask".

model

The ID of the model to use.

project_context

The context of the session executing the addin, obtained with 'get_project_context()'.

api_url

The API URL to use for requests.

api_key

The API key for MyOwnRobs, obtained with 'get_api_key()'.


Asynchronously Send Prompt to the LLM

Description

Asynchronously Send Prompt to the LLM

Usage

send_prompt_async(
  chat_id,
  prompt,
  role,
  mode,
  model,
  project_context,
  api_url,
  api_key
)

Arguments

chat_id

The ID of the chat session.

prompt

The prompt to send.

role

The role of the entity sending the prompt, one of "user" or "tool_runner".

mode

The mode of operation, one of "agent" or "ask".

model

The ID of the model to use.

project_context

The context of the session executing the addin, obtained with 'get_project_context()'.

api_url

The API URL to use for requests.

api_key

The API key for MyOwnRobs, obtained with 'get_api_key()'.


Set a Configuration Value

Description

Set a Configuration Value

Usage

set_config(config, value)

Arguments

config

The name of the configuration value to set.

value

The value to assign to assign to the configuration.


Set the Initial State of the Project

Description

Whether to save the initial state or to restore it.

Usage

set_initial_project(restore = FALSE)

Arguments

restore

If TRUE, it will restore the initial state. If FALSE, it will save the initial store in R's temp dir.


Settings Module

Description

Settings Module

Usage

settings_module(id, r_trigger)

Arguments

id

Module id.

r_trigger

A reactive expression that triggers opening the modal.


Validate Command Arguments

Description

Checks if all required parameters for a given command are present in the provided arguments. This function ensures that the AI agent has supplied all necessary arguments before executing a command.

Usage

validate_command_args(command, args)

Arguments

command

A list representing the command definition, expected to contain a 'parameters' element.

args

A list of arguments provided to the command.


Validate MyOwnRobs Credentials

Description

Validate MyOwnRobs Credentials

Usage

validate_credentials(api_url, force = FALSE)

Arguments

api_url

The API URL to use for requests.

force

Force validation altough there's an existing key.


Validate MyOwnRobs Policy Acceptance

Description

Checks if the user already accepted the usage policy. If the user didn't it prompts the policies.

Usage

validate_policy_acceptance()