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
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"agents-api.php"
],
"classmap": [
"src/Registry/class-wp-agent.php",
"src/Packages/"
"src/"
]
},
"suggest": {
Expand Down
13 changes: 12 additions & 1 deletion tests/composer-autoload-smoke.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,20 @@
exit( 1 );
}

$outcome_file = $loader->findFile( 'AgentsAPI\\AI\\WP_Agent_Run_Outcome' );
if ( ! is_string( $outcome_file ) || ! str_ends_with( str_replace( '\\', '/', $outcome_file ), '/src/Runtime/class-wp-agent-run-outcome.php' ) ) {
fwrite( STDERR, "FAIL: Composer classmap does not expose WP_Agent_Run_Outcome.\n" );
exit( 1 );
}

if ( class_exists( 'WP_Agent_Package', false ) ) {
fwrite( STDERR, "FAIL: Composer autoload eagerly loaded WP_Agent_Package outside WordPress.\n" );
exit( 1 );
}

echo "PASS: Composer autoload returns without WordPress and exposes package classmaps lazily.\n";
if ( class_exists( 'AgentsAPI\\AI\\WP_Agent_Run_Outcome', false ) ) {
fwrite( STDERR, "FAIL: Composer autoload eagerly loaded WP_Agent_Run_Outcome outside WordPress.\n" );
exit( 1 );
}

echo "PASS: Composer autoload returns without WordPress and exposes public classmaps lazily.\n";
36 changes: 36 additions & 0 deletions tests/fixtures/phpstan-consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
* @package AgentsAPI\Tests
*/

use AgentsAPI\AI\Tools\WP_Agent_Tool_Executor;
use AgentsAPI\AI\WP_Agent_Conversation_Completion_Policy;
use AgentsAPI\AI\WP_Agent_Run_Outcome;
use AgentsAPI\AI\WP_Agent_Runtime_Tool_Request;
use AgentsAPI\AI\WP_Agent_Transcript_Persister;

/**
* Exercise package types without loading the WordPress runtime bootstrap.
*
Expand All @@ -21,3 +27,33 @@ function agents_api_phpstan_consume_package( WP_Agent_Package $package ): array
WP_Agent_Package_Artifact_Hasher::hash( array() ),
);
}

/**
* Exercise conversation/runtime contracts from a Composer consumer.
*
* @param WP_Agent_Conversation_Completion_Policy $policy Completion policy.
* @param WP_Agent_Transcript_Persister $persister Transcript persister.
* @param WP_Agent_Tool_Executor $executor Tool executor.
* @return array<int,mixed>
*/
function agents_api_phpstan_consume_runtime(
WP_Agent_Conversation_Completion_Policy $policy,
WP_Agent_Transcript_Persister $persister,
WP_Agent_Tool_Executor $executor
): array {
return array(
$policy,
$persister,
$executor,
WP_Agent_Run_Outcome::normalize( null, array( 'completed' => true ) ),
WP_Agent_Runtime_Tool_Request::normalize(
array(
'id' => 'request-1',
'tool_call_id' => 'call-1',
'tool_name' => 'example/tool',
'parameters' => array(),
'status' => WP_Agent_Runtime_Tool_Request::STATUS_PENDING,
)
),
);
}