Class: Rubino::Tools::WebFetchTool

Inherits:
Base
  • Object
show all
Defined in:
lib/rubino/tools/webfetch_tool.rb

Overview

Tool for fetching web page content and converting to text/markdown.

Constant Summary collapse

MAX_BODY_SIZE =
100_000
TIMEOUT =
30

Instance Attribute Summary

Attributes inherited from Base

#cancel_token, #read_tracker, #stream_chunk

Instance Method Summary collapse

Methods inherited from Base

#cancellation_requested?, #emit_chunk, #risky?, #to_tool_definition, workspace_root, workspace_roots

Instance Method Details

#call(arguments) ⇒ Object



49
50
51
52
53
54
# File 'lib/rubino/tools/webfetch_tool.rb', line 49

def call(arguments)
  url = arguments["url"] || arguments[:url]
  format = arguments["format"] || arguments[:format] || "text"

  fetch_url(url, format: format)
end

#config_keyObject

Gated by ‘tools.web` (shared with websearch), not `tools.webfetch`.



18
19
20
# File 'lib/rubino/tools/webfetch_tool.rb', line 18

def config_key
  "web"
end

#descriptionObject



22
23
24
25
# File 'lib/rubino/tools/webfetch_tool.rb', line 22

def description
  "Fetch content from a URL and return it as text. " \
    "Useful for reading documentation, API references, and web pages."
end

#input_schemaObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rubino/tools/webfetch_tool.rb', line 27

def input_schema
  {
    type: "object",
    properties: {
      url: {
        type: "string",
        description: "The URL to fetch content from"
      },
      format: {
        type: "string",
        enum: %w[text html],
        description: "Output format: 'text' (default, strips HTML) or 'html' (raw)"
      }
    },
    required: %w[url]
  }
end

#nameObject



13
14
15
# File 'lib/rubino/tools/webfetch_tool.rb', line 13

def name
  "webfetch"
end

#risk_levelObject



45
46
47
# File 'lib/rubino/tools/webfetch_tool.rb', line 45

def risk_level
  :low
end