ai_service = $ai_service; } public function name(): string { return 'get_page_content'; } public function description(): string { return 'Read the full current page content as rendered HTML. ' . 'Call this when the compact page outline in the system prompt is not detailed enough — ' . "for example to match the exact Tailwind classes of an existing section, to copy a section's structure, " . 'to plan a multi-section edit, or to verify what is currently on the page. ' . 'For single-block edits use replace_selected_blocks, for adding a single new section use add_blocks_to_page — ' . "they don't need this tool. Returns the rendered HTML of every top-level block in document order."; } public function input_schema(): array { return array( 'type' => 'object', 'properties' => new \stdClass(), ); } public function execute( array $input, array $context = array() ): array { $post_id = intval( $context['post_id'] ?? 0 ) ?: null; $live_content = $context['page_content'] ?? ''; if ( ! $post_id && empty( $live_content ) ) { return array( 'type' => 'error', 'message' => __( 'No current post ID available.', 'advanced-animation' ), ); } $result = $this->ai_service->get_page_content( $post_id, $live_content ); if ( is_wp_error( $result ) ) { return array( 'type' => 'error', 'message' => $result->get_error_message(), ); } return array( 'type' => 'page_content', 'format' => 'html', 'total_blocks' => $result['total_blocks'], 'returned_blocks' => $result['returned_blocks'], 'truncated' => false, 'content' => $result['content'], ); } }