Abilities API

WordPress 6.9 Abilities API provides standardized capability discovery and execution for Data Machine operations. All REST API, CLI, and Chat tool operations delegate to registered abilities.

Overview

The Abilities API in inc/Abilities/ provides a unified interface for Data Machine operations. Each ability implements execute_callback with permission_callback for consistent access control across REST API, CLI commands, and Chat tools.

Total registered abilities: 193

The tables below document the core ability groups most commonly used by REST, CLI, and chat integrations. For a generated live inventory, run wp abilities list --category=datamachine-* or inspect the current wp_register_ability() callsites under inc/Abilities/.

Multi-Agent Scoping

All abilities support agent_id and user_id parameters for multi-agent scoping. The PermissionHelper class resolves scoped agent and user IDs, enforces ownership checks via owns_resource() and owns_agent_resource(), and controls access grants via can_access_agent().

Registered Abilities

Pipeline Management (7 abilities)

AbilityDescriptionLocation
datamachine/get-pipelinesList pipelines with pagination, or get single by IDinc/Abilities/Pipeline/GetPipelinesAbility.php
datamachine/create-pipelineCreate new pipelineinc/Abilities/Pipeline/CreatePipelineAbility.php
datamachine/update-pipelineUpdate pipeline propertiesinc/Abilities/Pipeline/UpdatePipelineAbility.php
datamachine/delete-pipelineDelete pipeline and associated flowsinc/Abilities/Pipeline/DeletePipelineAbility.php
datamachine/duplicate-pipelineDuplicate pipeline with flowsinc/Abilities/Pipeline/DuplicatePipelineAbility.php
datamachine/import-pipelinesImport pipelines from CSVinc/Abilities/Pipeline/ImportExportAbility.php
datamachine/export-pipelinesExport pipelines to CSVinc/Abilities/Pipeline/ImportExportAbility.php

Pipeline Steps (5 abilities)

AbilityDescriptionLocation
datamachine/get-pipeline-stepsList steps for a pipeline, or get single by IDinc/Abilities/PipelineStepAbilities.php
datamachine/add-pipeline-stepAdd step to pipeline (auto-syncs to all flows)inc/Abilities/PipelineStepAbilities.php
datamachine/update-pipeline-stepUpdate pipeline step config (system prompt, provider, model, tools)inc/Abilities/PipelineStepAbilities.php
datamachine/delete-pipeline-stepRemove step from pipeline (removes from all flows)inc/Abilities/PipelineStepAbilities.php
datamachine/reorder-pipeline-stepsReorder pipeline stepsinc/Abilities/PipelineStepAbilities.php

Flow Management (5 abilities)

AbilityDescriptionLocation
datamachine/get-flowsList flows with filtering, or get single by IDinc/Abilities/Flow/GetFlowsAbility.php
datamachine/create-flowCreate new flow from pipelineinc/Abilities/Flow/CreateFlowAbility.php
datamachine/update-flowUpdate flow propertiesinc/Abilities/Flow/UpdateFlowAbility.php
datamachine/delete-flowDelete flow and associated jobsinc/Abilities/Flow/DeleteFlowAbility.php
datamachine/duplicate-flowDuplicate flow within pipelineinc/Abilities/Flow/DuplicateFlowAbility.php

Flow Steps (4 abilities)

AbilityDescriptionLocation
datamachine/get-flow-stepsList steps for a flow, or get single by IDinc/Abilities/FlowStep/GetFlowStepsAbility.php
datamachine/update-flow-stepUpdate flow step configinc/Abilities/FlowStep/UpdateFlowStepAbility.php
datamachine/configure-flow-stepsBulk configure flow stepsinc/Abilities/FlowStep/ConfigureFlowStepsAbility.php
datamachine/validate-flow-steps-configValidate flow steps configurationinc/Abilities/FlowStep/ValidateFlowStepsConfigAbility.php

Queue Management (13 abilities)

AbilityDescriptionLocation
datamachine/queue-addAdd item to flow queueinc/Abilities/Flow/QueueAbility.php
datamachine/queue-listList queue entriesinc/Abilities/Flow/QueueAbility.php
datamachine/queue-clearClear queueinc/Abilities/Flow/QueueAbility.php
datamachine/queue-removeRemove item from queueinc/Abilities/Flow/QueueAbility.php
datamachine/queue-updateUpdate queue iteminc/Abilities/Flow/QueueAbility.php
datamachine/queue-moveReorder queue iteminc/Abilities/Flow/QueueAbility.php
datamachine/queue-modeSet queue access mode (drain, loop, or static)inc/Abilities/Flow/QueueAbility.php
datamachine/config-patch-addAdd a fetch config patch to a flow step queueinc/Abilities/Flow/QueueAbility.php
datamachine/config-patch-listList fetch config patchesinc/Abilities/Flow/QueueAbility.php
datamachine/config-patch-clearClear fetch config patchesinc/Abilities/Flow/QueueAbility.php
datamachine/config-patch-removeRemove a fetch config patch by indexinc/Abilities/Flow/QueueAbility.php
datamachine/config-patch-updateUpdate a fetch config patch by indexinc/Abilities/Flow/QueueAbility.php
datamachine/config-patch-moveReorder a fetch config patchinc/Abilities/Flow/QueueAbility.php

Webhook Triggers (8 abilities)

AbilityDescriptionLocation
datamachine/webhook-trigger-enableEnable webhook trigger for a flow. Supports bearer (default) or hmac (template-based).inc/Abilities/Flow/WebhookTriggerAbility.php
datamachine/webhook-trigger-disableDisable webhook trigger, revoke all auth material (token, template, secrets).inc/Abilities/Flow/WebhookTriggerAbility.php
datamachine/webhook-trigger-regenerateRegenerate Bearer token (bearer mode only; old token immediately invalidated).inc/Abilities/Flow/WebhookTriggerAbility.php
datamachine/webhook-trigger-set-secretSet or replace a specific secret id on an existing HMAC flow (no grace window).inc/Abilities/Flow/WebhookTriggerAbility.php
datamachine/webhook-trigger-rotate-secretZero-downtime rotation — demote current → previous with a TTL, install a fresh current.inc/Abilities/Flow/WebhookTriggerAbility.php
datamachine/webhook-trigger-forget-secretRemove a specific secret by id from the rotation list.inc/Abilities/Flow/WebhookTriggerAbility.php
datamachine/webhook-trigger-rate-limitSet rate limiting for flow webhook trigger.inc/Abilities/Flow/WebhookTriggerAbility.php
datamachine/webhook-trigger-statusGet webhook trigger status — auth mode, template, secret ids. Never the secret values.inc/Abilities/Flow/WebhookTriggerAbility.php

Job Execution (9 abilities)

AbilityDescriptionLocation
datamachine/get-jobsList jobs with filtering, or get single by IDinc/Abilities/Job/GetJobsAbility.php
datamachine/get-jobs-summaryGet job status summary countsinc/Abilities/Job/JobsSummaryAbility.php
datamachine/delete-jobsDelete jobs by criteriainc/Abilities/Job/DeleteJobsAbility.php
datamachine/execute-workflowExecute workflowinc/Abilities/Job/ExecuteWorkflowAbility.php
datamachine/get-flow-healthGet flow health metricsinc/Abilities/Job/FlowHealthAbility.php
datamachine/get-problem-flowsList flows exceeding failure thresholdinc/Abilities/Job/ProblemFlowsAbility.php
datamachine/recover-stuck-jobsRecover jobs stuck in processing stateinc/Abilities/Job/RecoverStuckJobsAbility.php
datamachine/retry-jobRetry a failed jobinc/Abilities/Job/RetryJobAbility.php
datamachine/fail-jobManually fail a processing jobinc/Abilities/Job/FailJobAbility.php

Engine (4 abilities)

Internal abilities for the pipeline execution engine.

AbilityDescriptionLocation
datamachine/run-flowRun a flowinc/Abilities/Engine/RunFlowAbility.php
datamachine/execute-stepExecute a pipeline stepinc/Abilities/Engine/ExecuteStepAbility.php
datamachine/schedule-next-stepSchedule the next step in pipeline executioninc/Abilities/Engine/ScheduleNextStepAbility.php
datamachine/schedule-flowSchedule a flow for executioninc/Abilities/Engine/ScheduleFlowAbility.php

Agent Management (6 abilities)

AbilityDescriptionLocation
datamachine/list-agentsList all registered agent identitiesinc/Abilities/AgentAbilities.php
datamachine/create-agentCreate a new agent identity with filesystem directory and owner accessinc/Abilities/AgentAbilities.php
datamachine/get-agentRetrieve a single agent by slug or ID with access grantsinc/Abilities/AgentAbilities.php
datamachine/update-agentUpdate an agent’s mutable fields (name, config, status)inc/Abilities/AgentAbilities.php
datamachine/delete-agentDelete an agent record and access grants, optionally remove filesysteminc/Abilities/AgentAbilities.php
datamachine/rename-agentRename an agent slug — updates database and moves filesystem directoryinc/Abilities/AgentAbilities.php

Agent Memory (4 abilities)

AbilityDescriptionLocation
datamachine/get-agent-memoryRead agent memory content — full file or a specific sectioninc/Abilities/AgentMemoryAbilities.php
datamachine/update-agent-memoryWrite to a specific section of agent memory — set (replace) or appendinc/Abilities/AgentMemoryAbilities.php
datamachine/search-agent-memorySearch across agent memory content, returns matching lines with contextinc/Abilities/AgentMemoryAbilities.php
datamachine/list-agent-memory-sectionsList all section headers in agent memoryinc/Abilities/AgentMemoryAbilities.php

Daily Memory (5 abilities)

AbilityDescriptionLocation
datamachine/daily-memory-readRead a daily memory file by date (defaults to today)inc/Abilities/DailyMemoryAbilities.php
datamachine/daily-memory-writeWrite or append to a daily memory fileinc/Abilities/DailyMemoryAbilities.php
datamachine/daily-memory-listList all daily memory files grouped by monthinc/Abilities/DailyMemoryAbilities.php
datamachine/search-daily-memorySearch across daily memory files with optional date rangeinc/Abilities/DailyMemoryAbilities.php
datamachine/daily-memory-deleteDelete a daily memory file by dateinc/Abilities/DailyMemoryAbilities.php

Agent Files (5 abilities)

AbilityDescriptionLocation
datamachine/list-agent-filesList memory files from agent identity and user layersinc/Abilities/File/AgentFileAbilities.php
datamachine/get-agent-fileGet a single agent memory file with contentinc/Abilities/File/AgentFileAbilities.php
datamachine/write-agent-fileWrite or update content for an agent memory fileinc/Abilities/File/AgentFileAbilities.php
datamachine/delete-agent-fileDelete an agent memory file (protected files cannot be deleted)inc/Abilities/File/AgentFileAbilities.php
datamachine/upload-agent-fileUpload a file to the agent memory directoryinc/Abilities/File/AgentFileAbilities.php

Flow Files (5 abilities)

AbilityDescriptionLocation
datamachine/list-flow-filesList uploaded files for a flow stepinc/Abilities/File/FlowFileAbilities.php
datamachine/get-flow-fileGet metadata for a single flow fileinc/Abilities/File/FlowFileAbilities.php
datamachine/delete-flow-fileDelete an uploaded file from a flow stepinc/Abilities/File/FlowFileAbilities.php
datamachine/upload-flow-fileUpload a file to a flow stepinc/Abilities/File/FlowFileAbilities.php
datamachine/cleanup-flow-filesCleanup data packets and temporary files for a job or flowinc/Abilities/File/FlowFileAbilities.php

Chat Sessions (4 abilities)

AbilityDescriptionLocation
datamachine/create-chat-sessionCreate a new chat session for a userinc/Abilities/Chat/CreateChatSessionAbility.php
datamachine/list-chat-sessionsList chat sessions with pagination and context filteringinc/Abilities/Chat/ListChatSessionsAbility.php
datamachine/get-chat-sessionRetrieve a chat session with conversation and metadatainc/Abilities/Chat/GetChatSessionAbility.php
datamachine/delete-chat-sessionDelete a chat session after verifying ownershipinc/Abilities/Chat/DeleteChatSessionAbility.php

Coding / GitHub Extension Abilities

Workspace and GitHub coding abilities live in the data-machine-code extension plugin. Data Machine core no longer registers the old workspace, GitHub issue, or GitHub repository ability names.

Handler Execution (8 abilities)

AbilityDescriptionLocation
datamachine/fetch-rssFetch items from RSS/Atom feedsinc/Abilities/Fetch/FetchRssAbility.php
datamachine/fetch-filesProcess uploaded filesinc/Abilities/Fetch/FetchFilesAbility.php
datamachine/fetch-wordpress-apiFetch posts from WordPress REST APIinc/Abilities/Fetch/FetchWordPressApiAbility.php
datamachine/fetch-wordpress-mediaQuery WordPress media libraryinc/Abilities/Fetch/FetchWordPressMediaAbility.php
datamachine/get-wordpress-postRetrieve single WordPress post by ID/URLinc/Abilities/Fetch/GetWordPressPostAbility.php
datamachine/query-wordpress-postsQuery WordPress posts with filtersinc/Abilities/Fetch/QueryWordPressPostsAbility.php
datamachine/publish-wordpressCreate WordPress postsinc/Abilities/Publish/PublishWordPressAbility.php
datamachine/update-wordpressUpdate existing WordPress postsinc/Abilities/Update/UpdateWordPressAbility.php

Duplicate Check (2 abilities)

AbilityDescriptionLocation
datamachine/check-duplicateCheck if similar content exists as published post or in queueinc/Abilities/DuplicateCheck/DuplicateCheckAbility.php
datamachine/titles-matchCompare two titles for semantic equivalence using similarity engineinc/Abilities/DuplicateCheck/DuplicateCheckAbility.php

Extensions: datamachine/check-duplicate runs extension strategies before core’s generic matching via the datamachine_duplicate_strategies filter. See Duplicate Detection Filters for the strategy contract and registration example.

Post Query (2 abilities)

AbilityDescriptionLocation
datamachine/query-postsFind posts created by Data Machine, filtered by handler/flow/pipelineinc/Abilities/PostQueryAbilities.php
datamachine/list-postsList Data Machine posts with combinable filtersinc/Abilities/PostQueryAbilities.php

Content / Block Editing (4 abilities)

AbilityDescriptionLocation
datamachine/upsert-postCreate or update a post. AI/chat tool calls default to markdown authoring; raw ability/API callers that omit content_format keep the legacy block-markup default.inc/Abilities/Content/UpsertPostAbility.php
datamachine/get-post-blocksGet Gutenberg blocks from a postinc/Abilities/Content/GetPostBlocksAbility.php
datamachine/edit-post-blocksUpdate Gutenberg blocks in a postinc/Abilities/Content/EditPostBlocksAbility.php
datamachine/replace-post-blocksReplace specific blocks in a postinc/Abilities/Content/ReplacePostBlocksAbility.php

Extensions: datamachine/check-duplicate runs extension strategies before core’s generic matching via the datamachine_duplicate_strategies filter. See Duplicate Detection Filters for the strategy contract and registration example.

Extensions: datamachine/check-duplicate runs extension strategies before core’s generic matching via the datamachine_duplicate_strategies filter. See Duplicate Detection Filters for the strategy contract and registration example.

Media (7 abilities)

AbilityDescriptionLocation
datamachine/generate-alt-textQueue system agent generation of alt text for imagesinc/Abilities/Media/AltTextAbilities.php
datamachine/diagnose-alt-textReport alt text coverage for image attachmentsinc/Abilities/Media/AltTextAbilities.php
datamachine/generate-imageGenerate images using AI models via Replicate APIinc/Abilities/Media/ImageGenerationAbilities.php
datamachine/upload-mediaUpload or fetch a media file (image/video), store in repositoryinc/Abilities/Media/MediaAbilities.php
datamachine/validate-mediaValidate a media file against platform-specific constraintsinc/Abilities/Media/MediaAbilities.php
datamachine/video-metadataExtract video metadata (duration, resolution, codec) via ffprobeinc/Abilities/Media/MediaAbilities.php
datamachine/render-image-templateGenerate branded graphics from registered GD templatesinc/Abilities/Media/ImageTemplateAbilities.php

Image Templates (1 ability)

AbilityDescriptionLocation
datamachine/list-image-templatesList all registered image generation templatesinc/Abilities/Media/ImageTemplateAbilities.php

Image Optimization (2 abilities)

AbilityDescriptionLocation
datamachine/diagnose-imagesScan media library for oversized images, missing WebP, missing thumbnailsinc/Abilities/Media/ImageOptimizationAbilities.php
datamachine/optimize-imagesCompress oversized images and generate WebP variantsinc/Abilities/Media/ImageOptimizationAbilities.php

Internal Linking (7 abilities)

AbilityDescriptionLocation
datamachine/internal-linkingQueue system agent insertion of semantic internal linksinc/Abilities/InternalLinkingAbilities.php
datamachine/diagnose-internal-linksReport internal link coverage across published postsinc/Abilities/InternalLinkingAbilities.php
datamachine/audit-internal-linksScan post content for internal links, build link graphinc/Abilities/InternalLinkingAbilities.php
datamachine/get-orphaned-postsReturn posts with zero inbound internal linksinc/Abilities/InternalLinkingAbilities.php
datamachine/get-backlinksReturn posts that link to a given postinc/Abilities/InternalLinkingAbilities.php
datamachine/check-broken-linksHTTP HEAD check links to find broken URLsinc/Abilities/InternalLinkingAbilities.php
datamachine/link-opportunitiesRank candidate internal links from search analytics and the cached link graphinc/Abilities/InternalLinkingAbilities.php

SEO — Meta Descriptions (2 abilities)

AbilityDescriptionLocation
datamachine/generate-meta-descriptionQueue system agent generation of meta descriptionsinc/Abilities/SEO/MetaDescriptionAbilities.php
datamachine/diagnose-meta-descriptionsReport post excerpt (meta description) coverageinc/Abilities/SEO/MetaDescriptionAbilities.php

SEO — IndexNow (4 abilities)

AbilityDescriptionLocation
datamachine/indexnow-submitSubmit URLs to IndexNow for instant search engine indexinginc/Abilities/SEO/IndexNowAbilities.php
datamachine/indexnow-statusGet IndexNow integration status (enabled, API key, endpoint)inc/Abilities/SEO/IndexNowAbilities.php
datamachine/indexnow-generate-keyGenerate a new IndexNow API keyinc/Abilities/SEO/IndexNowAbilities.php
datamachine/indexnow-verify-keyVerify that the IndexNow key file is accessibleinc/Abilities/SEO/IndexNowAbilities.php

Analytics (4 abilities)

AbilityDescriptionLocation
datamachine/bing-webmasterFetch search analytics from Bing Webmaster Tools APIinc/Abilities/Analytics/BingWebmasterAbilities.php
datamachine/google-search-consoleFetch search analytics from Google Search Console APIinc/Abilities/Analytics/GoogleSearchConsoleAbilities.php
datamachine/google-analyticsFetch visitor analytics from Google Analytics (GA4) Data APIinc/Abilities/Analytics/GoogleAnalyticsAbilities.php
datamachine/pagespeedRun Lighthouse audits via PageSpeed Insights APIinc/Abilities/Analytics/PageSpeedAbilities.php

Taxonomy (5 abilities)

AbilityDescriptionLocation
datamachine/get-taxonomy-termsList taxonomy termsinc/Abilities/Taxonomy/GetTaxonomyTermsAbility.php
datamachine/create-taxonomy-termCreate a taxonomy terminc/Abilities/Taxonomy/CreateTaxonomyTermAbility.php
datamachine/update-taxonomy-termUpdate a taxonomy terminc/Abilities/Taxonomy/UpdateTaxonomyTermAbility.php
datamachine/delete-taxonomy-termDelete a taxonomy terminc/Abilities/Taxonomy/DeleteTaxonomyTermAbility.php
datamachine/resolve-termResolve a term by name or sluginc/Abilities/Taxonomy/ResolveTermAbility.php

Settings (7 abilities)

AbilityDescriptionLocation
datamachine/get-settingsGet plugin settings including AI settings and masked API keysinc/Abilities/SettingsAbilities.php
datamachine/update-settingsPartial update of plugin settingsinc/Abilities/SettingsAbilities.php
datamachine/get-scheduling-intervalsGet available scheduling intervalsinc/Abilities/SettingsAbilities.php
datamachine/get-tool-configGet AI tool configuration with fields and current valuesinc/Abilities/SettingsAbilities.php
datamachine/save-tool-configSave AI tool configurationinc/Abilities/SettingsAbilities.php
datamachine/get-handler-defaultsGet handler default settings grouped by step typeinc/Abilities/SettingsAbilities.php
datamachine/update-handler-defaultsUpdate defaults for a specific handlerinc/Abilities/SettingsAbilities.php

Authentication (3 abilities)

AbilityDescriptionLocation
datamachine/get-auth-statusGet OAuth connection statusinc/Abilities/AuthAbilities.php
datamachine/disconnect-authDisconnect OAuth providerinc/Abilities/AuthAbilities.php
datamachine/save-auth-configSave OAuth API configurationinc/Abilities/AuthAbilities.php

Logging (5 abilities)

AbilityDescriptionLocation
datamachine/write-to-logWrite log entry with level routinginc/Abilities/LogAbilities.php
datamachine/clear-logsClear logs by agent typeinc/Abilities/LogAbilities.php
datamachine/read-logsRead logs with filtering and paginationinc/Abilities/LogAbilities.php
datamachine/get-log-metadataGet log entry counts and time rangeinc/Abilities/LogAbilities.php
datamachine/read-debug-logRead PHP debug.log entriesinc/Abilities/LogAbilities.php

Local Search (1 ability)

AbilityDescriptionLocation
datamachine/local-searchSearch WordPress site for posts by title or contentinc/Abilities/LocalSearchAbilities.php

Handler Discovery (5 abilities)

AbilityDescriptionLocation
datamachine/get-handlersList available handlers, or get single by sluginc/Abilities/HandlerAbilities.php
datamachine/validate-handlerValidate handler configurationinc/Abilities/HandlerAbilities.php
datamachine/get-handler-config-fieldsGet handler configuration fieldsinc/Abilities/HandlerAbilities.php
datamachine/apply-handler-defaultsApply default settings to handlerinc/Abilities/HandlerAbilities.php
datamachine/get-handler-site-defaultsGet site-wide handler defaultsinc/Abilities/HandlerAbilities.php

Step Types (2 abilities)

AbilityDescriptionLocation
datamachine/get-step-typesList available step types, or get single by sluginc/Abilities/StepTypeAbilities.php
datamachine/validate-step-typeValidate step type configurationinc/Abilities/StepTypeAbilities.php

Processed Items (6 abilities)

AbilityDescriptionLocation
datamachine/clear-processed-itemsClear processed items for flow (resets deduplication)inc/Abilities/ProcessedItemsAbilities.php
datamachine/check-processed-itemCheck if item was processedinc/Abilities/ProcessedItemsAbilities.php
datamachine/has-processed-historyCheck if flow has processed historyinc/Abilities/ProcessedItemsAbilities.php
datamachine/processed-items-get-processed-atGet last-processed Unix timestamp for an item (or null)inc/Abilities/ProcessedItemsAbilities.php
datamachine/processed-items-find-staleGiven candidates, return those older than N daysinc/Abilities/ProcessedItemsAbilities.php
datamachine/processed-items-find-never-processedGiven candidates, return those never processedinc/Abilities/ProcessedItemsAbilities.php

Agent Ping (1 ability)

AbilityDescriptionLocation
datamachine/send-pingSend agent ping notificationinc/Abilities/AgentPing/SendPingAbility.php

System Infrastructure (3 abilities)

AbilityDescriptionLocation
datamachine/generate-session-titleGenerate AI-powered title for chat sessioninc/Abilities/SystemAbilities.php
datamachine/system-health-checkUnified health diagnostics for Data Machine and extensionsinc/Abilities/SystemAbilities.php
datamachine/run-taskManually trigger a registered system task for immediate executioninc/Abilities/SystemAbilities.php

Category Registration

content_format is the caller’s authoring/source format (markdown, html, or blocks). It is distinct from the stored post_content format, which is chosen per post type by datamachine_post_content_format. Normal AI-authored prose should be markdown; only set content_format when the caller intentionally supplies HTML or serialized block markup.

php
wp_register_ability_category(
    'datamachine-flow',
    array(
        'label' => 'Flow',
        'description' => 'Flow CRUD, scheduling, queue management, and webhook triggers.',
    )
);

The block editing abilities are storage-format aware. They read the post type’s canonical stored format through DataMachineCoreContentContentFormat, convert to block markup for the edit operation, then convert the result back before writing.

Permission Model

Data Machine registers multiple ability categories via wp_register_ability_category() on the wp_abilities_api_categories_init hook. Category slugs use the datamachine-{domain} format (e.g. datamachine-content, datamachine-flow, datamachine-pipeline):

php
// Standard permission check
PermissionHelper::can_manage(); // WP-CLI always returns true; web requires manage_options

// Multi-agent scoped permission check
PermissionHelper::can_access_agent($agent_id);
PermissionHelper::owns_resource($resource_user_id);
PermissionHelper::resolve_scoped_agent_id($params);
PermissionHelper::resolve_scoped_user_id($params);

Architecture

Delegation Pattern

See inc/Abilities/AbilityCategories.php for the full list of registered categories.

REST API Endpoint → Ability → Database / WordPress API
CLI Command → Ability → Database / WordPress API
Chat Tool → Ability → Database / WordPress API

Facade Pattern

All abilities support both WordPress admin and WP-CLI contexts via the shared PermissionHelper:

  • inc/Abilities/ChatAbilities.phpinc/Abilities/Chat/CreateChatSessionAbility.php, etc.
  • inc/Abilities/EngineAbilities.phpinc/Abilities/Engine/RunFlowAbility.php, etc.
  • Flow abilities are registered from inc/Abilities/Flow/CreateFlowAbility.php, inc/Abilities/Flow/QueueAbility.php, inc/Abilities/Flow/WebhookTriggerAbility.php, etc.

Ability Registration

REST API endpoints, CLI commands, and Chat tools delegate to abilities for business logic. Abilities are the canonical, public-facing primitive; implementation classes below an ability are internal details.

php
public function register(): void {
    add_action( 'wp_abilities_api_init', array( $this, 'register_abilities' ) );
}

Testing

Several top-level ability classes serve as facades that instantiate sub-ability classes from subdirectories; other domains are registered directly from their subdirectory classes:

  • AuthAbilitiesTest.php – Authentication abilities
  • FileAbilitiesTest.php – File management abilities
  • FlowAbilitiesTest.php – Flow CRUD abilities
  • FlowStepAbilitiesTest.php – Flow step abilities
  • JobAbilitiesTest.php – Job execution abilities
  • LogAbilitiesTest.php – Logging abilities
  • PipelineAbilitiesTest.php – Pipeline CRUD abilities
  • PipelineStepAbilitiesTest.php – Pipeline step abilities
  • PostQueryAbilitiesTest.php – Post query abilities
  • ProcessedItemsAbilitiesTest.php – Processed items abilities
  • SettingsAbilitiesTest.php – Settings abilities

WP-CLI Integration

Each abilities class registers abilities on the wp_abilities_api_init hook:

Post Tracking

Unit tests in tests/Unit/Abilities/ verify ability registration, schema validation, permission checks, and execution logic:

CLI commands execute abilities directly. See individual command files in inc/Cli/Commands/ for available commands.

  • _datamachine_post_handler: Handler slug that created the post
  • _datamachine_post_flow_id: Flow ID associated with the post
  • _datamachine_post_pipeline_id: Pipeline ID associated with the post

The PostTracking class in inc/Core/WordPress/PostTracking.php provides post tracking functionality for handlers creating WordPress posts.

php
use DataMachineCoreWordPressPostTracking;

// After creating a post
$this->storePostTrackingMeta($post_id, $handler_config);