ask-web-fetch 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f73de0a29e2d37986a2b05a930640143f5566011782b5d68eed318bd82db746
4
- data.tar.gz: 86ee4e5a800bf7fa67df0a652f40f0058ba5e1c1fa00e77a63b737017e61fbf0
3
+ metadata.gz: efa999aac8d4321c2e8e6d463ace6c3f5ec5e95a62973ad06593c4714e1ffab1
4
+ data.tar.gz: 9a9e59e8da81bb4238bf1a08b0ba84634553dfd3caac99763a7bb52a54d9ac6e
5
5
  SHA512:
6
- metadata.gz: 9b3fe951669c892269d18304d4242786637df6b4f1ddd39aa4bfbc70d2241f90193701665f9141f5c7e816ba12e1a7bd5c48b98d2f0748ce1e093cfc70c5cd16
7
- data.tar.gz: f372adee62b1ab72695509aa6bac61d105a9dc64e5209d368273c8667fc62145075b978bd572b426bd54a42770a31f0ff192245f9f37b8f9c1c9e121a3fa0360
6
+ metadata.gz: af1e312f91b9e5ea72679b7e877232cc3e4e9639b3fdf3e98291810377a450a5ce180bb4664ca651c8ccd2084220632890da92fe4eaf8c1ca472e6ba464d60ff
7
+ data.tar.gz: 3951989986d476f6bc008712e6451ccb148c9fbe33537544061486d15c79443e0368dd668ef40b35287173ad41f569fc519130a9cb5368e78da16eafbcdf2c91
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ask-tools'
4
+
5
+ module Ask
6
+ module Tools
7
+ # The native agent tool for web fetch — the Ask::Tool framing of the
8
+ # library. Consumed WITHOUT MCP by agent frameworks (ask-agent's
9
+ # `tool: :web_fetch`, ask-app-server, llm-proxy) that resolve tools
10
+ # from the Ask::Tools registry. It is a pure adapter: the capability
11
+ # (chain, collapse, format) lives in Ask::WebFetch, and this file is
12
+ # loaded only when ask-tools is present (see lib/ask/web_fetch.rb), so
13
+ # the library itself never depends on it.
14
+ class WebFetch < Ask::Tool
15
+ # Chain configuration delegates to the library — swap or extend
16
+ # backends here or via Ask::WebFetch.backends.
17
+ def self.backends
18
+ Ask::WebFetch.backends
19
+ end
20
+
21
+ def self.backends=(chain)
22
+ Ask::WebFetch.backends = chain
23
+ end
24
+
25
+ description 'Fetch a URL and return its content as clean markdown for LLM consumption. ' \
26
+ 'Use this to read web pages, articles, and documentation.'
27
+
28
+ params(
29
+ type: 'object',
30
+ properties: {
31
+ url: { type: 'string', description: 'The URL to fetch' },
32
+ max_chars: { type: 'integer', description: 'Maximum number of characters to return (default 20000)' }
33
+ },
34
+ required: ['url']
35
+ )
36
+
37
+ def execute(url:, max_chars: Ask::WebFetch::DEFAULT_MAX_CHARS)
38
+ Ask::Result.ok(data: Ask::WebFetch.fetch(url, max_chars: max_chars))
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ Ask::Tools.register(Ask::Tools::WebFetch)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module WebFetch
5
- VERSION = '0.7.0'
5
+ VERSION = '0.7.1'
6
6
  end
7
7
  end
data/lib/ask/web_fetch.rb CHANGED
@@ -10,6 +10,19 @@ require_relative 'web_fetch/backends/crawl4ai'
10
10
  require_relative 'web_fetch/backends/jina'
11
11
  require_relative 'web_fetch/backends/browser'
12
12
 
13
+ # The native agent tool (Ask::Tools::WebFetch) is an OPTIONAL integration:
14
+ # it loads and registers only when ask-tools is present. The library works
15
+ # standalone — backend-only consumers (crawlers, pipelines) pay nothing —
16
+ # while agent frameworks (ask-agent, ask-app-server, llm-proxy) all ship
17
+ # ask-tools and get the registry tool with no extra step. Only the
18
+ # ask-tools miss is swallowed; any other LoadError is real.
19
+ begin
20
+ require 'ask-tools'
21
+ require_relative 'web_fetch/tool'
22
+ rescue LoadError => e
23
+ raise unless e.path == 'ask-tools'
24
+ end
25
+
13
26
  module Ask
14
27
  # Fetches a URL and returns its content as clean markdown for LLM
15
28
  # consumption. The capability layer: a pluggable backend chain, a
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-web-fetch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto
@@ -107,6 +107,20 @@ dependencies:
107
107
  - - "~>"
108
108
  - !ruby/object:Gem::Version
109
109
  version: '3.26'
110
+ - !ruby/object:Gem::Dependency
111
+ name: ask-tools
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0.1'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0.1'
110
124
  description: 'Fetches a URL and converts its content to clean markdown for LLM consumption.
111
125
  A pluggable backend chain: pure Ruby httpx + Nokogiri + reverse_markdown by default,
112
126
  a Jina Reader fallback for JS-rendered or blocked pages, and a real-Chrome fallback
@@ -133,6 +147,7 @@ files:
133
147
  - lib/ask/web_fetch/http.rb
134
148
  - lib/ask/web_fetch/markdown.rb
135
149
  - lib/ask/web_fetch/noise_filter.rb
150
+ - lib/ask/web_fetch/tool.rb
136
151
  - lib/ask/web_fetch/version.rb
137
152
  homepage: https://github.com/ask-rb/ask-web-fetch
138
153
  licenses: