'testing']); */ class StartSession { use Action; public function __construct( private AgentSessionService $sessionService, ) {} /** * @throws \InvalidArgumentException */ public function handle(string $agentType, ?string $planSlug, int $workspaceId, array $context = []): AgentSession { if ($agentType === '') { throw new \InvalidArgumentException('agent_type is required'); } $plan = null; if ($planSlug !== null && $planSlug !== '') { $plan = AgentPlan::where('slug', $planSlug)->first(); if (! $plan) { throw new \InvalidArgumentException("Plan not found: {$planSlug}"); } } return $this->sessionService->start($agentType, $plan, $workspaceId, $context); } }