PHP code example of evolvex / laravel-agent-fabric
1. Go to this page and download the library: Download evolvex/laravel-agent-fabric library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Evolvex\AgentFabric\Agents\AgentBlueprint;
final class SupportAgent extends AgentBlueprint
{
public function name(): string { return 'support'; }
public function version(): string { return '2.0.0'; }
public function goal(): string { return 'Resolve customer support cases end-to-end.'; }
public function instructions(): string
{
return <<<'PROMPT'
Never claim an action succeeded without evidence.
Ask for clarification when tured_output'];
}
}
$result = AgentFabric::agent('support')
->tenant($tenant->id)
->actor($customer->id, $customer::class)
->simulate()
->ask('Refund order 551');
use Evolvex\AgentFabric\Tools\QueryTool;
use Evolvex\AgentFabric\Tools\CommandTool;
use Evolvex\AgentFabric\Tools\RemoteOperationTool;
final class FindOrder extends QueryTool
{
public function name(): string { return 'find_order'; }
public function description(): string { return 'Read one accessible order.'; }
public function risk(): ToolRisk { return ToolRisk::Read; }
public function inputSchema(): array
{
return [
'type' => 'object',
'properties' => ['order_id' => ['type' => 'string']],
'ToolResult::failure('Order not found.');
}
}
interface Connector
{
public function name(): string;
public function schema(): ConnectorSchema;
public function query(AgentContext $context, ConnectorQuery $query): ConnectorResult;
public function execute(AgentContext $context, ConnectorAction $action): ConnectorResult;
}
final class EcommercePack extends AbstractDomainPack
{
public function name(): string { return 'ecommerce'; }
public function domain(): string { return 'ecommerce'; }
public function register(PluginContext $context): void
{
$context->workflows->register(RefundWorkflow::class);
$context->agents->register('support', SupportAgent::class);
}
}