$tools Tool name patterns; `*` is every tool policy allows. */ public function __construct( public readonly string $id, public readonly string $name, public readonly string $description = '', public readonly string $mode = self::PRIMARY, public readonly bool $hidden = false, public readonly string $instructions = '', public readonly array $tools = ['*'], public readonly int $maxSteps = 0, public readonly string $model = '', ) { } /** * Whether a tool name matches one of the agent's patterns. * * @since 0.1.0 * @param list $patterns */ public static function matches(string $tool, array $patterns): bool { foreach ($patterns as $pattern) { if ($pattern === '*' || $pattern === $tool || (str_ends_with($pattern, '*') && str_starts_with($tool, substr($pattern, 0, -1)))) { return true; } } return false; } /** * @since 0.1.0 * @return array */ public function toArray(): array { return [ 'id' => $this->id, 'name' => $this->name, 'description' => $this->description, 'mode' => $this->mode, 'hidden' => $this->hidden, 'tools' => $this->tools, 'max_steps' => $this->maxSteps, ]; } }