Class: RailsAiContext::Tools::GetMailers

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/rails_ai_context/tools/get_mailers.rb

Constant Summary

Constants inherited from BaseTool

BaseTool::DEFAULT_SESSION, BaseTool::MAX_SESSIONS, BaseTool::MAX_SESSION_ID_LENGTH, BaseTool::SESSION_CONTEXT, BaseTool::SHARED_CACHE

Class Method Summary collapse

Methods inherited from BaseTool

abstract!, abstract?, api_only_app?, api_only_note, cache_key, cached_context, config, current_session, #dedupe_put_patch_routes, detail_param?, error_response, evict_oldest_sessions, extract_method_source_from_file, extract_method_source_from_string, find_closest_match, fuzzy_find_key, guide_row, inherited, introspection_warnings_note, invalid_detail_note, normalize_detail, not_found_response, paginate, rails_app, rails_env_name, registered_tools, reset_all_caches!, reset_cache!, session_from, session_params, session_queries, session_record, session_reset!, static_tier_banner, static_tier_refusal, text_response, touch_session, unavailable_note, with_session, with_session_for

Methods included from SectionFetch

#fetch_section, usable?

Class Method Details

.call(mailer: nil, offset: 0, limit: nil, server_context: nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rails_ai_context/tools/get_mailers.rb', line 37

def self.call(mailer: nil, offset: 0, limit: nil, server_context: nil)
  fetch_section(:jobs, subject: "Mailer introspection") do |jobs|
    mailers = jobs[:mailers] || []

    if mailer
      names = mailers.map { |m| m[:name] }
      match = find_closest_match(mailer, names)
      return not_found_response("Mailer", mailer, names, recovery_tool: "omit `mailer` for all mailers") unless match

      mailers = mailers.select { |m| m[:name] == match }
    end

    page = paginate(mailers, offset: offset, limit: limit, default_limit: 50)

    lines = [ "# Mailers" ]
    if page[:items].any?
      page[:items].each do |m|
        lines << "" << "## #{m[:name]}"
        # Configured at boot, so the static tier has no value to give.
        lines << "- **Delivery method:** #{m[:delivery_method]}" if m[:delivery_method].present?
        lines << "- **Actions:** #{Array(m[:actions]).join(', ')}"
      end
    else
      lines << "_No mailers found#{" matching '#{mailer}'" if mailer}._"
    end

    lines << "" << page[:hint] unless page[:hint].empty?
    text_response(lines.join("\n"))
  end
end