integer('milestoneId')->description('ID of the milestone to get goals for.') ->required(); } public function name(): string { return 'getGoalsByMilestone'; } public function description(): string { return 'Gets all goals associated with a specific milestone.'; } /** * Handle the tool request. */ public function handle(array $arguments): ToolResult { $milestoneId = (int) ($arguments['milestoneId'] ?? 0); $goals = $this->goalcanvasService->getGoalsByMilestone($milestoneId); if (empty($goals)) { return ToolResult::text("No goals found for milestone ID: {$milestoneId}"); } $response = "## Goals for Milestone ID: {$milestoneId}\n"; foreach ($goals as $goal) { $result = [ 'id' => $goal['id'], 'title' => Str::sanitizeForLLM($goal['title']), 'description' => Str::sanitizeForLLM($goal['description']), 'startValue' => $goal['startValue'], 'currentValue' => $goal['currentValue'], 'endValue' => $goal['endValue'], 'metricType' => $goal['metricType'], 'canvasId' => $goal['canvasId'], 'startDate' => $goal['startDate'], 'endDate' => $goal['endDate'], 'status' => $goal['status'], ]; $response .= Str::toMarkdown($result)."\n"; } return ToolResult::text($response); } }