string('module')->description('Module type (ticket, project, goal, etc.).') ->required() ->integer('entityId')->description('ID of the entity to get comments for.') ->required() ->integer('commentOrder')->description('Order of comments (0 = newest first, 1 = oldest first).'); } public function name(): string { return 'getComments'; } public function description(): string { return 'Gets all comments for a specific entity.'; } /** * Handle the tool request. */ public function handle(array $arguments): ToolResult { $module = $arguments['module']; $entityId = (int) ($arguments['entityId'] ?? 0); $commentOrder = (int) ($arguments['commentOrder'] ?? 0); $comments = $this->commentsService->getComments($module, $entityId, $commentOrder); if (empty($comments)) { return ToolResult::text("No comments found for {$module} ID: {$entityId}"); } $response = "## Comments for {$module} #{$entityId}\n"; foreach ($comments as $comment) { $result = [ 'id' => $comment['id'], 'text' => Str::sanitizeForLLM($comment['text']), 'date' => $comment['date'], 'userId' => $comment['userId'], 'author' => $comment['firstname'].' '.$comment['lastname'], 'status' => $comment['status'] ?: 'None', ]; $response .= Str::toMarkdown($result)."\n"; } return ToolResult::text($response); } }