Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Abilities/functions-ability-dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function wp_agent_run_runtime_package( array $input ) {
$ability_name = defined( 'AgentsAPI\\AI\\AGENTS_RUN_RUNTIME_PACKAGE_ABILITY' )
? constant( 'AgentsAPI\\AI\\AGENTS_RUN_RUNTIME_PACKAGE_ABILITY' )
: 'agents/run-runtime-package';
if ( function_exists( 'AgentsAPI\\AI\\agents_register_runtime_package_run_abilities' ) ) {
AgentsAPI\AI\agents_register_runtime_package_run_abilities();
}

$normalize_result = static function ( mixed $result ) {
if ( $result instanceof WP_Error ) {
return $result;
Expand Down
13 changes: 13 additions & 0 deletions tests/runtime-package-run-contract-smoke.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,19 @@ static function ( $handler, WP_Agent_Runtime_Package_Run_Request $handler_reques
) : null;
agents_api_smoke_assert_equals( false, is_wp_error( $late_dispatch ), 'late-resolved ability executes through the canonical ability object', $failures, $passes );
agents_api_smoke_assert_equals( 'late-load', is_array( $late_dispatch ) ? $late_dispatch['result']['workflow_id'] ?? '' : '', 'late-resolved ability uses the runtime package handler filter', $failures, $passes );

if ( $registry instanceof WP_Abilities_Registry ) {
$registry->reset_registered_for_smoke();
}

$helper_dispatch = wp_agent_run_runtime_package(
array(
'package' => array( 'slug' => 'site-builder' ),
'workflow' => array( 'id' => 'helper-late-load' ),
)
);
agents_api_smoke_assert_equals( false, is_wp_error( $helper_dispatch ), 'runtime package helper resolves the ability after abilities init already fired', $failures, $passes );
agents_api_smoke_assert_equals( 'helper-late-load', is_array( $helper_dispatch ) ? $helper_dispatch['result']['workflow_id'] ?? '' : '', 'runtime package helper dispatches through the canonical ability', $failures, $passes );
$GLOBALS['__agents_api_smoke_actions']['wp_agent_runtime_package_run_handler'] = array();

echo "\n[1] Request validates package and workflow selectors:\n";
Expand Down