Module: OmniAI::Tools::Browser::PageInspect::HtmlSummarizer

Defined in:
lib/omniai/tools/browser/page_inspect/html_summarizer.rb

Overview

Module to handle HTML formatting and summary generation for AI agents

Class Method Summary collapse

Class Method Details

.summarize_interactive_elements(doc) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/omniai/tools/browser/page_inspect/html_summarizer.rb', line 11

def summarize_interactive_elements(doc)
  title = doc.at_css("title")&.text || "Untitled Page"

  summary = "#{title}\n\n"

  # Primary focus: What can agents fill out?
  data_entry = FormSummarizer.summarize_data_entry_opportunities(doc)
  summary += data_entry unless data_entry.empty?

  # Secondary: What actions can agents take?
  primary_actions = ButtonSummarizer.summarize_primary_actions(doc)
  summary += primary_actions unless primary_actions.empty?

  # Tertiary: Key navigation (only if relevant)
  navigation = LinkSummarizer.summarize_key_navigation(doc)
  summary += navigation unless navigation.empty?

  # Fallback: If no data entry found, show form structure
  summary += FormSummarizer.summarize_form_structure(doc) if data_entry.empty?

  summary.strip
end