Capability API
A capability is a named AI endpoint that a third-party Ai3 extension
provides. Ai3 Core exposes a tagged DI compiler pass so that
capabilities register without code changes in ai3_core.
ZakAiEndpointInterface
Every capability must implement
\Wegewerk\:
interface ZakAiEndpointInterface
{
public function generate(
string $imagePath,
string $description,
string $language,
): string;
}
The generate() method receives the image path (may be empty), a
text prompt, and a language code. It must return the generated text.
Registering a capability
Tag your endpoint service with ai3.capability in your extension's
Configuration/. The compiler pass picks up the
$key, $title, and $endpoint constructor arguments
automatically:
MyVendor\MyAiExt\Endpoint\SummaryEndpoint:
tags:
- name: ai3.capability
arguments:
$key: 'my_ext_summary'
$title: 'Automatic summary'
$endpoint: '@MyVendor\MyAiExt\Endpoint\SummaryEndpoint'
use Wegewerk\Ai3Core\Api\ZakAiEndpointInterface;
final class SummaryEndpoint implements ZakAiEndpointInterface
{
public function generate(
string $imagePath,
string $description,
string $language,
): string {
// Call Zak_ai provider here.
return 'Generated summary …';
}
}
CapabilityRegistry
At runtime, all registered capabilities are available via
\Wegewerk\. It is a
SingletonInterface and can be injected via constructor:
use Wegewerk\Ai3Core\Service\CapabilityRegistry;
final class MyService
{
public function __construct(
private readonly CapabilityRegistry $capabilityRegistry,
) {}
public function run(string $capabilityKey): string
{
$capability = $this->capabilityRegistry
->getCapability($capabilityKey);
if ($capability === null) {
throw new \RuntimeException(
'Unknown capability: ' . $capabilityKey,
);
}
return $capability->endpoint->generate('', 'Hello', 'en');
}
}
TCA integration
To expose capability selection in a FormEngine field, use the provided
itemsProcFunc:
'capability' => [
'label' => 'AI capability',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'itemsProcFunc' =>
\Wegewerk\Ai3Core\FormEngine\CapabilityItemsProcFunc::class
. '->itemsProcFunc',
],
],
The items list is populated dynamically from the CapabilityRegistry
at render time.