[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ai-client/ -> class-wp-ai-client-ability-function-resolver.php (summary)

WP AI Client: WP_AI_Client_Ability_Function_Resolver class

File Size: 232 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_AI_Client_Ability_Function_Resolver:: (7 methods):
  __construct()
  is_ability_call()
  execute_ability()
  has_ability_calls()
  execute_abilities()
  ability_name_to_function_name()
  function_name_to_ability_name()


Class: WP_AI_Client_Ability_Function_Resolver  - X-Ref

Resolves and executes WordPress Abilities API function calls from AI models.

This class must be instantiated with the specific abilities that the AI model
is allowed to execute, ensuring that only explicitly specified abilities can
be called. This prevents the model from executing arbitrary abilities.

__construct( ...$abilities )   X-Ref
Constructor.

param: WP_Ability|string ...$abilities The abilities that this resolver is allowed to execute.

is_ability_call( FunctionCall $call )   X-Ref
Checks if a function call is an ability call.

param: FunctionCall $call The function call to check.
return: bool True if the function call is an ability call, false otherwise.

execute_ability( FunctionCall $call )   X-Ref
Executes a WordPress ability from a function call.

Only abilities that were specified in the constructor are allowed to be
executed. If the ability is not in the allowed list, an error response
with code `ability_not_allowed` is returned.

param: FunctionCall $call The function call to execute.
return: FunctionResponse The response from executing the ability.

has_ability_calls( Message $message )   X-Ref
Checks if a message contains any ability function calls.

param: Message $message The message to check.
return: bool True if the message contains ability calls, false otherwise.

execute_abilities( Message $message )   X-Ref
Executes all ability function calls in a message.

param: Message $message The message containing function calls.
return: Message A new message with function responses.

ability_name_to_function_name( string $ability_name )   X-Ref
Converts an ability name to a function name.

Transforms "tec/create_event" to "wpab__tec__create_event".

param: string $ability_name The ability name to convert.
return: string The function name.

function_name_to_ability_name( string $function_name )   X-Ref
Converts a function name to an ability name.

Transforms "wpab__tec__create_event" to "tec/create_event".

param: string $function_name The function name to convert.
return: string The ability name.



Generated : Fri Jul 24 08:20:19 2026 Cross-referenced by PHPXref