Action System Overview
RCLI’s action system consists of:- ActionRegistry — Registers actions and dispatches execution
- ActionDef — Defines action metadata (name, description, JSON schema)
- ActionFunc — Function that executes the action and returns a result
- Tool Engine — Parses LLM tool calls and routes to the registry
src/actions/ and are registered in src/actions/action_registry.cpp.
Action Anatomy
Every action consists of three parts:- Implementation function — executes the action
- Registration call — registers with the registry
- JSON schema — defines parameters for the LLM
Example: Create Note Action
Here’s thecreate_note action from src/actions/notes_actions.cpp:
src/actions/notes_actions.cpp
Step-by-Step: Adding a New Action
Choose a category
Actions are organized by category in
src/actions/:- notes_actions.cpp — Apple Notes integration
- reminders_actions.cpp — Reminders integration
- messages_actions.cpp — Messages/iMessage
- app_control_actions.cpp — Open/quit apps
- window_actions.cpp — Window management
- system_actions.cpp — System settings (volume, dark mode, lock screen)
- media_actions.cpp — Spotify/Apple Music
- web_actions.cpp — Web search
- browser_actions.cpp — Safari/Chrome control
- clipboard_actions.cpp — Clipboard read/write
- files_actions.cpp — File search
- navigation_actions.cpp — Maps integration
- communication_actions.cpp — FaceTime
calendar_actions.cpp).Write the action function
Create a function that matches the
ActionFunc signature:src/actions/my_category_actions.cpp
Call registration in action_registry.cpp
Edit
src/actions/action_registry.cpp and add your registration call:src/actions/action_registry.cpp
Action Helpers
src/actions/action_helpers.h provides utilities for parsing JSON and escaping strings:
JSON Parsing
String Escaping
Execution
ActionResult Structure
Success Example
Failure Example
JSON Schema Format
The LLM uses JSON schemas to understand action parameters. Use this format:Tool Calling Flow
Testing Your Action
Action Categories
Use these categories for consistency:productivity— Notes, reminders, shortcutscommunication— Messages, FaceTimemedia— Spotify, Apple Music, volumesystem— Dark mode, volume, lock screen, battery, Wi-Fiwindow— Close, minimize, fullscreenweb— Search, YouTube, Mapsclipboard— Read/write clipboardfiles— Search filesbrowser— Get URL, list tabs
Advanced: Native macOS APIs
Some actions use Objective-C APIs instead of AppleScript for better performance. Seesrc/audio/mic_permission.mm for examples.
src/audio/mic_permission.mm
Enabling/Disabling Actions
Users can enable/disable actions via:ActionDef:
Next Steps
Project Structure
Understand the codebase organization
Contributing
Submit your new action as a PR
Building from Source
Build and test your changes