1. Go to this page and download the library: Download promptphp/intercept-support 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 Laravel\Ai\PendingStep;
use Laravel\Ai\Prompts\AgentPrompt;
use PromptPHP\Intercept\Support\Concerns\ScansApprovalDecisions;
use PromptPHP\Intercept\Support\Contracts\InspectsApprovalDecisions;
class ExampleMiddleware implements InspectsApprovalDecisions
{
use ScansApprovalDecisions;
public function handle(PendingStep $step, Closure $next): mixed
{
return $next($step);
}
public function inspectApprovalDecisions(AgentPrompt $prompt): void
{
foreach ($this->approvalDecisionSegments($prompt->approvalDecisions) as $segment) {
// $segment->toolCallId, $segment->field, $segment->text
}
}
}
foreach ($this->pendingApprovalSegments($response->pendingApprovals) as $segment) {
// $segment->toolCallId is the pending approval ID
}