$tools */ private function __construct(private ToolkitInterface $inner, private array $tools) {} /** * @param array $toolkits in the order the agent is to be handed them * @return list one per toolkit, in the same order */ public static function over(array $toolkits): array { $taken = []; $out = []; foreach ($toolkits as $toolkit) { $kept = []; $names = []; foreach ($toolkit->tools() as $tool) { if (!isset($taken[$tool->name()])) { $kept[] = $tool; $names[$tool->name()] = true; } } $taken += $names; $out[] = new self($toolkit, $kept); } return $out; } /** @return list */ public function tools(): array { return $this->tools; } public function guidelines(): string { return $this->tools === [] ? '' : $this->inner->guidelines(); } }