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: 87

Registered Abilities

Pipeline Management (7 abilities)

AbilityDescriptionLocation
datamachine/get-pipelinesList pipelines with pagination, or get single by IDPipelineAbilities.php
datamachine/create-pipelineCreate new pipelinePipelineAbilities.php
datamachine/update-pipelineUpdate pipeline propertiesPipelineAbilities.php
datamachine/delete-pipelineDelete pipeline and associated flowsPipelineAbilities.php
datamachine/duplicate-pipelineDuplicate pipeline with flowsPipelineAbilities.php
datamachine/import-pipelinesImport pipelines from JSONPipelineAbilities.php
datamachine/export-pipelinesExport pipelines to JSONPipelineAbilities.php

Pipeline Steps (5 abilities)

AbilityDescriptionLocation
datamachine/get-pipeline-stepsList steps for a pipeline, or get single by IDPipelineStepAbilities.php
datamachine/add-pipeline-stepAdd step to pipelinePipelineStepAbilities.php
datamachine/update-pipeline-stepUpdate pipeline step configPipelineStepAbilities.php
datamachine/delete-pipeline-stepRemove step from pipelinePipelineStepAbilities.php
datamachine/reorder-pipeline-stepsReorder pipeline stepsPipelineStepAbilities.php

Flow Management (5 abilities)

AbilityDescriptionLocation
datamachine/create-flowCreate new flow from pipelineFlowAbilities.php
datamachine/get-flowsList flows with filtering, or get single by IDFlowAbilities.php
datamachine/update-flowUpdate flow propertiesFlowAbilities.php
datamachine/delete-flowDelete flow and associated jobsFlowAbilities.php
datamachine/duplicate-flowDuplicate flow within pipelineFlowAbilities.php

Flow Steps (3 abilities)

AbilityDescriptionLocation
datamachine/get-flow-stepsList steps for a flow, or get single by IDFlowStepAbilities.php
datamachine/update-flow-stepUpdate flow step configFlowStepAbilities.php
datamachine/configure-flow-stepsBulk configure flow stepsFlowStepAbilities.php

Job Execution (6 abilities)

AbilityDescriptionLocation
datamachine/get-jobsList jobs with filtering, or get single by IDJobAbilities.php
datamachine/delete-jobsDelete jobs by criteriaJobAbilities.php
datamachine/execute-workflowExecute workflowJobAbilities.php
datamachine/get-flow-healthGet flow health metricsJobAbilities.php
datamachine/get-problem-flowsList flows exceeding failure thresholdJobAbilities.php
datamachine/get-jobs-summaryGet job status summary countsJobAbilities.php

File Management (5 abilities)

AbilityDescriptionLocation
datamachine/list-filesList files for a flowFileAbilities.php
datamachine/get-fileGet single file detailsFileAbilities.php
datamachine/delete-fileDelete specific fileFileAbilities.php
datamachine/cleanup-filesClean up orphaned filesFileAbilities.php
datamachine/upload-fileUpload file to flowFileAbilities.php

Processed Items (3 abilities)

AbilityDescriptionLocation
datamachine/clear-processed-itemsClear processed items for flowProcessedItemsAbilities.php
datamachine/check-processed-itemCheck if item was processedProcessedItemsAbilities.php
datamachine/has-processed-historyCheck if flow has processed historyProcessedItemsAbilities.php

Settings (7 abilities)

AbilityDescriptionLocation
datamachine/get-settingsGet plugin settingsSettingsAbilities.php
datamachine/update-settingsUpdate plugin settingsSettingsAbilities.php
datamachine/get-scheduling-intervalsGet available scheduling intervalsSettingsAbilities.php
datamachine/get-tool-configGet AI tool configurationSettingsAbilities.php
datamachine/save-tool-configSave AI tool configurationSettingsAbilities.php
datamachine/get-handler-defaultsGet handler default settingsSettingsAbilities.php
datamachine/update-handler-defaultsUpdate handler default settingsSettingsAbilities.php

Authentication (3 abilities)

AbilityDescriptionLocation
datamachine/get-auth-statusGet OAuth connection statusAuthAbilities.php
datamachine/disconnect-authDisconnect OAuth providerAuthAbilities.php
datamachine/save-auth-configSave OAuth API configurationAuthAbilities.php

Logging (6 abilities)

AbilityDescriptionLocation
datamachine/write-to-logWrite log entry with level routingLogAbilities.php
datamachine/clear-logsClear logs by agent typeLogAbilities.php
datamachine/read-logsRead logs with filteringLogAbilities.php
datamachine/get-log-metadataGet log file metadataLogAbilities.php
datamachine/set-log-levelSet logging levelLogAbilities.php
datamachine/get-log-levelGet current logging levelLogAbilities.php

Post Query (1 ability)

AbilityDescriptionLocation
datamachine/query-postsQuery posts by handler, flow, or pipelinePostQueryAbilities.php

Handler Discovery (5 abilities)

AbilityDescriptionLocation
datamachine/get-handlersList available handlers, or get single by slugHandlerAbilities.php
datamachine/validate-handlerValidate handler configurationHandlerAbilities.php
datamachine/get-handler-config-fieldsGet handler configuration fieldsHandlerAbilities.php
datamachine/apply-handler-defaultsApply default settings to handlerHandlerAbilities.php
datamachine/get-handler-site-defaultsGet site-wide handler defaultsHandlerAbilities.php

Step Types (2 abilities)

AbilityDescriptionLocation
datamachine/get-step-typesList available step types, or get single by slugStepTypeAbilities.php
datamachine/validate-step-typeValidate step type configurationStepTypeAbilities.php

Local Search (1 ability)

AbilityDescriptionLocation
datamachine/local-searchSearch WordPress site for posts by title or contentLocalSearchAbilities.php

Taxonomy (5 abilities)

AbilityDescriptionLocation
datamachine/get-taxonomy-termsList taxonomy termsTaxonomyAbilities.php
datamachine/create-taxonomy-termCreate a taxonomy termTaxonomyAbilities.php
datamachine/update-taxonomy-termUpdate a taxonomy termTaxonomyAbilities.php
datamachine/delete-taxonomy-termDelete a taxonomy termTaxonomyAbilities.php
datamachine/resolve-termResolve a term by name or slugTaxonomyAbilities.php

Queue Management (8 abilities)

AbilityDescriptionLocation
datamachine/queue-listList queue entriesFlowAbilities.php
datamachine/queue-addAdd item to queueFlowAbilities.php
datamachine/queue-removeRemove item from queueFlowAbilities.php
datamachine/queue-moveReorder queue itemFlowAbilities.php
datamachine/queue-clearClear queueFlowAbilities.php
datamachine/queue-updateUpdate queue itemFlowAbilities.php
datamachine/queue-settingsGet/set queue settingsFlowAbilities.php
datamachine/queue-validateValidate queue configurationFlowAbilities.php

Media (2 abilities)

AbilityDescriptionLocation
datamachine/generate-alt-textGenerate alt text for mediaAltTextAbilities.php
datamachine/diagnose-alt-textDiagnose alt text issuesAltTextAbilities.php

Agent Ping (1 ability)

AbilityDescriptionLocation
datamachine/send-pingSend agent ping notificationAgentPingAbilities.php

Job Recovery (1 ability)

AbilityDescriptionLocation
datamachine/recover-stuck-jobsRecover jobs stuck in processing stateRecoverStuckJobsAbility.php

Flow Steps — Additional (1 ability)

AbilityDescriptionLocation
datamachine/validate-flow-steps-configValidate flow steps configurationFlowStepAbilities.php

System Infrastructure (2 abilities)

AbilityDescriptionLocation
datamachine/generate-session-titleGenerate descriptive titles for chat sessionsSystemAbilities.php
datamachine/system-health-checkRun system health diagnosticsSystemAbilities.php

Handler Execution (8 abilities)

AbilityDescriptionLocation
datamachine/fetch-redditFetch posts from Reddit APIFetchRedditAbility.php
datamachine/fetch-rssFetch items from RSS/Atom feedsFetchRssAbility.php
datamachine/fetch-filesProcess uploaded filesFetchFilesAbility.php
datamachine/fetch-wordpress-apiFetch posts from WordPress REST APIFetchWordPressApiAbility.php
datamachine/fetch-wordpress-mediaQuery WordPress media libraryFetchWordPressMediaAbility.php
datamachine/get-wordpress-postRetrieve single WordPress post by ID/URLGetWordPressPostAbility.php
datamachine/query-wordpress-postsQuery WordPress posts with filtersQueryWordPressPostsAbility.php
datamachine/publish-wordpressCreate WordPress postsPublishWordPressAbility.php
datamachine/update-wordpressUpdate existing WordPress postsUpdateWordPressAbility.php

Category Registration

The datamachine category is registered via wp_register_ability_category() on the wp_abilities_api_categories_init hook:

php
wp_register_ability_category(
    'datamachine',
    array(
        'label' => 'Data Machine',
        'description' => 'Data Machine flow and pipeline operations',
    )
);

Permission Model

All abilities support both WordPress admin and WP-CLI contexts:

php
'permission_callback' => function () {
    if ( defined( 'WP_CLI' ) && WP_CLI ) {
        return true;
    }
    return current_user_can( 'manage_options' );
}

Architecture

Delegation Pattern

REST API endpoints, CLI commands, and Chat tools delegate to abilities for business logic. Abilities are the canonical, public-facing primitive; service classes are considered an internal implementation detail and are being phased out as abilities become fully self-contained.

REST API Endpoint → Ability → (Service layer used during migration) → Database
CLI Command → Ability → (Service layer used during migration) → Database
Chat Tool → Ability → (Service layer used during migration) → Database

Note: many ability implementations are already self-contained and do not call service managers. Where services remain, they are transitional and will be migrated into abilities per the migration plan.

Analytics Abilities (2 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

Bing Webmaster (datamachine/bing-webmaster):

  • Actions: query_stats, traffic_stats, page_stats, crawl_stats
  • Requires API key configuration

Google Search Console (datamachine/google-search-console):

  • Actions: search_analytics, sitemaps, url_inspection
  • Requires OAuth configuration

Content Abilities (3 abilities)

AbilityDescriptionLocation
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

Internal Linking Abilities (2 abilities)

AbilityDescriptionLocation
datamachine/internal-linkingBuild internal links between postsinc/Abilities/InternalLinkingAbilities.php
datamachine/diagnose-internal-linksAnalyze and report broken/missing internal linksinc/Abilities/InternalLinkingAbilities.php

Media Abilities (1 ability)

AbilityDescriptionLocation
datamachine/generate-imageGenerate images using AIinc/Abilities/Media/ImageGenerationAbilities.php

System Abilities (1 ability)

AbilityDescriptionLocation
datamachine/create-github-issueCreate GitHub issues programmaticallyinc/Abilities/SystemAbilities.php

Ability Registration

Each abilities class registers abilities on the wp_abilities_api_init hook:

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

Testing

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

  • 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

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

Post Tracking

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

Meta Keys:

  • _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

Usage:

php
use PostTrackingTrait;

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