-
Notifications
You must be signed in to change notification settings - Fork 0
Action System
Harish Dhanraj Sugandhi edited this page Mar 4, 2026
·
1 revision
The action system is the core of OpenWP. Every operation the AI agent can perform must be pre-registered as an action with a defined schema, capability, and risk level.
| Class | File | Purpose |
|---|---|---|
Action_Registry |
inc/Actions/Action_Registry.php |
Static registry of all available actions |
Action_Executor |
inc/Actions/Action_Executor.php |
Executes actions through policy/backup/logging pipeline |
Action_Bootstrap |
inc/Core/Action_Bootstrap.php |
Registers all 50+ built-in actions on boot |
ActionContext |
inc/Actions/ActionContext.php |
Carries user_id, prompt, model_output per execution |
ActionResult |
inc/Actions/ActionResult.php |
Structured action return type |
Actions are registered in Action_Bootstrap via the register() method:
$this->register(
'wp_create_post', // 1. Unique action key
[Content_Actions::class, 'create_post'], // 2. Callback
'edit_posts', // 3. Required WP capability
'low', // 4. Risk level
true, // 5. Mutates data?
true, // 6. Requires pre-action backup?
[ // 7. JSON input schema
'required' => ['title', 'content'],
'properties' => [
'title' => ['type' => 'string'],
'content' => ['type' => 'string'],
'status' => ['type' => 'string', 'enum' => ['draft', 'pending', 'publish']],
],
],
'openwp/content', // 8. Domain category
[ // 9. Output schema
'type' => 'object',
'properties' => ['post_id' => ['type' => 'integer']],
]
);| Level | Approval | Backup | Typed Confirmation |
|---|---|---|---|
low |
Never | Never | No |
medium |
Configurable | No | No |
high |
Configurable | Auto-required for mutating | No |
critical |
Configurable | Auto-required for mutating | Must type "APPROVE" |
Approval requirements are configurable per risk level via settings (medium_requires_approval, high_requires_approval, critical_requires_approval) and can be overridden per action via action policies.
Action_Executor::execute($action_key, $params, $context)
│
├── 1. Action_Registry::get($action_key) → Find action definition
├── 2. Schema_Validator::validate() → Validate params against schema
├── 3. PolicyEngine::evaluate() → Check permissions & policy
│ ├── Capability check (current_user_can)
│ ├── Action enabled check (policy override)
│ └── Determine approval/backup requirements
│
├── 4. If approval required (and not from_approval):
│ ├── Create approval record
│ ├── Log as pending_approval
│ └── Return {status: 'pending_approval', approval_id}
│
├── 5. If typed confirmation required:
│ └── Verify typed_confirmation === 'APPROVE'
│
├── 6. If backup required:
│ └── Backup_Service::create() → Full SQL dump
│
├── 7. call_user_func($callback, $params, $context)
│
└── 8. Log_Repository::insert() → Audit trail
└── Return {status, action, data, log_id, backup_id}
| Action | Capability | Risk | Mutates | Description |
|---|---|---|---|---|
wp_get_posts |
edit_posts |
low | No | List posts with filters |
wp_create_post |
edit_posts |
low | Yes | Create post with Gutenberg blocks |
wp_update_post |
edit_posts |
low | Yes | Update post content/meta |
publish_post |
publish_posts |
low | Yes | Publish a draft post |
wp_delete_post |
delete_posts |
low | Yes | Trash/delete a post |
| Action | Capability | Risk | Mutates |
|---|---|---|---|
wp_get_terms |
manage_categories |
low | No |
wp_create_term |
manage_categories |
low | Yes |
wp_update_term |
manage_categories |
low | Yes |
wp_delete_term |
manage_categories |
low | Yes |
| Action | Capability | Risk | Mutates |
|---|---|---|---|
wp_get_media |
upload_files |
low | No |
wp_upload_media |
upload_files |
low | Yes |
wp_update_media |
upload_files |
low | Yes |
wp_delete_media |
delete_posts |
low | Yes |
| Action | Capability | Risk | Mutates |
|---|---|---|---|
wp_get_users |
list_users |
low | No |
wp_create_user |
create_users |
low | Yes |
wp_update_user |
edit_users |
low | Yes |
delete_user |
delete_users |
low | Yes |
set_user_role |
promote_users |
low | Yes |
| Action | Capability | Risk | Mutates |
|---|---|---|---|
wp_get_comments |
moderate_comments |
low | No |
wp_update_comment |
moderate_comments |
low | Yes |
wp_delete_comment |
moderate_comments |
low | Yes |
| Action | Capability | Risk | Mutates |
|---|---|---|---|
wp_get_option |
manage_options |
low | No |
wp_update_option |
manage_options |
low | Yes |
delete_option |
manage_options |
low | Yes |
| Action | Capability | Risk | Mutates | Backup |
|---|---|---|---|---|
wp_list_plugins |
activate_plugins |
low | No | No |
install_plugin |
install_plugins |
low | Yes | No |
wp_activate_plugin |
activate_plugins |
low | Yes | Yes |
wp_deactivate_plugin |
activate_plugins |
low | Yes | Yes |
update_plugin |
update_plugins |
low | Yes | No |
wp_delete_plugin |
delete_plugins |
low | Yes | No |
| Action | Capability | Risk | Mutates |
|---|---|---|---|
wp_list_themes |
switch_themes |
low | No |
install_theme |
install_themes |
low | Yes |
wp_switch_theme |
switch_themes |
low | Yes |
update_theme |
update_themes |
low | Yes |
wp_delete_theme |
delete_themes |
low | Yes |
| Action | Capability | Risk | Mutates |
|---|---|---|---|
db_optimize_tables |
manage_options |
low | Yes |
db_repair_tables |
manage_options |
low | Yes |
db_analyze_tables |
manage_options |
low | Yes |
wp_db_query |
manage_options |
low | Yes |
| Action | Capability | Risk | Mutates |
|---|---|---|---|
remember_memory |
openwp_manage_settings |
low | Yes |
forget_memory |
openwp_manage_settings |
low | Yes |
list_memory |
openwp_manage_settings |
low | No |
clear_memory |
openwp_manage_settings |
low | Yes |
| Action | Capability | Risk | Description |
|---|---|---|---|
mcp_read_tool |
edit_posts |
low | Read-only MCP tools |
mcp_write_tool |
edit_posts |
medium | Write MCP tools (approval required) |
mcp_admin_tool |
manage_options |
high | Admin/destructive MCP tools |
Each domain has a dedicated handler class in inc/Actions/:
| Class | File | Actions |
|---|---|---|
Content_Actions |
inc/Actions/Content_Actions.php |
CRUD for posts/pages |
Taxonomy_Actions |
inc/Actions/Taxonomy_Actions.php |
CRUD for terms |
Media_Actions |
inc/Actions/Media_Actions.php |
Upload, update, delete media |
User_Actions |
inc/Actions/User_Actions.php |
User management |
Comment_Actions |
inc/Actions/Comment_Actions.php |
Comment moderation |
Option_Actions |
inc/Actions/Option_Actions.php |
WordPress options |
Plugin_Actions |
inc/Actions/Plugin_Actions.php |
Plugin lifecycle |
Theme_Actions |
inc/Actions/Theme_Actions.php |
Theme lifecycle |
Database_Actions |
inc/Actions/Database_Actions.php |
DB maintenance + raw queries |
Memory_Actions |
inc/Actions/Memory_Actions.php |
Agent memory CRUD |
Mcp_Bridge_Action |
inc/Actions/Mcp_Bridge_Action.php |
Bridges MCP tools to action system |
OpenWP v0.1.4 | GitHub Repository | GPLv2+